From 7873667544ec55cc27616c082098e3df87c27216 Mon Sep 17 00:00:00 2001 From: saqqdy Date: Sat, 20 Feb 2021 22:06:29 +0800 Subject: [PATCH] docs & prettier --- .eslintrc.js | 6 +- README.md | 4 +- bin/conf/admin.js | 310 ++++++------ bin/conf/branch.js | 166 +++---- bin/conf/build.js | 90 ++-- bin/conf/combine.js | 260 +++++----- bin/conf/continue.js | 48 +- bin/conf/copy.js | 78 +-- bin/conf/end.js | 28 +- bin/conf/get.js | 54 +- bin/conf/go.js | 22 +- bin/conf/hook.js | 164 +++---- bin/conf/link.js | 28 +- bin/conf/log.js | 84 ++-- bin/conf/postmsg.js | 34 +- bin/conf/revert.js | 72 +-- bin/conf/run.js | 44 +- bin/conf/save.js | 60 +-- bin/conf/start.js | 28 +- bin/conf/unlink.js | 34 +- bin/conf/update.js | 54 +- bin/gitm-admin.js | 580 +++++++++++----------- bin/gitm-branch.js | 90 ++-- bin/gitm-build.js | 12 +- bin/gitm-clean.js | 22 +- bin/gitm-combine.js | 290 +++++------ bin/gitm-config.js | 78 +-- bin/gitm-continue.js | 22 +- bin/gitm-copy.js | 104 ++-- bin/gitm-end.js | 158 +++--- bin/gitm-get.js | 32 +- bin/gitm-go.js | 132 ++--- bin/gitm-hook.js | 648 ++++++++++++------------ bin/gitm-init.js | 208 ++++---- bin/gitm-link.js | 20 +- bin/gitm-log.js | 16 +- bin/gitm-merge.js | 34 +- bin/gitm-permission.js | 50 +- bin/gitm-postmsg.js | 4 +- bin/gitm-revert.js | 32 +- bin/gitm-run.js | 4 +- bin/gitm-save.js | 14 +- bin/gitm-start.js | 34 +- bin/gitm-unlink.js | 24 +- bin/gitm-update.js | 92 ++-- bin/gitm-upgrade.js | 100 ++-- bin/gitm.js | 163 +++--- bin/js/apollo.js | 54 +- bin/js/checkGitDirEnv.js | 8 +- bin/js/config.js | 38 +- bin/js/configFrom.js | 12 +- bin/js/debug.js | 6 +- bin/js/getConfig.js | 48 +- bin/js/getGitConfig.js | 12 +- bin/js/getGitVersion.js | 22 +- bin/js/gitRevParse.js | 12 +- bin/js/global.js | 42 +- bin/js/go.js | 142 +++--- bin/js/go/cleanConfig.js | 68 +-- bin/js/go/createPrompt.js | 112 ++--- bin/js/go/getCommand.js | 102 ++-- bin/js/hook/getHookComment.js | 8 +- bin/js/hook/getHookShell.js | 6 +- bin/js/hook/getHookType.js | 10 +- bin/js/hook/getLocalShell.js | 2 +- bin/js/hook/getPackageManager.js | 20 +- bin/js/hook/index.js | 262 +++++----- bin/js/hook/run.js | 72 +-- bin/js/index.js | 820 +++++++++++++++---------------- bin/js/readPkg.js | 14 +- bin/js/runJenkins.js | 66 +-- lib/gitm-clean.js | 2 +- lib/gitm-go.js | 2 +- lib/gitm-hook.js | 2 +- lib/gitm-init.js | 2 +- lib/gitm-permission.js | 2 +- lib/gitm.js | 2 +- lib/js/hook/index.js | 2 +- lib/js/index.js | 2 +- lib/sh/gitmars.sh | 38 +- package.json | 128 ++--- 81 files changed, 3419 insertions(+), 3352 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5182519d..d20aeb15 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,6 @@ const { simple: config } = require('eslint-config-sets') module.exports = Object.assign(config, { - rules: { - semi: [2, 'never'] - } + rules: { + semi: [2, 'never'] + } }) diff --git a/README.md b/README.md index 49317f14..8bc45c25 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ 一个定制化的 git 工作流操作工具 -# **完整文档请查阅: [Gitmars API文档](http://docs.saqqdy.com/gitmars/api/)** +# **完整文档请查阅: [Gitmars API 文档](http://docs.saqqdy.com/gitmars/api/)** # gitmars 工作流: @@ -73,5 +73,5 @@ gitm copy -h - 使用:`gitm go` - 演示: - + > ![gitmars-go.gif](https://raw.githubusercontent.com/saqqdy/gitmars/master/lib/img/gitmars-go.gif) diff --git a/bin/conf/admin.js b/bin/conf/admin.js index 1ccb7322..421c8ee6 100644 --- a/bin/conf/admin.js +++ b/bin/conf/admin.js @@ -1,158 +1,158 @@ ;(function (root) { - const cmdConfig = { - command: 'admin', - short: null, - create: { - command: 'create', - short: null, - args: [ - { - required: true, - name: 'type', - variadic: false, - description: '分支类型' - } - ], - options: [] - }, - publish: { - command: 'publish', - short: null, - args: [ - { - required: true, - name: 'type', - variadic: false, - description: '分支类型' - } - ], - options: [ - { - flags: '-c, --combine', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-c', - long: '--combine', - negate: false, - description: '是否把release代码同步到bug', - defaultValue: false, - recommend: false - }, - { - flags: '--use-rebase', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--use-rebase', - negate: false, - description: '是否使用rebase方式更新,默认merge', - defaultValue: false, - recommend: false - }, - { - flags: '-p, --prod', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-p', - long: '--prod', - negate: false, - description: '发布bug分支时,是否合并bug到master', - defaultValue: false, - recommend: false - }, - { - flags: '-b, --build [build]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-b', - long: '--build', - negate: false, - description: '构建应用', - recommend: true - }, - { - flags: '--postmsg', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--postmsg', - negate: false, - description: '发送消息', - defaultValue: false, - recommend: false - } - ] - }, - update: { - command: 'update', - short: null, - args: [{ required: true, name: 'type', variadic: false, description: '分支类型' }], - options: [ - { - flags: '--use-rebase', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--use-rebase', - negate: false, - description: '是否使用rebase方式更新,默认merge', - defaultValue: false, - recommend: false - }, - { - flags: '-m, --mode [mode]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-m', - long: '--mode', - negate: false, - description: '出现冲突时,保留传入代码还是保留当前代码;1=采用当前 2=采用传入;默认为 0=手动处理。本参数不可与--use-rebase同时使用', - defaultValue: 0, - recommend: false - }, - { - flags: '--postmsg', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--postmsg', - negate: false, - description: '发送消息', - defaultValue: false, - recommend: false - } - ] - }, - clean: { - command: 'clean', - short: null, - args: [ - { - required: true, - name: 'type', - variadic: false, - description: '分支类型' - } - ], - options: [] - } - } + const cmdConfig = { + command: 'admin', + short: null, + create: { + command: 'create', + short: null, + args: [ + { + required: true, + name: 'type', + variadic: false, + description: '分支类型' + } + ], + options: [] + }, + publish: { + command: 'publish', + short: null, + args: [ + { + required: true, + name: 'type', + variadic: false, + description: '分支类型' + } + ], + options: [ + { + flags: '-c, --combine', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-c', + long: '--combine', + negate: false, + description: '是否把release代码同步到bug', + defaultValue: false, + recommend: false + }, + { + flags: '--use-rebase', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--use-rebase', + negate: false, + description: '是否使用rebase方式更新,默认merge', + defaultValue: false, + recommend: false + }, + { + flags: '-p, --prod', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-p', + long: '--prod', + negate: false, + description: '发布bug分支时,是否合并bug到master', + defaultValue: false, + recommend: false + }, + { + flags: '-b, --build [build]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-b', + long: '--build', + negate: false, + description: '构建应用', + recommend: true + }, + { + flags: '--postmsg', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--postmsg', + negate: false, + description: '发送消息', + defaultValue: false, + recommend: false + } + ] + }, + update: { + command: 'update', + short: null, + args: [{ required: true, name: 'type', variadic: false, description: '分支类型' }], + options: [ + { + flags: '--use-rebase', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--use-rebase', + negate: false, + description: '是否使用rebase方式更新,默认merge', + defaultValue: false, + recommend: false + }, + { + flags: '-m, --mode [mode]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-m', + long: '--mode', + negate: false, + description: '出现冲突时,保留传入代码还是保留当前代码;1=采用当前 2=采用传入;默认为 0=手动处理。本参数不可与--use-rebase同时使用', + defaultValue: 0, + recommend: false + }, + { + flags: '--postmsg', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--postmsg', + negate: false, + description: '发送消息', + defaultValue: false, + recommend: false + } + ] + }, + clean: { + command: 'clean', + short: null, + args: [ + { + required: true, + name: 'type', + variadic: false, + description: '分支类型' + } + ], + options: [] + } + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/branch.js b/bin/conf/branch.js index bdf63322..4d1c3c84 100644 --- a/bin/conf/branch.js +++ b/bin/conf/branch.js @@ -1,86 +1,86 @@ ;(function (root) { - const cmdConfig = { - command: 'branch', - short: 'bh', - args: [], - options: [ - { - flags: '-k, --key [keyword]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-k', - long: '--key', - negate: false, - description: '查询分支的关键词', - defaultValue: null - }, - { - flags: '-r, --remote', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-r', - long: '--remote', - negate: false, - description: '是否查询远程分支(这个参数不用于删除分支)默认只查询本地', - defaultValue: false - }, - { - flags: '-t, --type [type]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-t', - long: '--type', - negate: false, - description: '查询分支的类型,共有3种:feature、bugfix、support,不传则查询全部', - defaultValue: null - }, - { - flags: '-d, --delete [branch]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-d', - long: '--delete', - negate: false, - description: '删除分支', - defaultValue: null - }, - { - flags: '-D, --forcedelete [branch]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-D', - long: '--forcedelete', - negate: false, - description: '强行删除分支', - defaultValue: null - }, - { - flags: '-u, --upstream [upstream]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-u', - long: '--upstream', - negate: false, - description: '设置与远程分支关联' - } - ] - } + const cmdConfig = { + command: 'branch', + short: 'bh', + args: [], + options: [ + { + flags: '-k, --key [keyword]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-k', + long: '--key', + negate: false, + description: '查询分支的关键词', + defaultValue: null + }, + { + flags: '-r, --remote', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-r', + long: '--remote', + negate: false, + description: '是否查询远程分支(这个参数不用于删除分支)默认只查询本地', + defaultValue: false + }, + { + flags: '-t, --type [type]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-t', + long: '--type', + negate: false, + description: '查询分支的类型,共有3种:feature、bugfix、support,不传则查询全部', + defaultValue: null + }, + { + flags: '-d, --delete [branch]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-d', + long: '--delete', + negate: false, + description: '删除分支', + defaultValue: null + }, + { + flags: '-D, --forcedelete [branch]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-D', + long: '--forcedelete', + negate: false, + description: '强行删除分支', + defaultValue: null + }, + { + flags: '-u, --upstream [upstream]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-u', + long: '--upstream', + negate: false, + description: '设置与远程分支关联' + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/build.js b/bin/conf/build.js index 5ac60b57..68feca21 100644 --- a/bin/conf/build.js +++ b/bin/conf/build.js @@ -1,48 +1,48 @@ ;(function (root) { - const cmdConfig = { - command: 'build', - short: 'bd', - args: [ - { - required: true, - name: 'project', - variadic: false, - description: '项目名称' - } - ], - options: [ - { - flags: '-e, --env [env]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-e', - long: '--env', - negate: false, - description: '构建环境,可选dev、prod、bug、all', - defaultValue: 'dev', - recommend: true - }, - { - flags: '-a, --app [app]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-a', - long: '--app', - negate: false, - description: '构建应用', - defaultValue: 'all', - recommend: true - } - ] - } + const cmdConfig = { + command: 'build', + short: 'bd', + args: [ + { + required: true, + name: 'project', + variadic: false, + description: '项目名称' + } + ], + options: [ + { + flags: '-e, --env [env]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-e', + long: '--env', + negate: false, + description: '构建环境,可选dev、prod、bug、all', + defaultValue: 'dev', + recommend: true + }, + { + flags: '-a, --app [app]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-a', + long: '--app', + negate: false, + description: '构建应用', + defaultValue: 'all', + recommend: true + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/combine.js b/bin/conf/combine.js index 22fa9c46..8a4f7494 100644 --- a/bin/conf/combine.js +++ b/bin/conf/combine.js @@ -1,134 +1,134 @@ ;(function (root) { - const cmdConfig = { - command: 'combine', - short: 'cb', - args: [ - { required: false, name: 'type', variadic: false, validator: null, transformer: null, description: '分支类型' }, - { required: false, name: 'name', variadic: false, validator: null, transformer: null, description: '分支名称(不带feature/bugfix前缀)' } - ], - options: [ - { - flags: '-d, --dev', - required: false, // 必填<> - optional: false, // 不必填[] - variadic: false, // 有... - mandatory: false, - short: '-d', - long: '--dev', - negate: false, - description: '同步到dev环境', - defaultValue: false, - value: true, - recommend: true // 自定义值:是否默认选中 - }, - { - flags: '-p, --prod', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-p', - long: '--prod', - negate: false, - description: '同步到prod环境', - defaultValue: false, - value: false, - recommend: false - }, - { - flags: '-b, --build [build]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-b', - long: '--build', - negate: false, - description: '构建应用', - value: 'all', - recommend: true - }, - { - flags: '-m, --commit ', - required: true, - optional: false, - variadic: false, - mandatory: false, - short: '-m', - long: '--commit', - negate: false, - description: '执行commit,需填写信息', - defaultValue: '', - recommend: false - }, - { - flags: '-a, --add', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-a', - long: '--add', - negate: false, - description: '执行add', - defaultValue: false, - recommend: false - }, - { - flags: '--no-bugfix', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--no-bugfix', - negate: true, - description: 'bug分支合并到release时不合并到bug分支', - defaultValue: true, - recommend: false - }, - { - flags: '--as-feature', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--as-feature', - negate: false, - description: 'bug分支合并到release', - recommend: false - } - ], - // 校验传值 - validatorOpts: (val, opts, cb) => { - if (!val.includes('--dev') && !val.includes('--prod')) { - cb(new Error('合并dev或者prod必须至少选一个')) - return - } - if ((val.includes('--add') && !val.includes('--commit')) || (!val.includes('--add') && val.includes('--commit'))) { - cb(new Error('add和commit需要同时选择')) - return - } - cb() - }, - // 校验参数 - validatorArgs: (val, opts, cb) => { - cb() - }, - // 清洗传值 - transformOpts: (val, opts, cb) => { - cb() - }, - // 清洗参数 - transformArgs: (val, opts, cb) => { - cb() - } - } + const cmdConfig = { + command: 'combine', + short: 'cb', + args: [ + { required: false, name: 'type', variadic: false, validator: null, transformer: null, description: '分支类型' }, + { required: false, name: 'name', variadic: false, validator: null, transformer: null, description: '分支名称(不带feature/bugfix前缀)' } + ], + options: [ + { + flags: '-d, --dev', + required: false, // 必填<> + optional: false, // 不必填[] + variadic: false, // 有... + mandatory: false, + short: '-d', + long: '--dev', + negate: false, + description: '同步到dev环境', + defaultValue: false, + value: true, + recommend: true // 自定义值:是否默认选中 + }, + { + flags: '-p, --prod', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-p', + long: '--prod', + negate: false, + description: '同步到prod环境', + defaultValue: false, + value: false, + recommend: false + }, + { + flags: '-b, --build [build]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-b', + long: '--build', + negate: false, + description: '构建应用', + value: 'all', + recommend: true + }, + { + flags: '-m, --commit ', + required: true, + optional: false, + variadic: false, + mandatory: false, + short: '-m', + long: '--commit', + negate: false, + description: '执行commit,需填写信息', + defaultValue: '', + recommend: false + }, + { + flags: '-a, --add', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-a', + long: '--add', + negate: false, + description: '执行add', + defaultValue: false, + recommend: false + }, + { + flags: '--no-bugfix', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--no-bugfix', + negate: true, + description: 'bug分支合并到release时不合并到bug分支', + defaultValue: true, + recommend: false + }, + { + flags: '--as-feature', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--as-feature', + negate: false, + description: 'bug分支合并到release', + recommend: false + } + ], + // 校验传值 + validatorOpts: (val, opts, cb) => { + if (!val.includes('--dev') && !val.includes('--prod')) { + cb(new Error('合并dev或者prod必须至少选一个')) + return + } + if ((val.includes('--add') && !val.includes('--commit')) || (!val.includes('--add') && val.includes('--commit'))) { + cb(new Error('add和commit需要同时选择')) + return + } + cb() + }, + // 校验参数 + validatorArgs: (val, opts, cb) => { + cb() + }, + // 清洗传值 + transformOpts: (val, opts, cb) => { + cb() + }, + // 清洗参数 + transformArgs: (val, opts, cb) => { + cb() + } + } - // console.info(typeof exports, typeof module, typeof define, typeof exports) + // console.info(typeof exports, typeof module, typeof define, typeof exports) - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/continue.js b/bin/conf/continue.js index cf8eea68..e6fef019 100644 --- a/bin/conf/continue.js +++ b/bin/conf/continue.js @@ -1,27 +1,27 @@ ;(function (root) { - const cmdConfig = { - command: 'continue', - short: 'ct', - args: [], - options: [ - { - flags: '-l, --list', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-l', - long: '--list', - negate: false, - description: '显示指令队列', - defaultValue: false - } - ] - } + const cmdConfig = { + command: 'continue', + short: 'ct', + args: [], + options: [ + { + flags: '-l, --list', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-l', + long: '--list', + negate: false, + description: '显示指令队列', + defaultValue: false + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/copy.js b/bin/conf/copy.js index 418221a7..51fd9a1b 100644 --- a/bin/conf/copy.js +++ b/bin/conf/copy.js @@ -1,42 +1,42 @@ ;(function (root) { - const cmdConfig = { - command: 'copy', - short: 'cp', - args: [ - { required: true, name: 'from', variadic: false }, - { required: false, name: 'commitid', variadic: true } - ], - options: [ - { - flags: '-k, --key [keyword]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-k', - long: '--key', - negate: false, - description: '模糊搜索commit信息关键词', - defaultValue: '' - }, - { - flags: '-a, --author [author]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-a', - long: '--author', - negate: false, - description: '提交者', - defaultValue: '' - } - ] - } + const cmdConfig = { + command: 'copy', + short: 'cp', + args: [ + { required: true, name: 'from', variadic: false }, + { required: false, name: 'commitid', variadic: true } + ], + options: [ + { + flags: '-k, --key [keyword]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-k', + long: '--key', + negate: false, + description: '模糊搜索commit信息关键词', + defaultValue: '' + }, + { + flags: '-a, --author [author]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-a', + long: '--author', + negate: false, + description: '提交者', + defaultValue: '' + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/end.js b/bin/conf/end.js index 2daab900..d0d5aee1 100644 --- a/bin/conf/end.js +++ b/bin/conf/end.js @@ -1,17 +1,17 @@ ;(function (root) { - const cmdConfig = { - command: 'end', - short: 'ed', - args: [ - { required: false, name: 'type', variadic: false, description: '分支类型' }, - { required: false, name: 'name', variadic: false, description: '分支名称(不带feature/bugfix前缀)' } - ], - options: [] - } + const cmdConfig = { + command: 'end', + short: 'ed', + args: [ + { required: false, name: 'type', variadic: false, description: '分支类型' }, + { required: false, name: 'name', variadic: false, description: '分支名称(不带feature/bugfix前缀)' } + ], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/get.js b/bin/conf/get.js index 1eb4bdd0..8a05ae99 100644 --- a/bin/conf/get.js +++ b/bin/conf/get.js @@ -1,30 +1,30 @@ ;(function (root) { - const cmdConfig = { - command: 'get', - short: 'gt', - args: [ - { required: false, name: 'message', variadic: false }, - { required: false, name: 'index', variadic: false } - ], - options: [ - { - flags: '-k, --keep [keep]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-k', - long: '--keep', - negate: false, - description: '保留暂存区不删除', - defaultValue: false - } - ] - } + const cmdConfig = { + command: 'get', + short: 'gt', + args: [ + { required: false, name: 'message', variadic: false }, + { required: false, name: 'index', variadic: false } + ], + options: [ + { + flags: '-k, --keep [keep]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-k', + long: '--keep', + negate: false, + description: '保留暂存区不删除', + defaultValue: false + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/go.js b/bin/conf/go.js index 8b982e80..138886ba 100644 --- a/bin/conf/go.js +++ b/bin/conf/go.js @@ -1,14 +1,14 @@ ;(function (root) { - const cmdConfig = { - command: 'go', - short: '', - args: [], - options: [] - } + const cmdConfig = { + command: 'go', + short: '', + args: [], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/hook.js b/bin/conf/hook.js index bd3c4aec..ef5f91ee 100644 --- a/bin/conf/hook.js +++ b/bin/conf/hook.js @@ -1,85 +1,85 @@ ;(function (root) { - const cmdConfig = { - command: 'hook', - short: 'hk', - args: [ - { - required: false, - name: 'command', - variadic: false - }, - { - required: false, - name: 'args', - variadic: true - } - ], - options: [ - { - flags: '--no-verify', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--no-verify', - negate: true, - description: '是否需要跳过校验权限', - defaultValue: false - }, - { - flags: '--latest [latest]', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '', - long: '--latest', - negate: false, - description: '查询在某个时间之后的日志,填写格式:10s/2m/2h/3d/4M/5y', - defaultValue: '7d' - }, - { - flags: '--limit [limit]', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '', - long: '--limit', - negate: false, - description: '最多查询的日志条数', - defaultValue: 20 - }, - { - flags: '-t, --type ', - required: true, - optional: false, - variadic: false, - mandatory: false, - short: '-t', - long: '--type', - negate: false, - description: '检测类型', - defaultValue: '' - }, - { - flags: '--branch [branch]', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '', - long: '--branch', - negate: false, - description: '要查询的分支', - defaultValue: '' - } - ] - } + const cmdConfig = { + command: 'hook', + short: 'hk', + args: [ + { + required: false, + name: 'command', + variadic: false + }, + { + required: false, + name: 'args', + variadic: true + } + ], + options: [ + { + flags: '--no-verify', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--no-verify', + negate: true, + description: '是否需要跳过校验权限', + defaultValue: false + }, + { + flags: '--latest [latest]', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '', + long: '--latest', + negate: false, + description: '查询在某个时间之后的日志,填写格式:10s/2m/2h/3d/4M/5y', + defaultValue: '7d' + }, + { + flags: '--limit [limit]', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '', + long: '--limit', + negate: false, + description: '最多查询的日志条数', + defaultValue: 20 + }, + { + flags: '-t, --type ', + required: true, + optional: false, + variadic: false, + mandatory: false, + short: '-t', + long: '--type', + negate: false, + description: '检测类型', + defaultValue: '' + }, + { + flags: '--branch [branch]', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '', + long: '--branch', + negate: false, + description: '要查询的分支', + defaultValue: '' + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/link.js b/bin/conf/link.js index 0e723e47..cd79dafa 100644 --- a/bin/conf/link.js +++ b/bin/conf/link.js @@ -1,17 +1,17 @@ ;(function (root) { - const cmdConfig = { - command: 'link', - short: null, - args: [ - { required: true, name: 'name', variadic: false }, - { required: true, name: 'path', variadic: false } - ], - options: [] - } + const cmdConfig = { + command: 'link', + short: null, + args: [ + { required: true, name: 'name', variadic: false }, + { required: true, name: 'path', variadic: false } + ], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/log.js b/bin/conf/log.js index c5dbf9e0..6bc4a0da 100644 --- a/bin/conf/log.js +++ b/bin/conf/log.js @@ -1,45 +1,45 @@ ;(function (root) { - const cmdConfig = { - command: 'log', - short: 'lg', - args: [ - { - required: false, - name: 'branche', - variadic: false - } - ], - options: [ - { - flags: '--latest [latest]', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '', - long: '--latest', - negate: false, - description: '查询在某个时间之后的日志,填写格式:10s/2m/2h/3d/4M/5y', - defaultValue: '7d' - }, - { - flags: '--limit [limit]', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '', - long: '--limit', - negate: false, - description: '最多查询的日志条数', - defaultValue: 20 - } - ] - } + const cmdConfig = { + command: 'log', + short: 'lg', + args: [ + { + required: false, + name: 'branche', + variadic: false + } + ], + options: [ + { + flags: '--latest [latest]', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '', + long: '--latest', + negate: false, + description: '查询在某个时间之后的日志,填写格式:10s/2m/2h/3d/4M/5y', + defaultValue: '7d' + }, + { + flags: '--limit [limit]', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '', + long: '--limit', + negate: false, + description: '最多查询的日志条数', + defaultValue: 20 + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/postmsg.js b/bin/conf/postmsg.js index f5b96782..cf5bf081 100644 --- a/bin/conf/postmsg.js +++ b/bin/conf/postmsg.js @@ -1,20 +1,20 @@ ;(function (root) { - const cmdConfig = { - command: 'postmsg', - short: null, - args: [ - { - required: true, - name: 'message', - variadic: false - } - ], - options: [] - } + const cmdConfig = { + command: 'postmsg', + short: null, + args: [ + { + required: true, + name: 'message', + variadic: false + } + ], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/revert.js b/bin/conf/revert.js index 54d66350..2b879992 100644 --- a/bin/conf/revert.js +++ b/bin/conf/revert.js @@ -1,39 +1,39 @@ ;(function (root) { - const cmdConfig = { - command: 'revert', - short: 'rt', - args: [{ required: false, name: 'commitid', variadic: false }], - options: [ - { - flags: '-n, --number [number]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-n', - long: '--number', - negate: false, - description: '撤销最后一次提交(或者撤销倒数第n次提交)', - defaultValue: '' - }, - { - flags: '-m, --mode [mode]', - required: false, - optional: true, - variadic: false, - mandatory: false, - short: '-m', - long: '--mode', - negate: false, - description: '针对撤销一次merge记录,需要传入类型:1 = 保留当前分支代码,2 = 保留传入代码', - defaultValue: '' - } - ] - } + const cmdConfig = { + command: 'revert', + short: 'rt', + args: [{ required: false, name: 'commitid', variadic: false }], + options: [ + { + flags: '-n, --number [number]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-n', + long: '--number', + negate: false, + description: '撤销最后一次提交(或者撤销倒数第n次提交)', + defaultValue: '' + }, + { + flags: '-m, --mode [mode]', + required: false, + optional: true, + variadic: false, + mandatory: false, + short: '-m', + long: '--mode', + negate: false, + description: '针对撤销一次merge记录,需要传入类型:1 = 保留当前分支代码,2 = 保留传入代码', + defaultValue: '' + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/run.js b/bin/conf/run.js index 254e5823..22e7a6dd 100644 --- a/bin/conf/run.js +++ b/bin/conf/run.js @@ -1,25 +1,25 @@ ;(function (root) { - const cmdConfig = { - command: 'run', - short: '', - args: [ - { - required: false, - name: 'command', - variadic: false - }, - { - required: false, - name: 'args', - variadic: true - } - ], - options: [] - } + const cmdConfig = { + command: 'run', + short: '', + args: [ + { + required: false, + name: 'command', + variadic: false + }, + { + required: false, + name: 'args', + variadic: true + } + ], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/save.js b/bin/conf/save.js index ddb5c5bf..b700f164 100644 --- a/bin/conf/save.js +++ b/bin/conf/save.js @@ -1,33 +1,33 @@ ;(function (root) { - const cmdConfig = { - command: 'save', - short: 'sv', - args: [ - { - required: false, - name: 'message', - variadic: false - } - ], - options: [ - { - flags: '-f, --force', - required: false, - optional: false, - variadic: false, - mandatory: false, - short: '-f', - long: '--force', - negate: false, - description: '没有版本的文件也暂存,这会执行git add .', - defaultValue: false - } - ] - } + const cmdConfig = { + command: 'save', + short: 'sv', + args: [ + { + required: false, + name: 'message', + variadic: false + } + ], + options: [ + { + flags: '-f, --force', + required: false, + optional: false, + variadic: false, + mandatory: false, + short: '-f', + long: '--force', + negate: false, + description: '没有版本的文件也暂存,这会执行git add .', + defaultValue: false + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/start.js b/bin/conf/start.js index d838fb40..98b07dc8 100644 --- a/bin/conf/start.js +++ b/bin/conf/start.js @@ -1,17 +1,17 @@ ;(function (root) { - const cmdConfig = { - command: 'start', - short: 'st', - args: [ - { required: true, name: 'type', variadic: false, description: '分支类型' }, - { required: true, name: 'name', variadic: false, description: '分支名称(不带feature/bugfix前缀)' } - ], - options: [] - } + const cmdConfig = { + command: 'start', + short: 'st', + args: [ + { required: true, name: 'type', variadic: false, description: '分支类型' }, + { required: true, name: 'name', variadic: false, description: '分支名称(不带feature/bugfix前缀)' } + ], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/unlink.js b/bin/conf/unlink.js index b694879a..97e4c419 100644 --- a/bin/conf/unlink.js +++ b/bin/conf/unlink.js @@ -1,20 +1,20 @@ ;(function (root) { - const cmdConfig = { - command: 'unlink', - short: null, - args: [ - { - required: true, - name: 'name', - variadic: false - } - ], - options: [] - } + const cmdConfig = { + command: 'unlink', + short: null, + args: [ + { + required: true, + name: 'name', + variadic: false + } + ], + options: [] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/conf/update.js b/bin/conf/update.js index 673e04eb..a58ee878 100644 --- a/bin/conf/update.js +++ b/bin/conf/update.js @@ -1,30 +1,30 @@ ;(function (root) { - const cmdConfig = { - command: 'update', - short: 'up', - args: [ - { required: false, name: 'type', variadic: false, description: '分支类型' }, - { required: false, name: 'name', variadic: false, description: '分支名称(不带feature/bugfix前缀)' } - ], - options: [ - { - flags: '--use-merge', - required: false, - optional: false, - variadic: false, - mandatory: false, - long: '--use-merge', - negate: false, - description: '使用merge方式更新(默认rebase)', - defaultValue: false, - recommend: true - } - ] - } + const cmdConfig = { + command: 'update', + short: 'up', + args: [ + { required: false, name: 'type', variadic: false, description: '分支类型' }, + { required: false, name: 'name', variadic: false, description: '分支名称(不带feature/bugfix前缀)' } + ], + options: [ + { + flags: '--use-merge', + required: false, + optional: false, + variadic: false, + mandatory: false, + long: '--use-merge', + negate: false, + description: '使用merge方式更新(默认rebase)', + defaultValue: false, + recommend: true + } + ] + } - /* istanbul ignore next */ - if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig - // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) - else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig - else root['cmdConfig'] = cmdConfig + /* istanbul ignore next */ + if (typeof exports === 'object' && typeof module === 'object') module.exports = cmdConfig + // else if (typeof define === 'function' && define.amd) define(['cmdConfig'], () => cmdConfig) + else if (typeof exports === 'object') exports['cmdConfig'] = cmdConfig + else root['cmdConfig'] = cmdConfig })(typeof window !== 'undefined' ? window : global) diff --git a/bin/gitm-admin.js b/bin/gitm-admin.js index b3c1f5e1..a2d24d01 100755 --- a/bin/gitm-admin.js +++ b/bin/gitm-admin.js @@ -12,304 +12,304 @@ const config = require('./js/getConfig')() * gitm admin clean */ if (create.args.length > 0) { - let _program = program - .name('gitm admin') - .usage(' ') - .description('创建bugfix、release、develop和support分支') - .command('create ' + createArgs(create.args)) - create.options.forEach(o => { - _program.option(o.flags, o.description, o.defaultValue) - }) - // .command('create ') - _program.action(async type => { - const opts = ['bugfix', 'release', 'develop', 'support'] // 允许执行的指令 - let base = type === 'release' ? config.master : config.release, - status = getStatus(), - hasBase = await checkBranch(base), - exits = await checkBranch(config[type]) - if (!status) sh.exit(1) - if (!hasBase) { - sh.echo(error(base + '分支不存在,请先创建' + base + '分支')) - sh.exit(1) - } - if (exits) { - sh.echo(error(config[type] + '分支已存在,不需要重复创建')) - sh.exit(1) - } - if (opts.includes(type)) { - // release从master拉取,其他从release拉取 - let cmd = [`git fetch`, `git checkout ${base}`, `git pull`, `git checkout -b ${config[type]} ${base}`] - queue(cmd).then(data => { - if (data[3].code === 0) { - sh.echo(`${config[type]}分支创建成功,该分支基于${base}创建,您当前已经切换到${config[type]}\n需要发版时,记得执行: ${success('gitm admin publish ' + config[type])}`) - } - }) - } else { - sh.echo(error('type只允许输入:' + opts.join(','))) - sh.exit(1) - } - }) + let _program = program + .name('gitm admin') + .usage(' ') + .description('创建bugfix、release、develop和support分支') + .command('create ' + createArgs(create.args)) + create.options.forEach(o => { + _program.option(o.flags, o.description, o.defaultValue) + }) + // .command('create ') + _program.action(async type => { + const opts = ['bugfix', 'release', 'develop', 'support'] // 允许执行的指令 + let base = type === 'release' ? config.master : config.release, + status = getStatus(), + hasBase = await checkBranch(base), + exits = await checkBranch(config[type]) + if (!status) sh.exit(1) + if (!hasBase) { + sh.echo(error(base + '分支不存在,请先创建' + base + '分支')) + sh.exit(1) + } + if (exits) { + sh.echo(error(config[type] + '分支已存在,不需要重复创建')) + sh.exit(1) + } + if (opts.includes(type)) { + // release从master拉取,其他从release拉取 + let cmd = [`git fetch`, `git checkout ${base}`, `git pull`, `git checkout -b ${config[type]} ${base}`] + queue(cmd).then(data => { + if (data[3].code === 0) { + sh.echo(`${config[type]}分支创建成功,该分支基于${base}创建,您当前已经切换到${config[type]}\n需要发版时,记得执行: ${success('gitm admin publish ' + config[type])}`) + } + }) + } else { + sh.echo(error('type只允许输入:' + opts.join(','))) + sh.exit(1) + } + }) } if (publish.args.length > 0) { - let _program = program - .name('gitm admin') - .usage(' ') - .description('发布bugfix、release、support分支') - .command('publish ' + createArgs(publish.args)) - publish.options.forEach(o => { - _program.option(o.flags, o.description, o.defaultValue) - }) - // .command('publish ') - // .option('-c, --combine', '是否把release代码同步到bug', false) - // .option('--use-rebase', '是否使用rebase方式更新,默认merge', false) - // .option('-p, --prod', '发布bug分支时,是否合并bug到master', false) - // .option('-b, --build [build]', '需要构建的应用') - // .option('--postmsg', '发送消息', false) - _program.action(async (type, opt) => { - const opts = ['bugfix', 'release', 'support'] // 允许执行的指令 - let status = getStatus(), - curBranch = await getCurrent() - if (!status) sh.exit(1) - if (opts.includes(type)) { - /** - * bugfix -> master/release - * release -> master - * develop -> null - * support -> bugfix/release - */ - let cmd = { - bugfix: [ - `git fetch`, - `git checkout ${config.bugfix}`, - `git pull`, - `git checkout ${config.release}`, - `git pull`, - { - cmd: `git merge --no-ff ${config.bugfix}`, - config: { slient: false, again: false, postmsg: opt.postmsg, success: `${config.bugfix}合并到${config.release}成功`, fail: `${config.bugfix}合并到${config.release}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ], - support: [ - `git fetch`, - `git checkout ${config.support}`, - `git pull`, - `git checkout ${config.release}`, - `git pull`, - { - cmd: `git merge --no-ff ${config.support}`, - config: { slient: false, again: false, success: `${config.support}合并到${config.release}成功`, fail: `${config.support}合并到${config.release}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - }, - `git checkout ${config.bugfix}`, - `git pull`, - { - cmd: `git merge --no-ff ${config.support}`, - config: { slient: false, again: false, success: `${config.support}合并到${config.bugfix}成功`, fail: `${config.support}合并到${config.bugfix}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ], - release: [ - `git fetch`, - `git checkout ${config.release}`, - `git pull`, - `git checkout ${config.master}`, - `git pull`, - { - cmd: `git merge --no-ff ${config.release}`, - config: { slient: false, again: false, success: `${config.release}合并到${config.master}成功`, fail: `${config.release}合并到${config.master}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ] - } - // 发布bug分支且同步到master - if (type === 'bugfix' && opt.prod) { - cmd[type] = cmd[type].concat([ - `git checkout ${config.master}`, - `git pull`, - { - cmd: `git merge --no-ff ${config.bugfix}`, - config: { slient: false, again: false, success: `${config.bugfix}合并到${config.master}成功`, fail: `${config.bugfix}合并到${config.master}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ]) - if (opt.build) { - cmd[type] = cmd[type].concat([ - { - cmd: `gitm build ${appName} --env bug --app ${opt.build === true ? 'all' : opt.build}`, - config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } - } - ]) - } - } - // 发布release - if (type === 'release' && opt.build) { - cmd[type] = cmd[type].concat([ - { - cmd: `gitm build ${appName} --env prod --app ${opt.build === true ? 'all' : opt.build}`, - config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } - } - ]) - } - // 发布release分支且同步release代码到bug线 - if (type === 'release' && opt.combine) { - // 使用rebase - if (opt.useRebase) { - cmd[type] = cmd[type].concat([ - `git checkout ${config.release}`, - `git pull`, - `git checkout ${config.bugfix}`, - { - cmd: `git pull origin ${config.bugfix} --rebase`, - config: { slient: false, again: true } - }, - { - cmd: `git rebase ${config.release}`, - config: { slient: false, again: false, postmsg: opt.postmsg, success: `${config.release}同步到${config.bugfix}成功`, fail: `${config.release}同步到${config.bugfix}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ]) - } else { - cmd[type] = cmd[type].concat([ - `git checkout ${config.release}`, - `git pull`, - `git checkout ${config.bugfix}`, - `git pull`, - { - cmd: `git merge --no-ff ${config.release}`, - config: { slient: false, again: false, postmsg: opt.postmsg, success: `${config.release}合并到${config.bugfix}成功`, fail: `${config.release}合并到${config.bugfix}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ]) - } - } - // 回到当前分支 - for (let key in cmd) { - cmd[key].push(`git checkout ${curBranch}`) - } - queue(cmd[type]) - } else { - sh.echo(error('type只允许输入:' + opts.join(','))) - sh.exit(1) - } - }) + let _program = program + .name('gitm admin') + .usage(' ') + .description('发布bugfix、release、support分支') + .command('publish ' + createArgs(publish.args)) + publish.options.forEach(o => { + _program.option(o.flags, o.description, o.defaultValue) + }) + // .command('publish ') + // .option('-c, --combine', '是否把release代码同步到bug', false) + // .option('--use-rebase', '是否使用rebase方式更新,默认merge', false) + // .option('-p, --prod', '发布bug分支时,是否合并bug到master', false) + // .option('-b, --build [build]', '需要构建的应用') + // .option('--postmsg', '发送消息', false) + _program.action(async (type, opt) => { + const opts = ['bugfix', 'release', 'support'] // 允许执行的指令 + let status = getStatus(), + curBranch = await getCurrent() + if (!status) sh.exit(1) + if (opts.includes(type)) { + /** + * bugfix -> master/release + * release -> master + * develop -> null + * support -> bugfix/release + */ + let cmd = { + bugfix: [ + `git fetch`, + `git checkout ${config.bugfix}`, + `git pull`, + `git checkout ${config.release}`, + `git pull`, + { + cmd: `git merge --no-ff ${config.bugfix}`, + config: { slient: false, again: false, postmsg: opt.postmsg, success: `${config.bugfix}合并到${config.release}成功`, fail: `${config.bugfix}合并到${config.release}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ], + support: [ + `git fetch`, + `git checkout ${config.support}`, + `git pull`, + `git checkout ${config.release}`, + `git pull`, + { + cmd: `git merge --no-ff ${config.support}`, + config: { slient: false, again: false, success: `${config.support}合并到${config.release}成功`, fail: `${config.support}合并到${config.release}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + }, + `git checkout ${config.bugfix}`, + `git pull`, + { + cmd: `git merge --no-ff ${config.support}`, + config: { slient: false, again: false, success: `${config.support}合并到${config.bugfix}成功`, fail: `${config.support}合并到${config.bugfix}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ], + release: [ + `git fetch`, + `git checkout ${config.release}`, + `git pull`, + `git checkout ${config.master}`, + `git pull`, + { + cmd: `git merge --no-ff ${config.release}`, + config: { slient: false, again: false, success: `${config.release}合并到${config.master}成功`, fail: `${config.release}合并到${config.master}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ] + } + // 发布bug分支且同步到master + if (type === 'bugfix' && opt.prod) { + cmd[type] = cmd[type].concat([ + `git checkout ${config.master}`, + `git pull`, + { + cmd: `git merge --no-ff ${config.bugfix}`, + config: { slient: false, again: false, success: `${config.bugfix}合并到${config.master}成功`, fail: `${config.bugfix}合并到${config.master}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ]) + if (opt.build) { + cmd[type] = cmd[type].concat([ + { + cmd: `gitm build ${appName} --env bug --app ${opt.build === true ? 'all' : opt.build}`, + config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } + } + ]) + } + } + // 发布release + if (type === 'release' && opt.build) { + cmd[type] = cmd[type].concat([ + { + cmd: `gitm build ${appName} --env prod --app ${opt.build === true ? 'all' : opt.build}`, + config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } + } + ]) + } + // 发布release分支且同步release代码到bug线 + if (type === 'release' && opt.combine) { + // 使用rebase + if (opt.useRebase) { + cmd[type] = cmd[type].concat([ + `git checkout ${config.release}`, + `git pull`, + `git checkout ${config.bugfix}`, + { + cmd: `git pull origin ${config.bugfix} --rebase`, + config: { slient: false, again: true } + }, + { + cmd: `git rebase ${config.release}`, + config: { slient: false, again: false, postmsg: opt.postmsg, success: `${config.release}同步到${config.bugfix}成功`, fail: `${config.release}同步到${config.bugfix}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ]) + } else { + cmd[type] = cmd[type].concat([ + `git checkout ${config.release}`, + `git pull`, + `git checkout ${config.bugfix}`, + `git pull`, + { + cmd: `git merge --no-ff ${config.release}`, + config: { slient: false, again: false, postmsg: opt.postmsg, success: `${config.release}合并到${config.bugfix}成功`, fail: `${config.release}合并到${config.bugfix}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ]) + } + } + // 回到当前分支 + for (let key in cmd) { + cmd[key].push(`git checkout ${curBranch}`) + } + queue(cmd[type]) + } else { + sh.echo(error('type只允许输入:' + opts.join(','))) + sh.exit(1) + } + }) } if (update.args.length > 0) { - let _program = program - .name('gitm admin') - .usage(' [-m --mode [mode]]') - .description('更新bugfix、release、support分支代码') - .command('update ' + createArgs(update.args)) - update.options.forEach(o => { - _program.option(o.flags, o.description, o.defaultValue) - }) - // .command('update ') - // .option('--use-rebase', '是否使用rebase方式更新,默认merge', false) - // .option('-m, --mode [mode]', '出现冲突时,保留传入代码还是保留当前代码;1=采用当前 2=采用传入;默认为 0=手动处理。本参数不可与--use-rebase同时使用', 0) - // .option('--postmsg', '发送消息', false) - _program.action((type, opt) => { - const opts = ['bugfix', 'release', 'support'] // 允许执行的指令 - let base = type === 'release' ? config.master : config.release, - mode = '', // 冲突时,保留哪方代码 - status = getStatus() - if (!status) sh.exit(1) - if (opt.mode === 1) { - mode = ' --strategy-option ours' - } else if (opt.mode === 2) { - mode = ' --strategy-option theirs' - } - if (opts.includes(type)) { - let cmd = [ - `git fetch`, - `git checkout ${base}`, - `git pull`, - `git checkout ${config[type]}`, - { - cmd: `git pull`, - config: { slient: false, again: true } - }, - { - cmd: `git merge --no-ff ${base}${mode}`, - config: { slient: false, again: false, postmsg: opt.postmsg, success: `${base}同步到${config[type]}成功`, fail: `${base}同步到${config[type]}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ] - if (opt.useRebase) { - cmd = [ - `git fetch`, - `git checkout ${base}`, - `git pull`, - `git checkout ${config[type]}`, - { - cmd: `git pull origin ${config[type]} --rebase`, - config: { slient: false, again: true } - }, - { - cmd: `git rebase ${base}`, - config: { slient: false, again: false, postmsg: opt.postmsg, success: `${base}同步到${config[type]}成功`, fail: `${base}同步到${config[type]}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - } - ] - } - queue(cmd) - } else { - sh.echo(error('type只允许输入:' + opts.join(','))) - sh.exit(1) - } - }) + let _program = program + .name('gitm admin') + .usage(' [-m --mode [mode]]') + .description('更新bugfix、release、support分支代码') + .command('update ' + createArgs(update.args)) + update.options.forEach(o => { + _program.option(o.flags, o.description, o.defaultValue) + }) + // .command('update ') + // .option('--use-rebase', '是否使用rebase方式更新,默认merge', false) + // .option('-m, --mode [mode]', '出现冲突时,保留传入代码还是保留当前代码;1=采用当前 2=采用传入;默认为 0=手动处理。本参数不可与--use-rebase同时使用', 0) + // .option('--postmsg', '发送消息', false) + _program.action((type, opt) => { + const opts = ['bugfix', 'release', 'support'] // 允许执行的指令 + let base = type === 'release' ? config.master : config.release, + mode = '', // 冲突时,保留哪方代码 + status = getStatus() + if (!status) sh.exit(1) + if (opt.mode === 1) { + mode = ' --strategy-option ours' + } else if (opt.mode === 2) { + mode = ' --strategy-option theirs' + } + if (opts.includes(type)) { + let cmd = [ + `git fetch`, + `git checkout ${base}`, + `git pull`, + `git checkout ${config[type]}`, + { + cmd: `git pull`, + config: { slient: false, again: true } + }, + { + cmd: `git merge --no-ff ${base}${mode}`, + config: { slient: false, again: false, postmsg: opt.postmsg, success: `${base}同步到${config[type]}成功`, fail: `${base}同步到${config[type]}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ] + if (opt.useRebase) { + cmd = [ + `git fetch`, + `git checkout ${base}`, + `git pull`, + `git checkout ${config[type]}`, + { + cmd: `git pull origin ${config[type]} --rebase`, + config: { slient: false, again: true } + }, + { + cmd: `git rebase ${base}`, + config: { slient: false, again: false, postmsg: opt.postmsg, success: `${base}同步到${config[type]}成功`, fail: `${base}同步到${config[type]}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + } + ] + } + queue(cmd) + } else { + sh.echo(error('type只允许输入:' + opts.join(','))) + sh.exit(1) + } + }) } if (clean.args.length > 0) { - let _program = program - .name('gitm admin') - .usage(' ') - .description('构建清理工作') - .command('clean ' + createArgs(clean.args)) - clean.options.forEach(o => { - _program.option(o.flags, o.description, o.defaultValue) - }) - // .command('clean ') - _program.action(type => { - const opts = ['bugfix', 'release', 'develop', 'master'] // 允许执行的指令 - let status = getStatus() - if (!status) sh.exit(1) - if (opts.includes(type)) { - let cmd = [`git fetch`, `git checkout . -f`, `git clean -fd`, `git checkout ${config.master}`, `git branch -D ${config[type]}`, `git fetch`, `git checkout ${config[type]}`, `git pull`] - if (type === 'master') cmd = [`git checkout .`, `git clean -fd`, `git checkout ${config.master}`, `git clean -fd`, `git fetch`, `git pull`] - queue(cmd) - } else { - sh.echo(error('type只允许输入:' + opts.join(','))) - sh.exit(1) - } - }) + let _program = program + .name('gitm admin') + .usage(' ') + .description('构建清理工作') + .command('clean ' + createArgs(clean.args)) + clean.options.forEach(o => { + _program.option(o.flags, o.description, o.defaultValue) + }) + // .command('clean ') + _program.action(type => { + const opts = ['bugfix', 'release', 'develop', 'master'] // 允许执行的指令 + let status = getStatus() + if (!status) sh.exit(1) + if (opts.includes(type)) { + let cmd = [`git fetch`, `git checkout . -f`, `git clean -fd`, `git checkout ${config.master}`, `git branch -D ${config[type]}`, `git fetch`, `git checkout ${config[type]}`, `git pull`] + if (type === 'master') cmd = [`git checkout .`, `git clean -fd`, `git checkout ${config.master}`, `git clean -fd`, `git fetch`, `git pull`] + queue(cmd) + } else { + sh.echo(error('type只允许输入:' + opts.join(','))) + sh.exit(1) + } + }) } program.parse(process.argv) diff --git a/bin/gitm-branch.js b/bin/gitm-branch.js index 28f98600..ef801499 100755 --- a/bin/gitm-branch.js +++ b/bin/gitm-branch.js @@ -9,7 +9,7 @@ const { queue, createArgs } = require('./js/index') program.name('gitm branch').usage('[-k --key [keyword]] [-t --type [type]] [-d --delete [branch]] [-r --remote [remote]] [-D --forcedelete [branch]]').description('分支查询、删除(注意该指令不用于创建分支,如需创建分支请走start流程)') if (args.length > 0) program.arguments(createArgs(args)) options.forEach(o => { - program.option(o.flags, o.description, o.defaultValue) + program.option(o.flags, o.description, o.defaultValue) }) // .option('-k, --key [keyword]', '查询分支的关键词', null) // .option('-r, --remote', '是否查询远程分支(这个参数不用于删除分支)默认只查询本地', false) @@ -18,49 +18,49 @@ options.forEach(o => { // .option('-D, --forcedelete [branch]', '强行删除分支', null) // .option('-u, --upstream [upstream]', '设置与远程分支关联') program.action(opt => { - let cmd = [] - if (opt.delete) { - // 删除分支 - cmd.push(`git branch -d ${opt.delete}`) - } else if (opt.forcedelete) { - // 强行删除分支 - cmd.push(`git branch -D ${opt.forcedelete}`) - } else if (opt.upstream) { - if (typeof opt.upstream === 'string') { - // 与远程分支关联 - cmd.push(`git branch --set-upstream-to origin/${opt.upstream}`) - } else { - // 取消远程分支关联 - cmd.push(`git branch --unset-upstream`) - } - } else { - // 分支查询 - cmd.push(`git branch -a`) - queue(cmd).then(data => { - data.forEach((el, index) => { - if (index === 0 && el.code === 0) { - let list = (el.out && el.out.split('\n')) || [] - list = list.filter(el => { - let fit = true - if (opt.key) { - fit = fit && el.indexOf(opt.key) > -1 - } - if (opt.type) { - fit = fit && el.indexOf(opt.type) > -1 - } - if (opt.remote) { - fit = fit && el.indexOf('remotes/origin') > -1 - } else { - fit = fit && el.indexOf('remotes/origin') === -1 - } - return fit - }) - sh.echo(list.join('\n')) - } - }) - }) - return - } - queue(cmd) + let cmd = [] + if (opt.delete) { + // 删除分支 + cmd.push(`git branch -d ${opt.delete}`) + } else if (opt.forcedelete) { + // 强行删除分支 + cmd.push(`git branch -D ${opt.forcedelete}`) + } else if (opt.upstream) { + if (typeof opt.upstream === 'string') { + // 与远程分支关联 + cmd.push(`git branch --set-upstream-to origin/${opt.upstream}`) + } else { + // 取消远程分支关联 + cmd.push(`git branch --unset-upstream`) + } + } else { + // 分支查询 + cmd.push(`git branch -a`) + queue(cmd).then(data => { + data.forEach((el, index) => { + if (index === 0 && el.code === 0) { + let list = (el.out && el.out.split('\n')) || [] + list = list.filter(el => { + let fit = true + if (opt.key) { + fit = fit && el.indexOf(opt.key) > -1 + } + if (opt.type) { + fit = fit && el.indexOf(opt.type) > -1 + } + if (opt.remote) { + fit = fit && el.indexOf('remotes/origin') > -1 + } else { + fit = fit && el.indexOf('remotes/origin') === -1 + } + return fit + }) + sh.echo(list.join('\n')) + } + }) + }) + return + } + queue(cmd) }) program.parse(process.argv) diff --git a/bin/gitm-build.js b/bin/gitm-build.js index 5e700dcd..6b14037f 100755 --- a/bin/gitm-build.js +++ b/bin/gitm-build.js @@ -9,15 +9,15 @@ const runJenkins = require('./js/runJenkins') program.name('gitm build').usage('').description('构建Jenkins') if (args.length > 0) program.arguments(createArgs(args)) options.forEach(o => { - program.option(o.flags, o.description, o.defaultValue) + program.option(o.flags, o.description, o.defaultValue) }) // .option('-e, --env [env]', '需要构建的环境,可选dev、prod、bug、all', 'dev') // .option('-a, --app [app]', '需要构建的应用', 'all') program.action((project, opt) => { - runJenkins({ - env: opt.env, - project, - app: opt.app - }) + runJenkins({ + env: opt.env, + project, + app: opt.app + }) }) program.parse(process.argv) diff --git a/bin/gitm-clean.js b/bin/gitm-clean.js index 2c63e3aa..7b92a699 100755 --- a/bin/gitm-clean.js +++ b/bin/gitm-clean.js @@ -7,15 +7,15 @@ const { root, gitDir } = require('./js/gitRevParse')() * gitm clean */ program - .name('gitm clean') - .description('清理gitmars缓存') - .option('-f, --force', '强制清理', false) - .action(opt => { - sh.rm(gitDir + '/.gitmarscommands', gitDir + '/.gitmarslog', gitDir + '/buildConfig.json', gitDir + '/buildConfig.txt') - if (opt.force) { - sh.echo(warning('您输入了--force,将同时清理本地gitmars配置文件')) - sh.rm(root + '/gitmarsconfig.json', root + '/.gitmarsrc') - } - sh.echo(success('清理完毕')) - }) + .name('gitm clean') + .description('清理gitmars缓存') + .option('-f, --force', '强制清理', false) + .action(opt => { + sh.rm(gitDir + '/.gitmarscommands', gitDir + '/.gitmarslog', gitDir + '/buildConfig.json', gitDir + '/buildConfig.txt') + if (opt.force) { + sh.echo(warning('您输入了--force,将同时清理本地gitmars配置文件')) + sh.rm(root + '/gitmarsconfig.json', root + '/.gitmarsrc') + } + sh.echo(success('清理完毕')) + }) program.parse(process.argv) diff --git a/bin/gitm-combine.js b/bin/gitm-combine.js index 4d74e285..7e94fdb1 100755 --- a/bin/gitm-combine.js +++ b/bin/gitm-combine.js @@ -12,7 +12,7 @@ const config = require('./js/getConfig')() program.name('gitm combine').usage('[type] [name] [-d --dev] [-p --prod]').description('合并bugfix任务分支、合并feature功能开发分支、合并support分支') if (args.length > 0) program.arguments(createArgs(args)) options.forEach(o => { - program.option(o.flags, o.description, o.defaultValue) + program.option(o.flags, o.description, o.defaultValue) }) // .option('-d, --dev', '是否同步到alpha测试环境', false) // .option('-p, --prod', '是否同步到预发布环境', false) @@ -22,150 +22,150 @@ options.forEach(o => { // .option('--no-bugfix', '不同步到bug分支') // .option('--as-feature', 'bug分支合并到release') program.action(async (type, name, opt) => { - const allow = ['bugfix', 'feature', 'support'] // 允许执行的指令 - const deny = [defaults.master, defaults.develop, defaults.release, defaults.bugfix, defaults.support] - let status = !opt.add && opt.commit === '' ? getStatus() : true - if (!opt.dev && !opt.prod) { - sh.echo('请输入需要同步到的环境') - sh.exit(1) - } - if (!status) sh.exit(1) - if (opt.commit === true) { - sh.echo(error(`请输入要提交的message`)) - sh.exit(1) - } - if (!type) { - // type和name都没传且当前分支是开发分支 - ;[type, name] = getCurrent().split('/') - if (!name) { - deny.includes(type) && sh.echo(error(`骚年,你在${type}分支执行这个指令是什么骚操作?`)) - sh.exit(1) - } - } else if (!name) { - // 传了type没传name - if (allow.includes(type)) { - sh.echo('请输入分支名称') - sh.exit(1) - } - let branchs = await searchBranch(type) - if (branchs.length === 1) { - ;[type, name] = branchs[0].split('/') - } else { - sh.echo(branchs.length > 1 ? `查询到多条名称包含${type}的分支,请输入分支类型` : error('分支不存在,请正确输入')) - sh.exit(1) - } - } - if (allow.includes(type) && name) { - let base = type === 'bugfix' ? config.bugfix : config.release, - cmd = [] - if (opt.add) { - cmd = cmd.concat([`git add .`]) - } - if (opt.commit) { - cmd = cmd.concat([`git commit -m "${opt.commit}"`]) - } - if (opt.dev) { - cmd = cmd.concat([ - `git fetch`, - `git checkout ${config.develop}`, - `git pull`, - { - cmd: `git merge --no-ff ${type}/${name}`, - config: { slient: false, again: false, success: `${type}/${name}合并到${config.develop}成功`, fail: `${type}/${name}合并到${config.develop}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - }, - `git checkout ${type}/${name}` - ]) - if (opt.build) { - cmd = cmd.concat([ - { - cmd: `gitm build ${appName} --env dev --app ${opt.build === true ? 'all' : opt.build}`, - config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } - } - ]) - } - } - if (opt.prod) { - if (!opt.noBugfix && !opt.asFeature) { - // 传入noBugfix不合bug - cmd = cmd.concat([ - `git fetch`, - `git checkout ${base}`, - `git pull`, - { - cmd: `git merge --no-ff ${type}/${name}`, - config: { slient: false, again: false, success: `${type}/${name}合并到${base}成功`, fail: `${type}/${name}合并到${base}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - }, - `git checkout ${type}/${name}` - ]) - } + const allow = ['bugfix', 'feature', 'support'] // 允许执行的指令 + const deny = [defaults.master, defaults.develop, defaults.release, defaults.bugfix, defaults.support] + let status = !opt.add && opt.commit === '' ? getStatus() : true + if (!opt.dev && !opt.prod) { + sh.echo('请输入需要同步到的环境') + sh.exit(1) + } + if (!status) sh.exit(1) + if (opt.commit === true) { + sh.echo(error(`请输入要提交的message`)) + sh.exit(1) + } + if (!type) { + // type和name都没传且当前分支是开发分支 + ;[type, name] = getCurrent().split('/') + if (!name) { + deny.includes(type) && sh.echo(error(`骚年,你在${type}分支执行这个指令是什么骚操作?`)) + sh.exit(1) + } + } else if (!name) { + // 传了type没传name + if (allow.includes(type)) { + sh.echo('请输入分支名称') + sh.exit(1) + } + let branchs = await searchBranch(type) + if (branchs.length === 1) { + ;[type, name] = branchs[0].split('/') + } else { + sh.echo(branchs.length > 1 ? `查询到多条名称包含${type}的分支,请输入分支类型` : error('分支不存在,请正确输入')) + sh.exit(1) + } + } + if (allow.includes(type) && name) { + let base = type === 'bugfix' ? config.bugfix : config.release, + cmd = [] + if (opt.add) { + cmd = cmd.concat([`git add .`]) + } + if (opt.commit) { + cmd = cmd.concat([`git commit -m "${opt.commit}"`]) + } + if (opt.dev) { + cmd = cmd.concat([ + `git fetch`, + `git checkout ${config.develop}`, + `git pull`, + { + cmd: `git merge --no-ff ${type}/${name}`, + config: { slient: false, again: false, success: `${type}/${name}合并到${config.develop}成功`, fail: `${type}/${name}合并到${config.develop}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + }, + `git checkout ${type}/${name}` + ]) + if (opt.build) { + cmd = cmd.concat([ + { + cmd: `gitm build ${appName} --env dev --app ${opt.build === true ? 'all' : opt.build}`, + config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } + } + ]) + } + } + if (opt.prod) { + if (!opt.noBugfix && !opt.asFeature) { + // 传入noBugfix不合bug + cmd = cmd.concat([ + `git fetch`, + `git checkout ${base}`, + `git pull`, + { + cmd: `git merge --no-ff ${type}/${name}`, + config: { slient: false, again: false, success: `${type}/${name}合并到${base}成功`, fail: `${type}/${name}合并到${base}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + }, + `git checkout ${type}/${name}` + ]) + } - // bugfix分支走release发布 - if (type === 'bugfix' && opt.asFeature) { - cmd = cmd.concat([ - `git fetch`, - `git checkout ${config.release}`, - `git pull`, - { - cmd: `git merge --no-ff ${type}/${name}`, - config: { slient: false, again: false, success: `${type}/${name}合并到${config.release}成功`, fail: `${type}/${name}合并到${config.release}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - }, - `git checkout ${type}/${name}` - ]) - } - // support分支需要合到bugfix - if (type === 'support' && opt.bugfix) { - cmd = cmd.concat([ - `git fetch`, - `git checkout ${config.bugfix}`, - `git pull`, - { - cmd: `git merge --no-ff ${type}/${name}`, - config: { slient: false, again: false, success: `${type}/${name}合并到${config.bugfix}成功`, fail: `${type}/${name}合并到${config.bugfix}出错了,请根据提示处理` } - }, - { - cmd: `git push`, - config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } - }, - `git checkout ${type}/${name}` - ]) - } - // 仅支持构建bug - if (opt.build) { - if (type === 'bugfix') { - cmd = cmd.concat([ - { - cmd: `gitm build ${appName} --env bug --app ${opt.build === true ? 'all' : opt.build}`, - config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } - } - ]) - } - // support分支要构建bug和release - if (type === 'support' && opt.bugfix) { - cmd = cmd.concat([ - { - cmd: `gitm build ${appName} --env bug --app ${opt.build === true ? 'all' : opt.build}`, - config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } - } - ]) - } - } - } - queue(cmd) - } else { - sh.echo(error('type只允许输入:' + JSON.stringify(allow))) - sh.exit(1) - } + // bugfix分支走release发布 + if (type === 'bugfix' && opt.asFeature) { + cmd = cmd.concat([ + `git fetch`, + `git checkout ${config.release}`, + `git pull`, + { + cmd: `git merge --no-ff ${type}/${name}`, + config: { slient: false, again: false, success: `${type}/${name}合并到${config.release}成功`, fail: `${type}/${name}合并到${config.release}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + }, + `git checkout ${type}/${name}` + ]) + } + // support分支需要合到bugfix + if (type === 'support' && opt.bugfix) { + cmd = cmd.concat([ + `git fetch`, + `git checkout ${config.bugfix}`, + `git pull`, + { + cmd: `git merge --no-ff ${type}/${name}`, + config: { slient: false, again: false, success: `${type}/${name}合并到${config.bugfix}成功`, fail: `${type}/${name}合并到${config.bugfix}出错了,请根据提示处理` } + }, + { + cmd: `git push`, + config: { slient: false, again: true, success: '推送成功', fail: '推送失败,请根据提示处理' } + }, + `git checkout ${type}/${name}` + ]) + } + // 仅支持构建bug + if (opt.build) { + if (type === 'bugfix') { + cmd = cmd.concat([ + { + cmd: `gitm build ${appName} --env bug --app ${opt.build === true ? 'all' : opt.build}`, + config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } + } + ]) + } + // support分支要构建bug和release + if (type === 'support' && opt.bugfix) { + cmd = cmd.concat([ + { + cmd: `gitm build ${appName} --env bug --app ${opt.build === true ? 'all' : opt.build}`, + config: { slient: true, again: false, success: '调起构建成功', fail: '调起构建失败' } + } + ]) + } + } + } + queue(cmd) + } else { + sh.echo(error('type只允许输入:' + JSON.stringify(allow))) + sh.exit(1) + } }) program.parse(process.argv) diff --git a/bin/gitm-config.js b/bin/gitm-config.js index 397da054..6bfa19b1 100644 --- a/bin/gitm-config.js +++ b/bin/gitm-config.js @@ -9,47 +9,47 @@ const config = require('./js/getConfig')() * gitm config set */ program - .name('gitm config') - .usage('