From 63e654564631a07140eec3b6245fa23345aaa9fb Mon Sep 17 00:00:00 2001 From: yueming Date: Fri, 6 Jan 2017 11:19:47 +0800 Subject: [PATCH] update:english command. --- bin/uba.js | 8 ++++---- lib/help.js | 13 +++++++------ lib/init.js | 21 ++++++++++----------- lib/quick.js | 19 +++++++++---------- package.json | 2 +- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/bin/uba.js b/bin/uba.js index e8dee64..61010b8 100755 --- a/bin/uba.js +++ b/bin/uba.js @@ -5,20 +5,20 @@ const chalk = require('chalk'); const argv = require('minimist')(process.argv.slice(2)); const commands = argv._; const help = require('../lib/help'); +const init = require('../lib/init'); if (commands.length === 0) { if (argv.version || argv.v) { - console.log(chalk.green(require('../package.json').version)); + help.version(); } else if (argv.help || argv.h) { help.help(); } else { - const init = require('../lib/init'); - init(); + help.help(); } } else { switch (commands[0]) { case 'init': - require('../lib/quick')(commands); + init(); break; default: break; diff --git a/lib/help.js b/lib/help.js index ca54605..a799dac 100644 --- a/lib/help.js +++ b/lib/help.js @@ -2,7 +2,7 @@ * Module : helper * Author : Kvkens(yueming@yonyou.com) * Date : 2016-10-13 19:58:42 - * Update : 2016-12-29 08:44:13 + * Update : 2017-01-06 10:13:35 */ 'use strict'; @@ -13,23 +13,24 @@ const fs = require('fs'); module.exports = { help: () => { - console.log(chalk.green('1. uba Generate best practices')); - console.log(chalk.green('2. uba --help or -h Help')); + console.log(chalk.green('uba help')); + console.log(chalk.green('1. uba init Generate best practices')); + console.log(chalk.green('2. uba -h Help')); }, version: () => { console.log(); - console.log(chalk.green('当前版本:v' + require('../package.json').version)); + console.log(chalk.green('Version : ' + require('../package.json').version)); console.log(); process.exit(); }, info: (msg) => { // console.log(); - console.log(chalk.cyan("信息:" + msg)); + console.log(chalk.cyan("Info : " + msg)); // console.log(); }, error: (msg) => { // console.log(); - console.log(chalk.red("错误:" + msg)); + console.log(chalk.red("Error : " + msg)); // console.log(); }, merge: (destination, source) => { diff --git a/lib/init.js b/lib/init.js index 405b9b2..56e08d4 100644 --- a/lib/init.js +++ b/lib/init.js @@ -18,7 +18,7 @@ const spawn = require('cross-spawn'); module.exports = () => { - help.info("正在加载远程数据请稍等..."); + help.info("Available official templates:"); var repoNameData = []; request({ url: 'https://api.github.com/users/uba-templates/repos', @@ -40,15 +40,14 @@ module.exports = () => { inquirer.prompt([{ type: 'list', name: 'selectRepo', - message: '选择在线最佳实践:', + message: 'Please select :', choices: repoNameData }]).then(function(answers) { var selectName = answers.selectRepo.split(' - ')[0]; - //console.log(chalk.green(`已选择[${selectName}]`)); var questions = [{ type: 'input', name: 'selectName', - message: '最佳实践目录名称:', + message: 'boilerplate name :', default: function() { return 'uba-boilerplate'; } @@ -60,22 +59,22 @@ module.exports = () => { if (!pathExists.sync(name)) { fs.mkdirSync(root); } else { - help.error(`当前工程 ${name} 已存在,当前操作终止.`); + help.error(`directory ${name} already exists.`); process.exit(0); } - help.info(`开始下载 ${template} 最佳实践模板请稍等...`); + help.info(`Downloading ${template} please wait.`); //TODO 开始下载 download(help.getInitGithubRepo(template), `${name}`, function(err) { if (!err) { - help.info(`最佳实践 ${name} 创建完毕.`); + help.info(`Boilerplate ${name} done.`); inquirer.prompt([{ type: 'confirm', - message: '是否自动安装npm依赖包', + message: 'Automatically install NPM dependent packages?', name: 'ok' }]).then(function(res) { var npmInstallChdir = path.resolve('.', name); if (res.ok) { - help.info(`开始安装npm依赖包请稍等...`); + help.info(`Install NPM dependent packages,please wait.`); //TODO 选择自动安装 process.chdir(npmInstallChdir); var args = ['install'].filter(function(e) { @@ -89,11 +88,11 @@ module.exports = () => { console.error('`npm ' + args.join(' ') + '` failed'); return; } - help.info(`自动安装完毕.`); + help.info(`NPM package installed.`); }); } else { - help.error(`取消自动安装npm依赖包,请手动执行npm install.`); + help.error(`Cancel the installation of NPM dependent package,please run npm install.`); } }); diff --git a/lib/quick.js b/lib/quick.js index 974bf00..1caa635 100644 --- a/lib/quick.js +++ b/lib/quick.js @@ -17,7 +17,7 @@ const spawn = require('cross-spawn'); module.exports = (commands) => { if (commands.length !== 3) { - help.error(' uba init 命令不正确.'); + help.error(' uba init bad'); process.exit(0); } var name = null, @@ -33,21 +33,21 @@ module.exports = (commands) => { if (!pathExists.sync(name)) { fs.mkdirSync(root); } else { - help.error(`当前文件夹 ${name} 已经存在了,当前操作终止.`); + help.error(`directory ${name} already exists.`); process.exit(0); } - help.info(`开始下载 ${template} 最佳实践模板请稍等.`); + help.info(`Downloading ${template} please wait.`); download(help.getInitGithubRepo(template), `${name}`, function(err) { if (!err) { - help.info(`最佳实践 ${name} 创建完毕.`); + help.info(`Boilerplate ${name} done.`); inquirer.prompt([{ type: 'confirm', - message: '是否自动安装npm依赖包', + message: 'Automatically install NPM dependent packages?', name: 'ok' }]).then(function(res) { var npmInstallChdir = path.resolve('.', name); if (res.ok) { - help.info(`开始安装npm依赖包请稍等...`); + help.info(`Install NPM dependent packages,please wait.`); //TODO 选择自动安装 process.chdir(npmInstallChdir); var args = ['install'].filter(function(e) { @@ -61,17 +61,16 @@ module.exports = (commands) => { console.error('`npm ' + args.join(' ') + '` failed'); return; } - help.info(`自动安装完毕.`); + help.info(`NPM package installed.`); }); } else { - help.error(`取消自动安装npm依赖包,请手动执行npm install.`); + help.error(`Cancel the installation of NPM dependent package,please run npm install.`); } }); - } else { - help.error(`最佳实践下载失败,请检查最佳实践名字是否正确或网络错误.`); + console.error(requestBody.message); } }); diff --git a/package.json b/package.json index a0ba068..eb427c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uba", - "version": "2.0.2", + "version": "2.0.3", "description": "a font-end develop tool for tinper", "main": "bin/uba.js", "bin": {