zen-gitsync 2.13.23 → 2.13.24
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/package.json +1 -1
- package/scripts/README_COLOR_CONVERTER.md +196 -196
- package/scripts/README_FONTSIZE_CONVERTER.md +278 -278
- package/scripts/README_SPACING_CONVERTER.md +126 -126
- package/scripts/README_STYLE_VARS.md +180 -180
- package/src/gitCommit.js +2 -2
- package/src/ui/public/assets/{AppVersionBadge-BUS8w2f8.js → AppVersionBadge-CaVphp8E.js} +1 -1
- package/src/ui/public/assets/{BranchSelector-Dm7nENer.js → BranchSelector-B91Ylbas.js} +1 -1
- package/src/ui/public/assets/{CommandConsole-C1W9ZQkE.js → CommandConsole-bK4iwZvI.js} +2 -2
- package/src/ui/public/assets/{CommitForm-C76W1ZZH.js → CommitForm-zOCxmZ84.js} +1 -1
- package/src/ui/public/assets/{CustomCommandManager-JKx8JYqn.js → CustomCommandManager-C1lRrp5z.js} +1 -1
- package/src/ui/public/assets/{EditorView-CriUYDvi.js → EditorView-DYo2oYtk.js} +0 -0
- package/src/ui/public/assets/{FileDiffViewer-DNWsiIGt.js → FileDiffViewer-Ce17WOZ-.js} +1 -1
- package/src/ui/public/assets/{FlowExecutionViewer-CTDh2bCD.js → FlowExecutionViewer-CRK6lIul.js} +1 -1
- package/src/ui/public/assets/{FlowOrchestrationWorkspace-Chah2aGN.js → FlowOrchestrationWorkspace-BDw7ThWp.js} +1 -1
- package/src/ui/public/assets/{GitStatus-DP-DQsiS.js → GitStatus-DN4_m6sO.js} +1 -1
- package/src/ui/public/assets/{LogList-Z76_5USQ.js → LogList-BshRTCrE.js} +1 -1
- package/src/ui/public/assets/{ProjectStartupButton-C5oF4unq.js → ProjectStartupButton-C-dXxxMO.js} +1 -1
- package/src/ui/public/assets/{RemoteRepoCard-B-fGjb8Y.js → RemoteRepoCard-DDZcP5-V.js} +1 -1
- package/src/ui/public/assets/{ResetToRemoteButton-BixSoEVs.js → ResetToRemoteButton-TXJzvBxE.js} +1 -1
- package/src/ui/public/assets/{SourceMapView-C9HZiJ9N.js → SourceMapView-BUkB6h41.js} +1 -1
- package/src/ui/public/assets/{TemplateManager-C7SuKq0f.js → TemplateManager-DFVzDiu0.js} +1 -1
- package/src/ui/public/assets/{UserInputNode-CYy0UpzR.js → UserInputNode-CXyV1xG4.js} +1 -1
- package/src/ui/public/assets/{WorkbenchView-A9Oik707.js → WorkbenchView-CEYhsa4O.js} +1 -1
- package/src/ui/public/assets/{index-DPSGvy34.js → index-BGmxuKoN.js} +2 -2
- package/src/ui/public/favicon.svg +75 -75
- package/src/ui/public/index.html +18 -18
- package/src/ui/public/logo.svg +74 -74
- package/src/ui/server/index.js +3 -3
- package/src/ui/server/routes/branchStatus.js +4 -4
- package/src/ui/server/routes/config.js +8 -8
- package/src/ui/server/routes/exec.js +7 -1
- package/src/ui/server/routes/fs.js +2 -2
- package/src/ui/server/routes/git/diff.js +17 -16
- package/src/ui/server/routes/git/diffUtils.js +21 -2
- package/src/ui/server/routes/git/stash.js +38 -42
- package/src/ui/server/routes/git/tags.js +10 -10
- package/src/ui/server/routes/git.js +15 -26
- package/src/ui/server/routes/gitOps.js +91 -125
- package/src/ui/server/routes/status.js +3 -3
- package/src/utils/index.js +32 -29
package/src/utils/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import stringWidth from 'string-width';
|
|
|
32
32
|
import Table from 'cli-table3';
|
|
33
33
|
import chalk from 'chalk';
|
|
34
34
|
import boxen from "boxen";
|
|
35
|
-
import {
|
|
35
|
+
import {execFile, execSync} from 'child_process'
|
|
36
36
|
import os from 'os'
|
|
37
37
|
import ora from "ora";
|
|
38
38
|
import readline from 'readline'
|
|
@@ -266,14 +266,18 @@ function clearCommandHistory() {
|
|
|
266
266
|
|
|
267
267
|
function execGitCommand(command, options = {}) {
|
|
268
268
|
return new Promise((resolve, reject) => {
|
|
269
|
-
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024, head = command, log = true} = options
|
|
269
|
+
let {encoding = 'utf-8', maxBuffer = 30 * 1024 * 1024, head = Array.isArray(command) ? command.join(' ') : command, log = true} = options
|
|
270
270
|
let cwd = getCwd()
|
|
271
|
-
|
|
271
|
+
|
|
272
272
|
// Record start time for command execution
|
|
273
273
|
const startTime = Date.now();
|
|
274
274
|
|
|
275
275
|
// setTimeout(() => {
|
|
276
|
-
|
|
276
|
+
// 用 execFile('git', argv) 跨平台执行:
|
|
277
|
+
// - 不走 shell,Windows cmd.exe / POSIX sh 都一致
|
|
278
|
+
// - argv 数组天然免疫 shell 注入,文件名/参数无需 shellQuote
|
|
279
|
+
// - 所有调用点约定只跑 git 子命令,见 src/utils/index.js 内的 execGitCommand 调用清单
|
|
280
|
+
execFile('git', command, {
|
|
277
281
|
env: {
|
|
278
282
|
...process.env,
|
|
279
283
|
// LANG: 'en_US.UTF-8', // Linux/macOS
|
|
@@ -282,7 +286,10 @@ function execGitCommand(command, options = {}) {
|
|
|
282
286
|
},
|
|
283
287
|
encoding,
|
|
284
288
|
maxBuffer,
|
|
285
|
-
cwd
|
|
289
|
+
cwd,
|
|
290
|
+
// Windows 下 git 是 .exe;POSIX 下直接 PATH 找。
|
|
291
|
+
// 不传 shell,杜绝 cmd.exe 单/双引号兼容问题与注入风险。
|
|
292
|
+
windowsHide: true
|
|
286
293
|
}, (error, stdout, stderr) => {
|
|
287
294
|
if (options.spinner) {
|
|
288
295
|
options.spinner.stop();
|
|
@@ -590,7 +597,7 @@ async function printGitLog() {
|
|
|
590
597
|
n = parseInt(logArg.split('=')[1], 10);
|
|
591
598
|
}
|
|
592
599
|
// 使用 ASCII 记录分隔符 %x1E 作为字段分隔符
|
|
593
|
-
const logCommand =
|
|
600
|
+
const logCommand = ['log', '-n', n, '--pretty=format:%C(green)%h%C(reset) %x1E %C(cyan)%an%C(reset) %x1E %C(yellow)%ad%C(reset) %x1E %C(blue)%D%C(reset) %x1E %C(magenta)%s%C(reset)', '--date=format:%Y-%m-%d %H:%M', '--graph', '--decorate', '--color']
|
|
594
601
|
try {
|
|
595
602
|
const logOutput = await execGitCommand(logCommand, {
|
|
596
603
|
head: `git log`
|
|
@@ -620,7 +627,7 @@ async function exec_push({exit, commitMessage}) {
|
|
|
620
627
|
// 执行 git push
|
|
621
628
|
const spinner = ora('正在推送代码...').start();
|
|
622
629
|
try {
|
|
623
|
-
const {stdout, stderr} = await execGitCommand('
|
|
630
|
+
const {stdout, stderr} = await execGitCommand(['push'], {
|
|
624
631
|
spinner
|
|
625
632
|
});
|
|
626
633
|
await printCommitLog({commitMessage});
|
|
@@ -633,15 +640,15 @@ async function exec_push({exit, commitMessage}) {
|
|
|
633
640
|
async function printCommitLog({commitMessage}) {
|
|
634
641
|
try {
|
|
635
642
|
// 获取项目名称(取git仓库根目录名)
|
|
636
|
-
const projectRootResult = await execGitCommand('
|
|
643
|
+
const projectRootResult = await execGitCommand(['rev-parse', '--show-toplevel'], {log: false});
|
|
637
644
|
const projectName = chalk.blueBright(path.basename(projectRootResult.stdout.trim()));
|
|
638
645
|
|
|
639
646
|
// 获取当前提交hash(取前7位)
|
|
640
|
-
const commitHashResult = await execGitCommand('
|
|
647
|
+
const commitHashResult = await execGitCommand(['rev-parse', '--short', 'HEAD'], {log: false});
|
|
641
648
|
const hashDisplay = chalk.yellow(commitHashResult.stdout.trim());
|
|
642
649
|
|
|
643
650
|
// 获取分支信息
|
|
644
|
-
const branchResult = await execGitCommand('
|
|
651
|
+
const branchResult = await execGitCommand(['branch', '--show-current'], {log: false});
|
|
645
652
|
const branchDisplay = chalk.magenta(branchResult.stdout.trim());
|
|
646
653
|
|
|
647
654
|
// 构建信息内容
|
|
@@ -679,7 +686,7 @@ async function execPull() {
|
|
|
679
686
|
try {
|
|
680
687
|
// 检查是否需要拉取更新
|
|
681
688
|
const spinner = ora('正在拉取代码...').start();
|
|
682
|
-
await execGitCommand('
|
|
689
|
+
await execGitCommand(['pull'], {
|
|
683
690
|
spinner
|
|
684
691
|
})
|
|
685
692
|
} catch (e) {
|
|
@@ -697,12 +704,12 @@ async function judgeRemote() {
|
|
|
697
704
|
try {
|
|
698
705
|
// 检查是否有远程更新
|
|
699
706
|
// 先获取远程最新状态
|
|
700
|
-
await execGitCommand('
|
|
707
|
+
await execGitCommand(['remote', 'update'], {
|
|
701
708
|
head: 'Fetching remote updates',
|
|
702
709
|
log: false
|
|
703
710
|
});
|
|
704
711
|
// 检查是否需要 pull
|
|
705
|
-
const res = await execGitCommand('
|
|
712
|
+
const res = await execGitCommand(['rev-list', 'HEAD..@{u}', '--count'], {
|
|
706
713
|
head: 'Checking if behind remote',
|
|
707
714
|
log: false
|
|
708
715
|
});
|
|
@@ -754,7 +761,7 @@ async function judgeRemote() {
|
|
|
754
761
|
async function execDiff() {
|
|
755
762
|
const no_diff = process.argv.find(arg => arg.startsWith('--no-diff'))
|
|
756
763
|
if (!no_diff) {
|
|
757
|
-
await execGitCommand('
|
|
764
|
+
await execGitCommand(['diff', '--color=always'], {
|
|
758
765
|
head: `git diff`
|
|
759
766
|
})
|
|
760
767
|
}
|
|
@@ -768,14 +775,14 @@ async function execGitAddWithLockFilter() {
|
|
|
768
775
|
|
|
769
776
|
if (lockedFiles.length === 0) {
|
|
770
777
|
// 如果没有锁定文件,直接执行 git add .
|
|
771
|
-
await execGitCommand('
|
|
778
|
+
await execGitCommand(['add', '.']);
|
|
772
779
|
return;
|
|
773
780
|
}
|
|
774
781
|
|
|
775
782
|
// 获取Git工作目录根路径,确保路径匹配的准确性
|
|
776
783
|
let gitRoot;
|
|
777
784
|
try {
|
|
778
|
-
const gitRootResult = await execGitCommand('
|
|
785
|
+
const gitRootResult = await execGitCommand(['rev-parse', '--show-toplevel'], {log: false});
|
|
779
786
|
gitRoot = path.normalize(gitRootResult.stdout.trim());
|
|
780
787
|
} catch (error) {
|
|
781
788
|
console.warn(chalk.yellow('⚠️ 无法获取Git根目录,使用当前工作目录'));
|
|
@@ -783,7 +790,7 @@ async function execGitAddWithLockFilter() {
|
|
|
783
790
|
}
|
|
784
791
|
|
|
785
792
|
// 获取所有修改的文件(包括未跟踪文件)
|
|
786
|
-
const statusResult = await execGitCommand('
|
|
793
|
+
const statusResult = await execGitCommand(['status', '--porcelain', '--untracked-files=all'], {log: false});
|
|
787
794
|
const modifiedFiles = statusResult.stdout
|
|
788
795
|
.split('\n')
|
|
789
796
|
.filter(line => line.trim())
|
|
@@ -896,19 +903,15 @@ async function execGitAddWithLockFilter() {
|
|
|
896
903
|
}
|
|
897
904
|
|
|
898
905
|
// 逐个添加未锁定的文件
|
|
899
|
-
//
|
|
900
|
-
//
|
|
901
|
-
//
|
|
902
|
-
//
|
|
903
|
-
const shellQuote = (s) => {
|
|
904
|
-
if (s === null || s === undefined) return "''"
|
|
905
|
-
return `'${String(s).replace(/'/g, `'\\''`)}'`
|
|
906
|
-
}
|
|
906
|
+
// 用 execFile('git', argv) 直接传 argv 数组,不经过 shell,
|
|
907
|
+
// 文件名含空格/特殊字符时不需要 shellQuote;同时跨 Windows cmd.exe /
|
|
908
|
+
// POSIX sh 都一致(此前单引号写法在 Windows cmd.exe 不被识别,导致
|
|
909
|
+
// "pathspec '...did not match any files" 报错,见 da01bcb 回归)。
|
|
907
910
|
let successCount = 0
|
|
908
911
|
let failedFiles = []
|
|
909
912
|
for (const file of filesToAdd) {
|
|
910
913
|
try {
|
|
911
|
-
await execGitCommand(
|
|
914
|
+
await execGitCommand(['add', '--', file], {
|
|
912
915
|
head: `git add ${file}`,
|
|
913
916
|
log: false
|
|
914
917
|
})
|
|
@@ -979,7 +982,7 @@ async function execAddAndCommit({statusOutput, commitMessage, exit}) {
|
|
|
979
982
|
}
|
|
980
983
|
|
|
981
984
|
// 提交前二次校验(包括未跟踪文件)
|
|
982
|
-
const checkStatus = await execGitCommand('
|
|
985
|
+
const checkStatus = await execGitCommand(['status', '--porcelain', '--untracked-files=all'], {log: false});
|
|
983
986
|
if (!checkStatus.stdout.trim()) {
|
|
984
987
|
console.log(chalk.yellow('⚠️ 没有检测到可提交的变更'));
|
|
985
988
|
// exec_exit(exit)
|
|
@@ -988,7 +991,7 @@ async function execAddAndCommit({statusOutput, commitMessage, exit}) {
|
|
|
988
991
|
|
|
989
992
|
// 执行 git commit
|
|
990
993
|
if (statusOutput.includes('Untracked files:') || statusOutput.includes('Changes not staged for commit') || statusOutput.includes('Changes to be committed')) {
|
|
991
|
-
await execGitCommand(
|
|
994
|
+
await execGitCommand(['commit', '-m', commitMessage])
|
|
992
995
|
}
|
|
993
996
|
|
|
994
997
|
// 返回实际使用的提交信息
|
|
@@ -1053,7 +1056,7 @@ async function addResetScriptToPackageJson() {
|
|
|
1053
1056
|
}
|
|
1054
1057
|
|
|
1055
1058
|
// 获取当前分支名
|
|
1056
|
-
const branchResult = await execGitCommand('
|
|
1059
|
+
const branchResult = await execGitCommand(['branch', '--show-current'], {log: false});
|
|
1057
1060
|
const branch = branchResult.stdout.trim();
|
|
1058
1061
|
|
|
1059
1062
|
// 添加 g:reset 命令
|