Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed May 19, 2020
2 parents cbfb841 + 66ebb29 commit 87624ca
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,17 @@ gitm get

### gitm upgrade
#### 短指令:gitm ug
升级gitmars版本
升级gitmars版本,可输入version指定版本,选填,默认安装最新版
```
# 输入-m或者--mirror表示使用淘宝镜像升级
gitm upgrade [-m --mirror]
gitm upgrade [version] [-m --mirror]
```

### gitm clean
清理gitmars缓存和本地配置,输入--force同时清理本地配置文件(慎用)
```
# 形式:gitm clean [-f --force]
gitm clean
```

## 管理员
Expand Down
20 changes: 20 additions & 0 deletions bin/gitm-clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node
const program = require('commander')
const sh = require('shelljs')
const { error, success, warning, config, configFrom, queue, pwd, gitDir } = require('./index')
/**
* gitm clean
*/
program
.name('gitm clean')
.description('清理gitmars缓存')
.option('-f, --force', '强制清理', false)
.action(opt => {
sh.rm(gitDir + '/.gitmarscommands', gitDir + '/.gitmarslog')
if (opt.force) {
sh.echo(warning('您输入了--force,将同时清理本地gitmars配置文件'))
sh.rm(pwd + '/gitmarsconfig.json', pwd + '/.gitmarsrc')
}
sh.echo(success('清理完毕'))
})
program.parse(process.argv)
2 changes: 1 addition & 1 deletion bin/gitm-permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { error, success, config, configFrom, queue, getCurrent, gitDir } = requir
*/
program
.name('gitm permission')
.usage('')
.usage('[message]')
.arguments('[message]')
.description('校验提交权限')
.option('--no-verify', '是否需要跳过校验权限', false)
Expand Down
26 changes: 15 additions & 11 deletions bin/gitm-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ const { error, success, config, configFrom, queue, getStatus, pwd } = require('.
*/
program
.name('gitm upgrade')
.usage('[version]')
.description('升级gitmars')
.arguments('[version]')
.option('-m, --mirror', '是否使用淘宝镜像', false)
.action(opt => {
let cmd = [
{
cmd: `npm install -g gitmars ${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 }
}
]
.action((version, opt) => {
let match = version && version.match(/[0-9.]+$/) || null,
v = match ? match[0] : 'latest',
cmd = [
{
cmd: `npm install -g gitmars@${v} ${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(data => {
if (data[0].code === 0) {
sh.echo(data[1].out)
Expand Down
3 changes: 2 additions & 1 deletion bin/gitm.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ program
.alias('rt')
.command('upgrade', '升级gitmars')
.alias('ug')
.command('clean', '提交权限')
.command('permission', '提交权限')
.command('admin <command>', '管理员功能,包含对发版分支bugfix、release的操作')

Expand All @@ -62,7 +63,7 @@ program.on('--help', function () {

// 映射不存在的指令
program.on('command:*', function (types, opts) {
let cmd = ['init', 'config', 'combine', 'cb', 'start', 'st', 'end', 'ed', 'update', 'up', 'branch', 'bh', 'save', 'sv', 'get', 'gt', 'copy', 'cp', 'merge', 'mg', 'continue', 'ct', 'revert', 'rt', 'upgrade', 'ug', 'permission', 'admin']
let cmd = ['init', 'config', 'combine', 'cb', 'start', 'st', 'end', 'ed', 'update', 'up', 'branch', 'bh', 'save', 'sv', 'get', 'gt', 'copy', 'cp', 'merge', 'mg', 'continue', 'ct', 'revert', 'rt', 'upgrade', 'ug', 'clean', 'permission', 'admin']
if (!cmd.includes(types[0])) {
let arr = [].concat(types).concat(opts)
sh.exec('git ' + arr.join(' '), { silent: false })
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitmars",
"description": "一个高度定制化的git工作流工具",
"version": "1.1.0",
"version": "1.1.1",
"main": "bin/gitm.js",
"scripts": {
"eslint": "eslint --fix --ext .vue,.js",
Expand Down

0 comments on commit 87624ca

Please sign in to comment.