worktree-flow 0.0.16 → 0.0.18
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/README.md +30 -6
- package/dist/cli.js +6 -2
- package/dist/commands/attach.js +120 -0
- package/dist/commands/branch.js +3 -96
- package/dist/commands/checkout.js +55 -15
- package/dist/commands/create.js +118 -0
- package/dist/commands/{remove.js → drop.js} +8 -8
- package/dist/commands/fetch.js +25 -12
- package/dist/commands/helpers.js +24 -0
- package/dist/commands/prune.js +0 -1
- package/dist/commands/quickstart.js +1 -1
- package/dist/commands/tmux.js +3 -3
- package/dist/lib/git.js +3 -0
- package/dist/lib/repoConfig.js +60 -0
- package/dist/lib/services.js +3 -0
- package/dist/lib/tmux.js +23 -0
- package/dist/lib/workspaceResolver.js +13 -0
- package/dist/usecases/addToWorkspace.js +75 -0
- package/dist/usecases/createBranch.js +37 -0
- package/dist/usecases/createWorkspace.js +37 -0
- package/dist/usecases/discoverReposWithBranch.js +25 -0
- package/dist/usecases/usecases.js +8 -8
- package/package.json +1 -1
- package/dist/usecases/checkoutWorkspace.js +0 -91
- package/dist/usecases/createBranchWorkspace.js +0 -86
- package/dist/usecases/runPostCheckout.js +0 -49
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
/**
|
|
3
|
-
* Use case for running post-checkout commands.
|
|
4
|
-
* Runs commands either directly in worktree directories or in tmux panes.
|
|
5
|
-
*/
|
|
6
|
-
export class RunPostCheckoutUseCase {
|
|
7
|
-
workspaceDir;
|
|
8
|
-
postCheckout;
|
|
9
|
-
tmux;
|
|
10
|
-
constructor(workspaceDir, postCheckout, tmux) {
|
|
11
|
-
this.workspaceDir = workspaceDir;
|
|
12
|
-
this.postCheckout = postCheckout;
|
|
13
|
-
this.tmux = tmux;
|
|
14
|
-
}
|
|
15
|
-
async execute(params) {
|
|
16
|
-
// Skip if no commands configured
|
|
17
|
-
if (!params.postCheckout && (!params.perRepoPostCheckout || Object.keys(params.perRepoPostCheckout).length === 0)) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
// Get worktree directories
|
|
21
|
-
const worktreeDirs = this.workspaceDir.getWorktreeDirs(params.workspacePath);
|
|
22
|
-
// Map each worktree to its command (per-repo overrides global)
|
|
23
|
-
const commandsToRun = worktreeDirs
|
|
24
|
-
.map((dir, index) => {
|
|
25
|
-
const repoName = path.basename(dir);
|
|
26
|
-
const command = params.perRepoPostCheckout?.[repoName] ?? params.postCheckout;
|
|
27
|
-
return command ? { dir, command, paneIndex: index + 1 } : null;
|
|
28
|
-
})
|
|
29
|
-
.filter((x) => x !== null);
|
|
30
|
-
// Run commands in parallel
|
|
31
|
-
let successCount = 0;
|
|
32
|
-
await Promise.allSettled(commandsToRun.map(async ({ dir, command, paneIndex }) => {
|
|
33
|
-
try {
|
|
34
|
-
if (params.tmuxEnabled && params.sessionName) {
|
|
35
|
-
// Panes are indexed from 0, first pane (root) is 0, worktrees start at 1
|
|
36
|
-
await this.tmux.sendKeysToPane(params.sessionName, paneIndex, command);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
await this.postCheckout.runCommandInDirectory(dir, command);
|
|
40
|
-
}
|
|
41
|
-
successCount++;
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// Error handled by counting successes
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
47
|
-
return { successCount, totalCount: commandsToRun.length };
|
|
48
|
-
}
|
|
49
|
-
}
|