-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibs-update.js
61 lines (57 loc) · 1.38 KB
/
libs-update.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
const {readFileSync, writeFileSync} = require('fs');
const appVer = '0.0.43'
const versions = [
{
packages: [
"@ngx-k/form-builder",
"@ngx-k/form-builder-bootstrap",
"@ngx-k/auth",
"@ngx-k/core",
"@ngx-k/components",
"@ngx-k/components-bootstrap",
],
version: "^" + appVer
},
{
packages: ["@auth0/angular-jwt"],
version: "^5.0.1"
},
{
packages: ["@angular/cdk"],
version: "^11.0.0"
},
{
packages: ["@angular/common", "@angular/core", "@angular/animations", "@angular/router", "@angular/forms"],
version: "^11.0.1"
}
]
const getLibraries = () => {
const items = [];
const data = JSON.parse(readFileSync('angular.json')).projects;
Object.values(data).forEach((value, key) => {
if (value.projectType == 'library')
items.push(value.root);
})
return items;
}
const getPackageVersion = (name) => {
for (let version of versions) {
if (version.packages.indexOf(name) >= 0)
return version.version;
}
return null;
}
const updatePackageJson = (path) => {
const data = JSON.parse(readFileSync(path + '/package.json'));
data.version = appVer;
for (let key of Object.keys(data.peerDependencies)) {
const ver = getPackageVersion(key);
if (ver)
data.peerDependencies[key] = ver;
}
writeFileSync(path + '/package.json', JSON.stringify(data, '\t', 4))
}
for (let library of getLibraries()) {
updatePackageJson(library)
}
console.log("packages updated ...")