viza 1.7.46 → 1.7.48
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.
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { resolveEnv } from "../../../context/env.js";
|
|
2
|
+
import { resolveResourceHubIntent } from "../../../context/hubIntent.js";
|
|
3
|
+
import { dispatchIntentAndWait } from "../../../core/dispatch.js";
|
|
4
|
+
const TARGET_TEAMS = {
|
|
5
|
+
"dev": [
|
|
6
|
+
"viza-designer",
|
|
7
|
+
"viza-deployer",
|
|
8
|
+
"viza-manager",
|
|
9
|
+
"viza-admin",
|
|
10
|
+
"viza-super"
|
|
11
|
+
],
|
|
12
|
+
"prod": [
|
|
13
|
+
"viza-publisher",
|
|
14
|
+
"viza-admin",
|
|
15
|
+
"viza-super"
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* viza dispatch logs <runId>
|
|
20
|
+
*
|
|
21
|
+
* Flow:
|
|
22
|
+
* 1) Resolve env (deterministic)
|
|
23
|
+
* 2) If --app → show GitHub Actions page locally (no dispatch)
|
|
24
|
+
* 3) Otherwise dispatch intent to hub to fetch log artifact
|
|
25
|
+
*/
|
|
26
|
+
export async function logsCommand(runId, options) {
|
|
27
|
+
// 1️⃣ Resolve environment
|
|
28
|
+
const env = resolveEnv(options);
|
|
29
|
+
const intent = resolveResourceHubIntent(env);
|
|
30
|
+
// Resolve allowed teams (same contract as other commands)
|
|
31
|
+
const allowedTeams = TARGET_TEAMS[env];
|
|
32
|
+
// 2️⃣ Handle --app locally (do NOT dispatch)
|
|
33
|
+
if (options.app === true) {
|
|
34
|
+
const url = env === "prod"
|
|
35
|
+
? "https://github.com/Modo-Infra/publish-app/actions"
|
|
36
|
+
: "https://github.com/Modo-Infra/build-app/actions";
|
|
37
|
+
console.log("\n📦 App pipeline runs:");
|
|
38
|
+
console.log(url);
|
|
39
|
+
console.log();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// 3️⃣ Dispatch intent to hub
|
|
43
|
+
const result = await dispatchIntentAndWait({
|
|
44
|
+
intent,
|
|
45
|
+
commandType: "dispatch.logs",
|
|
46
|
+
infraKey: "core",
|
|
47
|
+
targetEnv: env,
|
|
48
|
+
allowedTeams,
|
|
49
|
+
selfHosted: options.selfHosted === true,
|
|
50
|
+
keepLog: options.removeLog !== true,
|
|
51
|
+
flowGates: {
|
|
52
|
+
secrets: false,
|
|
53
|
+
},
|
|
54
|
+
payload: {
|
|
55
|
+
runId
|
|
56
|
+
},
|
|
57
|
+
}, {
|
|
58
|
+
status: false,
|
|
59
|
+
log: "show",
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { logsCommand } from "./logs.js";
|
|
2
|
+
import { getResolvedOptions } from "../../../cli/resolveOptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Register:
|
|
5
|
+
* viza dispatch logs <runId>
|
|
6
|
+
*/
|
|
7
|
+
export function registerDispatchLogsCommand(program) {
|
|
8
|
+
program
|
|
9
|
+
.command("logs <runId>")
|
|
10
|
+
.description("Download logs for a dispatch workflow run")
|
|
11
|
+
.option("--prod", "Use production environment")
|
|
12
|
+
.option("--dev", "Use development environment")
|
|
13
|
+
.option("--app", "Open GitHub Actions page for app pipelines instead of querying hub")
|
|
14
|
+
.action(async (runId, opts, command) => {
|
|
15
|
+
const fullOpts = getResolvedOptions(command);
|
|
16
|
+
await logsCommand(runId, fullOpts);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { registerDispatchRunsCommand } from "./runs/register.js";
|
|
2
|
+
import { registerDispatchLogsCommand } from "./logs/register.js";
|
|
2
3
|
export function registerDispatchCommand(program) {
|
|
3
4
|
const dispatch = program
|
|
4
5
|
.command("dispatch")
|
|
5
6
|
.description("Dispatch operations");
|
|
6
7
|
registerDispatchRunsCommand(dispatch);
|
|
8
|
+
registerDispatchLogsCommand(dispatch);
|
|
7
9
|
}
|
|
@@ -43,18 +43,18 @@ export async function showDispatchRuns(result) {
|
|
|
43
43
|
throw new Error("invalid_dispatch_runs_result_shape");
|
|
44
44
|
}
|
|
45
45
|
console.log("\n📋 Dispatch Runs");
|
|
46
|
-
console.log("─".repeat(
|
|
46
|
+
console.log("─".repeat(125));
|
|
47
47
|
const header = [
|
|
48
|
-
pad("RUN",
|
|
49
|
-
pad("STATUS",
|
|
50
|
-
pad("CONCLUSION",
|
|
48
|
+
pad("RUN", 15),
|
|
49
|
+
pad("STATUS", 18),
|
|
50
|
+
pad("CONCLUSION", 15),
|
|
51
51
|
pad("COMMITTER", 38),
|
|
52
52
|
pad("AGE", 12),
|
|
53
53
|
pad("DURATION", 12),
|
|
54
54
|
"ATTEMPT",
|
|
55
55
|
].join(" ");
|
|
56
56
|
console.log(header);
|
|
57
|
-
console.log("─".repeat(
|
|
57
|
+
console.log("─".repeat(125));
|
|
58
58
|
for (const run of runs) {
|
|
59
59
|
let status;
|
|
60
60
|
let conclusion;
|
|
@@ -96,8 +96,8 @@ export async function showDispatchRuns(result) {
|
|
|
96
96
|
? formatDuration(run.createdAt, run.updatedAt)
|
|
97
97
|
: "-";
|
|
98
98
|
const row = [
|
|
99
|
-
pad(String(run.id),
|
|
100
|
-
pad(status,
|
|
99
|
+
pad(String(run.id), 15),
|
|
100
|
+
pad(status, 18),
|
|
101
101
|
pad(conclusion, 14),
|
|
102
102
|
pad(committer, 38),
|
|
103
103
|
pad(age, 12),
|
|
@@ -106,6 +106,6 @@ export async function showDispatchRuns(result) {
|
|
|
106
106
|
].join(" ");
|
|
107
107
|
console.log(row);
|
|
108
108
|
}
|
|
109
|
-
console.log("─".repeat(
|
|
109
|
+
console.log("─".repeat(125));
|
|
110
110
|
console.log();
|
|
111
111
|
}
|
|
@@ -26,6 +26,31 @@ export function renderLog(zipBuffer, options) {
|
|
|
26
26
|
}
|
|
27
27
|
// Print detailed workflow log
|
|
28
28
|
parseAndPrintDeployLog(zipBuffer);
|
|
29
|
+
// Attempt to detect dispatcher from log content
|
|
30
|
+
let detectedDispatcher;
|
|
31
|
+
try {
|
|
32
|
+
const zip = new AdmZip(zipBuffer);
|
|
33
|
+
for (const entry of zip.getEntries()) {
|
|
34
|
+
if (entry.isDirectory)
|
|
35
|
+
continue;
|
|
36
|
+
const text = entry.getData().toString("utf8");
|
|
37
|
+
// 1️⃣ Deterministic marker (preferred)
|
|
38
|
+
const marker = text.match(/VIZA_DISPATCH_ACTOR=([^\s"']+)/);
|
|
39
|
+
if (marker) {
|
|
40
|
+
detectedDispatcher = marker[1];
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
// 2️⃣ Fallback heuristic for legacy logs
|
|
44
|
+
const m = text.match(/Dispatch initiated by actor:\s*([^\s"']+)/i);
|
|
45
|
+
if (m) {
|
|
46
|
+
detectedDispatcher = m[1];
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// ignore parsing errors
|
|
53
|
+
}
|
|
29
54
|
// Print final status banner
|
|
30
55
|
const status = options.status ?? "unknown";
|
|
31
56
|
let color = chalk.gray;
|
|
@@ -36,6 +61,12 @@ export function renderLog(zipBuffer, options) {
|
|
|
36
61
|
else if (status === "cancelled")
|
|
37
62
|
color = chalk.yellowBright;
|
|
38
63
|
console.log(color(`\n────── DEPLOY STATUS: ${String(status).toUpperCase()} ─────────────────────────────────────────────────────────────────────────────────────────────\n`));
|
|
64
|
+
// Warn if the run was dispatched by someone else
|
|
65
|
+
if (detectedDispatcher &&
|
|
66
|
+
options.currentUser &&
|
|
67
|
+
detectedDispatcher !== options.currentUser) {
|
|
68
|
+
console.log(chalk.yellowBright(`⚠️ This run was dispatched by '${detectedDispatcher}', not by you (${options.currentUser}).`));
|
|
69
|
+
}
|
|
39
70
|
}
|
|
40
71
|
const RUNNER_TIMESTAMP_REGEX = /^\uFEFF?\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z\s*/;
|
|
41
72
|
const MARKERS_TO_REMOVE = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viza",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.48",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Viza unified command line interface",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"release:full": "rm -rf dist && npx npm-check-updates -u && npm install && git add package.json package-lock.json && git commit -m 'chore(deps): auto update dependencies before release' || echo 'No changes' && node versioning.js && npm login && npm publish --tag latest --access public && git push"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@vizamodo/viza-dispatcher": "^1.5.
|
|
20
|
+
"@vizamodo/viza-dispatcher": "^1.5.27",
|
|
21
21
|
"adm-zip": "^0.5.16",
|
|
22
22
|
"chalk": "^5.6.2",
|
|
23
23
|
"clipboardy": "^5.3.1",
|