clawt 2.3.1 → 2.3.2
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/dist/index.js +13 -2
- package/package.json +1 -1
- package/src/commands/remove.ts +13 -2
- package/src/constants/messages.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -114,7 +114,10 @@ var MESSAGES = {
|
|
|
114
114
|
/** reset 成功 */
|
|
115
115
|
RESET_SUCCESS: "\u2713 \u4E3B worktree \u5DE5\u4F5C\u533A\u548C\u6682\u5B58\u533A\u5DF2\u91CD\u7F6E",
|
|
116
116
|
/** reset 时工作区和暂存区已干净 */
|
|
117
|
-
RESET_ALREADY_CLEAN: "\u4E3B worktree \u5DE5\u4F5C\u533A\u548C\u6682\u5B58\u533A\u5DF2\u662F\u5E72\u51C0\u72B6\u6001\uFF0C\u65E0\u9700\u91CD\u7F6E"
|
|
117
|
+
RESET_ALREADY_CLEAN: "\u4E3B worktree \u5DE5\u4F5C\u533A\u548C\u6682\u5B58\u533A\u5DF2\u662F\u5E72\u51C0\u72B6\u6001\uFF0C\u65E0\u9700\u91CD\u7F6E",
|
|
118
|
+
/** 批量移除部分失败 */
|
|
119
|
+
REMOVE_PARTIAL_FAILURE: (failures) => `\u4EE5\u4E0B worktree \u79FB\u9664\u5931\u8D25\uFF1A
|
|
120
|
+
${failures.map((f) => ` \u2717 ${f.path}: ${f.error}`).join("\n")}`
|
|
118
121
|
};
|
|
119
122
|
|
|
120
123
|
// src/constants/exitCodes.ts
|
|
@@ -758,6 +761,7 @@ async function handleRemove(options) {
|
|
|
758
761
|
if (!autoDelete) {
|
|
759
762
|
shouldDeleteBranch = await confirmAction("\u662F\u5426\u540C\u65F6\u5220\u9664\u5BF9\u5E94\u7684\u672C\u5730\u5206\u652F\uFF1F");
|
|
760
763
|
}
|
|
764
|
+
const failures = [];
|
|
761
765
|
for (const wt of worktreesToRemove) {
|
|
762
766
|
try {
|
|
763
767
|
removeWorktreeByPath(wt.path);
|
|
@@ -766,13 +770,20 @@ async function handleRemove(options) {
|
|
|
766
770
|
}
|
|
767
771
|
printSuccess(MESSAGES.WORKTREE_REMOVED(wt.path));
|
|
768
772
|
} catch (error) {
|
|
773
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
769
774
|
logger.error(`\u79FB\u9664 worktree \u5931\u8D25: ${wt.path} - ${error}`);
|
|
770
|
-
|
|
775
|
+
failures.push({ path: wt.path, error: errorMessage });
|
|
771
776
|
}
|
|
772
777
|
}
|
|
773
778
|
gitWorktreePrune();
|
|
774
779
|
const projectDir = getProjectWorktreeDir();
|
|
775
780
|
removeEmptyDir(projectDir);
|
|
781
|
+
if (failures.length > 0) {
|
|
782
|
+
printError(MESSAGES.REMOVE_PARTIAL_FAILURE(failures));
|
|
783
|
+
throw new ClawtError(
|
|
784
|
+
`${failures.length} \u4E2A worktree \u79FB\u9664\u5931\u8D25`
|
|
785
|
+
);
|
|
786
|
+
}
|
|
776
787
|
}
|
|
777
788
|
|
|
778
789
|
// src/commands/run.ts
|
package/package.json
CHANGED
package/src/commands/remove.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
removeEmptyDir,
|
|
16
16
|
printInfo,
|
|
17
17
|
printSuccess,
|
|
18
|
+
printError,
|
|
18
19
|
confirmAction,
|
|
19
20
|
} from '../utils/index.js';
|
|
20
21
|
|
|
@@ -91,7 +92,8 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
91
92
|
shouldDeleteBranch = await confirmAction('是否同时删除对应的本地分支?');
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
//
|
|
95
|
+
// 执行移除,收集失败项
|
|
96
|
+
const failures: Array<{ path: string; error: string }> = [];
|
|
95
97
|
for (const wt of worktreesToRemove) {
|
|
96
98
|
try {
|
|
97
99
|
removeWorktreeByPath(wt.path);
|
|
@@ -100,8 +102,9 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
100
102
|
}
|
|
101
103
|
printSuccess(MESSAGES.WORKTREE_REMOVED(wt.path));
|
|
102
104
|
} catch (error) {
|
|
105
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
103
106
|
logger.error(`移除 worktree 失败: ${wt.path} - ${error}`);
|
|
104
|
-
|
|
107
|
+
failures.push({ path: wt.path, error: errorMessage });
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
|
|
@@ -109,4 +112,12 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
109
112
|
gitWorktreePrune();
|
|
110
113
|
const projectDir = getProjectWorktreeDir();
|
|
111
114
|
removeEmptyDir(projectDir);
|
|
115
|
+
|
|
116
|
+
// 汇总报告失败项
|
|
117
|
+
if (failures.length > 0) {
|
|
118
|
+
printError(MESSAGES.REMOVE_PARTIAL_FAILURE(failures));
|
|
119
|
+
throw new ClawtError(
|
|
120
|
+
`${failures.length} 个 worktree 移除失败`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
112
123
|
}
|
|
@@ -99,4 +99,7 @@ export const MESSAGES = {
|
|
|
99
99
|
RESET_SUCCESS: '✓ 主 worktree 工作区和暂存区已重置',
|
|
100
100
|
/** reset 时工作区和暂存区已干净 */
|
|
101
101
|
RESET_ALREADY_CLEAN: '主 worktree 工作区和暂存区已是干净状态,无需重置',
|
|
102
|
+
/** 批量移除部分失败 */
|
|
103
|
+
REMOVE_PARTIAL_FAILURE: (failures: Array<{ path: string; error: string }>) =>
|
|
104
|
+
`以下 worktree 移除失败:\n${failures.map((f) => ` ✗ ${f.path}: ${f.error}`).join('\n')}`,
|
|
102
105
|
} as const;
|