@alejandrochaves/devflow-cli 1.8.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/dist/commands/amend.js +4 -4
- package/dist/commands/branch.js +5 -1
- package/dist/commands/changelog.js +9 -4
- package/dist/commands/cleanup.js +6 -6
- package/dist/commands/comments.js +10 -5
- package/dist/commands/commit.js +14 -13
- package/dist/commands/doctor.js +8 -8
- package/dist/commands/fixup.js +19 -15
- package/dist/commands/init.js +13 -10
- package/dist/commands/issue.js +7 -9
- package/dist/commands/log.js +8 -5
- package/dist/commands/merge.js +6 -6
- package/dist/commands/pr.js +20 -17
- package/dist/commands/release.js +14 -10
- package/dist/commands/review.js +9 -11
- package/dist/commands/stash.js +8 -8
- package/dist/commands/stats.js +6 -7
- package/dist/commands/status.js +5 -5
- package/dist/commands/undo.js +5 -5
- package/dist/commands/worktree.js +8 -8
- package/dist/config.d.ts +1 -1
- package/dist/config.js +34 -1
- package/dist/git.d.ts +9 -0
- package/dist/git.js +56 -13
- package/dist/index.js +4 -2
- package/dist/plugins.d.ts +8 -0
- package/dist/plugins.js +222 -17
- package/dist/providers/projects.js +3 -3
- package/dist/providers/tickets.js +6 -6
- package/dist/update-notifier.js +11 -3
- package/package.json +1 -1
package/dist/commands/amend.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { loadConfig } from "../config.js";
|
|
3
3
|
import { inferTicket } from "../git.js";
|
|
4
4
|
import { bold, dim, green, yellow, cyan } from "../colors.js";
|
|
5
5
|
import { selectWithBack, inputWithBack, confirmWithBack, searchWithBack, BACK_VALUE } from "../prompts.js";
|
|
6
6
|
function getLastCommitMessage() {
|
|
7
|
-
return
|
|
7
|
+
return execFileSync("git", ["log", "-1", "--format=%s"], { encoding: "utf-8" }).trim();
|
|
8
8
|
}
|
|
9
9
|
function parseCommitMessage(msg, format) {
|
|
10
10
|
// Try to parse the default format: type[ticket]!(scope): message
|
|
@@ -192,7 +192,7 @@ export async function amendCommand(options = {}) {
|
|
|
192
192
|
newMessage = result;
|
|
193
193
|
}
|
|
194
194
|
// Check for additional staged changes
|
|
195
|
-
const staged =
|
|
195
|
+
const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
|
|
196
196
|
if (staged) {
|
|
197
197
|
console.log(dim("\nStaged changes will be included:"));
|
|
198
198
|
staged.split("\n").forEach((f) => console.log(dim(` ${f}`)));
|
|
@@ -227,7 +227,7 @@ export async function amendCommand(options = {}) {
|
|
|
227
227
|
process.exit(0);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
execFileSync("git", ["commit", "--amend", "-m", newMessage], {
|
|
231
231
|
stdio: "inherit",
|
|
232
232
|
});
|
|
233
233
|
console.log(green("✓ Commit amended successfully."));
|
package/dist/commands/branch.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { select, input } from "@inquirer/prompts";
|
|
2
2
|
import { execFileSync } from "child_process";
|
|
3
3
|
import { loadConfig } from "../config.js";
|
|
4
|
-
import { bold, dim, green, cyan, gray } from "../colors.js";
|
|
4
|
+
import { bold, dim, green, cyan, gray, red } from "../colors.js";
|
|
5
|
+
import { assertBranchName } from "../git.js";
|
|
5
6
|
import { setTestPlan } from "../test-plan.js";
|
|
6
7
|
import { createTicketProvider, inferBranchTypeFromLabels, parseAcceptanceCriteria, } from "../providers/tickets.js";
|
|
7
8
|
import { selectWithBack, inputWithBack, BACK_VALUE } from "../prompts.js";
|
|
@@ -17,6 +18,8 @@ export function formatBranchName(format, vars) {
|
|
|
17
18
|
result = result.replace(/__+/g, "_").replace(/^_|_$/g, "");
|
|
18
19
|
// Clean up underscore next to slash
|
|
19
20
|
result = result.replace(/\/_/g, "/").replace(/_\//g, "/");
|
|
21
|
+
// The ticket and branchFormat come from the user or the repo's config: never hand git an option
|
|
22
|
+
assertBranchName(result);
|
|
20
23
|
return result;
|
|
21
24
|
}
|
|
22
25
|
function toKebabCase(str) {
|
|
@@ -353,6 +356,7 @@ export async function branchCommand(options = {}) {
|
|
|
353
356
|
console.log("\nCancelled.");
|
|
354
357
|
process.exit(0);
|
|
355
358
|
}
|
|
359
|
+
console.error(red(`✗ ${error.message}`));
|
|
356
360
|
process.exit(1);
|
|
357
361
|
}
|
|
358
362
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { writeFileSync, existsSync, readFileSync } from "fs";
|
|
3
3
|
import { bold, dim, green, cyan, gray } from "../colors.js";
|
|
4
|
+
import { isOptionLike, resolveCommit } from "../git.js";
|
|
4
5
|
import { inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
|
|
5
6
|
function getLatestTag() {
|
|
6
7
|
try {
|
|
7
|
-
|
|
8
|
+
const tag = execFileSync("git", ["describe", "--tags", "--abbrev=0"], { encoding: "utf-8" }).trim();
|
|
9
|
+
return isOptionLike(tag) ? undefined : tag;
|
|
8
10
|
}
|
|
9
11
|
catch {
|
|
10
12
|
return undefined;
|
|
@@ -12,8 +14,11 @@ function getLatestTag() {
|
|
|
12
14
|
}
|
|
13
15
|
function getCommitsSinceTag(tag) {
|
|
14
16
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
+
const tagId = tag ? resolveCommit(tag) : undefined;
|
|
18
|
+
if (tag && !tagId)
|
|
19
|
+
return [];
|
|
20
|
+
const range = tagId ? `${tagId}..HEAD` : "HEAD";
|
|
21
|
+
const log = execFileSync("git", ["log", range, "--format=%s"], { encoding: "utf-8" }).trim();
|
|
17
22
|
return log ? log.split("\n") : [];
|
|
18
23
|
}
|
|
19
24
|
catch {
|
package/dist/commands/cleanup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, green, red, yellow, gray } from "../colors.js";
|
|
3
3
|
import { deleteTestPlan } from "../test-plan.js";
|
|
4
4
|
import { getRepoDefaultBranch } from "../git.js";
|
|
@@ -6,7 +6,7 @@ import { checkboxWithBack, confirmWithBack, BACK_VALUE } from "../prompts.js";
|
|
|
6
6
|
function getMergedBranches() {
|
|
7
7
|
try {
|
|
8
8
|
const defaultBranch = getRepoDefaultBranch();
|
|
9
|
-
const result =
|
|
9
|
+
const result = execFileSync("git", ["branch", "--merged", defaultBranch], { encoding: "utf-8" }).trim();
|
|
10
10
|
return result
|
|
11
11
|
.split("\n")
|
|
12
12
|
.map((b) => b.trim())
|
|
@@ -19,7 +19,7 @@ function getMergedBranches() {
|
|
|
19
19
|
function getGoneBranches() {
|
|
20
20
|
try {
|
|
21
21
|
// Branches whose remote tracking branch is gone
|
|
22
|
-
const result =
|
|
22
|
+
const result = execFileSync("git", ["branch", "-vv"], { encoding: "utf-8" }).trim();
|
|
23
23
|
return result
|
|
24
24
|
.split("\n")
|
|
25
25
|
.filter((line) => line.includes(": gone]"))
|
|
@@ -36,7 +36,7 @@ export async function cleanupCommand(options = {}) {
|
|
|
36
36
|
// Fetch latest remote state
|
|
37
37
|
console.log(dim("Fetching remote state..."));
|
|
38
38
|
try {
|
|
39
|
-
|
|
39
|
+
execFileSync("git", ["fetch", "--prune"], { stdio: "ignore" });
|
|
40
40
|
}
|
|
41
41
|
catch {
|
|
42
42
|
console.log(yellow("⚠ Could not fetch from remote."));
|
|
@@ -97,7 +97,7 @@ export async function cleanupCommand(options = {}) {
|
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
99
|
try {
|
|
100
|
-
|
|
100
|
+
execFileSync("git", ["branch", "-d", branch], { stdio: "ignore" });
|
|
101
101
|
deleteTestPlan(branch);
|
|
102
102
|
console.log(`${green("✓")} Deleted ${branch}`);
|
|
103
103
|
}
|
|
@@ -120,7 +120,7 @@ export async function cleanupCommand(options = {}) {
|
|
|
120
120
|
force = forceResult === true;
|
|
121
121
|
}
|
|
122
122
|
if (force) {
|
|
123
|
-
|
|
123
|
+
execFileSync("git", ["branch", "-D", branch], { stdio: "ignore" });
|
|
124
124
|
deleteTestPlan(branch);
|
|
125
125
|
console.log(`${yellow("✓")} Force deleted ${branch}`);
|
|
126
126
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, cyan, yellow, green, magenta, gray } from "../colors.js";
|
|
3
3
|
import { checkGhInstalled } from "../git.js";
|
|
4
4
|
function getCurrentPr() {
|
|
5
5
|
try {
|
|
6
|
-
const result =
|
|
6
|
+
const result = execFileSync("gh", ["pr", "view", "--json", "number,title"], {
|
|
7
7
|
encoding: "utf-8",
|
|
8
8
|
stdio: ["pipe", "pipe", "ignore"],
|
|
9
9
|
}).trim();
|
|
@@ -15,7 +15,7 @@ function getCurrentPr() {
|
|
|
15
15
|
}
|
|
16
16
|
function getRepoInfo() {
|
|
17
17
|
try {
|
|
18
|
-
const result =
|
|
18
|
+
const result = execFileSync("gh", ["repo", "view", "--json", "owner,name"], {
|
|
19
19
|
encoding: "utf-8",
|
|
20
20
|
stdio: ["pipe", "pipe", "ignore"],
|
|
21
21
|
}).trim();
|
|
@@ -51,7 +51,7 @@ function getReviewThreads(owner, repo, prNumber) {
|
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
53
|
try {
|
|
54
|
-
const result =
|
|
54
|
+
const result = execFileSync("gh", ["api", "graphql", "-f", `query=${query}`], {
|
|
55
55
|
encoding: "utf-8",
|
|
56
56
|
stdio: ["pipe", "pipe", "ignore"],
|
|
57
57
|
}).trim();
|
|
@@ -75,7 +75,12 @@ function getReviewThreads(owner, repo, prNumber) {
|
|
|
75
75
|
}
|
|
76
76
|
function getReviews(owner, repo, prNumber) {
|
|
77
77
|
try {
|
|
78
|
-
const result =
|
|
78
|
+
const result = execFileSync("gh", [
|
|
79
|
+
"api",
|
|
80
|
+
`repos/${owner}/${repo}/pulls/${prNumber}/reviews`,
|
|
81
|
+
"--jq",
|
|
82
|
+
"[.[] | {author: .user.login, state: .state, body: .body, submittedAt: .submitted_at}]",
|
|
83
|
+
], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
|
|
79
84
|
return result ? JSON.parse(result) : [];
|
|
80
85
|
}
|
|
81
86
|
catch {
|
package/dist/commands/commit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { loadConfig } from "../config.js";
|
|
3
3
|
import { inferTicket, inferScope, getBranch, isProtectedBranch } from "../git.js";
|
|
4
4
|
import { bold, cyan, dim, green, yellow } from "../colors.js";
|
|
@@ -66,14 +66,14 @@ export async function commitCommand(options = {}) {
|
|
|
66
66
|
// Stage files if --all or --files provided (non-interactive)
|
|
67
67
|
if (options.all) {
|
|
68
68
|
if (!options.dryRun) {
|
|
69
|
-
|
|
69
|
+
execFileSync("git", ["add", "-A"]);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
else if (options.files) {
|
|
73
73
|
const filesToStage = options.files.split(",").map((f) => f.trim());
|
|
74
74
|
if (!options.dryRun) {
|
|
75
75
|
for (const file of filesToStage) {
|
|
76
|
-
|
|
76
|
+
execFileSync("git", ["add", "--", file]);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -92,7 +92,7 @@ export async function commitCommand(options = {}) {
|
|
|
92
92
|
// Determine starting step based on flags
|
|
93
93
|
if (options.all || options.files) {
|
|
94
94
|
// Files already staged via flags, skip to type
|
|
95
|
-
const staged =
|
|
95
|
+
const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
|
|
96
96
|
state.stagedFiles = staged ? staged.split("\n") : [];
|
|
97
97
|
currentStep = "type";
|
|
98
98
|
}
|
|
@@ -129,9 +129,9 @@ export async function commitCommand(options = {}) {
|
|
|
129
129
|
switch (currentStep) {
|
|
130
130
|
case "stageFiles": {
|
|
131
131
|
// Check for staged files
|
|
132
|
-
const staged =
|
|
133
|
-
const unstaged =
|
|
134
|
-
const untracked =
|
|
132
|
+
const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
|
|
133
|
+
const unstaged = execFileSync("git", ["diff", "--name-only"], { encoding: "utf-8" }).trim();
|
|
134
|
+
const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf-8" }).trim();
|
|
135
135
|
const allChanges = [
|
|
136
136
|
...unstaged.split("\n").filter(Boolean).map((f) => ({ file: f, label: `M ${f}` })),
|
|
137
137
|
...untracked.split("\n").filter(Boolean).map((f) => ({ file: f, label: `? ${f}` })),
|
|
@@ -152,7 +152,7 @@ export async function commitCommand(options = {}) {
|
|
|
152
152
|
if (options.yes) {
|
|
153
153
|
// Auto-stage all files when --yes
|
|
154
154
|
if (!options.dryRun) {
|
|
155
|
-
|
|
155
|
+
execFileSync("git", ["add", "-A"]);
|
|
156
156
|
}
|
|
157
157
|
state.stagedFiles = allChanges.map((c) => c.file);
|
|
158
158
|
goNext();
|
|
@@ -169,7 +169,7 @@ export async function commitCommand(options = {}) {
|
|
|
169
169
|
process.exit(0);
|
|
170
170
|
}
|
|
171
171
|
if (!options.dryRun) {
|
|
172
|
-
|
|
172
|
+
execFileSync("git", ["--literal-pathspecs", "add", "--", allChanges[0].file]);
|
|
173
173
|
}
|
|
174
174
|
state.stagedFiles = [allChanges[0].file];
|
|
175
175
|
goNext();
|
|
@@ -191,7 +191,7 @@ export async function commitCommand(options = {}) {
|
|
|
191
191
|
}
|
|
192
192
|
if (stageChoice === "all") {
|
|
193
193
|
if (!options.dryRun) {
|
|
194
|
-
|
|
194
|
+
execFileSync("git", ["add", "-A"]);
|
|
195
195
|
}
|
|
196
196
|
state.stagedFiles = allChanges.map((c) => c.file);
|
|
197
197
|
goNext();
|
|
@@ -212,8 +212,9 @@ export async function commitCommand(options = {}) {
|
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
if (!options.dryRun) {
|
|
215
|
+
// Picked names are file names, not patterns: "x*" stages only the file called x*.
|
|
215
216
|
for (const file of filesToStage) {
|
|
216
|
-
|
|
217
|
+
execFileSync("git", ["--literal-pathspecs", "add", "--", file]);
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
state.stagedFiles = filesToStage;
|
|
@@ -234,7 +235,7 @@ export async function commitCommand(options = {}) {
|
|
|
234
235
|
});
|
|
235
236
|
if (result === BACK_VALUE) {
|
|
236
237
|
// Unstage files before going back
|
|
237
|
-
|
|
238
|
+
execFileSync("git", ["reset", "HEAD"], { stdio: "ignore" });
|
|
238
239
|
goBack();
|
|
239
240
|
}
|
|
240
241
|
else {
|
|
@@ -463,7 +464,7 @@ export async function commitCommand(options = {}) {
|
|
|
463
464
|
console.log("Commit aborted.");
|
|
464
465
|
process.exit(0);
|
|
465
466
|
}
|
|
466
|
-
|
|
467
|
+
execFileSync("git", ["commit", "-m", fullMessage], {
|
|
467
468
|
stdio: "inherit",
|
|
468
469
|
});
|
|
469
470
|
console.log(green("✓ Commit created successfully."));
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { existsSync, readFileSync } from "fs";
|
|
3
3
|
import { resolve } from "path";
|
|
4
4
|
import { bold, dim, green, red, yellow, gray } from "../colors.js";
|
|
5
|
-
function checkCommand(
|
|
5
|
+
function checkCommand(file, ...args) {
|
|
6
6
|
try {
|
|
7
|
-
return
|
|
7
|
+
return execFileSync(file, args, { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim();
|
|
8
8
|
}
|
|
9
9
|
catch {
|
|
10
10
|
return undefined;
|
|
@@ -15,12 +15,12 @@ export async function doctorCommand() {
|
|
|
15
15
|
const checks = [];
|
|
16
16
|
console.log(`\n${dim("───")} ${bold("devflow doctor")} ${dim("───")}\n`);
|
|
17
17
|
// 1. Git
|
|
18
|
-
const gitVersion = checkCommand("git --version");
|
|
18
|
+
const gitVersion = checkCommand("git", "--version");
|
|
19
19
|
checks.push(gitVersion
|
|
20
20
|
? { name: "git", status: "ok", detail: gitVersion.replace("git version ", "") }
|
|
21
21
|
: { name: "git", status: "error", detail: "Not installed" });
|
|
22
22
|
// 2. Node
|
|
23
|
-
const nodeVersion = checkCommand("node --version");
|
|
23
|
+
const nodeVersion = checkCommand("node", "--version");
|
|
24
24
|
if (nodeVersion) {
|
|
25
25
|
const major = parseInt(nodeVersion.replace("v", "").split(".")[0], 10);
|
|
26
26
|
checks.push(major >= 20
|
|
@@ -31,7 +31,7 @@ export async function doctorCommand() {
|
|
|
31
31
|
checks.push({ name: "node", status: "error", detail: "Not installed" });
|
|
32
32
|
}
|
|
33
33
|
// 3. GitHub CLI
|
|
34
|
-
const ghVersion = checkCommand("gh --version");
|
|
34
|
+
const ghVersion = checkCommand("gh", "--version");
|
|
35
35
|
if (ghVersion) {
|
|
36
36
|
const version = ghVersion.split("\n")[0];
|
|
37
37
|
checks.push({ name: "gh (GitHub CLI)", status: "ok", detail: version.replace("gh version ", "").split(" ")[0] });
|
|
@@ -41,13 +41,13 @@ export async function doctorCommand() {
|
|
|
41
41
|
}
|
|
42
42
|
// 4. gh auth
|
|
43
43
|
if (ghVersion) {
|
|
44
|
-
const ghAuth = checkCommand("gh auth status");
|
|
44
|
+
const ghAuth = checkCommand("gh", "auth", "status");
|
|
45
45
|
checks.push(ghAuth
|
|
46
46
|
? { name: "gh auth", status: "ok", detail: "Authenticated" }
|
|
47
47
|
: { name: "gh auth", status: "warning", detail: "Not authenticated (run: gh auth login)" });
|
|
48
48
|
}
|
|
49
49
|
// 5. Git repo
|
|
50
|
-
const isRepo = checkCommand("git rev-parse --is-inside-work-tree");
|
|
50
|
+
const isRepo = checkCommand("git", "rev-parse", "--is-inside-work-tree");
|
|
51
51
|
checks.push(isRepo === "true"
|
|
52
52
|
? { name: "git repository", status: "ok" }
|
|
53
53
|
: { name: "git repository", status: "error", detail: "Not inside a git repository" });
|
package/dist/commands/fixup.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, green, cyan } from "../colors.js";
|
|
3
|
-
import { getDefaultBase, getBranch } from "../git.js";
|
|
3
|
+
import { getDefaultBase, getBranch, resolveCommit } from "../git.js";
|
|
4
4
|
import { selectWithBack, confirmWithBack, checkboxWithBack, BACK_VALUE, } from "../prompts.js";
|
|
5
|
-
function getCommitsOnBranch(
|
|
5
|
+
function getCommitsOnBranch(baseId) {
|
|
6
|
+
if (!baseId)
|
|
7
|
+
return [];
|
|
6
8
|
try {
|
|
7
|
-
const log =
|
|
9
|
+
const log = execFileSync("git", ["log", `${baseId}..HEAD`, "--format=%H|%s"], { encoding: "utf-8" }).trim();
|
|
8
10
|
if (!log)
|
|
9
11
|
return [];
|
|
10
12
|
return log.split("\n").map((line) => {
|
|
@@ -20,7 +22,8 @@ export async function fixupCommand(options = {}) {
|
|
|
20
22
|
try {
|
|
21
23
|
const branch = getBranch();
|
|
22
24
|
const base = getDefaultBase(branch);
|
|
23
|
-
const
|
|
25
|
+
const baseId = resolveCommit(base);
|
|
26
|
+
const commits = getCommitsOnBranch(baseId);
|
|
24
27
|
if (commits.length < 2) {
|
|
25
28
|
console.log("Need at least 2 commits on the branch to fixup.");
|
|
26
29
|
return;
|
|
@@ -28,14 +31,14 @@ export async function fixupCommand(options = {}) {
|
|
|
28
31
|
// Stage files if --all or --files provided (non-interactive)
|
|
29
32
|
if (options.all) {
|
|
30
33
|
if (!options.dryRun) {
|
|
31
|
-
|
|
34
|
+
execFileSync("git", ["add", "-A"]);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
else if (options.files) {
|
|
35
38
|
const filesToStage = options.files.split(",").map((f) => f.trim());
|
|
36
39
|
if (!options.dryRun) {
|
|
37
40
|
for (const file of filesToStage) {
|
|
38
|
-
|
|
41
|
+
execFileSync("git", ["add", "--", file]);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -60,9 +63,9 @@ export async function fixupCommand(options = {}) {
|
|
|
60
63
|
switch (currentStep) {
|
|
61
64
|
case "stageFiles": {
|
|
62
65
|
// Check for unstaged/staged changes
|
|
63
|
-
const staged =
|
|
64
|
-
const unstaged =
|
|
65
|
-
const untracked =
|
|
66
|
+
const staged = execFileSync("git", ["diff", "--cached", "--name-only"], { encoding: "utf-8" }).trim();
|
|
67
|
+
const unstaged = execFileSync("git", ["diff", "--name-only"], { encoding: "utf-8" }).trim();
|
|
68
|
+
const untracked = execFileSync("git", ["ls-files", "--others", "--exclude-standard"], { encoding: "utf-8" }).trim();
|
|
66
69
|
// If already have staged changes, skip to target selection
|
|
67
70
|
if (staged) {
|
|
68
71
|
currentStep = "selectTarget";
|
|
@@ -80,7 +83,7 @@ export async function fixupCommand(options = {}) {
|
|
|
80
83
|
if (options.yes) {
|
|
81
84
|
// Auto-stage all when --yes
|
|
82
85
|
if (!options.dryRun) {
|
|
83
|
-
|
|
86
|
+
execFileSync("git", ["add", "-A"]);
|
|
84
87
|
}
|
|
85
88
|
currentStep = "selectTarget";
|
|
86
89
|
break;
|
|
@@ -104,11 +107,12 @@ export async function fixupCommand(options = {}) {
|
|
|
104
107
|
}
|
|
105
108
|
if (!options.dryRun) {
|
|
106
109
|
if (result.includes("__ALL__")) {
|
|
107
|
-
|
|
110
|
+
execFileSync("git", ["add", "-A"]);
|
|
108
111
|
}
|
|
109
112
|
else {
|
|
113
|
+
// Picked names are file names, not patterns: "x*" stages only the file called x*.
|
|
110
114
|
for (const file of result) {
|
|
111
|
-
|
|
115
|
+
execFileSync("git", ["--literal-pathspecs", "add", "--", file]);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
}
|
|
@@ -130,7 +134,7 @@ export async function fixupCommand(options = {}) {
|
|
|
130
134
|
});
|
|
131
135
|
if (result === BACK_VALUE) {
|
|
132
136
|
// Unstage files before going back
|
|
133
|
-
|
|
137
|
+
execFileSync("git", ["reset", "HEAD"], { stdio: "ignore" });
|
|
134
138
|
currentStep = "stageFiles";
|
|
135
139
|
}
|
|
136
140
|
else {
|
|
@@ -165,7 +169,7 @@ export async function fixupCommand(options = {}) {
|
|
|
165
169
|
autoSquash = squashResult === true;
|
|
166
170
|
}
|
|
167
171
|
if (autoSquash) {
|
|
168
|
-
execFileSync("git", ["rebase", "-i", "--autosquash",
|
|
172
|
+
execFileSync("git", ["rebase", "-i", "--autosquash", baseId], {
|
|
169
173
|
stdio: "inherit",
|
|
170
174
|
env: { ...process.env, GIT_SEQUENCE_EDITOR: "true" },
|
|
171
175
|
});
|
package/dist/commands/init.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2
2
|
import { resolve } from "path";
|
|
3
3
|
import { confirm, input, select } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
4
|
+
import { execFileSync } from "child_process";
|
|
5
5
|
import { PRESETS } from "../config.js";
|
|
6
6
|
import { writeVersionInfo, getCliVersion } from "../devflow-version.js";
|
|
7
7
|
import { isGhInstalled } from "../git.js";
|
|
8
8
|
import { selectWithBack, inputWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
|
|
9
|
+
// npm and npx are .cmd shims on Windows, which Node only runs through a shell. Their arguments here are constants.
|
|
10
|
+
const WINDOWS_SHELL = process.platform === "win32";
|
|
9
11
|
const DEFAULT_CHECKLIST = [
|
|
10
12
|
"Code follows project conventions",
|
|
11
13
|
"Self-reviewed the changes",
|
|
@@ -24,7 +26,7 @@ function readPackageJson(cwd) {
|
|
|
24
26
|
}
|
|
25
27
|
function getGitHubIssuesUrl() {
|
|
26
28
|
try {
|
|
27
|
-
const remoteUrl =
|
|
29
|
+
const remoteUrl = execFileSync("git", ["remote", "get-url", "origin"], {
|
|
28
30
|
encoding: "utf-8",
|
|
29
31
|
stdio: ["pipe", "pipe", "pipe"],
|
|
30
32
|
}).trim();
|
|
@@ -46,7 +48,7 @@ function getGitHubIssuesUrl() {
|
|
|
46
48
|
}
|
|
47
49
|
function getGitHubRepo() {
|
|
48
50
|
try {
|
|
49
|
-
const remoteUrl =
|
|
51
|
+
const remoteUrl = execFileSync("git", ["remote", "get-url", "origin"], {
|
|
50
52
|
encoding: "utf-8",
|
|
51
53
|
stdio: ["pipe", "pipe", "pipe"],
|
|
52
54
|
}).trim();
|
|
@@ -65,7 +67,7 @@ function getGitHubRepo() {
|
|
|
65
67
|
function hasProjectScopes() {
|
|
66
68
|
try {
|
|
67
69
|
// Try to list projects - if it fails with scope error, we don't have permissions
|
|
68
|
-
|
|
70
|
+
execFileSync("gh", ["project", "list", "--owner", "@me", "--limit", "1"], {
|
|
69
71
|
encoding: "utf-8",
|
|
70
72
|
stdio: ["pipe", "pipe", "pipe"],
|
|
71
73
|
});
|
|
@@ -104,7 +106,7 @@ function getRepoLinkedProjects(repo) {
|
|
|
104
106
|
}
|
|
105
107
|
function refreshProjectScopes() {
|
|
106
108
|
try {
|
|
107
|
-
|
|
109
|
+
execFileSync("gh", ["auth", "refresh", "-s", "project"], {
|
|
108
110
|
stdio: "inherit",
|
|
109
111
|
});
|
|
110
112
|
return true;
|
|
@@ -539,8 +541,9 @@ export async function initCommand() {
|
|
|
539
541
|
// Install commitlint deps
|
|
540
542
|
console.log("Installing commitlint...");
|
|
541
543
|
try {
|
|
542
|
-
|
|
544
|
+
execFileSync("npm", ["install", "-D", "@commitlint/cli", "@commitlint/config-conventional"], {
|
|
543
545
|
cwd,
|
|
546
|
+
shell: WINDOWS_SHELL,
|
|
544
547
|
stdio: "inherit",
|
|
545
548
|
});
|
|
546
549
|
console.log("✓ Installed commitlint");
|
|
@@ -559,8 +562,8 @@ export async function initCommand() {
|
|
|
559
562
|
// Install husky
|
|
560
563
|
console.log("Installing husky...");
|
|
561
564
|
try {
|
|
562
|
-
|
|
563
|
-
|
|
565
|
+
execFileSync("npm", ["install", "-D", "husky"], { cwd, stdio: "inherit", shell: WINDOWS_SHELL });
|
|
566
|
+
execFileSync("npx", ["husky", "init"], { cwd, stdio: "inherit", shell: WINDOWS_SHELL });
|
|
564
567
|
console.log("✓ Installed and initialized husky");
|
|
565
568
|
}
|
|
566
569
|
catch {
|
|
@@ -626,9 +629,9 @@ jobs:
|
|
|
626
629
|
ci:
|
|
627
630
|
runs-on: ubuntu-latest
|
|
628
631
|
steps:
|
|
629
|
-
- uses: actions/checkout@v4
|
|
632
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
630
633
|
|
|
631
|
-
- uses: actions/setup-node@v4
|
|
634
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
632
635
|
with:
|
|
633
636
|
node-version: 20
|
|
634
637
|
cache: npm
|
package/dist/commands/issue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { select, input, confirm, editor } from "@inquirer/prompts";
|
|
2
|
-
import {
|
|
2
|
+
import { execFileSync } from "child_process";
|
|
3
3
|
import { loadConfig } from "../config.js";
|
|
4
4
|
import { bold, dim, green, cyan, gray } from "../colors.js";
|
|
5
5
|
import { checkGhInstalled } from "../git.js";
|
|
@@ -203,13 +203,13 @@ function ensureLabelsExist(labels) {
|
|
|
203
203
|
const exactMatch = existingLabels.some((l) => l.name.toLowerCase() === label.toLowerCase());
|
|
204
204
|
if (!exactMatch) {
|
|
205
205
|
console.log(dim(`Creating label "${label}"...`));
|
|
206
|
-
execFileSync("gh", ["label", "create",
|
|
206
|
+
execFileSync("gh", ["label", "create", "--color", "0e8a16", "--force", "--", label], { stdio: ["pipe", "pipe", "pipe"] });
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
catch {
|
|
210
210
|
try {
|
|
211
211
|
console.log(dim(`Creating label "${label}"...`));
|
|
212
|
-
execFileSync("gh", ["label", "create",
|
|
212
|
+
execFileSync("gh", ["label", "create", "--color", "0e8a16", "--force", "--", label], { stdio: ["pipe", "pipe", "pipe"] });
|
|
213
213
|
}
|
|
214
214
|
catch {
|
|
215
215
|
console.warn(dim(`Warning: Could not create label "${label}"`));
|
|
@@ -223,7 +223,7 @@ function formatIssuePreview(data) {
|
|
|
223
223
|
"",
|
|
224
224
|
`${bold("Type:")} ${data.type.label}`,
|
|
225
225
|
`${bold("Title:")} ${cyan(data.title)}`,
|
|
226
|
-
`${bold("Labels:")} ${data.labels.join(", ")}`,
|
|
226
|
+
`${bold("Labels:")} ${data.labels.join(", ") || dim("none")}`,
|
|
227
227
|
"",
|
|
228
228
|
gray("─── Body ───"),
|
|
229
229
|
"",
|
|
@@ -332,8 +332,8 @@ export async function issueCommand(options = {}) {
|
|
|
332
332
|
console.log("Aborted.");
|
|
333
333
|
process.exit(0);
|
|
334
334
|
}
|
|
335
|
-
// Determine labels
|
|
336
|
-
const labels = [issueType.labelColor];
|
|
335
|
+
// Determine labels (an issue type may have none)
|
|
336
|
+
const labels = issueType.labelColor ? [issueType.labelColor] : [];
|
|
337
337
|
// Build issue data
|
|
338
338
|
const issueData = {
|
|
339
339
|
type: issueType,
|
|
@@ -372,9 +372,7 @@ export async function issueCommand(options = {}) {
|
|
|
372
372
|
ensureLabelsExist(labels);
|
|
373
373
|
}
|
|
374
374
|
// Create the issue using gh CLI
|
|
375
|
-
const
|
|
376
|
-
const cmd = `gh issue create --title ${JSON.stringify(title)} --body-file - ${labelArg}`;
|
|
377
|
-
const result = execSync(cmd, { input: body, encoding: "utf-8" }).trim();
|
|
375
|
+
const result = execFileSync("gh", ["issue", "create", `--title=${title}`, "--body-file", "-", ...labels.map((l) => `--label=${l}`)], { input: body, encoding: "utf-8" }).trim();
|
|
378
376
|
// Extract issue number from URL (format: https://github.com/owner/repo/issues/123)
|
|
379
377
|
const issueUrlMatch = result.match(/\/issues\/(\d+)/);
|
|
380
378
|
const issueNumber = issueUrlMatch ? issueUrlMatch[1] : null;
|
package/dist/commands/log.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, green, cyan } from "../colors.js";
|
|
3
|
-
import { getDefaultBase, getBranch } from "../git.js";
|
|
3
|
+
import { getDefaultBase, getBranch, resolveCommit } from "../git.js";
|
|
4
4
|
import { selectWithBack, BACK_VALUE } from "../prompts.js";
|
|
5
5
|
function getLog(base, limit = 20) {
|
|
6
6
|
try {
|
|
7
7
|
const format = "%H|%h|%s|%an|%ar";
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const baseId = base ? resolveCommit(base) : undefined;
|
|
9
|
+
if (base && !baseId)
|
|
10
|
+
return [];
|
|
11
|
+
const range = baseId ? `${baseId}..HEAD` : `HEAD~${limit}..HEAD`;
|
|
12
|
+
const result = execFileSync("git", ["log", range, `--pretty=format:${format}`, `-${limit}`], {
|
|
10
13
|
encoding: "utf-8",
|
|
11
14
|
}).trim();
|
|
12
15
|
if (!result)
|
|
@@ -61,7 +64,7 @@ export async function logCommand() {
|
|
|
61
64
|
case "action": {
|
|
62
65
|
const entry = entries.find((e) => e.hash === selectedHash);
|
|
63
66
|
// Show commit detail
|
|
64
|
-
const detail =
|
|
67
|
+
const detail = execFileSync("git", ["show", "--stat", selectedHash, "--format=%B"], {
|
|
65
68
|
encoding: "utf-8",
|
|
66
69
|
}).trim();
|
|
67
70
|
console.log(`\n${dim(detail)}\n`);
|
package/dist/commands/merge.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
2
|
import { bold, dim, green, cyan } from "../colors.js";
|
|
3
3
|
import { getBranch, checkGhInstalled, getRepoDefaultBranch } from "../git.js";
|
|
4
4
|
import { deleteTestPlan } from "../test-plan.js";
|
|
5
5
|
import { selectWithBack, confirmWithBack, BACK_VALUE, } from "../prompts.js";
|
|
6
6
|
function getPrForBranch() {
|
|
7
7
|
try {
|
|
8
|
-
const result =
|
|
8
|
+
const result = execFileSync("gh", ["pr", "view", "--json", "number,url,title,state"], {
|
|
9
9
|
encoding: "utf-8",
|
|
10
10
|
stdio: ["pipe", "pipe", "ignore"],
|
|
11
11
|
}).trim();
|
|
@@ -118,15 +118,15 @@ export async function mergeCommand(options = {}) {
|
|
|
118
118
|
currentStep = "execute";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
121
|
+
const deleteArgs = deleteBranch ? ["--delete-branch"] : [];
|
|
122
|
+
execFileSync("gh", ["pr", "merge", String(pr.number), `--${method}`, ...deleteArgs], { stdio: "inherit" });
|
|
123
123
|
console.log(green(`\n✓ PR #${pr.number} merged via ${method}.`));
|
|
124
124
|
if (deleteBranch) {
|
|
125
125
|
deleteTestPlan(branch);
|
|
126
126
|
const defaultBranch = getRepoDefaultBranch();
|
|
127
127
|
try {
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
execFileSync("git", ["checkout", defaultBranch], { stdio: "inherit" });
|
|
129
|
+
execFileSync("git", ["pull"], { stdio: "inherit" });
|
|
130
130
|
console.log(green(`✓ Switched to ${defaultBranch} and pulled latest.`));
|
|
131
131
|
}
|
|
132
132
|
catch {
|