-
Notifications
You must be signed in to change notification settings - Fork 4
/
.versionrc.js
65 lines (62 loc) · 1.31 KB
/
.versionrc.js
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
function isMelodieDep(name) {
return name?.startsWith('@melodie') || name?.startsWith('melodie')
}
function updateDeps(package, version) {
if (isMelodieDep(package.name)) {
package.version = version
}
for (const deps of [
'dependencies',
'optionalDependencies',
'devDependencies',
'packages',
'requires'
].filter(name => typeof package[name] === 'object')) {
for (const dep in package[deps]) {
if (deps === 'packages' || isMelodieDep(dep)) {
if (typeof package[deps][dep] === 'object') {
updateDeps(package[deps][dep], version)
} else {
package[deps][dep] = version
}
}
}
}
return package
}
const updater = {
readVersion(contents) {
return JSON.parse(contents).version
},
writeVersion(contents, version) {
return JSON.stringify(updateDeps(JSON.parse(contents), version))
}
}
module.exports = {
bumpFiles: [
{
filename: 'package.json',
updater
},
{
filename: 'package-lock.json',
updater
},
{
filename: 'common/core/package.json',
updater
},
{
filename: 'common/ui/package.json',
updater
},
{
filename: 'apps/desktop/package.json',
updater
},
{
filename: 'apps/site/package.json',
updater
}
]
}