@boy-offi9-inc/tidepull 0.7.2 → 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/main.js +5 -3
- package/dist/ui/banner.d.ts +1 -1
- package/dist/ui/banner.js +50 -24
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -181,9 +181,7 @@ export async function main(argv) {
|
|
|
181
181
|
return 2;
|
|
182
182
|
}
|
|
183
183
|
const machineMode = values.quiet || values["dump-json"] || values["get-url"] || values.simulate || values["progress-json"];
|
|
184
|
-
|
|
185
|
-
process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor()) + "\n");
|
|
186
|
-
}
|
|
184
|
+
const showBanner = process.stdout.isTTY && !machineMode;
|
|
187
185
|
const log = new Logger({
|
|
188
186
|
quiet: values.quiet,
|
|
189
187
|
verbose: values.verbose,
|
|
@@ -238,6 +236,10 @@ export async function main(argv) {
|
|
|
238
236
|
log.error(errMsg(e));
|
|
239
237
|
return e instanceof TidepullError ? e.exitCode : 1;
|
|
240
238
|
}
|
|
239
|
+
if (showBanner) {
|
|
240
|
+
const pluginNames = plugins.map((p) => p.name);
|
|
241
|
+
process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor(), pluginNames) + "\n");
|
|
242
|
+
}
|
|
241
243
|
const tp = createTidepull({
|
|
242
244
|
http: { headers, headerHosts: values["header-host"] ?? [], userAgent: values["user-agent"], retries: num(values.retries, 3), cookies },
|
|
243
245
|
plugins: [...plugins, dash, feeds],
|
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): string;
|
|
2
|
+
export declare function renderBanner(version: string, theme: Theme, color?: boolean, plugins?: string[], width?: number): string;
|
package/dist/ui/banner.js
CHANGED
|
@@ -28,41 +28,67 @@ function logo() {
|
|
|
28
28
|
}
|
|
29
29
|
return rows.map((r) => r.trimEnd());
|
|
30
30
|
}
|
|
31
|
-
function infoLines(version, theme, plain) {
|
|
31
|
+
function infoLines(version, theme, plain, plugins) {
|
|
32
32
|
const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
|
|
33
33
|
const ok = (s) => (plain ? s : theme.success + s + theme.reset);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`${dim("
|
|
38
|
-
|
|
34
|
+
const tag = (s) => (plain ? s : theme.tag + s + theme.reset);
|
|
35
|
+
const rows = [dim("media downloader"), `${dim("version")} ${ok(`v${version}`)}`, `${dim("stdout")} ${ok("data only")}`];
|
|
36
|
+
if (plugins.length)
|
|
37
|
+
rows.push(`${dim("plugins")} ${tag(plugins.join(", "))}`);
|
|
38
|
+
return rows;
|
|
39
39
|
}
|
|
40
|
-
|
|
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) {
|
|
41
49
|
const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
|
|
42
50
|
const paint = (c, s) => (plain ? s : c + s + theme.reset);
|
|
43
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;
|
|
44
58
|
if (plain) {
|
|
45
|
-
|
|
46
|
-
return rows.join("\n");
|
|
59
|
+
painted = rows;
|
|
47
60
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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]));
|
|
56
70
|
}
|
|
71
|
+
for (let r = 0; r < 3; r++)
|
|
72
|
+
painted[r] = painted[r].trimEnd() + theme.reset;
|
|
57
73
|
}
|
|
58
|
-
for (let r = 0; r < 3; r++)
|
|
59
|
-
painted[r] = painted[r].trimEnd() + theme.reset;
|
|
60
|
-
const info = infoLines(version, theme, plain);
|
|
61
|
-
const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
62
74
|
const lines = [];
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
75
|
+
if (layout === "side") {
|
|
76
|
+
const col = logoWidth + 4;
|
|
77
|
+
for (let r = 0; r < 3; r++) {
|
|
78
|
+
const pad = Math.max(2, col - visible(painted[r]));
|
|
79
|
+
lines.push(painted[r] + " ".repeat(pad) + (info[r] ?? ""));
|
|
80
|
+
}
|
|
81
|
+
for (let r = 3; r < info.length; r++)
|
|
82
|
+
lines.push(" ".repeat(col + 1) + info[r]);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
lines.push(...painted);
|
|
86
|
+
for (const row of info)
|
|
87
|
+
lines.push(" " + row);
|
|
66
88
|
}
|
|
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)));
|
|
67
93
|
return lines.join("\n");
|
|
68
94
|
}
|
package/package.json
CHANGED