@kaynooo/cli-forgejo 0.24.0 → 0.26.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 +206 -95
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Needs [tea](https://gitea.com/gitea/tea) logged in to the Forgejo instance (`tea
|
|
|
29
29
|
| `ft close <n>... [-m reason]` | closes issues no commit fixed (a duplicate, one dropped), posting the reason first; `ft reopen` reopens them the same way |
|
|
30
30
|
| `ft label <n> [+]a -b` | adds the labels named bare or with `+`, removes those named with `-`, refusing one the repository lacks, and prints the issue's labels |
|
|
31
31
|
| `ft plan add <plan> <n>...` / `ft plan carry <from> <to>` | adds `- [ ] #<n> <title>` lines to a release plan's checklist, or copies one plan's unticked `#<n>` lines into the next, both under `--section "Bugs:"` (created when missing) and skipping issues already listed |
|
|
32
|
-
| `ft milestones` | lists the milestones (`--state open\|closed\|all`, `--json`) with the issues open and closed in each, the progress and the due date |
|
|
32
|
+
| `ft milestones` | lists the milestones (`--state open\|closed\|all`, `--json`, `--issues` for each one's issues by title) with the issues open and closed in each, the progress and the due date |
|
|
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/kaynooo-cli/ft.json` (`{"remoteHost": "git.example.com"}`; the older `~/.config/ft/config.json` is read while the new file is missing), and with neither it checks nothing |
|
|
35
35
|
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process28 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -334,19 +334,53 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
// ../kit/src/theme.ts
|
|
337
|
+
function toLinear(channel) {
|
|
338
|
+
const value = channel / 255;
|
|
339
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
340
|
+
}
|
|
341
|
+
var fromLinear = (value) => Math.round(255 * Math.min(1, Math.max(0, value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055)));
|
|
342
|
+
function toOklab(hex) {
|
|
343
|
+
const [r, g, b] = [1, 3, 5].map((at) => toLinear(Number.parseInt(hex.slice(at, at + 2), 16)));
|
|
344
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
345
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
346
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
347
|
+
return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s];
|
|
348
|
+
}
|
|
349
|
+
function fromOklab([lightness, a, b]) {
|
|
350
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
351
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
352
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
353
|
+
const channels = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
|
|
354
|
+
return `#${channels.map((channel) => fromLinear(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
355
|
+
}
|
|
356
|
+
var ENDS = new Map;
|
|
357
|
+
function gradientAt(theme, ratio) {
|
|
358
|
+
if (theme.gradient === undefined)
|
|
359
|
+
return;
|
|
360
|
+
const key = theme.gradient.join();
|
|
361
|
+
let ends = ENDS.get(key);
|
|
362
|
+
if (ends === undefined) {
|
|
363
|
+
ends = [toOklab(theme.gradient[0]), toOklab(theme.gradient[1])];
|
|
364
|
+
ENDS.set(key, ends);
|
|
365
|
+
}
|
|
366
|
+
const at = Math.min(1, Math.max(0, ratio));
|
|
367
|
+
const [from, to] = ends;
|
|
368
|
+
return fromOklab(from.map((start, index) => start + (to[index] - start) * at));
|
|
369
|
+
}
|
|
337
370
|
var DEFAULT = {
|
|
338
371
|
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", rule: "\u2500", corner: "\u256D" },
|
|
372
|
+
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501", rule: "\u2500", corner: "\u256D", open: "\u2022", leaf: "\xB7", guide: "\u2502" },
|
|
340
373
|
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
341
|
-
bins: {}
|
|
374
|
+
bins: {},
|
|
375
|
+
gradient: ["#c084fc", "#67e8f9"]
|
|
342
376
|
};
|
|
343
377
|
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
378
|
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: "#", rule: "-", corner: "+" };
|
|
379
|
+
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#", rule: "-", corner: "+", open: "*", leaf: "-", guide: "|" };
|
|
346
380
|
var PRESETS = {
|
|
347
381
|
default: {},
|
|
348
|
-
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
|
|
349
|
-
mono: { colors: MONO, accents: ["bold"] },
|
|
382
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"], gradient: ["#d8b4fe", "#a5f3fc"] },
|
|
383
|
+
mono: { colors: MONO, accents: ["bold"], gradient: undefined },
|
|
350
384
|
ascii: { glyphs: ASCII }
|
|
351
385
|
};
|
|
352
386
|
var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
|
|
@@ -384,6 +418,9 @@ function tinted(colors, spec, env = process5.env) {
|
|
|
384
418
|
return chain[token] ?? chain;
|
|
385
419
|
}, colors);
|
|
386
420
|
}
|
|
421
|
+
function shaded(theme, colors, glyph, cells, width, env = process5.env) {
|
|
422
|
+
return Array.from({ length: cells }, (_, index) => tinted(colors, gradientAt(theme, width <= 1 ? 0 : index / (width - 1)) ?? theme.colors.accent, env)(glyph)).join("");
|
|
423
|
+
}
|
|
387
424
|
function isRecord(value) {
|
|
388
425
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
389
426
|
}
|
|
@@ -417,6 +454,8 @@ function applyPreset(theme, name, warn, where) {
|
|
|
417
454
|
Object.assign(theme.glyphs, preset.glyphs);
|
|
418
455
|
if (preset.accents !== undefined)
|
|
419
456
|
theme.accents = [...preset.accents];
|
|
457
|
+
if (Object.hasOwn(preset, "gradient"))
|
|
458
|
+
theme.gradient = preset.gradient;
|
|
420
459
|
return name;
|
|
421
460
|
}
|
|
422
461
|
function applyFile(theme, file, where, warn) {
|
|
@@ -444,6 +483,12 @@ function applyFile(theme, file, where, warn) {
|
|
|
444
483
|
theme.accents = [...file.accents];
|
|
445
484
|
else if (file.accents !== undefined)
|
|
446
485
|
warn(`${where}: accents must be a non-empty list of colours`);
|
|
486
|
+
if (file.gradient === null)
|
|
487
|
+
theme.gradient = undefined;
|
|
488
|
+
else if (Array.isArray(file.gradient) && file.gradient.length === 2 && file.gradient.every((end) => typeof end === "string" && HEX.test(end)))
|
|
489
|
+
theme.gradient = [file.gradient[0], file.gradient[1]];
|
|
490
|
+
else if (file.gradient !== undefined)
|
|
491
|
+
warn(`${where}: gradient must be two \`#rrggbb\` colours, or null for none`);
|
|
447
492
|
if (isRecord(file.bins)) {
|
|
448
493
|
for (const [bin, value] of Object.entries(file.bins)) {
|
|
449
494
|
if (isColorSpec(value))
|
|
@@ -467,7 +512,7 @@ function isPath(chosen) {
|
|
|
467
512
|
return chosen.includes("/") || chosen.endsWith(".json");
|
|
468
513
|
}
|
|
469
514
|
function loadTheme({ env = process5.env, from = process5.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
470
|
-
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
515
|
+
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null), gradient: DEFAULT.gradient };
|
|
471
516
|
const sources = [];
|
|
472
517
|
const chosen = env.KIT_THEME ?? "";
|
|
473
518
|
const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
|
|
@@ -668,6 +713,9 @@ function jsonText(value, replacer, { stream = process7.stdout, env = process7.en
|
|
|
668
713
|
function printJson(value) {
|
|
669
714
|
console.log(jsonText(value));
|
|
670
715
|
}
|
|
716
|
+
function formatPercent(ratio, digits = 0) {
|
|
717
|
+
return `${(ratio * 100).toFixed(digits)}%`;
|
|
718
|
+
}
|
|
671
719
|
|
|
672
720
|
// ../kit/src/help.ts
|
|
673
721
|
import process8 from "process";
|
|
@@ -1000,13 +1048,27 @@ function nearestOption(message, options, allowNegative) {
|
|
|
1000
1048
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
1001
1049
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
1002
1050
|
}
|
|
1051
|
+
// ../kit/src/chart.ts
|
|
1052
|
+
import process11 from "process";
|
|
1053
|
+
var FILLED = "\u2501";
|
|
1054
|
+
var EMPTY = "\u2500";
|
|
1055
|
+
function bar(ratio, { width = 20, stream = process11.stdout, env = process11.env } = {}) {
|
|
1056
|
+
if (outputMode(stream, env) === "agent")
|
|
1057
|
+
return formatPercent(Math.min(1, Math.max(0, ratio)));
|
|
1058
|
+
const colors = paint(stream, env);
|
|
1059
|
+
const filled = Math.round(Math.min(1, Math.max(0, ratio)) * width);
|
|
1060
|
+
if (!takesControlCodes(stream, env))
|
|
1061
|
+
return `${FILLED.repeat(filled)}${EMPTY.repeat(width - filled)}`;
|
|
1062
|
+
const { theme } = activeTheme();
|
|
1063
|
+
return `${shaded(theme, colors, theme.glyphs.bar, filled, width, env)}${colors.dim(theme.glyphs.bar.repeat(width - filled))}`;
|
|
1064
|
+
}
|
|
1003
1065
|
// ../kit/src/progress.ts
|
|
1004
|
-
import
|
|
1066
|
+
import process13 from "process";
|
|
1005
1067
|
|
|
1006
1068
|
// ../kit/src/process.ts
|
|
1007
1069
|
import { constants } from "os";
|
|
1008
1070
|
import { resolve as resolve3 } from "path";
|
|
1009
|
-
import
|
|
1071
|
+
import process12 from "process";
|
|
1010
1072
|
var KILL_GRACE_MS = 2000;
|
|
1011
1073
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
1012
1074
|
var SCHEME = /^[a-z][\w+.-]+:/i;
|
|
@@ -1030,7 +1092,7 @@ function holdSignals(cleanup) {
|
|
|
1030
1092
|
},
|
|
1031
1093
|
release: () => {
|
|
1032
1094
|
for (const signal of SIGNALS)
|
|
1033
|
-
|
|
1095
|
+
process12.off(signal, onSignal);
|
|
1034
1096
|
}
|
|
1035
1097
|
};
|
|
1036
1098
|
function onSignal(signal) {
|
|
@@ -1043,13 +1105,13 @@ function holdSignals(cleanup) {
|
|
|
1043
1105
|
return;
|
|
1044
1106
|
held.release();
|
|
1045
1107
|
cleanup(signal);
|
|
1046
|
-
|
|
1108
|
+
process12.kill(process12.pid, signal);
|
|
1047
1109
|
}
|
|
1048
1110
|
for (const signal of SIGNALS)
|
|
1049
|
-
|
|
1111
|
+
process12.on(signal, onSignal);
|
|
1050
1112
|
return held;
|
|
1051
1113
|
}
|
|
1052
|
-
function openUrl(target, env =
|
|
1114
|
+
function openUrl(target, env = process12.env, platform = process12.platform) {
|
|
1053
1115
|
const opener = env.BROWSER === undefined || env.BROWSER === "" ? OPENERS[platform] ?? ["xdg-open"] : [env.BROWSER];
|
|
1054
1116
|
try {
|
|
1055
1117
|
Bun.spawn([...opener, SCHEME.test(target) ? target : resolve3(target)], { env, stdio: ["ignore", "ignore", "ignore"] }).unref();
|
|
@@ -1086,7 +1148,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1086
1148
|
return;
|
|
1087
1149
|
try {
|
|
1088
1150
|
if (grouped)
|
|
1089
|
-
|
|
1151
|
+
process12.kill(-proc.pid, killing);
|
|
1090
1152
|
else
|
|
1091
1153
|
proc.kill(killing);
|
|
1092
1154
|
} catch {}
|
|
@@ -1165,7 +1227,7 @@ var RESET_STYLE = `${ESC}[0m`;
|
|
|
1165
1227
|
var CTRL_C = 3;
|
|
1166
1228
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1167
1229
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1168
|
-
function liveRegion(render, stream =
|
|
1230
|
+
function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
1169
1231
|
if (!takesControlCodes(stream, env))
|
|
1170
1232
|
return { redraw: () => {
|
|
1171
1233
|
return;
|
|
@@ -1210,11 +1272,11 @@ function liveRegion(render, stream = process12.stderr, env = process12.env) {
|
|
|
1210
1272
|
clear();
|
|
1211
1273
|
restore();
|
|
1212
1274
|
release();
|
|
1213
|
-
|
|
1275
|
+
process13.off("exit", onExit);
|
|
1214
1276
|
signals.release();
|
|
1215
1277
|
}
|
|
1216
1278
|
timer.unref();
|
|
1217
|
-
|
|
1279
|
+
process13.on("exit", onExit);
|
|
1218
1280
|
return {
|
|
1219
1281
|
redraw: draw,
|
|
1220
1282
|
print: (text) => {
|
|
@@ -1253,14 +1315,14 @@ function cutToWidth(line, width) {
|
|
|
1253
1315
|
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1254
1316
|
}
|
|
1255
1317
|
function swallowInput() {
|
|
1256
|
-
const input =
|
|
1318
|
+
const input = process13.stdin;
|
|
1257
1319
|
if (!input.isTTY)
|
|
1258
1320
|
return () => {
|
|
1259
1321
|
return;
|
|
1260
1322
|
};
|
|
1261
1323
|
const onData = (data) => {
|
|
1262
1324
|
if (data.includes(CTRL_C))
|
|
1263
|
-
|
|
1325
|
+
process13.kill(process13.pid, "SIGINT");
|
|
1264
1326
|
};
|
|
1265
1327
|
input.setRawMode(true);
|
|
1266
1328
|
input.on("data", onData);
|
|
@@ -1276,7 +1338,7 @@ function swallowInput() {
|
|
|
1276
1338
|
};
|
|
1277
1339
|
}
|
|
1278
1340
|
function interceptOutput(clear) {
|
|
1279
|
-
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [
|
|
1341
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process13.stdout, "write"], [process13.stderr, "write"]];
|
|
1280
1342
|
const wrapped = targets.map(([target, name]) => {
|
|
1281
1343
|
const original = Reflect.get(target, name);
|
|
1282
1344
|
const wrapper = (...args) => {
|
|
@@ -1295,11 +1357,11 @@ function interceptOutput(clear) {
|
|
|
1295
1357
|
}
|
|
1296
1358
|
|
|
1297
1359
|
// ../kit/src/tool.ts
|
|
1298
|
-
import
|
|
1360
|
+
import process14 from "process";
|
|
1299
1361
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
1300
1362
|
function cwdGone() {
|
|
1301
1363
|
try {
|
|
1302
|
-
|
|
1364
|
+
process14.cwd();
|
|
1303
1365
|
return false;
|
|
1304
1366
|
} catch {
|
|
1305
1367
|
return true;
|
|
@@ -1326,7 +1388,7 @@ function isPermanentFailure(error) {
|
|
|
1326
1388
|
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1327
1389
|
let ran;
|
|
1328
1390
|
try {
|
|
1329
|
-
ran = await runCommand(argv, { env:
|
|
1391
|
+
ran = await runCommand(argv, { env: process14.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1330
1392
|
} catch (error) {
|
|
1331
1393
|
throw spawnFailure(label, error);
|
|
1332
1394
|
}
|
|
@@ -1410,16 +1472,23 @@ async function waitForCi(wait) {
|
|
|
1410
1472
|
region?.stop();
|
|
1411
1473
|
}
|
|
1412
1474
|
}
|
|
1475
|
+
function ciLine(status, subject, details, out) {
|
|
1476
|
+
const rest = details.filter((each) => each !== undefined && each !== "").join(" ");
|
|
1477
|
+
return `${badge(status, out)} ${subject}${rest === "" ? "" : ` ${paint(out).dim(rest)}`}`;
|
|
1478
|
+
}
|
|
1479
|
+
function ciHeader(spinner, label, startedAt, out) {
|
|
1480
|
+
return `${spinner} ${label} ${paint(out).dim(formatElapsed(Date.now() - startedAt))}`;
|
|
1481
|
+
}
|
|
1413
1482
|
// ../kit/src/cli.ts
|
|
1414
1483
|
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
1415
1484
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1416
|
-
import
|
|
1485
|
+
import process16 from "process";
|
|
1417
1486
|
|
|
1418
1487
|
// ../kit/src/usage.ts
|
|
1419
1488
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1420
1489
|
import { homedir as homedir3 } from "os";
|
|
1421
1490
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1422
|
-
import
|
|
1491
|
+
import process15 from "process";
|
|
1423
1492
|
|
|
1424
1493
|
// ../kit/src/logs.ts
|
|
1425
1494
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1433,14 +1502,14 @@ var usageError;
|
|
|
1433
1502
|
function noteUsageError(message) {
|
|
1434
1503
|
usageError = message;
|
|
1435
1504
|
}
|
|
1436
|
-
function stateHome(env =
|
|
1505
|
+
function stateHome(env = process15.env) {
|
|
1437
1506
|
const dir = env.XDG_STATE_HOME;
|
|
1438
1507
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1439
1508
|
}
|
|
1440
|
-
function usagePath(env =
|
|
1509
|
+
function usagePath(env = process15.env) {
|
|
1441
1510
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1442
1511
|
}
|
|
1443
|
-
function usageRecorded(env =
|
|
1512
|
+
function usageRecorded(env = process15.env) {
|
|
1444
1513
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1445
1514
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1446
1515
|
}
|
|
@@ -1454,7 +1523,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1454
1523
|
usageError = undefined;
|
|
1455
1524
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1456
1525
|
}
|
|
1457
|
-
function recordUsage(entry, env =
|
|
1526
|
+
function recordUsage(entry, env = process15.env) {
|
|
1458
1527
|
if (!usageRecorded(env))
|
|
1459
1528
|
return;
|
|
1460
1529
|
try {
|
|
@@ -1545,8 +1614,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1545
1614
|
`);
|
|
1546
1615
|
}
|
|
1547
1616
|
function printError(prefix, message, hint, cause) {
|
|
1548
|
-
const colors = paint(
|
|
1549
|
-
const styled = takesControlCodes(
|
|
1617
|
+
const colors = paint(process16.stderr);
|
|
1618
|
+
const styled = takesControlCodes(process16.stderr);
|
|
1550
1619
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1551
1620
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1552
1621
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1556,8 +1625,8 @@ function runHint(command, effect) {
|
|
|
1556
1625
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1557
1626
|
}
|
|
1558
1627
|
function printHint(hint) {
|
|
1559
|
-
const colors = paint(
|
|
1560
|
-
console.error(` ${takesControlCodes(
|
|
1628
|
+
const colors = paint(process16.stderr);
|
|
1629
|
+
console.error(` ${takesControlCodes(process16.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1561
1630
|
}
|
|
1562
1631
|
function printJsonError(message, hint, cause) {
|
|
1563
1632
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1596,11 +1665,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1596
1665
|
}
|
|
1597
1666
|
}
|
|
1598
1667
|
if (name === undefined && level.path.length > 1) {
|
|
1599
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1668
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process16.stderr));
|
|
1600
1669
|
return 2;
|
|
1601
1670
|
}
|
|
1602
1671
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1603
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1672
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process16.stdout));
|
|
1604
1673
|
return 0;
|
|
1605
1674
|
}
|
|
1606
1675
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1727,7 +1796,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1727
1796
|
return "0.0.0";
|
|
1728
1797
|
}
|
|
1729
1798
|
}
|
|
1730
|
-
async function runCli(cli, argv =
|
|
1799
|
+
async function runCli(cli, argv = process16.argv.slice(2)) {
|
|
1731
1800
|
const version = cli.version ?? packageVersion();
|
|
1732
1801
|
if (argv[0] === COMPLETE)
|
|
1733
1802
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1758,7 +1827,7 @@ function commandPath(scope, argv) {
|
|
|
1758
1827
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1759
1828
|
// ../kit/src/git.ts
|
|
1760
1829
|
import { basename, dirname as dirname4 } from "path";
|
|
1761
|
-
import
|
|
1830
|
+
import process17 from "process";
|
|
1762
1831
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1763
1832
|
var GIT_NETWORK_MS = 60000;
|
|
1764
1833
|
async function git(args, timeoutMs) {
|
|
@@ -1788,7 +1857,7 @@ async function defaultBranch() {
|
|
|
1788
1857
|
async function leaveWorktree() {
|
|
1789
1858
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1790
1859
|
if (basename(common) === ".git")
|
|
1791
|
-
|
|
1860
|
+
process17.chdir(dirname4(common));
|
|
1792
1861
|
}
|
|
1793
1862
|
// ../kit/src/limit.ts
|
|
1794
1863
|
function limitOptions(fallback) {
|
|
@@ -1829,15 +1898,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
|
|
|
1829
1898
|
// ../kit/src/sessions.ts
|
|
1830
1899
|
import { homedir as homedir4 } from "os";
|
|
1831
1900
|
import { join as join6 } from "path";
|
|
1832
|
-
import
|
|
1901
|
+
import process18 from "process";
|
|
1833
1902
|
var {Glob } = globalThis.Bun;
|
|
1834
1903
|
var SESSION_FILES = new Glob("*.json");
|
|
1835
1904
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1836
1905
|
async function sessionDirs() {
|
|
1837
1906
|
const home = homedir4();
|
|
1838
1907
|
const dirs = new Set([join6(home, ".claude", "sessions")]);
|
|
1839
|
-
if (
|
|
1840
|
-
dirs.add(join6(
|
|
1908
|
+
if (process18.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1909
|
+
dirs.add(join6(process18.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1841
1910
|
try {
|
|
1842
1911
|
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1843
1912
|
dirs.add(dir);
|
|
@@ -1883,7 +1952,7 @@ async function liveSessions() {
|
|
|
1883
1952
|
}
|
|
1884
1953
|
async function currentSession(sessions) {
|
|
1885
1954
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1886
|
-
let pid =
|
|
1955
|
+
let pid = process18.ppid;
|
|
1887
1956
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1888
1957
|
const session = byPid.get(pid);
|
|
1889
1958
|
if (session !== undefined)
|
|
@@ -1896,7 +1965,7 @@ async function currentSession(sessions) {
|
|
|
1896
1965
|
return;
|
|
1897
1966
|
}
|
|
1898
1967
|
// ../kit/src/watch.ts
|
|
1899
|
-
import
|
|
1968
|
+
import process19 from "process";
|
|
1900
1969
|
import { format } from "util";
|
|
1901
1970
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1902
1971
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1918,7 +1987,7 @@ function withoutWatch(args) {
|
|
|
1918
1987
|
}
|
|
1919
1988
|
return rest;
|
|
1920
1989
|
}
|
|
1921
|
-
async function watching(value, step, stream =
|
|
1990
|
+
async function watching(value, step, stream = process19.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1922
1991
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1923
1992
|
if (!takesControlCodes(stream))
|
|
1924
1993
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1926,12 +1995,12 @@ async function watching(value, step, stream = process18.stdout, sleep = Bun.slee
|
|
|
1926
1995
|
for (let round = 0;round < rounds; round++) {
|
|
1927
1996
|
const held = [];
|
|
1928
1997
|
const { log, info } = console;
|
|
1929
|
-
const write =
|
|
1998
|
+
const write = process19.stdout.write.bind(process19.stdout);
|
|
1930
1999
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1931
2000
|
`);
|
|
1932
2001
|
console.log = hold;
|
|
1933
2002
|
console.info = hold;
|
|
1934
|
-
|
|
2003
|
+
process19.stdout.write = (text) => {
|
|
1935
2004
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1936
2005
|
return true;
|
|
1937
2006
|
};
|
|
@@ -1940,7 +2009,7 @@ async function watching(value, step, stream = process18.stdout, sleep = Bun.slee
|
|
|
1940
2009
|
} finally {
|
|
1941
2010
|
console.log = log;
|
|
1942
2011
|
console.info = info;
|
|
1943
|
-
|
|
2012
|
+
process19.stdout.write = write;
|
|
1944
2013
|
}
|
|
1945
2014
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1946
2015
|
await sleep(interval);
|
|
@@ -2117,10 +2186,16 @@ function holderSession(holder, sessions) {
|
|
|
2117
2186
|
return lane === undefined ? undefined : sessions.find((session) => session.name.endsWith(`-${lane}`));
|
|
2118
2187
|
}
|
|
2119
2188
|
|
|
2189
|
+
// src/good.ts
|
|
2190
|
+
import process21 from "process";
|
|
2191
|
+
function good(text) {
|
|
2192
|
+
return role("ok", process21.stdout)(text);
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2120
2195
|
// src/forge.ts
|
|
2121
2196
|
import { homedir as homedir5 } from "os";
|
|
2122
2197
|
import { join as join7 } from "path";
|
|
2123
|
-
import
|
|
2198
|
+
import process22 from "process";
|
|
2124
2199
|
|
|
2125
2200
|
// src/remote.ts
|
|
2126
2201
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2175,7 +2250,7 @@ function loginHosts(config) {
|
|
|
2175
2250
|
return hosts;
|
|
2176
2251
|
}
|
|
2177
2252
|
function teaConfigPath() {
|
|
2178
|
-
const base =
|
|
2253
|
+
const base = process22.env.XDG_CONFIG_HOME;
|
|
2179
2254
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2180
2255
|
}
|
|
2181
2256
|
async function readConfig() {
|
|
@@ -2642,7 +2717,7 @@ async function take(args) {
|
|
|
2642
2717
|
const standingNow = latestClaim(await commentsOf(number, values.repo), author);
|
|
2643
2718
|
if (standingNow?.holder !== name)
|
|
2644
2719
|
fail(`#${number} was taken by ${standingNow?.holder ?? "another session"} at the same moment`, 1);
|
|
2645
|
-
console.log(`took #${number} as ${name}: ${found.title}`);
|
|
2720
|
+
console.log(good(`took #${number} as ${name}: ${found.title}`));
|
|
2646
2721
|
});
|
|
2647
2722
|
}
|
|
2648
2723
|
var dropUsage = `ft drop <n>... [--stale] | --all-stale [--dry-run]
|
|
@@ -2668,7 +2743,7 @@ async function releaseStale(number, me, author, sessions, repo) {
|
|
|
2668
2743
|
fail(`#${number} is taken by ${claim.holder}, which still runs (${current.session.status})`, 1);
|
|
2669
2744
|
await comment(number, releasedComment(claim.holder), repo);
|
|
2670
2745
|
await comment(number, `Claim of ${claim.holder} from ${formatAge(claim.at)}, which no live session answered to, released as stale by session ${me}.`, repo);
|
|
2671
|
-
console.log(`released #${number}, held by ${claim.holder}`);
|
|
2746
|
+
console.log(good(`released #${number}, held by ${claim.holder}`));
|
|
2672
2747
|
}
|
|
2673
2748
|
async function drop(args) {
|
|
2674
2749
|
const parsed = parse(args, dropUsage, dropOptions);
|
|
@@ -2706,12 +2781,12 @@ async function drop(args) {
|
|
|
2706
2781
|
if (claim?.holder !== name)
|
|
2707
2782
|
fail(`#${number} is ${claim === undefined ? "not taken" : `taken by ${claim.holder}, not ${name}`}`, 1, claim === undefined ? undefined : runHint(`ft drop ${number} --stale`, "release it if no session answers to it"));
|
|
2708
2783
|
await comment(number, releasedComment(name), values.repo);
|
|
2709
|
-
console.log(`released #${number}`);
|
|
2784
|
+
console.log(good(`released #${number}`));
|
|
2710
2785
|
});
|
|
2711
2786
|
}
|
|
2712
2787
|
|
|
2713
2788
|
// src/commands/ci.ts
|
|
2714
|
-
import
|
|
2789
|
+
import process23 from "process";
|
|
2715
2790
|
|
|
2716
2791
|
// src/git.ts
|
|
2717
2792
|
async function tagsAt(commit) {
|
|
@@ -2783,6 +2858,15 @@ function startedAt(run) {
|
|
|
2783
2858
|
const at = Date.parse(run.started);
|
|
2784
2859
|
return Number.isNaN(at) || at < EPOCH ? undefined : at;
|
|
2785
2860
|
}
|
|
2861
|
+
function elapsed(run, seen) {
|
|
2862
|
+
if (FINISHED.has(run.status))
|
|
2863
|
+
return run.duration > 0 ? `in ${formatSeconds(runSeconds(run))}` : undefined;
|
|
2864
|
+
const seconds = Math.floor((Date.now() - (startedAt(run) ?? seen)) / 1000);
|
|
2865
|
+
return seconds > 0 ? `for ${formatSeconds(seconds)}` : undefined;
|
|
2866
|
+
}
|
|
2867
|
+
function runLine(run, out, seen = Date.now()) {
|
|
2868
|
+
return ciLine(run.status, run.workflow_id, [`run ${run.id}`, `on ${run.prettyref}`, elapsed(run, seen)], out);
|
|
2869
|
+
}
|
|
2786
2870
|
function startedAge(run, now = Date.now()) {
|
|
2787
2871
|
return startedAt(run) === undefined ? "-" : formatAge(run.started, now);
|
|
2788
2872
|
}
|
|
@@ -2967,7 +3051,6 @@ async function ci2(args) {
|
|
|
2967
3051
|
return;
|
|
2968
3052
|
}
|
|
2969
3053
|
const json = values.json === true;
|
|
2970
|
-
const { dim } = paint(process21.stderr);
|
|
2971
3054
|
const runs = await waitForCi({
|
|
2972
3055
|
tool: "ft ci",
|
|
2973
3056
|
short,
|
|
@@ -2991,8 +3074,8 @@ async function ci2(args) {
|
|
|
2991
3074
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
2992
3075
|
},
|
|
2993
3076
|
lines: (spinner, found, started) => [
|
|
2994
|
-
|
|
2995
|
-
...(found ?? []).map((run) => ` ${
|
|
3077
|
+
ciHeader(spinner, `CI on ${short}`, started, process23.stderr),
|
|
3078
|
+
...(found ?? []).map((run) => ` ${runLine(run, process23.stderr)}`)
|
|
2996
3079
|
]
|
|
2997
3080
|
});
|
|
2998
3081
|
const status = overall(runs);
|
|
@@ -3008,7 +3091,7 @@ async function ci2(args) {
|
|
|
3008
3091
|
return status === "failure" ? 1 : 0;
|
|
3009
3092
|
}
|
|
3010
3093
|
if (status !== "failure") {
|
|
3011
|
-
console.log(`CI ${status === "success" ? "passed" : "skipped its tests, a release tag's workflow testing them"} on ${short}`);
|
|
3094
|
+
console.log(good(`CI ${status === "success" ? "passed" : "skipped its tests, a release tag's workflow testing them"} on ${short}`));
|
|
3012
3095
|
return 0;
|
|
3013
3096
|
}
|
|
3014
3097
|
for (const run of runs) {
|
|
@@ -3022,7 +3105,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
3022
3105
|
}
|
|
3023
3106
|
|
|
3024
3107
|
// src/commands/digest.ts
|
|
3025
|
-
import
|
|
3108
|
+
import process24 from "process";
|
|
3026
3109
|
var RUNS_SCANNED = 50;
|
|
3027
3110
|
var TITLE_WIDTH2 = 70;
|
|
3028
3111
|
var SHOWN = 8;
|
|
@@ -3072,7 +3155,7 @@ async function quietly(read) {
|
|
|
3072
3155
|
}
|
|
3073
3156
|
}
|
|
3074
3157
|
async function staleTodos() {
|
|
3075
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3158
|
+
const bin = Bun.which("todo-scan", { PATH: process24.env.PATH ?? "" });
|
|
3076
3159
|
if (bin === null)
|
|
3077
3160
|
return [];
|
|
3078
3161
|
let found;
|
|
@@ -3094,8 +3177,8 @@ async function staleTodos() {
|
|
|
3094
3177
|
return [...byIssue.values()];
|
|
3095
3178
|
}
|
|
3096
3179
|
function claimLine(row, now) {
|
|
3097
|
-
const id = role("id",
|
|
3098
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
3180
|
+
const id = role("id", process24.stdout);
|
|
3181
|
+
return [id(`#${row.number}`), row.holder, paint(process24.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
|
|
3099
3182
|
}
|
|
3100
3183
|
function capped2(lines) {
|
|
3101
3184
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3106,13 +3189,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3106
3189
|
`) },
|
|
3107
3190
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3108
3191
|
`) },
|
|
3109
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
3192
|
+
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process24.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
|
|
3110
3193
|
`), TITLE_WIDTH2)}`) },
|
|
3111
3194
|
{ heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
|
|
3112
|
-
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path",
|
|
3195
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process24.stdout)(file.path)}`)) },
|
|
3113
3196
|
{ heading: "stale TODO comments", tone: "skipped", count: digest.stale.length, lines: capped2(digest.stale.map((todo) => `${todo.issue} closed: ${todo.comments.map((each) => `${each.path}:${each.line}`).join(", ")}`)) }
|
|
3114
3197
|
].filter((each) => each.count > 0);
|
|
3115
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
3198
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process24.stdout, process24.env, tone)}
|
|
3116
3199
|
${lines.join(`
|
|
3117
3200
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3118
3201
|
|
|
@@ -3240,12 +3323,12 @@ ${tickUsage}`);
|
|
|
3240
3323
|
}, values.repo);
|
|
3241
3324
|
}
|
|
3242
3325
|
for (const box of result.changed)
|
|
3243
|
-
console.log(`${done ? "ticked" : "unticked"} ${box.number}: ${box.text}`);
|
|
3326
|
+
console.log(good(`${done ? "ticked" : "unticked"} ${box.number}: ${box.text}`));
|
|
3244
3327
|
const left = boxes(result.body).filter((box) => !box.done).length;
|
|
3245
3328
|
console.log(`#${number}: ${result.changed.length === 0 ? "nothing to change, " : ""}${left} box${left === 1 ? "" : "es"} left`);
|
|
3246
3329
|
if (note !== undefined) {
|
|
3247
3330
|
await comment(number, note, values.repo);
|
|
3248
|
-
console.log(`commented on #${number}`);
|
|
3331
|
+
console.log(good(`commented on #${number}`));
|
|
3249
3332
|
}
|
|
3250
3333
|
return 0;
|
|
3251
3334
|
}
|
|
@@ -3292,7 +3375,7 @@ async function tickListings(closed, repo) {
|
|
|
3292
3375
|
if (!referencedBoxes(listing.body).some(({ box, issue }) => issue === closed && !box.done))
|
|
3293
3376
|
continue;
|
|
3294
3377
|
if (await editBody(listing.number, (body) => tickReferences(body, (issue) => issue === closed).body, repo))
|
|
3295
|
-
console.log(`ticked #${closed} in #${listing.number}`);
|
|
3378
|
+
console.log(good(`ticked #${closed} in #${listing.number}`));
|
|
3296
3379
|
}
|
|
3297
3380
|
}
|
|
3298
3381
|
async function fixed(args) {
|
|
@@ -3306,7 +3389,7 @@ async function fixed(args) {
|
|
|
3306
3389
|
const left = boxes(found.body).filter((box) => !box.done);
|
|
3307
3390
|
if (left.length > 0 && values.tick === true) {
|
|
3308
3391
|
await editBody(number, (body) => setBoxes(body, boxes(body).filter((box) => !box.done).map((box) => String(box.number)), true).body, values.repo);
|
|
3309
|
-
console.log(`ticked ${left.length} box${left.length === 1 ? "" : "es"} of #${number}`);
|
|
3392
|
+
console.log(good(`ticked ${left.length} box${left.length === 1 ? "" : "es"} of #${number}`));
|
|
3310
3393
|
} else if (left.length > 0 && values.force !== true) {
|
|
3311
3394
|
fail(`#${number} has ${left.length} boxes left:
|
|
3312
3395
|
${left.map((box) => `${String(box.number).padStart(3)} [ ] ${box.text}`).join(`
|
|
@@ -3317,7 +3400,7 @@ ${left.map((box) => `${String(box.number).padStart(3)} [ ] ${box.text}`).join(`
|
|
|
3317
3400
|
if ((await commentsOf(number, values.repo)).at(-1)?.body.trim() !== line.trim())
|
|
3318
3401
|
await comment(number, line, values.repo);
|
|
3319
3402
|
await close(number, values.repo);
|
|
3320
|
-
console.log(`closed #${number}: fixed in ${shas}`);
|
|
3403
|
+
console.log(good(`closed #${number}: fixed in ${shas}`));
|
|
3321
3404
|
await tickListings(number, values.repo);
|
|
3322
3405
|
return 0;
|
|
3323
3406
|
}
|
|
@@ -3348,7 +3431,7 @@ async function setState(args, usage, wanted) {
|
|
|
3348
3431
|
await close(number, values.repo);
|
|
3349
3432
|
else
|
|
3350
3433
|
await reopen(number, values.repo);
|
|
3351
|
-
console.log(`${wanted === "closed" ? "closed" : "reopened"} #${number}`);
|
|
3434
|
+
console.log(good(`${wanted === "closed" ? "closed" : "reopened"} #${number}`));
|
|
3352
3435
|
}
|
|
3353
3436
|
return 0;
|
|
3354
3437
|
}
|
|
@@ -3494,7 +3577,7 @@ ${text}` : body;
|
|
|
3494
3577
|
return missing.length > 0 ? appendBoxes(appended, missing) : appended;
|
|
3495
3578
|
}, values.repo);
|
|
3496
3579
|
}
|
|
3497
|
-
console.log(`edited #${number}`);
|
|
3580
|
+
console.log(good(`edited #${number}`));
|
|
3498
3581
|
return 0;
|
|
3499
3582
|
}
|
|
3500
3583
|
var commentUsage = `ft comment [<n>] [text]
|
|
@@ -3518,7 +3601,7 @@ async function commentOn(args) {
|
|
|
3518
3601
|
|
|
3519
3602
|
${commentUsage}`);
|
|
3520
3603
|
await comment(number, text, values.repo);
|
|
3521
|
-
console.log(`commented on #${number}`);
|
|
3604
|
+
console.log(good(`commented on #${number}`));
|
|
3522
3605
|
return 0;
|
|
3523
3606
|
}
|
|
3524
3607
|
|
|
@@ -3665,28 +3748,59 @@ async function logs2(args) {
|
|
|
3665
3748
|
printJson({ ...ciJson([run], shown.filter((job) => job.status === "failure").map((job) => ({ name: job.name, run: run.id, workflow: run.workflow_id, excerpt: job.excerpt }))), jobs: shown });
|
|
3666
3749
|
return 0;
|
|
3667
3750
|
}
|
|
3668
|
-
console.log(`${run.workflow_id} run ${run.id} on ${run.prettyref} (${run.commit_sha.slice(0, 7)}): ${badge(run.status, process.stdout)}, ${run.html_url}`);
|
|
3751
|
+
console.log(`${paint(process.stdout).bold(`${run.workflow_id} run ${run.id}`)} on ${run.prettyref} (${run.commit_sha.slice(0, 7)}): ${badge(run.status, process.stdout)}, ${role("path", process.stdout)(run.html_url)}`);
|
|
3669
3752
|
for (const job of picked) {
|
|
3670
3753
|
console.log(`
|
|
3671
|
-
job ${job.name}: ${badge(job.status, process.stdout)}
|
|
3754
|
+
${paint(process.stdout).bold(`job ${job.name}`)}: ${badge(job.status, process.stdout)}
|
|
3672
3755
|
${await text(job)}`);
|
|
3673
3756
|
}
|
|
3674
3757
|
return 0;
|
|
3675
3758
|
}
|
|
3676
3759
|
|
|
3677
3760
|
// src/commands/milestone.ts
|
|
3761
|
+
import process25 from "process";
|
|
3678
3762
|
var TITLE_WIDTH3 = 60;
|
|
3679
3763
|
var LIST_LIMIT = 30;
|
|
3764
|
+
var CONCURRENCY2 = 4;
|
|
3680
3765
|
function counts(milestone) {
|
|
3681
3766
|
return `${milestone.open_issues} open, ${milestone.closed_issues} closed`;
|
|
3682
3767
|
}
|
|
3768
|
+
function progressBar(milestone) {
|
|
3769
|
+
const total = milestone.open_issues + milestone.closed_issues;
|
|
3770
|
+
return takesControlCodes(process25.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
3771
|
+
}
|
|
3772
|
+
function milestoneCells(each, showState) {
|
|
3773
|
+
const drawn = progressBar(each);
|
|
3774
|
+
return [String(each.id), truncate(each.title, TITLE_WIDTH3), `${each.open_issues} open`, `${each.closed_issues} closed`, ...drawn === "" ? [] : [drawn], progress(each), dueDate(each) === "" ? "" : `due ${dueDate(each)}`, ...showState ? [each.state] : []];
|
|
3775
|
+
}
|
|
3776
|
+
async function printWithIssues(list, repo) {
|
|
3777
|
+
const colors = paint(process25.stdout);
|
|
3778
|
+
const id = role("id", process25.stdout);
|
|
3779
|
+
const issuesOf = await pool(list, CONCURRENCY2, async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
3780
|
+
const blocks = list.map((each, index) => {
|
|
3781
|
+
const byNumber = (left, right) => left.number - right.number;
|
|
3782
|
+
const [open, closed] = issuesOf[index].map((found) => found.toSorted(byNumber));
|
|
3783
|
+
const drawn = progressBar(each);
|
|
3784
|
+
const facts = [counts(each), progress(each), dueDate(each) === "" ? "" : `due ${dueDate(each)}`].filter((fact) => fact !== "").join(", ");
|
|
3785
|
+
const lines = [
|
|
3786
|
+
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
3787
|
+
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
3788
|
+
];
|
|
3789
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process25.stdout, process25.env, "accent"), ...lines].join(`
|
|
3790
|
+
`);
|
|
3791
|
+
});
|
|
3792
|
+
console.log(blocks.join(`
|
|
3793
|
+
|
|
3794
|
+
`));
|
|
3795
|
+
}
|
|
3683
3796
|
var listUsage = `ft milestones
|
|
3684
3797
|
|
|
3685
|
-
Lists the repository's milestones, the open ones unless --state says otherwise, with the issues open and closed in each, the progress and the due date.
|
|
3798
|
+
Lists the repository's milestones, the open ones unless --state says otherwise, with the issues open and closed in each, the progress and the due date; on a terminal the progress is a bar, and --issues lists the title of every issue under its milestone.
|
|
3686
3799
|
|
|
3687
3800
|
Exits 0 when it listed them, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3688
3801
|
var listOptions = {
|
|
3689
3802
|
state: { type: "string", description: "open (the default), closed or all" },
|
|
3803
|
+
issues: { type: "boolean", short: "i", description: "list the open and closed issues of each milestone by title" },
|
|
3690
3804
|
...limitOptions(LIST_LIMIT),
|
|
3691
3805
|
json: jsonOption("id, title, state, description, open, closed, due (YYYY-MM-DD or null)"),
|
|
3692
3806
|
...repoOption
|
|
@@ -3699,6 +3813,8 @@ async function milestones(args) {
|
|
|
3699
3813
|
fail(`--state takes open, closed or all, not ${state}`);
|
|
3700
3814
|
const limit = limitOf(values, LIST_LIMIT);
|
|
3701
3815
|
const found = await listMilestones(state, values.repo);
|
|
3816
|
+
if (values.issues === true && values.json === true)
|
|
3817
|
+
fail("--issues lists for a person, --json has the counts only");
|
|
3702
3818
|
if (values.json === true) {
|
|
3703
3819
|
printJson(found.slice(0, limit).map((each) => ({ id: each.id, title: each.title, state: each.state, description: each.description, open: each.open_issues, closed: each.closed_issues, due: dueDate(each) || null })));
|
|
3704
3820
|
return 0;
|
|
@@ -3708,9 +3824,10 @@ async function milestones(args) {
|
|
|
3708
3824
|
return 0;
|
|
3709
3825
|
}
|
|
3710
3826
|
const { shown, footer } = capped(found, limit);
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3827
|
+
if (values.issues === true)
|
|
3828
|
+
await printWithIssues(shown, values.repo);
|
|
3829
|
+
else
|
|
3830
|
+
console.log(table(shown.map((each) => milestoneCells(each, state === "all"))));
|
|
3714
3831
|
if (footer !== undefined)
|
|
3715
3832
|
console.log(footer);
|
|
3716
3833
|
return 0;
|
|
@@ -3766,7 +3883,7 @@ ${closeUsage2}`);
|
|
|
3766
3883
|
${open.map((issue) => ` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)}`).join(`
|
|
3767
3884
|
`)}`, 1, `${runHint(`ft milestone close ${found.title} --force`, "close it with them open")}, or move them with \`ft edit <n> -m <milestone>\``);
|
|
3768
3885
|
await closeMilestone(found.id, values.repo);
|
|
3769
|
-
console.log(`closed milestone ${found.title}`);
|
|
3886
|
+
console.log(good(`closed milestone ${found.title}`));
|
|
3770
3887
|
return 0;
|
|
3771
3888
|
}
|
|
3772
3889
|
var showUsage = `ft milestone <title|id>
|
|
@@ -3930,12 +4047,12 @@ async function carry(args) {
|
|
|
3930
4047
|
function report(plan, added, skipped) {
|
|
3931
4048
|
for (const line of added)
|
|
3932
4049
|
console.log(`#${plan}: ${line}`);
|
|
3933
|
-
console.log(`#${plan}: ${added.length} added${skipped === 0 ? "" : `, ${skipped} already listed`}`);
|
|
4050
|
+
console.log(good(`#${plan}: ${added.length} added${skipped === 0 ? "" : `, ${skipped} already listed`}`));
|
|
3934
4051
|
}
|
|
3935
4052
|
|
|
3936
4053
|
// src/commands/release.ts
|
|
3937
4054
|
import { basename as basename3, join as join11 } from "path";
|
|
3938
|
-
import
|
|
4055
|
+
import process27 from "process";
|
|
3939
4056
|
var {$: $2 } = globalThis.Bun;
|
|
3940
4057
|
|
|
3941
4058
|
// src/commands/watch.ts
|
|
@@ -3962,8 +4079,8 @@ async function followRuns(pick, timeout, repo, idle, out = process.stdout, mode
|
|
|
3962
4079
|
const started = Date.now();
|
|
3963
4080
|
const latest = new Map;
|
|
3964
4081
|
const seen = new Map;
|
|
3965
|
-
const line = (run) =>
|
|
3966
|
-
const region = takesControlCodes(out) && !quiet ? liveRegion(() => [...latest.values()].map(line), out) : undefined;
|
|
4082
|
+
const line = (run) => runLine(run, out, seen.get(run.id) ?? Date.now());
|
|
4083
|
+
const region = takesControlCodes(out) && !quiet ? liveRegion((spinner) => [ciHeader(spinner, "CI", started, out), ...[...latest.values()].map((run) => ` ${line(run)}`)], out) : undefined;
|
|
3967
4084
|
const followed = new Set;
|
|
3968
4085
|
const failed = new Set;
|
|
3969
4086
|
const failedJobs = [];
|
|
@@ -4046,12 +4163,6 @@ ${run.html_url}`);
|
|
|
4046
4163
|
}
|
|
4047
4164
|
}
|
|
4048
4165
|
}
|
|
4049
|
-
function elapsed(run, seen) {
|
|
4050
|
-
if (FINISHED.has(run.status))
|
|
4051
|
-
return run.duration > 0 ? ` in ${formatSeconds(runSeconds(run))}` : "";
|
|
4052
|
-
const seconds = Math.floor((Date.now() - (startedAt(run) ?? seen)) / 1000);
|
|
4053
|
-
return seconds > 0 ? ` for ${formatSeconds(seconds)}` : "";
|
|
4054
|
-
}
|
|
4055
4166
|
async function watch2(args) {
|
|
4056
4167
|
const parsed = parse(args, usage5, options5);
|
|
4057
4168
|
const { values } = parsed;
|
|
@@ -4179,12 +4290,12 @@ async function publishable() {
|
|
|
4179
4290
|
|
|
4180
4291
|
// src/commands/release-plan.ts
|
|
4181
4292
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4182
|
-
import
|
|
4293
|
+
import process26 from "process";
|
|
4183
4294
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4184
4295
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4185
4296
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4186
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4187
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4297
|
+
const name = pkg?.name ?? basename2(dir ?? process26.cwd());
|
|
4298
|
+
const where = dir === undefined ? "" : ` in ${relative(process26.cwd(), dir) || "."}`;
|
|
4188
4299
|
let version;
|
|
4189
4300
|
let bump;
|
|
4190
4301
|
if (level === undefined) {
|
|
@@ -4429,7 +4540,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4429
4540
|
if (late !== undefined)
|
|
4430
4541
|
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));
|
|
4431
4542
|
say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
|
|
4432
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ?
|
|
4543
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process27.stderr : process27.stdout, { json });
|
|
4433
4544
|
if (followed.code !== 0) {
|
|
4434
4545
|
report();
|
|
4435
4546
|
return followed.code;
|
|
@@ -4579,7 +4690,7 @@ async function remote(args, home) {
|
|
|
4579
4690
|
await restoreOrigin(fetchUrl, pushUrls, changes);
|
|
4580
4691
|
return fail(`the switched origin does not answer, so the old URLs were put back: ${redactUrl(error instanceof Error ? error.message : String(error))}`, 1);
|
|
4581
4692
|
}
|
|
4582
|
-
console.log("origin switched, and git ls-remote reaches it");
|
|
4693
|
+
console.log(good("origin switched, and git ls-remote reaches it"));
|
|
4583
4694
|
return 0;
|
|
4584
4695
|
}
|
|
4585
4696
|
|
|
@@ -4634,7 +4745,7 @@ async function runs(args) {
|
|
|
4634
4745
|
}
|
|
4635
4746
|
|
|
4636
4747
|
// src/cli.ts
|
|
4637
|
-
|
|
4748
|
+
process28.exitCode = await runCli({
|
|
4638
4749
|
name: "ft",
|
|
4639
4750
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4640
4751
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|
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.26.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.33.0"
|
|
32
32
|
}
|
|
33
33
|
}
|