diff --git a/scripts/src/gh.ts b/scripts/src/gh.ts index d1eec620..c4ebf457 100644 --- a/scripts/src/gh.ts +++ b/scripts/src/gh.ts @@ -6555,7 +6555,7 @@ async function issueCreate(repo: string, token: string, options: GitHubOptions): }, "issue create"); const labels = options.labels; if (options.dryRun) { - return { + return withIssueCreateRendered({ ok: true, command: "issue create", repo, @@ -6564,7 +6564,7 @@ async function issueCreate(repo: string, token: string, options: GitHubOptions): title: options.title, labels, ...writeBodyPlan("issue create", repo, body, bodySource, { title: options.title, labels }), - }; + }); } const { owner, name } = repoParts(repo); const payload: Record = { title: options.title, body }; @@ -6581,7 +6581,46 @@ async function issueCreate(repo: string, token: string, options: GitHubOptions): missingLabels, }); } - return { ok: true, command: "issue create", repo, issue: issueSummary(issue), labels, bodySource, rest: true }; + return withIssueCreateRendered({ ok: true, command: "issue create", repo, issue: issueSummary(issue), labels, bodySource, rest: true }); +} + +function withIssueCreateRendered(result: GitHubCommandResult): GitHubCommandResult { + return { + ...result, + contentType: "text/plain", + renderedText: renderIssueCreateTable(result), + }; +} + +function renderIssueCreateTable(result: GitHubCommandResult): string { + const issue = isRecord(result.issue) ? result.issue : {}; + const number = ghText(issue.number ?? result.number); + const title = ghText(issue.title ?? result.title); + const status = result.dryRun === true ? "dry-run" : "created"; + const labels = Array.isArray(result.labels) ? result.labels.map(String).join(",") : ghText(result.labels); + const lines = [ + `gh issue create (${status})`, + "", + ghTable(["ISSUE", "STATUS", "LABELS", "TITLE"], [[ + number === "-" ? "-" : `#${number}`, + status, + ghShort(labels, 40), + ghShort(title, 96), + ]]), + "", + "Summary:", + ` repo=${ghText(result.repo)} url=${ghText(issue.url ?? result.url)}`, + "", + "Next:", + ]; + if (status === "created" && number !== "-") { + lines.push(` bun scripts/cli.ts gh issue view ${number} --repo ${ghText(result.repo)}`); + } else { + lines.push(" rerun without --dry-run to create the issue"); + } + lines.push("", "Disclosure:"); + lines.push(" default view is a bounded table; use gh issue view --full for structured metadata."); + return lines.join("\n"); } async function issuePatch(repo: string, token: string, issueNumber: number, options: GitHubOptions): Promise {