Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Jun 27, 2020
2 parents 7fe7f7d + 997bad6 commit fdf1ef6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 36 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2020.06.27 v1.2.6更新日志
1. 升级upgrade指令,Windows用户终于能用上升级指令了!

# 2020.06.27 v1.2.5更新日志
1. 升级get/save指令,暂存区“绑定”git分支,新增高级用法
2. 修复config指令bug
Expand Down
86 changes: 59 additions & 27 deletions lib/gitm-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,72 @@ require("core-js/modules/es.array.concat");

require("core-js/modules/es.function.name");

require("core-js/modules/es.object.to-string");

require("core-js/modules/es.promise");

require("core-js/modules/es.regexp.exec");

require("core-js/modules/es.string.match");

require("core-js/modules/es.string.split");

require("regenerator-runtime/runtime");

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var program = require('commander');

var sh = require('shelljs');

var execa = require('execa');

var _require = require('./js/index'),
queue = _require.queue;

program.name('gitm upgrade').usage('[version]').description('升级gitmars').arguments('[version]').option('-m, --mirror', '是否使用淘宝镜像', false).action(function (version, opt) {
var match = version && version.match(/[0-9.]+$/) || null,
v = match ? match[0] : 'latest',
cmd = [{
cmd: "npm install -g gitmars@".concat(v, " ").concat(opt.mirror ? '--registry=https://registry.npm.taobao.org' : ''),
config: {
slient: false,
again: true,
kill: false,
success: '升级成功',
fail: '升级失败,请重试'
}
}, {
cmd: "gitm -v",
config: {
slient: true,
again: false
}
}];
queue(cmd).then(function (data) {
if (data[0].code === 0) {
sh.echo(data[1].out);
}
});
});
queue = _require.queue,
success = _require.success;

var ora = require('ora');

program.name('gitm upgrade').usage('[version]').description('升级gitmars').arguments('[version]').option('-m, --mirror', '是否使用淘宝镜像', false).action(function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(version, opt) {
var spinner, match, cmd, install, ver;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
spinner = ora(success('正在安装请稍后')).start();
match = version && version.match(/[0-9.]+$/) || null;
cmd = "install -g gitmars@".concat(match ? match[0] : 'latest', " ").concat(opt.mirror ? '--registry=https://registry.npm.taobao.org' : '');
_context.next = 5;
return execa('npm', cmd.split(' '), {
cwd: process.cwd()
});

case 5:
install = _context.sent;
_context.next = 8;
return execa('gitm', ['-v'], {
cwd: process.cwd()
});

case 8:
ver = _context.sent;
spinner.stop();
sh.echo(install.stdout + "\n".concat(success('安装完成')));
sh.echo(ver.stdout);

case 12:
case "end":
return _context.stop();
}
}
}, _callee);
}));

return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}());
program.parse(process.argv);
9 changes: 1 addition & 8 deletions lib/gitm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ require("core-js/modules/es.array.concat");

require("core-js/modules/es.array.includes");

require("core-js/modules/es.array.index-of");

require("core-js/modules/es.array.join");

require("core-js/modules/es.function.name");
Expand All @@ -22,17 +20,12 @@ var sh = require('shelljs');
var _require = require('./js/index'),
error = _require.error;

var _require2 = require('./js/global'),
system = _require2.system;

var isWindows = system.indexOf('MINGW') > -1;

if (!sh.which('git')) {
sh.echo(error('gitmars只能在git环境下执行,请先安装git'));
sh.exit(1);
}

program.version((isWindows ? '' : "\n e88~~ ,e, d8 \nd888 \" _d88__ 888-~88e-~88e /~~~8e 888-~ d88~ \n8888 __ 888 888 888 888 888 88b 888 C888 \n8888 | 888 888 888 888 888 e88~-888 888 Y88b \nY888 | 888 888 888 888 888 C888 888 888 888D \n \"88__/ 888 \"88_/ 888 888 888 \"88_-888 888 _88P \n \n") + "v".concat(set.version, ", powered by saqqdy\n"), '-v, --version', '查看gitmars版本');
program.version("\n e88~~ ,e, d8 \nd888 \" _d88__ 888-~88e-~88e /~~~8e 888-~ d88~ \n8888 __ 888 888 888 888 888 88b 888 C888 \n8888 | 888 888 888 888 888 e88~-888 888 Y88b \nY888 | 888 888 888 888 888 C888 888 888 888D \n \"88__/ 888 \"88_/ 888 888 888 \"88_-888 888 _88P \n \nv".concat(set.version, ", powered by saqqdy\n"), '-v, --version', '查看gitmars版本');
program.name('gitm').usage('[command] options').command('init', '初始化gitmars配置').command('config [options]', '查看/设置gitmars的配置项').command('combine', '分支阶段提测').alias('cb').command('start <type> <name>', '创建bugfix分支、创建/合并release分支').alias('st').command('end <type> <name>', '完成开发某项功能').alias('ed').command('update <type> <name>', '更新bug任务分支、更新feature功能开发分支').alias('up').command('branch', '列出分支列表').alias('bh').command('save', '暂存当前分支文件').alias('sv').command('get', '恢复暂存区最近一次暂存的文件').alias('gt').command('copy <id>', '简化git的cherry-pick操作').alias('cp').command('merge <name>', '合并代码').alias('mg').command('continue', '继续未完成的操作').alias('ct').command('revert', '撤销提交').alias('rt').command('upgrade', '升级gitmars').alias('ug').command('build', '构建Jenkins').alias('bd').command('clean', '提交权限').command('permission', '提交权限').command('admin <command>', '管理员功能,包含对发版分支bugfix、release的操作');
program.on('--help', function () {
sh.echo('使用案例:');
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitmars",
"description": "一个高度定制化的git工作流工具",
"version": "1.2.5",
"version": "1.2.6",
"main": "lib/gitm.js",
"scripts": {
"eslint": "eslint --fix --ext .vue,.js",
Expand All @@ -15,7 +15,9 @@
"colors": "^1.4.0",
"commander": "5.1.0",
"core-js": "^3.6.5",
"execa": "^4.0.2",
"node-apollo": "^1.2.1",
"ora": "^4.0.4",
"regenerator-runtime": "^0.13.5",
"shelljs": "0.8.4",
"tracer": "1.1.2"
Expand Down

0 comments on commit fdf1ef6

Please sign in to comment.