-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathyarn.config.cjs
28 lines (23 loc) · 901 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
/** @type {import('@yarnpkg/types')} */
const { defineConfig } = require(`@yarnpkg/types`);
// Example here: https://github.com/yarnpkg/berry/blob/master/yarn.config.cjs
/**
* This rule will enforce that a workspace MUST depend on the same version of
* a dependency as the one used by the other workspaces.
*
* @param {Context} context
*/
function enforceConsistentDependenciesAcrossTheProject({ Yarn }) {
for (const dependency of Yarn.dependencies()) {
if (dependency.type === `peerDependencies` || dependency.ident.startsWith('@ssrx/')) continue;
for (const otherDependency of Yarn.dependencies({ ident: dependency.ident })) {
if (otherDependency.type === `peerDependencies`) continue;
dependency.update(otherDependency.range);
}
}
}
module.exports = defineConfig({
constraints: async ctx => {
enforceConsistentDependenciesAcrossTheProject(ctx);
},
});