-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.ts
42 lines (29 loc) · 1.14 KB
/
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
39
40
41
42
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;
});
(() => {
childProcess.execSync(`yarn run lint`, { stdio: 'inherit' });
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, null, 2));
childProcess.execSync(`yarn run lint:fix`, { stdio: 'inherit' });
childProcess.execSync(`git add .`, { stdio: 'inherit' });
childProcess.execSync(`git commit -m "publish version ${newVersion}"`, {
stdio: 'inherit',
});
childProcess.execSync(`git tag ${newVersion}`, { stdio: 'inherit' });
childProcess.execSync(`git push`, { stdio: 'inherit' });
childProcess.execSync(`git push --tags`, { stdio: 'inherit' });
})();