zen-gitsync 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/package.json +3 -1
- package/src/gitCommit.js +13 -2
- package/src/utils/index.js +1 -4
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-gitsync",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "控制台输入g,回车,输入提交内容,自动执行git add+commit+push",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/xz333221/zen-gitsync#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"chalk": "^5.4.1",
|
|
35
|
+
"ora": "^8.1.1",
|
|
34
36
|
"string-width": "^7.2.0"
|
|
35
37
|
}
|
|
36
38
|
}
|
package/src/gitCommit.js
CHANGED
|
@@ -4,6 +4,8 @@ import {exec, execSync} from 'child_process'
|
|
|
4
4
|
import os from 'os'
|
|
5
5
|
import {coloredLog} from './utils/index.js';
|
|
6
6
|
import readline from 'readline'
|
|
7
|
+
import ora from 'ora';
|
|
8
|
+
import chalk from 'chalk';
|
|
7
9
|
|
|
8
10
|
let timer = null
|
|
9
11
|
|
|
@@ -103,8 +105,11 @@ class GitCommit {
|
|
|
103
105
|
exec_push() {
|
|
104
106
|
// 执行 git push
|
|
105
107
|
// this.execSyncGitCommand(`git push`);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const spinner = ora('正在推送代码...').start();
|
|
109
|
+
this.execGitCommand('git push', {
|
|
110
|
+
spinner
|
|
111
|
+
}, (error, stdout, stderr) => {
|
|
112
|
+
console.log(chalk.green.bold('✔ SUCCESS: 提交完成。')); // 使用绿色对勾图标
|
|
108
113
|
this.execSyncGitCommand(`git log -n 1 --pretty=format:"%B%n%h %d%n%ad" --date=iso`)
|
|
109
114
|
this.exec_exit();
|
|
110
115
|
})
|
|
@@ -115,6 +120,9 @@ class GitCommit {
|
|
|
115
120
|
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024} = options
|
|
116
121
|
let cwd = getCwd()
|
|
117
122
|
const output = execSync(command, {encoding, maxBuffer, cwd})
|
|
123
|
+
if(options.spinner){
|
|
124
|
+
options.spinner.stop();
|
|
125
|
+
}
|
|
118
126
|
let result = output.trim()
|
|
119
127
|
coloredLog(command, result)
|
|
120
128
|
return result
|
|
@@ -128,6 +136,9 @@ class GitCommit {
|
|
|
128
136
|
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024} = options
|
|
129
137
|
let cwd = getCwd()
|
|
130
138
|
exec(command, {encoding, maxBuffer, cwd}, (error, stdout, stderr) => {
|
|
139
|
+
if(options.spinner){
|
|
140
|
+
options.spinner.stop();
|
|
141
|
+
}
|
|
131
142
|
if (error) {
|
|
132
143
|
coloredLog(command, error)
|
|
133
144
|
return
|
package/src/utils/index.js
CHANGED
|
@@ -40,10 +40,6 @@ const coloredLog = (...args) => {
|
|
|
40
40
|
// 获取控制台的宽度
|
|
41
41
|
const terminalWidth = process.stdout.columns;
|
|
42
42
|
|
|
43
|
-
// 创建与控制台宽度相同的横线
|
|
44
|
-
// const line = '-'.repeat(terminalWidth);
|
|
45
|
-
let str = '├─'
|
|
46
|
-
let str2 = '│'
|
|
47
43
|
const start_line = '┌' + '─'.repeat(terminalWidth - 2) + '┐';
|
|
48
44
|
const end_line = '└' + '─'.repeat(terminalWidth - 2) + '┘';
|
|
49
45
|
let _args = args.map(arg => arg.split('\n')).flat().filter(arg => arg.trim() !== '');
|
|
@@ -77,6 +73,7 @@ const coloredLog = (...args) => {
|
|
|
77
73
|
if (
|
|
78
74
|
_args[0] === 'git status' && trim_arg.startsWith('modified:')
|
|
79
75
|
|| _args[0] === 'git status' && trim_arg.startsWith('deleted:')
|
|
76
|
+
|| _args[0] === 'git status' && trim_arg.startsWith('new file:')
|
|
80
77
|
) {
|
|
81
78
|
fix2 = 6
|
|
82
79
|
}
|