-
-
Notifications
You must be signed in to change notification settings - Fork 228
feat: add limited support for devEngines
#643
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
Conversation
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com>
What value of onFail is used by default if its not accepting user input? download? |
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.
How about updating the readme?
In particular, mentioning the onFail behavior and also which takes precedence when both packageManager and devEngines is defined?
| - if set to `warn` or some other value, Corepack will print a warning in case | ||
| of mismatch. | ||
|
|
||
| If the top-level `packageManager` field is missing, Corepack will use the |
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.
This should be the first sentence of this section.
Because it sounds like this devEngines.packageManager is ignored when there is a top level packageManager, right?
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.
No it's never ignored. As said in the first paragraph of this section, if it is defined to something Corepack recognises, it will throw/warn/do nothing (depending of the value of onFail) if the user is trying to use an incompatible package manager (i.e. if the one defined in package.json#packageManager does not match the one defined in package.json#devEngines.packageManager for when the user is using a Corepack shim)
|
|
||
| Unlike `corepack use` this command doesn't take a package manager name nor a | ||
| version range, as it will always select the latest available version from the | ||
| range specified in `devEngines.packageManager.version`, or fallback to the |
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.
What about top-level packageManager?
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.
That's what or fallback to the same major line is for
This comment was marked as resolved.
This comment was marked as resolved.
It's a [standardization effort by the OpenJS Foundation](https://github.com/openjs-foundation/package-metadata-interoperability-collab-space/blob/43e31689ae1fff8c46b617548655a3f60e0c9387/devengines-field-proposal.md) and has been implemented in [NPM 10.9.0](npm/cli#7766) and [Corepack 0.32.0](nodejs/corepack#643).
* Support `devEngines` field in `package.json` It's a [standardization effort by the OpenJS Foundation](https://github.com/openjs-foundation/package-metadata-interoperability-collab-space/blob/43e31689ae1fff8c46b617548655a3f60e0c9387/devengines-field-proposal.md) and has been implemented in [NPM 10.9.0](npm/cli#7766) and [Corepack 0.32.0](nodejs/corepack#643). * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
| onFail: selection.data.devEngines.packageManager.onFail, | ||
| }, | ||
| // Lazy-loading it so we do not throw errors on commands that do not need valid spec. | ||
| getSpec: () => parseSpec(rawPmSpec, path.relative(initialCwd, selection.manifestPath)), |
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.
devEngines allow to specify version ranges - this now causes this to throw an exception if you pass a version like ^10.
IMHO here the enforceExactVersion option of parseSpec needs to be set to false if devEngines is used.
| }); | ||
| }); | ||
|
|
||
| describe(`should accept range in devEngines only if a specific version is provided`, () => { |
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.
This behavior breaks existing projects which only define a range in devEngines (e.g. to make developers all use same major line of the package manager).
Normally that would be somewhat ok as its only your project and you know what you are doing, but this affects a lot of different tools like dependabot that are now broken for projects that not use corepack themself.
This implementation of
devEnginessupport in this PR is limited topackageManageronly, only onepackageManagercan be specified,theEDIT: I've added support for theonFailfield is ignoredonFailfield, supporting the same values as npm.Fixes: #567