@kaynooo/cli-forgejo 0.13.0 → 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 +69 -17
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1534,7 +1534,7 @@ async function currentSession(sessions) {
1534
1534
  return;
1535
1535
  }
1536
1536
  // package.json
1537
- var version = "0.13.0";
1537
+ var version = "0.14.0";
1538
1538
 
1539
1539
  // src/args.ts
1540
1540
  var repoOption = {
@@ -3328,7 +3328,7 @@ function report(plan, added, skipped) {
3328
3328
  }
3329
3329
 
3330
3330
  // src/commands/release.ts
3331
- import { basename as basename3, join as join5 } from "path";
3331
+ import { basename as basename3, join as join6 } from "path";
3332
3332
  var {$: $2 } = globalThis.Bun;
3333
3333
 
3334
3334
  // src/commands/watch.ts
@@ -3482,11 +3482,12 @@ ${push.stderr.trim()}`, 1);
3482
3482
  return await watchRuns((runs) => newestPerWorkflow(runs.filter((run) => run.commit_sha === sha)), timeout, undefined, NO_RUN2) === 0;
3483
3483
  }
3484
3484
 
3485
- // src/commands/release-plan.ts
3486
- import { basename as basename2, join as join3, relative } from "path";
3487
- import process17 from "process";
3485
+ // src/commands/release-many.ts
3486
+ import { readdir } from "fs/promises";
3487
+ import { join as join3 } from "path";
3488
3488
 
3489
3489
  // src/commands/release-version.ts
3490
+ var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
3490
3491
  var VERSION = /^\d+\.\d+\.\d+(?:-[\w.]+)?$/;
3491
3492
  var PARTS = /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/;
3492
3493
  var LAST_NUMBER = /\d+$/;
@@ -3521,9 +3522,33 @@ function nextVersion(current, level) {
3521
3522
  }
3522
3523
  }
3523
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
+ });
3534
+ }
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);
3543
+ }
3544
+ return found;
3545
+ }
3546
+
3524
3547
  // src/commands/release-plan.ts
3548
+ import { basename as basename2, join as join4, relative } from "path";
3549
+ import process17 from "process";
3525
3550
  async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
3526
- const file = Bun.file(join3(dir ?? ".", "package.json"));
3551
+ const file = Bun.file(join4(dir ?? ".", "package.json"));
3527
3552
  const pkg = await file.exists() ? await file.json() : undefined;
3528
3553
  const name = pkg?.name ?? basename2(dir ?? process17.cwd());
3529
3554
  const where = dir === undefined ? "" : ` in ${relative(process17.cwd(), dir) || "."}`;
@@ -3539,7 +3564,7 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
3539
3564
  console.log(`would release ${name} ${version}, tagged ${tag}`);
3540
3565
  } else {
3541
3566
  if (pkg?.version === undefined)
3542
- fail(`no version in ${join3(dir ?? ".", "package.json")}`);
3567
+ fail(`no version in ${join4(dir ?? ".", "package.json")}`);
3543
3568
  version = nextVersion(pkg.version, level);
3544
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}`;
3545
3570
  console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
@@ -3559,26 +3584,26 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
3559
3584
  }
3560
3585
 
3561
3586
  // src/commands/release-steps.ts
3562
- import { join as join4, resolve } from "path";
3587
+ import { join as join5, resolve } from "path";
3563
3588
  var {$ } = globalThis.Bun;
3564
3589
  var REGISTRY_TRIES = 12;
3565
3590
  var REGISTRY_POLL = 5000;
3566
3591
  var REGISTRY_INFO_MS = 30000;
3567
3592
  async function packageDir(value) {
3568
- for (const dir of [resolve(value), join4(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
3569
- if (await Bun.file(join4(dir, "package.json")).exists())
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())
3570
3595
  return dir;
3571
3596
  }
3572
3597
  fail(`no package.json in ${value} nor in packages/${value}`);
3573
3598
  }
3574
3599
  async function commitPackageBump(dir, prefix) {
3575
- const { version } = await Bun.file(join4(dir, "package.json")).json();
3600
+ const { version } = await Bun.file(join5(dir, "package.json")).json();
3576
3601
  const root = await git(["rev-parse", "--show-toplevel"]);
3577
3602
  const tag = `${prefix}${version}`;
3578
3603
  const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
3579
3604
  if (lock.exitCode !== 0)
3580
3605
  fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
3581
- await git(["add", join4(dir, "package.json"), join4(root, "bun.lock")]);
3606
+ await git(["add", join5(dir, "package.json"), join5(root, "bun.lock")]);
3582
3607
  await git(["commit", "-q", "-m", tag]);
3583
3608
  await git(["tag", "-a", tag, "-m", tag]);
3584
3609
  }
@@ -3629,20 +3654,24 @@ ${done.map((issue) => ` #${issue.number} ${issue.title}`).join(`
3629
3654
  }
3630
3655
 
3631
3656
  // src/commands/release.ts
3632
- var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
3657
+ var SEVERAL = /[,:]/;
3633
3658
  var usage6 = `ft release <patch|minor|major|x.y.z>
3659
+ ft release <level> -p <a,b:minor,...>
3660
+ ft release <level> --all
3634
3661
  ft release --tagged
3635
3662
 
3636
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.
3637
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.
3638
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.
3639
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.
3640
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.
3641
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.
3642
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.`;
3643
3671
  var options6 = {
3644
3672
  tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
3645
- package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/" },
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" },
3646
3675
  "no-registry": { type: "boolean", description: "do not wait for the registry to serve the new version" },
3647
3676
  "dry-run": { type: "boolean", description: "print what the release would do, changing nothing" },
3648
3677
  timeout: { type: "string", short: "t", description: "how long to wait for the runs (15m), a bare number in minutes" }
@@ -3658,6 +3687,29 @@ async function release(args) {
3658
3687
  ${usage6}`);
3659
3688
  if (level !== undefined && !LEVELS.has(level) && !VERSION.test(level))
3660
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
+ }
3661
3713
  const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
3662
3714
  const dir = values.package === undefined ? undefined : await packageDir(values.package);
3663
3715
  const prefix = dir === undefined ? "v" : `${basename3(dir)}-v`;
@@ -3724,7 +3776,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
3724
3776
  const code = await watchRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2);
3725
3777
  if (code !== 0)
3726
3778
  return code;
3727
- const file = Bun.file(join5(dir ?? ".", "package.json"));
3779
+ const file = Bun.file(join6(dir ?? ".", "package.json"));
3728
3780
  const pkg = await file.exists() ? await file.json() : undefined;
3729
3781
  const version = tag.slice(prefix.length);
3730
3782
  if (values["no-registry"] === true || pkg?.name === undefined || pkg.private === true) {
@@ -3746,9 +3798,9 @@ var {$: $3 } = globalThis.Bun;
3746
3798
 
3747
3799
  // src/config.ts
3748
3800
  import { homedir as homedir3 } from "os";
3749
- import { join as join6 } from "path";
3801
+ import { join as join7 } from "path";
3750
3802
  function settingsPath(home = homedir3()) {
3751
- return join6(home, ".config", "ft", "config.json");
3803
+ return join7(home, ".config", "ft", "config.json");
3752
3804
  }
3753
3805
  async function loadSettings(home = homedir3()) {
3754
3806
  const path = settingsPath(home);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-forgejo",
3
3
  "type": "module",
4
- "version": "0.13.0",
4
+ "version": "0.14.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",