@kaynooo/cli-forgejo 0.20.0 → 0.22.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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +132 -108
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -16,7 +16,7 @@ Needs [tea](https://gitea.com/gitea/tea) logged in to the Forgejo instance (`tea
16
16
  | `ft ci [ref]` | waits for the push runs covering a commit on the default branch and prints each failed test's output; `--json` prints `{status, runs, failedJobs, url}`, `--quiet` only the announcement, the failures and the result |
17
17
  | `ft watch` | waits for the runs in progress, or `--after <id>` those newer than a run; `--json` and `--quiet` as `ft ci` |
18
18
  | `ft logs <run>` | what the failed jobs of a run say went wrong, `-j <name or id>` picks a job, `--full` for whole logs, `--json` for the run, its jobs and the failed ones with their excerpts |
19
- | `ft release <level>` | waits for the runs on HEAD, pushing it first when origin lacks it, then `bun pm version`, one atomic push of branch and tag, and waits for the runs and the registry; `-p <folder>` releases one workspace package as `<folder>-v<version>`; `--json` prints `{released, tag, package, version, status, runs, failedJobs, url}` (an array with several packages) |
19
+ | `ft release <level>` | waits for the runs on HEAD, pushing it first when origin lacks it, then `bun pm version`, one atomic push of branch and tag, and waits for the runs and the registry; `-p <folder>` releases one workspace package as `<folder>-v<version>`, `-p a,b` or `--all` several in one push and one test run; `--json` prints `{released, tag, package, version, status, runs, failedJobs, url}` (an array with several packages) |
20
20
  | `ft board` | open issues: available, taken by a live session, or claimed with no live session here, each claim with its boxes left and a stale one with its latest note (`-q <regex>` on titles, `--state available\|taken\|away`, `-L`, `-m <milestone>`, `--json`) |
21
21
  | `ft digest` | one screen for a session starting cold: the issues this session holds with their boxes left, claims no live session answers to, red or running CI on the default branch, unpushed commits, dirty files and TODO comments naming a closed issue (needs `todo-scan` on the PATH; empty sections left out, `--json`) |
22
22
  | `ft take <n>...` / `ft drop <n>...` | claims or gives back issues for the calling Claude Code session, `--lane` as `lane-<s>-<n>` |
package/dist/cli.js CHANGED
@@ -336,13 +336,13 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
336
336
  // ../kit/src/theme.ts
337
337
  var DEFAULT = {
338
338
  colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
339
- glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
339
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D" },
340
340
  accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
341
341
  bins: {}
342
342
  };
343
343
  var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
344
344
  var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
345
- var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
345
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+" };
346
346
  var PRESETS = {
347
347
  default: {},
348
348
  "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
@@ -549,11 +549,38 @@ function badge(word, stream, env = process6.env) {
549
549
  const { theme } = activeTheme();
550
550
  return tinted(paint(stream, env), theme.colors[status], env)(`${theme.glyphs[status]} ${word}`);
551
551
  }
552
+ function header(bin, context, stream, env = process6.env) {
553
+ if (!takesControlCodes(stream, env))
554
+ return "";
555
+ const colors = paint(stream, env);
556
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
557
+ const { theme } = activeTheme();
558
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
559
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec, env);
560
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
561
+ }
552
562
  function link(text, url, stream, env = process6.env) {
553
563
  if (takesControlCodes(stream, env))
554
564
  return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`;
555
565
  return text === url ? text : `${text} (${url})`;
556
566
  }
567
+ function printHeader(bin, context, stream = process6.stdout, env = process6.env) {
568
+ const line = header(bin, context, stream, env);
569
+ if (line !== "")
570
+ console.log(line);
571
+ }
572
+ function section(title, count, stream = process6.stdout, env = process6.env) {
573
+ const label = count === undefined ? title : `${title} (${count})`;
574
+ if (!takesControlCodes(stream, env))
575
+ return label;
576
+ const { glyphs } = activeTheme().theme;
577
+ const head = `${glyphs.corner}${glyphs.rule} ${label} `;
578
+ const width = Math.min(stream.columns ?? 60, 100);
579
+ return paint(stream, env).dim(head + glyphs.rule.repeat(Math.max(3, width - Bun.stringWidth(head))));
580
+ }
581
+ function hyperlink(text, url, stream, env = process6.env) {
582
+ return takesControlCodes(stream, env) ? link(text, url, stream, env) : text;
583
+ }
557
584
 
558
585
  // ../kit/src/format.ts
559
586
  var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
@@ -1726,6 +1753,8 @@ function commandPath(scope, argv) {
1726
1753
  }
1727
1754
  return path.length === 0 ? undefined : path.join(" ");
1728
1755
  }
1756
+ // ../kit/src/folders.ts
1757
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1729
1758
  // ../kit/src/git.ts
1730
1759
  import { basename, dirname as dirname4 } from "path";
1731
1760
  import process16 from "process";
@@ -2421,7 +2450,7 @@ function dimmed(text) {
2421
2450
  }
2422
2451
  function issueNumber2(issue) {
2423
2452
  const number = role("id", process.stdout)(`#${issue.number}`);
2424
- return takesControlCodes(process.stdout) ? link(number, issue.html_url, process.stdout) : number;
2453
+ return hyperlink(number, issue.html_url, process.stdout);
2425
2454
  }
2426
2455
  function boxesLeft(issue) {
2427
2456
  const list = boxes(issue.body);
@@ -2534,6 +2563,7 @@ async function board(args) {
2534
2563
  printJson(boardJson(rows.slice(0, limit)));
2535
2564
  return 0;
2536
2565
  }
2566
+ printHeader("ft", "board");
2537
2567
  console.log(rows.length === 0 && (query !== undefined || state !== undefined) ? "no open issue matches" : renderBoard(rows, Date.now(), limit));
2538
2568
  return 0;
2539
2569
  }
@@ -3079,8 +3109,8 @@ function renderDigest(digest, now = Date.now()) {
3079
3109
  { heading: "unpushed commits", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
3080
3110
  { heading: "dirty files", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${file.path}`)) },
3081
3111
  { heading: "stale TODO comments", count: digest.stale.length, lines: capped2(digest.stale.map((todo) => `${todo.issue} closed: ${todo.comments.map((each) => `${each.path}:${each.line}`).join(", ")}`)) }
3082
- ].filter((section) => section.count > 0);
3083
- return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, count, lines }) => `${heading} (${count})
3112
+ ].filter((each) => each.count > 0);
3113
+ return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, count, lines }) => `${section(heading, count)}
3084
3114
  ${lines.join(`
3085
3115
  `).replace(LINE_START2, " ")}`).join(`
3086
3116
 
@@ -3109,10 +3139,12 @@ async function digest(args) {
3109
3139
  const rows = issues.map((issue) => ({ issue, claim: latestClaim(comments.get(issue.number) ?? [], author) }));
3110
3140
  const [unpushed, dirty, stale] = await Promise.all([quietly(unpushedCommits), quietly(dirtyTree), staleTodos()]);
3111
3141
  const summary = { ...claims(rows, sessions, me), ci: unsettled(runs, branch), unpushed, dirty, stale };
3112
- if (values.json === true)
3142
+ if (values.json === true) {
3113
3143
  printJson(summary);
3114
- else
3144
+ } else {
3145
+ printHeader("ft", "digest");
3115
3146
  console.log(renderDigest(summary));
3147
+ }
3116
3148
  return 0;
3117
3149
  }
3118
3150
 
@@ -4147,12 +4179,11 @@ async function publishable() {
4147
4179
  // src/commands/release-plan.ts
4148
4180
  import { basename as basename2, join as join9, relative } from "path";
4149
4181
  import process23 from "process";
4150
- async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
4182
+ async function planOf({ level, dir, prefix }, registry) {
4151
4183
  const file = Bun.file(join9(dir ?? ".", "package.json"));
4152
4184
  const pkg = await file.exists() ? await file.json() : undefined;
4153
4185
  const name = pkg?.name ?? basename2(dir ?? process23.cwd());
4154
4186
  const where = dir === undefined ? "" : ` in ${relative(process23.cwd(), dir) || "."}`;
4155
- const sha = base.slice(0, 7);
4156
4187
  let version;
4157
4188
  let bump;
4158
4189
  if (level === undefined) {
@@ -4169,13 +4200,20 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
4169
4200
  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}`;
4170
4201
  console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
4171
4202
  }
4203
+ const registryStep = registry && pkg?.name !== undefined && pkg.private !== true ? `wait for the registry to serve ${pkg.name}@${version}` : `skip the registry for ${name}: ${registry ? "the package is private or unnamed" : "--no-registry"}`;
4204
+ return { tag: `${prefix}${version}`, bump, registryStep };
4205
+ }
4206
+ async function printPlan({ releases, branch, base, timeout, registry }) {
4207
+ const planned = [];
4208
+ for (const each of releases)
4209
+ planned.push(await planOf(each, registry));
4210
+ const sha = base.slice(0, 7);
4172
4211
  const pushed = await gitOk(["merge-base", "--is-ancestor", base, `origin/${branch}`]);
4173
- const registryStep = registry && pkg?.name !== undefined && pkg.private !== true ? `wait for the registry to serve ${pkg.name}@${version}` : `skip the registry: ${registry ? "the package is private or unnamed" : "--no-registry"}`;
4174
4212
  const steps = [
4175
4213
  pushed ? `wait for the runs on ${sha}, already on origin/${branch}` : `push ${branch} at ${sha}, which origin lacks, then wait for its runs`,
4176
- bump,
4177
- `push ${branch} and ${prefix}${version} in one atomic push, then wait for the runs it starts (${formatDuration(timeout)} at most)`,
4178
- registryStep
4214
+ ...planned.map((each) => each.bump),
4215
+ `push ${branch} and ${planned.map((each) => each.tag).join(", ")} in one atomic push, then wait for the runs it starts (${formatDuration(timeout)} at most)`,
4216
+ ...planned.map((each) => each.registryStep)
4179
4217
  ];
4180
4218
  console.log(steps.map((step, i) => ` ${i + 1}. ${step}`).join(`
4181
4219
  `));
@@ -4222,21 +4260,22 @@ async function waitForRegistry(name, version) {
4222
4260
  }
4223
4261
  return false;
4224
4262
  }
4225
- async function rollBack(preBump, tagsBefore, dir) {
4263
+ async function rollBack(preBump, dirs) {
4226
4264
  try {
4227
- for (const name of await tagsAt("HEAD")) {
4228
- if (!tagsBefore.has(name))
4229
- await git(["tag", "-d", name]);
4230
- }
4231
- await git(["reset", "--keep", preBump]);
4232
- if (dir !== undefined) {
4265
+ if (dirs.length > 0) {
4233
4266
  const root = await git(["rev-parse", "--show-toplevel"]);
4234
- const paths = [join10(dir, "package.json"), join10(root, "bun.lock")].map((path) => relative2(root, path));
4235
- const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", preBump, "--", ...paths])).split(`
4267
+ const paths = [...dirs.map((dir) => join10(dir, "package.json")), join10(root, "bun.lock")].map((path) => relative2(root, path));
4268
+ const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", "HEAD", "--", ...paths])).split(`
4236
4269
  `).filter((path) => path !== "");
4237
4270
  if (tracked.length > 0)
4238
- await git(["restore", `--source=${preBump}`, "--staged", "--worktree", "--", ...tracked.map((path) => join10(root, path))]);
4271
+ await git(["restore", "--source=HEAD", "--staged", "--worktree", "--", ...tracked.map((path) => join10(root, path))]);
4272
+ }
4273
+ for (const commit of (await git(["rev-list", `${preBump}..HEAD`])).split(`
4274
+ `).filter(Boolean)) {
4275
+ for (const name of await tagsAt(commit))
4276
+ await git(["tag", "-d", name]);
4239
4277
  }
4278
+ await git(["reset", "--keep", preBump]);
4240
4279
  } catch (error) {
4241
4280
  warn(`could not undo the bump, back to ${preBump.slice(0, 7)} by hand`, error instanceof Error ? error.message : String(error));
4242
4281
  }
@@ -4270,8 +4309,8 @@ ft release --tagged
4270
4309
  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.
4271
4310
  --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.
4272
4311
  --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).
4273
- --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.
4274
- 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.
4312
+ --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. Each package gets its own bump commit and tag, and one atomic push sends the branch with every tag, so the tests run once for them all; the registry is then waited for package by package, stopping at the first one it does not serve.
4313
+ A refused or interrupted push drops the bump commits and their tags, so a retry starts clean; with --tagged the commit and tag are yours and stay.
4275
4314
  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.
4276
4315
  --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.
4277
4316
  --json prints {released, tag, package, version, status, runs, failedJobs, url} on stdout and the progress on stderr, an array of them with --package a,b or --all; it does not take --dry-run.
@@ -4279,16 +4318,13 @@ Exits 0 once released or planned, 1 when a run fails, origin refuses a push or t
4279
4318
  var options6 = {
4280
4319
  tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
4281
4320
  package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/, several separated by commas" },
4282
- all: { type: "boolean", description: "release every published package of the workspace, one after the other" },
4321
+ all: { type: "boolean", description: "release every published package of the workspace in one push" },
4283
4322
  "no-registry": { type: "boolean", description: "do not wait for the registry to serve the new version" },
4284
4323
  "dry-run": { type: "boolean", description: "print what the release would do, changing nothing" },
4285
4324
  timeout: { type: "string", short: "t", description: "how long to wait for the runs (15m), a bare number in minutes" },
4286
4325
  json: jsonOption("what was released and how its runs ended")
4287
4326
  };
4288
4327
  async function release(args) {
4289
- return cut(args);
4290
- }
4291
- async function cut(args, sink) {
4292
4328
  const parsed = parse(args, usage6, options6);
4293
4329
  const { values, positionals } = parsed;
4294
4330
  const json = values.json === true;
@@ -4303,39 +4339,16 @@ async function cut(args, sink) {
4303
4339
  ${usage6}`);
4304
4340
  if (level !== undefined && !LEVELS.has(level) && !VERSION.test(level))
4305
4341
  fail(`${level} is no level nor x.y.z version`);
4306
- if (values.all === true || SEVERAL.test(values.package ?? "")) {
4307
- if (tagged || level === undefined)
4308
- fail("--all and several packages take a level, not --tagged");
4309
- if (values.all === true && values.package !== undefined)
4310
- fail("give --all or --package, not both");
4311
- const targets = parseTargets(values.package ?? (await publishable()).join(","), level);
4312
- const flags = [...json ? ["--json"] : [], ...values["dry-run"] === true ? ["--dry-run"] : [], ...values["no-registry"] === true ? ["--no-registry"] : [], ...values.timeout === undefined ? [] : ["--timeout", values.timeout]];
4313
- const results = [];
4314
- for (const [index, target] of targets.entries()) {
4315
- say(`== ${target.level} ${target.folder} (${index + 1}/${targets.length})`);
4316
- const stopped = () => console.error(`stopped at ${target.folder}, not released: ${targets.slice(index).map((each) => each.folder).join(", ")}`);
4317
- try {
4318
- const code = await cut([target.level, "--package", target.folder, ...flags], results);
4319
- if (code === 0)
4320
- continue;
4321
- stopped();
4322
- if (json)
4323
- printJson(results);
4324
- return code;
4325
- } catch (error) {
4326
- stopped();
4327
- if (json)
4328
- printJson(results);
4329
- throw error;
4330
- }
4331
- }
4332
- if (json)
4333
- printJson(results);
4334
- return 0;
4335
- }
4342
+ const several = values.all === true || SEVERAL.test(values.package ?? "");
4343
+ if (several && (tagged || level === undefined))
4344
+ fail("--all and several packages take a level, not --tagged");
4345
+ if (values.all === true && values.package !== undefined)
4346
+ fail("give --all or --package, not both");
4347
+ const targets = several && level !== undefined ? await Promise.all(parseTargets(values.package ?? (await publishable()).join(","), level).map(async (target) => ({ level: target.level, dir: await packageDir(target.folder) }))) : [{ level, dir: values.package === undefined ? undefined : await packageDir(values.package) }];
4348
+ if (targets.length === 0)
4349
+ fail("no package to release: --all found no published package, or --package named none");
4336
4350
  const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
4337
- const dir = values.package === undefined ? undefined : await packageDir(values.package);
4338
- const prefix = dir === undefined ? "v" : `${basename3(dir)}-v`;
4351
+ const prefixOf = (dir) => dir === undefined ? "v" : `${basename3(dir)}-v`;
4339
4352
  const branch = await defaultBranch();
4340
4353
  const current = await git(["branch", "--show-current"]);
4341
4354
  if (current !== branch)
@@ -4347,88 +4360,98 @@ ${usage6}`);
4347
4360
  fail(`origin/${branch} has commits HEAD lacks`, 2, runHint(`git pull --rebase origin ${branch}`));
4348
4361
  const base = await git(["rev-parse", tagged ? "HEAD~1" : "HEAD"]);
4349
4362
  if (values["dry-run"] === true)
4350
- return printPlan({ level, dir, prefix, branch, base, timeout, registry: values["no-registry"] !== true });
4363
+ return printPlan({ releases: targets.map(({ level, dir }) => ({ level, dir, prefix: prefixOf(dir) })), branch, base, timeout, registry: values["no-registry"] !== true });
4351
4364
  if (!await testsPass(base, branch, timeout, json))
4352
4365
  fail(`the runs on ${base.slice(0, 7)} failed, so nothing was bumped or tagged`, 1, runHint(`ft runs --sha ${base.slice(0, 7)}`, "list the runs, then ft logs <id> reads the failure"));
4353
4366
  const preBump = await git(["rev-parse", "HEAD"]);
4354
- const tagsBefore = new Set(await tagsAt("HEAD"));
4355
4367
  const before = (await recentRuns(1))[0]?.id ?? 0;
4356
4368
  const held = holdSignals();
4357
4369
  const signalOf = () => held.signal;
4358
- let tag = "";
4359
- let head = "";
4370
+ const bumped = [];
4360
4371
  let pushed = false;
4361
4372
  let isPushUnknown = false;
4362
4373
  try {
4363
- if (level !== undefined) {
4364
- 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();
4365
- if (bump.exitCode !== 0)
4366
- fail(`bun pm version ${level}: ${bump.stderr.toString().trim() || bump.stdout.toString().trim()}`);
4367
- if (dir !== undefined)
4368
- await commitPackageBump(dir, prefix);
4374
+ for (const { level, dir } of targets) {
4375
+ const prefix = prefixOf(dir);
4376
+ if (level !== undefined) {
4377
+ 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();
4378
+ if (bump.exitCode !== 0)
4379
+ fail(`bun pm version ${level}${dir === undefined ? "" : ` in ${basename3(dir)}`}: ${bump.stderr.toString().trim() || bump.stdout.toString().trim()}`);
4380
+ if (dir !== undefined)
4381
+ await commitPackageBump(dir, prefix);
4382
+ }
4383
+ const tag = (await tagsAt("HEAD")).find((name) => taggedVersion(name, prefix) !== undefined);
4384
+ if (tag === undefined)
4385
+ fail(tagged ? `HEAD carries no ${prefix}* tag` : `the bump made no ${prefix}* tag`);
4386
+ bumped.push({ dir, prefix, tag, head: await git(["rev-parse", "HEAD"]) });
4387
+ if (held.signal !== undefined)
4388
+ fail(`interrupted by ${held.signal} before the push`, exitCodeOf(null, held.signal));
4369
4389
  }
4370
- const found = (await tagsAt("HEAD")).find((name) => taggedVersion(name, prefix) !== undefined);
4371
- if (found === undefined)
4372
- fail(tagged ? `HEAD carries no ${prefix}* tag` : `the bump made no ${prefix}* tag`);
4373
- tag = found;
4374
- head = await git(["rev-parse", "HEAD"]);
4375
- if (held.signal !== undefined)
4376
- fail(`interrupted by ${held.signal} before the push`, exitCodeOf(null, held.signal));
4390
+ const tags = bumped.map((each) => each.tag);
4377
4391
  let push;
4378
4392
  try {
4379
- push = await runTool("git push", ["git", "push", "--atomic", "origin", `HEAD:refs/heads/${branch}`, `refs/tags/${tag}`], { timeoutMs: limits.pushMs, onStart: (child) => held.forward(child) });
4393
+ push = await runTool("git push", ["git", "push", "--atomic", "origin", `HEAD:refs/heads/${branch}`, ...tags.map((tag) => `refs/tags/${tag}`)], { timeoutMs: limits.pushMs, onStart: (child) => held.forward(child) });
4380
4394
  } catch (error) {
4381
4395
  isPushUnknown = true;
4382
- fail(`${error instanceof Error ? error.message : String(error)}, so ${tag} and its commit are kept: the push may have landed`, 2, `git ls-remote origin refs/tags/${tag} tells; if it is there, ft release --tagged waits for its runs`);
4396
+ fail(`${error instanceof Error ? error.message : String(error)}, so ${tags.join(", ")} and ${tags.length === 1 ? "its commit are" : "their commits are"} kept: the push may have landed`, 2, tags.length === 1 ? `git ls-remote origin refs/tags/${tags[0]} tells; if it is there, ft release --tagged waits for its runs` : `git ls-remote --tags origin tells; if they are there, ft watch --after ${before} waits for their runs`);
4383
4397
  }
4384
4398
  if (push.code !== 0) {
4385
4399
  const signal = signalOf();
4386
- fail(`origin refused the push${signal === undefined ? "" : `, or ${signal} interrupted it`}, so ${level === undefined ? `${tag} and its commit are kept for a retry` : `${tag} and its commit were dropped for a clean retry`}:
4400
+ const kept = tagged ? `${tags.join(", ")} and its commit are kept for a retry` : `${tags.join(", ")} and ${tags.length === 1 ? "its commit were" : "their commits were"} dropped for a clean retry`;
4401
+ fail(`origin refused the push${signal === undefined ? "" : `, or ${signal} interrupted it`}, so ${kept}:
4387
4402
  ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
4388
4403
  }
4389
4404
  pushed = true;
4390
4405
  } finally {
4391
4406
  held.release();
4392
- if (!pushed && !isPushUnknown && level !== undefined)
4393
- await rollBack(preBump, tagsBefore, dir);
4407
+ if (!pushed && !isPushUnknown && !tagged)
4408
+ await rollBack(preBump, targets.flatMap((target) => target.dir === undefined ? [] : [target.dir]));
4394
4409
  }
4395
- const file = Bun.file(join11(dir ?? ".", "package.json"));
4396
- const pkg = await file.exists() ? await file.json() : undefined;
4397
- const version = tag.slice(prefix.length);
4410
+ const heads = new Set(bumped.map((each) => each.head));
4411
+ const manifests = await Promise.all(bumped.map(async (each) => {
4412
+ const file = Bun.file(join11(each.dir ?? ".", "package.json"));
4413
+ return await file.exists() ? await file.json() : undefined;
4414
+ }));
4415
+ const released = new Set;
4398
4416
  let followed = { code: 0, runs: [], failedJobs: [] };
4399
- const outcome = (released) => {
4417
+ const report = () => {
4400
4418
  if (!json)
4401
4419
  return;
4402
- const result = { released, tag, package: pkg?.name ?? null, version, ...ciJson(followed.runs, followed.failedJobs) };
4403
- if (sink === undefined)
4404
- printJson(result);
4405
- else
4406
- sink.push(result);
4420
+ const results = bumped.map((each, index) => {
4421
+ const own = followed.runs.filter((run) => run.prettyref === each.tag || run.prettyref === branch);
4422
+ return { released: released.has(each), tag: each.tag, package: manifests[index]?.name ?? null, version: each.tag.slice(each.prefix.length), ...ciJson(own, followed.failedJobs.filter((job) => own.some((run) => run.id === job.run))) };
4423
+ });
4424
+ printJson(several ? results : results[0]);
4407
4425
  };
4408
4426
  try {
4409
4427
  const late = signalOf();
4410
4428
  if (late !== undefined)
4411
- fail(`interrupted by ${late} after ${tag} was pushed: its runs are not waited for`, exitCodeOf(null, late));
4412
- say(`pushed ${branch} and ${tag}, waiting for their runs`);
4413
- followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2, json ? process24.stderr : process24.stdout, { json });
4429
+ fail(`interrupted by ${late} after ${bumped.map((each) => each.tag).join(", ")} ${bumped.length === 1 ? "was pushed: its runs are" : "were pushed: their runs are"} not waited for`, exitCodeOf(null, late));
4430
+ say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
4431
+ followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process24.stderr : process24.stdout, { json });
4414
4432
  if (followed.code !== 0) {
4415
- outcome(false);
4433
+ report();
4416
4434
  return followed.code;
4417
4435
  }
4418
- if (values["no-registry"] === true || pkg?.name === undefined || pkg.private === true) {
4419
- say(`released ${tag}`);
4420
- await settleMilestone(version, tag, say);
4421
- outcome(true);
4422
- return 0;
4436
+ for (const [index, each] of bumped.entries()) {
4437
+ const pkg = manifests[index];
4438
+ const version = each.tag.slice(each.prefix.length);
4439
+ if (values["no-registry"] !== true && pkg?.name !== undefined && pkg.private !== true) {
4440
+ if (!await waitForRegistry(pkg.name, version)) {
4441
+ const rest = bumped.slice(index + 1).map((next) => next.tag);
4442
+ fail(`the runs passed but the registry does not serve ${pkg.name}@${version}${rest.length === 0 ? "" : `, so ${rest.join(", ")} ${rest.length === 1 ? "is" : "are"} pushed but not waited for`}: read the publish job with \`ft logs\``, 1);
4443
+ }
4444
+ say(`released ${pkg.name}@${version}`);
4445
+ } else {
4446
+ say(`released ${each.tag}`);
4447
+ }
4448
+ await settleMilestone(version, each.tag, say);
4449
+ released.add(each);
4423
4450
  }
4424
- if (!await waitForRegistry(pkg.name, version))
4425
- fail(`the runs passed but the registry does not serve ${pkg.name}@${version}: read the publish job with \`ft logs\``, 1);
4426
- say(`released ${pkg.name}@${version}`);
4427
- await settleMilestone(version, tag, say);
4428
- outcome(true);
4451
+ report();
4429
4452
  return 0;
4430
4453
  } catch (error) {
4431
- outcome(false);
4454
+ report();
4432
4455
  throw error;
4433
4456
  }
4434
4457
  }
@@ -4595,13 +4618,14 @@ async function runs(args) {
4595
4618
  printJson(list.map((run) => ({ id: run.id, number: run.index_in_repo, status: run.status, workflow: run.workflow_id, ref: run.prettyref, event: run.event, sha: run.commit_sha, seconds: runSeconds(run), started: run.started, title: run.title, url: run.html_url })));
4596
4619
  return 0;
4597
4620
  }
4621
+ printHeader("ft", "runs");
4598
4622
  if (list.length === 0) {
4599
4623
  console.log("no run");
4600
4624
  return 0;
4601
4625
  }
4602
4626
  console.log(table([
4603
4627
  ["ID", "STATUS", "WORKFLOW", "REF", "EVENT", "TOOK", "STARTED", "TITLE"],
4604
- ...list.map((run) => [String(run.id), badge(run.status, process.stdout), run.workflow_id, run.prettyref, run.event, run.duration > 0 ? formatSeconds(runSeconds(run)) : "-", startedAge(run), truncate(upTo(run.title, `
4628
+ ...list.map((run) => [hyperlink(String(run.id), run.html_url, process.stdout), badge(run.status, process.stdout), run.workflow_id, run.prettyref, run.event, run.duration > 0 ? formatSeconds(runSeconds(run)) : "-", startedAge(run), truncate(upTo(run.title, `
4605
4629
  `), TITLE_WIDTH4)])
4606
4630
  ], { header: true }));
4607
4631
  if (more > 0)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.20.0",
4
+ "version": "0.22.0",
5
5
  "description": "ft: Forgejo CI runs, logs, releases and issue checklists from the terminal, through tea.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -28,6 +28,6 @@
28
28
  "ft": "$npm_execpath src/cli.ts"
29
29
  },
30
30
  "devDependencies": {
31
- "@kaynooo/cli-kit": "0.25.0"
31
+ "@kaynooo/cli-kit": "0.27.1"
32
32
  }
33
33
  }