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,176 +1,190 @@
|
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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 express from 'express';
|
|
16
|
+
|
|
17
|
+
export function registerGitRoutes({
|
|
18
|
+
app,
|
|
19
|
+
execGitCommand,
|
|
20
|
+
clearBranchCache
|
|
21
|
+
}) {
|
|
22
|
+
// 获取所有分支
|
|
23
|
+
app.get('/api/branches', async (req, res) => {
|
|
24
|
+
try {
|
|
25
|
+
// 获取本地分支 - 使用简单的git branch命令
|
|
26
|
+
const { stdout: localBranches } = await execGitCommand('git branch');
|
|
27
|
+
|
|
28
|
+
// 获取远程分支
|
|
29
|
+
const { stdout: remoteBranches } = await execGitCommand('git branch -r');
|
|
30
|
+
|
|
31
|
+
// 处理本地分支 - 正确解析git branch的标准输出格式
|
|
32
|
+
const localBranchList = localBranches.split('\n')
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.map(b => b.trim())
|
|
35
|
+
.map(b => b.startsWith('* ') ? b.substring(2) : b); // 移除星号并保留分支名
|
|
36
|
+
|
|
37
|
+
// 处理远程分支,保留完整的远程分支名称
|
|
38
|
+
const remoteBranchList = remoteBranches.split('\n')
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.map(b => b.trim())
|
|
41
|
+
.filter(b => b !== 'origin' && !b.includes('HEAD')); // 过滤掉单纯的origin和HEAD引用
|
|
42
|
+
|
|
43
|
+
// 合并分支列表
|
|
44
|
+
const allBranches = [
|
|
45
|
+
...localBranchList,
|
|
46
|
+
...remoteBranchList
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
res.json({ branches: allBranches });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('获取分支列表失败:', error);
|
|
52
|
+
res.status(500).json({ error: error.message });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 创建新分支
|
|
57
|
+
app.post('/api/create-branch', express.json(), async (req, res) => {
|
|
58
|
+
try {
|
|
59
|
+
const { newBranchName, baseBranch } = req.body;
|
|
60
|
+
|
|
61
|
+
if (!newBranchName) {
|
|
62
|
+
return res.status(400).json({ success: false, error: '分支名称不能为空' });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 构建创建分支的命令
|
|
66
|
+
let command = `git branch ${newBranchName}`;
|
|
67
|
+
|
|
68
|
+
// 如果指定了基础分支,则基于该分支创建
|
|
69
|
+
if (baseBranch) {
|
|
70
|
+
command = `git branch ${newBranchName} ${baseBranch}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 执行创建分支命令
|
|
74
|
+
await execGitCommand(command);
|
|
75
|
+
|
|
76
|
+
// 切换到新创建的分支
|
|
77
|
+
await execGitCommand(`git checkout ${newBranchName}`);
|
|
78
|
+
|
|
79
|
+
// 清除分支缓存,因为分支已切换
|
|
80
|
+
clearBranchCache();
|
|
81
|
+
|
|
82
|
+
res.json({ success: true, branch: newBranchName });
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error('创建分支失败:', error);
|
|
85
|
+
res.status(500).json({ success: false, error: error.message });
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// 切换分支
|
|
90
|
+
app.post('/api/checkout', async (req, res) => {
|
|
91
|
+
try {
|
|
92
|
+
const { branch } = req.body;
|
|
93
|
+
if (!branch) {
|
|
94
|
+
return res.status(400).json({ success: false, error: '分支名称不能为空' });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 执行分支切换
|
|
98
|
+
await execGitCommand(`git checkout ${branch}`);
|
|
99
|
+
|
|
100
|
+
// 清除分支缓存,因为分支已切换
|
|
101
|
+
clearBranchCache();
|
|
102
|
+
|
|
103
|
+
res.json({ success: true });
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.error('切换分支失败:', error);
|
|
106
|
+
res.status(500).json({ success: false, error: error.message });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// 合并分支
|
|
111
|
+
app.post('/api/merge', async (req, res) => {
|
|
112
|
+
try {
|
|
113
|
+
const { branch, noCommit, noFf, squash, message } = req.body;
|
|
114
|
+
|
|
115
|
+
if (!branch) {
|
|
116
|
+
return res.status(400).json({ success: false, error: '分支名称不能为空' });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 构建Git合并命令 - 直接使用传入的分支名(可能包含origin/前缀)
|
|
120
|
+
let command = `git merge ${branch}`;
|
|
121
|
+
|
|
122
|
+
// 添加可选参数
|
|
123
|
+
if (noCommit) {
|
|
124
|
+
command += ' --no-commit';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (noFf) {
|
|
128
|
+
command += ' --no-ff';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (squash) {
|
|
132
|
+
command += ' --squash';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (message) {
|
|
136
|
+
command += ` -m "${message}"`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
// 执行合并命令
|
|
141
|
+
const { stdout } = await execGitCommand(command);
|
|
142
|
+
|
|
143
|
+
res.json({
|
|
144
|
+
success: true,
|
|
145
|
+
message: '分支合并成功',
|
|
146
|
+
output: stdout
|
|
147
|
+
});
|
|
148
|
+
} catch (error) {
|
|
149
|
+
// 检查是否有合并冲突
|
|
150
|
+
const errorMsg = error.message || '';
|
|
151
|
+
const hasConflicts = errorMsg.includes('CONFLICT') ||
|
|
152
|
+
errorMsg.includes('Automatic merge failed');
|
|
153
|
+
|
|
154
|
+
if (hasConflicts) {
|
|
155
|
+
res.status(409).json({
|
|
156
|
+
success: false,
|
|
157
|
+
hasConflicts: true,
|
|
158
|
+
error: '合并过程中发生冲突,需要手动解决',
|
|
159
|
+
details: errorMsg
|
|
160
|
+
});
|
|
161
|
+
} else {
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error('合并分支失败:', error);
|
|
167
|
+
res.status(500).json({
|
|
168
|
+
success: false,
|
|
169
|
+
error: `合并分支失败: ${error.message}`
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// 获取Git用户配置信息
|
|
175
|
+
app.get('/api/user-info', async (req, res) => {
|
|
176
|
+
try {
|
|
177
|
+
// 获取全局用户名
|
|
178
|
+
const { stdout: userName } = await execGitCommand('git config --global user.name');
|
|
179
|
+
// 获取全局用户邮箱
|
|
180
|
+
const { stdout: userEmail } = await execGitCommand('git config --global user.email');
|
|
181
|
+
|
|
182
|
+
res.json({
|
|
183
|
+
name: userName.trim(),
|
|
184
|
+
email: userEmail.trim()
|
|
185
|
+
});
|
|
186
|
+
} catch (error) {
|
|
187
|
+
res.status(500).json({ error: error.message });
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|