/** * Console + GitHub Actions reporting shared by the issue reconcilers. * * Both reconcilers end the same way: an aligned table on stdout, and the same * table as Markdown in the step summary when running under Actions. */ /** Print rows[0] as a header, a rule, then the body — every column padded. */ export function printTable(rows: string[][]): void { const widths = rows[0]!.map((_, i) => Math.max(...rows.map((r) => r[i]!.length))); const render = (r: string[]) => r .map((cell, i) => cell.padEnd(widths[i]!)) .join(" ") .trimEnd(); console.log(render(rows[0]!)); console.log(widths.map((n) => "─".repeat(n)).join(" ")); for (const row of rows.slice(1)) console.log(render(row)); } /** Same rows as a GitHub-flavoured Markdown table; rows[0] is the header. */ export function markdownTable(rows: string[][]): string { const [header, ...body] = rows; return [ `| ${header!.join(" | ")} |`, `| ${header!.map(() => "---").join(" | ")} |`, ...body.map((r) => `| ${r.join(" | ")} |`), ].join("\n"); } /** Append to the Actions step summary; a no-op outside Actions. */ export async function writeStepSummary(markdown: string): Promise { const path = process.env.GITHUB_STEP_SUMMARY; if (!path) return; await Bun.write(path, markdown); }