-
Notifications
You must be signed in to change notification settings - Fork 316
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
base: main
Are you sure you want to change the base?
Conversation
@raineorshine would appreciate your CR |
… print it out, just like we do in peer checks raineorshine#1422
src/package-managers/npm.ts
Outdated
* @param version | ||
* @returns Promised engines collection | ||
*/ | ||
export const getEngines = async (packageName: string, version: Version): Promise<Index<Version | undefined>> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use fetchPartialPackument
instead of doing a separate spawn. fetchPartialPackument
uses streaming for performance, and is already used in other places to fetch node engines.
You might need to add a version
param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/types/PackageFile.ts
Outdated
engines?: Index<VersionSpec> | ||
engines?: Index<Version | undefined> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
src/types/Options.ts
Outdated
nodeEngineVersion?: VersionSpec | ||
nodeEngineVersion?: Version |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (!options.nodeEngineVersion) return {} | ||
const optionsEnginesNodeMinVersion = minVersion(options.nodeEngineVersion)?.version | ||
if (!optionsEnginesNodeMinVersion) return {} | ||
const [upgradedLatestVersions] = await upgradePackageDefinitions(current, { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
import upgradePackageDefinitions from './upgradePackageDefinitions' | ||
|
||
/** Checks if package.json min node version satisfies given package engine.node spec */ | ||
const satisfiesNodeEngine = (enginesNode: Maybe<Version>, optionsEnginesNodeMinVersion: string) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enginesNode
should be Maybe<VersionSpec>
, not Maybe<Version>
, since it can be represented as a version range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
import upgradePackageDefinitions from './upgradePackageDefinitions' | ||
|
||
/** Checks if package.json min node version satisfies given package engine.node spec */ | ||
const satisfiesNodeEngine = (enginesNode: Maybe<Version>, optionsEnginesNodeMinVersion: string) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also reuse satisfiesNodeEngine from filters.ts if you wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could but I would rather not call minVersion a bunch of times and instead call it once and reuse it
… print it out, just like we do in peer checks raineorshine#1422
… print it out, just like we do in peer checks raineorshine#1422
… print it out, just like we do in peer checks raineorshine#1422
@raineorshine would appreciate your CR |
Fix: #1422