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

Print reason when node engine does not match #1424

Merged
merged 7 commits into from
Jul 7, 2024

Conversation

rbnayax
Copy link
Contributor

@rbnayax rbnayax commented Jun 8, 2024

Fix: #1422

@rbnayax rbnayax marked this pull request as draft June 8, 2024 17:47
@rbnayax rbnayax marked this pull request as ready for review June 8, 2024 18:32
@rbnayax
Copy link
Contributor Author

rbnayax commented Jun 8, 2024

@raineorshine would appreciate your CR

@raineorshine raineorshine changed the title feat: when packages are filter due to engine not matching, we need to print it out, just like we do in peer checks Print reason when node engine does not match Jun 12, 2024
src/package-managers/npm.ts Outdated Show resolved Hide resolved
Comment on lines 15 to 16
engines?: Index<VersionSpec>
engines?: Index<Version | undefined>
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this is correct. If a package does not define a node engine, it should be omitted from the engines object. Explicit undefined should not be allowed.

Copy link
Owner

Choose a reason for hiding this comment

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

VersionSpec (i.e. a version range) is correct, not Version (an exact version).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you don't put undefined, the any access to the engines object will produce a type of VersionSpec which is not correct... engines.foo is not a string, but a sring | undefined this is just more safe, so when I access engines.node I will know to make sure it is not undefined.

Copy link
Owner

Choose a reason for hiding this comment

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

I think I hear what you are saying, but I don't see any indication that explicit undefined, i.e. engines: { node: undefined } }, is part of the manifest spec. The purpose of the PackageFile type is to represent the expected type of a package.json file. If there is no engine for a given key, then the key should be omitted from the engines object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lets agree to disagree :-) changed

src/types/Options.ts Outdated Show resolved Hide resolved
if (!options.nodeEngineVersion) return {}
const optionsEnginesNodeMinVersion = minVersion(options.nodeEngineVersion)?.version
if (!optionsEnginesNodeMinVersion) return {}
const [upgradedLatestVersions] = await upgradePackageDefinitions(current, {
Copy link
Owner

Choose a reason for hiding this comment

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

It's unfortunate that we have to call upgradePackageDefinitions again, since it was already called to produce upgraded. Optimizing this probably involves larger changes to the upgrade pipeline though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I first tried to see how I can overcome it, but it requires major changes. If we ever do go ahead and make those changes, we can also not run the upgrades again for the ignored upgrades due to peer dependencies...

src/lib/getIgnoredUpgradesDueToEnginesNode.ts Outdated Show resolved Hide resolved
src/lib/getIgnoredUpgradesDueToEnginesNode.ts Outdated Show resolved Hide resolved
@rbnayax
Copy link
Contributor Author

rbnayax commented Jun 15, 2024

@raineorshine would appreciate your CR

* @param version
* @returns Promised engines collection
*/
export const getEngines = async (
Copy link
Owner

Choose a reason for hiding this comment

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

This function doesn't do enough to justify it being factored out. Instead, call fetchPartialPackument directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

call it from where? fetchPartialPackument is internal to npm implementation, and getEngines is part of the package managers interface that is being used in the business logic. Where do you suggest I inline it and how?

Copy link
Owner

Choose a reason for hiding this comment

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

Good point, I did not realize it was not exported. Let's leave this as-is then. Thanks.

@raineorshine raineorshine merged commit 9694c21 into raineorshine:main Jul 7, 2024
7 checks passed
@rbnayax rbnayax deleted the 1422 branch July 7, 2024 17:17
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.

when packages are filter due to engine not matching, we need to print it out, just like we do in peer checks
2 participants