reactium
Version:
A CLI for creating Reactium / Actinium projects.
61 lines (46 loc) • 1.66 kB
JavaScript
/**
* -----------------------------------------------------------------------------
* Imports
* -----------------------------------------------------------------------------
*/
import GENERATOR from './generator.js';
const { message, op } = arcli;
export const NAME = 'install [name]';
const DESC = 'Install an Actinium or Reactium Plugin.';
const CANCELED = 'Action canceled!';
const HELP = () =>
console.log(`
Example:
$ arcli install @atomic-reactor/admin
For devops purposes you can call:
$ arcli install
This will install any previously installed plugins registered in the package.json > reactiumDependencies and package.json actiniumDependencies
`);
const ACTION = ({ name, opt, props }) => {
const ovr = FLAGS_TO_PARAMS({ opt });
const params = { ...ovr, name };
return GENERATOR({ params, props })
.then(() => process.exit())
.catch(err =>
message(op.get(err, 'message', op.get(err, 'msg', CANCELED))),
);
};
const FLAGS = ['app', 'npm', 'server'];
const FLAGS_TO_PARAMS = ({ opt = {} }) =>
FLAGS.reduce((obj, key) => {
let val = opt[key];
val = typeof val === 'function' ? undefined : val;
if (val) {
obj[key] = val;
}
return obj;
}, {});
export const COMMAND = ({ program, props }) =>
program
.command(NAME)
.description(DESC)
.action((name, opt) => ACTION({ name, opt, props }))
.option('-a, --app [app]', 'Actinium app ID')
.option('-s, --server [server]', 'Actinium server URL')
.option('--no-npm [npm]', 'Skip the `npm install`')
.on('--help', HELP);