@alejandrochaves/devflow-cli 0.1.0 → 0.1.1
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 +210 -0
- package/package.json +12 -3
package/README.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# @alejandrochaves/devflow-cli
|
|
2
|
+
|
|
3
|
+
Interactive CLI for branch creation, conventional commits, and PR management.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @alejandrochaves/devflow-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Initialize config in your project
|
|
15
|
+
npx devflow init
|
|
16
|
+
|
|
17
|
+
# Create a branch
|
|
18
|
+
npx devflow branch
|
|
19
|
+
|
|
20
|
+
# Stage files and commit
|
|
21
|
+
npx devflow commit
|
|
22
|
+
|
|
23
|
+
# Create or update a PR
|
|
24
|
+
npx devflow pr
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or add scripts to your `package.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"scripts": {
|
|
32
|
+
"branch": "devflow branch",
|
|
33
|
+
"commit": "devflow commit",
|
|
34
|
+
"pr": "devflow pr"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
### `devflow init`
|
|
42
|
+
|
|
43
|
+
Generates a `.devflow.json` config file in your project root. Prompts for your ticket base URL and creates a starter config with default scopes and checklist items.
|
|
44
|
+
|
|
45
|
+
### `devflow branch`
|
|
46
|
+
|
|
47
|
+
Interactive branch creation with consistent naming.
|
|
48
|
+
|
|
49
|
+
**Flow:**
|
|
50
|
+
1. Select branch type (feat, fix, chore, refactor, docs, test, release, hotfix)
|
|
51
|
+
2. Enter ticket number (or leave blank for `UNTRACKED`)
|
|
52
|
+
3. Enter short description (auto-kebab-cased)
|
|
53
|
+
4. Preview and confirm
|
|
54
|
+
|
|
55
|
+
**Branch format:**
|
|
56
|
+
```
|
|
57
|
+
type/TICKET_description
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Examples:**
|
|
61
|
+
```
|
|
62
|
+
feat/ENV-123_add-budget-sharing
|
|
63
|
+
fix/PROJ-45_correct-calculation-overflow
|
|
64
|
+
chore/UNTRACKED_update-dependencies
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `devflow commit`
|
|
68
|
+
|
|
69
|
+
Interactive conventional commit with file staging, scope selection, and ticket inference.
|
|
70
|
+
|
|
71
|
+
**Flow:**
|
|
72
|
+
1. If no files are staged, select files to stage (checkbox selection)
|
|
73
|
+
2. Select commit type
|
|
74
|
+
3. Select or enter scope (searchable list if configured, free text otherwise)
|
|
75
|
+
4. Enter commit message
|
|
76
|
+
5. Confirm if breaking change
|
|
77
|
+
6. Preview and confirm
|
|
78
|
+
|
|
79
|
+
**Commit format:**
|
|
80
|
+
```
|
|
81
|
+
type[ticket](scope): message
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The ticket is automatically inferred from the branch name. If the branch doesn't follow the `type/TICKET_description` format, it defaults to `UNTRACKED`.
|
|
85
|
+
|
|
86
|
+
**Examples:**
|
|
87
|
+
```
|
|
88
|
+
feat[ENV-123](auth): add biometric login
|
|
89
|
+
fix[PROJ-45](budget): correct calculation overflow
|
|
90
|
+
chore[UNTRACKED](deps): update dependencies
|
|
91
|
+
refactor[ENV-200]!(api): restructure endpoints
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The `!` after the ticket indicates a breaking change.
|
|
95
|
+
|
|
96
|
+
### `devflow pr`
|
|
97
|
+
|
|
98
|
+
Create or update a pull request with an auto-filled template.
|
|
99
|
+
|
|
100
|
+
**Flow:**
|
|
101
|
+
1. Checks if a PR already exists for the current branch (offers to update)
|
|
102
|
+
2. Infers the base branch (closest remote branch by merge-base)
|
|
103
|
+
3. Enter PR title (pre-filled from branch description)
|
|
104
|
+
4. Enter optional summary
|
|
105
|
+
5. Preview PR body with template
|
|
106
|
+
6. Confirm and create/update
|
|
107
|
+
|
|
108
|
+
**Features:**
|
|
109
|
+
- Auto-detects existing PRs and offers update flow
|
|
110
|
+
- Infers base branch using `git merge-base` comparison
|
|
111
|
+
- Pre-fills commit list in the summary
|
|
112
|
+
- Auto-labels from branch type (feat → `feature`, fix → `bug`, etc.)
|
|
113
|
+
- Auto-labels from commit scopes
|
|
114
|
+
- Self-assigns with `@me`
|
|
115
|
+
- Creates as draft by default
|
|
116
|
+
- Links ticket if `ticketBaseUrl` is configured
|
|
117
|
+
|
|
118
|
+
**PR template includes:**
|
|
119
|
+
- Summary (with commit list)
|
|
120
|
+
- Ticket (linked if base URL configured)
|
|
121
|
+
- Type of Change (checkboxes, auto-checked from branch type)
|
|
122
|
+
- Screenshots table
|
|
123
|
+
- Test Plan
|
|
124
|
+
- Checklist (customizable via config)
|
|
125
|
+
|
|
126
|
+
## Configuration
|
|
127
|
+
|
|
128
|
+
Create a `.devflow.json` in your project root (or run `devflow init`):
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"ticketBaseUrl": "https://github.com/org/repo/issues",
|
|
133
|
+
"scopes": [
|
|
134
|
+
{ "value": "auth", "description": "Authentication & login" },
|
|
135
|
+
{ "value": "ui", "description": "UI components" },
|
|
136
|
+
{ "value": "api", "description": "API layer" }
|
|
137
|
+
],
|
|
138
|
+
"branchTypes": ["feat", "fix", "chore", "refactor", "docs", "test", "release", "hotfix"],
|
|
139
|
+
"commitTypes": [
|
|
140
|
+
{ "value": "feat", "label": "feat: A new feature" },
|
|
141
|
+
{ "value": "fix", "label": "fix: A bug fix" }
|
|
142
|
+
],
|
|
143
|
+
"checklist": [
|
|
144
|
+
"Code follows project conventions",
|
|
145
|
+
"Self-reviewed the changes",
|
|
146
|
+
"No new warnings or errors introduced"
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Config Options
|
|
152
|
+
|
|
153
|
+
| Option | Description | Default |
|
|
154
|
+
|--------|-------------|---------|
|
|
155
|
+
| `ticketBaseUrl` | Base URL for linking tickets in PRs (e.g., `https://github.com/org/repo/issues`) | — |
|
|
156
|
+
| `scopes` | List of scopes with `value` and `description`. Enables searchable selection in commit command. | `[]` (free text input) |
|
|
157
|
+
| `branchTypes` | Allowed branch type prefixes. | `["feat", "fix", "chore", "refactor", "docs", "test", "release", "hotfix"]` |
|
|
158
|
+
| `commitTypes` | Commit types shown in the selection menu. Each has `value` and `label`. | Standard conventional commit types |
|
|
159
|
+
| `checklist` | PR checklist items added to the template. | Basic code review items |
|
|
160
|
+
|
|
161
|
+
### Scopes
|
|
162
|
+
|
|
163
|
+
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
|
+
|
|
165
|
+
The commit command also infers the scope from previous commits on the branch (`git log main..HEAD`) and pre-selects it as the default.
|
|
166
|
+
|
|
167
|
+
## Commitlint Integration
|
|
168
|
+
|
|
169
|
+
If you use [commitlint](https://commitlint.js.org/) to enforce commit conventions, add this parser preset to handle the `type[ticket](scope): message` format:
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
// commitlint.config.js
|
|
173
|
+
module.exports = {
|
|
174
|
+
extends: ['@commitlint/config-conventional'],
|
|
175
|
+
parserPreset: {
|
|
176
|
+
parserOpts: {
|
|
177
|
+
headerPattern: /^(\w+)\[.*?\]!?\((.+)\): (.+)$/,
|
|
178
|
+
headerCorrespondence: ['type', 'scope', 'subject'],
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
rules: {
|
|
182
|
+
'subject-case': [0],
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Git Hooks
|
|
188
|
+
|
|
189
|
+
Pair with [husky](https://typicode.github.io/husky/) for a guided commit experience:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# .husky/commit-msg
|
|
193
|
+
npx --no -- commitlint --edit $1 || {
|
|
194
|
+
echo ""
|
|
195
|
+
echo " Commit message does not follow the required format."
|
|
196
|
+
echo " Use: npm run commit"
|
|
197
|
+
echo ""
|
|
198
|
+
exit 1
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Requirements
|
|
203
|
+
|
|
204
|
+
- Node.js >= 18
|
|
205
|
+
- Git
|
|
206
|
+
- [GitHub CLI (gh)](https://cli.github.com/) — required for the `pr` command
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alejandrochaves/devflow-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Interactive CLI for branch creation, conventional commits, and PR management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -12,9 +12,18 @@
|
|
|
12
12
|
"publish:public": "npm publish --access=public",
|
|
13
13
|
"prepublishOnly": "npm run build"
|
|
14
14
|
},
|
|
15
|
-
"keywords": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cli",
|
|
17
|
+
"git",
|
|
18
|
+
"commits",
|
|
19
|
+
"conventional-commits",
|
|
20
|
+
"branch",
|
|
21
|
+
"pull-request"
|
|
22
|
+
],
|
|
16
23
|
"license": "MIT",
|
|
17
|
-
"files": [
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
18
27
|
"engines": {
|
|
19
28
|
"node": ">=18"
|
|
20
29
|
},
|