|
@@ -3,15 +3,15 @@ const p = require('path');
|
3
|
3
|
const semver = require('semver');
|
4
|
4
|
|
5
|
5
|
function execSync(cmd) {
|
6
|
|
- cp.execSync(cmd, {stdio: ['inherit', 'inherit', 'inherit']});
|
|
6
|
+ cp.execSync(cmd, { stdio: ['inherit', 'inherit', 'inherit'] });
|
7
|
7
|
}
|
8
|
8
|
|
9
|
9
|
function execSyncRead(cmd) {
|
10
|
|
- return String(cp.execSync(cmd, {stdio: ['inherit', 'pipe', 'inherit']})).trim();
|
|
10
|
+ return String(cp.execSync(cmd, { stdio: ['inherit', 'pipe', 'inherit'] })).trim();
|
11
|
11
|
}
|
12
|
12
|
|
13
|
13
|
function execSyncSilently(cmd) {
|
14
|
|
- cp.execSync(cmd, {stdio: ['ignore', 'ignore', 'ignore']});
|
|
14
|
+ cp.execSync(cmd, { stdio: ['ignore', 'ignore', 'ignore'] });
|
15
|
15
|
}
|
16
|
16
|
|
17
|
17
|
function validateEnv() {
|
|
@@ -42,9 +42,14 @@ function setupGit() {
|
42
|
42
|
}
|
43
|
43
|
|
44
|
44
|
function calcNewVersion() {
|
45
|
|
- const nextTaggedVersion = execSyncRead(`npm view ${process.env.npm_package_name}@next version`);
|
46
|
|
- console.log(`next tagged version is: ${nextTaggedVersion}`);
|
47
|
|
- return semver.inc(nextTaggedVersion, 'prerelease');
|
|
45
|
+ const latestVersion = execSyncRead(`npm view ${process.env.npm_package_name}@latest version`);
|
|
46
|
+ console.log(`latest version is: ${latestVersion}`);
|
|
47
|
+ console.log(`package version is: ${process.env.npm_package_version}`);
|
|
48
|
+ if (semver.gt(process.env.npm_package_version, latestVersion)) {
|
|
49
|
+ return semver.inc(process.env.npm_package_version, 'patch');
|
|
50
|
+ } else {
|
|
51
|
+ return semver.inc(latestVersion, 'patch');
|
|
52
|
+ }
|
48
|
53
|
}
|
49
|
54
|
|
50
|
55
|
function copyNpmRc() {
|
|
@@ -56,7 +61,7 @@ function tagAndPublish(newVersion) {
|
56
|
61
|
console.log(`new version is: ${newVersion}`);
|
57
|
62
|
execSync(`npm version ${newVersion} -m "v${newVersion} [ci skip]"`);
|
58
|
63
|
execSyncSilently(`git push deploy --tags`);
|
59
|
|
- execSync(`npm publish --tag next`);
|
|
64
|
+ execSync(`npm publish --tag latest`);
|
60
|
65
|
}
|
61
|
66
|
|
62
|
67
|
function run() {
|