Optimize workflow
This commit is contained in:
1 parent
cec28fc0f3
commit
1f18052940
14 files changed
+11765
-451
No files matched your search
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
*
|
||||
* @authors Tony.Deng (dengtongyu123@163.com)
|
||||
* @date 2018-05-14 16:44:06
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
const program = require('commander');
|
||||
const inquirer = require('inquirer');
|
||||
const util = require('./task/util');
|
||||
const task = require('./task/task');
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.command('new')
|
||||
.alias('n')
|
||||
.description('新建一个项目')
|
||||
.option('-n, --name [pathName]', '构建路径名称')
|
||||
.option('-t, --tpl [tplType]', '模版类型(pc or phone)')
|
||||
.action(option => {
|
||||
let config = Object.assign({
|
||||
tpl: 0,
|
||||
name: null
|
||||
}, option)
|
||||
|
||||
//console.log(config)
|
||||
|
||||
let promps = [];
|
||||
|
||||
if(!config.name) {
|
||||
promps.push({
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: '请输入需要创建的路径名:',
|
||||
default: util.randomActName()
|
||||
})
|
||||
}
|
||||
|
||||
if(!config.tpl) {
|
||||
promps.push({
|
||||
type: 'list',
|
||||
name: 'tpl',
|
||||
message: '请选择需要创建的模板:',
|
||||
choices: [
|
||||
{
|
||||
name: '1. tpl-pc',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: '2. tpl-phone',
|
||||
value: 2
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
inquirer.prompt(promps).then(function (answers) {
|
||||
//console.log('\n',answers)
|
||||
option = Object.assign(answers,option);
|
||||
//console.log(option);
|
||||
//util.initPath(answers.name);
|
||||
task.selectTpl(option.name,option.tpl);
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('dev')
|
||||
.alias('d')
|
||||
.description('开发一个已存在的项目')
|
||||
.option('-n, --name [pathName]', '开发路径名称')
|
||||
.action(option => {
|
||||
let config = Object.assign({
|
||||
name: null
|
||||
}, option)
|
||||
|
||||
//console.log(config)
|
||||
|
||||
let promps = [];
|
||||
|
||||
if(!config.name) {
|
||||
promps.push({
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: '请输入需要开发的路径名:',
|
||||
validate: function (input){
|
||||
if(!input) {
|
||||
return '不能为空'
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
inquirer.prompt(promps).then(function (answers) {
|
||||
//console.log('\n',answers)
|
||||
option = Object.assign(answers,option);
|
||||
//console.log(option.name);
|
||||
|
||||
//util.initPath(answers.name);
|
||||
task.dev(option.name);
|
||||
})
|
||||
});
|
||||
|
||||
program
|
||||
.command('build')
|
||||
.alias('b')
|
||||
.description('打包构建一个已存在的项目')
|
||||
.option('-n, --name [pathName]', '打包构建路径名称')
|
||||
.action(option => {
|
||||
let config = Object.assign({
|
||||
name: null
|
||||
}, option)
|
||||
|
||||
//console.log(config)
|
||||
|
||||
let promps = [];
|
||||
|
||||
if(!config.name) {
|
||||
promps.push({
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: '请输入需要打包构建的路径名:',
|
||||
validate: function (input){
|
||||
if(!input) {
|
||||
return '不能为空'
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
inquirer.prompt(promps).then(function (answers) {
|
||||
//console.log('\n',answers)
|
||||
option = Object.assign(answers,option);
|
||||
//console.log(option);
|
||||
task.pack(option.name);
|
||||
})
|
||||
});
|
||||
|
||||
program.parse(process.argv)
|
||||
|
||||
//console.log(program);
|
||||
Reference in new issue
Block a user