@kb-labs/shared-cli-ui 2.46.0 → 2.53.0
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/index.cjs +62 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2269,6 +2269,8 @@ function toPosixPath(input) {
|
|
|
2269
2269
|
function sideBorderBox(options) {
|
|
2270
2270
|
const { title, sections, footer, status, timing } = options;
|
|
2271
2271
|
const lines = [];
|
|
2272
|
+
const terminalWidth = typeof process !== "undefined" && process.stdout?.columns ? process.stdout.columns : 80;
|
|
2273
|
+
const itemMaxWidth = Math.max(40, terminalWidth - 4);
|
|
2272
2274
|
const titleLine = `${safeSymbols.topLeft}${safeSymbols.separator.repeat(2)} ${safeColors.primary(safeColors.bold(title))}`;
|
|
2273
2275
|
lines.push(titleLine);
|
|
2274
2276
|
lines.push(safeSymbols.border);
|
|
@@ -2280,8 +2282,20 @@ function sideBorderBox(options) {
|
|
|
2280
2282
|
if (section2.header) {
|
|
2281
2283
|
lines.push(`${safeSymbols.border} ${safeColors.bold(section2.header)}`);
|
|
2282
2284
|
}
|
|
2283
|
-
for (const
|
|
2284
|
-
|
|
2285
|
+
for (const rawItem of section2.items) {
|
|
2286
|
+
const item = typeof rawItem === "string" ? { text: rawItem } : rawItem;
|
|
2287
|
+
let displayLines;
|
|
2288
|
+
if (item.truncate !== void 0) {
|
|
2289
|
+
const vis = stripAnsi(item.text);
|
|
2290
|
+
const truncated = vis.length > item.truncate ? vis.slice(0, item.truncate - 1) + "\u2026" : vis;
|
|
2291
|
+
displayLines = [item.dim ? safeColors.muted(truncated) : truncated];
|
|
2292
|
+
} else {
|
|
2293
|
+
const wrapped = wrapText(item.text, itemMaxWidth);
|
|
2294
|
+
displayLines = item.dim ? wrapped.map((l) => safeColors.muted(l)) : wrapped;
|
|
2295
|
+
}
|
|
2296
|
+
for (const dl of displayLines) {
|
|
2297
|
+
lines.push(`${safeSymbols.border} ${dl}`);
|
|
2298
|
+
}
|
|
2285
2299
|
}
|
|
2286
2300
|
if (i < sections.length - 1) {
|
|
2287
2301
|
lines.push(safeSymbols.border);
|
|
@@ -2373,6 +2387,51 @@ function getStatusColor(status) {
|
|
|
2373
2387
|
return safeColors.info;
|
|
2374
2388
|
}
|
|
2375
2389
|
}
|
|
2390
|
+
function wrapText(text, maxWidth) {
|
|
2391
|
+
const result = [];
|
|
2392
|
+
const rawLines = text.split("\n");
|
|
2393
|
+
for (const rawLine of rawLines) {
|
|
2394
|
+
const line = rawLine.trimEnd();
|
|
2395
|
+
if (stripAnsi(line).length <= maxWidth) {
|
|
2396
|
+
result.push(line);
|
|
2397
|
+
continue;
|
|
2398
|
+
}
|
|
2399
|
+
const words = line.split(/(\s+)/);
|
|
2400
|
+
let current = "";
|
|
2401
|
+
for (const word of words) {
|
|
2402
|
+
const test = current + word;
|
|
2403
|
+
if (stripAnsi(test).length <= maxWidth) {
|
|
2404
|
+
current = test;
|
|
2405
|
+
} else {
|
|
2406
|
+
if (current.trimEnd()) {
|
|
2407
|
+
result.push(current.trimEnd());
|
|
2408
|
+
}
|
|
2409
|
+
const wordLen = stripAnsi(word).length;
|
|
2410
|
+
if (wordLen > maxWidth) {
|
|
2411
|
+
result.push(stripAnsi(word).slice(0, maxWidth - 1) + "\u2026");
|
|
2412
|
+
current = "";
|
|
2413
|
+
} else {
|
|
2414
|
+
current = word;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
if (current.trimEnd()) {
|
|
2419
|
+
result.push(current.trimEnd());
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
return result.length > 0 ? result : [""];
|
|
2423
|
+
}
|
|
2424
|
+
function formatError(err, opts) {
|
|
2425
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
2426
|
+
const allLines = raw.split("\n").map((l) => l.trimEnd()).filter((l) => l.length > 0);
|
|
2427
|
+
const max = opts?.maxLines ?? 8;
|
|
2428
|
+
if (allLines.length <= max) {
|
|
2429
|
+
return allLines;
|
|
2430
|
+
}
|
|
2431
|
+
const shown = allLines.slice(0, max - 1);
|
|
2432
|
+
shown.push(safeColors.muted(`\u2026 ${allLines.length - max + 1} more lines`));
|
|
2433
|
+
return shown;
|
|
2434
|
+
}
|
|
2376
2435
|
function formatCommandHelp(options) {
|
|
2377
2436
|
const { title, description, longDescription, examples, flags, aliases } = options;
|
|
2378
2437
|
const sections = [];
|
|
@@ -2581,6 +2640,7 @@ exports.formatDebugEntryAI = formatDebugEntryAI;
|
|
|
2581
2640
|
exports.formatDebugEntryHuman = formatDebugEntryHuman;
|
|
2582
2641
|
exports.formatDebugOutput = formatDebugOutput;
|
|
2583
2642
|
exports.formatDebugOutputs = formatDebugOutputs;
|
|
2643
|
+
exports.formatError = formatError;
|
|
2584
2644
|
exports.formatKeyValueTable = formatKeyValueTable;
|
|
2585
2645
|
exports.formatRelativeTime = formatRelativeTime;
|
|
2586
2646
|
exports.formatSize = formatSize;
|