-
Notifications
You must be signed in to change notification settings - Fork 0
/
yarn.config.cjs
62 lines (55 loc) · 1.76 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// @ts-check
/** @type {import('@yarnpkg/types')} */
// @ts-expect-error - Weird issue with cjs
const { defineConfig } = require(`@yarnpkg/types`);
/**
* 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 {import('@yarnpkg/types').Yarn.Constraints.Context} context
*/
const enforceConsistentDependenciesAcrossTheProject = ({ Yarn }) => {
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);
}
}
};
const packageInfo = {
private: true,
repository: {
type: "git",
url: "https://github.com/UKDanceBlue/monorepo.git",
},
license: "MPL-2.0",
author: {
name: "University of Kentucky DanceBlue Tech Committee",
email: "[email protected]",
url: "https://danceblue.org",
},
};
/**
* @param {import('@yarnpkg/types').Yarn.Constraints.Context} context
*/
const enforcePackageInfo = ({ Yarn }) => {
for (const w of Yarn.workspaces()) {
w.set(`license`, packageInfo.license);
w.set("private", packageInfo.private);
w.set(["repository", "type"], packageInfo.repository.type);
w.set(["repository", "url"], packageInfo.repository.url);
w.set(["author", "name"], packageInfo.author.name);
w.set(["author", "email"], packageInfo.author.email);
w.set(["author", "url"], packageInfo.author.url);
}
};
module.exports = defineConfig({
constraints: (ctx) => {
enforceConsistentDependenciesAcrossTheProject(ctx);
enforcePackageInfo(ctx);
return Promise.resolve();
},
});