@kaynooo/forgejo-tools 0.7.1 → 0.8.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 +37 -21
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -33,7 +33,7 @@ Needs [tea](https://gitea.com/gitea/tea) logged in to the Forgejo instance (`tea
33
33
  | `ft milestone <title\|id>` | shows a milestone's open issues as `ft board` does (available, taken, claimed by one gone); `ft milestone new <title> [-d text] [--due YYYY-MM-DD]` creates one through the API, sending no `due_on` unless `--due` is given, never a zero date; `ft milestone close <m>` refuses while issues are open in it, naming them, unless `--force` |
34
34
  | `ft remote [--fix]` | switches an origin using an ssh alias (`forgejo:owner/repo`) to `git@<host>:owner/repo.git`, which tea matches; the host comes from `--host` or `remoteHost` in `~/.config/ft/config.json` (`{"remoteHost": "git.example.com"}`), and with neither it checks nothing |
35
35
 
36
- `ft <command> --help` lists each command's options. Waiting commands exit 0 when the runs pass, 1 when one fails, 2 on a timeout, a stalled queue or bad usage; the other commands exit 0 when done, 1 when Forgejo refuses or a check fails, 2 on a usage error.
36
+ `ft <command> --help` lists each command's options. Waiting commands show one line per run, redrawn in place on a terminal and left at its last status, and a line per status change in a log or a pipe; they exit 0 when the runs pass, 1 when one fails, 2 on a timeout, a stalled queue or bad usage; the other commands exit 0 when done, 1 when Forgejo refuses or a check fails, 2 on a usage error.
37
37
 
38
38
  ## CI
39
39
 
package/dist/cli.js CHANGED
@@ -1292,7 +1292,7 @@ async function currentSession(sessions) {
1292
1292
  return;
1293
1293
  }
1294
1294
  // package.json
1295
- var version = "0.7.1";
1295
+ var version = "0.8.0";
1296
1296
 
1297
1297
  // src/args.ts
1298
1298
  var repoOption = {
@@ -3065,9 +3065,11 @@ var options5 = {
3065
3065
  var timing = { poll: 1e4 };
3066
3066
  var LIMIT = 20;
3067
3067
  var STALLED2 = 3 * 60000;
3068
- async function watchRuns(pick, timeout, repo, idle) {
3068
+ async function watchRuns(pick, timeout, repo, idle, out = process.stdout) {
3069
3069
  const started = Date.now();
3070
- const reported = new Map;
3070
+ const latest = new Map;
3071
+ const line = (run) => `${run.workflow_id} run ${run.id} on ${run.prettyref}: ${badge(run.status, out)}`;
3072
+ const region = takesControlCodes(out) ? liveRegion(() => [...latest.values()].map(line), out) : undefined;
3071
3073
  const followed = new Set;
3072
3074
  const failed = new Set;
3073
3075
  let moving = started;
@@ -3078,10 +3080,12 @@ async function watchRuns(pick, timeout, repo, idle) {
3078
3080
  for (const run of runs)
3079
3081
  followed.add(run.id);
3080
3082
  for (const run of runs) {
3081
- if (reported.get(run.id) !== run.status)
3082
- console.log(`${run.workflow_id} run ${run.id} on ${run.prettyref}: ${badge(run.status, process.stdout)}`);
3083
- reported.set(run.id, run.status);
3083
+ if (region === undefined && latest.get(run.id)?.status !== run.status)
3084
+ out.write(`${line(run)}
3085
+ `);
3086
+ latest.set(run.id, run);
3084
3087
  }
3088
+ region?.redraw();
3085
3089
  if (runs.length === 0) {
3086
3090
  if (idle !== undefined && Date.now() - started > idle) {
3087
3091
  console.log("no run started, so nothing was waited for");
@@ -3109,21 +3113,33 @@ ${run.html_url}`);
3109
3113
  fail(`queued runs are not moving: ${stall.reason}`);
3110
3114
  return;
3111
3115
  }
3112
- for (;; ) {
3113
- await Bun.sleep(timing.poll);
3114
- if (Date.now() - started > timeout)
3115
- fail(`the runs did not finish in ${formatDuration(timeout)}`);
3116
- try {
3117
- const code = await poll();
3118
- if (code !== undefined)
3119
- return code;
3120
- } catch (error) {
3121
- if (error instanceof Exit)
3122
- throw error;
3123
- const message = error instanceof Error ? error.message : String(error);
3124
- if (isPermanentFailure(error))
3125
- fail(message);
3126
- console.warn(`ft watch: ${message}, polling again`);
3116
+ async function settle() {
3117
+ for (;; ) {
3118
+ await Bun.sleep(timing.poll);
3119
+ if (Date.now() - started > timeout)
3120
+ fail(`the runs did not finish in ${formatDuration(timeout)}`);
3121
+ try {
3122
+ const code = await poll();
3123
+ if (code !== undefined)
3124
+ return code;
3125
+ } catch (error) {
3126
+ if (error instanceof Exit)
3127
+ throw error;
3128
+ const message = error instanceof Error ? error.message : String(error);
3129
+ if (isPermanentFailure(error))
3130
+ fail(message);
3131
+ console.warn(`ft watch: ${message}, polling again`);
3132
+ }
3133
+ }
3134
+ }
3135
+ try {
3136
+ return await settle();
3137
+ } finally {
3138
+ if (region !== undefined) {
3139
+ region.stop();
3140
+ for (const run of latest.values())
3141
+ out.write(`${line(run)}
3142
+ `);
3127
3143
  }
3128
3144
  }
3129
3145
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/forgejo-tools",
3
3
  "type": "module",
4
- "version": "0.7.1",
4
+ "version": "0.8.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",