@nemo-cli/git 0.1.1 → 0.1.3
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 +419 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1128 -52
- package/dist/index.js.map +1 -1
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -1,44 +1,445 @@
|
|
|
1
1
|
# `@nemo-cli/git`
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Enhanced Git workflow CLI with interactive prompts, automatic stash handling, and conventional commits support.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Global installation (recommended)
|
|
9
|
+
npm install -g @nemo-cli/git
|
|
10
|
+
|
|
11
|
+
# Or using pnpm
|
|
12
|
+
pnpm add @nemo-cli/git --global
|
|
8
13
|
```
|
|
9
14
|
|
|
15
|
+
## Key Features
|
|
16
|
+
|
|
17
|
+
- **Interactive Prompts**: User-friendly interface for all git operations
|
|
18
|
+
- **Auto Stash/Pop**: Automatically stashes changes before checkout/merge/pull, then restores them
|
|
19
|
+
- **Conventional Commits**: Interactive commit wizard with type/scope selection from your commitlint config
|
|
20
|
+
- **Smart Branch Management**: Advanced branch operations with merge status and time filtering
|
|
21
|
+
- **Ticket Auto-Detection**: Automatically extracts ticket numbers from branch names for commit messages
|
|
22
|
+
|
|
10
23
|
## Usage
|
|
11
24
|
|
|
25
|
+
The CLI provides the `ng` command as an enhanced replacement for git operations.
|
|
26
|
+
|
|
27
|
+
### Getting Help
|
|
28
|
+
|
|
12
29
|
```bash
|
|
13
|
-
# help
|
|
30
|
+
# Show main help
|
|
14
31
|
ng -h
|
|
15
|
-
|
|
32
|
+
|
|
33
|
+
# Show help for specific command
|
|
16
34
|
ng <command> -h
|
|
35
|
+
# Example:
|
|
36
|
+
ng commit -h
|
|
37
|
+
ng branch -h
|
|
38
|
+
```
|
|
17
39
|
|
|
18
|
-
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Commands
|
|
43
|
+
|
|
44
|
+
### Commit (`ng commit`)
|
|
45
|
+
|
|
46
|
+
Interactive commit workflow with conventional commits support.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
19
49
|
ng commit
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Features:**
|
|
53
|
+
- ✅ Shows staged and unstaged files
|
|
54
|
+
- ✅ Interactive file selection for staging
|
|
55
|
+
- ✅ Runs `lint-staged` before committing (configurable)
|
|
56
|
+
- ✅ Reads commit type and scope from your `commitlint.config.*`
|
|
57
|
+
- ✅ Auto-detects ticket number from branch name
|
|
58
|
+
- Supports: `feature/PRIME-1500`, `JIRA-123`, `123`, etc.
|
|
59
|
+
- ✅ Validates commit message (max 80 chars for title)
|
|
60
|
+
- ✅ Optional body/description
|
|
61
|
+
- ✅ Commit preview with colored output
|
|
62
|
+
- ✅ Optional push after commit
|
|
63
|
+
|
|
64
|
+
**Supported ticket formats:**
|
|
65
|
+
- `PRIME-1500`, `JIRA-123` (slash format)
|
|
66
|
+
- `PRIME_1500`, `JIRA_123` (underscore format)
|
|
67
|
+
- `1500` (number only)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Pull (`ng pull` / `ng pl`)
|
|
20
72
|
|
|
21
|
-
|
|
22
|
-
|
|
73
|
+
Pull changes with automatic stash handling.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Interactive mode (default)
|
|
23
77
|
ng pull
|
|
24
78
|
|
|
25
|
-
#
|
|
26
|
-
ng
|
|
79
|
+
# Rebase mode
|
|
80
|
+
ng pull -r
|
|
81
|
+
ng pull --rebase
|
|
82
|
+
|
|
83
|
+
# Merge mode (default)
|
|
84
|
+
ng pull -m
|
|
85
|
+
ng pull --merge
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Features:**
|
|
89
|
+
- ✅ Select any remote branch to pull
|
|
90
|
+
- ✅ Auto stash before pull, pop after
|
|
91
|
+
- ✅ Choose between merge or rebase mode
|
|
92
|
+
- ✅ Defaults to pulling current branch
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### Push (`ng push` / `ng ps`)
|
|
97
|
+
|
|
98
|
+
Push current branch to remote.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
27
101
|
ng push
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Features:**
|
|
105
|
+
- ✅ Pushes current branch to remote
|
|
106
|
+
- ✅ Interactive confirmation
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### Checkout (`ng checkout` / `ng co`)
|
|
111
|
+
|
|
112
|
+
Switch branches with automatic stash handling.
|
|
28
113
|
|
|
29
|
-
|
|
30
|
-
|
|
114
|
+
```bash
|
|
115
|
+
# Interactive branch selection (default: local)
|
|
31
116
|
ng checkout
|
|
32
117
|
|
|
33
|
-
#
|
|
34
|
-
|
|
118
|
+
# Local branches only
|
|
119
|
+
ng checkout -l
|
|
120
|
+
|
|
121
|
+
# Remote branches only
|
|
122
|
+
ng checkout -r
|
|
123
|
+
|
|
124
|
+
# Create and checkout new branch
|
|
125
|
+
ng checkout -b
|
|
126
|
+
ng checkout -b feature/my-branch
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Creating new branches:**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Interactive creation with branch type prefix
|
|
35
133
|
ng co -b
|
|
134
|
+
# Prompts you to select:
|
|
135
|
+
# 1. Branch type: feature/PRIME-, feature/, bugfix/
|
|
136
|
+
# 2. Branch name (max 15 chars)
|
|
137
|
+
|
|
138
|
+
# Direct creation
|
|
139
|
+
ng co -b feature/PRIME-1500
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Features:**
|
|
143
|
+
- ✅ Auto stash before checkout, pop after
|
|
144
|
+
- ✅ Interactive branch selection
|
|
145
|
+
- ✅ Separate lists for local and remote branches
|
|
146
|
+
- ✅ Create new branch with prefix templates
|
|
147
|
+
- ✅ Branch name validation
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### Branch Management (`ng branch`)
|
|
152
|
+
|
|
153
|
+
Advanced branch operations.
|
|
154
|
+
|
|
155
|
+
#### Delete Branches
|
|
36
156
|
|
|
37
|
-
|
|
157
|
+
```bash
|
|
158
|
+
# Delete local branches
|
|
38
159
|
ng branch delete
|
|
39
|
-
|
|
160
|
+
|
|
161
|
+
# Delete remote branches
|
|
40
162
|
ng branch delete -r
|
|
163
|
+
ng branch delete --remote
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Features:**
|
|
167
|
+
- ✅ Shows merge status: `(merged)` or `(not merged)`
|
|
168
|
+
- ✅ Displays last commit time
|
|
169
|
+
- ✅ Multi-select support
|
|
170
|
+
- ✅ Safety check for unmerged branches (requires confirmation)
|
|
171
|
+
- ✅ Excludes: `main`, `master`, `develop`
|
|
172
|
+
|
|
173
|
+
#### Clean Merged Branches
|
|
41
174
|
|
|
42
|
-
|
|
175
|
+
```bash
|
|
43
176
|
ng branch clean
|
|
44
177
|
```
|
|
178
|
+
|
|
179
|
+
**Features:**
|
|
180
|
+
- ✅ Only deletes branches merged to main/master/develop
|
|
181
|
+
- ✅ Time-based filtering:
|
|
182
|
+
- All merged branches
|
|
183
|
+
- Merged branches older than 1 month
|
|
184
|
+
- Merged branches older than 3 months
|
|
185
|
+
- Merged branches older than 1 year
|
|
186
|
+
- ✅ Shows list of branches before deletion
|
|
187
|
+
- ✅ Interactive confirmation
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
### List Branches (`ng list` / `ng ls`)
|
|
192
|
+
|
|
193
|
+
List branches with current branch indicator.
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# List all branches (default)
|
|
197
|
+
ng list
|
|
198
|
+
|
|
199
|
+
# Local branches only
|
|
200
|
+
ng list -l
|
|
201
|
+
ng list --local
|
|
202
|
+
|
|
203
|
+
# Remote branches only
|
|
204
|
+
ng list -r
|
|
205
|
+
ng list --remote
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Features:**
|
|
209
|
+
- ✅ Shows branch counts
|
|
210
|
+
- ✅ Highlights current branch
|
|
211
|
+
- ✅ Separate sections for local and remote branches
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### Merge Branches (`ng merge` / `ng mg`)
|
|
216
|
+
|
|
217
|
+
Merge branches with automatic stash handling.
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Interactive branch selection
|
|
221
|
+
ng merge
|
|
222
|
+
|
|
223
|
+
# Direct merge
|
|
224
|
+
ng merge feature/my-branch
|
|
225
|
+
|
|
226
|
+
# Merge local branch
|
|
227
|
+
ng merge -l
|
|
228
|
+
|
|
229
|
+
# Merge remote branch
|
|
230
|
+
ng merge -r
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Features:**
|
|
234
|
+
- ✅ Auto stash before merge, pop after
|
|
235
|
+
- ✅ Interactive branch selection with search
|
|
236
|
+
- ✅ Supports both local and remote branches
|
|
237
|
+
- ✅ Interactive confirmation for remote branches
|
|
238
|
+
- ✅ Direct argument support for quick merges
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### Stash Operations (`ng stash` / `ng st`)
|
|
243
|
+
|
|
244
|
+
Advanced stash management.
|
|
245
|
+
|
|
246
|
+
#### Save Changes
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Save with default message
|
|
250
|
+
ng stash save
|
|
251
|
+
|
|
252
|
+
# Save with custom message
|
|
253
|
+
ng stash save "work in progress"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### List Stashes
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
ng stash list
|
|
260
|
+
ng stash ls
|
|
261
|
+
ng stash l
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Features:**
|
|
265
|
+
- ✅ Shows all stash entries
|
|
266
|
+
- ✅ Displays changed files for each stash
|
|
267
|
+
- ✅ File count per stash
|
|
268
|
+
|
|
269
|
+
#### Pop Stashes
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
ng stash pop
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Features:**
|
|
276
|
+
- ✅ Multi-select support
|
|
277
|
+
- ✅ Pop multiple stashes at once
|
|
278
|
+
|
|
279
|
+
#### Drop Stashes
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
ng stash drop
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Features:**
|
|
286
|
+
- ✅ Multi-select support
|
|
287
|
+
- ✅ Drop specific stashes
|
|
288
|
+
|
|
289
|
+
#### Clear All Stashes
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
ng stash clear
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### Stash History
|
|
296
|
+
|
|
297
|
+
View persistent stash history with metadata.
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# View last 10 records
|
|
301
|
+
ng stash history
|
|
302
|
+
ng stash his # Alias
|
|
303
|
+
ng stash h # Short alias
|
|
304
|
+
|
|
305
|
+
# Options
|
|
306
|
+
ng stash history --all # Show all records
|
|
307
|
+
ng stash history --active # Active stashes only (unused)
|
|
308
|
+
ng stash history --clean # Clean records older than 30 days
|
|
309
|
+
ng stash history --clean 60 # Clean records older than 60 days
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Features:**
|
|
313
|
+
- ✅ **Semantic Naming**: Uses format `{operation}:{branch}@{timestamp}` (e.g., `pull:feature/test@2025-01-27-18-30-00`)
|
|
314
|
+
- ✅ **Persistent Tracking**: Maintains history even after stashes are popped or dropped
|
|
315
|
+
- ✅ **File Metadata**: Includes list of files changed in each stash
|
|
316
|
+
- ✅ **Status Tracking**: Tracks if stash is `active`, `popped`, or `dropped`
|
|
317
|
+
- ✅ **Auto Cleanup**: Keeps history manageable with configurable cleanup
|
|
318
|
+
|
|
319
|
+
**Display Format Example:**
|
|
320
|
+
```
|
|
321
|
+
📚 Stash History (3 records)
|
|
322
|
+
|
|
323
|
+
━━━ 📦 pull:feature/test@2025-01-27-18-30-00 ━━━
|
|
324
|
+
Operation: pull
|
|
325
|
+
Status: active
|
|
326
|
+
Branch: feature/test
|
|
327
|
+
Time: 2025-01-27, 18:30:00
|
|
328
|
+
Files (2):
|
|
329
|
+
• src/utils.ts
|
|
330
|
+
• src/index.ts
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Configuration
|
|
336
|
+
|
|
337
|
+
### Commitlint Integration
|
|
338
|
+
|
|
339
|
+
The commit command reads your `commitlint.config.*` file to provide type and scope options:
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
// commitlint.config.js
|
|
343
|
+
module.exports = {
|
|
344
|
+
rules: {
|
|
345
|
+
'type-enum': [2, 'always', [
|
|
346
|
+
'feat', 'fix', 'docs', 'style', 'refactor',
|
|
347
|
+
'perf', 'test', 'build', 'ci', 'chore', 'revert'
|
|
348
|
+
]],
|
|
349
|
+
'scope-enum': [2, 'always', [
|
|
350
|
+
'git', 'shared', 'ai', 'ui', 'packages', 'mail'
|
|
351
|
+
]]
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Lint-staged Integration
|
|
357
|
+
|
|
358
|
+
The commit command automatically runs `lint-staged` before committing if it's available in your project.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## Example Workflows
|
|
363
|
+
|
|
364
|
+
### Daily Development Flow
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
# 1. Start working on a new feature
|
|
368
|
+
ng co -b
|
|
369
|
+
# Select: feature/PRIME-
|
|
370
|
+
# Enter: 1500
|
|
371
|
+
# Creates: feature/PRIME-1500
|
|
372
|
+
|
|
373
|
+
# 2. Make changes...
|
|
374
|
+
|
|
375
|
+
# 3. Commit with interactive wizard
|
|
376
|
+
ng commit
|
|
377
|
+
# Select files to stage
|
|
378
|
+
# Choose type: feat
|
|
379
|
+
# Choose scope: git
|
|
380
|
+
# Enter title: add new command
|
|
381
|
+
# Enter description (optional)
|
|
382
|
+
# Preview and confirm
|
|
383
|
+
# Optionally push
|
|
384
|
+
|
|
385
|
+
# 4. Pull latest changes
|
|
386
|
+
ng pull
|
|
387
|
+
# Select branch: main
|
|
388
|
+
# Choose mode: rebase
|
|
389
|
+
# Auto stash/pop handled
|
|
390
|
+
|
|
391
|
+
# 5. Push your work
|
|
392
|
+
ng push
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Switching Contexts Safely
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Working on feature A, need to switch to feature B
|
|
399
|
+
ng checkout
|
|
400
|
+
# Auto stashes your current changes
|
|
401
|
+
# Select: feature/PRIME-1500 (feature B)
|
|
402
|
+
# Changes are popped automatically after checkout
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Cleaning Up Old Branches
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# Delete specific old branches
|
|
409
|
+
ng branch delete
|
|
410
|
+
# Select branches to delete
|
|
411
|
+
# See merge status and last commit time
|
|
412
|
+
# Confirm deletion
|
|
413
|
+
|
|
414
|
+
# Or clean all merged branches older than 1 month
|
|
415
|
+
ng branch clean
|
|
416
|
+
# Select: 1 month
|
|
417
|
+
# Review list
|
|
418
|
+
# Confirm deletion
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## Comparison: Git vs `ng`
|
|
424
|
+
|
|
425
|
+
| Operation | Git Command | `ng` Command |
|
|
426
|
+
|-----------|--------------|---------------|
|
|
427
|
+
| Commit | `git commit` | `ng commit` (interactive with lint) |
|
|
428
|
+
| Pull | `git pull` | `ng pull` (auto stash + mode selection) |
|
|
429
|
+
| Push | `git push` | `ng push` (interactive) |
|
|
430
|
+
| Checkout | `git checkout` | `ng checkout` (auto stash + interactive) |
|
|
431
|
+
| Branch delete | `git branch -D` | `ng branch delete` (merge status check) |
|
|
432
|
+
| List branches | `git branch` | `ng list` (enhanced display) |
|
|
433
|
+
| Merge | `git merge` | `ng merge` (auto stash + searchable) |
|
|
434
|
+
| Stash | `git stash` | `ng stash` (enhanced management) |
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Requirements
|
|
439
|
+
|
|
440
|
+
- Node.js `^20.19.0` or `>=22.12.0`
|
|
441
|
+
- Git installed and available in PATH
|
|
442
|
+
|
|
443
|
+
## License
|
|
444
|
+
|
|
445
|
+
ISC © [gaozimeng](https://github.com/GaoZimeng0425)
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;cAkBa,GAAA;;;;;;;yBAAoC,MAAA;AAAA;AAAA,cAEpC,IAAA,QAqBZ,UAAA,CArBgB,OAAA;AAAA,cAuBJ,GAAA,QAAG,OAAA"}
|