-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
Copy pathyarn.config.cjs
31 lines (27 loc) · 996 Bytes
/
yarn.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// @ts-check
/** @type {import('@yarnpkg/types')} */
const { defineConfig, Yarn } = require('@yarnpkg/types');
const semver = require('semver');
const MONOREPO_ROOT_WORKSPACE = 'twenty';
module.exports = defineConfig({
async constraints({ Yarn }) {
const rootWorkspace = Yarn.workspace({ ident: MONOREPO_ROOT_WORKSPACE });
if (!rootWorkspace) {
throw new Error(
`Should never occur, ${MONOREPO_ROOT_WORKSPACE} workspace not found`,
);
}
const requiredNodeVersion = rootWorkspace.manifest.engines?.node;
if (!requiredNodeVersion) {
throw new Error(
`Should never occur, ${requiredNodeVersion} could not find node range in engines manifest`,
);
}
const currentNodeVersion = process.version;
if (!semver.satisfies(currentNodeVersion, requiredNodeVersion)) {
throw new Error(
`Node version ${currentNodeVersion} doesn't match the required version, please use ${requiredNodeVersion}`,
);
}
},
});