-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.ts
38 lines (26 loc) · 951 Bytes
/
release.ts
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
import * as readlineSync from 'readline-sync';
import * as os from 'os';
import * as fs from 'fs';
import * as childProcess from 'child_process';
process.on('unhandledRejection', (error) => {
throw error;
});
(() => {
const packageJson = JSON.parse(
fs.readFileSync('./package.json', { encoding: 'utf-8' }),
);
const newVersion = readlineSync.question(
`current version - ${packageJson.version}${os.EOL}enter new version${os.EOL}`,
);
if (packageJson.version === newVersion) {
throw new Error('version_is_same');
}
packageJson.version = newVersion;
fs.writeFileSync('./package.json', JSON.stringify(packageJson));
childProcess.execSync(`yarn run lint:fix`);
childProcess.execSync(`git add .`);
childProcess.execSync(`git commit -m "publish version ${newVersion}"`);
childProcess.execSync(`git tag ${newVersion}`);
childProcess.execSync(`git push`);
childProcess.execSync(`git push --tags`);
})();