@onereach/orest-input-cli
Version:
The tool for creating, serving, and publishing OREST Inputs
50 lines (40 loc) • 1.58 kB
JavaScript
const { Command } = require('commander');
const updateNotifier = require('update-notifier');
const packageJson = require('../package.json');
const pkgVersion = require('../lib/util/ownPkgVersion');
const { CONFIG_PATH } = require('../lib/util/config');
const program = new Command();
updateNotifier({ pkg: packageJson }).notify();
if (pkgVersion) {
program.version(pkgVersion);
}
function collect(value, previous = []) {
return [...previous, ...value.split(',')];
}
program
.command('publish')
.description('publish unpacked npm package')
.option('-p, --profile <name>', 'profile name', 'default')
.option('-b, --build', 'run build script before publish')
.option('-d, --directory [directory]', 'select directory', collect)
.option('--from-npm [fromNpm]', 'download tarball from npm')
.option('--keep-artifacts [keepArtifacts]', 'keep the `npm pack` artifact')
.option('--package-name [packageName]', 'npm package name')
.option('--package-version [packageVersion]', 'npm package version')
.option('--user-token [userToken]', 'user token')
.option('--store-api-url [storeApiUrl]', 'Store API URL')
.action(options => {
options.type = 'NPM_UNPACKED';
require('../lib/publishNpm')(options);
});
program
.command('profiles')
.description('manage profiles')
.option('-a, --add <name>', 'add profile')
.option('-r, --remove <name>', 'remove profile')
.action(options => {
require('../lib/profiles/action')(options);
});
program.addHelpText('after', `\nConfig: ${CONFIG_PATH}`);
program.parse(process.argv);