dmx-cli
Version:
scaffold for create component, toolkit, page and so on
60 lines (49 loc) • 1.1 kB
JavaScript
;
const program = require('commander');
const dmxInit = require('../lib/dmx');
const pkgJSON = require('../package.json');
program.version(pkgJSON.version, '-v, --version');
/**
* 初始化套件
*/
program
.command('toolkit [type]')
.description('initialize a toolkit, example: `dmx toolkit ca-admin`')
.action((type) => {
if (!type) {
return;
}
dmxInit(type, 'toolkit');
});
/**
* 新增页面
*/
program
.command('page [type]')
.description('add a page, example: `dmx page ca-admin`')
.action((type) => {
if (!type) {
return;
}
dmxInit(type, 'page');
});
/**
* 初始化组件
*/
program
.command('component [type]')
.description('initialize a component, example: `dmx component react`')
.action((type) => {
if (!type) {
return;
}
dmxInit(type, 'component');
});
if (
!process.argv.slice(2).length ||
['-v', '--version', '-h', '--help'].indexOf(process.argv.slice(2)[0]) === -1 && !process.argv.slice(3).length
) {
program.outputHelp();
}
program.parse(process.argv);