Skip to content

Commit

Permalink
feat: added npm ci release process
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcaufy committed Mar 29, 2020
1 parent 00108ef commit ee2901f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions scripts/npm-ci-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint no-console: 0 */

const path = require('path');
const execa = require('execa');

const version = process.argv[2];
// @wepy/[email protected]

if (!version.startsWith('@wepy')) {
console.log('Do nothing with this version: "' + version + '"');
process.exit();
}
const client = 'npm';
// eslint-disable-next-line no-unused-vars
const [_, packageName, ver] = version.split('@');
const dirname = packageName.split('/')[1];

if (!dirname || !ver) {
console.log('Invalid version: "' + version + '"');
process.exit();
}

const tag = ver.indexOf('alpha') ? 'alpha' : ver.indexOf('beta') ? 'beta' : '';

let publishParams = ['publish'];

if (tag) {
publishParams = publishParams.concat(['--tag', tag]);
}

const cwd = path.join(process.cwd(), 'packages', dirname);

console.log('CWD: ' + cwd);
console.log('EXEC: ' + [client].concat(publishParams).join(' '));

execa(client, publishParams, {
cwd: path.join(process.cwd(), 'packages', dirname)
})
.then(res => {
console.log(res);
})
.catch(e => {
console.log(e);
});

0 comments on commit ee2901f

Please sign in to comment.