forked from clerk/clerk-sdk-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
35 lines (29 loc) · 1.07 KB
/
publish.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
const { argv } = require('process');
const utils = require('util');
const exec = utils.promisify(require('child_process').exec);
async function publish(publishType) {
if (!publishType || !publishType.match(/major|minor|patch/)) {
console.error(
'Invalid publish type: Available types are major|minor|patch'
);
process.exit(1);
}
try {
/* 1. Make sure the bump type is correct */
await exec(`npm version ${publishType} --git-tag-version=false`);
/* 2. Build and test with the correct version. Building the library will also update the src/info.ts file */
await exec('yarn build');
await exec('yarn test');
/* 3. Git actions */
await exec('git add -A');
await exec(`git commit -am "build: ${require('../package.json').version}"`);
await exec(`git tag -a v${require('../package.json').version} -m 'v${require('../package.json').version}'`);
await exec('git push && git push --tags');
/* 4. Publish to npm */
await exec('npm publish');
} catch (err) {
console.error(err);
process.exit(1);
}
}
publish(argv[2]);