automata-cli 0.2.0-develop.20 → 0.2.0-develop.26
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 +7 -59
- package/dist/index.js +64 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# automata-cli
|
|
2
2
|
|
|
3
|
-
A command-line interface tool.
|
|
3
|
+
A command-line interface tool for automating Git and project workflows.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ A command-line interface tool.
|
|
|
8
8
|
npm install -g automata-cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Quick start
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
automata --help
|
|
@@ -16,62 +16,10 @@ automata --help
|
|
|
16
16
|
|
|
17
17
|
## Commands
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
automata config
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### `automata config set type <value>`
|
|
28
|
-
|
|
29
|
-
Set a configuration value non-interactively (useful in scripts or CI).
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
automata config set type gh # GitHub
|
|
33
|
-
automata config set type azdo # Azure DevOps
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Configuration is saved to `.automata/config.json` in the current directory.
|
|
37
|
-
|
|
38
|
-
### `automata git get-pr-info`
|
|
39
|
-
|
|
40
|
-
Show the pull request associated with the current branch (requires [`gh` CLI](https://cli.github.com/) installed and authenticated).
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
automata git get-pr-info # human-readable output
|
|
44
|
-
automata git get-pr-info --json # JSON output
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Example output:
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
PR: #42
|
|
51
|
-
Title: Fix authentication bug
|
|
52
|
-
State: MERGED
|
|
53
|
-
URL: https://github.com/org/repo/pull/42
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
If no PR exists for the current branch, a friendly message is printed and the command exits with code 0.
|
|
57
|
-
|
|
58
|
-
### `automata git finish-feature`
|
|
59
|
-
|
|
60
|
-
Clean up a merged feature branch in one step: checkout `develop`, pull the latest, and delete the local branch.
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
automata git finish-feature
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
The command validates all preconditions before making any changes:
|
|
67
|
-
|
|
68
|
-
- Must **not** be on the `develop` branch
|
|
69
|
-
- Working tree must be clean (no uncommitted changes)
|
|
70
|
-
- A pull request for the branch must exist
|
|
71
|
-
- The PR must be in `merged` state (not open or closed-without-merge)
|
|
72
|
-
- The remote tracking branch must no longer exist (`origin/<branch>` is gone)
|
|
73
|
-
|
|
74
|
-
If any precondition fails, the command prints a descriptive error to stderr and exits with a non-zero code.
|
|
19
|
+
| Command group | Description | Docs |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `automata config` | Configure the tool | [docs/config.md](docs/config.md) |
|
|
22
|
+
| `automata git` | Git workflow helpers (requires `gh` CLI) | [docs/git.md](docs/git.md) |
|
|
75
23
|
|
|
76
24
|
## Development
|
|
77
25
|
|
|
@@ -91,7 +39,7 @@ npm install
|
|
|
91
39
|
### Scripts
|
|
92
40
|
|
|
93
41
|
| Command | Description |
|
|
94
|
-
|
|
42
|
+
|---|---|
|
|
95
43
|
| `npm run build` | Build the CLI with tsup |
|
|
96
44
|
| `npm test` | Build and run tests with vitest |
|
|
97
45
|
| `npm run lint` | Lint source files with ESLint |
|
package/dist/index.js
CHANGED
|
@@ -255,7 +255,7 @@ function getPrInfo(branch) {
|
|
|
255
255
|
"view",
|
|
256
256
|
branch,
|
|
257
257
|
"--json",
|
|
258
|
-
"number,title,state,url"
|
|
258
|
+
"number,title,state,url,statusCheckRollup"
|
|
259
259
|
]);
|
|
260
260
|
if (status !== 0) {
|
|
261
261
|
if (stderr.includes("no pull requests found") || stderr.includes("Could not resolve")) {
|
|
@@ -263,7 +263,15 @@ function getPrInfo(branch) {
|
|
|
263
263
|
}
|
|
264
264
|
throw new Error(stderr.trim() || "Failed to query GitHub. Is `gh` installed and authenticated?");
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
const raw = JSON.parse(stdout);
|
|
267
|
+
const checks = (raw.statusCheckRollup ?? []).map((c) => ({
|
|
268
|
+
name: c.name,
|
|
269
|
+
status: c.status,
|
|
270
|
+
conclusion: c.conclusion,
|
|
271
|
+
description: c.description ?? "",
|
|
272
|
+
detailsUrl: c.detailsUrl ?? ""
|
|
273
|
+
}));
|
|
274
|
+
return { number: raw.number, title: raw.title, state: raw.state, url: raw.url, checks };
|
|
267
275
|
}
|
|
268
276
|
function isUpstreamGone(branch) {
|
|
269
277
|
const { status } = run("git", ["ls-remote", "--exit-code", "--heads", "origin", branch]);
|
|
@@ -283,6 +291,12 @@ function checkoutAndPull(targetBranch) {
|
|
|
283
291
|
throw new Error(`Failed to pull ${targetBranch}: ${pull.stderr.trim()}`);
|
|
284
292
|
}
|
|
285
293
|
}
|
|
294
|
+
function fetchPrune() {
|
|
295
|
+
const result = run("git", ["fetch", "--prune"]);
|
|
296
|
+
if (result.status !== 0) {
|
|
297
|
+
throw new Error(`Failed to fetch --prune: ${result.stderr.trim()}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
286
300
|
function deleteLocalBranch(branch) {
|
|
287
301
|
const result = run("git", ["branch", "-d", branch]);
|
|
288
302
|
if (result.status !== 0) {
|
|
@@ -291,7 +305,49 @@ function deleteLocalBranch(branch) {
|
|
|
291
305
|
}
|
|
292
306
|
|
|
293
307
|
// src/commands/git.ts
|
|
294
|
-
var
|
|
308
|
+
var FAIL_CONCLUSIONS = /* @__PURE__ */ new Set(["FAILURE", "TIMED_OUT", "ACTION_REQUIRED", "CANCELLED"]);
|
|
309
|
+
var SKIP_CONCLUSIONS = /* @__PURE__ */ new Set(["SKIPPED", "NEUTRAL"]);
|
|
310
|
+
function checkSymbol(check) {
|
|
311
|
+
if (check.status !== "COMPLETED") return "\u25CF";
|
|
312
|
+
if (check.conclusion === "SUCCESS") return "\u2713";
|
|
313
|
+
if (check.conclusion !== null && SKIP_CONCLUSIONS.has(check.conclusion)) return "\u25CB";
|
|
314
|
+
if (check.conclusion !== null && FAIL_CONCLUSIONS.has(check.conclusion)) return "\u2717";
|
|
315
|
+
return "\u25CF";
|
|
316
|
+
}
|
|
317
|
+
function formatCheckSummary(checks) {
|
|
318
|
+
const running = checks.some((c) => c.status !== "COMPLETED");
|
|
319
|
+
const failed = checks.filter((c) => c.conclusion !== null && FAIL_CONCLUSIONS.has(c.conclusion));
|
|
320
|
+
const errors = failed.length === 0 ? "none" : failed.map((c) => `${c.name}: ${c.description.trim() || "no details available"}`).join("; ");
|
|
321
|
+
return `Checks Running: ${String(running)}
|
|
322
|
+
Check Errors: ${errors}
|
|
323
|
+
`;
|
|
324
|
+
}
|
|
325
|
+
function formatChecks(checks) {
|
|
326
|
+
if (checks.length === 0) return "Checks: none\n";
|
|
327
|
+
const lines = ["Checks:"];
|
|
328
|
+
for (const check of checks) {
|
|
329
|
+
const sym = checkSymbol(check);
|
|
330
|
+
const pending = check.status !== "COMPLETED" ? " (pending)" : "";
|
|
331
|
+
lines.push(` ${sym} ${check.name}${pending}`);
|
|
332
|
+
if (check.conclusion !== null && FAIL_CONCLUSIONS.has(check.conclusion)) {
|
|
333
|
+
const detail = check.description.trim() || "(no details available)";
|
|
334
|
+
lines.push(` Details: ${detail}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return lines.join("\n") + "\n";
|
|
338
|
+
}
|
|
339
|
+
var getPrInfoCmd = new Command2("get-pr-info").description("Show pull request info for the current branch").option("--json", "Output as JSON").addHelpText(
|
|
340
|
+
"after",
|
|
341
|
+
`
|
|
342
|
+
Check status symbols:
|
|
343
|
+
\u2713 Passed (conclusion: SUCCESS)
|
|
344
|
+
\u2717 Failed (conclusion: FAILURE / TIMED_OUT / ACTION_REQUIRED / CANCELLED)
|
|
345
|
+
\u25CF Pending (status: QUEUED or IN_PROGRESS)
|
|
346
|
+
\u25CB Skipped (conclusion: SKIPPED or NEUTRAL)
|
|
347
|
+
|
|
348
|
+
Failure details are printed beneath each \u2717 check.
|
|
349
|
+
See docs/git.md for full output reference.`
|
|
350
|
+
).action((options) => {
|
|
295
351
|
let branch;
|
|
296
352
|
try {
|
|
297
353
|
branch = getCurrentBranch();
|
|
@@ -321,6 +377,8 @@ Title: ${pr.title}
|
|
|
321
377
|
State: ${pr.state}
|
|
322
378
|
URL: ${pr.url}
|
|
323
379
|
`);
|
|
380
|
+
process.stdout.write(formatCheckSummary(pr.checks));
|
|
381
|
+
process.stdout.write(formatChecks(pr.checks));
|
|
324
382
|
}
|
|
325
383
|
});
|
|
326
384
|
var finishFeatureCmd = new Command2("finish-feature").description("Clean up a merged feature branch: checkout develop, pull, and delete local branch").action(() => {
|
|
@@ -375,6 +433,9 @@ var finishFeatureCmd = new Command2("finish-feature").description("Clean up a me
|
|
|
375
433
|
process.exit(1);
|
|
376
434
|
}
|
|
377
435
|
try {
|
|
436
|
+
process.stdout.write(`Fetching and pruning remote refs...
|
|
437
|
+
`);
|
|
438
|
+
fetchPrune();
|
|
378
439
|
process.stdout.write(`Checking out develop and pulling latest...
|
|
379
440
|
`);
|
|
380
441
|
checkoutAndPull("develop");
|