-
-
Notifications
You must be signed in to change notification settings - Fork 613
Expand file tree
/
Copy pathyarn.config.cjs
More file actions
49 lines (42 loc) · 1.32 KB
/
yarn.config.cjs
File metadata and controls
49 lines (42 loc) · 1.32 KB
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
45
46
47
48
49
// @ts-check
/** @type {import('@yarnpkg/types')} */
const { defineConfig } = require(`@yarnpkg/types`);
/**
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Context} Context
*/
const OPTIONAL_DEPS = [
'electron-wix-msi',
'electron-installer-dmg',
'electron-installer-redhat',
'electron-installer-snap',
'electron-installer-debian',
'electron-windows-msix',
'electron-windows-store',
'electron-winstaller',
'@malept/electron-installer-flatpak',
];
/**
* 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`) continue;
// HACK: the `Dependency` type doesn't contain information about optionalDependencies
// so skip them for now
if (OPTIONAL_DEPS.includes(dependency.ident)) 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);
},
});