zen-gitsync 2.12.2 → 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.
Files changed (47) hide show
  1. package/LICENSE +190 -21
  2. package/index.js +25 -11
  3. package/package.json +2 -2
  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-CbqSI9nw.css +1 -0
  12. package/src/ui/public/assets/{EditorView-bnJmBq-i.js → EditorView-GS5cmh99.js} +2 -2
  13. package/src/ui/public/assets/SourceMapView-DyMK80hS.css +1 -0
  14. package/src/ui/public/assets/{SourceMapView-Rz5SD0A0.js → SourceMapView-_YRtzmZZ.js} +3 -3
  15. package/src/ui/public/assets/{index-bOs5P8fz.css → index-ML5Y-5lO.css} +1 -1
  16. package/src/ui/public/assets/{index-Bo3tntQh.js → index-yky0Sd13.js} +11 -11
  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 +1172 -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,272 +1,286 @@
1
- /**
2
- * 将项目中硬编码的颜色值转换为 CSS 变量
3
- *
4
- * 根据 variables.scss 中定义的颜色变量进行映射
5
- *
6
- * 使用方式:
7
- * node scripts/convert-colors-to-vars.cjs [--dry-run]
8
- *
9
- * --dry-run: 预览模式,不实际修改文件
10
- */
11
-
12
- const fs = require('fs');
13
- const path = require('path');
14
-
15
- // 获取命令行参数
16
- const args = process.argv.slice(2);
17
- const isDryRun = args.includes('--dry-run');
18
-
19
- // 颜色映射表(基于 variables.scss)
20
- const COLOR_MAP = {
21
- // 主色调
22
- '#409eff': 'var(--color-primary)',
23
- '#5a67d8': 'var(--color-primary-light)',
24
- '#337ecc': 'var(--color-primary-dark)',
25
- '#66b1ff': 'var(--color-primary-light)',
26
- '#a0cfff': 'var(--color-primary-light)',
27
-
28
- // 成功色
29
- '#67c23a': 'var(--color-success)',
30
- '#10b981': 'var(--color-success-light)',
31
- '#85ce61': 'var(--color-success)',
32
- '#b3e19d': 'var(--color-success)',
33
-
34
- // 警告色
35
- '#e6a23c': 'var(--color-warning)',
36
- '#f59e0b': 'var(--color-warning-light)',
37
- '#ebb563': 'var(--color-warning)',
38
- '#f3d19e': 'var(--color-warning)',
39
-
40
- // 危险色
41
- '#f56c6c': 'var(--color-danger)',
42
- '#ef4444': 'var(--color-danger-light)',
43
- '#dc2626': 'var(--color-danger-dark)',
44
- '#f78989': 'var(--color-danger)',
45
-
46
- // 信息色
47
- '#909399': 'var(--color-info)',
48
- '#8b5cf6': 'var(--color-info-light)',
49
-
50
- // 基础颜色
51
- '#ffffff': 'var(--color-white)',
52
- '#fff': 'var(--color-white)',
53
- '#000000': 'var(--color-black)',
54
- '#000': 'var(--color-black)',
55
-
56
- // 灰色系列
57
- '#f9fafb': 'var(--color-gray-50)',
58
- '#f3f4f6': 'var(--color-gray-100)',
59
- '#e5e7eb': 'var(--color-gray-200)',
60
- '#d1d5db': 'var(--color-gray-300)',
61
- '#9ca3af': 'var(--color-gray-400)',
62
- '#6b7280': 'var(--color-gray-500)',
63
- '#4b5563': 'var(--color-gray-600)',
64
- '#374151': 'var(--color-gray-700)',
65
- '#1f2937': 'var(--color-gray-800)',
66
- '#111827': 'var(--color-gray-900)',
67
-
68
- // 文字颜色
69
- '#303133': 'var(--text-primary)',
70
- '#606266': 'var(--text-secondary)',
71
- '#909399': 'var(--text-tertiary)',
72
- '#c0c4cc': 'var(--text-placeholder)',
73
- '#a8abb2': 'var(--text-placeholder)',
74
-
75
- // Git 状态颜色
76
- '#10b981': 'var(--git-status-added)',
77
- '#f59e0b': 'var(--git-status-modified)',
78
- '#ef4444': 'var(--git-status-deleted)',
79
- '#8b5cf6': 'var(--git-status-untracked)',
80
- '#f97316': 'var(--git-status-conflicted)',
81
-
82
- // 背景色(特殊)
83
- '#f5f5f5': 'var(--bg-page)',
84
- '#f8fafc': 'var(--bg-container-hover)',
85
- '#2d2d2d': 'var(--bg-code-dark)',
86
- '#f6f8fa': 'var(--bg-code)',
87
-
88
- // 其他常见颜色
89
- '#f8faff': '#f8faff', // 特殊渐变色,暂时保留
90
- '#eef4ff': '#eef4ff',
91
- '#fff2e6': '#fff2e6',
92
- '#f8f8f2': '#f8f8f2',
93
- };
94
-
95
- // 需要处理的文件扩展名
96
- const TARGET_EXTENSIONS = ['.vue', '.scss', '.css'];
97
-
98
- // 需要跳过的文件
99
- const SKIP_FILES = ['variables.scss', 'dark-theme.scss'];
100
-
101
- // 统计信息
102
- let stats = {
103
- totalFiles: 0,
104
- modifiedFiles: 0,
105
- totalReplacements: 0,
106
- replacementDetails: {},
107
- skippedColors: new Set(),
108
- };
109
-
110
- console.log(`\n运行模式: ${isDryRun ? '预览模式(不会修改文件)' : '修改模式'}\n`);
111
-
112
- /**
113
- * 递归扫描目录
114
- */
115
- function scanDirectory(dir, fileList = []) {
116
- const files = fs.readdirSync(dir);
117
-
118
- files.forEach(file => {
119
- const filePath = path.join(dir, file);
120
- const stat = fs.statSync(filePath);
121
-
122
- if (stat.isDirectory()) {
123
- if (file !== 'node_modules' && file !== '.git' && file !== 'dist') {
124
- scanDirectory(filePath, fileList);
125
- }
126
- } else {
127
- const ext = path.extname(file);
128
- if (TARGET_EXTENSIONS.includes(ext) && !SKIP_FILES.includes(file)) {
129
- fileList.push(filePath);
130
- }
131
- }
132
- });
133
-
134
- return fileList;
135
- }
136
-
137
- /**
138
- * 规范化颜色值(统一为小写)
139
- */
140
- function normalizeColor(color) {
141
- return color.toLowerCase();
142
- }
143
-
144
- /**
145
- * 处理文件内容
146
- */
147
- function processFileContent(content, filePath) {
148
- let modified = false;
149
- let newContent = content;
150
-
151
- // 匹配 6位 和 3位 十六进制颜色
152
- const colorRegex = /#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/g;
153
-
154
- newContent = newContent.replace(colorRegex, (match) => {
155
- const normalizedColor = normalizeColor(match);
156
-
157
- // 如果是3位颜色,展开为6位
158
- let expandedColor = normalizedColor;
159
- if (normalizedColor.length === 4) {
160
- expandedColor = '#' + normalizedColor[1] + normalizedColor[1] +
161
- normalizedColor[2] + normalizedColor[2] +
162
- normalizedColor[3] + normalizedColor[3];
163
- }
164
-
165
- // 查找映射
166
- const mappedVar = COLOR_MAP[normalizedColor] || COLOR_MAP[expandedColor];
167
-
168
- if (mappedVar && mappedVar !== match) {
169
- // 记录替换
170
- stats.replacementDetails[match] = (stats.replacementDetails[match] || 0) + 1;
171
- stats.totalReplacements++;
172
- modified = true;
173
- return mappedVar;
174
- } else if (!mappedVar) {
175
- // 记录未映射的颜色
176
- stats.skippedColors.add(match);
177
- }
178
-
179
- return match;
180
- });
181
-
182
- return { content: newContent, modified };
183
- }
184
-
185
- /**
186
- * 处理单个文件
187
- */
188
- function processFile(filePath) {
189
- try {
190
- const content = fs.readFileSync(filePath, 'utf8');
191
- const { content: newContent, modified } = processFileContent(content, filePath);
192
-
193
- if (modified) {
194
- if (!isDryRun) {
195
- fs.writeFileSync(filePath, newContent, 'utf8');
196
- }
197
- stats.modifiedFiles++;
198
- console.log(`${isDryRun ? '📋 [预览]' : '✅'} ${filePath}`);
199
- return true;
200
- }
201
-
202
- return false;
203
- } catch (error) {
204
- console.error(`❌ 处理文件失败: ${filePath}`, error.message);
205
- return false;
206
- }
207
- }
208
-
209
- /**
210
- * 主函数
211
- */
212
- function main() {
213
- const projectRoot = path.join(__dirname, '..');
214
- const srcDir = path.join(projectRoot, 'src');
215
-
216
- console.log('🚀 开始扫描并转换颜色值...\n');
217
- console.log(`📁 项目根目录: ${projectRoot}`);
218
- console.log(`📁 扫描目录: ${srcDir}\n`);
219
-
220
- // 扫描所有目标文件
221
- const files = scanDirectory(srcDir);
222
- stats.totalFiles = files.length;
223
-
224
- console.log(`📊 找到 ${files.length} 个文件需要检查\n`);
225
- console.log('🔄 开始处理文件...\n');
226
-
227
- // 处理每个文件
228
- files.forEach(file => {
229
- processFile(file);
230
- });
231
-
232
- // 输出统计信息
233
- console.log('\n' + '='.repeat(60));
234
- console.log('📊 转换统计报告');
235
- console.log('='.repeat(60));
236
- console.log(`总文件数: ${stats.totalFiles}`);
237
- console.log(`修改文件数: ${stats.modifiedFiles}`);
238
- console.log(`总替换次数: ${stats.totalReplacements}`);
239
-
240
- if (Object.keys(stats.replacementDetails).length > 0) {
241
- console.log('\n📋 替换详情:');
242
- Object.entries(stats.replacementDetails)
243
- .sort((a, b) => b[1] - a[1])
244
- .forEach(([color, count]) => {
245
- const varName = COLOR_MAP[color.toLowerCase()];
246
- console.log(` ${color} => ${varName}: ${count} 次`);
247
- });
248
- }
249
-
250
- if (stats.skippedColors.size > 0) {
251
- console.log('\n⚠️ 未映射的颜色(需要手动检查):');
252
- Array.from(stats.skippedColors)
253
- .sort()
254
- .forEach(color => {
255
- console.log(` ${color}`);
256
- });
257
- }
258
-
259
- if (isDryRun) {
260
- console.log('\n💡 提示: 这是预览模式,文件未被修改');
261
- console.log(' 移除 --dry-run 参数以实际应用更改');
262
- } else {
263
- console.log('\n✨ 转换完成!');
264
- }
265
- }
266
-
267
- // 运行主函数
268
- if (require.main === module) {
269
- main();
270
- }
271
-
272
- module.exports = { processFileContent };
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
+ /**
16
+ * 将项目中硬编码的颜色值转换为 CSS 变量
17
+ *
18
+ * 根据 variables.scss 中定义的颜色变量进行映射
19
+ *
20
+ * 使用方式:
21
+ * node scripts/convert-colors-to-vars.cjs [--dry-run]
22
+ *
23
+ * --dry-run: 预览模式,不实际修改文件
24
+ */
25
+
26
+ const fs = require('fs');
27
+ const path = require('path');
28
+
29
+ // 获取命令行参数
30
+ const args = process.argv.slice(2);
31
+ const isDryRun = args.includes('--dry-run');
32
+
33
+ // 颜色映射表(基于 variables.scss)
34
+ const COLOR_MAP = {
35
+ // 主色调
36
+ '#409eff': 'var(--color-primary)',
37
+ '#5a67d8': 'var(--color-primary-light)',
38
+ '#337ecc': 'var(--color-primary-dark)',
39
+ '#66b1ff': 'var(--color-primary-light)',
40
+ '#a0cfff': 'var(--color-primary-light)',
41
+
42
+ // 成功色
43
+ '#67c23a': 'var(--color-success)',
44
+ '#10b981': 'var(--color-success-light)',
45
+ '#85ce61': 'var(--color-success)',
46
+ '#b3e19d': 'var(--color-success)',
47
+
48
+ // 警告色
49
+ '#e6a23c': 'var(--color-warning)',
50
+ '#f59e0b': 'var(--color-warning-light)',
51
+ '#ebb563': 'var(--color-warning)',
52
+ '#f3d19e': 'var(--color-warning)',
53
+
54
+ // 危险色
55
+ '#f56c6c': 'var(--color-danger)',
56
+ '#ef4444': 'var(--color-danger-light)',
57
+ '#dc2626': 'var(--color-danger-dark)',
58
+ '#f78989': 'var(--color-danger)',
59
+
60
+ // 信息色
61
+ '#909399': 'var(--color-info)',
62
+ '#8b5cf6': 'var(--color-info-light)',
63
+
64
+ // 基础颜色
65
+ '#ffffff': 'var(--color-white)',
66
+ '#fff': 'var(--color-white)',
67
+ '#000000': 'var(--color-black)',
68
+ '#000': 'var(--color-black)',
69
+
70
+ // 灰色系列
71
+ '#f9fafb': 'var(--color-gray-50)',
72
+ '#f3f4f6': 'var(--color-gray-100)',
73
+ '#e5e7eb': 'var(--color-gray-200)',
74
+ '#d1d5db': 'var(--color-gray-300)',
75
+ '#9ca3af': 'var(--color-gray-400)',
76
+ '#6b7280': 'var(--color-gray-500)',
77
+ '#4b5563': 'var(--color-gray-600)',
78
+ '#374151': 'var(--color-gray-700)',
79
+ '#1f2937': 'var(--color-gray-800)',
80
+ '#111827': 'var(--color-gray-900)',
81
+
82
+ // 文字颜色
83
+ '#303133': 'var(--text-primary)',
84
+ '#606266': 'var(--text-secondary)',
85
+ '#909399': 'var(--text-tertiary)',
86
+ '#c0c4cc': 'var(--text-placeholder)',
87
+ '#a8abb2': 'var(--text-placeholder)',
88
+
89
+ // Git 状态颜色
90
+ '#10b981': 'var(--git-status-added)',
91
+ '#f59e0b': 'var(--git-status-modified)',
92
+ '#ef4444': 'var(--git-status-deleted)',
93
+ '#8b5cf6': 'var(--git-status-untracked)',
94
+ '#f97316': 'var(--git-status-conflicted)',
95
+
96
+ // 背景色(特殊)
97
+ '#f5f5f5': 'var(--bg-page)',
98
+ '#f8fafc': 'var(--bg-container-hover)',
99
+ '#2d2d2d': 'var(--bg-code-dark)',
100
+ '#f6f8fa': 'var(--bg-code)',
101
+
102
+ // 其他常见颜色
103
+ '#f8faff': '#f8faff', // 特殊渐变色,暂时保留
104
+ '#eef4ff': '#eef4ff',
105
+ '#fff2e6': '#fff2e6',
106
+ '#f8f8f2': '#f8f8f2',
107
+ };
108
+
109
+ // 需要处理的文件扩展名
110
+ const TARGET_EXTENSIONS = ['.vue', '.scss', '.css'];
111
+
112
+ // 需要跳过的文件
113
+ const SKIP_FILES = ['variables.scss', 'dark-theme.scss'];
114
+
115
+ // 统计信息
116
+ let stats = {
117
+ totalFiles: 0,
118
+ modifiedFiles: 0,
119
+ totalReplacements: 0,
120
+ replacementDetails: {},
121
+ skippedColors: new Set(),
122
+ };
123
+
124
+ console.log(`\n运行模式: ${isDryRun ? '预览模式(不会修改文件)' : '修改模式'}\n`);
125
+
126
+ /**
127
+ * 递归扫描目录
128
+ */
129
+ function scanDirectory(dir, fileList = []) {
130
+ const files = fs.readdirSync(dir);
131
+
132
+ files.forEach(file => {
133
+ const filePath = path.join(dir, file);
134
+ const stat = fs.statSync(filePath);
135
+
136
+ if (stat.isDirectory()) {
137
+ if (file !== 'node_modules' && file !== '.git' && file !== 'dist') {
138
+ scanDirectory(filePath, fileList);
139
+ }
140
+ } else {
141
+ const ext = path.extname(file);
142
+ if (TARGET_EXTENSIONS.includes(ext) && !SKIP_FILES.includes(file)) {
143
+ fileList.push(filePath);
144
+ }
145
+ }
146
+ });
147
+
148
+ return fileList;
149
+ }
150
+
151
+ /**
152
+ * 规范化颜色值(统一为小写)
153
+ */
154
+ function normalizeColor(color) {
155
+ return color.toLowerCase();
156
+ }
157
+
158
+ /**
159
+ * 处理文件内容
160
+ */
161
+ function processFileContent(content, filePath) {
162
+ let modified = false;
163
+ let newContent = content;
164
+
165
+ // 匹配 6位 和 3位 十六进制颜色
166
+ const colorRegex = /#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/g;
167
+
168
+ newContent = newContent.replace(colorRegex, (match) => {
169
+ const normalizedColor = normalizeColor(match);
170
+
171
+ // 如果是3位颜色,展开为6位
172
+ let expandedColor = normalizedColor;
173
+ if (normalizedColor.length === 4) {
174
+ expandedColor = '#' + normalizedColor[1] + normalizedColor[1] +
175
+ normalizedColor[2] + normalizedColor[2] +
176
+ normalizedColor[3] + normalizedColor[3];
177
+ }
178
+
179
+ // 查找映射
180
+ const mappedVar = COLOR_MAP[normalizedColor] || COLOR_MAP[expandedColor];
181
+
182
+ if (mappedVar && mappedVar !== match) {
183
+ // 记录替换
184
+ stats.replacementDetails[match] = (stats.replacementDetails[match] || 0) + 1;
185
+ stats.totalReplacements++;
186
+ modified = true;
187
+ return mappedVar;
188
+ } else if (!mappedVar) {
189
+ // 记录未映射的颜色
190
+ stats.skippedColors.add(match);
191
+ }
192
+
193
+ return match;
194
+ });
195
+
196
+ return { content: newContent, modified };
197
+ }
198
+
199
+ /**
200
+ * 处理单个文件
201
+ */
202
+ function processFile(filePath) {
203
+ try {
204
+ const content = fs.readFileSync(filePath, 'utf8');
205
+ const { content: newContent, modified } = processFileContent(content, filePath);
206
+
207
+ if (modified) {
208
+ if (!isDryRun) {
209
+ fs.writeFileSync(filePath, newContent, 'utf8');
210
+ }
211
+ stats.modifiedFiles++;
212
+ console.log(`${isDryRun ? '📋 [预览]' : '✅'} ${filePath}`);
213
+ return true;
214
+ }
215
+
216
+ return false;
217
+ } catch (error) {
218
+ console.error(`❌ 处理文件失败: ${filePath}`, error.message);
219
+ return false;
220
+ }
221
+ }
222
+
223
+ /**
224
+ * 主函数
225
+ */
226
+ function main() {
227
+ const projectRoot = path.join(__dirname, '..');
228
+ const srcDir = path.join(projectRoot, 'src');
229
+
230
+ console.log('🚀 开始扫描并转换颜色值...\n');
231
+ console.log(`📁 项目根目录: ${projectRoot}`);
232
+ console.log(`📁 扫描目录: ${srcDir}\n`);
233
+
234
+ // 扫描所有目标文件
235
+ const files = scanDirectory(srcDir);
236
+ stats.totalFiles = files.length;
237
+
238
+ console.log(`📊 找到 ${files.length} 个文件需要检查\n`);
239
+ console.log('🔄 开始处理文件...\n');
240
+
241
+ // 处理每个文件
242
+ files.forEach(file => {
243
+ processFile(file);
244
+ });
245
+
246
+ // 输出统计信息
247
+ console.log('\n' + '='.repeat(60));
248
+ console.log('📊 转换统计报告');
249
+ console.log('='.repeat(60));
250
+ console.log(`总文件数: ${stats.totalFiles}`);
251
+ console.log(`修改文件数: ${stats.modifiedFiles}`);
252
+ console.log(`总替换次数: ${stats.totalReplacements}`);
253
+
254
+ if (Object.keys(stats.replacementDetails).length > 0) {
255
+ console.log('\n📋 替换详情:');
256
+ Object.entries(stats.replacementDetails)
257
+ .sort((a, b) => b[1] - a[1])
258
+ .forEach(([color, count]) => {
259
+ const varName = COLOR_MAP[color.toLowerCase()];
260
+ console.log(` ${color} => ${varName}: ${count} 次`);
261
+ });
262
+ }
263
+
264
+ if (stats.skippedColors.size > 0) {
265
+ console.log('\n⚠️ 未映射的颜色(需要手动检查):');
266
+ Array.from(stats.skippedColors)
267
+ .sort()
268
+ .forEach(color => {
269
+ console.log(` ${color}`);
270
+ });
271
+ }
272
+
273
+ if (isDryRun) {
274
+ console.log('\n💡 提示: 这是预览模式,文件未被修改');
275
+ console.log(' 移除 --dry-run 参数以实际应用更改');
276
+ } else {
277
+ console.log('\n✨ 转换完成!');
278
+ }
279
+ }
280
+
281
+ // 运行主函数
282
+ if (require.main === module) {
283
+ main();
284
+ }
285
+
286
+ module.exports = { processFileContent };