@boy-offi9-inc/tidepull 0.7.3 → 0.7.4
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/ui/banner.d.ts +1 -1
- package/dist/ui/banner.js +43 -33
- package/package.json +1 -1
package/dist/ui/banner.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Theme } from "./theme.js";
|
|
2
|
-
export declare function renderBanner(version: string, theme: Theme, color?: boolean, plugins?: string[]): string;
|
|
2
|
+
export declare function renderBanner(version: string, theme: Theme, color?: boolean, plugins?: string[], width?: number): string;
|
package/dist/ui/banner.js
CHANGED
|
@@ -28,7 +28,6 @@ function logo() {
|
|
|
28
28
|
}
|
|
29
29
|
return rows.map((r) => r.trimEnd());
|
|
30
30
|
}
|
|
31
|
-
const LOGO_COLS = 42;
|
|
32
31
|
function infoLines(version, theme, plain, plugins) {
|
|
33
32
|
const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
|
|
34
33
|
const ok = (s) => (plain ? s : theme.success + s + theme.reset);
|
|
@@ -38,47 +37,58 @@ function infoLines(version, theme, plain, plugins) {
|
|
|
38
37
|
rows.push(`${dim("plugins")} ${tag(plugins.join(", "))}`);
|
|
39
38
|
return rows;
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
function termWidth() {
|
|
41
|
+
return process.stdout.columns ?? 80;
|
|
42
|
+
}
|
|
43
|
+
const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
44
|
+
function chooseLayout(logoWidth, infoWidths, width) {
|
|
45
|
+
const maxInfo = Math.max(...infoWidths);
|
|
46
|
+
return logoWidth + 3 + maxInfo <= width - 1 ? "side" : "stack";
|
|
47
|
+
}
|
|
48
|
+
export function renderBanner(version, theme, color = true, plugins = [], width) {
|
|
42
49
|
const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
|
|
43
50
|
const paint = (c, s) => (plain ? s : c + s + theme.reset);
|
|
44
51
|
const rows = logo();
|
|
52
|
+
const logoWidth = Math.max(...rows.map((r) => r.length));
|
|
53
|
+
const info = infoLines(version, theme, plain, plugins);
|
|
54
|
+
const infoWidths = info.map(visible);
|
|
55
|
+
const w = width ?? termWidth();
|
|
56
|
+
const layout = chooseLayout(logoWidth, infoWidths, w);
|
|
57
|
+
let painted;
|
|
45
58
|
if (plain) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
painted = rows;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const stops = gradientStops(theme);
|
|
63
|
+
const starts = [0, 5, 9, 14, 19, 24, 29, 34];
|
|
64
|
+
const widths = [5, 4, 5, 5, 5, 5, 5, 5];
|
|
65
|
+
painted = ["", "", ""];
|
|
66
|
+
for (let li = 0; li < 8; li++) {
|
|
67
|
+
const c = stops[li] ?? theme.accent;
|
|
68
|
+
for (let r = 0; r < 3; r++)
|
|
69
|
+
painted[r] += paint(c, rows[r].slice(starts[li], starts[li] + widths[li]));
|
|
55
70
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return lines.join("\n");
|
|
71
|
+
for (let r = 0; r < 3; r++)
|
|
72
|
+
painted[r] = painted[r].trimEnd() + theme.reset;
|
|
59
73
|
}
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const painted = ["", "", ""];
|
|
64
|
-
for (let li = 0; li < 8; li++) {
|
|
65
|
-
const c = stops[li] ?? theme.accent;
|
|
74
|
+
const lines = [];
|
|
75
|
+
if (layout === "side") {
|
|
76
|
+
const col = logoWidth + 4;
|
|
66
77
|
for (let r = 0; r < 3; r++) {
|
|
67
|
-
|
|
78
|
+
const pad = Math.max(2, col - visible(painted[r]));
|
|
79
|
+
lines.push(painted[r] + " ".repeat(pad) + (info[r] ?? ""));
|
|
68
80
|
}
|
|
81
|
+
for (let r = 3; r < info.length; r++)
|
|
82
|
+
lines.push(" ".repeat(col + 1) + info[r]);
|
|
69
83
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const lines = [];
|
|
75
|
-
for (let r = 0; r < 3; r++) {
|
|
76
|
-
const pad = Math.max(2, LOGO_COLS - visible(painted[r]));
|
|
77
|
-
lines.push(painted[r] + " ".repeat(pad) + (info[r] ?? ""));
|
|
84
|
+
else {
|
|
85
|
+
lines.push(...painted);
|
|
86
|
+
for (const row of info)
|
|
87
|
+
lines.push(" " + row);
|
|
78
88
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
lines.push(paint(
|
|
89
|
+
const tag = plain ? "" : theme.tag;
|
|
90
|
+
const span = layout === "side" ? logoWidth + 4 + infoWidths[0] : logoWidth;
|
|
91
|
+
const waves = Math.max(6, Math.min(30, span - 1));
|
|
92
|
+
lines.push(paint(tag, " " + "≈".repeat(waves)));
|
|
83
93
|
return lines.join("\n");
|
|
84
94
|
}
|
package/package.json
CHANGED