@alejandrochaves/devflow-cli 1.7.0 → 1.9.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 +9 -3
- package/dist/cli-runner.d.ts +1 -0
- package/dist/cli-runner.js +17 -0
- package/dist/colors.d.ts +0 -1
- package/dist/colors.js +0 -1
- package/dist/commands/amend.d.ts +0 -1
- package/dist/commands/amend.js +7 -7
- package/dist/commands/branch.d.ts +0 -1
- package/dist/commands/branch.js +9 -6
- package/dist/commands/changelog.d.ts +0 -1
- package/dist/commands/changelog.js +9 -5
- package/dist/commands/cleanup.d.ts +0 -1
- package/dist/commands/cleanup.js +9 -8
- package/dist/commands/comments.d.ts +0 -1
- package/dist/commands/comments.js +10 -6
- package/dist/commands/commit.d.ts +0 -1
- package/dist/commands/commit.js +14 -14
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/doctor.js +8 -9
- package/dist/commands/fixup.d.ts +0 -1
- package/dist/commands/fixup.js +20 -17
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +69 -22
- package/dist/commands/issue.d.ts +0 -1
- package/dist/commands/issue.js +9 -27
- package/dist/commands/issues.d.ts +0 -1
- package/dist/commands/issues.js +2 -3
- package/dist/commands/lint-config.d.ts +0 -1
- package/dist/commands/lint-config.js +0 -1
- package/dist/commands/log.d.ts +0 -1
- package/dist/commands/log.js +12 -10
- package/dist/commands/merge.d.ts +0 -1
- package/dist/commands/merge.js +10 -11
- package/dist/commands/pr.d.ts +0 -1
- package/dist/commands/pr.js +85 -31
- package/dist/commands/release.d.ts +0 -1
- package/dist/commands/release.js +14 -11
- package/dist/commands/review.d.ts +0 -1
- package/dist/commands/review.js +9 -12
- package/dist/commands/stash.d.ts +1 -1
- package/dist/commands/stash.js +31 -17
- package/dist/commands/stats.d.ts +0 -1
- package/dist/commands/stats.js +6 -8
- package/dist/commands/status.d.ts +0 -1
- package/dist/commands/status.js +9 -7
- package/dist/commands/test-plan.d.ts +0 -1
- package/dist/commands/test-plan.js +0 -1
- package/dist/commands/undo.d.ts +0 -1
- package/dist/commands/undo.js +9 -10
- package/dist/commands/update.d.ts +0 -1
- package/dist/commands/update.js +71 -1
- package/dist/commands/worktree.d.ts +1 -1
- package/dist/commands/worktree.js +35 -26
- package/dist/config.d.ts +1 -2
- package/dist/config.js +34 -2
- package/dist/devflow-version.d.ts +1 -1
- package/dist/devflow-version.js +1 -1
- package/dist/git.d.ts +11 -1
- package/dist/git.js +82 -10
- package/dist/index.d.ts +0 -1
- package/dist/index.js +32 -27
- package/dist/monorepo.d.ts +0 -1
- package/dist/monorepo.js +0 -1
- package/dist/output.d.ts +3 -0
- package/dist/output.js +13 -0
- package/dist/plugins.d.ts +8 -1
- package/dist/plugins.js +222 -18
- package/dist/prompts.d.ts +0 -1
- package/dist/prompts.js +0 -1
- package/dist/providers/projects.d.ts +0 -1
- package/dist/providers/projects.js +5 -12
- package/dist/providers/tickets.d.ts +0 -1
- package/dist/providers/tickets.js +6 -7
- package/dist/test-plan.d.ts +0 -1
- package/dist/test-plan.js +0 -1
- package/dist/update-notifier.d.ts +0 -1
- package/dist/update-notifier.js +43 -28
- package/package.json +1 -1
- package/dist/colors.d.ts.map +0 -1
- package/dist/colors.js.map +0 -1
- package/dist/commands/amend.d.ts.map +0 -1
- package/dist/commands/amend.js.map +0 -1
- package/dist/commands/branch.d.ts.map +0 -1
- package/dist/commands/branch.js.map +0 -1
- package/dist/commands/changelog.d.ts.map +0 -1
- package/dist/commands/changelog.js.map +0 -1
- package/dist/commands/cleanup.d.ts.map +0 -1
- package/dist/commands/cleanup.js.map +0 -1
- package/dist/commands/comments.d.ts.map +0 -1
- package/dist/commands/comments.js.map +0 -1
- package/dist/commands/commit.d.ts.map +0 -1
- package/dist/commands/commit.js.map +0 -1
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/fixup.d.ts.map +0 -1
- package/dist/commands/fixup.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/issue.d.ts.map +0 -1
- package/dist/commands/issue.js.map +0 -1
- package/dist/commands/issues.d.ts.map +0 -1
- package/dist/commands/issues.js.map +0 -1
- package/dist/commands/lint-config.d.ts.map +0 -1
- package/dist/commands/lint-config.js.map +0 -1
- package/dist/commands/log.d.ts.map +0 -1
- package/dist/commands/log.js.map +0 -1
- package/dist/commands/merge.d.ts.map +0 -1
- package/dist/commands/merge.js.map +0 -1
- package/dist/commands/pr.d.ts.map +0 -1
- package/dist/commands/pr.js.map +0 -1
- package/dist/commands/release.d.ts.map +0 -1
- package/dist/commands/release.js.map +0 -1
- package/dist/commands/review.d.ts.map +0 -1
- package/dist/commands/review.js.map +0 -1
- package/dist/commands/stash.d.ts.map +0 -1
- package/dist/commands/stash.js.map +0 -1
- package/dist/commands/stats.d.ts.map +0 -1
- package/dist/commands/stats.js.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/test-plan.d.ts.map +0 -1
- package/dist/commands/test-plan.js.map +0 -1
- package/dist/commands/undo.d.ts.map +0 -1
- package/dist/commands/undo.js.map +0 -1
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/worktree.d.ts.map +0 -1
- package/dist/commands/worktree.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/devflow-version.d.ts.map +0 -1
- package/dist/devflow-version.js.map +0 -1
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/monorepo.d.ts.map +0 -1
- package/dist/monorepo.js.map +0 -1
- package/dist/plugins.d.ts.map +0 -1
- package/dist/plugins.js.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/providers/projects.d.ts.map +0 -1
- package/dist/providers/projects.js.map +0 -1
- package/dist/providers/tickets.d.ts.map +0 -1
- package/dist/providers/tickets.js.map +0 -1
- package/dist/test-plan.d.ts.map +0 -1
- package/dist/test-plan.js.map +0 -1
- package/dist/update-notifier.d.ts.map +0 -1
- package/dist/update-notifier.js.map +0 -1
package/dist/commands/release.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
3
3
|
import { resolve } from "path";
|
|
4
4
|
import { bold, dim, green, cyan } from "../colors.js";
|
|
5
|
-
import { checkGhInstalled } from "../git.js";
|
|
5
|
+
import { checkGhInstalled, isOptionLike, resolveCommit } from "../git.js";
|
|
6
6
|
import { selectWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
|
|
7
7
|
function getCurrentVersion(cwd) {
|
|
8
8
|
const pkgPath = resolve(cwd, "package.json");
|
|
@@ -11,19 +11,23 @@ function getCurrentVersion(cwd) {
|
|
|
11
11
|
}
|
|
12
12
|
function getLastTag() {
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
const tag = execFileSync("git", ["describe", "--tags", "--abbrev=0"], {
|
|
15
15
|
encoding: "utf-8",
|
|
16
16
|
stdio: ["pipe", "pipe", "ignore"],
|
|
17
17
|
}).trim();
|
|
18
|
+
return isOptionLike(tag) ? undefined : tag;
|
|
18
19
|
}
|
|
19
20
|
catch {
|
|
20
21
|
return undefined;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
function getCommitsSinceTag(tag) {
|
|
24
|
-
const
|
|
25
|
+
const tagId = tag ? resolveCommit(tag) : undefined;
|
|
26
|
+
if (tag && !tagId)
|
|
27
|
+
return [];
|
|
28
|
+
const range = tagId ? `${tagId}..HEAD` : "HEAD";
|
|
25
29
|
try {
|
|
26
|
-
const log =
|
|
30
|
+
const log = execFileSync("git", ["log", range, "--pretty=format:%H %s"], {
|
|
27
31
|
encoding: "utf-8",
|
|
28
32
|
}).trim();
|
|
29
33
|
if (!log)
|
|
@@ -216,14 +220,14 @@ export async function releaseCommand(options = {}) {
|
|
|
216
220
|
updateChangelog(cwd, newVersion, notes);
|
|
217
221
|
console.log(green("✓ Updated CHANGELOG.md"));
|
|
218
222
|
// 3. Commit
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
execFileSync("git", ["add", "package.json", "CHANGELOG.md"], { stdio: "ignore" });
|
|
224
|
+
execFileSync("git", ["commit", "-m", newVersion], { stdio: "ignore" });
|
|
221
225
|
console.log(green("✓ Created release commit"));
|
|
222
226
|
// 4. Tag
|
|
223
|
-
|
|
227
|
+
execFileSync("git", ["tag", `v${newVersion}`], { stdio: "ignore" });
|
|
224
228
|
console.log(green(`✓ Tagged v${newVersion}`));
|
|
225
229
|
// 5. Push
|
|
226
|
-
|
|
230
|
+
execFileSync("git", ["push", "origin", "HEAD", "--tags"], { stdio: "inherit" });
|
|
227
231
|
console.log(green("✓ Pushed to remote"));
|
|
228
232
|
// 6. Create GitHub release (auto-create with --yes)
|
|
229
233
|
const createReleaseResult = options.yes || await confirmWithBack({
|
|
@@ -233,7 +237,7 @@ export async function releaseCommand(options = {}) {
|
|
|
233
237
|
});
|
|
234
238
|
const createRelease = createReleaseResult === true;
|
|
235
239
|
if (createRelease) {
|
|
236
|
-
|
|
240
|
+
execFileSync("gh", ["release", "create", `v${newVersion}`, `--title=v${newVersion}`, "--notes-file", "-"], { input: notes, stdio: ["pipe", "inherit", "inherit"] });
|
|
237
241
|
console.log(green(`\n✓ Released v${newVersion}`));
|
|
238
242
|
console.log(dim(" npm publish will be triggered by the publish workflow."));
|
|
239
243
|
}
|
|
@@ -246,4 +250,3 @@ export async function releaseCommand(options = {}) {
|
|
|
246
250
|
process.exit(1);
|
|
247
251
|
}
|
|
248
252
|
}
|
|
249
|
-
//# sourceMappingURL=release.js.map
|
package/dist/commands/review.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, green, cyan, yellow } from "../colors.js";
|
|
3
3
|
import { checkGhInstalled } from "../git.js";
|
|
4
4
|
import { selectWithBack, inputWithBack, BACK_VALUE, } from "../prompts.js";
|
|
5
5
|
function listOpenPrs() {
|
|
6
6
|
try {
|
|
7
|
-
const result =
|
|
7
|
+
const result = execFileSync("gh", ["pr", "list", "--state", "open", "--json", "number,title,headRefName,author,additions,deletions,reviewDecision"], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
|
|
8
8
|
return JSON.parse(result);
|
|
9
9
|
}
|
|
10
10
|
catch {
|
|
@@ -13,7 +13,7 @@ function listOpenPrs() {
|
|
|
13
13
|
}
|
|
14
14
|
function getPrDiffStat(number) {
|
|
15
15
|
try {
|
|
16
|
-
return
|
|
16
|
+
return execFileSync("gh", ["pr", "diff", String(number), "--stat"], {
|
|
17
17
|
encoding: "utf-8",
|
|
18
18
|
stdio: ["pipe", "pipe", "ignore"],
|
|
19
19
|
}).trim();
|
|
@@ -112,7 +112,7 @@ export async function reviewCommand(options = {}) {
|
|
|
112
112
|
const pr = prs.find((p) => p.number === prNumber);
|
|
113
113
|
switch (selectedAction) {
|
|
114
114
|
case "checkout":
|
|
115
|
-
|
|
115
|
+
execFileSync("gh", ["pr", "checkout", String(pr.number)], { stdio: "inherit" });
|
|
116
116
|
console.log(green(`✓ Checked out ${pr.headRefName}`));
|
|
117
117
|
currentStep = "done";
|
|
118
118
|
break;
|
|
@@ -126,10 +126,8 @@ export async function reviewCommand(options = {}) {
|
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
const approveBody = approveBodyResult;
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
: "";
|
|
132
|
-
execSync(`gh pr review ${pr.number} --approve ${approveFlag}`, { stdio: "inherit" });
|
|
129
|
+
const approveArgs = approveBody.trim() ? [`--body=${approveBody.trim()}`] : [];
|
|
130
|
+
execFileSync("gh", ["pr", "review", String(pr.number), "--approve", ...approveArgs], { stdio: "inherit" });
|
|
133
131
|
console.log(green(`✓ Approved #${pr.number}`));
|
|
134
132
|
currentStep = "done";
|
|
135
133
|
break;
|
|
@@ -149,7 +147,7 @@ export async function reviewCommand(options = {}) {
|
|
|
149
147
|
console.error("Comment is required.");
|
|
150
148
|
process.exit(1);
|
|
151
149
|
}
|
|
152
|
-
|
|
150
|
+
execFileSync("gh", ["pr", "comment", String(pr.number), `--body=${comment.trim()}`], {
|
|
153
151
|
stdio: "inherit",
|
|
154
152
|
});
|
|
155
153
|
console.log(green("✓ Comment added"));
|
|
@@ -171,13 +169,13 @@ export async function reviewCommand(options = {}) {
|
|
|
171
169
|
console.error("Description is required.");
|
|
172
170
|
process.exit(1);
|
|
173
171
|
}
|
|
174
|
-
|
|
172
|
+
execFileSync("gh", ["pr", "review", String(pr.number), "--request-changes", `--body=${changesBody.trim()}`], { stdio: "inherit" });
|
|
175
173
|
console.log(yellow(`✓ Requested changes on #${pr.number}`));
|
|
176
174
|
currentStep = "done";
|
|
177
175
|
break;
|
|
178
176
|
}
|
|
179
177
|
case "view":
|
|
180
|
-
|
|
178
|
+
execFileSync("gh", ["pr", "view", String(pr.number), "--web"], { stdio: "inherit" });
|
|
181
179
|
currentStep = "done";
|
|
182
180
|
break;
|
|
183
181
|
default:
|
|
@@ -198,4 +196,3 @@ export async function reviewCommand(options = {}) {
|
|
|
198
196
|
process.exit(1);
|
|
199
197
|
}
|
|
200
198
|
}
|
|
201
|
-
//# sourceMappingURL=review.js.map
|
package/dist/commands/stash.d.ts
CHANGED
package/dist/commands/stash.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { select } from "@inquirer/prompts";
|
|
2
|
-
import {
|
|
2
|
+
import { execFileSync } from "child_process";
|
|
3
3
|
import { bold, dim, green, yellow } from "../colors.js";
|
|
4
4
|
import { getBranch } from "../git.js";
|
|
5
5
|
import { selectWithBack, inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
|
|
6
6
|
function listStashes() {
|
|
7
7
|
try {
|
|
8
|
-
const result =
|
|
8
|
+
const result = execFileSync("git", ["stash", "list"], { encoding: "utf-8" }).trim();
|
|
9
9
|
if (!result)
|
|
10
10
|
return [];
|
|
11
11
|
return result.split("\n").map((line, i) => {
|
|
@@ -22,7 +22,7 @@ function listStashes() {
|
|
|
22
22
|
}
|
|
23
23
|
function hasChanges() {
|
|
24
24
|
try {
|
|
25
|
-
const status =
|
|
25
|
+
const status = execFileSync("git", ["status", "--porcelain"], { encoding: "utf-8" }).trim();
|
|
26
26
|
return status.length > 0;
|
|
27
27
|
}
|
|
28
28
|
catch {
|
|
@@ -120,11 +120,16 @@ export async function stashCommand(options = {}) {
|
|
|
120
120
|
}
|
|
121
121
|
includeUntracked = untrackedResult === true;
|
|
122
122
|
}
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
123
|
+
const untrackedArgs = includeUntracked ? ["--include-untracked"] : [];
|
|
124
|
+
if (options.dryRun) {
|
|
125
|
+
console.log(dim(`[dry-run] Would stash with message: ${stashMessage}${includeUntracked ? " (incl. untracked)" : ""}`));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
execFileSync("git", ["stash", "push", "-m", stashMessage, ...untrackedArgs], {
|
|
129
|
+
stdio: "inherit",
|
|
130
|
+
});
|
|
131
|
+
console.log(green(`✓ Stashed: ${stashMessage}`));
|
|
132
|
+
}
|
|
128
133
|
currentStep = "done";
|
|
129
134
|
break;
|
|
130
135
|
}
|
|
@@ -141,12 +146,17 @@ export async function stashCommand(options = {}) {
|
|
|
141
146
|
}
|
|
142
147
|
stashTarget = target;
|
|
143
148
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
console.log(green(`✓ ${selectedAction === "pop" ? "Popped" : "Applied"} stash@{${stashTarget}}`));
|
|
149
|
+
if (options.dryRun) {
|
|
150
|
+
console.log(dim(`[dry-run] Would ${selectedAction} stash@{${stashTarget}}`));
|
|
147
151
|
}
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
else {
|
|
153
|
+
try {
|
|
154
|
+
execFileSync("git", ["stash", selectedAction, `stash@{${stashTarget}}`], { stdio: "inherit" });
|
|
155
|
+
console.log(green(`✓ ${selectedAction === "pop" ? "Popped" : "Applied"} stash@{${stashTarget}}`));
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
console.log(yellow("⚠ Stash could not be applied cleanly. Resolve conflicts manually."));
|
|
159
|
+
}
|
|
150
160
|
}
|
|
151
161
|
currentStep = "done";
|
|
152
162
|
break;
|
|
@@ -173,8 +183,13 @@ export async function stashCommand(options = {}) {
|
|
|
173
183
|
break;
|
|
174
184
|
}
|
|
175
185
|
if (confirmed === true) {
|
|
176
|
-
|
|
177
|
-
|
|
186
|
+
if (options.dryRun) {
|
|
187
|
+
console.log(dim(`[dry-run] Would drop stash@{${stashTarget}}`));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
execFileSync("git", ["stash", "drop", `stash@{${stashTarget}}`], { stdio: "ignore" });
|
|
191
|
+
console.log(green(`✓ Dropped stash@{${stashTarget}}`));
|
|
192
|
+
}
|
|
178
193
|
}
|
|
179
194
|
currentStep = "done";
|
|
180
195
|
break;
|
|
@@ -191,7 +206,7 @@ export async function stashCommand(options = {}) {
|
|
|
191
206
|
}
|
|
192
207
|
stashTarget = target;
|
|
193
208
|
}
|
|
194
|
-
const diff =
|
|
209
|
+
const diff = execFileSync("git", ["stash", "show", "-p", `stash@{${stashTarget}}`], { encoding: "utf-8" });
|
|
195
210
|
console.log(diff);
|
|
196
211
|
currentStep = "done";
|
|
197
212
|
break;
|
|
@@ -233,4 +248,3 @@ async function selectStashWithBack(stashes, message, showBack) {
|
|
|
233
248
|
showBack,
|
|
234
249
|
});
|
|
235
250
|
}
|
|
236
|
-
//# sourceMappingURL=stash.js.map
|
package/dist/commands/stats.d.ts
CHANGED
package/dist/commands/stats.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, cyan } from "../colors.js";
|
|
3
3
|
function getCommitStats(limit = 100) {
|
|
4
4
|
try {
|
|
5
|
-
const result =
|
|
5
|
+
const result = execFileSync("git", ["log", "--pretty=format:%s|%an", `-${limit}`], { encoding: "utf-8" }).trim();
|
|
6
6
|
if (!result)
|
|
7
7
|
return [];
|
|
8
8
|
return result.split("\n").map((line) => {
|
|
@@ -79,12 +79,11 @@ export function statsCommand() {
|
|
|
79
79
|
// Activity
|
|
80
80
|
console.log("");
|
|
81
81
|
try {
|
|
82
|
-
const firstCommit =
|
|
82
|
+
const firstCommit = execFileSync("git", ["log", "--reverse", "--format=%ar"], {
|
|
83
83
|
encoding: "utf-8",
|
|
84
|
-
|
|
85
|
-
}).trim();
|
|
86
|
-
const
|
|
87
|
-
const branches = execSync("git branch | wc -l", { encoding: "utf-8", shell: "/bin/bash" }).trim();
|
|
84
|
+
}).split("\n")[0].trim();
|
|
85
|
+
const totalCommits = execFileSync("git", ["rev-list", "--count", "HEAD"], { encoding: "utf-8" }).trim();
|
|
86
|
+
const branches = String(execFileSync("git", ["branch", "--format=%(refname)"], { encoding: "utf-8" }).split("\n").filter(Boolean).length);
|
|
88
87
|
console.log(bold(" Summary"));
|
|
89
88
|
console.log(` ${dim("Total commits:")} ${cyan(totalCommits)}`);
|
|
90
89
|
console.log(` ${dim("Local branches:")} ${cyan(branches.trim())}`);
|
|
@@ -95,4 +94,3 @@ export function statsCommand() {
|
|
|
95
94
|
}
|
|
96
95
|
console.log("");
|
|
97
96
|
}
|
|
98
|
-
//# sourceMappingURL=stats.js.map
|
package/dist/commands/status.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { loadConfig } from "../config.js";
|
|
3
3
|
import { bold, dim, cyan, green, yellow, gray } from "../colors.js";
|
|
4
|
-
import { getBranch, parseBranch, getDefaultBase, getCommits } from "../git.js";
|
|
4
|
+
import { getBranch, parseBranch, getDefaultBase, getCommits, isGhInstalled } from "../git.js";
|
|
5
5
|
function getPrInfo() {
|
|
6
6
|
try {
|
|
7
|
-
const result =
|
|
7
|
+
const result = execFileSync("gh", ["pr", "view", "--json", "url,number,state"], {
|
|
8
8
|
encoding: "utf-8",
|
|
9
9
|
stdio: ["pipe", "pipe", "ignore"],
|
|
10
10
|
}).trim();
|
|
@@ -15,9 +15,9 @@ function getPrInfo() {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
function getUncommittedCount() {
|
|
18
|
-
const staged =
|
|
19
|
-
const unstaged =
|
|
20
|
-
const untracked =
|
|
18
|
+
const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
|
|
19
|
+
const unstaged = execFileSync("git", ["diff", "--name-only"], { encoding: "utf-8" }).trim();
|
|
20
|
+
const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf-8" }).trim();
|
|
21
21
|
return {
|
|
22
22
|
staged: staged ? staged.split("\n").length : 0,
|
|
23
23
|
unstaged: unstaged ? unstaged.split("\n").length : 0,
|
|
@@ -71,6 +71,9 @@ export async function statusCommand() {
|
|
|
71
71
|
const stateColor = pr.state === "OPEN" ? green : pr.state === "MERGED" ? cyan : gray;
|
|
72
72
|
console.log(`\n${dim("PR:")} ${stateColor(`#${pr.number} (${pr.state.toLowerCase()})`)} ${dim(pr.url)}`);
|
|
73
73
|
}
|
|
74
|
+
else if (!isGhInstalled()) {
|
|
75
|
+
console.log(`\n${dim("PR:")} ${gray("gh not installed — install with: brew install gh")}`);
|
|
76
|
+
}
|
|
74
77
|
else {
|
|
75
78
|
console.log(`\n${dim("PR:")} ${gray("none")}`);
|
|
76
79
|
}
|
|
@@ -80,4 +83,3 @@ export async function statusCommand() {
|
|
|
80
83
|
}
|
|
81
84
|
console.log("");
|
|
82
85
|
}
|
|
83
|
-
//# sourceMappingURL=status.js.map
|
package/dist/commands/undo.d.ts
CHANGED
package/dist/commands/undo.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { execSync } from "child_process";
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
3
2
|
import { bold, dim, green, yellow } from "../colors.js";
|
|
3
|
+
import { confirmWithBack } from "../prompts.js";
|
|
4
4
|
export async function undoCommand(options = {}) {
|
|
5
5
|
try {
|
|
6
6
|
// Check if there are commits to undo
|
|
7
7
|
try {
|
|
8
|
-
|
|
8
|
+
execFileSync("git", ["log", "-1", "--format=%H"], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] });
|
|
9
9
|
}
|
|
10
10
|
catch {
|
|
11
11
|
console.log("No commits to undo.");
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
const lastMessage =
|
|
15
|
-
const lastFiles =
|
|
14
|
+
const lastMessage = execFileSync("git", ["log", "-1", "--format=%s"], { encoding: "utf-8" }).trim();
|
|
15
|
+
const lastFiles = execFileSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"], { encoding: "utf-8" }).trim();
|
|
16
16
|
console.log(`\n${dim("───")} ${bold("Undo Last Commit")} ${dim("───")}\n`);
|
|
17
17
|
console.log(`${dim("Message:")} ${yellow(lastMessage)}`);
|
|
18
18
|
if (lastFiles) {
|
|
@@ -24,18 +24,18 @@ export async function undoCommand(options = {}) {
|
|
|
24
24
|
console.log(dim("[dry-run] No undo performed."));
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
// Confirm (skip if --yes)
|
|
28
27
|
if (!options.yes) {
|
|
29
|
-
const confirmed = await
|
|
28
|
+
const confirmed = await confirmWithBack({
|
|
30
29
|
message: "Undo this commit? (changes will remain staged)",
|
|
31
30
|
default: true,
|
|
31
|
+
showBack: false,
|
|
32
32
|
});
|
|
33
|
-
if (
|
|
33
|
+
if (confirmed !== true) {
|
|
34
34
|
console.log("Aborted.");
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
execFileSync("git", ["reset", "--soft", "HEAD~1"], { stdio: "inherit" });
|
|
39
39
|
console.log(green("✓ Commit undone. Changes are staged."));
|
|
40
40
|
}
|
|
41
41
|
catch (error) {
|
|
@@ -46,4 +46,3 @@ export async function undoCommand(options = {}) {
|
|
|
46
46
|
process.exit(1);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
//# sourceMappingURL=undo.js.map
|
package/dist/commands/update.js
CHANGED
|
@@ -4,6 +4,47 @@ import { bold, dim, green, yellow } from "../colors.js";
|
|
|
4
4
|
import { loadConfig } from "../config.js";
|
|
5
5
|
import { writeVersionInfo, getCliVersion } from "../devflow-version.js";
|
|
6
6
|
import { confirmWithBack, } from "../prompts.js";
|
|
7
|
+
const CLAUDE_SKILL_TEMPLATE = `---
|
|
8
|
+
name: devflow-usage
|
|
9
|
+
description: MANDATORY when working in any devflow-managed repo (one with a .devflow/config.json). Always use devflow commands instead of raw git/gh — \`devflow branch\` over \`git checkout -b\`, \`devflow commit\` over \`git commit\`, \`devflow pr\` over \`gh pr create\`. Never push directly to main; all changes go through PRs. Full command reference and non-interactive flag examples live in .devflow/AI_INSTRUCTIONS.md.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# DevFlow Usage
|
|
13
|
+
|
|
14
|
+
This repo uses [devflow](https://github.com/alejandrochvs/devflow-cli) for Git workflow automation. Apply these rules whenever making changes.
|
|
15
|
+
|
|
16
|
+
## Core rules
|
|
17
|
+
|
|
18
|
+
1. **Never push directly to main.** All changes go through pull requests, even small fixes.
|
|
19
|
+
2. **Use devflow commands, not raw git/gh:**
|
|
20
|
+
- Branches: \`devflow branch\` (not \`git checkout -b\`)
|
|
21
|
+
- Commits: \`devflow commit\` (not \`git commit\`)
|
|
22
|
+
- PRs: \`devflow pr\` (not \`gh pr create\`)
|
|
23
|
+
- Issues: \`devflow issue\` / \`devflow issues\` (not \`gh issue ...\`)
|
|
24
|
+
3. **Issue-first workflow** (when a project board is configured):
|
|
25
|
+
- \`devflow issues\` to see Todo / In Progress
|
|
26
|
+
- \`devflow issues --work --issue <N> --yes\` to start work
|
|
27
|
+
4. **Commit format:** \`{type}[{ticket}]{breaking}({scope}): {message}\` — e.g. \`feat[123](auth): add OAuth2 login\`.
|
|
28
|
+
5. **Branch format:** \`{type}/{ticket}_{description}\` — e.g. \`feat/123_add-login\`.
|
|
29
|
+
6. **Press \`Escape\`** to go back a step in any multi-step prompt.
|
|
30
|
+
7. **Use \`--dry-run\`** to preview any command without executing.
|
|
31
|
+
|
|
32
|
+
## Non-interactive mode for AI agents
|
|
33
|
+
|
|
34
|
+
Append \`--yes\` to skip all confirmation prompts. Each command also accepts content flags so prompts can be skipped entirely:
|
|
35
|
+
|
|
36
|
+
\`\`\`bash
|
|
37
|
+
devflow branch --type feat --ticket 123 --description "add-login" --yes
|
|
38
|
+
devflow commit --type feat --scope auth --message "add login" --all --yes
|
|
39
|
+
devflow pr --title "Add login" --summary "Implements login UI" --yes
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
Full per-command non-interactive examples live in \`.devflow/AI_INSTRUCTIONS.md\`.
|
|
43
|
+
|
|
44
|
+
## Full reference
|
|
45
|
+
|
|
46
|
+
For everything beyond the basics above — Quick Reference table, all command flags, common workflows, edge cases like merged/closed PRs — read \`.devflow/AI_INSTRUCTIONS.md\`. Treat that file as canonical.
|
|
47
|
+
`;
|
|
7
48
|
const AI_INSTRUCTIONS_TEMPLATE = `# DevFlow - AI Agent Instructions
|
|
8
49
|
|
|
9
50
|
## Quick Reference
|
|
@@ -243,6 +284,36 @@ export async function updateCommand(options = {}) {
|
|
|
243
284
|
updates.push(aiInstructionsExists ? "Updated .devflow/AI_INSTRUCTIONS.md" : "Created .devflow/AI_INSTRUCTIONS.md");
|
|
244
285
|
}
|
|
245
286
|
}
|
|
287
|
+
// Update Claude Code wrapper skill
|
|
288
|
+
const skillDir = resolve(cwd, ".claude/skills/devflow-usage");
|
|
289
|
+
const skillPath = resolve(skillDir, "SKILL.md");
|
|
290
|
+
const skillExists = existsSync(skillPath);
|
|
291
|
+
let updateSkill = true;
|
|
292
|
+
if (skillExists && !options.yes) {
|
|
293
|
+
const result = await confirmWithBack({
|
|
294
|
+
message: "Update .claude/skills/devflow-usage/SKILL.md with latest template?",
|
|
295
|
+
default: true,
|
|
296
|
+
showBack: false,
|
|
297
|
+
});
|
|
298
|
+
updateSkill = result === true;
|
|
299
|
+
}
|
|
300
|
+
if (updateSkill) {
|
|
301
|
+
let skillTemplate = CLAUDE_SKILL_TEMPLATE;
|
|
302
|
+
if (config.commitFormat) {
|
|
303
|
+
skillTemplate = skillTemplate.replace("{type}[{ticket}]{breaking}({scope}): {message}", config.commitFormat);
|
|
304
|
+
}
|
|
305
|
+
if (config.branchFormat) {
|
|
306
|
+
skillTemplate = skillTemplate.replace("{type}/{ticket}_{description}", config.branchFormat);
|
|
307
|
+
}
|
|
308
|
+
if (options.dryRun) {
|
|
309
|
+
console.log(dim(`[dry-run] Would ${skillExists ? "update" : "create"} .claude/skills/devflow-usage/SKILL.md`));
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
mkdirSync(skillDir, { recursive: true });
|
|
313
|
+
writeFileSync(skillPath, skillTemplate);
|
|
314
|
+
updates.push(skillExists ? "Updated .claude/skills/devflow-usage/SKILL.md" : "Created .claude/skills/devflow-usage/SKILL.md");
|
|
315
|
+
}
|
|
316
|
+
}
|
|
246
317
|
// Update CLAUDE.md
|
|
247
318
|
if (existsSync(claudeMdPath)) {
|
|
248
319
|
const claudeMd = readFileSync(claudeMdPath, "utf-8");
|
|
@@ -308,4 +379,3 @@ export async function updateCommand(options = {}) {
|
|
|
308
379
|
process.exit(1);
|
|
309
380
|
}
|
|
310
381
|
}
|
|
311
|
-
//# sourceMappingURL=update.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, green, cyan, yellow, red } from "../colors.js";
|
|
3
3
|
import { selectWithBack, inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
|
|
4
4
|
function listWorktrees() {
|
|
5
5
|
try {
|
|
6
|
-
const result =
|
|
6
|
+
const result = execFileSync("git", ["worktree", "list", "--porcelain"], { encoding: "utf-8" }).trim();
|
|
7
7
|
if (!result)
|
|
8
8
|
return [];
|
|
9
9
|
const trees = [];
|
|
@@ -30,7 +30,7 @@ function listWorktrees() {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function getRepoRoot() {
|
|
33
|
-
return
|
|
33
|
+
return execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8" }).trim();
|
|
34
34
|
}
|
|
35
35
|
export async function worktreeCommand(options = {}) {
|
|
36
36
|
try {
|
|
@@ -137,22 +137,27 @@ export async function worktreeCommand(options = {}) {
|
|
|
137
137
|
// Check if branch exists
|
|
138
138
|
let branchExists = false;
|
|
139
139
|
try {
|
|
140
|
-
|
|
140
|
+
execFileSync("git", ["rev-parse", "--verify", branchName.trim()], { stdio: "ignore" });
|
|
141
141
|
branchExists = true;
|
|
142
142
|
}
|
|
143
143
|
catch {
|
|
144
144
|
// Branch doesn't exist
|
|
145
145
|
}
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
stdio: "inherit",
|
|
150
|
-
});
|
|
151
|
-
console.log(green(`✓ Created worktree at ${worktreePath.trim()}`));
|
|
152
|
-
console.log(dim(` cd ${worktreePath.trim()}`));
|
|
146
|
+
const branchArgs = branchExists ? ["--", worktreePath.trim(), branchName.trim()] : ["-b", branchName.trim(), "--", worktreePath.trim()];
|
|
147
|
+
if (options.dryRun) {
|
|
148
|
+
console.log(dim(`[dry-run] Would create worktree at ${worktreePath.trim()} for ${branchName.trim()}`));
|
|
153
149
|
}
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
else {
|
|
151
|
+
try {
|
|
152
|
+
execFileSync("git", ["worktree", "add", ...branchArgs], {
|
|
153
|
+
stdio: "inherit",
|
|
154
|
+
});
|
|
155
|
+
console.log(green(`✓ Created worktree at ${worktreePath.trim()}`));
|
|
156
|
+
console.log(dim(` cd ${worktreePath.trim()}`));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
console.log(red("✗ Failed to create worktree"));
|
|
160
|
+
}
|
|
156
161
|
}
|
|
157
162
|
currentStep = "done";
|
|
158
163
|
}
|
|
@@ -199,19 +204,24 @@ export async function worktreeCommand(options = {}) {
|
|
|
199
204
|
break;
|
|
200
205
|
}
|
|
201
206
|
if (confirmed === true) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
console.log(green("✓ Worktree removed"));
|
|
207
|
+
if (options.dryRun) {
|
|
208
|
+
console.log(dim(`[dry-run] Would remove worktree at ${selected}`));
|
|
205
209
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
else {
|
|
211
|
+
try {
|
|
212
|
+
execFileSync("git", ["worktree", "remove", "--", selected], { stdio: "inherit" });
|
|
213
|
+
console.log(green("✓ Worktree removed"));
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
const force = options.yes || await confirmWithBack({
|
|
217
|
+
message: "Worktree has changes. Force remove?",
|
|
218
|
+
default: false,
|
|
219
|
+
showBack: false,
|
|
220
|
+
});
|
|
221
|
+
if (force === true) {
|
|
222
|
+
execFileSync("git", ["worktree", "remove", "--force", "--", selected], { stdio: "inherit" });
|
|
223
|
+
console.log(yellow("✓ Force removed worktree"));
|
|
224
|
+
}
|
|
215
225
|
}
|
|
216
226
|
}
|
|
217
227
|
}
|
|
@@ -235,4 +245,3 @@ export async function worktreeCommand(options = {}) {
|
|
|
235
245
|
process.exit(1);
|
|
236
246
|
}
|
|
237
247
|
}
|
|
238
|
-
//# sourceMappingURL=worktree.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface IssueField {
|
|
|
13
13
|
export interface IssueType {
|
|
14
14
|
value: string;
|
|
15
15
|
label: string;
|
|
16
|
-
labelColor
|
|
16
|
+
labelColor?: string;
|
|
17
17
|
branchType: string;
|
|
18
18
|
fields: IssueField[];
|
|
19
19
|
template: string;
|
|
@@ -83,4 +83,3 @@ export interface ConfigWarning {
|
|
|
83
83
|
}
|
|
84
84
|
export declare function validateConfig(raw: Record<string, unknown>): ConfigWarning[];
|
|
85
85
|
export declare function loadConfig(cwd?: string): DevflowConfig;
|
|
86
|
-
//# sourceMappingURL=config.d.ts.map
|