@boy-offi9-inc/tidepull 0.7.3 → 0.7.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.
- package/dist/loader.js +15 -1
- package/dist/ui/banner.d.ts +1 -1
- package/dist/ui/banner.js +43 -33
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -7,6 +7,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
import { readdir, stat } from "node:fs/promises";
|
|
10
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
10
11
|
import os from "node:os";
|
|
11
12
|
import path from "node:path";
|
|
12
13
|
import { pathToFileURL } from "node:url";
|
|
@@ -40,6 +41,18 @@ export async function loadPlugin(file) {
|
|
|
40
41
|
}
|
|
41
42
|
const FILE_RE = /\.(?:m?js|cjs|mts|ts)$/;
|
|
42
43
|
const INDEX_RE = /^index\.(?:m?js|mts|ts)$/;
|
|
44
|
+
function ensureModuleType(dir) {
|
|
45
|
+
if (process.env.TIDEPULL_NO_MODULE_FIX)
|
|
46
|
+
return;
|
|
47
|
+
const pkg = path.join(dir, "package.json");
|
|
48
|
+
if (existsSync(pkg))
|
|
49
|
+
return;
|
|
50
|
+
try {
|
|
51
|
+
writeFileSync(pkg, JSON.stringify({ type: "module" }) + "\n");
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
43
56
|
export async function loadPlugins(paths) {
|
|
44
57
|
const out = [];
|
|
45
58
|
for (const p of paths) {
|
|
@@ -50,8 +63,9 @@ export async function loadPlugins(paths) {
|
|
|
50
63
|
out.push(await loadPlugin(p));
|
|
51
64
|
continue;
|
|
52
65
|
}
|
|
66
|
+
ensureModuleType(p);
|
|
53
67
|
for (const name of (await readdir(p)).sort()) {
|
|
54
|
-
if (name.startsWith("_") || name.startsWith(".") || name.endsWith(".d.ts"))
|
|
68
|
+
if (name.startsWith("_") || name.startsWith(".") || name.endsWith(".d.ts") || name === "package.json")
|
|
55
69
|
continue;
|
|
56
70
|
const full = path.join(p, name);
|
|
57
71
|
const fs = await stat(full);
|
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