@onereach/orest-input-cli
Version:
The tool for creating, serving, and publishing OREST Inputs
112 lines (95 loc) • 3.59 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 { types: packageTypes } = require('../lib/packageType');
const packageTypesStr = Object.keys(packageTypes).join(', ');
const program = new Command();
updateNotifier({ pkg: packageJson }).notify();
if (pkgVersion) {
program.version(pkgVersion);
}
function collect(value, previous = []) {
return [...previous, ...value.split(',')];
}
program
.command('create')
.description('create orest-input')
.argument('[destination]', 'folder to create')
.option('-t, --type <type>', `package type [${packageTypesStr}]`)
.action((destination, options) => {
require('../lib/create')(destination, options);
});
program
.command('add-tests')
.description('add unit-tests to orest-input')
.action(() => {
const yeoman = require('yeoman-environment');
const env = yeoman.createEnv();
env.register(
require.resolve('../lib/generators/tests/index.js'),
'yo:create'
);
env.run(`yo:create`);
});
program
.command('serve')
.description('serve orest-input')
.option('--port <port>', 'port', 9000)
.action(options => {
require('../lib/serve')(options);
});
program
.command('publish')
.description('publish orest-input')
.option('-p, --profile <name>', 'profile name', 'default')
.option('-s, --sandbox', 'upload to sandbox')
.option('-t, --type <type>', `package type [${packageTypesStr}]`)
.option('-b, --build', 'run build script before publish')
.option('-d, --directory [directory]', 'select directory', collect)
.option('--keep-artifacts [keepArtifacts]', 'keep the `npm pack` artifact')
.option('--user-token [userToken]', 'user token')
.option('--store-api-url [storeApiUrl]', 'Store API URL')
.action(options => {
require('../lib/publish')(options);
});
program
.command('status')
.description('update package status (default: "BETA")')
.option('-p, --profile <name>', 'profile name', 'default')
.option('-t, --type <type>', `package type [${packageTypesStr}]`)
.option('--all', 'show all version status')
.option('--pde', 'set status on PDE')
.option('--release', 'set status to the "RELEASED"')
.option('--deprecate', 'set status to the "DEPRECATED"')
.option('-d, --directory [directory]', 'select directory', collect)
.option('--user-token [userToken]', 'user token')
.option('--store-api-url [storeApiUrl]', 'Store API URL')
.action(options => {
require('../lib/status')(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
.command('share')
.description('share package with account')
.option('-p, --profile <name>', 'profile name', 'default')
.option('-t, --type <type>', `package type [${packageTypesStr}]`)
.option('-d, --directory [directory]', 'select directory', collect)
.option('-r, --remove <uuid>', 'remove account id')
.option('-a, --add <uuid>', 'add account id')
.option('-l, --list', 'show all account ids')
.option('--remove-all', 'remove all account members ids from sharing')
.action(options => {
require('../lib/share')(options);
});
program.addHelpText('after', `\nConfig: ${CONFIG_PATH}`);
program.parse(process.argv);