@kaynooo/cli-forgejo 0.12.1 → 0.14.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.
Files changed (2) hide show
  1. package/dist/cli.js +700 -552
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -2,10 +2,10 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process15 from "process";
5
+ import process18 from "process";
6
6
 
7
7
  // ../kit/src/args.ts
8
- import process4 from "process";
8
+ import process6 from "process";
9
9
  import { parseArgs } from "util";
10
10
 
11
11
  // ../kit/src/format.ts
@@ -398,6 +398,55 @@ function printJson(value) {
398
398
  console.log(JSON.stringify(value, undefined, 2));
399
399
  }
400
400
 
401
+ // ../kit/src/help.ts
402
+ import process4 from "process";
403
+ var OPTIONAL = /\[[^\]]+\]/g;
404
+ var USAGE_PREFIX = /^usage:\s*/i;
405
+ var FULL_STOP = /\.$/;
406
+ function usageLine(usage, colors = paint(process4.stdout)) {
407
+ return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
408
+ }
409
+ function helpText(usage, options, colors = paint(process4.stdout), { examples = [], replaces } = {}) {
410
+ return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exampleRows(examples, colors)].join(`
411
+ `);
412
+ }
413
+ function replacesRows(replaces, colors = paint(process4.stdout)) {
414
+ return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
415
+ }
416
+ function wantsHelpJson(env = process4.env) {
417
+ return env.KIT_HELP === "json";
418
+ }
419
+ function description(usage, { examples = [], replaces } = {}) {
420
+ const lines = usage.replace(USAGE_PREFIX, "").split(`
421
+ `);
422
+ const first = lines[0];
423
+ const colon = first.indexOf(": ");
424
+ const prose = lines[lines.indexOf("") + 1] ?? "";
425
+ const fallback = lines.includes("") ? `${prose.charAt(0).toLowerCase()}${prose.slice(1)}`.replace(FULL_STOP, "") : "";
426
+ return {
427
+ synopsis: colon === -1 ? first : first.slice(0, colon),
428
+ summary: colon === -1 ? fallback : first.slice(colon + 2),
429
+ ...replaces === undefined ? {} : { replaces },
430
+ examples: examples.map((example) => typeof example === "string" ? { line: example } : { line: example[0], note: example[1] })
431
+ };
432
+ }
433
+ function exampleRows(examples, colors = paint(process4.stdout)) {
434
+ if (examples.length === 0)
435
+ return [];
436
+ return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
437
+ }
438
+ function optionRows(options, colors = paint(process4.stdout)) {
439
+ const rows = Object.entries(options).map(([name, option]) => {
440
+ const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
441
+ const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
442
+ const placeholder = option.optional === undefined ? named : `[${named}]`;
443
+ const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
444
+ return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
445
+ });
446
+ const width = Math.max(0, ...rows.map((row) => row.width));
447
+ return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
448
+ }
449
+
401
450
  // ../kit/src/text.ts
402
451
  var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
403
452
  function distance(a, b) {
@@ -417,8 +466,42 @@ function closest(name, names) {
417
466
  const [best] = names.map((known) => ({ known, far: distance(name, known) })).sort((a, b) => a.far - b.far);
418
467
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
419
468
  }
469
+ // ../kit/src/input.ts
470
+ import process5 from "process";
471
+ var WHOLE = /^\d+$/;
472
+ function wholeNumber(value, name, fallback, min = 1) {
473
+ if (value === undefined)
474
+ return fallback;
475
+ const number = Number(value);
476
+ if (!WHOLE.test(value) || !Number.isSafeInteger(number) || number < min)
477
+ badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
478
+ return number;
479
+ }
480
+ var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
481
+ var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
482
+ function duration(value, name, fallback, unit = "s") {
483
+ if (value === undefined)
484
+ return fallback;
485
+ const match = DURATION.exec(value.trim());
486
+ const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
487
+ if (ms < 1)
488
+ badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
489
+ return ms;
490
+ }
491
+ async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
492
+ if (path === "-") {
493
+ if (process5.stdin.isTTY)
494
+ fail(noStdin);
495
+ return Bun.stdin.text();
496
+ }
497
+ const file = Bun.file(path);
498
+ if (!await file.exists())
499
+ fail(`no file ${path}`);
500
+ return file.text();
501
+ }
420
502
 
421
503
  // ../kit/src/args.ts
504
+ var DASHES = /^-+/;
422
505
  function jsonOption(holds) {
423
506
  return { type: "boolean", description: holds === undefined ? "print JSON" : `print JSON: ${holds}` };
424
507
  }
@@ -462,58 +545,11 @@ class Completing {
462
545
  }
463
546
  }
464
547
  var completion = { active: false };
465
- var OPTIONAL = /\[[^\]]+\]/g;
466
- var USAGE_PREFIX = /^usage:\s*/i;
467
- var FULL_STOP = /\.$/;
468
- var DASHES = /^-+/;
469
- function usageLine(usage, colors = paint(process4.stdout)) {
470
- return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
471
- }
472
- function helpText(usage, options, colors = paint(process4.stdout), { examples = [], replaces } = {}) {
473
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exampleRows(examples, colors)].join(`
474
- `);
475
- }
476
- function replacesRows(replaces, colors = paint(process4.stdout)) {
477
- return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
478
- }
479
- function wantsHelpJson(env = process4.env) {
480
- return env.KIT_HELP === "json";
481
- }
482
- function description(usage, { examples = [], replaces } = {}) {
483
- const lines = usage.replace(USAGE_PREFIX, "").split(`
484
- `);
485
- const first = lines[0];
486
- const colon = first.indexOf(": ");
487
- const prose = lines[lines.indexOf("") + 1] ?? "";
488
- const fallback = lines.includes("") ? `${prose.charAt(0).toLowerCase()}${prose.slice(1)}`.replace(FULL_STOP, "") : "";
489
- return {
490
- synopsis: colon === -1 ? first : first.slice(0, colon),
491
- summary: colon === -1 ? fallback : first.slice(colon + 2),
492
- ...replaces === undefined ? {} : { replaces },
493
- examples: examples.map((example) => typeof example === "string" ? { line: example } : { line: example[0], note: example[1] })
494
- };
495
- }
496
- function exampleRows(examples, colors = paint(process4.stdout)) {
497
- if (examples.length === 0)
498
- return [];
499
- return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
500
- }
501
- function optionRows(options, colors = paint(process4.stdout)) {
502
- const rows = Object.entries(options).map(([name, option]) => {
503
- const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
504
- const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
505
- const placeholder = option.optional === undefined ? named : `[${named}]`;
506
- const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
507
- return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
508
- });
509
- const width = Math.max(0, ...rows.map((row) => row.width));
510
- return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
511
- }
512
548
  var OUTPUT_OPTIONS = {
513
549
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
514
550
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
515
551
  };
516
- function applyOutput(color, plain, env = process4.env) {
552
+ function applyOutput(color, plain, env = process6.env) {
517
553
  const when = plain === true ? "never" : color ?? "auto";
518
554
  if (when === "auto")
519
555
  return;
@@ -670,43 +706,12 @@ function nearestOption(message, options, allowNegative) {
670
706
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
671
707
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
672
708
  }
673
- var WHOLE = /^\d+$/;
674
- function wholeNumber(value, name, fallback, min = 1) {
675
- if (value === undefined)
676
- return fallback;
677
- const number = Number(value);
678
- if (!WHOLE.test(value) || !Number.isSafeInteger(number) || number < min)
679
- badUsage(`${name.startsWith("<") ? name : `--${name}`} takes a whole number from ${min}, not ${value}`);
680
- return number;
681
- }
682
- var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
683
- var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
684
- function duration(value, name, fallback, unit = "s") {
685
- if (value === undefined)
686
- return fallback;
687
- const match = DURATION.exec(value.trim());
688
- const ms = match === null ? 0 : Number(match[1]) * UNIT_MS[match[2] ?? unit];
689
- if (ms < 1)
690
- badUsage(`--${name} takes a duration such as 30s, 5m, 1h or 7d, not ${value}`);
691
- return ms;
692
- }
693
- async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
694
- if (path === "-") {
695
- if (process4.stdin.isTTY)
696
- fail(noStdin);
697
- return Bun.stdin.text();
698
- }
699
- const file = Bun.file(path);
700
- if (!await file.exists())
701
- fail(`no file ${path}`);
702
- return file.text();
703
- }
704
709
  // ../kit/src/progress.ts
705
- import process6 from "process";
710
+ import process8 from "process";
706
711
 
707
712
  // ../kit/src/process.ts
708
713
  import { constants } from "os";
709
- import process5 from "process";
714
+ import process7 from "process";
710
715
  var KILL_GRACE_MS = 2000;
711
716
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
712
717
  function exitCodeOf(code, signal) {
@@ -728,7 +733,7 @@ function holdSignals(cleanup) {
728
733
  },
729
734
  release: () => {
730
735
  for (const signal of SIGNALS)
731
- process5.off(signal, onSignal);
736
+ process7.off(signal, onSignal);
732
737
  }
733
738
  };
734
739
  function onSignal(signal) {
@@ -741,10 +746,10 @@ function holdSignals(cleanup) {
741
746
  return;
742
747
  held.release();
743
748
  cleanup(signal);
744
- process5.kill(process5.pid, signal);
749
+ process7.kill(process7.pid, signal);
745
750
  }
746
751
  for (const signal of SIGNALS)
747
- process5.on(signal, onSignal);
752
+ process7.on(signal, onSignal);
748
753
  return held;
749
754
  }
750
755
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -758,7 +763,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
758
763
  return;
759
764
  try {
760
765
  if (grouped)
761
- process5.kill(-proc.pid, killing);
766
+ process7.kill(-proc.pid, killing);
762
767
  else
763
768
  proc.kill(killing);
764
769
  } catch {}
@@ -837,7 +842,7 @@ var RESET_STYLE = `${ESC}[0m`;
837
842
  var CTRL_C = 3;
838
843
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
839
844
  var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
840
- function liveRegion(render, stream = process6.stderr, env = process6.env) {
845
+ function liveRegion(render, stream = process8.stderr, env = process8.env) {
841
846
  if (!takesControlCodes(stream, env))
842
847
  return { redraw: () => {
843
848
  return;
@@ -878,11 +883,11 @@ function liveRegion(render, stream = process6.stderr, env = process6.env) {
878
883
  clear();
879
884
  restore();
880
885
  release();
881
- process6.off("exit", onExit);
886
+ process8.off("exit", onExit);
882
887
  signals.release();
883
888
  }
884
889
  timer.unref();
885
- process6.on("exit", onExit);
890
+ process8.on("exit", onExit);
886
891
  return {
887
892
  redraw: draw,
888
893
  print: (text) => {
@@ -921,14 +926,14 @@ function cutToWidth(line, width) {
921
926
  return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
922
927
  }
923
928
  function swallowInput() {
924
- const input = process6.stdin;
929
+ const input = process8.stdin;
925
930
  if (!input.isTTY)
926
931
  return () => {
927
932
  return;
928
933
  };
929
934
  const onData = (data) => {
930
935
  if (data.includes(CTRL_C))
931
- process6.kill(process6.pid, "SIGINT");
936
+ process8.kill(process8.pid, "SIGINT");
932
937
  };
933
938
  input.setRawMode(true);
934
939
  input.on("data", onData);
@@ -944,7 +949,7 @@ function swallowInput() {
944
949
  };
945
950
  }
946
951
  function interceptOutput(clear) {
947
- const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process6.stdout, "write"], [process6.stderr, "write"]];
952
+ const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process8.stdout, "write"], [process8.stderr, "write"]];
948
953
  const wrapped = targets.map(([target, name]) => {
949
954
  const original = Reflect.get(target, name);
950
955
  const wrapper = (...args) => {
@@ -963,11 +968,11 @@ function interceptOutput(clear) {
963
968
  }
964
969
 
965
970
  // ../kit/src/tool.ts
966
- import process7 from "process";
971
+ import process9 from "process";
967
972
  var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
968
973
  function cwdGone() {
969
974
  try {
970
- process7.cwd();
975
+ process9.cwd();
971
976
  return false;
972
977
  } catch {
973
978
  return true;
@@ -994,7 +999,7 @@ function isPermanentFailure(error) {
994
999
  async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
995
1000
  let ran;
996
1001
  try {
997
- ran = await runCommand(argv, { env: process7.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
1002
+ ran = await runCommand(argv, { env: process9.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
998
1003
  } catch (error) {
999
1004
  throw spawnFailure(label, error);
1000
1005
  }
@@ -1073,7 +1078,59 @@ async function waitForCi(wait) {
1073
1078
  }
1074
1079
  }
1075
1080
  // ../kit/src/cli.ts
1076
- import process8 from "process";
1081
+ import process11 from "process";
1082
+
1083
+ // ../kit/src/usage.ts
1084
+ import { appendFileSync, mkdirSync } from "fs";
1085
+ import { homedir } from "os";
1086
+ import { dirname, isAbsolute, join } from "path";
1087
+ import process10 from "process";
1088
+
1089
+ // ../kit/src/logs.ts
1090
+ var DAY_MS = 24 * 60 * 60 * 1000;
1091
+ var CLI_FOLDER = "kaynooo-cli";
1092
+
1093
+ // ../kit/src/usage.ts
1094
+ var UNKNOWN_OPTION2 = /unknown option '(--[a-z][a-z0-9-]*)[=']/;
1095
+ var FLAG_NAME = /^(?:--[a-z][a-z0-9-]*|-[a-zA-Z])$/;
1096
+ var LONGEST_NAME = 40;
1097
+ var usageError;
1098
+ function noteUsageError(message) {
1099
+ usageError = message;
1100
+ }
1101
+ function stateHome(env = process10.env) {
1102
+ const dir = env.XDG_STATE_HOME;
1103
+ return dir !== undefined && isAbsolute(dir) ? dir : join(homedir(), ".local", "state");
1104
+ }
1105
+ function usagePath(env = process10.env) {
1106
+ return join(stateHome(env), CLI_FOLDER, "usage.jsonl");
1107
+ }
1108
+ function usageRecorded(env = process10.env) {
1109
+ const off = env.KAYNOOO_CLI_NO_USAGE;
1110
+ return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1111
+ }
1112
+ function flagNames(argv) {
1113
+ const end = argv.indexOf("--");
1114
+ const names = (end === -1 ? argv : argv.slice(0, end)).filter((word) => word.startsWith("-") && word !== "-").map((word) => word.includes("=") ? word.slice(0, word.indexOf("=")) : word);
1115
+ return [...new Set(names)].filter((name) => name.length <= LONGEST_NAME && FLAG_NAME.test(name));
1116
+ }
1117
+ function usageEntry(bin, command, argv, code, now = new Date) {
1118
+ const unknown = code === 2 && usageError !== undefined ? UNKNOWN_OPTION2.exec(usageError)?.[1] : undefined;
1119
+ usageError = undefined;
1120
+ return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1121
+ }
1122
+ function recordUsage(entry, env = process10.env) {
1123
+ if (!usageRecorded(env))
1124
+ return;
1125
+ try {
1126
+ const path = usagePath(env);
1127
+ mkdirSync(dirname(path), { recursive: true, mode: 448 });
1128
+ appendFileSync(path, `${JSON.stringify(entry)}
1129
+ `, { mode: 384 });
1130
+ } catch {}
1131
+ }
1132
+
1133
+ // ../kit/src/cli.ts
1077
1134
  var LEVEL_OPTIONS = {
1078
1135
  ...OUTPUT_OPTIONS,
1079
1136
  help: { type: "boolean", short: "h", description: "show this help" }
@@ -1126,7 +1183,7 @@ async function expand(scope, words) {
1126
1183
  }
1127
1184
  return { ...scope, commands, lazy: [] };
1128
1185
  }
1129
- async function help({ path, header, summary: lazySummary, commands, defaultCommand, examples, replaces }, stream) {
1186
+ async function help2({ path, header, summary: lazySummary, commands, defaultCommand, examples, replaces }, stream) {
1130
1187
  const colors = paint(stream);
1131
1188
  const prefix = path.join(" ");
1132
1189
  const summary = await resolveSummary(lazySummary);
@@ -1153,8 +1210,8 @@ async function help({ path, header, summary: lazySummary, commands, defaultComma
1153
1210
  `);
1154
1211
  }
1155
1212
  function printError(prefix, message, hint, cause) {
1156
- const colors = paint(process8.stderr);
1157
- const styled = takesControlCodes(process8.stderr);
1213
+ const colors = paint(process11.stderr);
1214
+ const styled = takesControlCodes(process11.stderr);
1158
1215
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1159
1216
  const under = (label, text, tint) => text === undefined ? "" : `
1160
1217
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1164,8 +1221,8 @@ function runHint(command, effect) {
1164
1221
  return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
1165
1222
  }
1166
1223
  function printHint(hint) {
1167
- const colors = paint(process8.stderr);
1168
- console.error(` ${takesControlCodes(process8.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
1224
+ const colors = paint(process11.stderr);
1225
+ console.error(` ${takesControlCodes(process11.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
1169
1226
  }
1170
1227
  function printJsonError(message, hint, cause) {
1171
1228
  console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
@@ -1180,6 +1237,8 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
1180
1237
  const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
1181
1238
  const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
1182
1239
  const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
1240
+ if (error instanceof UsageError)
1241
+ noteUsageError(error.message);
1183
1242
  const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
1184
1243
  report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
1185
1244
  return error instanceof Exit ? error.code : 1;
@@ -1202,11 +1261,11 @@ async function dispatch(level, typed, { version, redact }) {
1202
1261
  }
1203
1262
  }
1204
1263
  if (name === undefined && level.path.length > 1) {
1205
- console.error(await help(await expand(level, [...level.path.slice(1), ...argv]), process8.stderr));
1264
+ console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stderr));
1206
1265
  return 2;
1207
1266
  }
1208
1267
  if (name === undefined || name === "help" || name === "--help" || name === "-h") {
1209
- console.log(await help(await expand(level, [...level.path.slice(1), ...argv]), process8.stdout));
1268
+ console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process11.stdout));
1210
1269
  return 0;
1211
1270
  }
1212
1271
  if (level.path.length === 1 && (name === "--version" || name === "-v")) {
@@ -1322,14 +1381,35 @@ async function printCandidates(found) {
1322
1381
  console.log(line);
1323
1382
  return 0;
1324
1383
  }
1325
- async function runCli(cli, argv = process8.argv.slice(2)) {
1384
+ async function runCli(cli, argv = process11.argv.slice(2)) {
1326
1385
  if (argv[0] === COMPLETE)
1327
1386
  return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
1328
- return dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(cli.version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version: cli.version, redact: cli.redact });
1387
+ const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(cli.version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version: cli.version, redact: cli.redact });
1388
+ if (cli.usage !== false) {
1389
+ try {
1390
+ recordUsage(usageEntry(cli.name, commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv), argv, code));
1391
+ } catch {}
1392
+ }
1393
+ return code;
1394
+ }
1395
+ function commandPath(scope, argv) {
1396
+ const path = [];
1397
+ let level = scope;
1398
+ for (const word of argv.filter((each) => !each.startsWith("-"))) {
1399
+ const name = level.aliases !== undefined && Object.hasOwn(level.aliases, word) ? level.aliases[word] ?? word : word;
1400
+ const command = Object.hasOwn(level.commands, name) ? level.commands[name] : undefined;
1401
+ if (command === undefined)
1402
+ break;
1403
+ path.push(word);
1404
+ if (!("commands" in command))
1405
+ break;
1406
+ level = scopeOf(command.commands, command.extraCommands, command.aliases);
1407
+ }
1408
+ return path.length === 0 ? undefined : path.join(" ");
1329
1409
  }
1330
1410
  // ../kit/src/git.ts
1331
- import { basename, dirname } from "path";
1332
- import process9 from "process";
1411
+ import { basename, dirname as dirname2 } from "path";
1412
+ import process12 from "process";
1333
1413
  var ORIGIN_PREFIX = /^origin\//;
1334
1414
  var GIT_NETWORK_MS = 60000;
1335
1415
  async function git(args, timeoutMs) {
@@ -1359,7 +1439,7 @@ async function defaultBranch() {
1359
1439
  async function leaveWorktree() {
1360
1440
  const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
1361
1441
  if (basename(common) === ".git")
1362
- process9.chdir(dirname(common));
1442
+ process12.chdir(dirname2(common));
1363
1443
  }
1364
1444
  // ../kit/src/limit.ts
1365
1445
  function limitOptions(fallback) {
@@ -1382,24 +1462,22 @@ function capped(rows, limit) {
1382
1462
  const more = rows.length - limit;
1383
1463
  return more > 0 ? { shown: rows.slice(0, limit), footer: moreFooter(more) } : { shown: [...rows], footer: undefined };
1384
1464
  }
1385
- // ../kit/src/logs.ts
1386
- var DAY_MS = 24 * 60 * 60 * 1000;
1387
1465
  // ../kit/src/secrets.ts
1388
1466
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1389
1467
  // ../kit/src/sessions.ts
1390
- import { homedir } from "os";
1391
- import { join } from "path";
1392
- import process10 from "process";
1468
+ import { homedir as homedir2 } from "os";
1469
+ import { join as join2 } from "path";
1470
+ import process13 from "process";
1393
1471
  var {Glob } = globalThis.Bun;
1394
1472
  var SESSION_FILES = new Glob("*.json");
1395
1473
  var ACCOUNT_DIRS = new Glob("*/sessions");
1396
1474
  async function sessionDirs() {
1397
- const home = homedir();
1398
- const dirs = new Set([join(home, ".claude", "sessions")]);
1399
- if (process10.env.CLAUDE_CONFIG_DIR !== undefined)
1400
- dirs.add(join(process10.env.CLAUDE_CONFIG_DIR, "sessions"));
1475
+ const home = homedir2();
1476
+ const dirs = new Set([join2(home, ".claude", "sessions")]);
1477
+ if (process13.env.CLAUDE_CONFIG_DIR !== undefined)
1478
+ dirs.add(join2(process13.env.CLAUDE_CONFIG_DIR, "sessions"));
1401
1479
  try {
1402
- for await (const dir of ACCOUNT_DIRS.scan({ cwd: join(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1480
+ for await (const dir of ACCOUNT_DIRS.scan({ cwd: join2(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
1403
1481
  dirs.add(dir);
1404
1482
  } catch {}
1405
1483
  return [...dirs];
@@ -1443,7 +1521,7 @@ async function liveSessions() {
1443
1521
  }
1444
1522
  async function currentSession(sessions) {
1445
1523
  const byPid = new Map(sessions.map((session) => [session.pid, session]));
1446
- let pid = process10.ppid;
1524
+ let pid = process13.ppid;
1447
1525
  for (let depth = 0;depth < 32 && pid > 1; depth++) {
1448
1526
  const session = byPid.get(pid);
1449
1527
  if (session !== undefined)
@@ -1456,7 +1534,7 @@ async function currentSession(sessions) {
1456
1534
  return;
1457
1535
  }
1458
1536
  // package.json
1459
- var version = "0.12.1";
1537
+ var version = "0.14.0";
1460
1538
 
1461
1539
  // src/args.ts
1462
1540
  var repoOption = {
@@ -2084,7 +2162,7 @@ async function drop(args) {
2084
2162
  }
2085
2163
 
2086
2164
  // src/commands/ci.ts
2087
- import process12 from "process";
2165
+ import process15 from "process";
2088
2166
 
2089
2167
  // src/git.ts
2090
2168
  async function tagsAt(commit) {
@@ -2259,7 +2337,7 @@ ${excerpt(await jobLog(job.id, repo))}`);
2259
2337
  }
2260
2338
 
2261
2339
  // src/commands/ci.ts
2262
- var usage = `ft ci [ref]
2340
+ var usage2 = `ft ci [ref]
2263
2341
 
2264
2342
  Waits for the push runs covering a commit on the branch, by default origin's tip, and prints what each failed job's log says.
2265
2343
  A push's run tests every commit since the previous push, so a commit whose own run was cancelled, or whose --job was skipped, is covered by the next commit's runs.
@@ -2291,7 +2369,7 @@ function settled(latest) {
2291
2369
  return latest !== undefined && latest.every((run) => FINISHED.has(run.status)) && judge(latest, false, false).kind === "runs" ? latest : undefined;
2292
2370
  }
2293
2371
  async function ci2(args) {
2294
- const parsed = parse(args, usage, options);
2372
+ const parsed = parse(args, usage2, options);
2295
2373
  const { values, positionals } = parsed;
2296
2374
  const branch = values.branch ?? await defaultBranch();
2297
2375
  const giveUp = duration(values.timeout, "timeout", 30 * 60000, "m");
@@ -2326,7 +2404,7 @@ async function ci2(args) {
2326
2404
  }
2327
2405
  return;
2328
2406
  }
2329
- const { dim } = paint(process12.stderr);
2407
+ const { dim } = paint(process15.stderr);
2330
2408
  const runs = await waitForCi({
2331
2409
  tool: "ft ci",
2332
2410
  short,
@@ -2349,7 +2427,7 @@ async function ci2(args) {
2349
2427
  },
2350
2428
  lines: (spinner, found, started) => [
2351
2429
  `${spinner} CI on ${short} ${dim(formatElapsed(Date.now() - started))}`,
2352
- ...(found ?? []).map((run) => ` ${badge(run.status, process12.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
2430
+ ...(found ?? []).map((run) => ` ${badge(run.status, process15.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
2353
2431
  ]
2354
2432
  });
2355
2433
  const status = overall(runs);
@@ -2368,7 +2446,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
2368
2446
  }
2369
2447
 
2370
2448
  // src/commands/digest.ts
2371
- import process13 from "process";
2449
+ import process16 from "process";
2372
2450
  var RUNS_SCANNED = 50;
2373
2451
  var TITLE_WIDTH2 = 70;
2374
2452
  var SHOWN = 8;
@@ -2418,7 +2496,7 @@ async function quietly(read) {
2418
2496
  }
2419
2497
  }
2420
2498
  async function staleTodos() {
2421
- const bin = Bun.which("todo-scan", { PATH: process13.env.PATH ?? "" });
2499
+ const bin = Bun.which("todo-scan", { PATH: process16.env.PATH ?? "" });
2422
2500
  if (bin === null)
2423
2501
  return [];
2424
2502
  let found;
@@ -2463,7 +2541,7 @@ ${lines.join(`
2463
2541
 
2464
2542
  `);
2465
2543
  }
2466
- var usage2 = `ft digest
2544
+ var usage3 = `ft digest
2467
2545
 
2468
2546
  Summarises the repository for a session starting cold: the issues this session holds with their boxes left, the claims no live session here answers to, red or running CI on the default branch, unpushed commits, dirty files and TODO comments naming a closed issue.
2469
2547
  A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH.
@@ -2474,7 +2552,7 @@ var options2 = {
2474
2552
  ...repoOption
2475
2553
  };
2476
2554
  async function digest(args) {
2477
- const parsed = parse(args, usage2, options2);
2555
+ const parsed = parse(args, usage3, options2);
2478
2556
  const { values } = parsed;
2479
2557
  const [issues, sessions, branch, runs] = await Promise.all([openIssues(undefined, values.repo), liveSessions(), defaultBranch(), recentRuns(RUNS_SCANNED, values.repo)]);
2480
2558
  const comments = await commentsOfAll(issues, values.repo);
@@ -2490,49 +2568,221 @@ async function digest(args) {
2490
2568
  return 0;
2491
2569
  }
2492
2570
 
2493
- // src/commands/triage.ts
2494
- async function checkLabels(names, repo) {
2495
- if (names.length === 0)
2496
- return;
2497
- const known = await repoLabels(repo);
2498
- const missing = names.filter((name) => !known.includes(name));
2499
- if (missing.length > 0)
2500
- fail(`no label ${missing.join(", ")} in this repository, ${known.length === 0 ? "which has none" : `it has: ${known.join(", ")}`}`);
2501
- }
2502
- var stateOptions = {
2503
- message: { type: "string", short: "m", description: "a comment posted first, saying why" },
2504
- ...repoOption
2505
- };
2506
- async function setState(args, usage, wanted) {
2507
- const parsed = parse(args, usage, stateOptions);
2508
- const { values, positionals } = parsed;
2509
- for (const number of issueNumbers(positionals, usage)) {
2510
- if ((await getIssue(number, values.repo)).state === wanted) {
2511
- console.log(`#${number} is already ${wanted}`);
2512
- continue;
2513
- }
2514
- if (values.message !== undefined && values.message.trim() !== "")
2515
- await comment(number, values.message.trim(), values.repo);
2516
- if (wanted === "closed")
2517
- await close(number, values.repo);
2518
- else
2519
- await reopen(number, values.repo);
2520
- console.log(`${wanted === "closed" ? "closed" : "reopened"} #${number}`);
2521
- }
2522
- return 0;
2523
- }
2524
- var closeUsage = `ft close <n>... [-m <reason>]
2525
-
2526
- Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed.
2571
+ // src/commands/issue-target.ts
2572
+ var ISSUE_REFERENCE = /^#?\d+$/;
2573
+ async function chooseTarget(positionals, held, usage) {
2574
+ if (positionals[0] !== undefined && ISSUE_REFERENCE.test(positionals[0]))
2575
+ return { number: issueNumber(positionals[0], usage), rest: positionals.slice(1), defaulted: false };
2576
+ const [only, ...others] = await held();
2577
+ if (only === undefined || others.length > 0)
2578
+ fail(`an issue number is needed, this session holds ${only === undefined ? "none" : "several"}
2527
2579
 
2528
- Exits 0 when every issue is closed, 1 when Forgejo refuses, 2 on a usage error.`;
2529
- async function closeIssues(args) {
2530
- return setState(args, closeUsage, "closed");
2580
+ ${usage}`);
2581
+ return { number: only, rest: positionals, defaulted: true };
2531
2582
  }
2532
- var reopenUsage = `ft reopen <n>... [-m <reason>]
2533
-
2534
- Reopens closed issues, posting the -m reason first.
2535
-
2583
+ async function targetIssue(positionals, repo, usage) {
2584
+ const { number, rest, defaulted } = await chooseTarget(positionals, async () => heldIssues(repo), usage);
2585
+ if (defaulted)
2586
+ warn(`using #${number}, the issue this session holds`);
2587
+ return { number, rest };
2588
+ }
2589
+ var noteOptions = {
2590
+ message: { type: "string", short: "m", description: "comment this text on the issue" },
2591
+ file: { type: "string", short: "F", description: "comment the text of this file, - for stdin" }
2592
+ };
2593
+ async function noteText(values) {
2594
+ if (values.message !== undefined && values.file !== undefined)
2595
+ fail("give the comment once, as text or with -F");
2596
+ const text = values.file === undefined ? values.message : await readInput(values.file);
2597
+ return text?.trim() === "" ? undefined : text?.trim();
2598
+ }
2599
+ var NOT_FOUND = /not exist|not found|couldn't be found/i;
2600
+ async function isClosed(number, repo) {
2601
+ try {
2602
+ return (await getIssue(number, repo)).state === "closed";
2603
+ } catch (error) {
2604
+ if (error instanceof Error && NOT_FOUND.test(error.message))
2605
+ return false;
2606
+ throw error;
2607
+ }
2608
+ }
2609
+ async function closedReferences(body, repo) {
2610
+ const listed = [...new Set(referencedBoxes(body).filter(({ box }) => !box.done).map(({ issue }) => issue))];
2611
+ const states = await Promise.all(listed.map(async (issue) => isClosed(issue, repo)));
2612
+ return new Set(listed.filter((_, at) => states[at] === true));
2613
+ }
2614
+
2615
+ // src/commands/issue-progress.ts
2616
+ var tickUsage = `ft tick [<n>] <box>...
2617
+
2618
+ Ticks checklist boxes of issue <n>, each given by its number from \`ft issue\` or by text matching exactly one box, then posts the -m or -F comment.
2619
+ With --closed, ticks instead every box opening with \`#<issue>\` whose issue is closed, as a release plan lists them.
2620
+
2621
+ Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.
2622
+
2623
+ Exits 0 when it ticked the boxes, 1 when Forgejo refuses, 2 on a usage error or a box matching none or several.`;
2624
+ var tickOptions = {
2625
+ undo: { type: "boolean", short: "u", description: "untick them instead" },
2626
+ closed: { type: "boolean", description: "tick the boxes listing a closed issue, no box to name" },
2627
+ ...noteOptions,
2628
+ ...repoOption
2629
+ };
2630
+ function tickedOrFail(number, run) {
2631
+ try {
2632
+ return run();
2633
+ } catch (error) {
2634
+ fail(`#${number}: ${error instanceof Error ? error.message : String(error)}`);
2635
+ }
2636
+ }
2637
+ async function tick(args) {
2638
+ const parsed = parse(args, tickUsage, tickOptions);
2639
+ const { values, positionals } = parsed;
2640
+ const { number, rest: picks } = await targetIssue(positionals, values.repo, tickUsage);
2641
+ if (values.closed === true && (picks.length > 0 || values.undo === true))
2642
+ fail(`--closed takes no boxes and no --undo
2643
+
2644
+ ${tickUsage}`);
2645
+ if (picks.length === 0 && values.closed !== true)
2646
+ fail(`name the boxes to tick
2647
+
2648
+ ${tickUsage}`);
2649
+ const note = await noteText(values);
2650
+ const found = await getIssue(number, values.repo);
2651
+ const done = values.undo !== true;
2652
+ const closed = values.closed === true ? await closedReferences(found.body, values.repo) : undefined;
2653
+ const apply = (body) => closed === undefined ? setBoxes(body, picks, done) : tickReferences(body, (issue) => closed.has(issue));
2654
+ let result = tickedOrFail(number, () => apply(found.body));
2655
+ if (result.changed.length > 0) {
2656
+ await editBody(number, (body) => {
2657
+ result = tickedOrFail(number, () => apply(body));
2658
+ return result.body;
2659
+ }, values.repo);
2660
+ }
2661
+ for (const box of result.changed)
2662
+ console.log(`${done ? "ticked" : "unticked"} ${box.number}: ${box.text}`);
2663
+ const left = boxes(result.body).filter((box) => !box.done).length;
2664
+ console.log(`#${number}: ${result.changed.length === 0 ? "nothing to change, " : ""}${left} box${left === 1 ? "" : "es"} left`);
2665
+ if (note !== undefined) {
2666
+ await comment(number, note, values.repo);
2667
+ console.log(`commented on #${number}`);
2668
+ }
2669
+ return 0;
2670
+ }
2671
+ var fixedUsage = `ft fixed [<n>] [commit]...
2672
+
2673
+ Comments "Fixed in <sha>: <message>" on issue <n> and closes it, naming each commit given as "Fixed in <a>, <b> and <c>".
2674
+ Without a commit it takes those on origin's default branch whose message names #<n>, and says which, or HEAD when none does.
2675
+ Without <n> it takes the one open issue this session holds (\`ft take\`). The message defaults to the subject of the first commit. Every open issue listing \`- [ ] #<n>\` in its checklist gets that line ticked. An issue with boxes left is refused, as a partly done issue stays open, unless --tick ticks them first.
2676
+
2677
+ Exits 0 when it closed the issue, 1 when the issue is already closed, has boxes left or Forgejo refuses, 2 on a usage error.`;
2678
+ var fixedOptions = {
2679
+ message: { type: "string", short: "m", description: 'the line after "Fixed in <sha>:"' },
2680
+ tick: { type: "boolean", description: "tick the boxes left before closing" },
2681
+ force: { type: "boolean", description: "close even with boxes left" },
2682
+ ...repoOption
2683
+ };
2684
+ function joinShas(shas) {
2685
+ const last = shas.at(-1) ?? "";
2686
+ return shas.length < 2 ? last : `${shas.slice(0, -1).join(", ")} and ${last}`;
2687
+ }
2688
+ async function fixingCommits(number, given) {
2689
+ if (given.length > 0) {
2690
+ const named = [];
2691
+ for (const ref of given) {
2692
+ const sha = await resolveCommit(ref);
2693
+ named.push({ sha, subject: await git(["log", "-1", "--format=%s", sha]) });
2694
+ }
2695
+ return named;
2696
+ }
2697
+ const ref = `origin/${await defaultBranch()}`;
2698
+ const found = await commitsNaming(number, ref);
2699
+ if (found.length > 0) {
2700
+ console.log(`commits on ${ref} naming #${number}:
2701
+ ${found.map((each) => ` ${each.sha.slice(0, 7)} ${each.subject}`).join(`
2702
+ `)}`);
2703
+ return found;
2704
+ }
2705
+ const sha = await resolveCommit("HEAD");
2706
+ console.log(`no commit on ${ref} names #${number}, using HEAD`);
2707
+ return [{ sha, subject: await git(["log", "-1", "--format=%s", sha]) }];
2708
+ }
2709
+ async function tickListings(closed, repo) {
2710
+ for (const listing of await openIssues(undefined, repo)) {
2711
+ if (!referencedBoxes(listing.body).some(({ box, issue }) => issue === closed && !box.done))
2712
+ continue;
2713
+ if (await editBody(listing.number, (body) => tickReferences(body, (issue) => issue === closed).body, repo))
2714
+ console.log(`ticked #${closed} in #${listing.number}`);
2715
+ }
2716
+ }
2717
+ async function fixed(args) {
2718
+ const parsed = parse(args, fixedUsage, fixedOptions);
2719
+ const { values, positionals } = parsed;
2720
+ const { number, rest } = await targetIssue(positionals, values.repo, fixedUsage);
2721
+ const commits = await fixingCommits(number, rest);
2722
+ const found = await getIssue(number, values.repo);
2723
+ if (found.state === "closed")
2724
+ fail(`#${number} is already closed`, 1, runHint(`ft reopen ${number}`, "reopen it"));
2725
+ const left = boxes(found.body).filter((box) => !box.done);
2726
+ if (left.length > 0 && values.tick === true) {
2727
+ await editBody(number, (body) => setBoxes(body, boxes(body).filter((box) => !box.done).map((box) => String(box.number)), true).body, values.repo);
2728
+ console.log(`ticked ${left.length} box${left.length === 1 ? "" : "es"} of #${number}`);
2729
+ } else if (left.length > 0 && values.force !== true) {
2730
+ fail(`#${number} has ${left.length} boxes left:
2731
+ ${left.map((box) => `${String(box.number).padStart(3)} [ ] ${box.text}`).join(`
2732
+ `)}`, 1, `${runHint(`ft fixed ${number} --tick`, "tick them and close")}, or ${runHint(`ft fixed ${number} --force`, "close with them left")}`);
2733
+ }
2734
+ const shas = joinShas(commits.map((each) => each.sha.slice(0, 7)));
2735
+ const line = `Fixed in ${shas}: ${values.message ?? commits[0]?.subject ?? ""}`;
2736
+ if ((await commentsOf(number, values.repo)).at(-1)?.body.trim() !== line.trim())
2737
+ await comment(number, line, values.repo);
2738
+ await close(number, values.repo);
2739
+ console.log(`closed #${number}: fixed in ${shas}`);
2740
+ await tickListings(number, values.repo);
2741
+ return 0;
2742
+ }
2743
+ // src/commands/triage.ts
2744
+ async function checkLabels(names, repo) {
2745
+ if (names.length === 0)
2746
+ return;
2747
+ const known = await repoLabels(repo);
2748
+ const missing = names.filter((name) => !known.includes(name));
2749
+ if (missing.length > 0)
2750
+ fail(`no label ${missing.join(", ")} in this repository, ${known.length === 0 ? "which has none" : `it has: ${known.join(", ")}`}`);
2751
+ }
2752
+ var stateOptions = {
2753
+ message: { type: "string", short: "m", description: "a comment posted first, saying why" },
2754
+ ...repoOption
2755
+ };
2756
+ async function setState(args, usage, wanted) {
2757
+ const parsed = parse(args, usage, stateOptions);
2758
+ const { values, positionals } = parsed;
2759
+ for (const number of issueNumbers(positionals, usage)) {
2760
+ if ((await getIssue(number, values.repo)).state === wanted) {
2761
+ console.log(`#${number} is already ${wanted}`);
2762
+ continue;
2763
+ }
2764
+ if (values.message !== undefined && values.message.trim() !== "")
2765
+ await comment(number, values.message.trim(), values.repo);
2766
+ if (wanted === "closed")
2767
+ await close(number, values.repo);
2768
+ else
2769
+ await reopen(number, values.repo);
2770
+ console.log(`${wanted === "closed" ? "closed" : "reopened"} #${number}`);
2771
+ }
2772
+ return 0;
2773
+ }
2774
+ var closeUsage = `ft close <n>... [-m <reason>]
2775
+
2776
+ Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed.
2777
+
2778
+ Exits 0 when every issue is closed, 1 when Forgejo refuses, 2 on a usage error.`;
2779
+ async function closeIssues(args) {
2780
+ return setState(args, closeUsage, "closed");
2781
+ }
2782
+ var reopenUsage = `ft reopen <n>... [-m <reason>]
2783
+
2784
+ Reopens closed issues, posting the -m reason first.
2785
+
2536
2786
  Exits 0 when every issue is open, 1 when Forgejo refuses, 2 on a usage error.`;
2537
2787
  async function reopenIssues(args) {
2538
2788
  return setState(args, reopenUsage, "open");
@@ -2582,135 +2832,7 @@ ${labelUsage}`);
2582
2832
  return 0;
2583
2833
  }
2584
2834
 
2585
- // src/commands/issue.ts
2586
- var issueUsage = `ft issue [<n>...]
2587
-
2588
- Prints each issue: its title, state, boxes left and claim, then its description with each checklist box numbered as \`ft tick\` takes it.
2589
- With --body, prints only the raw description, to edit and give back to \`ft edit -F\`.
2590
- With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none.
2591
-
2592
- Exits 0 when it printed them, 1 when an issue cannot be read, 2 on a usage error.`;
2593
- var issueOptions = {
2594
- todo: { type: "boolean", short: "t", description: "only the header and the boxes left to tick" },
2595
- comments: { type: "boolean", short: "c", description: "add the comments, each with its author and age" },
2596
- body: { type: "boolean", short: "b", description: "only the raw description, without numbered boxes" },
2597
- json: jsonOption("number, title, state, url, labels, claim, boxes, body and comments, an array for several issues"),
2598
- ...repoOption
2599
- };
2600
- function renderIssue(found, comments, view, now = Date.now()) {
2601
- const claim = latestClaim(comments, view.author);
2602
- const list = boxes(found.body);
2603
- const left = list.filter((box) => !box.done);
2604
- const facts = [found.state];
2605
- if (list.length > 0)
2606
- facts.push(`${left.length} of ${list.length} boxes left`);
2607
- if (claim !== undefined)
2608
- facts.push(`taken by ${claim.holder} ${formatAge(claim.at, now)}`);
2609
- const header = `#${found.number} ${found.title} (${facts.join(", ")})`;
2610
- if (view.todo)
2611
- return [header, ...left.map((box) => `${String(box.number).padStart(3)} [ ] ${box.text}`)].join(`
2612
- `);
2613
- const parts = [`${header}
2614
- ${found.html_url}`];
2615
- const body = numberedBody(found.body);
2616
- if (body !== "")
2617
- parts.push(body);
2618
- if (view.comments) {
2619
- for (const each of comments)
2620
- parts.push(`--- ${each.user.login}, ${formatAge(each.created_at, now)}
2621
- ${each.body.replaceAll(`\r
2622
- `, `
2623
- `).trim()}`);
2624
- }
2625
- return parts.join(`
2626
-
2627
- `);
2628
- }
2629
- function issueJson(found, comments, author) {
2630
- return {
2631
- number: found.number,
2632
- title: found.title,
2633
- state: found.state,
2634
- url: found.html_url,
2635
- labels: found.labels.map((label) => label.name),
2636
- claim: latestClaim(comments, author) ?? null,
2637
- boxes: boxes(found.body).map(({ number, done, text }) => ({ number, done, text })),
2638
- body: found.body,
2639
- comments: comments.map((each) => ({ author: each.user.login, at: each.created_at, body: each.body }))
2640
- };
2641
- }
2642
- async function issue(args) {
2643
- const parsed = parse(args, issueUsage, issueOptions);
2644
- const { values, positionals } = parsed;
2645
- const held = positionals.length === 0 ? await heldIssues(values.repo) : [];
2646
- const numbers = held.length === 0 ? issueNumbers(positionals, issueUsage) : held;
2647
- if (values.body === true) {
2648
- const bodies = await Promise.all(numbers.map(async (number) => (await getIssue(number, values.repo)).body.replaceAll(`\r
2649
- `, `
2650
- `)));
2651
- console.log(bodies.join(`
2652
-
2653
- `));
2654
- return 0;
2655
- }
2656
- const read = await Promise.all(numbers.map(async (number) => Promise.all([getIssue(number, values.repo), commentsOf(number, values.repo)])));
2657
- const author = await sessionAuthor();
2658
- if (values.json === true) {
2659
- const json = read.map(([found, comments]) => issueJson(found, comments, author));
2660
- printJson(json.length === 1 ? json[0] : json);
2661
- return 0;
2662
- }
2663
- const view = { todo: values.todo === true, comments: values.comments === true, author };
2664
- console.log(read.map(([found, comments]) => renderIssue(found, comments, view)).join(view.todo ? `
2665
-
2666
- ` : `
2667
-
2668
-
2669
- `));
2670
- return 0;
2671
- }
2672
- var ISSUE_REFERENCE = /^#?\d+$/;
2673
- async function chooseTarget(positionals, held, usage) {
2674
- if (positionals[0] !== undefined && ISSUE_REFERENCE.test(positionals[0]))
2675
- return { number: issueNumber(positionals[0], usage), rest: positionals.slice(1), defaulted: false };
2676
- const [only, ...others] = await held();
2677
- if (only === undefined || others.length > 0)
2678
- fail(`an issue number is needed, this session holds ${only === undefined ? "none" : "several"}
2679
-
2680
- ${usage}`);
2681
- return { number: only, rest: positionals, defaulted: true };
2682
- }
2683
- async function targetIssue(positionals, repo, usage) {
2684
- const { number, rest, defaulted } = await chooseTarget(positionals, async () => heldIssues(repo), usage);
2685
- if (defaulted)
2686
- warn(`using #${number}, the issue this session holds`);
2687
- return { number, rest };
2688
- }
2689
- var noteOptions = {
2690
- message: { type: "string", short: "m", description: "comment this text on the issue" },
2691
- file: { type: "string", short: "F", description: "comment the text of this file, - for stdin" }
2692
- };
2693
- async function noteText(values) {
2694
- if (values.message !== undefined && values.file !== undefined)
2695
- fail("give the comment once, as text or with -F");
2696
- const text = values.file === undefined ? values.message : await readInput(values.file);
2697
- return text?.trim() === "" ? undefined : text?.trim();
2698
- }
2699
- var NOT_FOUND = /not exist|not found|couldn't be found/i;
2700
- async function isClosed(number, repo) {
2701
- try {
2702
- return (await getIssue(number, repo)).state === "closed";
2703
- } catch (error) {
2704
- if (error instanceof Error && NOT_FOUND.test(error.message))
2705
- return false;
2706
- throw error;
2707
- }
2708
- }
2709
- async function closedReferences(body, repo) {
2710
- const listed = [...new Set(referencedBoxes(body).filter(({ box }) => !box.done).map(({ issue }) => issue))];
2711
- const states = await Promise.all(listed.map(async (issue) => isClosed(issue, repo)));
2712
- return new Set(listed.filter((_, at) => states[at] === true));
2713
- }
2835
+ // src/commands/issue-write.ts
2714
2836
  var newUsage = `ft new -t <title> [-F <file>] [-L a,b] [-m <milestone>]
2715
2837
 
2716
2838
  Creates an issue and prints its number and url. The description is read from -F <file>, or from stdin with -F -, and is empty without it. A label or milestone the repository lacks is refused before anything is created.
@@ -2794,61 +2916,6 @@ ${text}` : body;
2794
2916
  console.log(`edited #${number}`);
2795
2917
  return 0;
2796
2918
  }
2797
- var tickUsage = `ft tick [<n>] <box>...
2798
-
2799
- Ticks checklist boxes of issue <n>, each given by its number from \`ft issue\` or by text matching exactly one box, then posts the -m or -F comment.
2800
- With --closed, ticks instead every box opening with \`#<issue>\` whose issue is closed, as a release plan lists them.
2801
-
2802
- Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.
2803
-
2804
- Exits 0 when it ticked the boxes, 1 when Forgejo refuses, 2 on a usage error or a box matching none or several.`;
2805
- var tickOptions = {
2806
- undo: { type: "boolean", short: "u", description: "untick them instead" },
2807
- closed: { type: "boolean", description: "tick the boxes listing a closed issue, no box to name" },
2808
- ...noteOptions,
2809
- ...repoOption
2810
- };
2811
- function tickedOrFail(number, run) {
2812
- try {
2813
- return run();
2814
- } catch (error) {
2815
- fail(`#${number}: ${error instanceof Error ? error.message : String(error)}`);
2816
- }
2817
- }
2818
- async function tick(args) {
2819
- const parsed = parse(args, tickUsage, tickOptions);
2820
- const { values, positionals } = parsed;
2821
- const { number, rest: picks } = await targetIssue(positionals, values.repo, tickUsage);
2822
- if (values.closed === true && (picks.length > 0 || values.undo === true))
2823
- fail(`--closed takes no boxes and no --undo
2824
-
2825
- ${tickUsage}`);
2826
- if (picks.length === 0 && values.closed !== true)
2827
- fail(`name the boxes to tick
2828
-
2829
- ${tickUsage}`);
2830
- const note = await noteText(values);
2831
- const found = await getIssue(number, values.repo);
2832
- const done = values.undo !== true;
2833
- const closed = values.closed === true ? await closedReferences(found.body, values.repo) : undefined;
2834
- const apply = (body) => closed === undefined ? setBoxes(body, picks, done) : tickReferences(body, (issue) => closed.has(issue));
2835
- let result = tickedOrFail(number, () => apply(found.body));
2836
- if (result.changed.length > 0) {
2837
- await editBody(number, (body) => {
2838
- result = tickedOrFail(number, () => apply(body));
2839
- return result.body;
2840
- }, values.repo);
2841
- }
2842
- for (const box of result.changed)
2843
- console.log(`${done ? "ticked" : "unticked"} ${box.number}: ${box.text}`);
2844
- const left = boxes(result.body).filter((box) => !box.done).length;
2845
- console.log(`#${number}: ${result.changed.length === 0 ? "nothing to change, " : ""}${left} box${left === 1 ? "" : "es"} left`);
2846
- if (note !== undefined) {
2847
- await comment(number, note, values.repo);
2848
- console.log(`commented on #${number}`);
2849
- }
2850
- return 0;
2851
- }
2852
2919
  var commentUsage = `ft comment [<n>] [text]
2853
2920
 
2854
2921
  Posts a comment on issue <n>: the text given, -F <file>, or stdin when neither is, so a heredoc needs no escaping.
@@ -2873,81 +2940,97 @@ ${commentUsage}`);
2873
2940
  console.log(`commented on #${number}`);
2874
2941
  return 0;
2875
2942
  }
2876
- var fixedUsage = `ft fixed [<n>] [commit]...
2877
2943
 
2878
- Comments "Fixed in <sha>: <message>" on issue <n> and closes it, naming each commit given as "Fixed in <a>, <b> and <c>".
2879
- Without a commit it takes those on origin's default branch whose message names #<n>, and says which, or HEAD when none does.
2880
- Without <n> it takes the one open issue this session holds (\`ft take\`). The message defaults to the subject of the first commit. Every open issue listing \`- [ ] #<n>\` in its checklist gets that line ticked. An issue with boxes left is refused, as a partly done issue stays open, unless --tick ticks them first.
2944
+ // src/commands/issue.ts
2945
+ var issueUsage = `ft issue [<n>...]
2881
2946
 
2882
- Exits 0 when it closed the issue, 1 when the issue is already closed, has boxes left or Forgejo refuses, 2 on a usage error.`;
2883
- var fixedOptions = {
2884
- message: { type: "string", short: "m", description: 'the line after "Fixed in <sha>:"' },
2885
- tick: { type: "boolean", description: "tick the boxes left before closing" },
2886
- force: { type: "boolean", description: "close even with boxes left" },
2947
+ Prints each issue: its title, state, boxes left and claim, then its description with each checklist box numbered as \`ft tick\` takes it.
2948
+ With --body, prints only the raw description, to edit and give back to \`ft edit -F\`.
2949
+ With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none.
2950
+
2951
+ Exits 0 when it printed them, 1 when an issue cannot be read, 2 on a usage error.`;
2952
+ var issueOptions = {
2953
+ todo: { type: "boolean", short: "t", description: "only the header and the boxes left to tick" },
2954
+ comments: { type: "boolean", short: "c", description: "add the comments, each with its author and age" },
2955
+ body: { type: "boolean", short: "b", description: "only the raw description, without numbered boxes" },
2956
+ json: jsonOption("number, title, state, url, labels, claim, boxes, body and comments, an array for several issues"),
2887
2957
  ...repoOption
2888
2958
  };
2889
- function joinShas(shas) {
2890
- const last = shas.at(-1) ?? "";
2891
- return shas.length < 2 ? last : `${shas.slice(0, -1).join(", ")} and ${last}`;
2892
- }
2893
- async function fixingCommits(number, given) {
2894
- if (given.length > 0) {
2895
- const named = [];
2896
- for (const ref of given) {
2897
- const sha = await resolveCommit(ref);
2898
- named.push({ sha, subject: await git(["log", "-1", "--format=%s", sha]) });
2899
- }
2900
- return named;
2901
- }
2902
- const ref = `origin/${await defaultBranch()}`;
2903
- const found = await commitsNaming(number, ref);
2904
- if (found.length > 0) {
2905
- console.log(`commits on ${ref} naming #${number}:
2906
- ${found.map((each) => ` ${each.sha.slice(0, 7)} ${each.subject}`).join(`
2907
- `)}`);
2908
- return found;
2909
- }
2910
- const sha = await resolveCommit("HEAD");
2911
- console.log(`no commit on ${ref} names #${number}, using HEAD`);
2912
- return [{ sha, subject: await git(["log", "-1", "--format=%s", sha]) }];
2913
- }
2914
- async function tickListings(closed, repo) {
2915
- for (const listing of await openIssues(undefined, repo)) {
2916
- if (!referencedBoxes(listing.body).some(({ box, issue }) => issue === closed && !box.done))
2917
- continue;
2918
- if (await editBody(listing.number, (body) => tickReferences(body, (issue) => issue === closed).body, repo))
2919
- console.log(`ticked #${closed} in #${listing.number}`);
2959
+ function renderIssue(found, comments, view, now = Date.now()) {
2960
+ const claim = latestClaim(comments, view.author);
2961
+ const list = boxes(found.body);
2962
+ const left = list.filter((box) => !box.done);
2963
+ const facts = [found.state];
2964
+ if (list.length > 0)
2965
+ facts.push(`${left.length} of ${list.length} boxes left`);
2966
+ if (claim !== undefined)
2967
+ facts.push(`taken by ${claim.holder} ${formatAge(claim.at, now)}`);
2968
+ const header = `#${found.number} ${found.title} (${facts.join(", ")})`;
2969
+ if (view.todo)
2970
+ return [header, ...left.map((box) => `${String(box.number).padStart(3)} [ ] ${box.text}`)].join(`
2971
+ `);
2972
+ const parts = [`${header}
2973
+ ${found.html_url}`];
2974
+ const body = numberedBody(found.body);
2975
+ if (body !== "")
2976
+ parts.push(body);
2977
+ if (view.comments) {
2978
+ for (const each of comments)
2979
+ parts.push(`--- ${each.user.login}, ${formatAge(each.created_at, now)}
2980
+ ${each.body.replaceAll(`\r
2981
+ `, `
2982
+ `).trim()}`);
2920
2983
  }
2984
+ return parts.join(`
2985
+
2986
+ `);
2921
2987
  }
2922
- async function fixed(args) {
2923
- const parsed = parse(args, fixedUsage, fixedOptions);
2924
- const { values, positionals } = parsed;
2925
- const { number, rest } = await targetIssue(positionals, values.repo, fixedUsage);
2926
- const commits = await fixingCommits(number, rest);
2927
- const found = await getIssue(number, values.repo);
2928
- if (found.state === "closed")
2929
- fail(`#${number} is already closed`, 1, runHint(`ft reopen ${number}`, "reopen it"));
2930
- const left = boxes(found.body).filter((box) => !box.done);
2931
- if (left.length > 0 && values.tick === true) {
2932
- await editBody(number, (body) => setBoxes(body, boxes(body).filter((box) => !box.done).map((box) => String(box.number)), true).body, values.repo);
2933
- console.log(`ticked ${left.length} box${left.length === 1 ? "" : "es"} of #${number}`);
2934
- } else if (left.length > 0 && values.force !== true) {
2935
- fail(`#${number} has ${left.length} boxes left:
2936
- ${left.map((box) => `${String(box.number).padStart(3)} [ ] ${box.text}`).join(`
2937
- `)}`, 1, `${runHint(`ft fixed ${number} --tick`, "tick them and close")}, or ${runHint(`ft fixed ${number} --force`, "close with them left")}`);
2988
+ function issueJson(found, comments, author) {
2989
+ return {
2990
+ number: found.number,
2991
+ title: found.title,
2992
+ state: found.state,
2993
+ url: found.html_url,
2994
+ labels: found.labels.map((label) => label.name),
2995
+ claim: latestClaim(comments, author) ?? null,
2996
+ boxes: boxes(found.body).map(({ number, done, text }) => ({ number, done, text })),
2997
+ body: found.body,
2998
+ comments: comments.map((each) => ({ author: each.user.login, at: each.created_at, body: each.body }))
2999
+ };
3000
+ }
3001
+ async function issue(args) {
3002
+ const parsed = parse(args, issueUsage, issueOptions);
3003
+ const { values, positionals } = parsed;
3004
+ const held = positionals.length === 0 ? await heldIssues(values.repo) : [];
3005
+ const numbers = held.length === 0 ? issueNumbers(positionals, issueUsage) : held;
3006
+ if (values.body === true) {
3007
+ const bodies = await Promise.all(numbers.map(async (number) => (await getIssue(number, values.repo)).body.replaceAll(`\r
3008
+ `, `
3009
+ `)));
3010
+ console.log(bodies.join(`
3011
+
3012
+ `));
3013
+ return 0;
2938
3014
  }
2939
- const shas = joinShas(commits.map((each) => each.sha.slice(0, 7)));
2940
- const line = `Fixed in ${shas}: ${values.message ?? commits[0]?.subject ?? ""}`;
2941
- if ((await commentsOf(number, values.repo)).at(-1)?.body.trim() !== line.trim())
2942
- await comment(number, line, values.repo);
2943
- await close(number, values.repo);
2944
- console.log(`closed #${number}: fixed in ${shas}`);
2945
- await tickListings(number, values.repo);
3015
+ const read = await Promise.all(numbers.map(async (number) => Promise.all([getIssue(number, values.repo), commentsOf(number, values.repo)])));
3016
+ const author = await sessionAuthor();
3017
+ if (values.json === true) {
3018
+ const json = read.map(([found, comments]) => issueJson(found, comments, author));
3019
+ printJson(json.length === 1 ? json[0] : json);
3020
+ return 0;
3021
+ }
3022
+ const view = { todo: values.todo === true, comments: values.comments === true, author };
3023
+ console.log(read.map(([found, comments]) => renderIssue(found, comments, view)).join(view.todo ? `
3024
+
3025
+ ` : `
3026
+
3027
+
3028
+ `));
2946
3029
  return 0;
2947
3030
  }
2948
3031
 
2949
3032
  // src/commands/logs.ts
2950
- var usage3 = `ft logs <run id>
3033
+ var usage4 = `ft logs <run id>
2951
3034
 
2952
3035
  Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step.
2953
3036
  With no failed job it prints every job's last lines; --full prints whole logs.
@@ -2965,7 +3048,7 @@ function pickJobs(jobs, wanted) {
2965
3048
  return failed.length > 0 ? failed : jobs;
2966
3049
  }
2967
3050
  async function logs2(args) {
2968
- const parsed = parse(args, usage3, options3);
3051
+ const parsed = parse(args, usage4, options3);
2969
3052
  const { values, positionals } = parsed;
2970
3053
  if (positionals[0] === undefined)
2971
3054
  fail("a run id is needed", 2, runHint("ft runs", "list them"));
@@ -3245,12 +3328,11 @@ function report(plan, added, skipped) {
3245
3328
  }
3246
3329
 
3247
3330
  // src/commands/release.ts
3248
- import { basename as basename2, join as join2, relative, resolve } from "path";
3249
- import process14 from "process";
3250
- var {$ } = globalThis.Bun;
3331
+ import { basename as basename3, join as join6 } from "path";
3332
+ var {$: $2 } = globalThis.Bun;
3251
3333
 
3252
3334
  // src/commands/watch.ts
3253
- var usage4 = `ft watch [--after <id>]
3335
+ var usage5 = `ft watch [--after <id>]
3254
3336
 
3255
3337
  Waits for runs to finish: those newer than run <id>, or else the ones in progress now.
3256
3338
  Exits 0 when every one passed or was skipped, 1 when one failed or was cancelled, 2 on a timeout or a stalled queue.`;
@@ -3350,7 +3432,7 @@ function elapsed(run, seen) {
3350
3432
  return seconds > 0 ? ` for ${formatSeconds(seconds)}` : "";
3351
3433
  }
3352
3434
  async function watch(args) {
3353
- const parsed = parse(args, usage4, options5);
3435
+ const parsed = parse(args, usage5, options5);
3354
3436
  const { values } = parsed;
3355
3437
  const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
3356
3438
  if (values.after !== undefined) {
@@ -3365,34 +3447,50 @@ async function watch(args) {
3365
3447
  return watchRuns((runs) => runs.filter((run) => active.has(run.id)), timeout, values.repo);
3366
3448
  }
3367
3449
 
3368
- // src/commands/release.ts
3369
- var usage5 = `ft release <patch|minor|major|x.y.z>
3370
- ft release --tagged
3450
+ // src/commands/release-checks.ts
3451
+ var limits = { pushMs: 5 * 60000 };
3452
+ var NO_RUN2 = 3 * 60000;
3453
+ var RUNS_LOOKED_AT = 20;
3454
+ async function alreadyPassed(sha) {
3455
+ try {
3456
+ const own = newestPerWorkflow((await recentRuns(RUNS_LOOKED_AT)).filter((run) => run.commit_sha === sha));
3457
+ return own.length > 0 && own.every((run) => FINISHED.has(run.status)) && ["success", "skipped"].includes(overall(own));
3458
+ } catch {
3459
+ return false;
3460
+ }
3461
+ }
3462
+ async function testsPass(sha, branch, timeout) {
3463
+ if (!await gitOk(["merge-base", "--is-ancestor", sha, `origin/${branch}`])) {
3464
+ const held = holdSignals();
3465
+ let push;
3466
+ try {
3467
+ push = await runTool("git push", ["git", "push", "origin", `${sha}:refs/heads/${branch}`], { timeoutMs: limits.pushMs, onStart: (child) => held.forward(child) });
3468
+ } finally {
3469
+ held.release();
3470
+ }
3471
+ if (held.signal !== undefined)
3472
+ fail(`interrupted by ${held.signal} while pushing ${sha.slice(0, 7)}, so nothing was bumped`, exitCodeOf(null, held.signal));
3473
+ if (push.code !== 0)
3474
+ fail(`origin refused the push of ${sha.slice(0, 7)}, so nothing was bumped:
3475
+ ${push.stderr.trim()}`, 1);
3476
+ console.log(`pushed ${branch} at ${sha.slice(0, 7)}, waiting for its runs before the bump`);
3477
+ } else if (await alreadyPassed(sha)) {
3478
+ return true;
3479
+ } else {
3480
+ console.log(`${branch} at ${sha.slice(0, 7)} is on origin, waiting for its runs before the bump`);
3481
+ }
3482
+ return await watchRuns((runs) => newestPerWorkflow(runs.filter((run) => run.commit_sha === sha)), timeout, undefined, NO_RUN2) === 0;
3483
+ }
3371
3484
 
3372
- Cuts a release from the default branch: first the commit it sits on is pushed and its runs waited for, so failing tests stop it before anything is bumped or tagged. Then \`bun pm version\` commits and tags the bump, one atomic push sends the branch and its tag, and it waits for the runs the push started and for the registry to serve the version.
3373
- --tagged releases a version commit already tagged at HEAD instead, for repos bumping with their own script; the runs waited for first are then those of the commit below it.
3374
- --package releases one workspace package of a monorepo on its own, tagged \`<folder>-v<version>\` (\`ft release patch -p ft\` tags packages/ft as ft-v0.3.0).
3375
- A refused or interrupted push drops the bump commit and its tag, so a retry starts clean; with --tagged the commit and tag are yours and stay.
3376
- Once released, an open milestone titled like the version (\`1.2.0\`, \`v1.2.0\` or the tag) has its closed issues listed and is closed; a failure there only warns.
3377
- --dry-run checks the same and prints the plan: the version bump, the tag, the pushes and the runs and registry it would wait for, changing nothing.
3378
- Exits 0 once released or planned, 1 when a run fails, origin refuses a push or the registry never serves the version, 2 on a timeout, a stalled queue, a refusal before anything ran (another branch, uncommitted changes, origin ahead) or a usage error.`;
3379
- var options6 = {
3380
- tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
3381
- package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/" },
3382
- "no-registry": { type: "boolean", description: "do not wait for the registry to serve the new version" },
3383
- "dry-run": { type: "boolean", description: "print what the release would do, changing nothing" },
3384
- timeout: { type: "string", short: "t", description: "how long to wait for the runs (15m), a bare number in minutes" }
3385
- };
3485
+ // src/commands/release-many.ts
3486
+ import { readdir } from "fs/promises";
3487
+ import { join as join3 } from "path";
3488
+
3489
+ // src/commands/release-version.ts
3386
3490
  var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
3387
3491
  var VERSION = /^\d+\.\d+\.\d+(?:-[\w.]+)?$/;
3388
3492
  var PARTS = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/;
3389
3493
  var LAST_NUMBER = /\d+$/;
3390
- var REGISTRY_TRIES = 12;
3391
- var REGISTRY_POLL = 5000;
3392
- var limits = { pushMs: 5 * 60000 };
3393
- var REGISTRY_INFO_MS = 30000;
3394
- var NO_RUN2 = 3 * 60000;
3395
- var RUNS_LOOKED_AT = 20;
3396
3494
  function taggedVersion(tag, prefix) {
3397
3495
  const version = tag.slice(prefix.length);
3398
3496
  return tag.startsWith(prefix) && VERSION.test(version) ? version : undefined;
@@ -3423,75 +3521,37 @@ function nextVersion(current, level) {
3423
3521
  }
3424
3522
  }
3425
3523
  }
3426
- async function packageDir(value) {
3427
- for (const dir of [resolve(value), join2(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
3428
- if (await Bun.file(join2(dir, "package.json")).exists())
3429
- return dir;
3430
- }
3431
- fail(`no package.json in ${value} nor in packages/${value}`);
3432
- }
3433
- async function commitPackageBump(dir, prefix) {
3434
- const { version } = await Bun.file(join2(dir, "package.json")).json();
3435
- const root = await git(["rev-parse", "--show-toplevel"]);
3436
- const tag = `${prefix}${version}`;
3437
- const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
3438
- if (lock.exitCode !== 0)
3439
- fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
3440
- await git(["add", join2(dir, "package.json"), join2(root, "bun.lock")]);
3441
- await git(["commit", "-q", "-m", tag]);
3442
- await git(["tag", "-a", tag, "-m", tag]);
3443
- }
3444
- async function waitForRegistry(name, version) {
3445
- for (let attempt = 0;attempt < REGISTRY_TRIES; attempt++) {
3446
- let served;
3447
- try {
3448
- served = (await runTool("bun info", ["bun", "info", name, "version", "--no-cache"], { timeoutMs: REGISTRY_INFO_MS })).stdout.trim().split(`
3449
- `).at(-1);
3450
- } catch (error) {
3451
- if (isPermanentFailure(error))
3452
- throw error;
3453
- }
3454
- if (served === version)
3455
- return true;
3456
- await Bun.sleep(REGISTRY_POLL);
3457
- }
3458
- return false;
3459
- }
3460
- async function alreadyPassed(sha) {
3461
- try {
3462
- const own = newestPerWorkflow((await recentRuns(RUNS_LOOKED_AT)).filter((run) => run.commit_sha === sha));
3463
- return own.length > 0 && own.every((run) => FINISHED.has(run.status)) && ["success", "skipped"].includes(overall(own));
3464
- } catch {
3465
- return false;
3466
- }
3524
+
3525
+ // src/commands/release-many.ts
3526
+ function parseTargets(spec, level) {
3527
+ return spec.split(",").filter((part) => part !== "").map((part) => {
3528
+ const [folder = "", own] = part.split(":");
3529
+ const chosen = own ?? level;
3530
+ if (folder === "" || !LEVELS.has(chosen) && !VERSION.test(chosen))
3531
+ fail(`${part} is no folder[:level] in --package`);
3532
+ return { folder, level: chosen };
3533
+ });
3467
3534
  }
3468
- async function testsPass(sha, branch, timeout) {
3469
- if (!await gitOk(["merge-base", "--is-ancestor", sha, `origin/${branch}`])) {
3470
- const held = holdSignals();
3471
- let push;
3472
- try {
3473
- push = await runTool("git push", ["git", "push", "origin", `${sha}:refs/heads/${branch}`], { timeoutMs: limits.pushMs, onStart: (child) => held.forward(child) });
3474
- } finally {
3475
- held.release();
3476
- }
3477
- if (held.signal !== undefined)
3478
- fail(`interrupted by ${held.signal} while pushing ${sha.slice(0, 7)}, so nothing was bumped`, exitCodeOf(null, held.signal));
3479
- if (push.code !== 0)
3480
- fail(`origin refused the push of ${sha.slice(0, 7)}, so nothing was bumped:
3481
- ${push.stderr.trim()}`, 1);
3482
- console.log(`pushed ${branch} at ${sha.slice(0, 7)}, waiting for its runs before the bump`);
3483
- } else if (await alreadyPassed(sha)) {
3484
- return true;
3485
- } else {
3486
- console.log(`${branch} at ${sha.slice(0, 7)} is on origin, waiting for its runs before the bump`);
3535
+ async function publishable() {
3536
+ const root = join3(await git(["rev-parse", "--show-toplevel"]), "packages");
3537
+ const folders = (await readdir(root, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted();
3538
+ const found = [];
3539
+ for (const folder of folders) {
3540
+ const file = Bun.file(join3(root, folder, "package.json"));
3541
+ if (await file.exists() && (await file.json()).private !== true)
3542
+ found.push(folder);
3487
3543
  }
3488
- return await watchRuns((runs) => newestPerWorkflow(runs.filter((run) => run.commit_sha === sha)), timeout, undefined, NO_RUN2) === 0;
3544
+ return found;
3489
3545
  }
3546
+
3547
+ // src/commands/release-plan.ts
3548
+ import { basename as basename2, join as join4, relative } from "path";
3549
+ import process17 from "process";
3490
3550
  async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
3491
- const file = Bun.file(join2(dir ?? ".", "package.json"));
3551
+ const file = Bun.file(join4(dir ?? ".", "package.json"));
3492
3552
  const pkg = await file.exists() ? await file.json() : undefined;
3493
- const name = pkg?.name ?? basename2(dir ?? process14.cwd());
3494
- const where = dir === undefined ? "" : ` in ${relative(process14.cwd(), dir) || "."}`;
3553
+ const name = pkg?.name ?? basename2(dir ?? process17.cwd());
3554
+ const where = dir === undefined ? "" : ` in ${relative(process17.cwd(), dir) || "."}`;
3495
3555
  const sha = base.slice(0, 7);
3496
3556
  let version;
3497
3557
  let bump;
@@ -3504,7 +3564,7 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
3504
3564
  console.log(`would release ${name} ${version}, tagged ${tag}`);
3505
3565
  } else {
3506
3566
  if (pkg?.version === undefined)
3507
- fail(`no version in ${join2(dir ?? ".", "package.json")}`);
3567
+ fail(`no version in ${join4(dir ?? ".", "package.json")}`);
3508
3568
  version = nextVersion(pkg.version, level);
3509
3569
  bump = dir === undefined ? `bun pm version ${level}, which commits and tags ${prefix}${version}` : `bun pm version ${level} --no-git-tag-version${where}, then commit it with bun.lock refreshed and tag ${prefix}${version}`;
3510
3570
  console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
@@ -3522,6 +3582,47 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
3522
3582
  console.log("dry run: nothing was pushed, committed or tagged");
3523
3583
  return 0;
3524
3584
  }
3585
+
3586
+ // src/commands/release-steps.ts
3587
+ import { join as join5, resolve } from "path";
3588
+ var {$ } = globalThis.Bun;
3589
+ var REGISTRY_TRIES = 12;
3590
+ var REGISTRY_POLL = 5000;
3591
+ var REGISTRY_INFO_MS = 30000;
3592
+ async function packageDir(value) {
3593
+ for (const dir of [resolve(value), join5(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
3594
+ if (await Bun.file(join5(dir, "package.json")).exists())
3595
+ return dir;
3596
+ }
3597
+ fail(`no package.json in ${value} nor in packages/${value}`);
3598
+ }
3599
+ async function commitPackageBump(dir, prefix) {
3600
+ const { version } = await Bun.file(join5(dir, "package.json")).json();
3601
+ const root = await git(["rev-parse", "--show-toplevel"]);
3602
+ const tag = `${prefix}${version}`;
3603
+ const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
3604
+ if (lock.exitCode !== 0)
3605
+ fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
3606
+ await git(["add", join5(dir, "package.json"), join5(root, "bun.lock")]);
3607
+ await git(["commit", "-q", "-m", tag]);
3608
+ await git(["tag", "-a", tag, "-m", tag]);
3609
+ }
3610
+ async function waitForRegistry(name, version) {
3611
+ for (let attempt = 0;attempt < REGISTRY_TRIES; attempt++) {
3612
+ let served;
3613
+ try {
3614
+ served = (await runTool("bun info", ["bun", "info", name, "version", "--no-cache"], { timeoutMs: REGISTRY_INFO_MS })).stdout.trim().split(`
3615
+ `).at(-1);
3616
+ } catch (error) {
3617
+ if (isPermanentFailure(error))
3618
+ throw error;
3619
+ }
3620
+ if (served === version)
3621
+ return true;
3622
+ await Bun.sleep(REGISTRY_POLL);
3623
+ }
3624
+ return false;
3625
+ }
3525
3626
  async function rollBack(preBump, tagsBefore) {
3526
3627
  try {
3527
3628
  for (const name of await tagsAt("HEAD")) {
@@ -3533,20 +3634,85 @@ async function rollBack(preBump, tagsBefore) {
3533
3634
  warn(`could not undo the bump, back to ${preBump.slice(0, 7)} by hand`, error instanceof Error ? error.message : String(error));
3534
3635
  }
3535
3636
  }
3637
+ async function settleMilestone(version, tag) {
3638
+ try {
3639
+ const names = new Set([version, `v${version}`, tag]);
3640
+ const found = (await listMilestones("open")).find((each) => names.has(each.title));
3641
+ if (found === undefined)
3642
+ return;
3643
+ const [done, left] = await Promise.all([closedIssues(found.id), openIssues(undefined, undefined, found.id)]);
3644
+ console.log(`milestone ${found.title}: ${done.length} closed issue${done.length === 1 ? "" : "s"}${done.length === 0 ? "" : `
3645
+ ${done.map((issue) => ` #${issue.number} ${issue.title}`).join(`
3646
+ `)}`}`);
3647
+ if (left.length > 0)
3648
+ warn(`${left.length} issue${left.length === 1 ? " is" : "s are"} still open in it`, left.map((issue) => `#${issue.number}`).join(" "));
3649
+ await closeMilestone(found.id);
3650
+ console.log(`closed milestone ${found.title}`);
3651
+ } catch (error) {
3652
+ warn(`released, but the milestone ${version} could not be settled`, error instanceof Error ? error.message : String(error));
3653
+ }
3654
+ }
3655
+
3656
+ // src/commands/release.ts
3657
+ var SEVERAL = /[,:]/;
3658
+ var usage6 = `ft release <patch|minor|major|x.y.z>
3659
+ ft release <level> -p <a,b:minor,...>
3660
+ ft release <level> --all
3661
+ ft release --tagged
3662
+
3663
+ Cuts a release from the default branch: first the commit it sits on is pushed and its runs waited for, so failing tests stop it before anything is bumped or tagged. Then \`bun pm version\` commits and tags the bump, one atomic push sends the branch and its tag, and it waits for the runs the push started and for the registry to serve the version.
3664
+ --tagged releases a version commit already tagged at HEAD instead, for repos bumping with their own script; the runs waited for first are then those of the commit below it.
3665
+ --package releases one workspace package of a monorepo on its own, tagged \`<folder>-v<version>\` (\`ft release patch -p ft\` tags packages/ft as ft-v0.3.0).
3666
+ --package takes several folders separated by commas, each optionally with its own level after a colon (\`-p ft:minor,db\` bumps ft by minor and db by the level given); --all takes every published package of the workspace. They are released one after the other and the run stops at the first one that fails, naming the ones not released.
3667
+ A refused or interrupted push drops the bump commit and its tag, so a retry starts clean; with --tagged the commit and tag are yours and stay.
3668
+ Once released, an open milestone titled like the version (\`1.2.0\`, \`v1.2.0\` or the tag) has its closed issues listed and is closed; a failure there only warns.
3669
+ --dry-run checks the same and prints the plan: the version bump, the tag, the pushes and the runs and registry it would wait for, changing nothing.
3670
+ Exits 0 once released or planned, 1 when a run fails, origin refuses a push or the registry never serves the version, 2 on a timeout, a stalled queue, a refusal before anything ran (another branch, uncommitted changes, origin ahead) or a usage error.`;
3671
+ var options6 = {
3672
+ tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
3673
+ package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/, several separated by commas" },
3674
+ all: { type: "boolean", description: "release every published package of the workspace, one after the other" },
3675
+ "no-registry": { type: "boolean", description: "do not wait for the registry to serve the new version" },
3676
+ "dry-run": { type: "boolean", description: "print what the release would do, changing nothing" },
3677
+ timeout: { type: "string", short: "t", description: "how long to wait for the runs (15m), a bare number in minutes" }
3678
+ };
3536
3679
  async function release(args) {
3537
- const parsed = parse(args, usage5, options6);
3680
+ const parsed = parse(args, usage6, options6);
3538
3681
  const { values, positionals } = parsed;
3539
3682
  const level = positionals[0];
3540
3683
  const tagged = values.tagged === true;
3541
3684
  if (tagged === (level !== undefined))
3542
3685
  fail(`give a level or --tagged
3543
3686
 
3544
- ${usage5}`);
3687
+ ${usage6}`);
3545
3688
  if (level !== undefined && !LEVELS.has(level) && !VERSION.test(level))
3546
3689
  fail(`${level} is no level nor x.y.z version`);
3690
+ if (values.all === true || SEVERAL.test(values.package ?? "")) {
3691
+ if (tagged || level === undefined)
3692
+ fail("--all and several packages take a level, not --tagged");
3693
+ if (values.all === true && values.package !== undefined)
3694
+ fail("give --all or --package, not both");
3695
+ const targets = parseTargets(values.package ?? (await publishable()).join(","), level);
3696
+ const flags = [...values["dry-run"] === true ? ["--dry-run"] : [], ...values["no-registry"] === true ? ["--no-registry"] : [], ...values.timeout === undefined ? [] : ["--timeout", values.timeout]];
3697
+ for (const [index, target] of targets.entries()) {
3698
+ console.log(`== ${target.level} ${target.folder} (${index + 1}/${targets.length})`);
3699
+ const stopped = () => console.error(`stopped at ${target.folder}, not released: ${targets.slice(index).map((each) => each.folder).join(", ")}`);
3700
+ try {
3701
+ const code = await release([target.level, "--package", target.folder, ...flags]);
3702
+ if (code === 0)
3703
+ continue;
3704
+ stopped();
3705
+ return code;
3706
+ } catch (error) {
3707
+ stopped();
3708
+ throw error;
3709
+ }
3710
+ }
3711
+ return 0;
3712
+ }
3547
3713
  const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
3548
3714
  const dir = values.package === undefined ? undefined : await packageDir(values.package);
3549
- const prefix = dir === undefined ? "v" : `${basename2(dir)}-v`;
3715
+ const prefix = dir === undefined ? "v" : `${basename3(dir)}-v`;
3550
3716
  const branch = await defaultBranch();
3551
3717
  const current = await git(["branch", "--show-current"]);
3552
3718
  if (current !== branch)
@@ -3554,7 +3720,7 @@ ${usage5}`);
3554
3720
  if (await git(["status", "--porcelain"]) !== "")
3555
3721
  fail("the tree has uncommitted changes", 2, runHint("gst", "see them, then commit them with gc"));
3556
3722
  await fetchBranch(branch);
3557
- if ((await $`git merge-base --is-ancestor ${`origin/${branch}`} HEAD`.quiet().nothrow()).exitCode !== 0)
3723
+ if ((await $2`git merge-base --is-ancestor ${`origin/${branch}`} HEAD`.quiet().nothrow()).exitCode !== 0)
3558
3724
  fail(`origin/${branch} has commits HEAD lacks`, 2, runHint(`git pull --rebase origin ${branch}`));
3559
3725
  const base = await git(["rev-parse", tagged ? "HEAD~1" : "HEAD"]);
3560
3726
  if (values["dry-run"] === true)
@@ -3572,7 +3738,7 @@ ${usage5}`);
3572
3738
  let isPushUnknown = false;
3573
3739
  try {
3574
3740
  if (level !== undefined) {
3575
- const bump = dir === undefined ? await $`bun pm version ${level}`.quiet().nothrow() : await $`bun pm version ${level} --no-git-tag-version`.cwd(dir).quiet().nothrow();
3741
+ const bump = dir === undefined ? await $2`bun pm version ${level}`.quiet().nothrow() : await $2`bun pm version ${level} --no-git-tag-version`.cwd(dir).quiet().nothrow();
3576
3742
  if (bump.exitCode !== 0)
3577
3743
  fail(`bun pm version ${level}: ${bump.stderr.toString().trim() || bump.stdout.toString().trim()}`);
3578
3744
  if (dir !== undefined)
@@ -3610,7 +3776,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
3610
3776
  const code = await watchRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2);
3611
3777
  if (code !== 0)
3612
3778
  return code;
3613
- const file = Bun.file(join2(dir ?? ".", "package.json"));
3779
+ const file = Bun.file(join6(dir ?? ".", "package.json"));
3614
3780
  const pkg = await file.exists() ? await file.json() : undefined;
3615
3781
  const version = tag.slice(prefix.length);
3616
3782
  if (values["no-registry"] === true || pkg?.name === undefined || pkg.private === true) {
@@ -3624,37 +3790,19 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
3624
3790
  await settleMilestone(version, tag);
3625
3791
  return 0;
3626
3792
  }
3627
- async function settleMilestone(version, tag) {
3628
- try {
3629
- const names = new Set([version, `v${version}`, tag]);
3630
- const found = (await listMilestones("open")).find((each) => names.has(each.title));
3631
- if (found === undefined)
3632
- return;
3633
- const [done, left] = await Promise.all([closedIssues(found.id), openIssues(undefined, undefined, found.id)]);
3634
- console.log(`milestone ${found.title}: ${done.length} closed issue${done.length === 1 ? "" : "s"}${done.length === 0 ? "" : `
3635
- ${done.map((issue) => ` #${issue.number} ${issue.title}`).join(`
3636
- `)}`}`);
3637
- if (left.length > 0)
3638
- warn(`${left.length} issue${left.length === 1 ? " is" : "s are"} still open in it`, left.map((issue) => `#${issue.number}`).join(" "));
3639
- await closeMilestone(found.id);
3640
- console.log(`closed milestone ${found.title}`);
3641
- } catch (error) {
3642
- warn(`released, but the milestone ${version} could not be settled`, error instanceof Error ? error.message : String(error));
3643
- }
3644
- }
3645
3793
 
3646
3794
  // src/commands/remote.ts
3647
3795
  import { lookup } from "dns/promises";
3648
- import { homedir as homedir3 } from "os";
3649
- var {$: $2 } = globalThis.Bun;
3796
+ import { homedir as homedir4 } from "os";
3797
+ var {$: $3 } = globalThis.Bun;
3650
3798
 
3651
3799
  // src/config.ts
3652
- import { homedir as homedir2 } from "os";
3653
- import { join as join3 } from "path";
3654
- function settingsPath(home = homedir2()) {
3655
- return join3(home, ".config", "ft", "config.json");
3800
+ import { homedir as homedir3 } from "os";
3801
+ import { join as join7 } from "path";
3802
+ function settingsPath(home = homedir3()) {
3803
+ return join7(home, ".config", "ft", "config.json");
3656
3804
  }
3657
- async function loadSettings(home = homedir2()) {
3805
+ async function loadSettings(home = homedir3()) {
3658
3806
  const path = settingsPath(home);
3659
3807
  const file = Bun.file(path);
3660
3808
  if (!await file.exists())
@@ -3711,7 +3859,7 @@ async function reachesHost(hostname, host, hostAddresses, addressesOf) {
3711
3859
  }
3712
3860
 
3713
3861
  // src/commands/remote.ts
3714
- var usage6 = `ft remote [--fix]
3862
+ var usage7 = `ft remote [--fix]
3715
3863
 
3716
3864
  Checks that origin's URLs name the Forgejo host itself: tea only finds the repository when origin's host is the login's ssh_host, never through an ssh alias such as \`forgejo\` or \`gitea\`.
3717
3865
  --fix switches every alias URL to \`git@<host>:<owner>/<repo>.git\` and proves it with \`git ls-remote\`.
@@ -3724,7 +3872,7 @@ var options7 = {
3724
3872
  };
3725
3873
  var HOSTNAME = /^hostname (.+)$/m;
3726
3874
  async function sshHostname(alias) {
3727
- return HOSTNAME.exec(await $2`ssh -G -- ${alias}`.quiet().nothrow().text())?.[1];
3875
+ return HOSTNAME.exec(await $3`ssh -G -- ${alias}`.quiet().nothrow().text())?.[1];
3728
3876
  }
3729
3877
  async function addresses(name) {
3730
3878
  try {
@@ -3744,15 +3892,15 @@ async function restoreOrigin(fetchUrl, pushUrls, changes) {
3744
3892
  function originHost(url) {
3745
3893
  return parseSshRemote(url)?.host ?? (URL.canParse(url) ? new URL(url).hostname : undefined);
3746
3894
  }
3747
- async function remote(args, home = homedir3()) {
3748
- const { values } = parse(args, usage6, options7);
3895
+ async function remote(args, home = homedir4()) {
3896
+ const { values } = parse(args, usage7, options7);
3749
3897
  const host = values.host ?? (await loadSettings(home)).remoteHost;
3750
3898
  if (host === undefined) {
3751
3899
  note(`no Forgejo host to check origin against: pass --host, or set "remoteHost" in ${settingsPath(home)}`);
3752
3900
  return 0;
3753
3901
  }
3754
3902
  const fetchUrl = await git(["remote", "get-url", "origin"]);
3755
- const pushUrls = (await $2`git config --get-all remote.origin.pushurl`.quiet().nothrow().text()).split(`
3903
+ const pushUrls = (await $3`git config --get-all remote.origin.pushurl`.quiet().nothrow().text()).split(`
3756
3904
  `).filter(Boolean);
3757
3905
  const hostAddresses = new Set(await addresses(host));
3758
3906
  const hostnames = new Map;
@@ -3801,7 +3949,7 @@ async function remote(args, home = homedir3()) {
3801
3949
  }
3802
3950
 
3803
3951
  // src/commands/runs.ts
3804
- var usage7 = `ft runs [--sha <ref>]
3952
+ var usage8 = `ft runs [--sha <ref>]
3805
3953
 
3806
3954
  Lists recent runs with what tea's own listing leaves empty: workflow, ref, duration and age, ten by default with the count of the rest (--full for all of them; --json is never cut unless --limit is given).
3807
3955
 
@@ -3820,7 +3968,7 @@ async function onCommit(sha, repo) {
3820
3968
  return { runs: found, total: found.length };
3821
3969
  }
3822
3970
  async function runs(args) {
3823
- const parsed = parse(args, usage7, options8);
3971
+ const parsed = parse(args, usage8, options8);
3824
3972
  const { values } = parsed;
3825
3973
  const limit = limitOf(values, DEFAULT_LIMIT);
3826
3974
  const { runs: found, total } = values.sha === undefined ? await runsListing(limit, values.repo, values.workflow) : await onCommit(values.sha, values.repo);
@@ -3846,7 +3994,7 @@ async function runs(args) {
3846
3994
  }
3847
3995
 
3848
3996
  // src/cli.ts
3849
- process15.exitCode = await runCli({
3997
+ process18.exitCode = await runCli({
3850
3998
  name: "ft",
3851
3999
  version,
3852
4000
  about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",