@bensandee/forgejo-cli 0.7.0 → 0.8.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/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # @bensandee/forgejo-cli
2
2
 
3
3
  `bst-fj`: the Forgejo API commands, without the rest of `bst`. Most of these commands used to ship on
4
- `@bensandee/tooling`'s `bst` bin; `issue:*`, `pr:create`, `pr:update`, `pr:ready` and `pr:retarget` still do, and run the same code.
4
+ `@bensandee/tooling`'s `bst` bin; `issue:*`, `pr:create`, `pr:update`, `pr:ready`, `pr:reopen` and
5
+ `pr:retarget` still do, and run the same code.
5
6
 
6
7
  ## Installation
7
8
 
@@ -56,11 +57,13 @@ command takes `--json`, which prints exactly one JSON document, failures include
56
57
  | `pr:merge` | Merge an open, non-draft, mergeable PR pinned to the head it read; refuses closed, draft, conflicted, unconfirmed or non-green checks (zero statuses included) unless `--ignore-checks`; `--delete-branch` is opt-in |
57
58
  | `pr:ready` | Mark a draft pull request ready, dropping one `WIP:` prefix or taking `--title`, and confirm the forge no longer reports a draft |
58
59
  | `pr:close` | Close an open pull request, optionally posting `--comment`/`--comment-file` first; reports an already-closed or merged PR without writing; refuses an issue |
60
+ | `pr:reopen` | Reopen a closed pull request and confirm the forge reports it open; reports an already-open PR without writing; refuses a merged PR and an issue |
59
61
  | `pr:retarget` | Repoint an open pull request at a new base branch, confirm the forge took it, and report its mergeability as advice |
60
62
  | `workflow:dispatch` | Dispatch a workflow with `--workflow`, `--ref` and repeatable `--input`; takes `--repo owner/repo`, not a URL |
61
63
  | `ci:runs` | List a repository's workflow runs with their jobs, filtered by workflow, ref, pull request, head SHA or status |
62
64
  | `ci:log` | Print one workflow job's whole log, or with `--grep` only the lines whose text matches |
63
65
 
64
66
  Zero posted statuses reads as `no-status`, never as green. Every command is Forgejo-only: on
65
- GitHub, use `gh`. The `issue:*`, `pr:create`, `pr:update`, `pr:ready` and `pr:retarget` commands take the same flags and print the
67
+ GitHub, use `gh`. The `issue:*`, `pr:create`, `pr:update`, `pr:ready`, `pr:reopen` and `pr:retarget`
68
+ commands take the same flags and print the
66
69
  same `--json` documents as `bst`'s, except that `issue:create` has no config default for assignees.
package/bin/bst-fj.mjs CHANGED
@@ -11,8 +11,8 @@
11
11
  *
12
12
  * The indirection costs one module load and makes the bin link independent of build state: the
13
13
  * link always exists, and `dist/bin.mjs` only has to be there by the time someone runs it. When
14
- * it is not, the failure is an explicit ERR_MODULE_NOT_FOUND naming the missing build output --
15
- * a far better error than a command that appears not to exist.
14
+ * it is not, the shim says so in one line and names the command that builds it, rather than
15
+ * leaving Node's ERR_MODULE_NOT_FOUND stack trace.
16
16
  *
17
17
  * Consumers installing from the registry get both files (`files` ships `bin` and `dist`) and are
18
18
  * unaffected either way, since a published tarball is always built.
@@ -22,4 +22,13 @@
22
22
  * wrong trade for a file whose entire purpose is a side effect: the dynamic form says "run this"
23
23
  * rather than "bring in these bindings", which is what is actually meant here.
24
24
  */
25
- await import("../dist/bin.mjs");
25
+ import { existsSync } from "node:fs";
26
+ import { fileURLToPath } from "node:url";
27
+
28
+ const entry = new URL("../dist/bin.mjs", import.meta.url);
29
+ if (existsSync(entry)) {
30
+ await import(entry.href);
31
+ } else {
32
+ process.stderr.write(`bst-fj: ${fileURLToPath(entry)} is missing. Run \`pnpm build\` first.\n`);
33
+ process.exitCode = 1;
34
+ }
package/dist/bin.mjs CHANGED
@@ -160,7 +160,7 @@ function loadEnvFileForBin(rawArgs, bin, io = processIo) {
160
160
  // src/version.ts
161
161
  const parsed = z.object({ version: z.string() }).safeParse({
162
162
  name: "@bensandee/forgejo-cli",
163
- version: "0.7.0",
163
+ version: "0.8.0",
164
164
  description: "bst-fj: Forgejo API commands without the rest of bst",
165
165
  license: "MIT",
166
166
  repository: {
@@ -196,7 +196,7 @@ const parsed = z.object({ version: z.string() }).safeParse({
196
196
  "@bensandee/cli-kit": "workspace:*",
197
197
  "@bensandee/forgejo": "workspace:*",
198
198
  "@types/node": "24.19.2",
199
- "tsdown": "0.23.1"
199
+ "tsdown": "0.23.4"
200
200
  }
201
201
  });
202
202
  if (!parsed.success) throw new UnexpectedError(`@bensandee/forgejo-cli's package.json has no string version.`);
@@ -1450,6 +1450,7 @@ async function settleChecks(fetcher, conn, poll, round) {
1450
1450
  } else {
1451
1451
  consecutiveFailures = 0;
1452
1452
  lastGoodChecks = checks;
1453
+ round.observe?.(checks);
1453
1454
  pushDisagreementNotice(round.notices, sha, checks);
1454
1455
  if (isSettled(checks)) {
1455
1456
  const contexts = new Set(checks.contexts.map((check) => check.context));
@@ -3347,7 +3348,7 @@ function readActionsJobLog(text) {
3347
3348
  lines
3348
3349
  };
3349
3350
  }
3350
- // src/ci-log.ts
3351
+ // src/ci/ci-log.ts
3351
3352
  const ACTIONS_RUN_URL = /\/actions\/runs\/(\d+)\/?(?:[?#]|$)/u;
3352
3353
  function parseCiLogTarget(target) {
3353
3354
  if (/^\d+$/.test(target)) return {
@@ -3492,7 +3493,7 @@ const ciLogCommand = defineCommand({
3492
3493
  out.text(renderCiLog(result));
3493
3494
  }
3494
3495
  });
3495
- // src/ci-runs.ts
3496
+ // src/ci/ci-runs.ts
3496
3497
  function resolveRunsRef(ref, pr) {
3497
3498
  if (ref !== void 0 && pr !== void 0) throw new FatalError("--ref and --pr are the same filter -- give one of them (--pr 273 for a pull request's own runs, --ref main for a branch's).");
3498
3499
  if (pr !== void 0) {
@@ -3660,7 +3661,7 @@ function parseInputs(raw) {
3660
3661
  }
3661
3662
  return inputs;
3662
3663
  }
3663
- // src/workflow-dispatch.ts
3664
+ // src/ci/workflow-dispatch.ts
3664
3665
  async function runWorkflowDispatch(fetcher, options) {
3665
3666
  const dispatched = await dispatchWorkflow(fetcher, requireForgejoTarget(options.cwd, void 0, "workflow:dispatch is Forgejo-only -- use gh workflow run on GitHub."), {
3666
3667
  ...options.repo === void 0 ? {} : { repository: options.repo },
@@ -3677,7 +3678,7 @@ async function runWorkflowDispatch(fetcher, options) {
3677
3678
  inputs: dispatched.inputs
3678
3679
  };
3679
3680
  }
3680
- // src/registry-actions.ts
3681
+ // src/registry/registry-actions.ts
3681
3682
  const actionsSubCommands = {
3682
3683
  "ci:log": ciLogCommand,
3683
3684
  "ci:runs": ciRunsCommand,
@@ -3851,7 +3852,7 @@ function renderBranchList(listing) {
3851
3852
  if (listing.truncated) lines.push("Listing truncated at the page cap; more branches exist.");
3852
3853
  return lines.join("\n");
3853
3854
  }
3854
- // src/registry-branch.ts
3855
+ // src/registry/registry-branch.ts
3855
3856
  const branchSubCommands = {
3856
3857
  "branch:delete": defineCommand({
3857
3858
  meta: {
@@ -4191,8 +4192,13 @@ const PrDetailSchema = z.object({
4191
4192
  draft: z.boolean(),
4192
4193
  merged: z.boolean(),
4193
4194
  mergeable: z.boolean().nullish(),
4195
+ merge_commit_sha: z.string().nullish(),
4194
4196
  state: z.string()
4195
4197
  });
4198
+ const MERGE_COMMIT_SHA = /^[0-9a-f]{7,64}$/;
4199
+ function isMergeCommitSha(value) {
4200
+ return value !== void 0 && value !== null && MERGE_COMMIT_SHA.test(value);
4201
+ }
4196
4202
  function normalizePrDetail(data) {
4197
4203
  return {
4198
4204
  head: {
@@ -4208,6 +4214,7 @@ function normalizePrDetail(data) {
4208
4214
  draft: data.draft,
4209
4215
  merged: data.merged,
4210
4216
  mergeable: data.mergeable ?? null,
4217
+ mergeCommitSha: isMergeCommitSha(data.merge_commit_sha) ? data.merge_commit_sha : null,
4211
4218
  state: data.state
4212
4219
  };
4213
4220
  }
@@ -4252,6 +4259,21 @@ async function retargetPr(executor, conn, prNumber, base) {
4252
4259
  resource: `#${String(prNumber)}`
4253
4260
  });
4254
4261
  }
4262
+ async function reopenPr(executor, conn, prNumber) {
4263
+ const url = `${conn.serverUrl}/api/v1/repos/${conn.repository}/pulls/${String(prNumber)}`;
4264
+ const res = await executor.fetch(url, {
4265
+ method: "PATCH",
4266
+ headers: {
4267
+ Authorization: `token ${conn.token}`,
4268
+ "Content-Type": "application/json"
4269
+ },
4270
+ body: JSON.stringify({ state: "open" })
4271
+ }, { idempotent: true });
4272
+ if (!res.ok) await throwForgejoFailure(res, {
4273
+ verb: "reopen PR",
4274
+ resource: `#${String(prNumber)}`
4275
+ });
4276
+ }
4255
4277
  const PrContentSchema = z.object({
4256
4278
  title: z.string(),
4257
4279
  body: z.string().nullish()
@@ -4641,7 +4663,7 @@ function forgejoIssueTransport(cwd, target, command) {
4641
4663
  target: resolved.target
4642
4664
  };
4643
4665
  }
4644
- // src/commands/issue-comment.ts
4666
+ // src/commands/issue/issue-comment.ts
4645
4667
  const issueCommentCommand = defineCommand({
4646
4668
  meta: {
4647
4669
  name: "issue:comment",
@@ -4699,7 +4721,7 @@ const issueCommentCommand = defineCommand({
4699
4721
  }
4700
4722
  }
4701
4723
  });
4702
- // src/commands/issue-create.ts
4724
+ // src/commands/issue/issue-create.ts
4703
4725
  const issueCreateCommand = defineCommand({
4704
4726
  meta: {
4705
4727
  name: "issue:create",
@@ -4865,7 +4887,7 @@ function formatDownload(result, dryRun) {
4865
4887
  for (const file of result.files) lines.push(` ${file.name} (${String(file.size)} bytes)`);
4866
4888
  return lines.join("\n");
4867
4889
  }
4868
- // src/commands/issue-download.ts
4890
+ // src/commands/issue/issue-download.ts
4869
4891
  const issueDownloadCommand = defineCommand({
4870
4892
  meta: {
4871
4893
  name: "issue:download",
@@ -5044,7 +5066,7 @@ function formatIssueSetLabels(result, dryRun) {
5044
5066
  if (result.added.length > 0) lines.push(` ${dryRun ? "would add" : "added"}: ${result.added.join(", ")}`);
5045
5067
  return lines.join("\n");
5046
5068
  }
5047
- // src/commands/issue-label.ts
5069
+ // src/commands/issue/issue-label.ts
5048
5070
  function defineIssueLabelCommand(action) {
5049
5071
  const name = action === "add" ? "issue:label" : "issue:unlabel";
5050
5072
  return defineCommand({
@@ -5103,7 +5125,7 @@ function defineIssueLabelCommand(action) {
5103
5125
  }
5104
5126
  const issueLabelCommand = defineIssueLabelCommand("add");
5105
5127
  const issueUnlabelCommand = defineIssueLabelCommand("remove");
5106
- // src/commands/issue-set-labels.ts
5128
+ // src/commands/issue/issue-set-labels.ts
5107
5129
  const issueSetLabelsCommand = defineCommand({
5108
5130
  meta: {
5109
5131
  name: "issue:set-labels",
@@ -5259,7 +5281,7 @@ function formatIssueState(result, dryRun) {
5259
5281
  }
5260
5282
  return lines.join("\n");
5261
5283
  }
5262
- // src/commands/issue-state.ts
5284
+ // src/commands/issue/issue-state.ts
5263
5285
  function defineIssueStateCommand(action) {
5264
5286
  const name = action === "close" ? "issue:close" : "issue:reopen";
5265
5287
  return defineCommand({
@@ -5322,7 +5344,7 @@ function defineIssueStateCommand(action) {
5322
5344
  if (error instanceof IssueNumberRequiredError) throw new FatalError(describeIssueNumberRequired(`pnpm exec bst-fj ${name} 273`));
5323
5345
  if (error instanceof EmptyCommentError) throw new FatalError(describeEmptyComment(flags));
5324
5346
  if (error instanceof PullRequestStateError) {
5325
- const advice = action === "close" ? `Run \`pnpm exec bst-fj pr:close ${String(error.number)}\` to close it.` : "Use the forge UI to change a pull request's state.";
5347
+ const advice = action === "close" ? `Run \`pnpm exec bst-fj pr:close ${String(error.number)}\` to close it.` : `Run \`pnpm exec bst-fj pr:reopen ${String(error.number)}\` to reopen it.`;
5326
5348
  throw new FatalError(describePullRequestState(error, {
5327
5349
  command: `bst-fj ${name}`,
5328
5350
  advice
@@ -5335,7 +5357,7 @@ function defineIssueStateCommand(action) {
5335
5357
  }
5336
5358
  const issueCloseCommand = defineIssueStateCommand("close");
5337
5359
  const issueReopenCommand = defineIssueStateCommand("reopen");
5338
- // src/commands/issue-list.ts
5360
+ // src/commands/issue/issue-list.ts
5339
5361
  const issueListCommand = defineCommand({
5340
5362
  meta: {
5341
5363
  name: "issue:list",
@@ -5393,7 +5415,7 @@ const issueListCommand = defineCommand({
5393
5415
  }
5394
5416
  }
5395
5417
  });
5396
- // src/commands/issue-update.ts
5418
+ // src/commands/issue/issue-update.ts
5397
5419
  const issueUpdateCommand = defineCommand({
5398
5420
  meta: {
5399
5421
  name: "issue:update",
@@ -5464,7 +5486,7 @@ const issueUpdateCommand = defineCommand({
5464
5486
  }
5465
5487
  }
5466
5488
  });
5467
- // src/registry-issue.ts
5489
+ // src/registry/registry-issue.ts
5468
5490
  const issueSubCommands = {
5469
5491
  "issue:view": defineCommand({
5470
5492
  meta: {
@@ -5517,7 +5539,7 @@ const issueSubCommands = {
5517
5539
  "issue:set-labels": issueSetLabelsCommand,
5518
5540
  "issue:download": issueDownloadCommand
5519
5541
  };
5520
- // src/pr-checks.ts
5542
+ // src/pr/pr-checks.ts
5521
5543
  async function resolvePrChecksTarget(fetcher, options) {
5522
5544
  const ref = parseIssueRef(options.pr);
5523
5545
  if (options.repo !== void 0 && ref.number === void 0 && options.branch === void 0) throw new FatalError("--repo requires --pr or --branch -- the current branch of this checkout means nothing in another repository, and inferring it there would silently answer about the wrong PR.");
@@ -5691,7 +5713,7 @@ function renderPrChecks(report) {
5691
5713
  lines.push(summaryParts.join(" -- "));
5692
5714
  return lines.join("\n");
5693
5715
  }
5694
- // src/commands/pr-checks.ts
5716
+ // src/commands/pr/pr-checks.ts
5695
5717
  const prChecksCommand = defineCommand({
5696
5718
  meta: {
5697
5719
  name: "pr:checks",
@@ -5778,7 +5800,7 @@ function parsePrNumber(raw) {
5778
5800
  if (!/^\d+$/.test(raw) || !Number.isSafeInteger(value) || value < 1) throw new FatalError(`Invalid pull request number "${raw}" (expected a positive integer).`);
5779
5801
  return value;
5780
5802
  }
5781
- // src/commands/pr-close.ts
5803
+ // src/commands/pr/pr-close.ts
5782
5804
  const prCloseCommand = defineCommand({
5783
5805
  meta: {
5784
5806
  name: "pr:close",
@@ -6308,7 +6330,8 @@ function forgejoPrEditHost(fetcher, conn) {
6308
6330
  readLive: (number) => getPrEditState(fetcher, conn, number),
6309
6331
  branchExists: (name) => branchExists(fetcher, conn, name),
6310
6332
  setBase: (number, base) => retargetPr(fetcher, conn, number, base),
6311
- ready: (number, write) => updatePr(fetcher, conn, number, { title: write.title })
6333
+ ready: (number, write) => updatePr(fetcher, conn, number, { title: write.title }),
6334
+ reopen: (number) => reopenPr(fetcher, conn, number)
6312
6335
  };
6313
6336
  }
6314
6337
  // src/git.ts
@@ -6387,7 +6410,7 @@ function cliGit() {
6387
6410
  });
6388
6411
  }) };
6389
6412
  }
6390
- // src/pr-run.ts
6413
+ // src/pr/pr-run.ts
6391
6414
  const COMMANDS = {
6392
6415
  create: "pnpm exec bst-fj pr:create",
6393
6416
  update: "pnpm exec bst-fj pr:update"
@@ -6421,7 +6444,7 @@ async function runForgejoPr(githubRefusal, options) {
6421
6444
  });
6422
6445
  }
6423
6446
  }
6424
- // src/commands/pr-create.ts
6447
+ // src/commands/pr/pr-create.ts
6425
6448
  const prCreateCommand = defineCommand({
6426
6449
  meta: {
6427
6450
  name: "pr:create",
@@ -6540,7 +6563,7 @@ async function readPrFilesPage(executor, conn, prNumber, page, limit) {
6540
6563
  truncated: res.headers.get("x-hasmore") === "true"
6541
6564
  };
6542
6565
  }
6543
- // src/pr-files.ts
6566
+ // src/pr/pr-files.ts
6544
6567
  function runPrFiles(fetcher, options) {
6545
6568
  const number = parsePrNumber(options.number);
6546
6569
  return listAllPrFiles(fetcher, requireForgejoTarget(options.cwd, parseRepoTarget(options.repo), "pr:files is Forgejo-only -- gh pr diff --name-only already serves GitHub."), number);
@@ -6551,7 +6574,7 @@ function renderPrFiles(listing) {
6551
6574
  if (listing.truncated) lines.push("Listing truncated; the pull request changes more files.");
6552
6575
  return lines.join("\n");
6553
6576
  }
6554
- // src/commands/pr-files.ts
6577
+ // src/commands/pr/pr-files.ts
6555
6578
  const prFilesCommand = defineCommand({
6556
6579
  meta: {
6557
6580
  name: "pr:files",
@@ -6590,7 +6613,7 @@ const prFilesCommand = defineCommand({
6590
6613
  out.text(renderPrFiles(listing));
6591
6614
  }
6592
6615
  });
6593
- // src/pr-list.ts
6616
+ // src/pr/pr-list.ts
6594
6617
  function parseState(state) {
6595
6618
  if (state === "open" || state === "closed" || state === "all") return state;
6596
6619
  throw new FatalError(`Invalid --state "${state}" (expected open, closed, or all).`);
@@ -6627,7 +6650,7 @@ function renderPrList(result) {
6627
6650
  return `#${String(pr.number)} ${statusLabel(pr)} ${branches}: ${pr.title ?? "(no title)"}${labels}${url}`;
6628
6651
  }).join("\n");
6629
6652
  }
6630
- // src/commands/pr-list.ts
6653
+ // src/commands/pr/pr-list.ts
6631
6654
  const prListCommand = defineCommand({
6632
6655
  meta: {
6633
6656
  name: "pr:list",
@@ -6844,7 +6867,7 @@ async function runPrMergeCore(fetcher, conn, number, options = {}) {
6844
6867
  }
6845
6868
  };
6846
6869
  }
6847
- // src/pr-merge.ts
6870
+ // src/pr/pr-merge.ts
6848
6871
  function parseMethod(raw) {
6849
6872
  if (raw === void 0) return "merge";
6850
6873
  const method = MERGE_METHODS.find((candidate) => candidate === raw);
@@ -6871,7 +6894,7 @@ function renderPrMerge(result) {
6871
6894
  const what = `PR #${String(result.number)} (${result.method}) at ${result.headSha.slice(0, 12)}, checks ${result.checks}`;
6872
6895
  return result.merged ? `Merged ${what}.` : `Dry run: would merge ${what}.`;
6873
6896
  }
6874
- // src/commands/pr-merge.ts
6897
+ // src/commands/pr/pr-merge.ts
6875
6898
  const prMergeCommand = defineCommand({
6876
6899
  meta: {
6877
6900
  name: "pr:merge",
@@ -6933,8 +6956,9 @@ function isOpen(live) {
6933
6956
  return live.state === "open" && live.merged === false;
6934
6957
  }
6935
6958
  function notOpenMessage(prNumber, live) {
6936
- const what = live.merged ? "merged" : live.state;
6937
- return `Pull request #${String(prNumber)} is ${what}, so it has no base or draft state left to change. Reopen it first if this work is still live.`;
6959
+ const number = `#${String(prNumber)}`;
6960
+ if (live.merged) return `Pull request ${number} is merged, so it has no base or draft state left to change.`;
6961
+ return `Pull request ${number} is ${live.state}, so it has no base or draft state left to change. Run \`pr:reopen ${String(prNumber)}\` first if this work is still live.`;
6938
6962
  }
6939
6963
  async function runPrRetarget(host, options) {
6940
6964
  const live = await host.readLive(options.number);
@@ -7030,8 +7054,47 @@ async function runPrReady(host, options) {
7030
7054
  dryRun: false
7031
7055
  };
7032
7056
  }
7057
+ async function runPrReopen(host, options) {
7058
+ const live = await host.readLive(options.number);
7059
+ if (live.merged === true) throw new FatalError(`Pull request #${String(options.number)} was merged, so there is nothing to reopen -- open a new pull request for further work.`);
7060
+ if (live.state === "open") return {
7061
+ action: "already-open",
7062
+ number: options.number,
7063
+ url: live.url,
7064
+ title: live.title,
7065
+ head: live.head,
7066
+ base: live.base,
7067
+ draft: live.draft,
7068
+ dryRun: options.dryRun
7069
+ };
7070
+ if (live.state !== "closed") throw new FatalError(`Pull request #${String(options.number)} reports the state "${live.state}", which this command has no rule for -- it reopens a pull request reported as closed, and guesses at no state it did not expect.`);
7071
+ if (options.dryRun) return {
7072
+ action: "would-reopen",
7073
+ number: options.number,
7074
+ url: live.url,
7075
+ title: live.title,
7076
+ head: live.head,
7077
+ base: live.base,
7078
+ draft: live.draft,
7079
+ dryRun: true
7080
+ };
7081
+ await host.reopen(options.number);
7082
+ const recheck = await host.readLive(options.number);
7083
+ if (!isOpen(recheck)) throw new FatalError(`Pull request #${String(options.number)} still reports \`${recheck.state}\` after the request to reopen it -- reopen it in the forge's web interface.`);
7084
+ return {
7085
+ action: "reopened",
7086
+ number: options.number,
7087
+ url: recheck.url,
7088
+ title: recheck.title,
7089
+ head: recheck.head,
7090
+ base: recheck.base,
7091
+ draft: recheck.draft,
7092
+ dryRun: false
7093
+ };
7094
+ }
7033
7095
  const PR_RETARGET_JSON_HELP = "Emit one JSON document: action (retargeted | unchanged | would-retarget), number, url, previousBase, base, head, mergeable (true | false | null, advice only), dryRun; a refusal is an error, never this document.";
7034
7096
  const PR_READY_JSON_HELP = "Emit one JSON document: action (readied | retitled | already-ready | would-ready | would-retitle), number, url, previousTitle, title, draft, dryRun; a refusal is an error, never this document.";
7097
+ const PR_REOPEN_JSON_HELP = "Emit one JSON document: action (reopened | already-open | would-reopen), number, url, title, head, base, draft, dryRun; a refusal is an error, never this document.";
7035
7098
  function mergeabilityLine(mergeable) {
7036
7099
  if (mergeable === true) return "Mergeability: mergeable.";
7037
7100
  if (mergeable === false) return "Mergeability: not mergeable -- advice, not a verdict.";
@@ -7054,7 +7117,17 @@ function renderPrReady(result) {
7054
7117
  if (result.action === "would-ready") return `Dry run: pull request ${number} would stop being a draft, reading "${result.title}".`;
7055
7118
  return `Dry run: pull request ${number} would read "${result.title}".`;
7056
7119
  }
7057
- // src/registry-pr.ts
7120
+ function renderPrReopen(result) {
7121
+ const number = `#${String(result.number)}`;
7122
+ if (result.action === "reopened") {
7123
+ const lines = [`Pull request ${number} is open again (head "${result.head}" -> "${result.base}").`];
7124
+ if (result.draft) lines.push(`It is still a draft -- run pr:ready ${String(result.number)} when it is ready for review.`);
7125
+ return lines.join("\n");
7126
+ }
7127
+ if (result.action === "already-open") return `Pull request ${number} is already open.`;
7128
+ return `Dry run: pull request ${number} would be reopened.`;
7129
+ }
7130
+ // src/registry/registry-pr.ts
7058
7131
  const prSubCommands = {
7059
7132
  "pr:checks": prChecksCommand,
7060
7133
  "pr:close": prCloseCommand,
@@ -7106,6 +7179,47 @@ const prSubCommands = {
7106
7179
  out.text(renderPrReady(result));
7107
7180
  }
7108
7181
  }),
7182
+ "pr:reopen": defineCommand({
7183
+ meta: {
7184
+ name: "pr:reopen",
7185
+ description: "Reopen a closed, unmerged pull request and confirm the forge reports it open. An already-open pull request is reported without writing; a merged one, or an issue, is refused (Forgejo-only; use gh pr reopen on GitHub)"
7186
+ },
7187
+ args: {
7188
+ number: {
7189
+ type: "positional",
7190
+ required: true,
7191
+ description: "Pull request number"
7192
+ },
7193
+ repo: {
7194
+ type: "string",
7195
+ description: "Repository URL (default: this repo)"
7196
+ },
7197
+ "dry-run": {
7198
+ type: "boolean",
7199
+ description: "Run every read and report, but do not write"
7200
+ },
7201
+ json: {
7202
+ type: "boolean",
7203
+ description: PR_REOPEN_JSON_HELP
7204
+ },
7205
+ verbose: {
7206
+ type: "boolean",
7207
+ description: "Emit detailed debug output"
7208
+ }
7209
+ },
7210
+ async run({ args }) {
7211
+ const out = createCliOutput(args.json === true);
7212
+ const conn = requireForgejoTargetFromRepo(process.cwd(), args.repo ?? void 0, "pr:reopen is Forgejo-only -- use gh pr reopen <n> on GitHub.");
7213
+ const number = parsePrNumber(args.number);
7214
+ if (!(await forgejoIssueApi(cliFetcher(), conn).get(number)).isPullRequest) throw new FatalError(`#${String(number)} is an issue, not a pull request -- pr:reopen refuses to write issue state. Use \`pnpm exec bst-fj issue:reopen ${String(number)}\` to reopen it.`);
7215
+ const result = await runPrReopen(forgejoPrEditHost(cliFetcher(), conn), {
7216
+ number,
7217
+ dryRun: args["dry-run"] === true
7218
+ });
7219
+ out.json(result);
7220
+ out.text(renderPrReopen(result));
7221
+ }
7222
+ }),
7109
7223
  "pr:retarget": defineCommand({
7110
7224
  meta: {
7111
7225
  name: "pr:retarget",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bensandee/forgejo-cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "bst-fj: Forgejo API commands without the rest of bst",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "@bensandee/cli-kit": "0.0.0",
36
36
  "@bensandee/forgejo": "0.7.0",
37
37
  "@types/node": "24.19.2",
38
- "tsdown": "0.23.1"
38
+ "tsdown": "0.23.4"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsdown",