Skip to content

Commit

Permalink
Add yarn plugin to check node and yarn version
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Apr 19, 2022
1 parent 9e2bb3c commit f23a13f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict = true
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-engines.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-engines",
factory: function (require) {
var plugin=(()=>{var l=Object.create,c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=e=>c(e,"__esModule",{value:!0});var t=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var g=(e,o)=>{for(var r in o)c(e,r,{get:o[r],enumerable:!0})},P=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of u(o))!h.call(e,s)&&s!=="default"&&c(e,s,{get:()=>o[s],enumerable:!(r=v(o,s))||r.enumerable});return e},i=e=>P(y(c(e!=null?l(m(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var k={};g(k,{default:()=>$});var n=i(t("@yarnpkg/core")),p=i(t("@yarnpkg/fslib")),d=i(t("fs")),f=i(t("path")),a=i(t("semver")),N={hooks:{validateProject:e=>{let o=(0,d.readFileSync)((0,f.resolve)(p.npath.fromPortablePath(e.cwd),"package.json"),"utf-8"),{engines:r={}}=JSON.parse(o);if(r.node!=null&&!(0,a.satisfies)(process.version,r.node))throw new n.ReportError(n.MessageName.UNNAMED,`The current Node version ${process.version} does not satisfy the required version ${r.node}.`);if(r.yarn!=null&&!(0,a.satisfies)(n.YarnVersion,r.yarn))throw new n.ReportError(n.MessageName.UNNAMED,`The current Yarn version v${n.YarnVersion} does not satisfy the required version ${r.yarn}.`)},setupScriptEnvironment:async e=>{let o=(0,d.readFileSync)((0,f.resolve)(p.npath.fromPortablePath(e.cwd),"package.json"),"utf-8"),{engines:r={}}=JSON.parse(o);r.node!=null&&!(0,a.satisfies)(process.version,r.node)&&(console.error(`The current Node version ${process.version} does not satisfy the required version ${r.node}.`),process.exit(1)),r.yarn!=null&&!(0,a.satisfies)(n.YarnVersion,r.yarn)&&(console.error(`The current Yarn version v${n.YarnVersion} does not satisfy the required version ${r.yarn}.`),process.exit(1))}}},$=N;return k;})();
return plugin;
}
};
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"

yarnPath: .yarn/releases/yarn-3.2.0.cjs
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
"scripts": {
"postinstall": "husky install",
"build": "turbo run build",
"prebuild": "echo \"use yarn build\" & exit 1",
"build:services": "turbo run build --filter=rocketchat-services...",
"build:ci": "turbo run build:ci",
"testunit": "turbo run testunit",
"dev": "turbo run dev --filter=@rocket.chat/meteor...",
"predev": "echo \"use yarn dev\" & exit 1",
"lint": "turbo run lint",
"prelint": "echo \"use yarn lint\" & exit 1",
"storybook": "yarn workspace @rocket.chat/meteor run storybook"
},
"devDependencies": {
Expand All @@ -34,8 +37,9 @@
},
"homepage": "https://github.com/RocketChat/Rocket.Chat#readme",
"engines": {
"npm": ">=7.0.0",
"node": ">=14.0.0 <15"
"yarn": "3.2.0",
"node": ">=14.0.0 <15",
"npm": "Use yarn instead"
},
"packageManager": "yarn@3.2.0",
"houston": {
Expand Down

0 comments on commit f23a13f

Please sign in to comment.