@ntindle/branchlet 0.1.6
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/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/index.js +57425 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Raghav Pillai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# 🌳 Branchlet
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/branchlet)
|
|
4
|
+
[](https://www.npmjs.com/package/branchlet)
|
|
5
|
+
|
|
6
|
+
A interactive CLI tool for creating and managing Git worktrees with an easy to use interface.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Quick Commands**: Jump directly to specific actions via command line
|
|
13
|
+
- **Smart Configuration**: Project-specific and global configuration support
|
|
14
|
+
- **File Management**: Automatically copy configuration files to new worktrees
|
|
15
|
+
- **Post-Create Actions**: Run custom commands after worktree creation
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g branchlet
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
Run Branchlet in any Git repository:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
branchlet
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This opens an interactive menu where you can:
|
|
32
|
+
- Create new worktrees
|
|
33
|
+
- List existing worktrees
|
|
34
|
+
- Delete worktrees
|
|
35
|
+
- Configure settings
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
### Interactive Menu (Default)
|
|
40
|
+
```bash
|
|
41
|
+
branchlet
|
|
42
|
+
```
|
|
43
|
+
Opens the main menu with all available options.
|
|
44
|
+
|
|
45
|
+
### Direct Commands
|
|
46
|
+
```bash
|
|
47
|
+
branchlet create # Go directly to worktree creation
|
|
48
|
+
branchlet list # List all worktrees
|
|
49
|
+
branchlet delete # Go directly to worktree deletion
|
|
50
|
+
branchlet settings # Open settings menu
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Options
|
|
54
|
+
```bash
|
|
55
|
+
branchlet --help # Show help information
|
|
56
|
+
branchlet --version # Show version number
|
|
57
|
+
branchlet -m create # Set initial mode
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
Branchlet looks for configuration files in this order:
|
|
63
|
+
1. `.branchlet.json` in your repo's root (project-specific)
|
|
64
|
+
2. `~/.branchlet/settings.json` (global configuration)
|
|
65
|
+
|
|
66
|
+
### Configuration Options
|
|
67
|
+
|
|
68
|
+
Create a `.branchlet.json` file in your project root or configure global settings:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"worktreeCopyPatterns": [".env*", ".vscode/**"],
|
|
73
|
+
"worktreeCopyIgnores": ["**/node_modules/**", "**/dist/**", "**/.git/**"],
|
|
74
|
+
"worktreePathTemplate": "$BASE_PATH.worktree",
|
|
75
|
+
"postCreateCmd": ["npm install", "npm run db:generate"],
|
|
76
|
+
"terminalCommand": "code .",
|
|
77
|
+
"deleteBranchWithWorktree": true
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Configuration Fields
|
|
82
|
+
|
|
83
|
+
- **`worktreeCopyPatterns`**: Files/directories to copy to new worktrees (supports glob patterns)
|
|
84
|
+
- Default: `[".env*", ".vscode/**"]`
|
|
85
|
+
- Examples: `["*.json", "config/**", ".env.local"]`
|
|
86
|
+
|
|
87
|
+
- **`worktreeCopyIgnores`**: Files/directories to exclude when copying (supports glob patterns)
|
|
88
|
+
- Default: `["**/node_modules/**", "**/dist/**", "**/.git/**", "**/Thumbs.db", "**/.DS_Store"]`
|
|
89
|
+
|
|
90
|
+
- **`worktreePathTemplate`**: Template for worktree directory names
|
|
91
|
+
- Default: `"$BASE_PATH.worktree"`
|
|
92
|
+
- Variables: `$BASE_PATH`, `$WORKTREE_PATH`, `$BRANCH_NAME`, `$SOURCE_BRANCH`
|
|
93
|
+
- Examples: `"worktrees/$BRANCH_NAME"`, `"$BASE_PATH-branches/$BRANCH_NAME"`
|
|
94
|
+
|
|
95
|
+
- **`postCreateCmd`**: Commands to run after creating a worktree. Runs in the new worktree directory.
|
|
96
|
+
- Default: `[]`
|
|
97
|
+
- Examples: `["npm install"]`, `["pnpm install", "pnpm build"]`
|
|
98
|
+
- Variables supported in commands: `$BASE_PATH`, `$WORKTREE_PATH`, `$BRANCH_NAME`, `$SOURCE_BRANCH`
|
|
99
|
+
|
|
100
|
+
- **`terminalCommand`**: Command to open terminal/editor in the new worktree. Runs in the new worktree directory.
|
|
101
|
+
- Default: `""`
|
|
102
|
+
- Examples: `"code ."`, `"cursor ."`, `"zed ."`
|
|
103
|
+
|
|
104
|
+
- **`deleteBranchWithWorktree`**: Whether to also delete the associated git branch when deleting a worktree
|
|
105
|
+
- Default: `false`
|
|
106
|
+
- When enabled, deleting a worktree will also delete its branch (with safety checks)
|
|
107
|
+
- Shows warnings for branches with unpushed commits or uncommitted changes
|
|
108
|
+
|
|
109
|
+
### Template Variables
|
|
110
|
+
|
|
111
|
+
Available in `worktreePathTemplate`, `postCreateCmd`, and `terminalCommand`:
|
|
112
|
+
|
|
113
|
+
- `$BASE_PATH`: Base name of your repository
|
|
114
|
+
- `$WORKTREE_PATH`: Full path to the new worktree
|
|
115
|
+
- `$BRANCH_NAME`: Name of the new branch
|
|
116
|
+
- `$SOURCE_BRANCH`: Name of the source branch
|
|
117
|
+
|
|
118
|
+
## Usage Examples
|
|
119
|
+
|
|
120
|
+
### Basic Workflow
|
|
121
|
+
|
|
122
|
+
1. **Navigate to your Git repository**
|
|
123
|
+
```bash
|
|
124
|
+
cd my-project
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
2. **Start Branchlet**
|
|
128
|
+
```bash
|
|
129
|
+
branchlet
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
3. **Create a worktree**
|
|
133
|
+
- Select "Create new worktree"
|
|
134
|
+
- Enter directory name (e.g., `feature-auth`)
|
|
135
|
+
- Choose source branch (e.g., `main`)
|
|
136
|
+
- Enter new branch name (e.g., `feature/authentication`)
|
|
137
|
+
- Confirm creation
|
|
138
|
+
|
|
139
|
+
### Project-Specific Configuration
|
|
140
|
+
|
|
141
|
+
Create `.branchlet.json` in your project:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"worktreeCopyPatterns": [
|
|
146
|
+
".env.local",
|
|
147
|
+
".vscode/**",
|
|
148
|
+
"package.json",
|
|
149
|
+
"tsconfig.json"
|
|
150
|
+
],
|
|
151
|
+
"worktreePathTemplate": "worktrees/$BRANCH_NAME",
|
|
152
|
+
"postCreateCmd": [
|
|
153
|
+
"npm install",
|
|
154
|
+
"npm run db:populate"
|
|
155
|
+
],
|
|
156
|
+
"terminalCommand": "code .",
|
|
157
|
+
"deleteBranchWithWorktree": true
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Requirements
|
|
162
|
+
|
|
163
|
+
- Node.js 20.0.0 or higher
|
|
164
|
+
- Git installed and available in PATH
|
|
165
|
+
- Operating system: macOS, Linux, or Windows
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT
|