vesh-cli
Version:
码农村nodejs版本VESH框架脚手架搭建器
53 lines (52 loc) • 2.66 kB
JavaScript
const co = require('co');
const prompt = require('co-prompt');
const chalk = require('chalk');
const fs = require('fs');
const V = require('gcl/com/coooders/io/tool');
module.exports = () => {
co(function*() {
try {
switch ((process.argv[3] + "").toLowerCase()) {
case 'module':
if ((process.argv[4] + "").length) {
yield V.createDir(`./Module/${process.argv[4]}`);
yield V.createDir(`./Scripts/Module/${process.argv[4]}`);
yield V.createDir(`./Style/Module/${process.argv[4]}`);
yield V.copyFile(__dirname + '/../template/Module/action.js', `./Module/${process.argv[4]}/action.js`);
console.log(chalk.green(`module:${process.argv[4]}创建完毕`));
} else throw new Error('需要添加module名');
break;
case 'action':
yield V.copyFile(__dirname + '/../template/Module/action.js', `./action.js`);
console.log(chalk.green(`action创建完毕`));
break;
case 'html':
if ((process.argv[4] + "").length) {
yield V.copyFile(__dirname + '/../template/Module/test2.html', `./${process.argv[4]}.html`);
console.log(chalk.green(`html:${process.argv[4]}.html创建完毕`));
} else throw new Error('需要添加页面名');
break;
case 'jhtml':
if ((process.argv[4] + "").length) {
yield V.copyFile(__dirname + '/../template/Module/test3.jhtml', `./${process.argv[4]}.jhtml`);
console.log(chalk.green(`jhtml:${process.argv[4]}.jhtml创建完毕`));
} else throw new Error('需要添加页面名');
break;
case 'ni':
if ((process.argv[4] + "").length) {
yield V.copyFile(__dirname + '/../template/Ni/ni.npcf', `./${process.argv[4]}.npcf`);
console.log(chalk.green(`ni:${process.argv[4]}.npcf创建完毕`));
} else throw new Error('需要添加ni文件名');
break;
default:
throw new Error('需要第二个参数为添加文件类型:module,action,html,jhtml,ni');
break;
}
process.exit();
} catch (e) {
console.log(chalk.red(e.message));
process.exit();
}
})
};