chore: restrict node version (#3120)

This commit is contained in:
Alex Yang 2023-07-10 14:19:59 +08:00 committed by GitHub
parent 8bcc4d6a57
commit 05291a8a36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 1 deletions

1
.npmrc
View File

@ -1,2 +1,3 @@
shell-emulator=true
electron_mirror="https://cdn.npmmirror.com/binaries/electron/"
engine-strict=true

View File

@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-after-install",
factory: function (require) {
var plugin=(()=>{var g=Object.create,r=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var I=t=>r(t,"__esModule",{value:!0});var i=t=>{if(typeof require!="undefined")return require(t);throw new Error('Dynamic require of "'+t+'" is not supported')};var h=(t,o)=>{for(var e in o)r(t,e,{get:o[e],enumerable:!0})},w=(t,o,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of C(o))!y.call(t,n)&&n!=="default"&&r(t,n,{get:()=>o[n],enumerable:!(e=x(o,n))||e.enumerable});return t},a=t=>w(I(r(t!=null?g(k(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var j={};h(j,{default:()=>b});var c=a(i("@yarnpkg/core")),m={afterInstall:{description:"Hook that will always run after install",type:c.SettingsType.STRING,default:""}};var u=a(i("clipanion")),d=a(i("@yarnpkg/core"));var p=a(i("@yarnpkg/shell")),l=async(t,o)=>{var f;let e=t.get("afterInstall"),n=!!((f=t.projectCwd)==null?void 0:f.endsWith(`dlx-${process.pid}`));return e&&!n?(o&&console.log("Running `afterInstall` hook..."),(0,p.execute)(e,[],{cwd:t.projectCwd||void 0})):0};var s=class extends u.Command{async execute(){let o=await d.Configuration.find(this.context.cwd,this.context.plugins);return l(o,!1)}};s.paths=[["after-install"]];var P={configuration:m,commands:[s],hooks:{afterAllInstalled:async t=>{if(await l(t.configuration,!0))throw new Error("The `afterInstall` hook failed, see output above.")}}},b=P;return j;})();
return plugin;
}
};

View File

@ -15,5 +15,9 @@ plugins:
spec: '@yarnpkg/plugin-version'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-after-install.cjs
spec: 'https://raw.githubusercontent.com/mhassan1/yarn-plugin-after-install/v0.3.1/bundles/@yarnpkg/plugin-after-install.js'
yarnPath: .yarn/releases/yarn-3.6.0.cjs
afterInstall: node ./scripts/check-version.mjs && yarn i18n-codegen gen && yarn husky install

View File

@ -13,6 +13,9 @@
"tests/kit",
"tests/affine-legacy/*"
],
"engines": {
"node": ">=18.16.1 <19.0.0"
},
"scripts": {
"dev": "dev-web",
"dev:electron": "yarn workspace @affine/electron dev:app",
@ -37,7 +40,6 @@
"test": "ENABLE_PRELOADING=false vitest --run",
"test:ui": "ENABLE_PRELOADING=false vitest --ui",
"test:coverage": "ENABLE_PRELOADING=false vitest run --coverage",
"postinstall": "i18n-codegen gen && husky install",
"notify": "node scripts/notify.mjs",
"circular": "madge --circular --ts-config ./tsconfig.json ./apps/web/src/pages/**/*.tsx",
"typecheck": "tsc -b tsconfig.json --diagnostics"
@ -97,6 +99,7 @@
"nx-cloud": "latest",
"nyc": "^15.1.0",
"prettier": "^3.0.0",
"semver": "^7.5.4",
"serve": "^14.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",

13
scripts/check-version.mjs Normal file
View File

@ -0,0 +1,13 @@
import semver from 'semver';
import packageJson from '../package.json' assert { type: 'json' };
const { engines } = packageJson;
const version = engines.node;
if (!semver.satisfies(process.version, version)) {
console.log(
`Required node version ${version} not satisfied with current version ${process.version}.`
);
process.exit(1);
}

View File

@ -368,6 +368,7 @@ __metadata:
nx-cloud: latest
nyc: ^15.1.0
prettier: ^3.0.0
semver: ^7.5.4
serve: ^14.2.0
ts-node: ^10.9.1
typescript: ^5.1.6
@ -27705,6 +27706,17 @@ __metadata:
languageName: node
linkType: hard
"semver@npm:^7.5.4":
version: 7.5.4
resolution: "semver@npm:7.5.4"
dependencies:
lru-cache: ^6.0.0
bin:
semver: bin/semver.js
checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3
languageName: node
linkType: hard
"semver@npm:~7.0.0":
version: 7.0.0
resolution: "semver@npm:7.0.0"