forked from tldraw/tldraw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyarn.config.cjs
41 lines (32 loc) · 1.08 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
/** @type {import('@yarnpkg/types')} */
const { defineConfig } = require(`@yarnpkg/types`)
/**
* @param {Context} context
*/
function enforceConsistentDependenciesAcrossTheProject({ Yarn }) {
// check non-peer deps:
for (const dependency of Yarn.dependencies()) {
if (dependency.type === 'peerDependencies') continue
for (const otherDependency of Yarn.dependencies({ ident: dependency.ident })) {
if (otherDependency.type === 'peerDependencies') continue
dependency.update(otherDependency.range)
}
}
// check peer deps:
for (const dependency of Yarn.dependencies()) {
if (dependency.type !== 'peerDependencies') continue
for (const otherDependency of Yarn.dependencies({ ident: dependency.ident })) {
if (otherDependency.type !== 'peerDependencies') continue
dependency.update(otherDependency.range)
}
}
for (const workspace of Yarn.workspaces()) {
if (workspace.cwd === '.') continue
workspace.set('packageManager', undefined)
}
}
module.exports = defineConfig({
constraints: async (ctx) => {
enforceConsistentDependenciesAcrossTheProject(ctx)
},
})