clawt 2.16.0 → 2.16.1
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
CHANGED
|
@@ -261,7 +261,9 @@ var REMOVE_MESSAGES = {
|
|
|
261
261
|
${branches.map((b) => ` - ${b}`).join("\n")}`,
|
|
262
262
|
/** 批量移除部分失败 */
|
|
263
263
|
REMOVE_PARTIAL_FAILURE: (failures) => `\u4EE5\u4E0B worktree \u79FB\u9664\u5931\u8D25\uFF1A
|
|
264
|
-
${failures.map((f) => ` \u2717 ${f.path}: ${f.error}`).join("\n")}
|
|
264
|
+
${failures.map((f) => ` \u2717 ${f.path}: ${f.error}`).join("\n")}`,
|
|
265
|
+
/** 用户选择保留本地分支 */
|
|
266
|
+
REMOVE_BRANCHES_KEPT: "\u5DF2\u4FDD\u7559\u672C\u5730\u5206\u652F\uFF0C\u53EF\u7A0D\u540E\u4F7F\u7528 git branch -D <\u5206\u652F\u540D> \u624B\u52A8\u5220\u9664"
|
|
265
267
|
};
|
|
266
268
|
|
|
267
269
|
// src/constants/messages/reset.ts
|
|
@@ -762,6 +764,9 @@ function printWarning(message) {
|
|
|
762
764
|
function printInfo(message) {
|
|
763
765
|
console.log(message);
|
|
764
766
|
}
|
|
767
|
+
function printHint(message) {
|
|
768
|
+
console.log(chalk2.hex("#FF8C00")(message));
|
|
769
|
+
}
|
|
765
770
|
function printSeparator() {
|
|
766
771
|
console.log(MESSAGES.SEPARATOR);
|
|
767
772
|
}
|
|
@@ -2062,6 +2067,9 @@ async function handleRemove(options) {
|
|
|
2062
2067
|
let shouldDeleteBranch = autoDelete;
|
|
2063
2068
|
if (!autoDelete) {
|
|
2064
2069
|
shouldDeleteBranch = await confirmAction("\u662F\u5426\u540C\u65F6\u5220\u9664\u5BF9\u5E94\u7684\u672C\u5730\u5206\u652F\uFF1F");
|
|
2070
|
+
if (!shouldDeleteBranch) {
|
|
2071
|
+
printHint(MESSAGES.REMOVE_BRANCHES_KEPT);
|
|
2072
|
+
}
|
|
2065
2073
|
}
|
|
2066
2074
|
const failures = [];
|
|
2067
2075
|
for (const wt of worktreesToRemove) {
|
package/dist/postinstall.js
CHANGED
|
@@ -253,7 +253,9 @@ var REMOVE_MESSAGES = {
|
|
|
253
253
|
${branches.map((b) => ` - ${b}`).join("\n")}`,
|
|
254
254
|
/** 批量移除部分失败 */
|
|
255
255
|
REMOVE_PARTIAL_FAILURE: (failures) => `\u4EE5\u4E0B worktree \u79FB\u9664\u5931\u8D25\uFF1A
|
|
256
|
-
${failures.map((f) => ` \u2717 ${f.path}: ${f.error}`).join("\n")}
|
|
256
|
+
${failures.map((f) => ` \u2717 ${f.path}: ${f.error}`).join("\n")}`,
|
|
257
|
+
/** 用户选择保留本地分支 */
|
|
258
|
+
REMOVE_BRANCHES_KEPT: "\u5DF2\u4FDD\u7559\u672C\u5730\u5206\u652F\uFF0C\u53EF\u7A0D\u540E\u4F7F\u7528 git branch -D <\u5206\u652F\u540D> \u624B\u52A8\u5220\u9664"
|
|
257
259
|
};
|
|
258
260
|
|
|
259
261
|
// src/constants/messages/reset.ts
|
package/package.json
CHANGED
package/src/commands/remove.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
printInfo,
|
|
17
17
|
printSuccess,
|
|
18
18
|
printError,
|
|
19
|
+
printHint,
|
|
19
20
|
confirmAction,
|
|
20
21
|
removeSnapshot,
|
|
21
22
|
removeProjectSnapshots,
|
|
@@ -85,6 +86,9 @@ async function handleRemove(options: RemoveOptions): Promise<void> {
|
|
|
85
86
|
|
|
86
87
|
if (!autoDelete) {
|
|
87
88
|
shouldDeleteBranch = await confirmAction('是否同时删除对应的本地分支?');
|
|
89
|
+
if (!shouldDeleteBranch) {
|
|
90
|
+
printHint(MESSAGES.REMOVE_BRANCHES_KEPT);
|
|
91
|
+
}
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
// 执行移除,收集失败项
|
|
@@ -12,4 +12,6 @@ export const REMOVE_MESSAGES = {
|
|
|
12
12
|
/** 批量移除部分失败 */
|
|
13
13
|
REMOVE_PARTIAL_FAILURE: (failures: Array<{ path: string; error: string }>) =>
|
|
14
14
|
`以下 worktree 移除失败:\n${failures.map((f) => ` ✗ ${f.path}: ${f.error}`).join('\n')}`,
|
|
15
|
+
/** 用户选择保留本地分支 */
|
|
16
|
+
REMOVE_BRANCHES_KEPT: '已保留本地分支,可稍后使用 git branch -D <分支名> 手动删除',
|
|
15
17
|
} as const;
|
package/src/utils/formatter.ts
CHANGED
|
@@ -35,6 +35,14 @@ export function printInfo(message: string): void {
|
|
|
35
35
|
console.log(message);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* 输出提示信息(橙色)
|
|
40
|
+
* @param {string} message - 消息内容
|
|
41
|
+
*/
|
|
42
|
+
export function printHint(message: string): void {
|
|
43
|
+
console.log(chalk.hex('#FF8C00')(message));
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
/**
|
|
39
47
|
* 输出分隔线
|
|
40
48
|
*/
|
package/src/utils/index.ts
CHANGED
|
@@ -49,7 +49,7 @@ export { sanitizeBranchName, generateBranchNames, validateBranchesNotExist } fro
|
|
|
49
49
|
export { validateMainWorktree, validateGitInstalled, validateClaudeCodeInstalled } from './validation.js';
|
|
50
50
|
export { createWorktrees, getProjectWorktrees, getProjectWorktreeDir, cleanupWorktrees, getWorktreeStatus, createWorktreesByBranches } from './worktree.js';
|
|
51
51
|
export { loadConfig, writeDefaultConfig, writeConfig, saveConfig, getConfigValue, ensureClawtDirs, parseConcurrency } from './config.js';
|
|
52
|
-
export { printSuccess, printError, printWarning, printInfo, printSeparator, printDoubleSeparator, confirmAction, confirmDestructiveAction, formatWorktreeStatus, isWorktreeIdle, formatDuration } from './formatter.js';
|
|
52
|
+
export { printSuccess, printError, printWarning, printInfo, printHint, printSeparator, printDoubleSeparator, confirmAction, confirmDestructiveAction, formatWorktreeStatus, isWorktreeIdle, formatDuration } from './formatter.js';
|
|
53
53
|
export { ensureDir, removeEmptyDir } from './fs.js';
|
|
54
54
|
export { multilineInput } from './prompt.js';
|
|
55
55
|
export { launchInteractiveClaude, hasClaudeSessionHistory, launchInteractiveClaudeInNewTerminal } from './claude.js';
|
|
@@ -24,6 +24,7 @@ vi.mock('../../../src/constants/index.js', () => ({
|
|
|
24
24
|
REMOVE_SELECT_BRANCH: '请选择要移除的分支(空格选择,回车确认)',
|
|
25
25
|
REMOVE_MULTIPLE_MATCHES: (name: string) => `"${name}" 匹配到多个分支`,
|
|
26
26
|
REMOVE_NO_MATCH: (name: string, branches: string[]) => `未找到与 "${name}" 匹配的分支,可用:${branches.join(', ')}`,
|
|
27
|
+
REMOVE_BRANCHES_KEPT: '已保留本地分支,可稍后使用 git branch -D <分支名> 手动删除',
|
|
27
28
|
},
|
|
28
29
|
}));
|
|
29
30
|
|
|
@@ -40,6 +41,7 @@ vi.mock('../../../src/utils/index.js', () => ({
|
|
|
40
41
|
printInfo: vi.fn(),
|
|
41
42
|
printSuccess: vi.fn(),
|
|
42
43
|
printError: vi.fn(),
|
|
44
|
+
printHint: vi.fn(),
|
|
43
45
|
confirmAction: vi.fn(),
|
|
44
46
|
removeSnapshot: vi.fn(),
|
|
45
47
|
removeProjectSnapshots: vi.fn(),
|
|
@@ -59,6 +61,7 @@ import {
|
|
|
59
61
|
removeProjectSnapshots,
|
|
60
62
|
printSuccess,
|
|
61
63
|
printError,
|
|
64
|
+
printHint,
|
|
62
65
|
resolveTargetWorktrees,
|
|
63
66
|
} from '../../../src/utils/index.js';
|
|
64
67
|
|
|
@@ -72,6 +75,7 @@ const mockedRemoveSnapshot = vi.mocked(removeSnapshot);
|
|
|
72
75
|
const mockedRemoveProjectSnapshots = vi.mocked(removeProjectSnapshots);
|
|
73
76
|
const mockedPrintSuccess = vi.mocked(printSuccess);
|
|
74
77
|
const mockedPrintError = vi.mocked(printError);
|
|
78
|
+
const mockedPrintHint = vi.mocked(printHint);
|
|
75
79
|
const mockedResolveTargetWorktrees = vi.mocked(resolveTargetWorktrees);
|
|
76
80
|
|
|
77
81
|
beforeEach(() => {
|
|
@@ -86,6 +90,7 @@ beforeEach(() => {
|
|
|
86
90
|
mockedRemoveProjectSnapshots.mockReset();
|
|
87
91
|
mockedPrintSuccess.mockReset();
|
|
88
92
|
mockedPrintError.mockReset();
|
|
93
|
+
mockedPrintHint.mockReset();
|
|
89
94
|
mockedResolveTargetWorktrees.mockReset();
|
|
90
95
|
});
|
|
91
96
|
|
|
@@ -199,6 +204,8 @@ describe('handleRemove', () => {
|
|
|
199
204
|
expect(mockedConfirmAction).toHaveBeenCalled();
|
|
200
205
|
// 用户拒绝删除分支
|
|
201
206
|
expect(mockedDeleteBranch).not.toHaveBeenCalled();
|
|
207
|
+
// 应提示用户分支已保留
|
|
208
|
+
expect(mockedPrintHint).toHaveBeenCalledWith('已保留本地分支,可稍后使用 git branch -D <分支名> 手动删除');
|
|
202
209
|
});
|
|
203
210
|
|
|
204
211
|
it('-b 指定不存在的分支时 resolveTargetWorktrees 抛出错误', async () => {
|