@kaynooo/cli-forgejo 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.js +166 -115
- 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
|
|
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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process25 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -1726,6 +1726,8 @@ function commandPath(scope, argv) {
|
|
|
1726
1726
|
}
|
|
1727
1727
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1728
1728
|
}
|
|
1729
|
+
// ../kit/src/folders.ts
|
|
1730
|
+
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1729
1731
|
// ../kit/src/git.ts
|
|
1730
1732
|
import { basename, dirname as dirname4 } from "path";
|
|
1731
1733
|
import process16 from "process";
|
|
@@ -1865,6 +1867,58 @@ async function currentSession(sessions) {
|
|
|
1865
1867
|
}
|
|
1866
1868
|
return;
|
|
1867
1869
|
}
|
|
1870
|
+
// ../kit/src/watch.ts
|
|
1871
|
+
import process18 from "process";
|
|
1872
|
+
import { format } from "util";
|
|
1873
|
+
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1874
|
+
var DEFAULT_SECONDS = 2;
|
|
1875
|
+
var ATTACHED_SHORT = /^-w./;
|
|
1876
|
+
var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
|
|
1877
|
+
function watchOption(what) {
|
|
1878
|
+
return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
|
|
1879
|
+
}
|
|
1880
|
+
function withoutWatch(args) {
|
|
1881
|
+
const rest = [];
|
|
1882
|
+
for (let at = 0;at < args.length; at++) {
|
|
1883
|
+
const arg = args[at];
|
|
1884
|
+
if (arg === "--watch" || arg === "-w") {
|
|
1885
|
+
if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
|
|
1886
|
+
at++;
|
|
1887
|
+
} else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
|
|
1888
|
+
rest.push(arg);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
return rest;
|
|
1892
|
+
}
|
|
1893
|
+
async function watching(value, step, stream = process18.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1894
|
+
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1895
|
+
if (!takesControlCodes(stream))
|
|
1896
|
+
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
1897
|
+
let code = 0;
|
|
1898
|
+
for (let round = 0;round < rounds; round++) {
|
|
1899
|
+
const held = [];
|
|
1900
|
+
const { log, info } = console;
|
|
1901
|
+
const write = process18.stdout.write.bind(process18.stdout);
|
|
1902
|
+
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1903
|
+
`);
|
|
1904
|
+
console.log = hold;
|
|
1905
|
+
console.info = hold;
|
|
1906
|
+
process18.stdout.write = (text) => {
|
|
1907
|
+
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1908
|
+
return true;
|
|
1909
|
+
};
|
|
1910
|
+
try {
|
|
1911
|
+
code = await step();
|
|
1912
|
+
} finally {
|
|
1913
|
+
console.log = log;
|
|
1914
|
+
console.info = info;
|
|
1915
|
+
process18.stdout.write = write;
|
|
1916
|
+
}
|
|
1917
|
+
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1918
|
+
await sleep(interval);
|
|
1919
|
+
}
|
|
1920
|
+
return code;
|
|
1921
|
+
}
|
|
1868
1922
|
// src/args.ts
|
|
1869
1923
|
var repoOption = {
|
|
1870
1924
|
repo: { type: "string", short: "r", description: "owner/name of the repository, instead of the one origin points at" }
|
|
@@ -2038,7 +2092,7 @@ function holderSession(holder, sessions) {
|
|
|
2038
2092
|
// src/forge.ts
|
|
2039
2093
|
import { homedir as homedir5 } from "os";
|
|
2040
2094
|
import { join as join7 } from "path";
|
|
2041
|
-
import
|
|
2095
|
+
import process20 from "process";
|
|
2042
2096
|
|
|
2043
2097
|
// src/remote.ts
|
|
2044
2098
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2093,7 +2147,7 @@ function loginHosts(config) {
|
|
|
2093
2147
|
return hosts;
|
|
2094
2148
|
}
|
|
2095
2149
|
function teaConfigPath() {
|
|
2096
|
-
const base =
|
|
2150
|
+
const base = process20.env.XDG_CONFIG_HOME;
|
|
2097
2151
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2098
2152
|
}
|
|
2099
2153
|
async function readConfig() {
|
|
@@ -2456,11 +2510,14 @@ var boardOptions = {
|
|
|
2456
2510
|
state: { type: "string", description: "only issues in this state: available, taken or away (claimed, no live session here)" },
|
|
2457
2511
|
...limitOptions(BOARD_LIMIT),
|
|
2458
2512
|
json: jsonOption("number, title, labels, state, holder, since, session, boxesTotal, boxesLeft and note (author, at, body of the latest comment that is not a claim)"),
|
|
2513
|
+
watch: watchOption("the board"),
|
|
2459
2514
|
...repoOption
|
|
2460
2515
|
};
|
|
2461
2516
|
async function board(args) {
|
|
2462
2517
|
const parsed = parse(args, boardUsage, boardOptions);
|
|
2463
2518
|
const { values } = parsed;
|
|
2519
|
+
if (values.watch !== undefined)
|
|
2520
|
+
return watching(values.watch, async () => board(withoutWatch(args)));
|
|
2464
2521
|
const state = values.state;
|
|
2465
2522
|
const limit = limitOf(values, BOARD_LIMIT);
|
|
2466
2523
|
if (state !== undefined && !STATES.has(state))
|
|
@@ -2625,7 +2682,7 @@ async function drop(args) {
|
|
|
2625
2682
|
}
|
|
2626
2683
|
|
|
2627
2684
|
// src/commands/ci.ts
|
|
2628
|
-
import
|
|
2685
|
+
import process21 from "process";
|
|
2629
2686
|
|
|
2630
2687
|
// src/git.ts
|
|
2631
2688
|
async function tagsAt(commit) {
|
|
@@ -2881,7 +2938,7 @@ async function ci2(args) {
|
|
|
2881
2938
|
return;
|
|
2882
2939
|
}
|
|
2883
2940
|
const json = values.json === true;
|
|
2884
|
-
const { dim } = paint(
|
|
2941
|
+
const { dim } = paint(process21.stderr);
|
|
2885
2942
|
const runs = await waitForCi({
|
|
2886
2943
|
tool: "ft ci",
|
|
2887
2944
|
short,
|
|
@@ -2906,7 +2963,7 @@ async function ci2(args) {
|
|
|
2906
2963
|
},
|
|
2907
2964
|
lines: (spinner, found, started) => [
|
|
2908
2965
|
`${spinner} CI on ${short} ${dim(formatElapsed(Date.now() - started))}`,
|
|
2909
|
-
...(found ?? []).map((run) => ` ${badge(run.status,
|
|
2966
|
+
...(found ?? []).map((run) => ` ${badge(run.status, process21.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
|
|
2910
2967
|
]
|
|
2911
2968
|
});
|
|
2912
2969
|
const status = overall(runs);
|
|
@@ -2936,7 +2993,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2936
2993
|
}
|
|
2937
2994
|
|
|
2938
2995
|
// src/commands/digest.ts
|
|
2939
|
-
import
|
|
2996
|
+
import process22 from "process";
|
|
2940
2997
|
var RUNS_SCANNED = 50;
|
|
2941
2998
|
var TITLE_WIDTH2 = 70;
|
|
2942
2999
|
var SHOWN = 8;
|
|
@@ -2986,7 +3043,7 @@ async function quietly(read) {
|
|
|
2986
3043
|
}
|
|
2987
3044
|
}
|
|
2988
3045
|
async function staleTodos() {
|
|
2989
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3046
|
+
const bin = Bun.which("todo-scan", { PATH: process22.env.PATH ?? "" });
|
|
2990
3047
|
if (bin === null)
|
|
2991
3048
|
return [];
|
|
2992
3049
|
let found;
|
|
@@ -3039,11 +3096,14 @@ A section with nothing in it is left out, and the stale TODO comments need todo-
|
|
|
3039
3096
|
Exits 0 when it summarised the repository, 1 when Forgejo cannot be read, 2 on a usage error.`;
|
|
3040
3097
|
var options2 = {
|
|
3041
3098
|
json: jsonOption("held and away (number, title, holder, since, boxesLeft, boxesTotal), ci (id, status, workflow, started, title), unpushed, dirty (status, path) and stale (issue, comments: path, line)"),
|
|
3099
|
+
watch: watchOption("the digest"),
|
|
3042
3100
|
...repoOption
|
|
3043
3101
|
};
|
|
3044
3102
|
async function digest(args) {
|
|
3045
3103
|
const parsed = parse(args, usage3, options2);
|
|
3046
3104
|
const { values } = parsed;
|
|
3105
|
+
if (values.watch !== undefined)
|
|
3106
|
+
return watching(values.watch, async () => digest(withoutWatch(args)));
|
|
3047
3107
|
const [issues, sessions, branch, runs] = await Promise.all([openIssues(undefined, values.repo), liveSessions(), defaultBranch(), recentRuns(RUNS_SCANNED, values.repo)]);
|
|
3048
3108
|
const comments = await commentsOfAll(issues, values.repo);
|
|
3049
3109
|
const me = await currentSession(sessions);
|
|
@@ -3844,7 +3904,7 @@ function report(plan, added, skipped) {
|
|
|
3844
3904
|
|
|
3845
3905
|
// src/commands/release.ts
|
|
3846
3906
|
import { basename as basename3, join as join11 } from "path";
|
|
3847
|
-
import
|
|
3907
|
+
import process24 from "process";
|
|
3848
3908
|
var {$: $2 } = globalThis.Bun;
|
|
3849
3909
|
|
|
3850
3910
|
// src/commands/watch.ts
|
|
@@ -3961,7 +4021,7 @@ function elapsed(run, seen) {
|
|
|
3961
4021
|
const seconds = Math.floor((Date.now() - (startedAt(run) ?? seen)) / 1000);
|
|
3962
4022
|
return seconds > 0 ? ` for ${formatSeconds(seconds)}` : "";
|
|
3963
4023
|
}
|
|
3964
|
-
async function
|
|
4024
|
+
async function watch2(args) {
|
|
3965
4025
|
const parsed = parse(args, usage5, options5);
|
|
3966
4026
|
const { values } = parsed;
|
|
3967
4027
|
const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
|
|
@@ -4088,13 +4148,12 @@ async function publishable() {
|
|
|
4088
4148
|
|
|
4089
4149
|
// src/commands/release-plan.ts
|
|
4090
4150
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4091
|
-
import
|
|
4092
|
-
async function
|
|
4151
|
+
import process23 from "process";
|
|
4152
|
+
async function planOf({ level, dir, prefix }, registry) {
|
|
4093
4153
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4094
4154
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4095
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4096
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4097
|
-
const sha = base.slice(0, 7);
|
|
4155
|
+
const name = pkg?.name ?? basename2(dir ?? process23.cwd());
|
|
4156
|
+
const where = dir === undefined ? "" : ` in ${relative(process23.cwd(), dir) || "."}`;
|
|
4098
4157
|
let version;
|
|
4099
4158
|
let bump;
|
|
4100
4159
|
if (level === undefined) {
|
|
@@ -4111,13 +4170,20 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
|
|
|
4111
4170
|
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}`;
|
|
4112
4171
|
console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
|
|
4113
4172
|
}
|
|
4173
|
+
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"}`;
|
|
4174
|
+
return { tag: `${prefix}${version}`, bump, registryStep };
|
|
4175
|
+
}
|
|
4176
|
+
async function printPlan({ releases, branch, base, timeout, registry }) {
|
|
4177
|
+
const planned = [];
|
|
4178
|
+
for (const each of releases)
|
|
4179
|
+
planned.push(await planOf(each, registry));
|
|
4180
|
+
const sha = base.slice(0, 7);
|
|
4114
4181
|
const pushed = await gitOk(["merge-base", "--is-ancestor", base, `origin/${branch}`]);
|
|
4115
|
-
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"}`;
|
|
4116
4182
|
const steps = [
|
|
4117
4183
|
pushed ? `wait for the runs on ${sha}, already on origin/${branch}` : `push ${branch} at ${sha}, which origin lacks, then wait for its runs`,
|
|
4118
|
-
bump,
|
|
4119
|
-
`push ${branch} and ${
|
|
4120
|
-
registryStep
|
|
4184
|
+
...planned.map((each) => each.bump),
|
|
4185
|
+
`push ${branch} and ${planned.map((each) => each.tag).join(", ")} in one atomic push, then wait for the runs it starts (${formatDuration(timeout)} at most)`,
|
|
4186
|
+
...planned.map((each) => each.registryStep)
|
|
4121
4187
|
];
|
|
4122
4188
|
console.log(steps.map((step, i) => ` ${i + 1}. ${step}`).join(`
|
|
4123
4189
|
`));
|
|
@@ -4164,21 +4230,22 @@ async function waitForRegistry(name, version) {
|
|
|
4164
4230
|
}
|
|
4165
4231
|
return false;
|
|
4166
4232
|
}
|
|
4167
|
-
async function rollBack(preBump,
|
|
4233
|
+
async function rollBack(preBump, dirs) {
|
|
4168
4234
|
try {
|
|
4169
|
-
|
|
4170
|
-
if (!tagsBefore.has(name))
|
|
4171
|
-
await git(["tag", "-d", name]);
|
|
4172
|
-
}
|
|
4173
|
-
await git(["reset", "--keep", preBump]);
|
|
4174
|
-
if (dir !== undefined) {
|
|
4235
|
+
if (dirs.length > 0) {
|
|
4175
4236
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
4176
|
-
const paths = [join10(dir, "package.json"), join10(root, "bun.lock")].map((path) => relative2(root, path));
|
|
4177
|
-
const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only",
|
|
4237
|
+
const paths = [...dirs.map((dir) => join10(dir, "package.json")), join10(root, "bun.lock")].map((path) => relative2(root, path));
|
|
4238
|
+
const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", "HEAD", "--", ...paths])).split(`
|
|
4178
4239
|
`).filter((path) => path !== "");
|
|
4179
4240
|
if (tracked.length > 0)
|
|
4180
|
-
await git(["restore",
|
|
4241
|
+
await git(["restore", "--source=HEAD", "--staged", "--worktree", "--", ...tracked.map((path) => join10(root, path))]);
|
|
4242
|
+
}
|
|
4243
|
+
for (const commit of (await git(["rev-list", `${preBump}..HEAD`])).split(`
|
|
4244
|
+
`).filter(Boolean)) {
|
|
4245
|
+
for (const name of await tagsAt(commit))
|
|
4246
|
+
await git(["tag", "-d", name]);
|
|
4181
4247
|
}
|
|
4248
|
+
await git(["reset", "--keep", preBump]);
|
|
4182
4249
|
} catch (error) {
|
|
4183
4250
|
warn(`could not undo the bump, back to ${preBump.slice(0, 7)} by hand`, error instanceof Error ? error.message : String(error));
|
|
4184
4251
|
}
|
|
@@ -4212,8 +4279,8 @@ ft release --tagged
|
|
|
4212
4279
|
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.
|
|
4213
4280
|
--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.
|
|
4214
4281
|
--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).
|
|
4215
|
-
--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.
|
|
4216
|
-
A refused or interrupted push drops the bump
|
|
4282
|
+
--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.
|
|
4283
|
+
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.
|
|
4217
4284
|
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.
|
|
4218
4285
|
--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.
|
|
4219
4286
|
--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.
|
|
@@ -4221,16 +4288,13 @@ Exits 0 once released or planned, 1 when a run fails, origin refuses a push or t
|
|
|
4221
4288
|
var options6 = {
|
|
4222
4289
|
tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
|
|
4223
4290
|
package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/, several separated by commas" },
|
|
4224
|
-
all: { type: "boolean", description: "release every published package of the workspace
|
|
4291
|
+
all: { type: "boolean", description: "release every published package of the workspace in one push" },
|
|
4225
4292
|
"no-registry": { type: "boolean", description: "do not wait for the registry to serve the new version" },
|
|
4226
4293
|
"dry-run": { type: "boolean", description: "print what the release would do, changing nothing" },
|
|
4227
4294
|
timeout: { type: "string", short: "t", description: "how long to wait for the runs (15m), a bare number in minutes" },
|
|
4228
4295
|
json: jsonOption("what was released and how its runs ended")
|
|
4229
4296
|
};
|
|
4230
4297
|
async function release(args) {
|
|
4231
|
-
return cut(args);
|
|
4232
|
-
}
|
|
4233
|
-
async function cut(args, sink) {
|
|
4234
4298
|
const parsed = parse(args, usage6, options6);
|
|
4235
4299
|
const { values, positionals } = parsed;
|
|
4236
4300
|
const json = values.json === true;
|
|
@@ -4245,39 +4309,16 @@ async function cut(args, sink) {
|
|
|
4245
4309
|
${usage6}`);
|
|
4246
4310
|
if (level !== undefined && !LEVELS.has(level) && !VERSION.test(level))
|
|
4247
4311
|
fail(`${level} is no level nor x.y.z version`);
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
for (const [index, target] of targets.entries()) {
|
|
4257
|
-
say(`== ${target.level} ${target.folder} (${index + 1}/${targets.length})`);
|
|
4258
|
-
const stopped = () => console.error(`stopped at ${target.folder}, not released: ${targets.slice(index).map((each) => each.folder).join(", ")}`);
|
|
4259
|
-
try {
|
|
4260
|
-
const code = await cut([target.level, "--package", target.folder, ...flags], results);
|
|
4261
|
-
if (code === 0)
|
|
4262
|
-
continue;
|
|
4263
|
-
stopped();
|
|
4264
|
-
if (json)
|
|
4265
|
-
printJson(results);
|
|
4266
|
-
return code;
|
|
4267
|
-
} catch (error) {
|
|
4268
|
-
stopped();
|
|
4269
|
-
if (json)
|
|
4270
|
-
printJson(results);
|
|
4271
|
-
throw error;
|
|
4272
|
-
}
|
|
4273
|
-
}
|
|
4274
|
-
if (json)
|
|
4275
|
-
printJson(results);
|
|
4276
|
-
return 0;
|
|
4277
|
-
}
|
|
4312
|
+
const several = values.all === true || SEVERAL.test(values.package ?? "");
|
|
4313
|
+
if (several && (tagged || level === undefined))
|
|
4314
|
+
fail("--all and several packages take a level, not --tagged");
|
|
4315
|
+
if (values.all === true && values.package !== undefined)
|
|
4316
|
+
fail("give --all or --package, not both");
|
|
4317
|
+
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) }];
|
|
4318
|
+
if (targets.length === 0)
|
|
4319
|
+
fail("no package to release: --all found no published package, or --package named none");
|
|
4278
4320
|
const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
|
|
4279
|
-
const
|
|
4280
|
-
const prefix = dir === undefined ? "v" : `${basename3(dir)}-v`;
|
|
4321
|
+
const prefixOf = (dir) => dir === undefined ? "v" : `${basename3(dir)}-v`;
|
|
4281
4322
|
const branch = await defaultBranch();
|
|
4282
4323
|
const current = await git(["branch", "--show-current"]);
|
|
4283
4324
|
if (current !== branch)
|
|
@@ -4289,88 +4330,98 @@ ${usage6}`);
|
|
|
4289
4330
|
fail(`origin/${branch} has commits HEAD lacks`, 2, runHint(`git pull --rebase origin ${branch}`));
|
|
4290
4331
|
const base = await git(["rev-parse", tagged ? "HEAD~1" : "HEAD"]);
|
|
4291
4332
|
if (values["dry-run"] === true)
|
|
4292
|
-
return printPlan({ level, dir, prefix, branch, base, timeout, registry: values["no-registry"] !== true });
|
|
4333
|
+
return printPlan({ releases: targets.map(({ level, dir }) => ({ level, dir, prefix: prefixOf(dir) })), branch, base, timeout, registry: values["no-registry"] !== true });
|
|
4293
4334
|
if (!await testsPass(base, branch, timeout, json))
|
|
4294
4335
|
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"));
|
|
4295
4336
|
const preBump = await git(["rev-parse", "HEAD"]);
|
|
4296
|
-
const tagsBefore = new Set(await tagsAt("HEAD"));
|
|
4297
4337
|
const before = (await recentRuns(1))[0]?.id ?? 0;
|
|
4298
4338
|
const held = holdSignals();
|
|
4299
4339
|
const signalOf = () => held.signal;
|
|
4300
|
-
|
|
4301
|
-
let head = "";
|
|
4340
|
+
const bumped = [];
|
|
4302
4341
|
let pushed = false;
|
|
4303
4342
|
let isPushUnknown = false;
|
|
4304
4343
|
try {
|
|
4305
|
-
|
|
4306
|
-
const
|
|
4307
|
-
if (
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4344
|
+
for (const { level, dir } of targets) {
|
|
4345
|
+
const prefix = prefixOf(dir);
|
|
4346
|
+
if (level !== undefined) {
|
|
4347
|
+
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();
|
|
4348
|
+
if (bump.exitCode !== 0)
|
|
4349
|
+
fail(`bun pm version ${level}${dir === undefined ? "" : ` in ${basename3(dir)}`}: ${bump.stderr.toString().trim() || bump.stdout.toString().trim()}`);
|
|
4350
|
+
if (dir !== undefined)
|
|
4351
|
+
await commitPackageBump(dir, prefix);
|
|
4352
|
+
}
|
|
4353
|
+
const tag = (await tagsAt("HEAD")).find((name) => taggedVersion(name, prefix) !== undefined);
|
|
4354
|
+
if (tag === undefined)
|
|
4355
|
+
fail(tagged ? `HEAD carries no ${prefix}* tag` : `the bump made no ${prefix}* tag`);
|
|
4356
|
+
bumped.push({ dir, prefix, tag, head: await git(["rev-parse", "HEAD"]) });
|
|
4357
|
+
if (held.signal !== undefined)
|
|
4358
|
+
fail(`interrupted by ${held.signal} before the push`, exitCodeOf(null, held.signal));
|
|
4311
4359
|
}
|
|
4312
|
-
const
|
|
4313
|
-
if (found === undefined)
|
|
4314
|
-
fail(tagged ? `HEAD carries no ${prefix}* tag` : `the bump made no ${prefix}* tag`);
|
|
4315
|
-
tag = found;
|
|
4316
|
-
head = await git(["rev-parse", "HEAD"]);
|
|
4317
|
-
if (held.signal !== undefined)
|
|
4318
|
-
fail(`interrupted by ${held.signal} before the push`, exitCodeOf(null, held.signal));
|
|
4360
|
+
const tags = bumped.map((each) => each.tag);
|
|
4319
4361
|
let push;
|
|
4320
4362
|
try {
|
|
4321
|
-
push = await runTool("git push", ["git", "push", "--atomic", "origin", `HEAD:refs/heads/${branch}`, `refs/tags/${tag}`], { timeoutMs: limits.pushMs, onStart: (child) => held.forward(child) });
|
|
4363
|
+
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) });
|
|
4322
4364
|
} catch (error) {
|
|
4323
4365
|
isPushUnknown = true;
|
|
4324
|
-
fail(`${error instanceof Error ? error.message : String(error)}, so ${
|
|
4366
|
+
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`);
|
|
4325
4367
|
}
|
|
4326
4368
|
if (push.code !== 0) {
|
|
4327
4369
|
const signal = signalOf();
|
|
4328
|
-
|
|
4370
|
+
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`;
|
|
4371
|
+
fail(`origin refused the push${signal === undefined ? "" : `, or ${signal} interrupted it`}, so ${kept}:
|
|
4329
4372
|
${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
4330
4373
|
}
|
|
4331
4374
|
pushed = true;
|
|
4332
4375
|
} finally {
|
|
4333
4376
|
held.release();
|
|
4334
|
-
if (!pushed && !isPushUnknown &&
|
|
4335
|
-
await rollBack(preBump,
|
|
4377
|
+
if (!pushed && !isPushUnknown && !tagged)
|
|
4378
|
+
await rollBack(preBump, targets.flatMap((target) => target.dir === undefined ? [] : [target.dir]));
|
|
4336
4379
|
}
|
|
4337
|
-
const
|
|
4338
|
-
const
|
|
4339
|
-
|
|
4380
|
+
const heads = new Set(bumped.map((each) => each.head));
|
|
4381
|
+
const manifests = await Promise.all(bumped.map(async (each) => {
|
|
4382
|
+
const file = Bun.file(join11(each.dir ?? ".", "package.json"));
|
|
4383
|
+
return await file.exists() ? await file.json() : undefined;
|
|
4384
|
+
}));
|
|
4385
|
+
const released = new Set;
|
|
4340
4386
|
let followed = { code: 0, runs: [], failedJobs: [] };
|
|
4341
|
-
const
|
|
4387
|
+
const report = () => {
|
|
4342
4388
|
if (!json)
|
|
4343
4389
|
return;
|
|
4344
|
-
const
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4390
|
+
const results = bumped.map((each, index) => {
|
|
4391
|
+
const own = followed.runs.filter((run) => run.prettyref === each.tag || run.prettyref === branch);
|
|
4392
|
+
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))) };
|
|
4393
|
+
});
|
|
4394
|
+
printJson(several ? results : results[0]);
|
|
4349
4395
|
};
|
|
4350
4396
|
try {
|
|
4351
4397
|
const late = signalOf();
|
|
4352
4398
|
if (late !== undefined)
|
|
4353
|
-
fail(`interrupted by ${late} after ${tag} was pushed: its runs are not waited for`, exitCodeOf(null, late));
|
|
4354
|
-
say(`pushed ${branch} and ${tag}, waiting for their runs`);
|
|
4355
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha
|
|
4399
|
+
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));
|
|
4400
|
+
say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
|
|
4401
|
+
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 });
|
|
4356
4402
|
if (followed.code !== 0) {
|
|
4357
|
-
|
|
4403
|
+
report();
|
|
4358
4404
|
return followed.code;
|
|
4359
4405
|
}
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4406
|
+
for (const [index, each] of bumped.entries()) {
|
|
4407
|
+
const pkg = manifests[index];
|
|
4408
|
+
const version = each.tag.slice(each.prefix.length);
|
|
4409
|
+
if (values["no-registry"] !== true && pkg?.name !== undefined && pkg.private !== true) {
|
|
4410
|
+
if (!await waitForRegistry(pkg.name, version)) {
|
|
4411
|
+
const rest = bumped.slice(index + 1).map((next) => next.tag);
|
|
4412
|
+
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);
|
|
4413
|
+
}
|
|
4414
|
+
say(`released ${pkg.name}@${version}`);
|
|
4415
|
+
} else {
|
|
4416
|
+
say(`released ${each.tag}`);
|
|
4417
|
+
}
|
|
4418
|
+
await settleMilestone(version, each.tag, say);
|
|
4419
|
+
released.add(each);
|
|
4365
4420
|
}
|
|
4366
|
-
|
|
4367
|
-
fail(`the runs passed but the registry does not serve ${pkg.name}@${version}: read the publish job with \`ft logs\``, 1);
|
|
4368
|
-
say(`released ${pkg.name}@${version}`);
|
|
4369
|
-
await settleMilestone(version, tag, say);
|
|
4370
|
-
outcome(true);
|
|
4421
|
+
report();
|
|
4371
4422
|
return 0;
|
|
4372
4423
|
} catch (error) {
|
|
4373
|
-
|
|
4424
|
+
report();
|
|
4374
4425
|
throw error;
|
|
4375
4426
|
}
|
|
4376
4427
|
}
|
|
@@ -4552,7 +4603,7 @@ async function runs(args) {
|
|
|
4552
4603
|
}
|
|
4553
4604
|
|
|
4554
4605
|
// src/cli.ts
|
|
4555
|
-
|
|
4606
|
+
process25.exitCode = await runCli({
|
|
4556
4607
|
name: "ft",
|
|
4557
4608
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4558
4609
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|
|
@@ -4560,7 +4611,7 @@ process24.exitCode = await runCli({
|
|
|
4560
4611
|
commands: {
|
|
4561
4612
|
runs: { run: runs, summary: "recent runs with workflow, ref, duration and age", group: "CI and release" },
|
|
4562
4613
|
ci: { run: ci2, summary: "wait for the runs covering a commit, printing what failed", group: "CI and release" },
|
|
4563
|
-
watch: { run:
|
|
4614
|
+
watch: { run: watch2, summary: "wait for runs newer than an id, or those in progress", group: "CI and release" },
|
|
4564
4615
|
logs: { run: logs2, summary: "what the failed jobs of a run say went wrong", group: "CI and release" },
|
|
4565
4616
|
release: { run: release, summary: "bump, push branch and tag atomically, wait for runs and registry", group: "CI and release" },
|
|
4566
4617
|
board: { run: board, summary: "open issues: available, taken by a live session, or claimed by one gone", group: "Issues and claims" },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-forgejo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.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.
|
|
31
|
+
"@kaynooo/cli-kit": "0.27.1"
|
|
32
32
|
}
|
|
33
33
|
}
|