@alejandrochaves/devflow-cli 0.1.1 → 0.3.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/LICENSE +21 -0
- package/README.md +217 -15
- package/dist/colors.d.ts +9 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +13 -0
- package/dist/colors.js.map +1 -0
- package/dist/commands/amend.d.ts +4 -0
- package/dist/commands/amend.d.ts.map +1 -0
- package/dist/commands/amend.js +138 -0
- package/dist/commands/amend.js.map +1 -0
- package/dist/commands/branch.d.ts +3 -1
- package/dist/commands/branch.d.ts.map +1 -1
- package/dist/commands/branch.js +37 -5
- package/dist/commands/branch.js.map +1 -1
- package/dist/commands/changelog.d.ts +4 -0
- package/dist/commands/changelog.d.ts.map +1 -0
- package/dist/commands/changelog.js +204 -0
- package/dist/commands/changelog.js.map +1 -0
- package/dist/commands/cleanup.d.ts +4 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +124 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/commit.d.ts +13 -1
- package/dist/commands/commit.d.ts.map +1 -1
- package/dist/commands/commit.js +107 -25
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +122 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/fixup.d.ts +4 -0
- package/dist/commands/fixup.d.ts.map +1 -0
- package/dist/commands/fixup.js +100 -0
- package/dist/commands/fixup.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +260 -22
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/merge.d.ts +4 -0
- package/dist/commands/merge.d.ts.map +1 -0
- package/dist/commands/merge.js +84 -0
- package/dist/commands/merge.js.map +1 -0
- package/dist/commands/pr.d.ts +3 -1
- package/dist/commands/pr.d.ts.map +1 -1
- package/dist/commands/pr.js +49 -40
- package/dist/commands/pr.js.map +1 -1
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +83 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/test-plan.d.ts +2 -0
- package/dist/commands/test-plan.d.ts.map +1 -0
- package/dist/commands/test-plan.js +92 -0
- package/dist/commands/test-plan.js.map +1 -0
- package/dist/commands/undo.d.ts +4 -0
- package/dist/commands/undo.d.ts.map +1 -0
- package/dist/commands/undo.js +46 -0
- package/dist/commands/undo.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +100 -3
- package/dist/config.js.map +1 -1
- package/dist/git.d.ts +1 -0
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +5 -0
- package/dist/git.js.map +1 -1
- package/dist/index.js +145 -5
- package/dist/index.js.map +1 -1
- package/dist/monorepo.d.ts +13 -0
- package/dist/monorepo.d.ts.map +1 -0
- package/dist/monorepo.js +191 -0
- package/dist/monorepo.js.map +1 -0
- package/dist/test-plan.d.ts +5 -0
- package/dist/test-plan.d.ts.map +1 -0
- package/dist/test-plan.js +48 -0
- package/dist/test-plan.js.map +1 -0
- package/dist/update-notifier.d.ts +2 -0
- package/dist/update-notifier.d.ts.map +1 -0
- package/dist/update-notifier.js +96 -0
- package/dist/update-notifier.js.map +1 -0
- package/package.json +14 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alejandro Chaves
|
|
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
CHANGED
|
@@ -40,9 +40,17 @@ Or add scripts to your `package.json`:
|
|
|
40
40
|
|
|
41
41
|
### `devflow init`
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Interactive setup wizard that configures your entire project. Walks you through:
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
1. **Ticket base URL** — for linking tickets in PRs
|
|
46
|
+
2. **Scopes** — add project-specific scopes one by one (or use defaults)
|
|
47
|
+
3. **PR checklist** — customize or use defaults
|
|
48
|
+
4. **package.json scripts** — auto-adds `commit`, `branch`, `pr` scripts
|
|
49
|
+
5. **Commitlint** — creates config with the devflow parser preset, installs deps
|
|
50
|
+
6. **Husky** — installs, initializes, creates `commit-msg` hook + optional `pre-push` hook (lint + typecheck)
|
|
51
|
+
7. **CI workflow** — optionally generates `.github/workflows/ci.yml` (lint, typecheck, test)
|
|
52
|
+
|
|
53
|
+
### `devflow branch` (alias: `b`)
|
|
46
54
|
|
|
47
55
|
Interactive branch creation with consistent naming.
|
|
48
56
|
|
|
@@ -64,10 +72,12 @@ fix/PROJ-45_correct-calculation-overflow
|
|
|
64
72
|
chore/UNTRACKED_update-dependencies
|
|
65
73
|
```
|
|
66
74
|
|
|
67
|
-
### `devflow commit`
|
|
75
|
+
### `devflow commit` (alias: `c`)
|
|
68
76
|
|
|
69
77
|
Interactive conventional commit with file staging, scope selection, and ticket inference.
|
|
70
78
|
|
|
79
|
+
**Branch protection:** If you're on `main`, `master`, `develop`, or `production`, devflow warns you and asks for confirmation before proceeding.
|
|
80
|
+
|
|
71
81
|
**Flow:**
|
|
72
82
|
1. If no files are staged, select files to stage (checkbox selection)
|
|
73
83
|
2. Select commit type
|
|
@@ -93,7 +103,7 @@ refactor[ENV-200]!(api): restructure endpoints
|
|
|
93
103
|
|
|
94
104
|
The `!` after the ticket indicates a breaking change.
|
|
95
105
|
|
|
96
|
-
### `devflow pr`
|
|
106
|
+
### `devflow pr` (alias: `p`)
|
|
97
107
|
|
|
98
108
|
Create or update a pull request with an auto-filled template.
|
|
99
109
|
|
|
@@ -123,6 +133,127 @@ Create or update a pull request with an auto-filled template.
|
|
|
123
133
|
- Test Plan
|
|
124
134
|
- Checklist (customizable via config)
|
|
125
135
|
|
|
136
|
+
### `devflow test-plan` (alias: `tp`)
|
|
137
|
+
|
|
138
|
+
View or edit the test plan for the current branch. Test plan steps are stored locally and automatically included in the PR body.
|
|
139
|
+
|
|
140
|
+
**Flow:**
|
|
141
|
+
- If a test plan exists: view steps and choose to add, replace, or clear
|
|
142
|
+
- If no test plan: prompted to add steps
|
|
143
|
+
|
|
144
|
+
Steps are also optionally collected during `devflow branch` creation.
|
|
145
|
+
|
|
146
|
+
When you run `devflow pr`, stored test plan steps auto-populate the "Test Plan" section as checkboxes:
|
|
147
|
+
|
|
148
|
+
```markdown
|
|
149
|
+
## Test Plan
|
|
150
|
+
|
|
151
|
+
- [ ] Verify login flow with valid credentials
|
|
152
|
+
- [ ] Test error handling for expired tokens
|
|
153
|
+
- [ ] Confirm logout clears session data
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### `devflow undo` (alias: `u`)
|
|
157
|
+
|
|
158
|
+
Undo the last commit, keeping changes staged. Shows a preview of the commit that will be undone before confirming.
|
|
159
|
+
|
|
160
|
+
### `devflow fixup` (alias: `f`)
|
|
161
|
+
|
|
162
|
+
Create a fixup commit targeting a previous commit on the branch:
|
|
163
|
+
|
|
164
|
+
1. Shows recent commits on the branch
|
|
165
|
+
2. Select which commit to fix
|
|
166
|
+
3. Stage files (if needed)
|
|
167
|
+
4. Optionally auto-squash via interactive rebase
|
|
168
|
+
|
|
169
|
+
### `devflow merge` (alias: `m`)
|
|
170
|
+
|
|
171
|
+
Merge the current branch's PR via GitHub CLI:
|
|
172
|
+
|
|
173
|
+
1. Detects the PR for the current branch
|
|
174
|
+
2. Select merge strategy (squash, merge, rebase)
|
|
175
|
+
3. Optionally delete the branch and switch back to main
|
|
176
|
+
|
|
177
|
+
Requires `gh` CLI to be installed and authenticated.
|
|
178
|
+
|
|
179
|
+
### `devflow status` (alias: `s`)
|
|
180
|
+
|
|
181
|
+
At-a-glance view of your current branch context:
|
|
182
|
+
- Branch name, type, ticket, and description
|
|
183
|
+
- Inferred base branch
|
|
184
|
+
- Commit count with recent messages
|
|
185
|
+
- Working tree status (staged/modified/untracked)
|
|
186
|
+
- PR link and state (if exists)
|
|
187
|
+
|
|
188
|
+
### `devflow amend` (alias: `a`)
|
|
189
|
+
|
|
190
|
+
Re-edit the last commit message using the same guided prompts. Pre-fills all fields from the existing message. Also includes any staged changes in the amend.
|
|
191
|
+
|
|
192
|
+
### `devflow cleanup`
|
|
193
|
+
|
|
194
|
+
Finds and deletes local branches that are:
|
|
195
|
+
- Merged into `main`
|
|
196
|
+
- Tracking a remote branch that no longer exists
|
|
197
|
+
|
|
198
|
+
Fetches remote state first, shows checkbox selection, and asks for confirmation before force-deleting unmerged branches.
|
|
199
|
+
|
|
200
|
+
### `devflow changelog`
|
|
201
|
+
|
|
202
|
+
Generates a changelog entry from conventional commits since the last git tag:
|
|
203
|
+
- Groups by type (Features, Bug Fixes, etc.)
|
|
204
|
+
- Highlights breaking changes
|
|
205
|
+
- Auto-suggests the next version (semver bump based on commit types)
|
|
206
|
+
- Prepends to `CHANGELOG.md`
|
|
207
|
+
|
|
208
|
+
### `devflow doctor`
|
|
209
|
+
|
|
210
|
+
Checks that all devflow dependencies are properly configured:
|
|
211
|
+
- git, node (>= 18), gh CLI + auth
|
|
212
|
+
- `.devflow.json`, commitlint config, husky hooks
|
|
213
|
+
- `package.json` scripts
|
|
214
|
+
|
|
215
|
+
### `devflow completions`
|
|
216
|
+
|
|
217
|
+
Outputs shell completion scripts for tab-completion of commands:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# zsh (add to ~/.zshrc)
|
|
221
|
+
eval "$(devflow completions --shell zsh)"
|
|
222
|
+
|
|
223
|
+
# bash (add to ~/.bashrc)
|
|
224
|
+
eval "$(devflow completions --shell bash)"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Command Aliases
|
|
228
|
+
|
|
229
|
+
| Command | Alias |
|
|
230
|
+
|---------|-------|
|
|
231
|
+
| `devflow branch` | `devflow b` |
|
|
232
|
+
| `devflow commit` | `devflow c` |
|
|
233
|
+
| `devflow pr` | `devflow p` |
|
|
234
|
+
| `devflow amend` | `devflow a` |
|
|
235
|
+
| `devflow undo` | `devflow u` |
|
|
236
|
+
| `devflow fixup` | `devflow f` |
|
|
237
|
+
| `devflow merge` | `devflow m` |
|
|
238
|
+
| `devflow status` | `devflow s` |
|
|
239
|
+
| `devflow test-plan` | `devflow tp` |
|
|
240
|
+
|
|
241
|
+
## Global Options
|
|
242
|
+
|
|
243
|
+
Commands that modify git state support `--dry-run` to preview without executing:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
devflow commit --dry-run
|
|
247
|
+
devflow branch --dry-run
|
|
248
|
+
devflow pr --dry-run
|
|
249
|
+
devflow amend --dry-run
|
|
250
|
+
devflow undo --dry-run
|
|
251
|
+
devflow fixup --dry-run
|
|
252
|
+
devflow merge --dry-run
|
|
253
|
+
devflow cleanup --dry-run
|
|
254
|
+
devflow changelog --dry-run
|
|
255
|
+
```
|
|
256
|
+
|
|
126
257
|
## Configuration
|
|
127
258
|
|
|
128
259
|
Create a `.devflow.json` in your project root (or run `devflow init`):
|
|
@@ -131,20 +262,26 @@ Create a `.devflow.json` in your project root (or run `devflow init`):
|
|
|
131
262
|
{
|
|
132
263
|
"ticketBaseUrl": "https://github.com/org/repo/issues",
|
|
133
264
|
"scopes": [
|
|
134
|
-
{ "value": "auth", "description": "Authentication & login" },
|
|
135
|
-
{ "value": "ui", "description": "UI components" },
|
|
136
|
-
{ "value": "api", "description": "API layer" }
|
|
265
|
+
{ "value": "auth", "description": "Authentication & login", "paths": ["src/auth/**"] },
|
|
266
|
+
{ "value": "ui", "description": "UI components", "paths": ["src/components/**"] },
|
|
267
|
+
{ "value": "api", "description": "API layer", "paths": ["src/api/**", "src/services/**"] }
|
|
137
268
|
],
|
|
138
269
|
"branchTypes": ["feat", "fix", "chore", "refactor", "docs", "test", "release", "hotfix"],
|
|
139
270
|
"commitTypes": [
|
|
140
271
|
{ "value": "feat", "label": "feat: A new feature" },
|
|
141
272
|
{ "value": "fix", "label": "fix: A bug fix" }
|
|
142
273
|
],
|
|
274
|
+
"commitFormat": "{type}[{ticket}]{breaking}({scope}): {message}",
|
|
143
275
|
"checklist": [
|
|
144
276
|
"Code follows project conventions",
|
|
145
277
|
"Self-reviewed the changes",
|
|
146
278
|
"No new warnings or errors introduced"
|
|
147
|
-
]
|
|
279
|
+
],
|
|
280
|
+
"prTemplate": {
|
|
281
|
+
"sections": ["summary", "ticket", "type", "screenshots", "testPlan", "checklist"],
|
|
282
|
+
"screenshotsTable": true
|
|
283
|
+
},
|
|
284
|
+
"prReviewers": ["copilot"]
|
|
148
285
|
}
|
|
149
286
|
```
|
|
150
287
|
|
|
@@ -152,17 +289,66 @@ Create a `.devflow.json` in your project root (or run `devflow init`):
|
|
|
152
289
|
|
|
153
290
|
| Option | Description | Default |
|
|
154
291
|
|--------|-------------|---------|
|
|
155
|
-
| `ticketBaseUrl` | Base URL for linking tickets in PRs
|
|
156
|
-
| `scopes` | List of scopes with `value
|
|
157
|
-
| `
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
292
|
+
| `ticketBaseUrl` | Base URL for linking tickets in PRs | — |
|
|
293
|
+
| `scopes` | List of scopes with `value`, `description`, and optional `paths` for auto-inference | `[]` (free text input) |
|
|
294
|
+
| `scopes[].paths` | Glob patterns to auto-suggest this scope when matching files are staged | — |
|
|
295
|
+
| `branchTypes` | Allowed branch type prefixes | `["feat", "fix", "chore", ...]` |
|
|
296
|
+
| `commitTypes` | Commit types shown in selection menu (`value` + `label`) | Standard conventional types |
|
|
297
|
+
| `commitFormat` | Commit message format with `{type}`, `{ticket}`, `{breaking}`, `{scope}`, `{message}` placeholders | `{type}[{ticket}]{breaking}({scope}): {message}` |
|
|
298
|
+
| `checklist` | PR checklist items | Basic code review items |
|
|
299
|
+
| `prTemplate.sections` | PR body sections to include | All sections |
|
|
300
|
+
| `prTemplate.screenshotsTable` | Include before/after screenshots table | `true` |
|
|
301
|
+
| `prReviewers` | Default PR reviewers (GitHub usernames) | — |
|
|
302
|
+
|
|
303
|
+
### Shareable Configs (`extends`)
|
|
304
|
+
|
|
305
|
+
Share a base configuration across projects using the `extends` field:
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"extends": "@myorg/devflow-config",
|
|
310
|
+
"ticketBaseUrl": "https://jira.myorg.com/browse"
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The `extends` value can be:
|
|
315
|
+
- An npm package name (resolved from `node_modules`)
|
|
316
|
+
- A relative file path (e.g., `"./config/devflow-base.json"`)
|
|
317
|
+
|
|
318
|
+
The extended config is merged with local overrides — local fields take precedence.
|
|
319
|
+
|
|
320
|
+
### Monorepo Awareness
|
|
321
|
+
|
|
322
|
+
devflow automatically detects monorepo workspace setups and uses workspace packages as commit scopes when no scopes are configured. Supported:
|
|
323
|
+
|
|
324
|
+
- **npm/yarn workspaces** — `workspaces` field in `package.json`
|
|
325
|
+
- **pnpm workspaces** — `pnpm-workspace.yaml`
|
|
326
|
+
- **Lerna** — `lerna.json`
|
|
327
|
+
- **Nx** — `nx.json` with `project.json` files
|
|
328
|
+
- **Turborepo** — `turbo.json` (uses package.json workspaces)
|
|
329
|
+
|
|
330
|
+
Each workspace package becomes a scope with its directory as the `paths` pattern for auto-inference. For example, in a monorepo with `packages/auth` and `packages/ui`, staging a file in `packages/auth/src/login.ts` auto-suggests the `auth` scope.
|
|
160
331
|
|
|
161
332
|
### Scopes
|
|
162
333
|
|
|
163
334
|
When `scopes` is an empty array, the commit command shows a free text input for scope. When populated, it shows a searchable list that can be filtered by typing.
|
|
164
335
|
|
|
165
|
-
|
|
336
|
+
**Scope inference** works in two ways (first match wins):
|
|
337
|
+
|
|
338
|
+
1. **From file paths** — if a scope has `paths` configured, staged files are matched against those glob patterns. The scope with the most matching files is suggested.
|
|
339
|
+
2. **From git history** — previous commits on the branch (`git log main..HEAD`) are parsed for existing scopes.
|
|
340
|
+
|
|
341
|
+
Example with paths:
|
|
342
|
+
```json
|
|
343
|
+
{
|
|
344
|
+
"scopes": [
|
|
345
|
+
{ "value": "auth", "description": "Authentication", "paths": ["src/auth/**", "src/hooks/useAuth*"] },
|
|
346
|
+
{ "value": "ui", "description": "UI components", "paths": ["src/components/**"] }
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
If you stage `src/auth/login.ts`, the `auth` scope is auto-suggested.
|
|
166
352
|
|
|
167
353
|
## Commitlint Integration
|
|
168
354
|
|
|
@@ -199,9 +385,25 @@ npx --no -- commitlint --edit $1 || {
|
|
|
199
385
|
}
|
|
200
386
|
```
|
|
201
387
|
|
|
388
|
+
The `devflow init` wizard can also set up a **pre-push** hook that runs lint and type checking before push:
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
# .husky/pre-push
|
|
392
|
+
npm run lint
|
|
393
|
+
npx tsc --noEmit
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## Update Notifications
|
|
397
|
+
|
|
398
|
+
devflow checks for newer versions on npm once every 24 hours and displays a non-blocking notification if an update is available:
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
─ Update available: 0.2.0 → 0.3.0 (npm update @alejandrochaves/devflow-cli) ─
|
|
402
|
+
```
|
|
403
|
+
|
|
202
404
|
## Requirements
|
|
203
405
|
|
|
204
|
-
- Node.js >=
|
|
406
|
+
- Node.js >= 20.12
|
|
205
407
|
- Git
|
|
206
408
|
- [GitHub CLI (gh)](https://cli.github.com/) — required for the `pr` command
|
|
207
409
|
|
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const bold: (text: string) => string;
|
|
2
|
+
export declare const dim: (text: string) => string;
|
|
3
|
+
export declare const green: (text: string) => string;
|
|
4
|
+
export declare const yellow: (text: string) => string;
|
|
5
|
+
export declare const red: (text: string) => string;
|
|
6
|
+
export declare const cyan: (text: string) => string;
|
|
7
|
+
export declare const gray: (text: string) => string;
|
|
8
|
+
export declare const magenta: (text: string) => string;
|
|
9
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,SAJD,MAAM,WAIS,CAAC;AAChC,eAAO,MAAM,GAAG,SALA,MAAM,WAKQ,CAAC;AAC/B,eAAO,MAAM,KAAK,SANF,MAAM,WAMW,CAAC;AAClC,eAAO,MAAM,MAAM,SAPH,MAAM,WAOY,CAAC;AACnC,eAAO,MAAM,GAAG,SARA,MAAM,WAQS,CAAC;AAChC,eAAO,MAAM,IAAI,SATD,MAAM,WASU,CAAC;AACjC,eAAO,MAAM,IAAI,SAVD,MAAM,WAUU,CAAC;AACjC,eAAO,MAAM,OAAO,SAXJ,MAAM,WAWa,CAAC"}
|
package/dist/colors.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const enabled = process.stdout.isTTY !== false;
|
|
2
|
+
function wrap(code, resetCode) {
|
|
3
|
+
return (text) => enabled ? `\x1b[${code}m${text}\x1b[${resetCode}m` : text;
|
|
4
|
+
}
|
|
5
|
+
export const bold = wrap(1, 22);
|
|
6
|
+
export const dim = wrap(2, 22);
|
|
7
|
+
export const green = wrap(32, 39);
|
|
8
|
+
export const yellow = wrap(33, 39);
|
|
9
|
+
export const red = wrap(31, 39);
|
|
10
|
+
export const cyan = wrap(36, 39);
|
|
11
|
+
export const gray = wrap(90, 39);
|
|
12
|
+
export const magenta = wrap(35, 39);
|
|
13
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC;AAE/C,SAAS,IAAI,CAAC,IAAY,EAAE,SAAiB;IAC3C,OAAO,CAAC,IAAY,EAAE,EAAE,CACtB,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,IAAI,QAAQ,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amend.d.ts","sourceRoot":"","sources":["../../src/commands/amend.ts"],"names":[],"mappings":"AA4CA,wBAAsB,YAAY,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA2HpF"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { confirm, input, select, search } from "@inquirer/prompts";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import { loadConfig } from "../config.js";
|
|
4
|
+
import { inferTicket } from "../git.js";
|
|
5
|
+
import { bold, dim, green, yellow, cyan } from "../colors.js";
|
|
6
|
+
function getLastCommitMessage() {
|
|
7
|
+
return execSync("git log -1 --format=%s", { encoding: "utf-8" }).trim();
|
|
8
|
+
}
|
|
9
|
+
function parseCommitMessage(msg, format) {
|
|
10
|
+
// Try to parse the default format: type[ticket]!(scope): message
|
|
11
|
+
const match = msg.match(/^(\w+)\[([^\]]*)\](!?)\(([^)]*)\): (.+)$/);
|
|
12
|
+
if (match) {
|
|
13
|
+
return {
|
|
14
|
+
type: match[1],
|
|
15
|
+
ticket: match[2],
|
|
16
|
+
breaking: match[3] === "!",
|
|
17
|
+
scope: match[4],
|
|
18
|
+
message: match[5],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// Try standard conventional commit: type(scope): message
|
|
22
|
+
const conventional = msg.match(/^(\w+)(!?)\(([^)]*)\): (.+)$/);
|
|
23
|
+
if (conventional) {
|
|
24
|
+
return {
|
|
25
|
+
type: conventional[1],
|
|
26
|
+
breaking: conventional[2] === "!",
|
|
27
|
+
scope: conventional[3],
|
|
28
|
+
message: conventional[4],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Fallback: treat whole thing as message
|
|
32
|
+
return { message: msg, breaking: false };
|
|
33
|
+
}
|
|
34
|
+
export async function amendCommand(options = {}) {
|
|
35
|
+
try {
|
|
36
|
+
const config = loadConfig();
|
|
37
|
+
const lastMessage = getLastCommitMessage();
|
|
38
|
+
const parsed = parseCommitMessage(lastMessage, config.commitFormat);
|
|
39
|
+
console.log(`\n${dim("Last commit:")} ${lastMessage}\n`);
|
|
40
|
+
const editMessage = await confirm({
|
|
41
|
+
message: "Edit commit message?",
|
|
42
|
+
default: true,
|
|
43
|
+
});
|
|
44
|
+
let newMessage = lastMessage;
|
|
45
|
+
if (editMessage) {
|
|
46
|
+
const type = await select({
|
|
47
|
+
message: "Select commit type:",
|
|
48
|
+
choices: config.commitTypes.map((t) => ({ value: t.value, name: t.label })),
|
|
49
|
+
default: parsed.type,
|
|
50
|
+
});
|
|
51
|
+
let finalScope;
|
|
52
|
+
if (config.scopes.length > 0) {
|
|
53
|
+
finalScope = await search({
|
|
54
|
+
message: parsed.scope
|
|
55
|
+
? `Select scope (current: ${cyan(parsed.scope)}):`
|
|
56
|
+
: "Select scope (type to filter):",
|
|
57
|
+
source: (term) => {
|
|
58
|
+
const filtered = config.scopes.filter((s) => !term ||
|
|
59
|
+
s.value.includes(term.toLowerCase()) ||
|
|
60
|
+
s.description.toLowerCase().includes(term.toLowerCase()));
|
|
61
|
+
if (parsed.scope) {
|
|
62
|
+
filtered.sort((a, b) => a.value === parsed.scope ? -1 : b.value === parsed.scope ? 1 : 0);
|
|
63
|
+
}
|
|
64
|
+
return filtered.map((s) => ({
|
|
65
|
+
value: s.value,
|
|
66
|
+
name: `${s.value} — ${s.description}`,
|
|
67
|
+
}));
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
finalScope = await input({
|
|
73
|
+
message: "Enter scope (optional):",
|
|
74
|
+
default: parsed.scope,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const message = await input({
|
|
78
|
+
message: "Enter commit message:",
|
|
79
|
+
default: parsed.message,
|
|
80
|
+
validate: (val) => val.trim().length > 0 || "Commit message is required",
|
|
81
|
+
});
|
|
82
|
+
const isBreaking = await confirm({
|
|
83
|
+
message: "Is this a breaking change?",
|
|
84
|
+
default: parsed.breaking,
|
|
85
|
+
});
|
|
86
|
+
const ticket = parsed.ticket || inferTicket();
|
|
87
|
+
const breaking = isBreaking ? "!" : "";
|
|
88
|
+
const scope = finalScope || "";
|
|
89
|
+
// Build using format
|
|
90
|
+
let result = config.commitFormat;
|
|
91
|
+
result = result.replace("{type}", type);
|
|
92
|
+
result = result.replace("{ticket}", ticket);
|
|
93
|
+
result = result.replace("{breaking}", breaking);
|
|
94
|
+
result = result.replace("{scope}", scope);
|
|
95
|
+
result = result.replace("{message}", message.trim());
|
|
96
|
+
result = result.replace(/\[\]/g, "");
|
|
97
|
+
result = result.replace(/\(\)/g, "");
|
|
98
|
+
newMessage = result;
|
|
99
|
+
}
|
|
100
|
+
// Check for additional staged changes
|
|
101
|
+
const staged = execSync("git diff --cached --name-only", { encoding: "utf-8" }).trim();
|
|
102
|
+
if (staged) {
|
|
103
|
+
console.log(dim("\nStaged changes will be included:"));
|
|
104
|
+
staged.split("\n").forEach((f) => console.log(dim(` ${f}`)));
|
|
105
|
+
}
|
|
106
|
+
console.log(`\n${dim("───")} ${bold("Amend Preview")} ${dim("───")}`);
|
|
107
|
+
console.log(`${dim("Before:")} ${yellow(lastMessage)}`);
|
|
108
|
+
console.log(`${dim("After:")} ${green(newMessage)}`);
|
|
109
|
+
if (staged) {
|
|
110
|
+
console.log(`${dim("Files:")} +${staged.split("\n").length} staged`);
|
|
111
|
+
}
|
|
112
|
+
console.log(`${dim("───────────────────")}\n`);
|
|
113
|
+
if (options.dryRun) {
|
|
114
|
+
console.log(dim("[dry-run] No amend performed."));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const confirmed = await confirm({
|
|
118
|
+
message: "Amend this commit?",
|
|
119
|
+
default: true,
|
|
120
|
+
});
|
|
121
|
+
if (!confirmed) {
|
|
122
|
+
console.log("Aborted.");
|
|
123
|
+
process.exit(0);
|
|
124
|
+
}
|
|
125
|
+
execSync(`git commit --amend -m ${JSON.stringify(newMessage)}`, {
|
|
126
|
+
stdio: "inherit",
|
|
127
|
+
});
|
|
128
|
+
console.log(green("✓ Commit amended successfully."));
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (error.name === "ExitPromptError") {
|
|
132
|
+
console.log("\nCancelled.");
|
|
133
|
+
process.exit(0);
|
|
134
|
+
}
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=amend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amend.js","sourceRoot":"","sources":["../../src/commands/amend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAc,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE9D,SAAS,oBAAoB;IAC3B,OAAO,QAAQ,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW,EAAE,MAAc;IAOrD,iEAAiE;IACjE,MAAM,KAA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,CAAC,QAAQ,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC,CAAC;YAClD,OAAO;QACT,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;YAC9B,OAAO,EAAE,oBAAoB;YAC7B,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,QAAQ,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE;YAC9D,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAAe,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/commands/branch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"branch.d.ts","sourceRoot":"","sources":["../../src/commands/branch.ts"],"names":[],"mappings":"AAMA,wBAAsB,aAAa,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiFrF"}
|
package/dist/commands/branch.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { select, input, confirm } from "@inquirer/prompts";
|
|
2
2
|
import { execSync } from "child_process";
|
|
3
3
|
import { loadConfig } from "../config.js";
|
|
4
|
-
|
|
4
|
+
import { bold, dim, green, cyan } from "../colors.js";
|
|
5
|
+
import { setTestPlan } from "../test-plan.js";
|
|
6
|
+
export async function branchCommand(options = {}) {
|
|
5
7
|
try {
|
|
6
8
|
const config = loadConfig();
|
|
7
9
|
const type = await select({
|
|
@@ -22,9 +24,13 @@ export async function branchCommand() {
|
|
|
22
24
|
.replace(/[^a-z0-9]+/g, "-")
|
|
23
25
|
.replace(/^-|-$/g, "");
|
|
24
26
|
const branchName = `${type}/${ticketPart}_${kebab}`;
|
|
25
|
-
console.log(`\n
|
|
26
|
-
console.log(branchName);
|
|
27
|
-
console.log(
|
|
27
|
+
console.log(`\n${dim("───")} ${bold("Branch Preview")} ${dim("───")}`);
|
|
28
|
+
console.log(cyan(branchName));
|
|
29
|
+
console.log(`${dim("───────────────────")}\n`);
|
|
30
|
+
if (options.dryRun) {
|
|
31
|
+
console.log(dim("[dry-run] No branch created."));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
28
34
|
const confirmed = await confirm({
|
|
29
35
|
message: "Create this branch?",
|
|
30
36
|
default: true,
|
|
@@ -34,7 +40,33 @@ export async function branchCommand() {
|
|
|
34
40
|
process.exit(0);
|
|
35
41
|
}
|
|
36
42
|
execSync(`git checkout -b ${branchName}`, { stdio: "inherit" });
|
|
37
|
-
console.log(
|
|
43
|
+
console.log(green(`✓ Branch created: ${branchName}`));
|
|
44
|
+
// Optional test plan
|
|
45
|
+
const addTestPlan = await confirm({
|
|
46
|
+
message: "Add test plan steps for this branch?",
|
|
47
|
+
default: false,
|
|
48
|
+
});
|
|
49
|
+
if (addTestPlan) {
|
|
50
|
+
const steps = [];
|
|
51
|
+
console.log(dim("\nAdd testing steps one at a time. Press Enter with empty text to finish.\n"));
|
|
52
|
+
let adding = true;
|
|
53
|
+
while (adding) {
|
|
54
|
+
const step = await input({
|
|
55
|
+
message: `Step ${steps.length + 1}${steps.length > 0 ? " (blank to finish)" : ""}:`,
|
|
56
|
+
});
|
|
57
|
+
if (!step.trim()) {
|
|
58
|
+
adding = false;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
steps.push(step.trim());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (steps.length > 0) {
|
|
65
|
+
setTestPlan(branchName, steps);
|
|
66
|
+
console.log(green(`✓ Saved ${steps.length} test plan step${steps.length > 1 ? "s" : ""}`));
|
|
67
|
+
console.log(dim(" Edit later with: devflow test-plan"));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
38
70
|
}
|
|
39
71
|
catch (error) {
|
|
40
72
|
if (error.name === "ExitPromptError") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/commands/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../src/commands/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cA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