fix: put plugin descriptions under source
This commit is contained in:
@@ -135,7 +135,10 @@ export function registerPluginsCli(program: Command) {
|
|||||||
|
|
||||||
if (!opts.verbose) {
|
if (!opts.verbose) {
|
||||||
const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
|
const tableWidth = Math.max(60, (process.stdout.columns ?? 120) - 1);
|
||||||
const rows = list.map((plugin) => ({
|
const rows = list.map((plugin) => {
|
||||||
|
const desc = plugin.description ? theme.muted(plugin.description) : "";
|
||||||
|
const sourceLine = desc ? `${plugin.source}\n${desc}` : plugin.source;
|
||||||
|
return {
|
||||||
Name: plugin.name || plugin.id,
|
Name: plugin.name || plugin.id,
|
||||||
ID: plugin.name && plugin.name !== plugin.id ? plugin.id : "",
|
ID: plugin.name && plugin.name !== plugin.id ? plugin.id : "",
|
||||||
Status:
|
Status:
|
||||||
@@ -144,10 +147,10 @@ export function registerPluginsCli(program: Command) {
|
|||||||
: plugin.status === "disabled"
|
: plugin.status === "disabled"
|
||||||
? theme.warn("disabled")
|
? theme.warn("disabled")
|
||||||
: theme.error("error"),
|
: theme.error("error"),
|
||||||
Source: plugin.source,
|
Source: sourceLine,
|
||||||
Version: plugin.version ?? "",
|
Version: plugin.version ?? "",
|
||||||
Description: plugin.description ?? "",
|
};
|
||||||
}));
|
});
|
||||||
defaultRuntime.log(
|
defaultRuntime.log(
|
||||||
renderTable({
|
renderTable({
|
||||||
width: tableWidth,
|
width: tableWidth,
|
||||||
@@ -155,9 +158,8 @@ export function registerPluginsCli(program: Command) {
|
|||||||
{ key: "Name", header: "Name", minWidth: 14, flex: true },
|
{ key: "Name", header: "Name", minWidth: 14, flex: true },
|
||||||
{ key: "ID", header: "ID", minWidth: 10, flex: true },
|
{ key: "ID", header: "ID", minWidth: 10, flex: true },
|
||||||
{ key: "Status", header: "Status", minWidth: 10 },
|
{ key: "Status", header: "Status", minWidth: 10 },
|
||||||
{ key: "Source", header: "Source", minWidth: 10 },
|
{ key: "Source", header: "Source", minWidth: 26, flex: true },
|
||||||
{ key: "Version", header: "Version", minWidth: 8 },
|
{ key: "Version", header: "Version", minWidth: 8 },
|
||||||
{ key: "Description", header: "Description", minWidth: 18, flex: true },
|
|
||||||
],
|
],
|
||||||
rows,
|
rows,
|
||||||
}).trimEnd(),
|
}).trimEnd(),
|
||||||
|
|||||||
@@ -84,4 +84,21 @@ describe("renderTable", () => {
|
|||||||
throw new Error(`Unexpected escape sequence at index ${i}`);
|
throw new Error(`Unexpected escape sequence at index ${i}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("respects explicit newlines in cell values", () => {
|
||||||
|
const out = renderTable({
|
||||||
|
width: 48,
|
||||||
|
columns: [
|
||||||
|
{ key: "A", header: "A", minWidth: 6 },
|
||||||
|
{ key: "B", header: "B", minWidth: 10, flex: true },
|
||||||
|
],
|
||||||
|
rows: [{ A: "row", B: "line1\nline2" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
const lines = out.trimEnd().split("\n");
|
||||||
|
const line1Index = lines.findIndex((line) => line.includes("line1"));
|
||||||
|
const line2Index = lines.findIndex((line) => line.includes("line2"));
|
||||||
|
expect(line1Index).toBeGreaterThan(-1);
|
||||||
|
expect(line2Index).toBe(line1Index + 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -93,15 +93,9 @@ function wrapLine(text: string, width: number): string[] {
|
|||||||
|
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
const isBreakChar = (ch: string) =>
|
const isBreakChar = (ch: string) =>
|
||||||
ch === " " ||
|
ch === " " || ch === "\t" || ch === "/" || ch === "-" || ch === "_" || ch === ".";
|
||||||
ch === "\t" ||
|
|
||||||
ch === "\n" ||
|
|
||||||
ch === "\r" ||
|
|
||||||
ch === "/" ||
|
|
||||||
ch === "-" ||
|
|
||||||
ch === "_" ||
|
|
||||||
ch === ".";
|
|
||||||
const isSpaceChar = (ch: string) => ch === " " || ch === "\t";
|
const isSpaceChar = (ch: string) => ch === " " || ch === "\t";
|
||||||
|
let skipNextLf = false;
|
||||||
|
|
||||||
const buf: Token[] = [];
|
const buf: Token[] = [];
|
||||||
let bufVisible = 0;
|
let bufVisible = 0;
|
||||||
@@ -149,6 +143,15 @@ function wrapLine(text: string, width: number): string[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ch = token.value;
|
const ch = token.value;
|
||||||
|
if (skipNextLf) {
|
||||||
|
skipNextLf = false;
|
||||||
|
if (ch === "\n") continue;
|
||||||
|
}
|
||||||
|
if (ch === "\n" || ch === "\r") {
|
||||||
|
flushAt(buf.length);
|
||||||
|
if (ch === "\r") skipNextLf = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (bufVisible + 1 > width && bufVisible > 0) {
|
if (bufVisible + 1 > width && bufVisible > 0) {
|
||||||
flushAt(lastBreakIndex);
|
flushAt(lastBreakIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user