viza 1.8.45 → 1.8.49
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/src/commands/dispatch/logs/logs.js +1 -1
- package/dist/src/commands/dispatch/runs/show-runs.js +6 -3
- package/dist/src/commands/github/secrets/restore/restore.js +8 -8
- package/dist/src/commands/infra/deploy/command-hub/command-hub.js +1 -1
- package/dist/src/context/hubIntent.js +4 -1
- package/dist/src/context/resolveBinaryContext.js +1 -1
- package/dist/src/core/dispatch.js +27 -6
- package/dist/src/core/version.js +2 -2
- package/dist/src/ui/banner.js +4 -4
- package/dist/src/ui/index.js +3 -3
- package/dist/src/ui/infraLogRenderer.js +5 -5
- package/package.json +2 -2
|
@@ -13,7 +13,7 @@ import { policy } from "./policy.js";
|
|
|
13
13
|
export async function logsCommand(runId, options) {
|
|
14
14
|
// 1️⃣ Resolve environment
|
|
15
15
|
const env = getEnv();
|
|
16
|
-
const intent = resolveHubIntent();
|
|
16
|
+
const intent = resolveHubIntent(false);
|
|
17
17
|
// Resolve allowed teams (same contract as other commands)
|
|
18
18
|
const allowedTeams = Array.from(policy.byEnv[env]);
|
|
19
19
|
// 3️⃣ Dispatch intent to hub
|
|
@@ -94,8 +94,8 @@ export async function showDispatchRuns(result) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
else if (run.status === "in_progress") {
|
|
97
|
-
status = "
|
|
98
|
-
conclusion = "
|
|
97
|
+
status = "⏳ in progress";
|
|
98
|
+
conclusion = "...";
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
101
|
status = "⏳ queued";
|
|
@@ -124,7 +124,10 @@ export async function showDispatchRuns(result) {
|
|
|
124
124
|
console.log();
|
|
125
125
|
// Hint section
|
|
126
126
|
if (runs.length > 0) {
|
|
127
|
-
const
|
|
127
|
+
const [firstRun] = runs;
|
|
128
|
+
if (!firstRun)
|
|
129
|
+
return;
|
|
130
|
+
const firstRunId = firstRun.id;
|
|
128
131
|
// derive binary name from process.argv (fallback safe)
|
|
129
132
|
const bin = (process.argv[1] || "viza").split("/").pop();
|
|
130
133
|
const sampleCmd = `${bin} dispatch logs ${firstRunId}`;
|
|
@@ -23,20 +23,20 @@ export async function restoreGithubSecretsCommand(options) {
|
|
|
23
23
|
// Resolve domain restore flags (forward to hub)
|
|
24
24
|
const payload = {};
|
|
25
25
|
if (options.all) {
|
|
26
|
-
payload
|
|
27
|
-
payload
|
|
28
|
-
payload
|
|
29
|
-
payload
|
|
26
|
+
payload["core"] = true;
|
|
27
|
+
payload["infra"] = true;
|
|
28
|
+
payload["builder"] = true;
|
|
29
|
+
payload["deployer"] = true;
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
if (options.core)
|
|
33
|
-
payload
|
|
33
|
+
payload["core"] = true;
|
|
34
34
|
if (options.infra)
|
|
35
|
-
payload
|
|
35
|
+
payload["infra"] = true;
|
|
36
36
|
if (options.builder)
|
|
37
|
-
payload
|
|
37
|
+
payload["builder"] = true;
|
|
38
38
|
if (options.deployer)
|
|
39
|
-
payload
|
|
39
|
+
payload["deployer"] = true;
|
|
40
40
|
}
|
|
41
41
|
// Fail fast if no domain flags were provided
|
|
42
42
|
if (Object.keys(payload).length === 0) {
|
|
@@ -15,7 +15,7 @@ import { policy } from "./policy.js";
|
|
|
15
15
|
export async function deployCommandHubCommand(options) {
|
|
16
16
|
// 1) Resolve environment from global CLI context
|
|
17
17
|
const env = getEnv();
|
|
18
|
-
const intent = resolveHubIntent();
|
|
18
|
+
const intent = resolveHubIntent(options.selfHosted === true);
|
|
19
19
|
// Resolve allowed teams for the current environment only.
|
|
20
20
|
// CLI performs a fail-fast UX check but must still respect env boundaries.
|
|
21
21
|
const allowedTeams = Array.from(policy.byEnv[env]);
|
|
@@ -23,7 +23,10 @@ const RESOURCE_BUILDER_INTENT_BY_ENV = "builder";
|
|
|
23
23
|
* Single intent for both dev and prod (env derived at gateway)
|
|
24
24
|
*/
|
|
25
25
|
const RUNTIME_HUB_INTENT = "hub-worker";
|
|
26
|
-
export function resolveHubIntent() {
|
|
26
|
+
export function resolveHubIntent(selfHosted) {
|
|
27
|
+
if (selfHosted) {
|
|
28
|
+
return RESOURCE_HUB_INTENT_BY_ENV;
|
|
29
|
+
}
|
|
27
30
|
const r = currentRunner;
|
|
28
31
|
switch (r) {
|
|
29
32
|
case "builder":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
export function resolveBinaryContext() {
|
|
3
|
-
const bin = path.basename(process.argv[1]);
|
|
3
|
+
const bin = path.basename(process.argv[1] ?? "");
|
|
4
4
|
const env = bin.startsWith("xviza") ? "prod" : "dev";
|
|
5
5
|
let runner = "hub";
|
|
6
6
|
if (bin.includes("builder"))
|
|
@@ -26,7 +26,12 @@ function maybeRenderLog(result, policy, currentUser) {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
if (result.logBuffer) {
|
|
29
|
-
|
|
29
|
+
const conclusion = result.status;
|
|
30
|
+
const logOptions = {
|
|
31
|
+
conclusion,
|
|
32
|
+
...(currentUser !== undefined ? { currentUser } : {})
|
|
33
|
+
};
|
|
34
|
+
renderLog(result.logBuffer, logOptions);
|
|
30
35
|
return;
|
|
31
36
|
}
|
|
32
37
|
// Log artifact not available (likely GitHub log archive not ready yet)
|
|
@@ -98,8 +103,8 @@ async function dispatchIntent(input, mode = "dispatch") {
|
|
|
98
103
|
infraKey: input.infraKey,
|
|
99
104
|
payload: input.payload,
|
|
100
105
|
runnerLabel: input.selfHosted ? "selfhosted" : "native",
|
|
101
|
-
keepLog: input.keepLog,
|
|
102
|
-
flowGates: input.flowGates,
|
|
106
|
+
...(input.keepLog !== undefined ? { keepLog: input.keepLog } : {}),
|
|
107
|
+
...(input.flowGates !== undefined ? { flowGates: input.flowGates } : {}),
|
|
103
108
|
};
|
|
104
109
|
// CLI fail-fast: never dispatch dirty envelope
|
|
105
110
|
assertDispatchInputStrict(dispatchInput);
|
|
@@ -141,11 +146,27 @@ export async function dispatchIntentAndWait(input, opts = {}) {
|
|
|
141
146
|
]) // Ép kiểu tại đây
|
|
142
147
|
]);
|
|
143
148
|
// 4. Dừng spinner và in kết quả dispatch trước
|
|
144
|
-
|
|
149
|
+
const conclusion = result.kind === "github" ? result.status : undefined;
|
|
150
|
+
const message = result.kind === "github"
|
|
151
|
+
? conclusion === "success"
|
|
152
|
+
? chalk.green("✅ Done")
|
|
153
|
+
: conclusion === "failure"
|
|
154
|
+
? chalk.red("❌ Failed")
|
|
155
|
+
: chalk.yellow("⚠️ Completed")
|
|
156
|
+
: result.status === "success"
|
|
157
|
+
? chalk.green("✅ Done")
|
|
158
|
+
: chalk.red("❌ Failed");
|
|
159
|
+
stopSpinner(spinner, message);
|
|
145
160
|
// 5. Render log và thông báo update
|
|
146
161
|
maybeRenderLog(result, policy, currentUser);
|
|
147
|
-
|
|
148
|
-
|
|
162
|
+
const isSuccess = result.kind === "github"
|
|
163
|
+
? result.status === "success"
|
|
164
|
+
: result.status === "success";
|
|
165
|
+
if (!isSuccess) {
|
|
166
|
+
const reason = result.kind === "github"
|
|
167
|
+
? result.status
|
|
168
|
+
: result.status;
|
|
169
|
+
throw new Error(`Dispatch failed: ${reason}`);
|
|
149
170
|
}
|
|
150
171
|
if (updateInfo?.hasUpdate) {
|
|
151
172
|
renderUpdateHint(updateInfo);
|
package/dist/src/core/version.js
CHANGED
|
@@ -13,7 +13,7 @@ let _cached;
|
|
|
13
13
|
export function getCliVersion() {
|
|
14
14
|
if (_cached)
|
|
15
15
|
return _cached;
|
|
16
|
-
const injected = process.env
|
|
16
|
+
const injected = process.env["VIZA_CLI_VERSION"];
|
|
17
17
|
if (injected && injected.trim()) {
|
|
18
18
|
_cached = injected.trim();
|
|
19
19
|
return _cached;
|
|
@@ -49,7 +49,7 @@ export function getCliVersion() {
|
|
|
49
49
|
}
|
|
50
50
|
function resolveVizaConfigDir() {
|
|
51
51
|
if (process.platform === "win32") {
|
|
52
|
-
const appData = process.env
|
|
52
|
+
const appData = process.env["APPDATA"] || join(process.env["USERPROFILE"] || "", "AppData", "Roaming");
|
|
53
53
|
return join(appData, "viza");
|
|
54
54
|
}
|
|
55
55
|
else {
|
package/dist/src/ui/banner.js
CHANGED
|
@@ -29,7 +29,7 @@ export function showDispatchBanner(input, meta, status) {
|
|
|
29
29
|
commandType,
|
|
30
30
|
color: cfg.color,
|
|
31
31
|
env: input.targetEnv,
|
|
32
|
-
status,
|
|
32
|
+
...(status !== undefined ? { status } : {}),
|
|
33
33
|
intent: input.intent,
|
|
34
34
|
runner: input.selfHosted
|
|
35
35
|
? {
|
|
@@ -37,9 +37,9 @@ export function showDispatchBanner(input, meta, status) {
|
|
|
37
37
|
label: "viza-builder",
|
|
38
38
|
} :
|
|
39
39
|
{ type: "github" },
|
|
40
|
-
meta
|
|
41
|
-
version: meta
|
|
42
|
-
|
|
40
|
+
...(meta?.cliVersion !== undefined
|
|
41
|
+
? { meta: { version: meta.cliVersion } }
|
|
42
|
+
: {})
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
export function showBanner(opts) {
|
package/dist/src/ui/index.js
CHANGED
|
@@ -10,13 +10,13 @@ export function beginUi(opts) {
|
|
|
10
10
|
if (opts.spinnerMessage) {
|
|
11
11
|
spinner = startSpinner(opts.spinnerMessage);
|
|
12
12
|
}
|
|
13
|
-
return { spinner };
|
|
13
|
+
return spinner !== undefined ? { spinner } : {};
|
|
14
14
|
}
|
|
15
15
|
export function endUi(session, opts) {
|
|
16
16
|
if (session.spinner) {
|
|
17
17
|
stopSpinner(session.spinner, opts?.finalMessage);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export function renderArtifactLog(buffer,
|
|
21
|
-
renderLog(buffer, {
|
|
20
|
+
export function renderArtifactLog(buffer, conclusion) {
|
|
21
|
+
renderLog(buffer, { conclusion });
|
|
22
22
|
}
|
|
@@ -53,15 +53,15 @@ export function renderLog(zipBuffer, options) {
|
|
|
53
53
|
}
|
|
54
54
|
// Print final status banner
|
|
55
55
|
// Chuyển về lowercase ngay từ đầu, mặc định là "unknown" nếu undefined
|
|
56
|
-
const
|
|
56
|
+
const conclusion = (options.conclusion?.toString() || "unknown").toLowerCase();
|
|
57
57
|
let color = chalk.gray;
|
|
58
|
-
if (
|
|
58
|
+
if (conclusion === "success")
|
|
59
59
|
color = chalk.greenBright;
|
|
60
|
-
else if (
|
|
60
|
+
else if (conclusion === "failure" || conclusion === "failed")
|
|
61
61
|
color = chalk.redBright;
|
|
62
|
-
else
|
|
62
|
+
else
|
|
63
63
|
color = chalk.yellowBright;
|
|
64
|
-
console.log(color(`\n────── DEPLOY STATUS: ${String(
|
|
64
|
+
console.log(color(`\n────── DEPLOY STATUS: ${String(conclusion).toUpperCase()} ─────────────────────────────────────────────────────────────────────────────────────────────\n`));
|
|
65
65
|
// Warn if the run was dispatched by someone else
|
|
66
66
|
if (detectedDispatcher &&
|
|
67
67
|
options.currentUser &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viza",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Viza unified command line interface",
|
|
6
6
|
"bin": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"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"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@vizamodo/viza-dispatcher": "^1.5.
|
|
25
|
+
"@vizamodo/viza-dispatcher": "^1.5.36",
|
|
26
26
|
"adm-zip": "^0.5.16",
|
|
27
27
|
"chalk": "^5.6.2",
|
|
28
28
|
"clipboardy": "^5.3.1",
|