Browse Source

'lll'

master
1549469775 5 years ago
parent
commit
8ee9e80cbf
  1. 68
      bin/xyx
  2. 2
      package-lock.json
  3. 4
      package.json
  4. 87
      prompt.js
  5. 8
      readme

68
bin/xyx

@ -4,6 +4,7 @@ const inquirer = require('inquirer');
const program = require('commander');
const util = require('../util')
const git_util = require('../git_util.js');
const prompt = require('../prompt.js');
program
.version(require('../package.json').version, '-v, --version') // 定义版本信息
.usage('<command> [options]'); // 定义命令用法
@ -38,44 +39,45 @@ program
.action(async (options, cmd) => { // 对应命令的处理函数
// let currentPath = process.cwd();
let remote = await util._getAllRemote();
let branch = await util._getBranch();; //当前分支
if (remote.length > 0) {
console.log('所有远程源:', remote);
inquirer.prompt([{
type: 'confirm', // 问题类型,包括input,number,confirm,list,rawlist,password
name: 'all',
message: '是否提交所有源', // 问题
default: true // 默认值
}]).then(async answers => {
if (answers.all) {
// 所有源提交
inquirer.prompt([{
type: 'input',
name: 'msg',
message: '请输入需要提交的消息', // 问题
default: '', // 默认值
validate: (input) => {
if (input.length == 0) { //
return '消息不能为空'
}
return true;
}
}]).then(async answers => {
let msg = answers.msg;
let branch = await util._getBranch();; //当前分支
for (let i = 0; i < remote.length; i++) {
const o = remote[i];
let isclean = await util._isClean();
if (!isclean) {
await git_util.all(msg, o, branch);
} else {
await git_util.push(o, branch);
}
let isPushAll = await prompt.isPushAll();
if (isPushAll) {
let pushMsg = await prompt.pushMsg();
for (let i = 0; i < remote.length; i++) {
const o = remote[i];
let isclean = await util._isClean();
if (!isclean) {
await git_util.all(pushMsg, o, branch);
} else {
await git_util.push(o, branch);
}
}
} else {
let list = await prompt.listPush(remote);
if (list.length) {
let pushMsg = await prompt.pushMsg();
for (let i = 0; i < list.length; i++) {
const o = list[i];
let isclean = await util._isClean();
if (!isclean) {
await git_util.all(pushMsg, o, branch);
} else {
await git_util.push(o, branch);
}
});
}
} else {
console.log('您未选择源进行提交');
}
})
}
} else {
console.log('请添加源');
// let {
// name,
// url
// } = await prompt.addRemote();
// await util.exec('git remote add ' + name + ' ' + url);
// console.log('添加成功');
}
// let info = await util.exec('git status');
});

2
package-lock.json

@ -1,6 +1,6 @@
{
"name": "gittttup",
"version": "1.0.3",
"version": "1.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

4
package.json

@ -1,6 +1,6 @@
{
"name": "gittttup",
"version": "1.0.3",
"version": "1.0.6",
"description": "",
"main": "app.js",
"bin": {
@ -21,4 +21,4 @@
"inquirer": "^7.0.0",
"ora": "^4.0.2"
}
}
}

87
prompt.js

@ -0,0 +1,87 @@
const inquirer = require('inquirer');
module.exports = {
isPushAll() {
return new Promise((resolve, reject) => {
inquirer.prompt([{
type: 'confirm', // 问题类型,包括input,number,confirm,list,rawlist,password
name: 'all',
message: '是否提交所有源', // 问题
default: true // 默认值
}]).then(async answers => {
if (answers.all) {
resolve(true);
} else {
resolve(false);
}
})
})
},
pushMsg() {
return new Promise((resolve, reject) => {
inquirer.prompt([{
type: 'input',
name: 'msg',
message: '请输入需要提交的消息', // 问题
default: '', // 默认值
validate: (input) => {
if (input.length == 0) { //
return '消息不能为空'
}
return true;
}
}]).then(async answers => {
if (answers.msg) {
resolve(answers.msg);
} else {
resolve('');
}
})
})
},
listPush(origin) {
return new Promise((resolve, reject) => {
inquirer.prompt([{
type: 'checkbox', // 问题类型,包括input,number,confirm,list,rawlist,password
choices: origin,
name: 'choices',
message: '请选择一个源提交', // 问题
default: true // 默认值
}]).then(async answers => {
resolve(answers.choices);
})
})
},
addRemote() {
return new Promise((resolve, reject) => {
inquirer.prompt([{
type: 'input', // 问题类型,包括input,number,confirm,list,rawlist,password
name: 'name',
message: '源名字', // 问题
default: '', // 默认值
validate: (input) => {
if (input.length == 0) {
return '请输入源名字';
}
return true;
}
}, {
type: 'input', // 问题类型,包括input,number,confirm,list,rawlist,password
name: 'url',
message: '源url', // 问题
default: '', // 默认值
validate: (input) => {
if (input.length == 0) {
return '请输入源url';
}
return true;
}
}]).then(async answers => {
resolve({
name: answers.name,
url: answers.url
});
})
})
}
}

8
readme

@ -1,6 +1,14 @@
## 自用的 请勿下载
自用的 请勿下载, GIT一键多源提交
目前只用于`nodejs`
V 1.0.5
`xyx sync`当前目录下提交所有存在的源
V 1.0.*
项目雏形,逐步完善,不升到版本2以上表示不能使用
Loading…
Cancel
Save