-
Notifications
You must be signed in to change notification settings - Fork 1
/
yarn.config.cjs
44 lines (37 loc) · 1.3 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
// @ts-check
const { defineConfig } = require(`@yarnpkg/types`);
/** @type {import('./package.json') & { devDependencies?: Record<string, string>, dependencies?: Record<string, string>, peerDependencies?: Record<string, string> }} */
const pkg = require("./package.json");
const config = defineConfig({
async constraints({ Yarn }) {
for (const workspace of Yarn.workspaces()) {
if (workspace.cwd !== ".") {
const dependencies = Yarn.dependencies({
workspace,
});
for (const dep of dependencies) {
const rootVersion =
pkg.dependencies?.[dep.ident] || pkg.devDependencies?.[dep.ident];
if (rootVersion) {
dep.update(rootVersion);
continue;
}
if (dep.type === "devDependencies") {
const peerVersion = dependencies.find(
(d) => d.ident === dep.ident && d.type === "peerDependencies"
)?.range;
if (peerVersion) {
dep.update(peerVersion);
continue;
}
}
}
}
}
},
});
module.exports = config;