feat: declare generated Node.js version - #9
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR updates the base project generator to always scaffold a .nvmrc file pinned to Node.js v24, documents the new file in the generated project layout, and adds a unit test plus a Handlebars template to ensure the Node version is written consistently. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The Node.js version is hardcoded in both the
.nvmrctemplate (v24) and the test ('v24\n'); consider sourcing this from a single shared constant or config (e.g., a central version module orpackage.jsonengines field) to avoid future drift. - Ensure the
.nvmrctemplate matches the exact formatting asserted in tests (including trailing newline), or update the test to read the desired output via the same render helper, so formatting changes in one place don’t silently diverge.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The Node.js version is hardcoded in both the `.nvmrc` template (`v24`) and the test (`'v24\n'`); consider sourcing this from a single shared constant or config (e.g., a central version module or `package.json` engines field) to avoid future drift.
- Ensure the `.nvmrc` template matches the exact formatting asserted in tests (including trailing newline), or update the test to read the desired output via the same render helper, so formatting changes in one place don’t silently diverge.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
In initial rfc @korvin89 asked to remove nvmrc generation step |
|
we can discuss it here, now it is not obvious which node version is should be used. it is described only in https://github.com/gravity-ui/create#requirements, however this might be requirements for this repo. i see no issue about adding .nvmrc, also there is no engines in package.json |
To be honest, I don't remember saying that, but if I did, I don't remember the reasons anymore. It seems like a good suggestion |
| private: true, | ||
| ...(isModule ? {type: 'module'} : {}), | ||
| engines: { | ||
| node: `${NODE_VERSION_MAJOR}.x`, |
There was a problem hiding this comment.
I think we can use just ^${NODE_VERSION_MAJOR}
| @@ -1 +1,2 @@ | |||
| export const DEFAULT_NPM_REGISTRY = 'https://registry.npmjs.org/'; | |||
| export const NODE_VERSION_MAJOR = 24; | |||
There was a problem hiding this comment.
It's better to add additional step with prompt for user to input nodejs version
There was a problem hiding this comment.
I guess we need minimum version here, and maybe add validation
ogonkov
left a comment
There was a problem hiding this comment.
We also need to test validation of passing generic string as --node-version value like --node-version=foobar24
| ), | ||
|
|
||
| 'node-version': z | ||
| .enum(SUPPORTED_NODE_VERSIONS) |
There was a problem hiding this comment.
Let's make it string, i don't think we want to maintain all future Node majors
Summary
.nvmrcfile with Node.jsv24for every scaffolded project"engines": {"node": "24.x"}in the generatedpackage.jsonTesting
npm test(85 tests)npx tsc --noEmitnpm run lint -- --fixnpm run lint:prettiernpm run knipnpm run buildI hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en