|
@@ -1,19 +1,7 @@
|
1
|
|
-const cp = require('child_process');
|
|
1
|
+const shellUtils = require('shell-utils');
|
2
|
2
|
const p = require('path');
|
3
|
3
|
const semver = require('semver');
|
4
|
4
|
|
5
|
|
-function execSync(cmd) {
|
6
|
|
- cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
|
7
|
|
-}
|
8
|
|
-
|
9
|
|
-function execSyncRead(cmd) {
|
10
|
|
- return String(cp.execSync(cmd, {stdio: ['inherit', 'pipe', 'inherit']})).trim();
|
11
|
|
-}
|
12
|
|
-
|
13
|
|
-function execSyncSilently(cmd) {
|
14
|
|
- cp.execSync(cmd, {stdio: ['ignore', 'ignore', 'ignore']});
|
15
|
|
-}
|
16
|
|
-
|
17
|
5
|
function validateEnv() {
|
18
|
6
|
if (!process.env.CI || !process.env.TRAVIS) {
|
19
|
7
|
throw new Error(`releasing is only available from Travis CI`);
|
|
@@ -33,30 +21,30 @@ function validateEnv() {
|
33
|
21
|
}
|
34
|
22
|
|
35
|
23
|
function setupGit() {
|
36
|
|
- execSyncSilently(`git config --global push.default simple`);
|
37
|
|
- execSyncSilently(`git config --global user.email "${process.env.GIT_EMAIL}"`);
|
38
|
|
- execSyncSilently(`git config --global user.name "${process.env.GIT_USER}"`);
|
39
|
|
- const remoteUrl = new RegExp(`https?://(\\S+)`).exec(execSyncRead(`git remote -v`))[1];
|
40
|
|
- execSyncSilently(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
|
41
|
|
- execSync(`git checkout master`);
|
|
24
|
+ shellUtils.exec.execSyncSilent(`git config --global push.default simple`);
|
|
25
|
+ shellUtils.exec.execSyncSilent(`git config --global user.email "${process.env.GIT_EMAIL}"`);
|
|
26
|
+ shellUtils.exec.execSyncSilent(`git config --global user.name "${process.env.GIT_USER}"`);
|
|
27
|
+ const remoteUrl = new RegExp(`https?://(\\S+)`).exec(shellUtils.exec.execSyncRead(`git remote -v`))[1];
|
|
28
|
+ shellUtils.exec.execSyncSilent(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
|
|
29
|
+ shellUtils.exec.execSync(`git checkout master`);
|
42
|
30
|
}
|
43
|
31
|
|
44
|
32
|
function calcNewVersion() {
|
45
|
|
- const nextTaggedVersion = execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
|
|
33
|
+ const nextTaggedVersion = shellUtils.exec.execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
|
46
|
34
|
console.log(`next tagged version is: ${nextTaggedVersion}`);
|
47
|
35
|
return semver.inc(nextTaggedVersion, 'prerelease');
|
48
|
36
|
}
|
49
|
37
|
|
50
|
38
|
function copyNpmRc() {
|
51
|
39
|
const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
|
52
|
|
- execSync(`cp -rf ${npmrcPath} .`);
|
|
40
|
+ shellUtils.exec.execSync(`cp -rf ${npmrcPath} .`);
|
53
|
41
|
}
|
54
|
42
|
|
55
|
43
|
function tagAndPublish(newVersion) {
|
56
|
44
|
console.log(`new version is: ${newVersion}`);
|
57
|
|
- execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
|
58
|
|
- execSyncSilently(`git push deploy --tags`);
|
59
|
|
- execSync(`npm publish --tag next`);
|
|
45
|
+ shellUtils.exec.execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
|
|
46
|
+ shellUtils.exec.execSyncSilent(`git push deploy --tags`);
|
|
47
|
+ shellUtils.exec.execSync(`npm publish --tag next`);
|
60
|
48
|
}
|
61
|
49
|
|
62
|
50
|
function run() {
|