viza 1.9.35 → 1.9.36
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.
|
@@ -2,34 +2,25 @@ import { getEnv } from "../../../context/env.js";
|
|
|
2
2
|
import { getRunner, RUNTIME_WORKER_CONTROL_INTENT } from "../../../context/hubIntent.js";
|
|
3
3
|
import { dispatchIntentAndWait } from "../../../core/dispatch.js";
|
|
4
4
|
import { policy } from "./policy.js";
|
|
5
|
-
import { showDispatchRuns } from "./show-runs.js";
|
|
6
5
|
/**
|
|
7
|
-
* viza dispatch
|
|
6
|
+
* viza dispatch cancel-run <runId>
|
|
8
7
|
*
|
|
9
8
|
* Flow:
|
|
10
9
|
* 1) Resolve env (deterministic)
|
|
11
10
|
* 2) If --app → show GitHub Actions link locally (no dispatch)
|
|
12
11
|
* 3) Otherwise dispatch intent to hub
|
|
13
12
|
*/
|
|
14
|
-
export async function
|
|
13
|
+
export async function cancelRunCommand(runId, options) {
|
|
15
14
|
// 1️⃣ Resolve environment
|
|
16
15
|
const env = getEnv();
|
|
17
16
|
const intent = RUNTIME_WORKER_CONTROL_INTENT;
|
|
18
17
|
const runner = getRunner();
|
|
19
18
|
// Resolve allowed teams (same contract as other commands)
|
|
20
19
|
const allowedTeams = Array.from(policy.byEnv[env]);
|
|
21
|
-
// Parse limit option
|
|
22
|
-
let limit = undefined;
|
|
23
|
-
if (options.limit !== undefined) {
|
|
24
|
-
const parsed = Number(options.limit);
|
|
25
|
-
if (!Number.isNaN(parsed) && parsed > 0) {
|
|
26
|
-
limit = parsed;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
20
|
// 3️⃣ Dispatch intent to hub
|
|
30
21
|
const result = await dispatchIntentAndWait({
|
|
31
22
|
intent,
|
|
32
|
-
commandType: "dispatch.
|
|
23
|
+
commandType: "dispatch.cancel-run",
|
|
33
24
|
infraKey: "core",
|
|
34
25
|
runType: "runtime",
|
|
35
26
|
targetEnv: env,
|
|
@@ -41,12 +32,11 @@ export async function runsCommand(options) {
|
|
|
41
32
|
},
|
|
42
33
|
payload: {
|
|
43
34
|
runner,
|
|
44
|
-
|
|
35
|
+
runId,
|
|
45
36
|
},
|
|
46
37
|
}, {
|
|
47
38
|
mode: "dispatch",
|
|
48
39
|
log: "show",
|
|
49
40
|
});
|
|
50
|
-
await showDispatchRuns(result);
|
|
51
41
|
return result;
|
|
52
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { registerCommand } from "../../../core/commandRegistry.js";
|
|
2
|
-
import {
|
|
2
|
+
import { cancelRunCommand } from "./cancel-run.js";
|
|
3
3
|
const descriptor = {
|
|
4
4
|
path: ["dispatch", "cancel-run"],
|
|
5
5
|
description: "Cancel a queued GitHub Actions run by runId (admin only)",
|
|
@@ -11,7 +11,9 @@ const descriptor = {
|
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
13
|
options: [],
|
|
14
|
-
run:
|
|
14
|
+
run: async (runId, options) => {
|
|
15
|
+
return cancelRunCommand(runId, options ?? {});
|
|
16
|
+
}
|
|
15
17
|
};
|
|
16
18
|
registerCommand(descriptor);
|
|
17
19
|
export default descriptor;
|
package/package.json
CHANGED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { formatDateTime, renderCommandInline } from "../../../ui/primitives/render-command.js";
|
|
3
|
-
import { formatAge, formatDuration, pad } from "../../../ui/theme.js";
|
|
4
|
-
export async function showDispatchRuns(result) {
|
|
5
|
-
const env = result;
|
|
6
|
-
if (env.status !== "success" ||
|
|
7
|
-
env.kind !== "runtime" ||
|
|
8
|
-
!env.data?.result) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const { runs } = env.data.result;
|
|
12
|
-
if (!Array.isArray(runs)) {
|
|
13
|
-
throw new Error("invalid_dispatch_runs_result_shape");
|
|
14
|
-
}
|
|
15
|
-
console.log("\n📋 Dispatch Runs");
|
|
16
|
-
console.log(chalk.gray("─".repeat(131)));
|
|
17
|
-
const header = [
|
|
18
|
-
pad("RUN", 15),
|
|
19
|
-
pad("STATUS", 18),
|
|
20
|
-
pad("CONCLUSION", 15),
|
|
21
|
-
pad("COMMITTER", 18),
|
|
22
|
-
pad("CREATED_AT", 22),
|
|
23
|
-
pad("AGE", 13),
|
|
24
|
-
pad("DURATION", 13),
|
|
25
|
-
"ATTEMPT",
|
|
26
|
-
].join(" ");
|
|
27
|
-
console.log(header);
|
|
28
|
-
console.log(chalk.gray("─".repeat(131)));
|
|
29
|
-
if (runs.length === 0) {
|
|
30
|
-
const emptyRow = chalk.gray(" (no dispatch runs found)");
|
|
31
|
-
console.log(emptyRow);
|
|
32
|
-
console.log(chalk.gray("─".repeat(131)));
|
|
33
|
-
console.log();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
for (const run of runs) {
|
|
37
|
-
let status;
|
|
38
|
-
let conclusion;
|
|
39
|
-
if (run.status === "completed") {
|
|
40
|
-
status = "completed";
|
|
41
|
-
switch (run.conclusion) {
|
|
42
|
-
case "success":
|
|
43
|
-
conclusion = "✅ success";
|
|
44
|
-
break;
|
|
45
|
-
case "failure":
|
|
46
|
-
conclusion = "❌ failure";
|
|
47
|
-
break;
|
|
48
|
-
case "cancelled":
|
|
49
|
-
conclusion = "⚪ cancelled";
|
|
50
|
-
break;
|
|
51
|
-
case "timed_out":
|
|
52
|
-
conclusion = "⏱ timed_out";
|
|
53
|
-
break;
|
|
54
|
-
case "skipped":
|
|
55
|
-
conclusion = "⏭ skipped";
|
|
56
|
-
break;
|
|
57
|
-
default:
|
|
58
|
-
conclusion = run.conclusion ?? "-";
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (run.status === "in_progress") {
|
|
62
|
-
status = "⏳ in progress";
|
|
63
|
-
conclusion = "...";
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
status = "⏳ queued";
|
|
67
|
-
conclusion = "-";
|
|
68
|
-
}
|
|
69
|
-
const committer = run.committer
|
|
70
|
-
? `${run.committer.name}`
|
|
71
|
-
: "unknown";
|
|
72
|
-
const age = formatAge(run.createdAt);
|
|
73
|
-
const duration = run.status === "completed"
|
|
74
|
-
? formatDuration(run.createdAt, run.updatedAt)
|
|
75
|
-
: "-";
|
|
76
|
-
const row = [
|
|
77
|
-
pad(String(run.id), 15),
|
|
78
|
-
pad(status, 18),
|
|
79
|
-
pad(conclusion, 14),
|
|
80
|
-
pad(committer, 18),
|
|
81
|
-
pad(formatDateTime(run.createdAt), 22),
|
|
82
|
-
pad(age, 13),
|
|
83
|
-
pad(duration, 13),
|
|
84
|
-
`#${run.attempt}`,
|
|
85
|
-
].join(" ");
|
|
86
|
-
console.log(row);
|
|
87
|
-
}
|
|
88
|
-
console.log(chalk.gray("─".repeat(131)));
|
|
89
|
-
console.log();
|
|
90
|
-
// Hint section
|
|
91
|
-
if (runs.length > 0) {
|
|
92
|
-
const [firstRun] = runs;
|
|
93
|
-
if (!firstRun)
|
|
94
|
-
return;
|
|
95
|
-
const firstRunId = firstRun.id;
|
|
96
|
-
// derive binary name from process.argv (fallback safe)
|
|
97
|
-
const bin = (process.argv[1] || "viza").split("/").pop();
|
|
98
|
-
const sampleCmd = `${bin} dispatch logs ${firstRunId}`;
|
|
99
|
-
console.log();
|
|
100
|
-
console.log("💡 " + "\x1b[1mQuick Hint\x1b[0m");
|
|
101
|
-
console.log();
|
|
102
|
-
console.log(chalk.gray(" 👉 To list fewer or more runs, use --limit:"));
|
|
103
|
-
console.log(` ${renderCommandInline(`${bin} dispatch runs --limit <n>`)}`);
|
|
104
|
-
console.log();
|
|
105
|
-
console.log(chalk.gray(" 👉 To view detailed logs for a specific run, use:"));
|
|
106
|
-
console.log(` ${renderCommandInline(`${bin} dispatch logs <runId>`)}`);
|
|
107
|
-
console.log();
|
|
108
|
-
console.log(chalk.gray(" 👉 Example:"));
|
|
109
|
-
console.log(` ${renderCommandInline(sampleCmd)}`);
|
|
110
|
-
console.log();
|
|
111
|
-
}
|
|
112
|
-
}
|