-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnpmhelper.js
68 lines (68 loc) · 1.74 KB
/
npmhelper.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
66
67
68
import {readFileSync, writeFileSync} from 'fs';
import {execSync} from 'child_process';
/*
cd plugin-parcel1 && npm publish
cd -
cd plugin-parcel2 && npm publish
cd -
cd plugin-rollup && npm publish
cd -
cd plugin-webpack4 && npm publish
cd -
cd plugin-webpack5 && npm publish
cd -
*/
const dirs = [
'.',
'@runtime-type-inspector/runtime',
'@runtime-type-inspector/transpiler',
'plugin-parcel1',
'plugin-parcel2',
'plugin-rollup',
'plugin-webpack',
'plugin-webpack4',
'plugin-webpack5',
'repl',
];
const newVersion = JSON.parse(readFileSync('package.json', 'utf-8')).version;
for (const dir of dirs) {
const file = `${dir}/package.json`;
const content = readFileSync(file, 'utf8');
const json = JSON.parse(content);
json.version = newVersion;
for (const key in json.dependencies) {
if (key.includes('runtime-type-inspector')) {
json.dependencies[key] = `^${newVersion}`;
}
}
for (const key in json.devDependencies) {
if (key.includes('runtime-type-inspector')) {
json.devDependencies[key] = `^${newVersion}`;
}
}
const newContent = JSON.stringify(json, null, 2) + '\n';
writeFileSync(file, newContent);
}
console.log('# For publishing: ');
console.log('export OTP=123');
for (const dir of dirs) {
const command = [
`cd ${dir}`,
'npm publish --otp=$OTP',
].join(' && ') + '\ncd -';
console.log(command);
}
console.log('# For updating package-lock.json files');
for (const dir of dirs) {
const command = [
`cd ${dir}`,
'npm install',
].join(' && ') + '\ncd -';
console.log(command);
}
for (const dir of dirs) {
const file = `${dir}/package.json`;
const content = readFileSync(file, 'utf8');
const json = JSON.parse(content);
console.log(`Publish ${json.name}@${json.version}`);
}