-
Notifications
You must be signed in to change notification settings - Fork 103
/
yarn.config.cjs
66 lines (56 loc) · 1.79 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
63
64
65
66
//
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
function enforceConsistentDependencies ({ 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)
}
}
}
function enforceConsistentVueUseVersions({ Yarn }) {
const vueUsePackages = Yarn.dependencies().filter(dep => dep.ident.startsWith('@vueuse/'));
if (vueUsePackages.length > 0) {
const firstVersion = vueUsePackages[0].range
for (const dependency of vueUsePackages) {
dependency.update(firstVersion)
}
}
}
function enforceWorkspaceDependencies({ Yarn }) {
for (const dependency of Yarn.dependencies()) {
if (!Yarn.workspace({ ident: dependency.ident })) {
continue
}
dependency.update('workspace:^')
}
}
function enforceFieldsOnAllWorkspaces({ Yarn }, fields) {
for (const workspace of Yarn.workspaces()) {
for (const [field, value] of Object.entries(fields)) {
workspace.set(field, typeof value === 'function' ? value(workspace) : value)
}
}
}
module.exports = {
async constraints (ctx) {
enforceConsistentDependencies(ctx)
enforceConsistentVueUseVersions(ctx)
enforceWorkspaceDependencies(ctx)
enforceFieldsOnAllWorkspaces(ctx, {
license: 'Apache-2.0',
'engines.node': '^22.7.0',
'packageManager': '[email protected]',
'repository.type': 'git',
'repository.url': 'git+https://github.com/gardener/dashboard.git',
'repository.directory': workspace => workspace.cwd,
})
}
}