-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathyarn.config.cjs
More file actions
67 lines (56 loc) · 2.44 KB
/
yarn.config.cjs
File metadata and controls
67 lines (56 loc) · 2.44 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// @ts-check
const { defineConfig } = require('@yarnpkg/types');
const { name } = require('./package.json');
module.exports = defineConfig({
async constraints({ Yarn }) {
// Make sure all workspaces have type: "module"
for (const workspace of Yarn.workspaces()) {
workspace.set('type', 'module');
// All the vitest dependencies should have the same version as vitest
const vitestDep = Yarn.dependency({ workspace, ident: 'vitest' });
if (vitestDep !== null) {
for (const otherVitestDep of Yarn.dependencies({ workspace })) {
const depName = otherVitestDep.ident;
// Except for the eslint plugin
if (depName.startsWith('@vitest') && depName !== '@vitest/eslint-plugin') {
otherVitestDep.update(vitestDep.range);
}
}
}
}
const [rootWorkspace] = Yarn.workspaces({ ident: name });
// There should not be any resolutions value for js-slang,
// which might be present if you linked js-slang to a local copy
rootWorkspace.set('resolutions.js-slang', undefined);
// Make sure that if the dependency is defined in the root workspace
// that all child workspaces use the same version of that dependency
for (const workspaceDep of Yarn.dependencies({ workspace: rootWorkspace })) {
for (const otherDep of Yarn.dependencies({ ident: workspaceDep.ident })) {
if (otherDep.type === 'peerDependencies') continue;
otherDep.update(workspaceDep.range);
}
}
for (const dep of Yarn.dependencies()) {
// Dependencies that are from this repository should use
// the correct version
if (
dep.ident.startsWith('@sourceacademy/modules') ||
dep.ident.startsWith('@sourceacademy/bundle') ||
dep.ident.startsWith('@sourceacademy/tab')
) {
dep.update('workspace:^');
}
// @types dependencies should be devDependencies, not dependencies
if (dep.ident.startsWith('@types') && dep.type === 'dependencies') {
dep.workspace.set(`devDependencies.${dep.ident}`, dep.range);
dep.update(undefined);
}
}
// Repotools should not be allowed to depend on any other packages in this
// repository
const [repotools] = Yarn.workspaces({ ident: '@sourceacademy/modules-repotools' });
for (const dep of Yarn.dependencies({ workspace: repotools })) {
if (dep.ident.startsWith('@sourceacademy/modules')) dep.update(undefined);
}
}
});