zen-gitsync 2.11.39 → 2.12.3
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/LICENSE +190 -21
- package/README.md +695 -695
- package/index.js +25 -11
- package/package.json +2 -2
- package/scripts/convert-colors-to-vars.cjs +286 -272
- package/scripts/convert-fontsize-to-vars.cjs +221 -207
- package/scripts/convert-spacing-to-vars.cjs +256 -242
- package/scripts/convert-to-standard-vars.cjs +282 -268
- package/scripts/release.js +599 -585
- package/src/config.js +350 -336
- package/src/gitCommit.js +455 -440
- package/src/ui/public/assets/EditorView-CbqSI9nw.css +1 -0
- package/src/ui/public/assets/EditorView-GS5cmh99.js +21 -0
- package/src/ui/public/assets/SourceMapView-DyMK80hS.css +1 -0
- package/src/ui/public/assets/SourceMapView-_YRtzmZZ.js +3 -0
- package/src/ui/public/assets/index-ML5Y-5lO.css +1 -0
- package/src/ui/public/assets/index-yky0Sd13.js +73 -0
- package/src/ui/public/assets/{ts.worker-Dth06zuC.js → ts.worker-METxwbDZ.js} +1 -16
- package/src/ui/public/assets/{vendor-B1T2uxYO.js → vendor-DITsiaGj.js} +294 -287
- package/src/ui/public/assets/vendor-q83wvJns.css +1 -0
- package/src/ui/public/index.html +4 -4
- package/src/ui/server/.claude/codediff.txt +6 -0
- package/src/ui/server/index.js +410 -396
- package/src/ui/server/middleware/requestLogger.js +51 -37
- package/src/ui/server/routes/branchStatus.js +101 -87
- package/src/ui/server/routes/code.js +110 -96
- package/src/ui/server/routes/codeAnalysis.js +995 -981
- package/src/ui/server/routes/config.js +1172 -1158
- package/src/ui/server/routes/exec.js +272 -258
- package/src/ui/server/routes/fileOpen.js +279 -265
- package/src/ui/server/routes/fs.js +701 -699
- package/src/ui/server/routes/git/diff.js +352 -338
- package/src/ui/server/routes/git/diffUtils.js +128 -114
- package/src/ui/server/routes/git/stash.js +552 -538
- package/src/ui/server/routes/git/tags.js +172 -158
- package/src/ui/server/routes/git.js +190 -176
- package/src/ui/server/routes/gitOps.js +1179 -1165
- package/src/ui/server/routes/instances.js +38 -24
- package/src/ui/server/routes/npm.js +1023 -1009
- package/src/ui/server/routes/process.js +82 -68
- package/src/ui/server/routes/status.js +67 -53
- package/src/ui/server/routes/terminal.js +319 -305
- package/src/ui/server/socket/registerUiSocketHandlers.js +226 -212
- package/src/ui/server/utils/createSavePortToFile.js +46 -32
- package/src/ui/server/utils/instanceRegistry.js +270 -256
- package/src/ui/server/utils/pathGuard.js +155 -0
- package/src/ui/server/utils/pathGuard.test.js +138 -0
- package/src/ui/server/utils/randomStartPort.js +51 -37
- package/src/ui/server/utils/startServerOnAvailablePort.js +101 -87
- package/src/utils/index.js +1058 -1044
- package/src/ui/public/assets/devopicons-QN4QXivI.woff2 +0 -0
- package/src/ui/public/assets/file-icons-C0jOugUK.woff2 +0 -0
- package/src/ui/public/assets/fontawesome-B-jkhYfk.woff2 +0 -0
- package/src/ui/public/assets/index-BvVl-092.js +0 -95
- package/src/ui/public/assets/index-DXO3Lvqi.css +0 -1
- package/src/ui/public/assets/mfixx-CpAhKOZz.woff2 +0 -0
- package/src/ui/public/assets/octicons-CaZ_fok2.woff2 +0 -0
- package/src/ui/public/assets/vendor-hOO_r_AU.css +0 -1
|
@@ -1,68 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
// Copyright 2026 xz333221
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
export function registerProcessRoutes({
|
|
16
|
+
app,
|
|
17
|
+
runningProcesses,
|
|
18
|
+
exec
|
|
19
|
+
}) {
|
|
20
|
+
// 停止正在运行的进程
|
|
21
|
+
app.post('/api/kill-process', async (req, res) => {
|
|
22
|
+
try {
|
|
23
|
+
const { processId } = req.body || {};
|
|
24
|
+
if (!processId || typeof processId !== 'number') {
|
|
25
|
+
return res.status(400).json({ success: false, error: 'processId 必须是数字' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const processInfo = runningProcesses.get(processId);
|
|
29
|
+
if (!processInfo) {
|
|
30
|
+
return res.status(404).json({
|
|
31
|
+
success: false,
|
|
32
|
+
error: `进程 #${processId} 不存在或已结束`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(`[进程管理] 尝试停止进程 #${processId}: ${processInfo.command}`);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
// 在 Windows 上需要使用 taskkill 来杀死整个进程树
|
|
40
|
+
if (process.platform === 'win32') {
|
|
41
|
+
// 使用已导入的 exec
|
|
42
|
+
// /F 强制终止, /T 终止进程树
|
|
43
|
+
exec(`taskkill /pid ${processInfo.childProcess.pid} /T /F`, (error) => {
|
|
44
|
+
if (error) {
|
|
45
|
+
console.error(`[进程管理] taskkill 失败:`, error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
// Unix/Linux/Mac 使用 SIGTERM
|
|
50
|
+
processInfo.childProcess.kill('SIGTERM');
|
|
51
|
+
|
|
52
|
+
// 如果 2 秒后还没结束,使用 SIGKILL 强制终止
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
if (runningProcesses.has(processId)) {
|
|
55
|
+
console.log(`[进程管理] 进程 #${processId} 未响应 SIGTERM,使用 SIGKILL 强制终止`);
|
|
56
|
+
processInfo.childProcess.kill('SIGKILL');
|
|
57
|
+
}
|
|
58
|
+
}, 2000);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
res.json({
|
|
62
|
+
success: true,
|
|
63
|
+
message: `已发送停止信号到进程 #${processId}`,
|
|
64
|
+
processId,
|
|
65
|
+
command: processInfo.command
|
|
66
|
+
});
|
|
67
|
+
} catch (killError) {
|
|
68
|
+
console.error(`[进程管理] 停止进程失败:`, killError);
|
|
69
|
+
res.status(500).json({
|
|
70
|
+
success: false,
|
|
71
|
+
error: `停止进程失败: ${killError.message}`
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('停止进程接口失败:', error);
|
|
76
|
+
res.status(500).json({
|
|
77
|
+
success: false,
|
|
78
|
+
error: `停止进程失败: ${error.message}`
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -1,53 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
app
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
// Copyright 2026 xz333221
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
import { promises as fs } from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
|
|
18
|
+
export function registerStatusRoutes({
|
|
19
|
+
app,
|
|
20
|
+
getCommandHistory,
|
|
21
|
+
execGitCommand
|
|
22
|
+
}) {
|
|
23
|
+
// Add new endpoint for command history
|
|
24
|
+
app.get('/api/command-history', async (req, res) => {
|
|
25
|
+
try {
|
|
26
|
+
const history = getCommandHistory();
|
|
27
|
+
res.json({ success: true, history });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
res.status(500).json({ success: false, error: error.message });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
app.get('/api/status_porcelain', async (req, res) => {
|
|
34
|
+
try {
|
|
35
|
+
const { stdout } = await execGitCommand('git status --porcelain --untracked-files=all');
|
|
36
|
+
// 检测是否处于 MERGING 状态(MERGE_HEAD 文件存在)
|
|
37
|
+
let isMergeInProgress = false;
|
|
38
|
+
let mergeMessage = '';
|
|
39
|
+
try {
|
|
40
|
+
const { stdout: mergeHead } = await execGitCommand('git rev-parse -q --verify MERGE_HEAD');
|
|
41
|
+
isMergeInProgress = mergeHead.trim().length > 0;
|
|
42
|
+
if (isMergeInProgress) {
|
|
43
|
+
// 读取 Git 自动生成的合并提交信息
|
|
44
|
+
try {
|
|
45
|
+
const { stdout: gitDir } = await execGitCommand('git rev-parse --git-dir');
|
|
46
|
+
const mergeMsgPath = path.resolve(gitDir.trim(), 'MERGE_MSG');
|
|
47
|
+
const raw = await fs.readFile(mergeMsgPath, 'utf-8');
|
|
48
|
+
// 过滤掉以 # 开头的注释行,取第一个非空行
|
|
49
|
+
mergeMessage = raw
|
|
50
|
+
.split('\n')
|
|
51
|
+
.filter(line => line.trim() && !line.startsWith('#'))
|
|
52
|
+
.join('\n')
|
|
53
|
+
.trim();
|
|
54
|
+
} catch (_) {
|
|
55
|
+
// MERGE_MSG 不存在时忽略
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (_) {
|
|
59
|
+
// MERGE_HEAD 不存在时命令会报错,属正常情况
|
|
60
|
+
isMergeInProgress = false;
|
|
61
|
+
}
|
|
62
|
+
res.json({ status: stdout, isMergeInProgress, mergeMessage });
|
|
63
|
+
} catch (error) {
|
|
64
|
+
res.status(500).json({ error: error.message });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|