viza 1.9.2 → 1.9.5

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.
@@ -1,7 +1,7 @@
1
1
  export function getGlobalOptions() {
2
2
  return [
3
3
  { flags: "--status", description: "Show status only (no execution)" },
4
- { flags: "--remove-log", description: "Remove execution logs after completion" },
4
+ { flags: "--remove-log", description: "Remove execution logs after completion", defaultValue: true },
5
5
  { flags: "--self-hosted", description: "Use self-hosted runner (viza-builder)" }
6
6
  ];
7
7
  }
@@ -52,6 +52,7 @@ export async function createProgram() {
52
52
  }
53
53
  process.exit(1);
54
54
  });
55
+ const argRegistry = new WeakMap();
55
56
  const walk = (nodes, parent) => {
56
57
  for (const node of nodes) {
57
58
  const name = node.command.split(" ").pop(); // chỉ lấy tên cuối
@@ -62,15 +63,19 @@ export async function createProgram() {
62
63
  sub.description(node.description || "");
63
64
  parent.addCommand(sub);
64
65
  }
66
+ if (!argRegistry.has(sub)) {
67
+ argRegistry.set(sub, new Set());
68
+ }
65
69
  // Bind positional arguments from descriptor (must run even if sub already exists)
66
70
  if (node.args?.length) {
67
71
  for (const arg of node.args) {
68
72
  const syntax = arg.required
69
73
  ? `<${arg.name}>`
70
74
  : `[${arg.name}]`;
71
- const exists = sub._args?.some((a) => a.name === arg.name);
72
- if (!exists) {
75
+ const registry = argRegistry.get(sub);
76
+ if (!registry.has(arg.name)) {
73
77
  sub.argument(syntax, arg.description);
78
+ registry.add(arg.name);
74
79
  }
75
80
  }
76
81
  }
@@ -27,9 +27,16 @@ function maybeRenderLog(result, policy, currentUser) {
27
27
  }
28
28
  if (result.logBuffer) {
29
29
  const conclusion = result.conclusion;
30
+ const log = result.log;
30
31
  const logOptions = {
31
32
  conclusion,
32
- ...(currentUser !== undefined ? { currentUser } : {})
33
+ ...(currentUser !== undefined ? { currentUser } : {}),
34
+ ...(log?.triggeredAt !== undefined ? { triggeredAt: log.triggeredAt } : {}),
35
+ ...(log?.startedAt !== undefined ? { startedAt: log.startedAt } : {}),
36
+ ...(log?.completedAt !== undefined ? { completedAt: log.completedAt } : {}),
37
+ ...(log?.queueDuration !== undefined ? { queueDuration: log.queueDuration } : {}),
38
+ ...(log?.runDuration !== undefined ? { runDuration: log.runDuration } : {}),
39
+ ...(log?.duration !== undefined ? { duration: log.duration } : {}),
33
40
  };
34
41
  renderLog(result.logBuffer, logOptions);
35
42
  return;
@@ -1,7 +1,6 @@
1
1
  // public exports (optional)
2
2
  import { showBanner } from "./banner.js";
3
3
  import { startSpinner, stopSpinner } from "./spinner.js";
4
- import { renderLog } from "./infraLogRenderer.js";
5
4
  export function beginUi(opts) {
6
5
  if (opts.banner) {
7
6
  showBanner(opts.banner);
@@ -17,6 +16,3 @@ export function endUi(session, opts) {
17
16
  stopSpinner(session.spinner, opts?.finalMessage);
18
17
  }
19
18
  }
20
- export function renderArtifactLog(buffer, conclusion) {
21
- renderLog(buffer, { conclusion });
22
- }
@@ -51,6 +51,37 @@ export function renderLog(zipBuffer, options) {
51
51
  catch {
52
52
  // ignore parsing errors
53
53
  }
54
+ // Render timeline summary (if available)
55
+ if (options.startedAt || options.duration) {
56
+ const started = options.startedAt
57
+ ? (() => {
58
+ try {
59
+ const d = new Date(options.startedAt);
60
+ const formatted = d.toLocaleString(undefined, {
61
+ weekday: "short",
62
+ year: "numeric",
63
+ month: "short",
64
+ day: "2-digit",
65
+ hour: "2-digit",
66
+ minute: "2-digit",
67
+ hour12: false
68
+ });
69
+ return chalk.yellow(formatted);
70
+ }
71
+ catch {
72
+ return chalk.yellow(options.startedAt);
73
+ }
74
+ })()
75
+ : chalk.gray("unknown");
76
+ const duration = options.duration
77
+ ? chalk.yellow(options.duration)
78
+ : chalk.gray("unknown");
79
+ console.log(chalk.gray("\n\n────── ") +
80
+ chalk.gray("started:") + " " + started +
81
+ chalk.gray(" ────── ") +
82
+ chalk.gray("duration:") + " " + duration +
83
+ chalk.gray(" ─────────────────────────────────────────────────────────────"));
84
+ }
54
85
  // Print final status banner
55
86
  // Chuyển về lowercase ngay từ đầu, mặc định là "unknown" nếu undefined
56
87
  const conclusion = (options.conclusion?.toString() || "unknown").toLowerCase();
@@ -61,7 +92,7 @@ export function renderLog(zipBuffer, options) {
61
92
  color = chalk.redBright;
62
93
  else
63
94
  color = chalk.yellowBright;
64
- console.log(color(`\n────── DEPLOY STATUS: ${String(conclusion).toUpperCase()} ─────────────────────────────────────────────────────────────────────────────────────────────\n`));
95
+ console.log(color(`\n────── DEPLOY STATUS: ${String(conclusion).toUpperCase()} ────────────────────────────────────────────────────────────────────────────────────────────────\n`));
65
96
  // Warn if the run was dispatched by someone else
66
97
  if (detectedDispatcher &&
67
98
  options.currentUser &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viza",
3
- "version": "1.9.2",
3
+ "version": "1.9.5",
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.39",
25
+ "@vizamodo/viza-dispatcher": "^1.5.45",
26
26
  "adm-zip": "^0.5.16",
27
27
  "chalk": "^5.6.2",
28
28
  "clipboardy": "^5.3.1",