zen-gitsync 2.12.2 → 2.12.4

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.
Files changed (47) hide show
  1. package/LICENSE +190 -21
  2. package/index.js +25 -11
  3. package/package.json +18 -5
  4. package/scripts/convert-colors-to-vars.cjs +286 -272
  5. package/scripts/convert-fontsize-to-vars.cjs +221 -207
  6. package/scripts/convert-spacing-to-vars.cjs +256 -242
  7. package/scripts/convert-to-standard-vars.cjs +282 -268
  8. package/scripts/release.js +599 -585
  9. package/src/config.js +350 -336
  10. package/src/gitCommit.js +455 -440
  11. package/src/ui/public/assets/{EditorView-bnJmBq-i.js → EditorView-BZaOzahT.js} +2 -2
  12. package/src/ui/public/assets/EditorView-CbqSI9nw.css +1 -0
  13. package/src/ui/public/assets/{SourceMapView-Rz5SD0A0.js → SourceMapView-D_8mnVt2.js} +3 -3
  14. package/src/ui/public/assets/SourceMapView-DyMK80hS.css +1 -0
  15. package/src/ui/public/assets/{index-Bo3tntQh.js → index-BgFwmXzV.js} +11 -11
  16. package/src/ui/public/assets/{index-bOs5P8fz.css → index-Dsi6tg7k.css} +1 -1
  17. package/src/ui/public/index.html +2 -2
  18. package/src/ui/server/index.js +410 -396
  19. package/src/ui/server/middleware/requestLogger.js +51 -37
  20. package/src/ui/server/routes/branchStatus.js +101 -87
  21. package/src/ui/server/routes/code.js +110 -96
  22. package/src/ui/server/routes/codeAnalysis.js +995 -981
  23. package/src/ui/server/routes/config.js +1190 -1158
  24. package/src/ui/server/routes/exec.js +272 -258
  25. package/src/ui/server/routes/fileOpen.js +279 -265
  26. package/src/ui/server/routes/fs.js +701 -687
  27. package/src/ui/server/routes/git/diff.js +352 -338
  28. package/src/ui/server/routes/git/diffUtils.js +128 -114
  29. package/src/ui/server/routes/git/stash.js +552 -538
  30. package/src/ui/server/routes/git/tags.js +172 -158
  31. package/src/ui/server/routes/git.js +190 -176
  32. package/src/ui/server/routes/gitOps.js +1179 -1165
  33. package/src/ui/server/routes/instances.js +14 -0
  34. package/src/ui/server/routes/npm.js +1023 -1009
  35. package/src/ui/server/routes/process.js +82 -68
  36. package/src/ui/server/routes/status.js +67 -53
  37. package/src/ui/server/routes/terminal.js +319 -305
  38. package/src/ui/server/socket/registerUiSocketHandlers.js +226 -212
  39. package/src/ui/server/utils/createSavePortToFile.js +46 -32
  40. package/src/ui/server/utils/instanceRegistry.js +14 -0
  41. package/src/ui/server/utils/pathGuard.js +14 -0
  42. package/src/ui/server/utils/pathGuard.test.js +14 -0
  43. package/src/ui/server/utils/randomStartPort.js +14 -0
  44. package/src/ui/server/utils/startServerOnAvailablePort.js +101 -87
  45. package/src/utils/index.js +14 -0
  46. package/src/ui/public/assets/EditorView-CHBjgiZc.css +0 -1
  47. package/src/ui/public/assets/SourceMapView-DhQX0K7t.css +0 -1
@@ -1,158 +1,172 @@
1
- export function registerGitTagRoutes({ app, execGitCommand, clearCommandHistory }) {
2
- // ============ Git Tag 相关接口 ============
3
-
4
- // 创建标签
5
- app.post('/api/create-tag', async (req, res) => {
6
- try {
7
- const { tagName, message, type, commit } = req.body;
8
-
9
- if (!tagName) {
10
- return res.status(400).json({ success: false, error: '缺少标签名称' });
11
- }
12
-
13
- let command = 'git tag';
14
-
15
- if (type === 'annotated') {
16
- // 附注标签
17
- if (!message) {
18
- return res.status(400).json({ success: false, error: '附注标签需要提供说明信息' });
19
- }
20
- command += ` -a "${tagName}" -m "${message}"`;
21
- } else {
22
- // 轻量标签
23
- command += ` "${tagName}"`;
24
- }
25
-
26
- // 如果指定了commit,添加到命令中
27
- if (commit && commit.trim()) {
28
- command += ` ${commit.trim()}`;
29
- }
30
-
31
- const { stdout } = await execGitCommand(command);
32
-
33
- res.json({
34
- success: true,
35
- message: '标签创建成功',
36
- output: stdout
37
- });
38
- } catch (error) {
39
- console.error('创建标签失败:', error);
40
- res.status(500).json({ success: false, error: error.message });
41
- }
42
- });
43
-
44
- // 获取标签列表
45
- app.get('/api/list-tags', async (req, res) => {
46
- try {
47
- // 使用 git tag -n --format 获取详细信息
48
- const { stdout } = await execGitCommand(
49
- 'git tag -n --format="%(refname:short)|%(objectname:short)|%(creatordate:iso8601)|%(subject)"'
50
- );
51
-
52
- if (!stdout.trim()) {
53
- return res.json({ success: true, tags: [] });
54
- }
55
-
56
- const tags = stdout.trim().split('\n').map(line => {
57
- const [name, commit, date, message] = line.split('|');
58
- return {
59
- name: name || '',
60
- commit: commit || '',
61
- date: date || '',
62
- message: message || '',
63
- type: 'lightweight' // 默认为轻量标签
64
- };
65
- });
66
-
67
- // 检测哪些是附注标签
68
- for (const tag of tags) {
69
- try {
70
- const { stdout: typeCheck } = await execGitCommand(
71
- `git cat-file -t ${tag.name}`,
72
- { log: false }
73
- );
74
- if (typeCheck.trim() === 'tag') {
75
- tag.type = 'annotated';
76
- }
77
- } catch (error) {
78
- // 忽略错误,保持默认值
79
- }
80
- }
81
-
82
- res.json({ success: true, tags });
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/push-tag', async (req, res) => {
91
- try {
92
- const { tagName } = req.body;
93
-
94
- if (!tagName) {
95
- return res.status(400).json({ success: false, error: '缺少标签名称' });
96
- }
97
-
98
- const { stdout } = await execGitCommand(`git push origin ${tagName}`);
99
-
100
- res.json({
101
- success: true,
102
- message: '标签推送成功',
103
- output: stdout
104
- });
105
- } catch (error) {
106
- console.error('推送标签失败:', error);
107
- res.status(500).json({ success: false, error: error.message });
108
- }
109
- });
110
-
111
- // 推送所有标签到远程
112
- app.post('/api/push-all-tags', async (req, res) => {
113
- try {
114
- const { stdout } = await execGitCommand('git push origin --tags');
115
-
116
- res.json({
117
- success: true,
118
- message: '所有标签推送成功',
119
- output: stdout
120
- });
121
- } catch (error) {
122
- console.error('推送所有标签失败:', error);
123
- res.status(500).json({ success: false, error: error.message });
124
- }
125
- });
126
-
127
- // 删除标签
128
- app.post('/api/delete-tag', async (req, res) => {
129
- try {
130
- const { tagName } = req.body;
131
-
132
- if (!tagName) {
133
- return res.status(400).json({ success: false, error: '缺少标签名称' });
134
- }
135
-
136
- const { stdout } = await execGitCommand(`git tag -d ${tagName}`);
137
-
138
- res.json({
139
- success: true,
140
- message: '标签删除成功',
141
- output: stdout
142
- });
143
- } catch (error) {
144
- console.error('删除标签失败:', error);
145
- res.status(500).json({ success: false, error: error.message });
146
- }
147
- });
148
-
149
- // 添加命令历史的清空API
150
- app.post('/api/clear-command-history', async (req, res) => {
151
- try {
152
- const result = clearCommandHistory();
153
- res.json({ success: result });
154
- } catch (error) {
155
- res.status(500).json({ success: false, error: error.message });
156
- }
157
- });
158
- }
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 registerGitTagRoutes({ app, execGitCommand, clearCommandHistory }) {
16
+ // ============ Git Tag 相关接口 ============
17
+
18
+ // 创建标签
19
+ app.post('/api/create-tag', async (req, res) => {
20
+ try {
21
+ const { tagName, message, type, commit } = req.body;
22
+
23
+ if (!tagName) {
24
+ return res.status(400).json({ success: false, error: '缺少标签名称' });
25
+ }
26
+
27
+ let command = 'git tag';
28
+
29
+ if (type === 'annotated') {
30
+ // 附注标签
31
+ if (!message) {
32
+ return res.status(400).json({ success: false, error: '附注标签需要提供说明信息' });
33
+ }
34
+ command += ` -a "${tagName}" -m "${message}"`;
35
+ } else {
36
+ // 轻量标签
37
+ command += ` "${tagName}"`;
38
+ }
39
+
40
+ // 如果指定了commit,添加到命令中
41
+ if (commit && commit.trim()) {
42
+ command += ` ${commit.trim()}`;
43
+ }
44
+
45
+ const { stdout } = await execGitCommand(command);
46
+
47
+ res.json({
48
+ success: true,
49
+ message: '标签创建成功',
50
+ output: stdout
51
+ });
52
+ } catch (error) {
53
+ console.error('创建标签失败:', error);
54
+ res.status(500).json({ success: false, error: error.message });
55
+ }
56
+ });
57
+
58
+ // 获取标签列表
59
+ app.get('/api/list-tags', async (req, res) => {
60
+ try {
61
+ // 使用 git tag -n --format 获取详细信息
62
+ const { stdout } = await execGitCommand(
63
+ 'git tag -n --format="%(refname:short)|%(objectname:short)|%(creatordate:iso8601)|%(subject)"'
64
+ );
65
+
66
+ if (!stdout.trim()) {
67
+ return res.json({ success: true, tags: [] });
68
+ }
69
+
70
+ const tags = stdout.trim().split('\n').map(line => {
71
+ const [name, commit, date, message] = line.split('|');
72
+ return {
73
+ name: name || '',
74
+ commit: commit || '',
75
+ date: date || '',
76
+ message: message || '',
77
+ type: 'lightweight' // 默认为轻量标签
78
+ };
79
+ });
80
+
81
+ // 检测哪些是附注标签
82
+ for (const tag of tags) {
83
+ try {
84
+ const { stdout: typeCheck } = await execGitCommand(
85
+ `git cat-file -t ${tag.name}`,
86
+ { log: false }
87
+ );
88
+ if (typeCheck.trim() === 'tag') {
89
+ tag.type = 'annotated';
90
+ }
91
+ } catch (error) {
92
+ // 忽略错误,保持默认值
93
+ }
94
+ }
95
+
96
+ res.json({ success: true, tags });
97
+ } catch (error) {
98
+ console.error('获取标签列表失败:', error);
99
+ res.status(500).json({ success: false, error: error.message });
100
+ }
101
+ });
102
+
103
+ // 推送标签到远程
104
+ app.post('/api/push-tag', async (req, res) => {
105
+ try {
106
+ const { tagName } = req.body;
107
+
108
+ if (!tagName) {
109
+ return res.status(400).json({ success: false, error: '缺少标签名称' });
110
+ }
111
+
112
+ const { stdout } = await execGitCommand(`git push origin ${tagName}`);
113
+
114
+ res.json({
115
+ success: true,
116
+ message: '标签推送成功',
117
+ output: stdout
118
+ });
119
+ } catch (error) {
120
+ console.error('推送标签失败:', error);
121
+ res.status(500).json({ success: false, error: error.message });
122
+ }
123
+ });
124
+
125
+ // 推送所有标签到远程
126
+ app.post('/api/push-all-tags', async (req, res) => {
127
+ try {
128
+ const { stdout } = await execGitCommand('git push origin --tags');
129
+
130
+ res.json({
131
+ success: true,
132
+ message: '所有标签推送成功',
133
+ output: stdout
134
+ });
135
+ } catch (error) {
136
+ console.error('推送所有标签失败:', error);
137
+ res.status(500).json({ success: false, error: error.message });
138
+ }
139
+ });
140
+
141
+ // 删除标签
142
+ app.post('/api/delete-tag', async (req, res) => {
143
+ try {
144
+ const { tagName } = req.body;
145
+
146
+ if (!tagName) {
147
+ return res.status(400).json({ success: false, error: '缺少标签名称' });
148
+ }
149
+
150
+ const { stdout } = await execGitCommand(`git tag -d ${tagName}`);
151
+
152
+ res.json({
153
+ success: true,
154
+ message: '标签删除成功',
155
+ output: stdout
156
+ });
157
+ } catch (error) {
158
+ console.error('删除标签失败:', error);
159
+ res.status(500).json({ success: false, error: error.message });
160
+ }
161
+ });
162
+
163
+ // 添加命令历史的清空API
164
+ app.post('/api/clear-command-history', async (req, res) => {
165
+ try {
166
+ const result = clearCommandHistory();
167
+ res.json({ success: result });
168
+ } catch (error) {
169
+ res.status(500).json({ success: false, error: error.message });
170
+ }
171
+ });
172
+ }