@jhorst11/wt 2.0.1 → 2.1.0
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 +39 -3
- package/dist/bin/wt.d.ts +3 -0
- package/dist/bin/wt.d.ts.map +1 -0
- package/dist/bin/wt.js +83 -0
- package/dist/bin/wt.js.map +1 -0
- package/dist/src/commands.d.ts +9 -0
- package/dist/src/commands.d.ts.map +1 -0
- package/dist/src/commands.js +924 -0
- package/dist/src/commands.js.map +1 -0
- package/dist/src/config.d.ts +51 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +384 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/git.d.ts +55 -0
- package/dist/src/git.d.ts.map +1 -0
- package/dist/src/git.js +387 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/setup.d.ts +8 -0
- package/dist/src/setup.d.ts.map +1 -0
- package/dist/src/setup.js +245 -0
- package/dist/src/setup.js.map +1 -0
- package/dist/src/types.d.ts +64 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/ui.d.ts +93 -0
- package/dist/src/ui.d.ts.map +1 -0
- package/dist/src/ui.js +273 -0
- package/dist/src/ui.js.map +1 -0
- package/package.json +20 -6
- package/bin/wt.js +0 -87
- package/shell/wt.sh +0 -66
- package/src/commands.js +0 -883
- package/src/config.js +0 -257
- package/src/git.js +0 -397
- package/src/setup.js +0 -267
- package/src/ui.js +0 -147
package/README.md
CHANGED
|
@@ -107,6 +107,9 @@ Create `<repo>/.wt/config.json`:
|
|
|
107
107
|
"post-create": [
|
|
108
108
|
"npm install",
|
|
109
109
|
"cp $WT_SOURCE/.env .env"
|
|
110
|
+
],
|
|
111
|
+
"pre-destroy": [
|
|
112
|
+
"npm run clean"
|
|
110
113
|
]
|
|
111
114
|
}
|
|
112
115
|
}
|
|
@@ -120,16 +123,49 @@ Create `<repo>/.wt/config.json`:
|
|
|
120
123
|
| `worktreesDir` | `string` | `~/projects/worktrees` | Directory where worktrees are created |
|
|
121
124
|
| `branchPrefix` | `string` | `""` | Prefix for branch names (e.g., "username/") |
|
|
122
125
|
| `hooks.post-create` | `string[]` | `[]` | Shell commands to run after creating a worktree |
|
|
126
|
+
| `hooks.pre-destroy` | `string[]` | `[]` | Shell commands to run before removing a worktree |
|
|
123
127
|
|
|
124
128
|
**Hook environment variables** (available in hook commands):
|
|
125
129
|
|
|
126
130
|
| Variable | Description |
|
|
127
131
|
|----------|-------------|
|
|
128
132
|
| `WT_SOURCE` | Absolute path to the main repository |
|
|
129
|
-
| `WT_BRANCH` | Branch name of the
|
|
130
|
-
| `WT_PATH` | Absolute path to the
|
|
133
|
+
| `WT_BRANCH` | Branch name of the worktree |
|
|
134
|
+
| `WT_PATH` | Absolute path to the worktree (also the cwd) |
|
|
135
|
+
| `WT_NAME` | Worktree name (directory name, e.g. `feature-a`) |
|
|
136
|
+
| `WT_COLOR` | Hex color assigned to this worktree (e.g. `#E53935`), for UI/theming |
|
|
131
137
|
|
|
132
|
-
|
|
138
|
+
Each new worktree is assigned a unique color from a fixed palette (stored in `<repo>/.wt/worktree-colors.json`). In supported terminals (iTerm2, WezTerm, Ghostty, Kitty, Windows Terminal, Alacritty), the tab color is set to that worktree's color when you create a worktree or run `wt go <name>`. Colors also appear as indicators (●) throughout the CLI UI.
|
|
139
|
+
|
|
140
|
+
Hook commands run with cwd set to the worktree path. To run a Node script that lives in the main repo (e.g. `<repo>/.wt/scripts/foo.js`), use `WT_SOURCE`: `node "$WT_SOURCE/.wt/scripts/foo.js"` — `./scripts/foo.js` would look inside the worktree, not the main repo. If a hook command fails, a warning is shown but the operation continues (worktree creation still succeeds; worktree removal still proceeds after pre-destroy).
|
|
141
|
+
|
|
142
|
+
#### Worktree Color Configuration
|
|
143
|
+
|
|
144
|
+
Override automatic colors or provide a custom palette:
|
|
145
|
+
|
|
146
|
+
**Manual color assignment** (`.wt/config.json`):
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"worktreeColors": {
|
|
151
|
+
"feature-auth": "#FF5733",
|
|
152
|
+
"feature-payments": "#33FF57"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Custom color palette** (`.wt/config.json`):
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"colorPalette": [
|
|
162
|
+
"#FF6B6B", "#4ECDC4", "#45B7D1", "#FFA07A",
|
|
163
|
+
"#98D8C8", "#F7DC6F", "#BB8FCE", "#85C1E2"
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Colors are stored per-repository in `.wt/worktree-colors.json` and support hierarchical configuration (global → repo → directory overrides).
|
|
133
169
|
|
|
134
170
|
## How It Works
|
|
135
171
|
|
package/dist/bin/wt.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wt.d.ts","sourceRoot":"","sources":["../../bin/wt.ts"],"names":[],"mappings":""}
|
package/dist/bin/wt.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
5
|
+
import { program } from 'commander';
|
|
6
|
+
import { mainMenu, createWorktreeFlow, listWorktrees, removeWorktreeFlow, mergeWorktreeFlow, goHome, goToWorktree, } from '../src/commands.js';
|
|
7
|
+
import { spacer, colors } from '../src/ui.js';
|
|
8
|
+
import { setupCommand } from '../src/setup.js';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
// Resolve package.json relative to project root (one level up from bin/)
|
|
13
|
+
const packagePath = join(__dirname, '..', '..', 'package.json');
|
|
14
|
+
const { version } = require(packagePath);
|
|
15
|
+
program
|
|
16
|
+
.name('wt')
|
|
17
|
+
.description('🌳 Beautiful interactive git worktree manager')
|
|
18
|
+
.version(version)
|
|
19
|
+
.option('--verbose', 'Show full hook command output (default: show command name with spinner only)');
|
|
20
|
+
program
|
|
21
|
+
.command('new', { isDefault: false })
|
|
22
|
+
.description('Create a new worktree interactively')
|
|
23
|
+
.option('--no-hooks', 'Skip post-create hooks')
|
|
24
|
+
.action((args, cmd) => {
|
|
25
|
+
createWorktreeFlow({ verbose: !!cmd.parent?.opts?.()?.verbose, hooks: args.hooks });
|
|
26
|
+
});
|
|
27
|
+
program
|
|
28
|
+
.command('list')
|
|
29
|
+
.alias('ls')
|
|
30
|
+
.description('List all worktrees for the current repo')
|
|
31
|
+
.action(listWorktrees);
|
|
32
|
+
program
|
|
33
|
+
.command('remove')
|
|
34
|
+
.alias('rm')
|
|
35
|
+
.description('Remove a worktree interactively')
|
|
36
|
+
.action((_args, cmd) => {
|
|
37
|
+
removeWorktreeFlow({ verbose: !!cmd.parent?.opts?.()?.verbose });
|
|
38
|
+
});
|
|
39
|
+
program
|
|
40
|
+
.command('merge')
|
|
41
|
+
.description('Merge a worktree branch back to main')
|
|
42
|
+
.action((_args, cmd) => {
|
|
43
|
+
mergeWorktreeFlow({ verbose: !!cmd.parent?.opts?.()?.verbose });
|
|
44
|
+
});
|
|
45
|
+
program
|
|
46
|
+
.command('home')
|
|
47
|
+
.description('Return to the main repository')
|
|
48
|
+
.action(goHome);
|
|
49
|
+
program
|
|
50
|
+
.command('go [name]')
|
|
51
|
+
.alias('jump')
|
|
52
|
+
.description('Jump to a worktree (interactive if no name)')
|
|
53
|
+
.action((name) => {
|
|
54
|
+
goToWorktree(name);
|
|
55
|
+
});
|
|
56
|
+
program
|
|
57
|
+
.command('setup')
|
|
58
|
+
.description('Configure shell integration for directory jumping')
|
|
59
|
+
.action(setupCommand);
|
|
60
|
+
// Default action (no command = interactive menu)
|
|
61
|
+
program.action(async () => {
|
|
62
|
+
await mainMenu();
|
|
63
|
+
});
|
|
64
|
+
// Custom help
|
|
65
|
+
program.on('--help', () => {
|
|
66
|
+
spacer();
|
|
67
|
+
console.log('Examples:');
|
|
68
|
+
console.log(` ${colors.muted('$')} wt ${colors.muted('# Interactive menu')}`);
|
|
69
|
+
console.log(` ${colors.muted('$')} wt new ${colors.muted('# Create new worktree')}`);
|
|
70
|
+
console.log(` ${colors.muted('$')} wt list ${colors.muted('# List all worktrees')}`);
|
|
71
|
+
console.log(` ${colors.muted('$')} wt go feature-x ${colors.muted('# Jump to worktree')}`);
|
|
72
|
+
console.log(` ${colors.muted('$')} wt merge ${colors.muted('# Merge worktree to main')}`);
|
|
73
|
+
console.log(` ${colors.muted('$')} wt home ${colors.muted('# Return to main repo')}`);
|
|
74
|
+
console.log(` ${colors.muted('$')} wt setup ${colors.muted('# Configure shell integration')}`);
|
|
75
|
+
spacer();
|
|
76
|
+
});
|
|
77
|
+
// Handle graceful exit
|
|
78
|
+
process.on('SIGINT', () => {
|
|
79
|
+
console.log('\n');
|
|
80
|
+
process.exit(0);
|
|
81
|
+
});
|
|
82
|
+
program.parse();
|
|
83
|
+
//# sourceMappingURL=wt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wt.js","sourceRoot":"","sources":["../../bin/wt.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,EACN,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAsB,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CA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types.js';
|
|
2
|
+
export declare function mainMenu(): Promise<void>;
|
|
3
|
+
export declare function createWorktreeFlow(options?: CommandOptions): Promise<void>;
|
|
4
|
+
export declare function listWorktrees(): Promise<void>;
|
|
5
|
+
export declare function removeWorktreeFlow(options?: CommandOptions): Promise<void>;
|
|
6
|
+
export declare function mergeWorktreeFlow(options?: CommandOptions): Promise<void>;
|
|
7
|
+
export declare function goHome(): Promise<void>;
|
|
8
|
+
export declare function goToWorktree(name?: string): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,YAAY,CAAC;AAuB/D,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CA+H9C;AAED,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2QpF;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAyCnD;AAED,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2KpF;AAED,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiQnF;AAED,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAuC5C;AAED,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgG/D"}
|