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: check if upgrade ignored due to engines fails due to usage of ranges #1447

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

rbnayax
Copy link
Contributor

@rbnayax rbnayax commented Aug 7, 2024

@raineorshine this is a show stopper for us, I would appreciate your input

Comment on lines 14 to 15
async function getEnginesNodeFromRegistry(packageMap: Index<VersionSpec>, options: Options) {
async function getEnginesNodeFromRegistry(packageMap: Index<VersionResult>, options: Options) {
Copy link
Owner

Choose a reason for hiding this comment

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

The function only uses version, so why pass in more information than what is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const enginesNodes = await getEnginesNodeFromRegistry(upgradedLatestVersions, options)
const enginesNodes = await getEnginesNodeFromRegistry(latestVersionResults, options)
Copy link
Owner

Choose a reason for hiding this comment

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

Can you explain this change for me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

upgradedLatestVersions contains specs (^4.0.0) which can't be used to get the info from npm registry. So we use the actual versions instead

Copy link
Owner

@raineorshine raineorshine Aug 8, 2024

Choose a reason for hiding this comment

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

First, in that case, let's change the first param of getEnginesNodeFromRegistry to use Version instead of VersionSpec.

i.e.:

async function getEnginesNodeFromRegistry(packageMap: Index<Version>, options: Options)

(Eventually I hope to change Version to a branded type so that the type system can enforce the distinction between an exact version and a version range.)


Second, latestVersionResults is not filtered the way that upgradedLatestVersions is. Is that desired? I'm thinking we probably don't need to look up the engines node version for dependencies that have already been filtered out due to the minimal or filterResults options. That will just result in extra HTTP requests that will get thrown away.

This filters down latestVersionResults to just the keys in upgradedLatestVersions. You could pass filteredLatestVersionResults to getEnginesNodeFromRegistry instead:

const filteredLatestVersionResults = pickBy(latestVersionResults, (spec, dep) => upgradedLatestVersions[dep])

Copy link
Contributor Author

@rbnayax rbnayax Aug 8, 2024

Choose a reason for hiding this comment

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

I already changed getEnginesNodeFromRegistry to use Version.
Yes, branded types might be the way thought it comes with annoying boilerplate :-(
Yes you are correct, I applied a fix

@raineorshine raineorshine merged commit 369bbdf into raineorshine:main Aug 8, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants