@kaynooo/cli-forgejo 0.19.0 → 0.20.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/dist/cli.js +74 -16
- package/package.json +2 -2
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";
|
|
@@ -1865,6 +1865,58 @@ async function currentSession(sessions) {
|
|
|
1865
1865
|
}
|
|
1866
1866
|
return;
|
|
1867
1867
|
}
|
|
1868
|
+
// ../kit/src/watch.ts
|
|
1869
|
+
import process18 from "process";
|
|
1870
|
+
import { format } from "util";
|
|
1871
|
+
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1872
|
+
var DEFAULT_SECONDS = 2;
|
|
1873
|
+
var ATTACHED_SHORT = /^-w./;
|
|
1874
|
+
var INTERVAL = /^\d+(?:\.\d+)?(?:ms|[smh])?$/;
|
|
1875
|
+
function watchOption(what) {
|
|
1876
|
+
return { type: "string", short: "w", optional: { bare: "", accepts: INTERVAL }, description: `redraw ${what} every 2s, or every interval given (500ms, 5s), until ctrl-c` };
|
|
1877
|
+
}
|
|
1878
|
+
function withoutWatch(args) {
|
|
1879
|
+
const rest = [];
|
|
1880
|
+
for (let at = 0;at < args.length; at++) {
|
|
1881
|
+
const arg = args[at];
|
|
1882
|
+
if (arg === "--watch" || arg === "-w") {
|
|
1883
|
+
if (args[at + 1] !== undefined && INTERVAL.test(args[at + 1]))
|
|
1884
|
+
at++;
|
|
1885
|
+
} else if (!arg.startsWith("--watch=") && !ATTACHED_SHORT.test(arg)) {
|
|
1886
|
+
rest.push(arg);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
return rest;
|
|
1890
|
+
}
|
|
1891
|
+
async function watching(value, step, stream = process18.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1892
|
+
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1893
|
+
if (!takesControlCodes(stream))
|
|
1894
|
+
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
1895
|
+
let code = 0;
|
|
1896
|
+
for (let round = 0;round < rounds; round++) {
|
|
1897
|
+
const held = [];
|
|
1898
|
+
const { log, info } = console;
|
|
1899
|
+
const write = process18.stdout.write.bind(process18.stdout);
|
|
1900
|
+
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1901
|
+
`);
|
|
1902
|
+
console.log = hold;
|
|
1903
|
+
console.info = hold;
|
|
1904
|
+
process18.stdout.write = (text) => {
|
|
1905
|
+
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1906
|
+
return true;
|
|
1907
|
+
};
|
|
1908
|
+
try {
|
|
1909
|
+
code = await step();
|
|
1910
|
+
} finally {
|
|
1911
|
+
console.log = log;
|
|
1912
|
+
console.info = info;
|
|
1913
|
+
process18.stdout.write = write;
|
|
1914
|
+
}
|
|
1915
|
+
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1916
|
+
await sleep(interval);
|
|
1917
|
+
}
|
|
1918
|
+
return code;
|
|
1919
|
+
}
|
|
1868
1920
|
// src/args.ts
|
|
1869
1921
|
var repoOption = {
|
|
1870
1922
|
repo: { type: "string", short: "r", description: "owner/name of the repository, instead of the one origin points at" }
|
|
@@ -2038,7 +2090,7 @@ function holderSession(holder, sessions) {
|
|
|
2038
2090
|
// src/forge.ts
|
|
2039
2091
|
import { homedir as homedir5 } from "os";
|
|
2040
2092
|
import { join as join7 } from "path";
|
|
2041
|
-
import
|
|
2093
|
+
import process20 from "process";
|
|
2042
2094
|
|
|
2043
2095
|
// src/remote.ts
|
|
2044
2096
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2093,7 +2145,7 @@ function loginHosts(config) {
|
|
|
2093
2145
|
return hosts;
|
|
2094
2146
|
}
|
|
2095
2147
|
function teaConfigPath() {
|
|
2096
|
-
const base =
|
|
2148
|
+
const base = process20.env.XDG_CONFIG_HOME;
|
|
2097
2149
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2098
2150
|
}
|
|
2099
2151
|
async function readConfig() {
|
|
@@ -2456,11 +2508,14 @@ var boardOptions = {
|
|
|
2456
2508
|
state: { type: "string", description: "only issues in this state: available, taken or away (claimed, no live session here)" },
|
|
2457
2509
|
...limitOptions(BOARD_LIMIT),
|
|
2458
2510
|
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)"),
|
|
2511
|
+
watch: watchOption("the board"),
|
|
2459
2512
|
...repoOption
|
|
2460
2513
|
};
|
|
2461
2514
|
async function board(args) {
|
|
2462
2515
|
const parsed = parse(args, boardUsage, boardOptions);
|
|
2463
2516
|
const { values } = parsed;
|
|
2517
|
+
if (values.watch !== undefined)
|
|
2518
|
+
return watching(values.watch, async () => board(withoutWatch(args)));
|
|
2464
2519
|
const state = values.state;
|
|
2465
2520
|
const limit = limitOf(values, BOARD_LIMIT);
|
|
2466
2521
|
if (state !== undefined && !STATES.has(state))
|
|
@@ -2625,7 +2680,7 @@ async function drop(args) {
|
|
|
2625
2680
|
}
|
|
2626
2681
|
|
|
2627
2682
|
// src/commands/ci.ts
|
|
2628
|
-
import
|
|
2683
|
+
import process21 from "process";
|
|
2629
2684
|
|
|
2630
2685
|
// src/git.ts
|
|
2631
2686
|
async function tagsAt(commit) {
|
|
@@ -2881,7 +2936,7 @@ async function ci2(args) {
|
|
|
2881
2936
|
return;
|
|
2882
2937
|
}
|
|
2883
2938
|
const json = values.json === true;
|
|
2884
|
-
const { dim } = paint(
|
|
2939
|
+
const { dim } = paint(process21.stderr);
|
|
2885
2940
|
const runs = await waitForCi({
|
|
2886
2941
|
tool: "ft ci",
|
|
2887
2942
|
short,
|
|
@@ -2906,7 +2961,7 @@ async function ci2(args) {
|
|
|
2906
2961
|
},
|
|
2907
2962
|
lines: (spinner, found, started) => [
|
|
2908
2963
|
`${spinner} CI on ${short} ${dim(formatElapsed(Date.now() - started))}`,
|
|
2909
|
-
...(found ?? []).map((run) => ` ${badge(run.status,
|
|
2964
|
+
...(found ?? []).map((run) => ` ${badge(run.status, process21.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
|
|
2910
2965
|
]
|
|
2911
2966
|
});
|
|
2912
2967
|
const status = overall(runs);
|
|
@@ -2936,7 +2991,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2936
2991
|
}
|
|
2937
2992
|
|
|
2938
2993
|
// src/commands/digest.ts
|
|
2939
|
-
import
|
|
2994
|
+
import process22 from "process";
|
|
2940
2995
|
var RUNS_SCANNED = 50;
|
|
2941
2996
|
var TITLE_WIDTH2 = 70;
|
|
2942
2997
|
var SHOWN = 8;
|
|
@@ -2986,7 +3041,7 @@ async function quietly(read) {
|
|
|
2986
3041
|
}
|
|
2987
3042
|
}
|
|
2988
3043
|
async function staleTodos() {
|
|
2989
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3044
|
+
const bin = Bun.which("todo-scan", { PATH: process22.env.PATH ?? "" });
|
|
2990
3045
|
if (bin === null)
|
|
2991
3046
|
return [];
|
|
2992
3047
|
let found;
|
|
@@ -3039,11 +3094,14 @@ A section with nothing in it is left out, and the stale TODO comments need todo-
|
|
|
3039
3094
|
Exits 0 when it summarised the repository, 1 when Forgejo cannot be read, 2 on a usage error.`;
|
|
3040
3095
|
var options2 = {
|
|
3041
3096
|
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)"),
|
|
3097
|
+
watch: watchOption("the digest"),
|
|
3042
3098
|
...repoOption
|
|
3043
3099
|
};
|
|
3044
3100
|
async function digest(args) {
|
|
3045
3101
|
const parsed = parse(args, usage3, options2);
|
|
3046
3102
|
const { values } = parsed;
|
|
3103
|
+
if (values.watch !== undefined)
|
|
3104
|
+
return watching(values.watch, async () => digest(withoutWatch(args)));
|
|
3047
3105
|
const [issues, sessions, branch, runs] = await Promise.all([openIssues(undefined, values.repo), liveSessions(), defaultBranch(), recentRuns(RUNS_SCANNED, values.repo)]);
|
|
3048
3106
|
const comments = await commentsOfAll(issues, values.repo);
|
|
3049
3107
|
const me = await currentSession(sessions);
|
|
@@ -3844,7 +3902,7 @@ function report(plan, added, skipped) {
|
|
|
3844
3902
|
|
|
3845
3903
|
// src/commands/release.ts
|
|
3846
3904
|
import { basename as basename3, join as join11 } from "path";
|
|
3847
|
-
import
|
|
3905
|
+
import process24 from "process";
|
|
3848
3906
|
var {$: $2 } = globalThis.Bun;
|
|
3849
3907
|
|
|
3850
3908
|
// src/commands/watch.ts
|
|
@@ -3961,7 +4019,7 @@ function elapsed(run, seen) {
|
|
|
3961
4019
|
const seconds = Math.floor((Date.now() - (startedAt(run) ?? seen)) / 1000);
|
|
3962
4020
|
return seconds > 0 ? ` for ${formatSeconds(seconds)}` : "";
|
|
3963
4021
|
}
|
|
3964
|
-
async function
|
|
4022
|
+
async function watch2(args) {
|
|
3965
4023
|
const parsed = parse(args, usage5, options5);
|
|
3966
4024
|
const { values } = parsed;
|
|
3967
4025
|
const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
|
|
@@ -4088,12 +4146,12 @@ async function publishable() {
|
|
|
4088
4146
|
|
|
4089
4147
|
// src/commands/release-plan.ts
|
|
4090
4148
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4091
|
-
import
|
|
4149
|
+
import process23 from "process";
|
|
4092
4150
|
async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
|
|
4093
4151
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4094
4152
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4095
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4096
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4153
|
+
const name = pkg?.name ?? basename2(dir ?? process23.cwd());
|
|
4154
|
+
const where = dir === undefined ? "" : ` in ${relative(process23.cwd(), dir) || "."}`;
|
|
4097
4155
|
const sha = base.slice(0, 7);
|
|
4098
4156
|
let version;
|
|
4099
4157
|
let bump;
|
|
@@ -4352,7 +4410,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4352
4410
|
if (late !== undefined)
|
|
4353
4411
|
fail(`interrupted by ${late} after ${tag} was pushed: its runs are not waited for`, exitCodeOf(null, late));
|
|
4354
4412
|
say(`pushed ${branch} and ${tag}, waiting for their runs`);
|
|
4355
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2, json ?
|
|
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 });
|
|
4356
4414
|
if (followed.code !== 0) {
|
|
4357
4415
|
outcome(false);
|
|
4358
4416
|
return followed.code;
|
|
@@ -4552,7 +4610,7 @@ async function runs(args) {
|
|
|
4552
4610
|
}
|
|
4553
4611
|
|
|
4554
4612
|
// src/cli.ts
|
|
4555
|
-
|
|
4613
|
+
process25.exitCode = await runCli({
|
|
4556
4614
|
name: "ft",
|
|
4557
4615
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4558
4616
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|
|
@@ -4560,7 +4618,7 @@ process24.exitCode = await runCli({
|
|
|
4560
4618
|
commands: {
|
|
4561
4619
|
runs: { run: runs, summary: "recent runs with workflow, ref, duration and age", group: "CI and release" },
|
|
4562
4620
|
ci: { run: ci2, summary: "wait for the runs covering a commit, printing what failed", group: "CI and release" },
|
|
4563
|
-
watch: { run:
|
|
4621
|
+
watch: { run: watch2, summary: "wait for runs newer than an id, or those in progress", group: "CI and release" },
|
|
4564
4622
|
logs: { run: logs2, summary: "what the failed jobs of a run say went wrong", group: "CI and release" },
|
|
4565
4623
|
release: { run: release, summary: "bump, push branch and tag atomically, wait for runs and registry", group: "CI and release" },
|
|
4566
4624
|
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.20.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.25.0"
|
|
32
32
|
}
|
|
33
33
|
}
|