@jhorst11/wt 1.0.0 → 2.0.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 CHANGED
@@ -72,19 +72,65 @@ You'll be prompted to:
72
72
 
73
73
  ### Configuration
74
74
 
75
- You can configure wt-cli via environment variables:
75
+ wt-cli uses hierarchical config files to support user-wide and per-directory customization.
76
76
 
77
- ```bash
78
- # Directory where your projects live
79
- export W_PROJECTS_DIR="$HOME/projects"
77
+ #### Config File Locations
78
+
79
+ Config files are loaded from (lowest to highest priority):
80
+
81
+ 1. **Global config:** `~/.wt/config.json` - applies to all repositories
82
+ 2. **Repository config:** `<repo>/.wt/config.json` - overrides global config for this repo
83
+ 3. **Directory config:** `<any-directory>/.wt/config.json` - overrides parent configs for this directory and subdirectories
84
+
85
+ The nearest config file wins for each setting.
86
+
87
+ #### Global Config Example
88
+
89
+ Create `~/.wt/config.json`:
90
+
91
+ ```json
92
+ {
93
+ "projectsDir": "$HOME/code",
94
+ "worktreesDir": "$HOME/code/worktrees",
95
+ "branchPrefix": "username/"
96
+ }
97
+ ```
98
+
99
+ #### Repository Config Example
80
100
 
81
- # Directory where worktrees will be created
82
- export W_WORKTREES_DIR="$HOME/projects/worktrees"
101
+ Create `<repo>/.wt/config.json`:
83
102
 
84
- # Optional prefix for branch names (e.g., "username")
85
- export W_DEFAULT_BRANCH_PREFIX=""
103
+ ```json
104
+ {
105
+ "branchPrefix": "feature/",
106
+ "hooks": {
107
+ "post-create": [
108
+ "npm install",
109
+ "cp $WT_SOURCE/.env .env"
110
+ ]
111
+ }
112
+ }
86
113
  ```
87
114
 
115
+ #### Config Settings
116
+
117
+ | Field | Type | Default | Description |
118
+ |-------|------|---------|-------------|
119
+ | `projectsDir` | `string` | `~/projects` | Directory where main repositories live |
120
+ | `worktreesDir` | `string` | `~/projects/worktrees` | Directory where worktrees are created |
121
+ | `branchPrefix` | `string` | `""` | Prefix for branch names (e.g., "username/") |
122
+ | `hooks.post-create` | `string[]` | `[]` | Shell commands to run after creating a worktree |
123
+
124
+ **Hook environment variables** (available in hook commands):
125
+
126
+ | Variable | Description |
127
+ |----------|-------------|
128
+ | `WT_SOURCE` | Absolute path to the main repository |
129
+ | `WT_BRANCH` | Branch name of the new worktree |
130
+ | `WT_PATH` | Absolute path to the new worktree (also the cwd) |
131
+
132
+ Hook commands run with cwd set to the new worktree path. If a hook command fails, a warning is shown but the worktree creation still succeeds.
133
+
88
134
  ## How It Works
89
135
 
90
136
  wt-cli creates worktrees in a structured directory based on your project:
package/bin/wt.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { createRequire } from 'module';
3
4
  import { program } from 'commander';
4
5
  import {
5
6
  mainMenu,
@@ -13,10 +14,13 @@ import {
13
14
  import { showHelp, showLogo, spacer, colors } from '../src/ui.js';
14
15
  import { setupCommand } from '../src/setup.js';
15
16
 
17
+ const require = createRequire(import.meta.url);
18
+ const { version } = require('../package.json');
19
+
16
20
  program
17
21
  .name('wt')
18
22
  .description('🌳 Beautiful interactive git worktree manager')
19
- .version('1.0.0');
23
+ .version(version);
20
24
 
21
25
  program
22
26
  .command('new', { isDefault: false })
@@ -57,10 +61,7 @@ program
57
61
 
58
62
  // Default action (no command = interactive menu)
59
63
  program.action(async () => {
60
- const args = process.argv.slice(2);
61
- if (args.length === 0) {
62
- await mainMenu();
63
- }
64
+ await mainMenu();
64
65
  });
65
66
 
66
67
  // Custom help
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jhorst11/wt",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "🌳 Beautiful interactive git worktree manager",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,7 +12,8 @@
12
12
  "shell"
13
13
  ],
14
14
  "scripts": {
15
- "start": "node bin/wt.js"
15
+ "start": "node bin/wt.js",
16
+ "test": "node --test test/*.test.js"
16
17
  },
17
18
  "keywords": [
18
19
  "git",