Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: verify @types/node version with registry #32

Merged
merged 2 commits into from
Oct 29, 2024
Merged

Conversation

molisani
Copy link
Member

Resolves #30

Describe your changes
New behavior to check the locally-configured registry for @types/node and only write a version that exists to the package.json for the new project.

The registry URL is pulled from one of two sources:

  • The NPM_CONFIG_REGISTRY environment variable
    • Less common use case, but good to read from an env var if possible
  • Executes NPM_EXECPATH with process.execPath and args config get registry
    • This method works for npm, yarn, and pnpm as all of them set that environment variable and share those command line args (tested this manually)

Once the data is fetched from the registry, there is additional logic to determine if there is an exact or approximate (same major version) version of @types/node available. If not it defaults to the highest published LTS version.

Testing performed
Updated test suite to hit 100% coverage. (Also removed some outdated baselines)

@molisani molisani self-assigned this Oct 25, 2024
@molisani molisani requested a review from a team as a code owner October 25, 2024 17:57
@github-actions github-actions bot added the create-app 📂 Relates to the @stricli/create-app package label Oct 25, 2024
@molisani molisani force-pushed the fix/node-types-version branch from 94866ba to 36741f7 Compare October 25, 2024 18:05
@molisani
Copy link
Member Author

This is a preventative change for future versions of Node.js/@types/node. As such, we hardcode a known maximum and if the version is beneath that we do not have to go through this new logic.

mkubilayk
mkubilayk previously approved these changes Oct 29, 2024
Copy link
Collaborator

@mkubilayk mkubilayk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, it might be nice to bypass this using a --node-version flag but changes look good. I like that more complicated logic only kicks in for super fresh things.

@molisani molisani force-pushed the fix/node-types-version branch from d5c9b34 to e0c376a Compare October 29, 2024 14:10
@molisani molisani requested a review from mkubilayk October 29, 2024 14:22
@molisani molisani merged commit f237e04 into main Oct 29, 2024
3 checks passed
@molisani molisani deleted the fix/node-types-version branch October 29, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-app 📂 Relates to the @stricli/create-app package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check if @types/node is in sync with latest node version in the tutorial
2 participants