-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Feature] Return "engines" check #1177
Comments
@arcanis if you'll provide some basic thoughts, i can try to implement this as plugin. |
Setting |
Hi there! So the problem was that yarn2 doesn't respect If it was intentional please point it out in the docs - because I couldn't find any information about it... P.S. I subscribed to this issue - and if it resolves - gonna notify our team to migrate again. |
We've been having the same issues as @bekliev, we have numerous projects requiring numerous Node/Yarn configurations and moving to Yarn2 we are now seeing our devs spending time trying to figure out what a project won't build. Though we are now aware of the problem it still catches our devs out from time to time, simply enforcing the required engines in package.json would save a lot of time and trouble. In the meantime I just made a plugin in module.exports = {
name: `plugin-requirements-check`,
factory: require => {
const semver = require('semver');
const { readFileSync } = require('fs');
const data = readFileSync('package.json');
const { engines } = JSON.parse(data.toString());
const { node } = engines;
return {
default: {
hooks: {
validateProject(project) {
if (!semver.satisfies(process.version, node)) {
throw new Error(
`The current node version ${process.version} does not satisfy the required version ${node}.`,
);
}
},
},
},
};
},
}; This produces the following if the node version doesn't satisfy the engines in package.json: ➤ YN0000: ┌ Project validation
➤ YN0001: │ Error: The current node version v12.20.0 does not satisfy the required version >=14.0.0.
at validateProject (/xxx/xxx/xxx/.devutils/plugin-requirements-check.js:14:21)
at W.triggerHook (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:322167)
at async /xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:383280
at async f.startTimerPromise (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:396400)
at async ie.install (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:383199)
at async /xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:109983
at async Function.start (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:395097)
at async Ue.execute (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:109879)
at async Ue.validateAndExecute (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:2:666150)
at async Y.run (/xxx/xxx/xxx/.yarn/releases/yarn-berry.cjs:17:3854)
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 0s 6ms Hope this helps 👍 |
I made a repo here:
|
Ha-ha, funny! I've also made a very similar plugin couple of days back. |
Thanks @devoto13. I've decided to use your plug-in implementation since it has recent updates and seems to have the oldest git commit history. |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
@nedkelly very helpful! I modified it to also run on all scripts and check .nvmrc:
|
Your code contains an error that could lead to very serious problems (we've already encountered one).
The code needs to be changed as follows: validateProject(project) {
checksemver();
},
async wrapScriptExecution(executor) {
checksemver();
- return new Promise(executor);
+ return executor;
}, |
@DiFuks you're completely right and i have had that problem myself and corrected my code in my project but forgot all about this issue. I have updated my post now. |
Describe the user story
Simple: I want to pin my node version (and, may be, in future - yarn version) via engines entry in package.json or, may be, in .yarnrc.yml
For example, deps builds are broken at node 12, but on node 10 all is OK. I want to ensure what every who try to start my project cannot use node 12.
Describe the solution you'd like
Just restore old behavior from 1.x, maybe as a (optional) plugin.
Describe the drawbacks of your solution
IDK.
Describe alternatives you've considered
IDK
Additional context
IDK
The text was updated successfully, but these errors were encountered: