viza 1.8.38 ā 1.8.39
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,3 +1,14 @@
|
|
|
1
|
+
import { renderCommandInline } from "../../../ui/primitives/render-command.js";
|
|
2
|
+
function formatDateTime(iso) {
|
|
3
|
+
const d = new Date(iso);
|
|
4
|
+
const yyyy = d.getFullYear();
|
|
5
|
+
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
6
|
+
const dd = String(d.getDate()).padStart(2, "0");
|
|
7
|
+
const hh = String(d.getHours()).padStart(2, "0");
|
|
8
|
+
const mi = String(d.getMinutes()).padStart(2, "0");
|
|
9
|
+
const ss = String(d.getSeconds()).padStart(2, "0");
|
|
10
|
+
return `${yyyy}-${mm}-${dd} ${hh}:${mi}:${ss}`;
|
|
11
|
+
}
|
|
1
12
|
function formatAge(iso) {
|
|
2
13
|
const diff = Date.now() - new Date(iso).getTime();
|
|
3
14
|
const sec = Math.floor(diff / 1000);
|
|
@@ -43,18 +54,19 @@ export async function showDispatchRuns(result) {
|
|
|
43
54
|
throw new Error("invalid_dispatch_runs_result_shape");
|
|
44
55
|
}
|
|
45
56
|
console.log("\nš Dispatch Runs");
|
|
46
|
-
console.log("ā".repeat(
|
|
57
|
+
console.log("ā".repeat(150));
|
|
47
58
|
const header = [
|
|
48
59
|
pad("RUN", 15),
|
|
49
60
|
pad("STATUS", 18),
|
|
50
61
|
pad("CONCLUSION", 15),
|
|
51
62
|
pad("COMMITTER", 38),
|
|
63
|
+
pad("CREATED_AT", 25),
|
|
52
64
|
pad("AGE", 12),
|
|
53
65
|
pad("DURATION", 12),
|
|
54
66
|
"ATTEMPT",
|
|
55
67
|
].join(" ");
|
|
56
68
|
console.log(header);
|
|
57
|
-
console.log("ā".repeat(
|
|
69
|
+
console.log("ā".repeat(150));
|
|
58
70
|
for (const run of runs) {
|
|
59
71
|
let status;
|
|
60
72
|
let conclusion;
|
|
@@ -100,12 +112,27 @@ export async function showDispatchRuns(result) {
|
|
|
100
112
|
pad(status, 18),
|
|
101
113
|
pad(conclusion, 14),
|
|
102
114
|
pad(committer, 38),
|
|
115
|
+
pad(formatDateTime(run.createdAt), 25),
|
|
103
116
|
pad(age, 12),
|
|
104
117
|
pad(duration, 12),
|
|
105
118
|
`#${run.attempt}`,
|
|
106
119
|
].join(" ");
|
|
107
120
|
console.log(row);
|
|
108
121
|
}
|
|
109
|
-
console.log("ā".repeat(
|
|
122
|
+
console.log("ā".repeat(150));
|
|
110
123
|
console.log();
|
|
124
|
+
// Hint section
|
|
125
|
+
if (runs.length > 0) {
|
|
126
|
+
const firstRunId = runs[0].id;
|
|
127
|
+
// derive binary name from process.argv (fallback safe)
|
|
128
|
+
const bin = (process.argv[1] || "viza").split("/").pop();
|
|
129
|
+
const sampleCmd = `${bin} dispatch logs ${firstRunId}`;
|
|
130
|
+
console.log();
|
|
131
|
+
console.log("š” " + "\x1b[1mQuick Hint\x1b[0m");
|
|
132
|
+
console.log(" š Usage:");
|
|
133
|
+
console.log(` ${renderCommandInline(`${bin} dispatch logs <runId>`)}`);
|
|
134
|
+
console.log(" š Example:");
|
|
135
|
+
console.log(` ${renderCommandInline(sampleCmd)}`);
|
|
136
|
+
console.log();
|
|
137
|
+
}
|
|
111
138
|
}
|
package/dist/src/ui/banner.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import figlet from "figlet";
|
|
3
3
|
import { getCommand } from "../context/command.js";
|
|
4
|
+
import { renderCommandInline } from "./primitives/render-command.js";
|
|
4
5
|
const ENV_BANNER_CONFIG = {
|
|
5
6
|
"dev": { title: "Viza Development", color: "gray" },
|
|
6
7
|
"prod": { title: "Viza Production", color: "yellow" },
|
|
@@ -41,44 +42,6 @@ export function showDispatchBanner(input, meta, status) {
|
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
function formatCommandTokens(cmd, maxLen = 90) {
|
|
45
|
-
const tokens = cmd.trim().split(/\s+/);
|
|
46
|
-
const kept = [];
|
|
47
|
-
let length = 0;
|
|
48
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
49
|
-
const t = tokens[i];
|
|
50
|
-
const addLen = (kept.length ? 1 : 0) + t.length; // space + token
|
|
51
|
-
if (length + addLen > maxLen)
|
|
52
|
-
break;
|
|
53
|
-
kept.push(t);
|
|
54
|
-
length += addLen;
|
|
55
|
-
}
|
|
56
|
-
const remaining = tokens.length - kept.length;
|
|
57
|
-
return { kept, remaining };
|
|
58
|
-
}
|
|
59
|
-
function renderCommand(cmd, status) {
|
|
60
|
-
const { kept, remaining } = formatCommandTokens(cmd, 102);
|
|
61
|
-
// semantic highlight: [bin] [subcommand] [rest...]
|
|
62
|
-
const main = kept[0] ?? "";
|
|
63
|
-
const sub = kept[1];
|
|
64
|
-
const rest = kept.slice(2);
|
|
65
|
-
const parts = [];
|
|
66
|
-
if (main)
|
|
67
|
-
parts.push(chalk.magentaBright(main));
|
|
68
|
-
if (sub)
|
|
69
|
-
parts.push(chalk.yellowBright(sub));
|
|
70
|
-
if (rest.length)
|
|
71
|
-
parts.push(chalk.cyan(rest.join(" ")));
|
|
72
|
-
let line = parts.join(" ");
|
|
73
|
-
if (remaining > 0) {
|
|
74
|
-
line += chalk.gray(` ⦠(+${remaining} more)`);
|
|
75
|
-
}
|
|
76
|
-
return [
|
|
77
|
-
chalk.gray("Command:"),
|
|
78
|
-
line,
|
|
79
|
-
status ? chalk.gray("[status checking]") : "",
|
|
80
|
-
].join(" ");
|
|
81
|
-
}
|
|
82
45
|
export function showBanner(opts) {
|
|
83
46
|
const { title, commandType, status, color = "cyanBright", intent, runner, meta } = opts;
|
|
84
47
|
process.stdout.write("\u001b[2J\u001b[3J\u001b[H");
|
|
@@ -90,7 +53,7 @@ export function showBanner(opts) {
|
|
|
90
53
|
const bannerText = figlet.textSync(title, { font });
|
|
91
54
|
console.log(chalk[color](bannerText));
|
|
92
55
|
if (commandType) {
|
|
93
|
-
console.log(
|
|
56
|
+
console.log(chalk.gray("Command:"), renderCommandInline(commandType), status ? chalk.gray("[status checking]") : "");
|
|
94
57
|
}
|
|
95
58
|
// Environment line removed; replaced by user-friendly info line below
|
|
96
59
|
if (runner) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function formatCommandTokens(cmd, maxLen = 100) {
|
|
3
|
+
const tokens = cmd.trim().split(/\s+/);
|
|
4
|
+
const kept = [];
|
|
5
|
+
let length = 0;
|
|
6
|
+
for (const t of tokens) {
|
|
7
|
+
const addLen = (kept.length ? 1 : 0) + t.length;
|
|
8
|
+
if (length + addLen > maxLen)
|
|
9
|
+
break;
|
|
10
|
+
kept.push(t);
|
|
11
|
+
length += addLen;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
kept,
|
|
15
|
+
remaining: tokens.length - kept.length,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function renderCommandInline(cmd) {
|
|
19
|
+
const { kept, remaining } = formatCommandTokens(cmd);
|
|
20
|
+
const main = kept[0];
|
|
21
|
+
const sub = kept[1];
|
|
22
|
+
const rest = kept.slice(2);
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (main)
|
|
25
|
+
parts.push(chalk.magentaBright(main));
|
|
26
|
+
if (sub)
|
|
27
|
+
parts.push(chalk.yellowBright(sub));
|
|
28
|
+
if (rest.length)
|
|
29
|
+
parts.push(chalk.cyan(rest.join(" ")));
|
|
30
|
+
let line = parts.join(" ");
|
|
31
|
+
if (remaining > 0) {
|
|
32
|
+
line += chalk.gray(` ⦠(+${remaining} more)`);
|
|
33
|
+
}
|
|
34
|
+
return line;
|
|
35
|
+
}
|