From 3ebed47170a2f68246d1ebd6936bc61e542dbc2c Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sat, 25 Jun 2016 12:28:51 +0200 Subject: [PATCH] switched from commander to smartcli --- dist/index.js | 105 +++++++++++++++++++------------------- dist/npmci.plugins.d.ts | 2 +- dist/npmci.plugins.js | 4 +- package.json | 2 +- ts/index.ts | 109 +++++++++++++++++++++------------------- ts/npmci.plugins.ts | 2 +- 6 files changed, 112 insertions(+), 112 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1479022..7288b75 100644 --- a/dist/index.js +++ b/dist/index.js @@ -19,59 +19,56 @@ var npmci_install_2 = require("./npmci.install"); exports.install = npmci_install_2.install; var npmci_publish_2 = require("./npmci.publish"); exports.publish = npmci_publish_2.publish; -var command; -var commandOption; -var commander = plugins.commander - .option("-v", "--version", "print version") - .arguments(' [commandoptionarg]') - .action(function (commandarg, commandoptionarg) { - command = commandarg; - commandOption = commandoptionarg; +var smartcli = new plugins.smartcli.Smartcli(); +smartcli.addVersion(npmciInfo.version); +// build +smartcli.addCommand({ + commandName: "build" +}).then(function (argv) { + npmci_build_1.build(argv._[1]) + .then(NpmciEnv.configStore); }); -plugins.commander.parse(process.argv); -if (commander.version) { - console.log(npmciInfo.version); - process.exit(0); -} -if (typeof command === 'undefined') { - console.error('no command given!'); - process.exit(1); -} -switch (command) { - case "build": - npmci_build_1.build(commandOption) - .then(NpmciEnv.configStore); - break; - case "command": - npmci_command_1.command() - .then(NpmciEnv.configStore); - break; - case "install": - npmci_install_1.install(commandOption) - .then(NpmciEnv.configStore); - ; - break; - case "prepare": - npmci_prepare_1.prepare(commandOption) - .then(NpmciEnv.configStore); - ; - break; - case "publish": - npmci_publish_1.publish(commandOption) - .then(NpmciEnv.configStore); - ; - break; - case "test": - npmci_test_1.test(commandOption) - .then(NpmciEnv.configStore); - break; - case "trigger": - npmci_trigger_1.trigger(); - break; - default: - plugins.beautylog.error("command " + commandOption.blue + " not recognised"); - process.exit(1); - break; -} +// command +smartcli.addCommand({ + commandName: "command" +}).then(function (argv) { + npmci_command_1.command() + .then(NpmciEnv.configStore); +}); +// install +smartcli.addCommand({ + commandName: "install" +}).then(function (argv) { + npmci_install_1.install(argv._[1]) + .then(NpmciEnv.configStore); +}); +// prepare +smartcli.addCommand({ + commandName: "prepare" +}).then(function (argv) { + npmci_prepare_1.prepare(argv._[1]) + .then(NpmciEnv.configStore); +}); +// publish +smartcli.addCommand({ + commandName: "publish" +}).then(function (argv) { + npmci_publish_1.publish(argv._[1]) + .then(NpmciEnv.configStore); +}); +// test +smartcli.addCommand({ + commandName: "test" +}).then(function (argv) { + npmci_test_1.test(argv._[1]) + .then(NpmciEnv.configStore); +}); +// trigger +smartcli.addCommand({ + commandName: "trigger" +}).then(function (argv) { + npmci_trigger_1.trigger(); +}); +smartcli.startParse(); -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ0EsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLElBQVksT0FBTyxXQUFNLGlCQUFpQixDQUFDLENBQUE7QUFDM0MsSUFBWSxLQUFLLFdBQU0sZUFBZSxDQUFDLENBQUE7QUFDdkMsSUFBSSxTQUFTLEdBQUcsSUFBSSxPQUFPLENBQUMsV0FBVyxDQUFDLGNBQWMsQ0FBQyxLQUFLLENBQUMsZ0JBQWdCLENBQUMsQ0FBQztBQUMvRSxPQUFPLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxpQkFBaUIsR0FBRyxTQUFTLENBQUMsT0FBTyxDQUFDLENBQUM7QUFFN0QsNEJBQW9CLGVBQ3BCLENBQUMsQ0FEa0M7QUFDbkMsOEJBQWtDLGlCQUFpQixDQUFDLENBQUE7QUFDcEQsOEJBQXNCLGlCQUFpQixDQUFDLENBQUE7QUFDeEMsOEJBQXNCLGlCQUFpQixDQUFDLENBQU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VxuICAgICAgICAgICAgLnRoZW4oTnBtY2lFbnYuY29uZmlnU3RvcmUpO1xuICAgICAgICBicmVhaztcbiAgICBjYXNlIFwiY29tbWFuZFwiOlxuICAgICAgICBjb21tYW5kMigpXG4gICAgICAgICAgICAudGhlbihOcG1jaUVudi5jb25maWdTdG9yZSk7XG4gICAgICAgIGJyZWFrO1xuICAgIGNhc2UgXCJpbnN0YWxsXCI6XG4gICAgICAgIGluc3RhbGwoY29tbWFuZE9wdGlvbilcbiAgICAgICAgICAgIC50aGVuKE5wbWNpRW52LmNvbmZpZ1N0b3JlKTs7XG4gICAgICAgIGJyZWFrO1xuICAgIGNhc2UgXCJwcmVwYXJlXCI6XG4gICAgICAgIHByZXBhcmUoY29tbWFuZE9wdGlvbilcbiAgICAgICAgICAgIC50aGVuKE5wbWNpRW52LmNvbmZpZ1N0b3JlKTs7XG4gICAgICAgIGJyZWFrO1xuICAgIGNhc2UgXCJwdWJsaXNoXCI6XG4gICAgICAgIHB1Ymxpc2goY29tbWFuZE9wdGlvbilcbiAgICAgICAgICAgIC50aGVuKE5wbWNpRW52LmNvbmZpZ1N0b3JlKTs7XG4gICAgICAgIGJyZWFrO1xuICAgIGNhc2UgXCJ0ZXN0XCI6XG4gICAgICAgIHRlc3QoY29tbWFuZE9wdGlvbilcbiAgICAgICAgICAgIC50aGVuKE5wbWNpRW52LmNvbmZpZ1N0b3JlKTtcbiAgICAgICAgYnJlYWs7XG4gICAgY2FzZSBcInRyaWdnZXJcIjpcbiAgICAgICAgdHJpZ2dlcigpO1xuICAgICAgICBicmVhaztcbiAgICBkZWZhdWx0OlxuICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcImNvbW1hbmQgXCIgKyBjb21tYW5kT3B0aW9uLmJsdWUgKyBcIiBub3QgcmVjb2duaXNlZFwiKTtcbiAgICAgICAgcHJvY2Vzcy5leGl0KDEpO1xuICAgICAgICBicmVhaztcbn1cblxuIl19 +//# sourceMappingURL=data:application/json;charset=utf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TnBtY2lFbnYuY29uZmlnU3RvcmUpO1xufSk7XG5cbi8vIHRyaWdnZXJcbnNtYXJ0Y2xpLmFkZENvbW1hbmQoe1xuICAgIGNvbW1hbmROYW1lOlwidHJpZ2dlclwiXG59KS50aGVuKChhcmd2KSA9PiB7XG4gICAgdHJpZ2dlcigpO1xufSk7XG5cbnNtYXJ0Y2xpLnN0YXJ0UGFyc2UoKTsiXX0= diff --git a/dist/npmci.plugins.d.ts b/dist/npmci.plugins.d.ts index 3badc06..f4199ff 100644 --- a/dist/npmci.plugins.d.ts +++ b/dist/npmci.plugins.d.ts @@ -1,6 +1,5 @@ import "typings-global"; export import beautylog = require("beautylog"); -export declare let commander: any; export declare let gulp: any; export declare let gulpFunction: any; export import path = require("path"); @@ -8,6 +7,7 @@ export import projectinfo = require("projectinfo"); export declare let q: any; export declare let request: any; export declare let shelljs: any; +export import smartcli = require("smartcli"); export import smartfile = require("smartfile"); export import smartparam = require("smartparam"); export import smartssh = require("smartssh"); diff --git a/dist/npmci.plugins.js b/dist/npmci.plugins.js index 6dd26be..6121ef6 100644 --- a/dist/npmci.plugins.js +++ b/dist/npmci.plugins.js @@ -1,7 +1,6 @@ "use strict"; require("typings-global"); exports.beautylog = require("beautylog"); -exports.commander = require("commander"); exports.gulp = require("gulp"); exports.gulpFunction = require("gulp-function"); exports.path = require("path"); @@ -9,10 +8,11 @@ exports.projectinfo = require("projectinfo"); exports.q = require("q"); exports.request = require("request"); exports.shelljs = require("shelljs"); +exports.smartcli = require("smartcli"); exports.smartfile = require("smartfile"); exports.smartparam = require("smartparam"); exports.smartssh = require("smartssh"); exports.smartstring = require("smartstring"); exports.through2 = require("through2"); -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNWLGlCQUFT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lXCIpO1xuZXhwb3J0IGltcG9ydCBzbWFydHBhcmFtID0gcmVxdWlyZShcInNtYXJ0cGFyYW1cIik7XG5leHBvcnQgaW1wb3J0IHNtYXJ0c3NoID0gcmVxdWlyZShcInNtYXJ0c3NoXCIpO1xuZXhwb3J0IGltcG9ydCBzbWFydHN0cmluZyA9IHJlcXVpcmUoXCJzbWFydHN0cmluZ1wiKTtcbmV4cG9ydCBsZXQgdGhyb3VnaDIgPSByZXF1aXJlKFwidGhyb3VnaDJcIik7Il19 diff --git a/package.json b/package.json index 06af39c..41864da 100644 --- a/package.json +++ b/package.json @@ -27,13 +27,13 @@ }, "dependencies": { "beautylog": "^5.0.12", - "commander": "^2.9.0", "gulp": "^3.9.1", "gulp-function": "^1.3.6", "projectinfo": "^1.0.3", "q": "^1.4.1", "request": "^2.72.0", "shelljs": "^0.7.0", + "smartcli": "^1.0.4", "smartfile": "^4.0.5", "smartparam": "^0.1.1", "smartssh": "^1.1.0", diff --git a/ts/index.ts b/ts/index.ts index da3a8f9..3abea0a 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -6,7 +6,7 @@ let npmciInfo = new plugins.projectinfo.ProjectinfoNpm(paths.NpmciPackageRoot); plugins.beautylog.log("npmci version: " + npmciInfo.version); import {build} from "./npmci.build" -import {command as command2} from "./npmci.command"; +import {command} from "./npmci.command"; import {install} from "./npmci.install"; import {publish} from "./npmci.publish"; import {prepare} from "./npmci.prepare"; @@ -19,60 +19,63 @@ export {build} from "./npmci.build" export {install} from "./npmci.install"; export {publish} from "./npmci.publish"; -let command; -let commandOption:string; -let commander = plugins.commander - .option("-v","--version","print version") - .arguments(' [commandoptionarg]') - .action(function (commandarg, commandoptionarg) { - command = commandarg; - commandOption = commandoptionarg; - }); - -plugins.commander.parse(process.argv); +let smartcli = new plugins.smartcli.Smartcli(); +smartcli.addVersion(npmciInfo.version); -if(commander.version) { - console.log(npmciInfo.version); - process.exit(0); -} +// build +smartcli.addCommand({ + commandName:"build" +}).then((argv) => { + build(argv._[1]) + .then(NpmciEnv.configStore); +}); -if (typeof command === 'undefined') { - console.error('no command given!'); - process.exit(1); -} +// command +smartcli.addCommand({ + commandName:"command" +}).then((argv) => { + command() + .then(NpmciEnv.configStore); +}); -switch (command){ - case "build": - build(commandOption) - .then(NpmciEnv.configStore); - break; - case "command": - command2() - .then(NpmciEnv.configStore); - break; - case "install": - install(commandOption) - .then(NpmciEnv.configStore);; - break; - case "prepare": - prepare(commandOption) - .then(NpmciEnv.configStore);; - break; - case "publish": - publish(commandOption) - .then(NpmciEnv.configStore);; - break; - case "test": - test(commandOption) - .then(NpmciEnv.configStore); - break; - case "trigger": - trigger(); - break; - default: - plugins.beautylog.error("command " + commandOption.blue + " not recognised"); - process.exit(1); - break; -} +// install +smartcli.addCommand({ + commandName:"install" +}).then((argv) => { + install(argv._[1]) + .then(NpmciEnv.configStore); +}); +// prepare +smartcli.addCommand({ + commandName:"prepare" +}).then((argv) => { + prepare(argv._[1]) + .then(NpmciEnv.configStore); +}); + +// publish +smartcli.addCommand({ + commandName:"publish" +}).then((argv) => { + publish(argv._[1]) + .then(NpmciEnv.configStore); +}); + +// test +smartcli.addCommand({ + commandName:"test" +}).then((argv) => { + test(argv._[1]) + .then(NpmciEnv.configStore); +}); + +// trigger +smartcli.addCommand({ + commandName:"trigger" +}).then((argv) => { + trigger(); +}); + +smartcli.startParse(); \ No newline at end of file diff --git a/ts/npmci.plugins.ts b/ts/npmci.plugins.ts index 0ff8e31..cac8215 100644 --- a/ts/npmci.plugins.ts +++ b/ts/npmci.plugins.ts @@ -1,6 +1,5 @@ import "typings-global"; export import beautylog = require("beautylog"); -export let commander = require("commander"); export let gulp = require("gulp"); export let gulpFunction = require("gulp-function"); export import path = require("path"); @@ -8,6 +7,7 @@ export import projectinfo = require("projectinfo"); export let q = require("q"); export let request = require("request"); export let shelljs = require("shelljs"); +export import smartcli = require("smartcli"); export import smartfile = require("smartfile"); export import smartparam = require("smartparam"); export import smartssh = require("smartssh");