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,68 +1,82 @@
1
- export function registerProcessRoutes({
2
- app,
3
- runningProcesses,
4
- exec
5
- }) {
6
- // 停止正在运行的进程
7
- app.post('/api/kill-process', async (req, res) => {
8
- try {
9
- const { processId } = req.body || {};
10
- if (!processId || typeof processId !== 'number') {
11
- return res.status(400).json({ success: false, error: 'processId 必须是数字' });
12
- }
13
-
14
- const processInfo = runningProcesses.get(processId);
15
- if (!processInfo) {
16
- return res.status(404).json({
17
- success: false,
18
- error: `进程 #${processId} 不存在或已结束`
19
- });
20
- }
21
-
22
- console.log(`[进程管理] 尝试停止进程 #${processId}: ${processInfo.command}`);
23
-
24
- try {
25
- // Windows 上需要使用 taskkill 来杀死整个进程树
26
- if (process.platform === 'win32') {
27
- // 使用已导入的 exec
28
- // /F 强制终止, /T 终止进程树
29
- exec(`taskkill /pid ${processInfo.childProcess.pid} /T /F`, (error) => {
30
- if (error) {
31
- console.error(`[进程管理] taskkill 失败:`, error);
32
- }
33
- });
34
- } else {
35
- // Unix/Linux/Mac 使用 SIGTERM
36
- processInfo.childProcess.kill('SIGTERM');
37
-
38
- // 如果 2 秒后还没结束,使用 SIGKILL 强制终止
39
- setTimeout(() => {
40
- if (runningProcesses.has(processId)) {
41
- console.log(`[进程管理] 进程 #${processId} 未响应 SIGTERM,使用 SIGKILL 强制终止`);
42
- processInfo.childProcess.kill('SIGKILL');
43
- }
44
- }, 2000);
45
- }
46
-
47
- res.json({
48
- success: true,
49
- message: `已发送停止信号到进程 #${processId}`,
50
- processId,
51
- command: processInfo.command
52
- });
53
- } catch (killError) {
54
- console.error(`[进程管理] 停止进程失败:`, killError);
55
- res.status(500).json({
56
- success: false,
57
- error: `停止进程失败: ${killError.message}`
58
- });
59
- }
60
- } catch (error) {
61
- console.error('停止进程接口失败:', error);
62
- res.status(500).json({
63
- success: false,
64
- error: `停止进程失败: ${error.message}`
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
- import { promises as fs } from 'fs';
2
- import path from 'path';
3
-
4
- export function registerStatusRoutes({
5
- app,
6
- getCommandHistory,
7
- execGitCommand
8
- }) {
9
- // Add new endpoint for command history
10
- app.get('/api/command-history', async (req, res) => {
11
- try {
12
- const history = getCommandHistory();
13
- res.json({ success: true, history });
14
- } catch (error) {
15
- res.status(500).json({ success: false, error: error.message });
16
- }
17
- });
18
-
19
- app.get('/api/status_porcelain', async (req, res) => {
20
- try {
21
- const { stdout } = await execGitCommand('git status --porcelain --untracked-files=all');
22
- // 检测是否处于 MERGING 状态(MERGE_HEAD 文件存在)
23
- let isMergeInProgress = false;
24
- let mergeMessage = '';
25
- try {
26
- const { stdout: mergeHead } = await execGitCommand('git rev-parse -q --verify MERGE_HEAD');
27
- isMergeInProgress = mergeHead.trim().length > 0;
28
- if (isMergeInProgress) {
29
- // 读取 Git 自动生成的合并提交信息
30
- try {
31
- const { stdout: gitDir } = await execGitCommand('git rev-parse --git-dir');
32
- const mergeMsgPath = path.resolve(gitDir.trim(), 'MERGE_MSG');
33
- const raw = await fs.readFile(mergeMsgPath, 'utf-8');
34
- // 过滤掉以 # 开头的注释行,取第一个非空行
35
- mergeMessage = raw
36
- .split('\n')
37
- .filter(line => line.trim() && !line.startsWith('#'))
38
- .join('\n')
39
- .trim();
40
- } catch (_) {
41
- // MERGE_MSG 不存在时忽略
42
- }
43
- }
44
- } catch (_) {
45
- // MERGE_HEAD 不存在时命令会报错,属正常情况
46
- isMergeInProgress = false;
47
- }
48
- res.json({ status: stdout, isMergeInProgress, mergeMessage });
49
- } catch (error) {
50
- res.status(500).json({ error: error.message });
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
+ }