@kaynooo/cli-forgejo 0.28.2 → 0.29.1
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 +194 -193
- 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 process29 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -574,18 +574,14 @@ var FULL_STOP = /\.$/;
|
|
|
574
574
|
function usageLine(usage, colors = paint(process8.stdout)) {
|
|
575
575
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
576
576
|
}
|
|
577
|
-
function helpText(usage, options, colors = paint(process8.stdout), { examples = [],
|
|
578
|
-
return [usageLine(usage, colors),
|
|
577
|
+
function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
|
|
578
|
+
return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
579
579
|
`);
|
|
580
580
|
}
|
|
581
581
|
function exitRows(exits, colors = paint(process8.stdout)) {
|
|
582
582
|
if (exits.length === 0)
|
|
583
583
|
return [];
|
|
584
|
-
|
|
585
|
-
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
586
|
-
}
|
|
587
|
-
function replacesRows(replaces, colors = paint(process8.stdout)) {
|
|
588
|
-
return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
584
|
+
return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
|
|
589
585
|
}
|
|
590
586
|
function wantsHelpJson(env = process8.env) {
|
|
591
587
|
return env.KIT_HELP === "json";
|
|
@@ -897,11 +893,35 @@ function nearestOption(message, options, allowNegative) {
|
|
|
897
893
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
898
894
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
899
895
|
}
|
|
900
|
-
// ../kit/src/
|
|
896
|
+
// ../kit/src/argv.ts
|
|
897
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
898
|
+
import { resolve as resolve3 } from "path";
|
|
901
899
|
import process11 from "process";
|
|
900
|
+
function commandLine() {
|
|
901
|
+
try {
|
|
902
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
903
|
+
} catch {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function realPath(word) {
|
|
908
|
+
try {
|
|
909
|
+
return realpathSync(resolve3(word));
|
|
910
|
+
} catch {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
|
|
915
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
916
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
|
|
917
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
918
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
919
|
+
}
|
|
920
|
+
// ../kit/src/chart.ts
|
|
921
|
+
import process12 from "process";
|
|
902
922
|
var FILLED = "\u2501";
|
|
903
923
|
var EMPTY = "\u2500";
|
|
904
|
-
function bar(ratio, { width = 20, stream =
|
|
924
|
+
function bar(ratio, { width = 20, stream = process12.stdout, env = process12.env } = {}) {
|
|
905
925
|
if (outputMode(stream, env) === "agent")
|
|
906
926
|
return formatPercent(Math.min(1, Math.max(0, ratio)));
|
|
907
927
|
const colors = paint(stream, env);
|
|
@@ -912,12 +932,12 @@ function bar(ratio, { width = 20, stream = process11.stdout, env = process11.env
|
|
|
912
932
|
return `${shaded(theme, colors, theme.glyphs.bar, filled, width, env)}${colors.dim(theme.glyphs.bar.repeat(width - filled))}`;
|
|
913
933
|
}
|
|
914
934
|
// ../kit/src/progress.ts
|
|
915
|
-
import
|
|
935
|
+
import process14 from "process";
|
|
916
936
|
|
|
917
937
|
// ../kit/src/process.ts
|
|
918
938
|
import { constants } from "os";
|
|
919
|
-
import { resolve as
|
|
920
|
-
import
|
|
939
|
+
import { resolve as resolve4 } from "path";
|
|
940
|
+
import process13 from "process";
|
|
921
941
|
var KILL_GRACE_MS = 2000;
|
|
922
942
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
923
943
|
var SCHEME = /^[a-z][\w+.-]+:/i;
|
|
@@ -941,7 +961,7 @@ function holdSignals(cleanup) {
|
|
|
941
961
|
},
|
|
942
962
|
release: () => {
|
|
943
963
|
for (const signal of SIGNALS)
|
|
944
|
-
|
|
964
|
+
process13.off(signal, onSignal);
|
|
945
965
|
}
|
|
946
966
|
};
|
|
947
967
|
function onSignal(signal) {
|
|
@@ -954,16 +974,16 @@ function holdSignals(cleanup) {
|
|
|
954
974
|
return;
|
|
955
975
|
held.release();
|
|
956
976
|
cleanup(signal);
|
|
957
|
-
|
|
977
|
+
process13.kill(process13.pid, signal);
|
|
958
978
|
}
|
|
959
979
|
for (const signal of SIGNALS)
|
|
960
|
-
|
|
980
|
+
process13.on(signal, onSignal);
|
|
961
981
|
return held;
|
|
962
982
|
}
|
|
963
|
-
function openUrl(target, env =
|
|
983
|
+
function openUrl(target, env = process13.env, platform = process13.platform) {
|
|
964
984
|
const opener = env.BROWSER === undefined || env.BROWSER === "" ? OPENERS[platform] ?? ["xdg-open"] : [env.BROWSER];
|
|
965
985
|
try {
|
|
966
|
-
Bun.spawn([...opener, SCHEME.test(target) ? target :
|
|
986
|
+
Bun.spawn([...opener, SCHEME.test(target) ? target : resolve4(target)], { env, stdio: ["ignore", "ignore", "ignore"] }).unref();
|
|
967
987
|
return true;
|
|
968
988
|
} catch {
|
|
969
989
|
return false;
|
|
@@ -997,7 +1017,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
997
1017
|
return;
|
|
998
1018
|
try {
|
|
999
1019
|
if (grouped)
|
|
1000
|
-
|
|
1020
|
+
process13.kill(-proc.pid, killing);
|
|
1001
1021
|
else
|
|
1002
1022
|
proc.kill(killing);
|
|
1003
1023
|
} catch {}
|
|
@@ -1075,7 +1095,7 @@ var RESET_STYLE = `${ESC}[0m`;
|
|
|
1075
1095
|
var CTRL_C = 3;
|
|
1076
1096
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1077
1097
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1078
|
-
function liveRegion(render, stream =
|
|
1098
|
+
function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
1079
1099
|
if (!takesControlCodes(stream, env))
|
|
1080
1100
|
return { redraw: () => {
|
|
1081
1101
|
return;
|
|
@@ -1122,11 +1142,11 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1122
1142
|
clear();
|
|
1123
1143
|
restore();
|
|
1124
1144
|
release();
|
|
1125
|
-
|
|
1145
|
+
process14.off("exit", onExit);
|
|
1126
1146
|
signals.release();
|
|
1127
1147
|
}
|
|
1128
1148
|
timer.unref();
|
|
1129
|
-
|
|
1149
|
+
process14.on("exit", onExit);
|
|
1130
1150
|
return {
|
|
1131
1151
|
redraw: draw,
|
|
1132
1152
|
print: (text) => {
|
|
@@ -1165,14 +1185,14 @@ function cutToWidth(line, width) {
|
|
|
1165
1185
|
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1166
1186
|
}
|
|
1167
1187
|
function swallowInput() {
|
|
1168
|
-
const input =
|
|
1188
|
+
const input = process14.stdin;
|
|
1169
1189
|
if (!input.isTTY)
|
|
1170
1190
|
return () => {
|
|
1171
1191
|
return;
|
|
1172
1192
|
};
|
|
1173
1193
|
const onData = (data) => {
|
|
1174
1194
|
if (data.includes(CTRL_C))
|
|
1175
|
-
|
|
1195
|
+
process14.kill(process14.pid, "SIGINT");
|
|
1176
1196
|
};
|
|
1177
1197
|
input.setRawMode(true);
|
|
1178
1198
|
input.on("data", onData);
|
|
@@ -1188,7 +1208,7 @@ function swallowInput() {
|
|
|
1188
1208
|
};
|
|
1189
1209
|
}
|
|
1190
1210
|
function interceptOutput(clear) {
|
|
1191
|
-
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [
|
|
1211
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process14.stdout, "write"], [process14.stderr, "write"]];
|
|
1192
1212
|
const wrapped = targets.map(([target, name]) => {
|
|
1193
1213
|
const original = Reflect.get(target, name);
|
|
1194
1214
|
const wrapper = (...args) => {
|
|
@@ -1207,11 +1227,11 @@ function interceptOutput(clear) {
|
|
|
1207
1227
|
}
|
|
1208
1228
|
|
|
1209
1229
|
// ../kit/src/tool.ts
|
|
1210
|
-
import
|
|
1230
|
+
import process15 from "process";
|
|
1211
1231
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
1212
1232
|
function cwdGone() {
|
|
1213
1233
|
try {
|
|
1214
|
-
|
|
1234
|
+
process15.cwd();
|
|
1215
1235
|
return false;
|
|
1216
1236
|
} catch {
|
|
1217
1237
|
return true;
|
|
@@ -1238,7 +1258,7 @@ function isPermanentFailure(error) {
|
|
|
1238
1258
|
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1239
1259
|
let ran;
|
|
1240
1260
|
try {
|
|
1241
|
-
ran = await runCommand(argv, { env:
|
|
1261
|
+
ran = await runCommand(argv, { env: process15.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1242
1262
|
} catch (error) {
|
|
1243
1263
|
throw spawnFailure(label, error);
|
|
1244
1264
|
}
|
|
@@ -1330,15 +1350,15 @@ function ciHeader(spinner, label, startedAt, out) {
|
|
|
1330
1350
|
return `${spinner} ${label} ${paint(out).dim(formatElapsed(Date.now() - startedAt))}`;
|
|
1331
1351
|
}
|
|
1332
1352
|
// ../kit/src/cli.ts
|
|
1333
|
-
import { readFileSync as
|
|
1353
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1334
1354
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1335
|
-
import
|
|
1355
|
+
import process17 from "process";
|
|
1336
1356
|
|
|
1337
1357
|
// ../kit/src/usage.ts
|
|
1338
1358
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1339
1359
|
import { homedir as homedir3 } from "os";
|
|
1340
1360
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1341
|
-
import
|
|
1361
|
+
import process16 from "process";
|
|
1342
1362
|
|
|
1343
1363
|
// ../kit/src/logs.ts
|
|
1344
1364
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1352,14 +1372,14 @@ var usageError;
|
|
|
1352
1372
|
function noteUsageError(message) {
|
|
1353
1373
|
usageError = message;
|
|
1354
1374
|
}
|
|
1355
|
-
function stateHome(env =
|
|
1375
|
+
function stateHome(env = process16.env) {
|
|
1356
1376
|
const dir = env.XDG_STATE_HOME;
|
|
1357
1377
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1358
1378
|
}
|
|
1359
|
-
function usagePath(env =
|
|
1379
|
+
function usagePath(env = process16.env) {
|
|
1360
1380
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1361
1381
|
}
|
|
1362
|
-
function usageRecorded(env =
|
|
1382
|
+
function usageRecorded(env = process16.env) {
|
|
1363
1383
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1364
1384
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1365
1385
|
}
|
|
@@ -1373,7 +1393,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1373
1393
|
usageError = undefined;
|
|
1374
1394
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1375
1395
|
}
|
|
1376
|
-
function recordUsage(entry, env =
|
|
1396
|
+
function recordUsage(entry, env = process16.env) {
|
|
1377
1397
|
if (!usageRecorded(env))
|
|
1378
1398
|
return;
|
|
1379
1399
|
try {
|
|
@@ -1450,7 +1470,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1450
1470
|
header(colors, summary),
|
|
1451
1471
|
"",
|
|
1452
1472
|
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
1453
|
-
...replacesRows(replaces, colors),
|
|
1454
1473
|
"",
|
|
1455
1474
|
...await commandRows(commands, colors),
|
|
1456
1475
|
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
@@ -1464,8 +1483,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1464
1483
|
`);
|
|
1465
1484
|
}
|
|
1466
1485
|
function printError(prefix, message, hint, cause) {
|
|
1467
|
-
const colors = paint(
|
|
1468
|
-
const styled = takesControlCodes(
|
|
1486
|
+
const colors = paint(process17.stderr);
|
|
1487
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1469
1488
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1470
1489
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1471
1490
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1475,8 +1494,8 @@ function runHint(command, effect) {
|
|
|
1475
1494
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1476
1495
|
}
|
|
1477
1496
|
function printHint(hint) {
|
|
1478
|
-
const colors = paint(
|
|
1479
|
-
console.error(` ${takesControlCodes(
|
|
1497
|
+
const colors = paint(process17.stderr);
|
|
1498
|
+
console.error(` ${takesControlCodes(process17.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1480
1499
|
}
|
|
1481
1500
|
function printJsonError(message, hint, cause) {
|
|
1482
1501
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1515,11 +1534,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1515
1534
|
}
|
|
1516
1535
|
}
|
|
1517
1536
|
if (name === undefined && level.path.length > 1) {
|
|
1518
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1537
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stderr));
|
|
1519
1538
|
return 2;
|
|
1520
1539
|
}
|
|
1521
1540
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1522
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1541
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stdout));
|
|
1523
1542
|
return 0;
|
|
1524
1543
|
}
|
|
1525
1544
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1575,24 +1594,24 @@ function candidateLine(candidate) {
|
|
|
1575
1594
|
}
|
|
1576
1595
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
1577
1596
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
1578
|
-
|
|
1597
|
+
const typed = [];
|
|
1579
1598
|
let at = 0;
|
|
1580
1599
|
while (at < before.length) {
|
|
1581
1600
|
const word = before[at];
|
|
1582
1601
|
if (word === "--") {
|
|
1583
|
-
|
|
1602
|
+
typed.push(...before.slice(at + 1));
|
|
1584
1603
|
break;
|
|
1585
1604
|
}
|
|
1586
1605
|
if (!word.startsWith("-"))
|
|
1587
|
-
|
|
1606
|
+
typed.push(word);
|
|
1588
1607
|
else if (takesValue(word))
|
|
1589
1608
|
at++;
|
|
1590
1609
|
at++;
|
|
1591
1610
|
}
|
|
1592
1611
|
const last = positionals.at(-1);
|
|
1593
|
-
if (
|
|
1594
|
-
return positionals[
|
|
1595
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1612
|
+
if (typed.length < positionals.length)
|
|
1613
|
+
return { name: positionals[typed.length], typed };
|
|
1614
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
1596
1615
|
}
|
|
1597
1616
|
async function leafCandidates(run, words) {
|
|
1598
1617
|
const completing = await completingOf(run);
|
|
@@ -1600,12 +1619,12 @@ async function leafCandidates(run, words) {
|
|
|
1600
1619
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
1601
1620
|
const flag = words.at(-2);
|
|
1602
1621
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1622
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
1603
1623
|
if (option?.type === "string") {
|
|
1604
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1624
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
1605
1625
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1606
1626
|
}
|
|
1607
|
-
const
|
|
1608
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1627
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1609
1628
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1610
1629
|
}
|
|
1611
1630
|
async function candidates(scope, defaultCommand, words, before = []) {
|
|
@@ -1636,9 +1655,13 @@ async function printCandidates(found) {
|
|
|
1636
1655
|
return 0;
|
|
1637
1656
|
}
|
|
1638
1657
|
function packageVersion(entry = Bun.main) {
|
|
1639
|
-
|
|
1658
|
+
let resolved = entry;
|
|
1659
|
+
try {
|
|
1660
|
+
resolved = realpathSync2(entry);
|
|
1661
|
+
} catch {}
|
|
1662
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1640
1663
|
try {
|
|
1641
|
-
const { version } = JSON.parse(
|
|
1664
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1642
1665
|
if (typeof version === "string")
|
|
1643
1666
|
return version;
|
|
1644
1667
|
} catch {}
|
|
@@ -1646,7 +1669,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1646
1669
|
return "0.0.0";
|
|
1647
1670
|
}
|
|
1648
1671
|
}
|
|
1649
|
-
async function runCli(cli, argv =
|
|
1672
|
+
async function runCli(cli, argv = scriptArgs()) {
|
|
1650
1673
|
const version = cli.version ?? packageVersion();
|
|
1651
1674
|
if (argv[0] === COMPLETE)
|
|
1652
1675
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1677,7 +1700,7 @@ function commandPath(scope, argv) {
|
|
|
1677
1700
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1678
1701
|
// ../kit/src/git.ts
|
|
1679
1702
|
import { basename, dirname as dirname4 } from "path";
|
|
1680
|
-
import
|
|
1703
|
+
import process18 from "process";
|
|
1681
1704
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1682
1705
|
var GIT_NETWORK_MS = 60000;
|
|
1683
1706
|
async function git(args, timeoutMs) {
|
|
@@ -1707,7 +1730,7 @@ async function defaultBranch() {
|
|
|
1707
1730
|
async function leaveWorktree() {
|
|
1708
1731
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1709
1732
|
if (basename(common) === ".git")
|
|
1710
|
-
|
|
1733
|
+
process18.chdir(dirname4(common));
|
|
1711
1734
|
}
|
|
1712
1735
|
// ../kit/src/limit.ts
|
|
1713
1736
|
function limitOptions(fallback) {
|
|
@@ -1748,15 +1771,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
|
|
|
1748
1771
|
// ../kit/src/sessions.ts
|
|
1749
1772
|
import { homedir as homedir4 } from "os";
|
|
1750
1773
|
import { join as join6 } from "path";
|
|
1751
|
-
import
|
|
1774
|
+
import process19 from "process";
|
|
1752
1775
|
var {Glob } = globalThis.Bun;
|
|
1753
1776
|
var SESSION_FILES = new Glob("*.json");
|
|
1754
1777
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1755
1778
|
async function sessionDirs() {
|
|
1756
1779
|
const home = homedir4();
|
|
1757
1780
|
const dirs = new Set([join6(home, ".claude", "sessions")]);
|
|
1758
|
-
if (
|
|
1759
|
-
dirs.add(join6(
|
|
1781
|
+
if (process19.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1782
|
+
dirs.add(join6(process19.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1760
1783
|
try {
|
|
1761
1784
|
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1762
1785
|
dirs.add(dir);
|
|
@@ -1802,7 +1825,7 @@ async function liveSessions() {
|
|
|
1802
1825
|
}
|
|
1803
1826
|
async function currentSession(sessions) {
|
|
1804
1827
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1805
|
-
let pid =
|
|
1828
|
+
let pid = process19.ppid;
|
|
1806
1829
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1807
1830
|
const session = byPid.get(pid);
|
|
1808
1831
|
if (session !== undefined)
|
|
@@ -1815,7 +1838,7 @@ async function currentSession(sessions) {
|
|
|
1815
1838
|
return;
|
|
1816
1839
|
}
|
|
1817
1840
|
// ../kit/src/watch.ts
|
|
1818
|
-
import
|
|
1841
|
+
import process20 from "process";
|
|
1819
1842
|
import { format } from "util";
|
|
1820
1843
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1821
1844
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1837,7 +1860,7 @@ function withoutWatch(args) {
|
|
|
1837
1860
|
}
|
|
1838
1861
|
return rest;
|
|
1839
1862
|
}
|
|
1840
|
-
async function watching(value, step, stream =
|
|
1863
|
+
async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1841
1864
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1842
1865
|
if (!takesControlCodes(stream))
|
|
1843
1866
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1845,12 +1868,12 @@ async function watching(value, step, stream = process19.stdout, sleep = Bun.slee
|
|
|
1845
1868
|
for (let round = 0;round < rounds; round++) {
|
|
1846
1869
|
const held = [];
|
|
1847
1870
|
const { log, info } = console;
|
|
1848
|
-
const write =
|
|
1871
|
+
const write = process20.stdout.write.bind(process20.stdout);
|
|
1849
1872
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1850
1873
|
`);
|
|
1851
1874
|
console.log = hold;
|
|
1852
1875
|
console.info = hold;
|
|
1853
|
-
|
|
1876
|
+
process20.stdout.write = (text) => {
|
|
1854
1877
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1855
1878
|
return true;
|
|
1856
1879
|
};
|
|
@@ -1859,7 +1882,7 @@ async function watching(value, step, stream = process19.stdout, sleep = Bun.slee
|
|
|
1859
1882
|
} finally {
|
|
1860
1883
|
console.log = log;
|
|
1861
1884
|
console.info = info;
|
|
1862
|
-
|
|
1885
|
+
process20.stdout.write = write;
|
|
1863
1886
|
}
|
|
1864
1887
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1865
1888
|
await sleep(interval);
|
|
@@ -2037,9 +2060,9 @@ function holderSession(holder, sessions) {
|
|
|
2037
2060
|
}
|
|
2038
2061
|
|
|
2039
2062
|
// src/good.ts
|
|
2040
|
-
import
|
|
2063
|
+
import process22 from "process";
|
|
2041
2064
|
function good(text) {
|
|
2042
|
-
return role("ok",
|
|
2065
|
+
return role("ok", process22.stdout)(text);
|
|
2043
2066
|
}
|
|
2044
2067
|
|
|
2045
2068
|
// src/config.ts
|
|
@@ -2074,7 +2097,7 @@ async function loadSettings(home) {
|
|
|
2074
2097
|
// src/forge.ts
|
|
2075
2098
|
import { homedir as homedir5 } from "os";
|
|
2076
2099
|
import { join as join7 } from "path";
|
|
2077
|
-
import
|
|
2100
|
+
import process23 from "process";
|
|
2078
2101
|
|
|
2079
2102
|
// src/remote.ts
|
|
2080
2103
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2129,7 +2152,7 @@ function loginHosts(config) {
|
|
|
2129
2152
|
return hosts;
|
|
2130
2153
|
}
|
|
2131
2154
|
function teaConfigPath() {
|
|
2132
|
-
const base =
|
|
2155
|
+
const base = process23.env.XDG_CONFIG_HOME;
|
|
2133
2156
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2134
2157
|
}
|
|
2135
2158
|
async function readConfig() {
|
|
@@ -2481,9 +2504,8 @@ var boardUsage = `ft board
|
|
|
2481
2504
|
|
|
2482
2505
|
Lists open issues, at most 30 of each kind (--full for all), as available, taken by a session running here, or claimed by a session no session here answers to, from their latest "Taken by session <name>." comment.
|
|
2483
2506
|
A claim shows its boxes left, and one no live session holds also the latest comment that is not a claim.
|
|
2484
|
-
A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs
|
|
2485
|
-
|
|
2486
|
-
Exits 0 when it listed them, 1 when the issues cannot be read, 2 on a usage error.`;
|
|
2507
|
+
A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs.`;
|
|
2508
|
+
var boardExits = [[0, "it listed them"], [1, "the issues cannot be read"], [2, "a usage error"]];
|
|
2487
2509
|
var BOARD_LIMIT = 30;
|
|
2488
2510
|
var boardOptions = {
|
|
2489
2511
|
labels: { type: "string", short: "L", description: "only issues with these labels, comma separated" },
|
|
@@ -2496,7 +2518,7 @@ var boardOptions = {
|
|
|
2496
2518
|
...repoOption
|
|
2497
2519
|
};
|
|
2498
2520
|
async function board(args) {
|
|
2499
|
-
const parsed = parse(args, boardUsage, boardOptions);
|
|
2521
|
+
const parsed = parse(args, boardUsage, boardOptions, { exits: boardExits });
|
|
2500
2522
|
const { values } = parsed;
|
|
2501
2523
|
if (values.watch !== undefined)
|
|
2502
2524
|
return watching(values.watch, async () => board(withoutWatch(args)));
|
|
@@ -2533,9 +2555,8 @@ async function me(as, sessions) {
|
|
|
2533
2555
|
var takeUsage = `ft take <n>...
|
|
2534
2556
|
|
|
2535
2557
|
Claims each issue for this Claude Code session with a "Taken by session <name>." comment.
|
|
2536
|
-
An issue another live session holds is refused, one this session or its lanes hold passes to the new name, and one claimed by a session no session here answers to needs --take-stale; a refusal leaves the other issues taken
|
|
2537
|
-
|
|
2538
|
-
Exits 0 when every issue is taken, 1 when one is refused, 2 on a usage error.`;
|
|
2558
|
+
An issue another live session holds is refused, one this session or its lanes hold passes to the new name, and one claimed by a session no session here answers to needs --take-stale; a refusal leaves the other issues taken.`;
|
|
2559
|
+
var takeExits = [[0, "every issue is taken"], [1, "one is refused"], [2, "a usage error"]];
|
|
2539
2560
|
var laneOption = {
|
|
2540
2561
|
lane: { type: "boolean", description: "claim each as lane-<s>-<n>, <s> ending this session's name, so the claim stays live while it runs" }
|
|
2541
2562
|
};
|
|
@@ -2571,7 +2592,7 @@ async function eachIssue(command, numbers, step) {
|
|
|
2571
2592
|
return code;
|
|
2572
2593
|
}
|
|
2573
2594
|
async function take(args) {
|
|
2574
|
-
const parsed = parse(args, takeUsage, takeOptions);
|
|
2595
|
+
const parsed = parse(args, takeUsage, takeOptions, { exits: takeExits });
|
|
2575
2596
|
const { values, positionals } = parsed;
|
|
2576
2597
|
const numbers = issueNumbers(positionals, takeUsage);
|
|
2577
2598
|
const sessions = await liveSessions();
|
|
@@ -2602,9 +2623,8 @@ async function take(args) {
|
|
|
2602
2623
|
var dropUsage = `ft drop <n>... [--stale] | --all-stale [--dry-run]
|
|
2603
2624
|
|
|
2604
2625
|
Gives each issue back with a "Released by session <name>." comment, when this session holds it.
|
|
2605
|
-
With --stale, a claim no session here answers to is released too, in the name of its holder, followed by a comment saying this session released it as stale; a claim a live session holds is still refused. --all-stale does that for every such claim on the board, and with --dry-run only lists them
|
|
2606
|
-
|
|
2607
|
-
Exits 0 when every issue is given back, 1 when one is not held by this session or, with --stale, by a live one, 2 on a usage error.`;
|
|
2626
|
+
With --stale, a claim no session here answers to is released too, in the name of its holder, followed by a comment saying this session released it as stale; a claim a live session holds is still refused. --all-stale does that for every such claim on the board, and with --dry-run only lists them.`;
|
|
2627
|
+
var dropExits = [[0, "every issue is given back"], [1, "one is not held by this session or, with --stale, by a live one"], [2, "a usage error"]];
|
|
2608
2628
|
var dropOptions = {
|
|
2609
2629
|
as: { type: "string", description: "the name it was taken as, instead of this session's" },
|
|
2610
2630
|
stale: { type: "boolean", description: "also release a claim no live session here answers to" },
|
|
@@ -2625,7 +2645,7 @@ async function releaseStale(number, me, author, sessions, repo) {
|
|
|
2625
2645
|
console.log(good(`released #${number}, held by ${claim.holder}`));
|
|
2626
2646
|
}
|
|
2627
2647
|
async function drop(args) {
|
|
2628
|
-
const parsed = parse(args, dropUsage, dropOptions);
|
|
2648
|
+
const parsed = parse(args, dropUsage, dropOptions, { exits: dropExits });
|
|
2629
2649
|
const { values, positionals } = parsed;
|
|
2630
2650
|
const sessions = await liveSessions();
|
|
2631
2651
|
const nameFor = await claimant(values, sessions);
|
|
@@ -2665,7 +2685,7 @@ async function drop(args) {
|
|
|
2665
2685
|
}
|
|
2666
2686
|
|
|
2667
2687
|
// src/commands/ci.ts
|
|
2668
|
-
import
|
|
2688
|
+
import process24 from "process";
|
|
2669
2689
|
|
|
2670
2690
|
// src/git.ts
|
|
2671
2691
|
async function tagsAt(commit) {
|
|
@@ -2864,8 +2884,8 @@ var usage2 = `ft ci [ref]
|
|
|
2864
2884
|
|
|
2865
2885
|
Waits for the push runs covering a commit on the branch, by default origin's tip, and prints what each failed job's log says.
|
|
2866
2886
|
A push's run tests every commit since the previous push, so a commit whose own run was cancelled, or whose --job was skipped, is covered by the next commit's runs.
|
|
2867
|
-
--json prints {status, runs, failedJobs, url} on stdout, the progress going to stderr; --quiet prints only the announcement, the failures and the result
|
|
2868
|
-
|
|
2887
|
+
--json prints {status, runs, failedJobs, url} on stdout, the progress going to stderr; --quiet prints only the announcement, the failures and the result.`;
|
|
2888
|
+
var EXITS = [[0, "they pass"], [1, "one fails"], [2, "a timeout, a stalled queue or a commit not on the branch"]];
|
|
2869
2889
|
var options = {
|
|
2870
2890
|
branch: { type: "string", short: "b", description: "branch the commit is on, by default the one origin/HEAD names" },
|
|
2871
2891
|
workflow: { type: "string", short: "w", description: "only this workflow file, e.g. test.yml; by default every workflow a push starts" },
|
|
@@ -2895,7 +2915,7 @@ function settled(latest) {
|
|
|
2895
2915
|
return latest !== undefined && latest.every((run) => FINISHED.has(run.status)) && judge(latest, false, false).kind === "runs" ? latest : undefined;
|
|
2896
2916
|
}
|
|
2897
2917
|
async function ci2(args) {
|
|
2898
|
-
const parsed = parse(args, usage2, options);
|
|
2918
|
+
const parsed = parse(args, usage2, options, { exits: EXITS });
|
|
2899
2919
|
const { values, positionals } = parsed;
|
|
2900
2920
|
const branch = values.branch ?? await defaultBranch();
|
|
2901
2921
|
const giveUp = duration(values.timeout, "timeout", 30 * 60000, "m");
|
|
@@ -2931,7 +2951,7 @@ async function ci2(args) {
|
|
|
2931
2951
|
return;
|
|
2932
2952
|
}
|
|
2933
2953
|
const json = values.json === true;
|
|
2934
|
-
const live = takesControlCodes(
|
|
2954
|
+
const live = takesControlCodes(process24.stderr) && takesControlCodes(process24.stdout) && !json && values.quiet !== true;
|
|
2935
2955
|
const runs = await waitForCi({
|
|
2936
2956
|
tool: "ft ci",
|
|
2937
2957
|
short,
|
|
@@ -2957,8 +2977,8 @@ async function ci2(args) {
|
|
|
2957
2977
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
2958
2978
|
},
|
|
2959
2979
|
lines: (spinner, found, started) => [
|
|
2960
|
-
ciHeader(spinner, `CI on ${short}`, started,
|
|
2961
|
-
...(found ?? []).map((run) => ` ${runLine(run,
|
|
2980
|
+
ciHeader(spinner, `CI on ${short}`, started, process24.stderr),
|
|
2981
|
+
...(found ?? []).map((run) => ` ${runLine(run, process24.stderr, undefined, run.commit_sha.slice(0, 7))}`)
|
|
2962
2982
|
]
|
|
2963
2983
|
});
|
|
2964
2984
|
const status = overall(runs);
|
|
@@ -2975,7 +2995,7 @@ async function ci2(args) {
|
|
|
2975
2995
|
}
|
|
2976
2996
|
if (live) {
|
|
2977
2997
|
for (const run of runs)
|
|
2978
|
-
console.log(runLine(run,
|
|
2998
|
+
console.log(runLine(run, process24.stdout, undefined, run.commit_sha.slice(0, 7)));
|
|
2979
2999
|
}
|
|
2980
3000
|
if (status !== "failure") {
|
|
2981
3001
|
if (live)
|
|
@@ -2994,7 +3014,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2994
3014
|
}
|
|
2995
3015
|
|
|
2996
3016
|
// src/commands/digest.ts
|
|
2997
|
-
import
|
|
3017
|
+
import process25 from "process";
|
|
2998
3018
|
var RUNS_SCANNED = 50;
|
|
2999
3019
|
var TITLE_WIDTH2 = 70;
|
|
3000
3020
|
var SHOWN = 8;
|
|
@@ -3044,7 +3064,7 @@ async function quietly(read) {
|
|
|
3044
3064
|
}
|
|
3045
3065
|
}
|
|
3046
3066
|
async function staleTodos() {
|
|
3047
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3067
|
+
const bin = Bun.which("todo-scan", { PATH: process25.env.PATH ?? "" });
|
|
3048
3068
|
if (bin === null)
|
|
3049
3069
|
return [];
|
|
3050
3070
|
let found;
|
|
@@ -3066,8 +3086,8 @@ async function staleTodos() {
|
|
|
3066
3086
|
return [...byIssue.values()];
|
|
3067
3087
|
}
|
|
3068
3088
|
function claimLine(row, now) {
|
|
3069
|
-
const id = role("id",
|
|
3070
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
3089
|
+
const id = role("id", process25.stdout);
|
|
3090
|
+
return [id(`#${row.number}`), row.holder, paint(process25.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
|
|
3071
3091
|
}
|
|
3072
3092
|
function capped2(lines) {
|
|
3073
3093
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3078,13 +3098,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3078
3098
|
`) },
|
|
3079
3099
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3080
3100
|
`) },
|
|
3081
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
3101
|
+
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process25.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
|
|
3082
3102
|
`), TITLE_WIDTH2)}`) },
|
|
3083
3103
|
{ heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
|
|
3084
|
-
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path",
|
|
3104
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process25.stdout)(file.path)}`)) },
|
|
3085
3105
|
{ 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(", ")}`)) }
|
|
3086
3106
|
].filter((each) => each.count > 0);
|
|
3087
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
3107
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process25.stdout, process25.env, tone)}
|
|
3088
3108
|
${lines.join(`
|
|
3089
3109
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3090
3110
|
|
|
@@ -3093,16 +3113,15 @@ ${lines.join(`
|
|
|
3093
3113
|
var usage3 = `ft digest
|
|
3094
3114
|
|
|
3095
3115
|
Summarises the repository for a session starting cold: the issues this session holds with their boxes left, the claims no live session here answers to, red or running CI on the default branch, unpushed commits, dirty files and TODO comments naming a closed issue.
|
|
3096
|
-
A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH
|
|
3097
|
-
|
|
3098
|
-
Exits 0 when it summarised the repository, 1 when Forgejo cannot be read, 2 on a usage error.`;
|
|
3116
|
+
A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH.`;
|
|
3117
|
+
var EXITS2 = [[0, "it summarised the repository"], [1, "Forgejo cannot be read"], [2, "a usage error"]];
|
|
3099
3118
|
var options2 = {
|
|
3100
3119
|
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)"),
|
|
3101
3120
|
watch: watchOption("the digest"),
|
|
3102
3121
|
...repoOption
|
|
3103
3122
|
};
|
|
3104
3123
|
async function digest(args) {
|
|
3105
|
-
const parsed = parse(args, usage3, options2);
|
|
3124
|
+
const parsed = parse(args, usage3, options2, { exits: EXITS2 });
|
|
3106
3125
|
const { values } = parsed;
|
|
3107
3126
|
if (values.watch !== undefined)
|
|
3108
3127
|
return watching(values.watch, async () => digest(withoutWatch(args)));
|
|
@@ -3171,9 +3190,8 @@ var tickUsage = `ft tick [<n>] <box>...
|
|
|
3171
3190
|
Ticks checklist boxes of issue <n>, each given by its number from \`ft issue\` or by text matching exactly one box, then posts the -m or -F comment.
|
|
3172
3191
|
With --closed, ticks instead every box opening with \`#<issue>\` whose issue is closed, as a release plan lists them.
|
|
3173
3192
|
|
|
3174
|
-
Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it
|
|
3175
|
-
|
|
3176
|
-
Exits 0 when it ticked the boxes, 1 when Forgejo refuses, 2 on a usage error or a box matching none or several.`;
|
|
3193
|
+
Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.`;
|
|
3194
|
+
var tickExits = [[0, "it ticked the boxes"], [1, "Forgejo refuses"], [2, "a usage error or a box matching none or several"]];
|
|
3177
3195
|
var tickOptions = {
|
|
3178
3196
|
undo: { type: "boolean", short: "u", description: "untick them instead" },
|
|
3179
3197
|
closed: { type: "boolean", description: "tick the boxes listing a closed issue, no box to name" },
|
|
@@ -3188,7 +3206,7 @@ function tickedOrFail(number, run) {
|
|
|
3188
3206
|
}
|
|
3189
3207
|
}
|
|
3190
3208
|
async function tick(args) {
|
|
3191
|
-
const parsed = parse(args, tickUsage, tickOptions);
|
|
3209
|
+
const parsed = parse(args, tickUsage, tickOptions, { exits: tickExits });
|
|
3192
3210
|
const { values, positionals } = parsed;
|
|
3193
3211
|
const { number, rest: picks } = await targetIssue(positionals, values.repo, tickUsage);
|
|
3194
3212
|
if (values.closed === true && (picks.length > 0 || values.undo === true))
|
|
@@ -3225,9 +3243,8 @@ var fixedUsage = `ft fixed [<n>] [commit]...
|
|
|
3225
3243
|
|
|
3226
3244
|
Comments "Fixed in <sha>: <message>" on issue <n> and closes it, naming each commit given as "Fixed in <a>, <b> and <c>".
|
|
3227
3245
|
Without a commit it takes those on origin's default branch whose message names #<n>, and says which, or HEAD when none does.
|
|
3228
|
-
Without <n> it takes the one open issue this session holds (\`ft take\`). The message defaults to the subject of the first commit. Every open issue listing \`- [ ] #<n>\` in its checklist gets that line ticked. An issue with boxes left is refused, as a partly done issue stays open, unless --tick ticks them first
|
|
3229
|
-
|
|
3230
|
-
Exits 0 when it closed the issue, 1 when the issue is already closed, has boxes left or Forgejo refuses, 2 on a usage error.`;
|
|
3246
|
+
Without <n> it takes the one open issue this session holds (\`ft take\`). The message defaults to the subject of the first commit. Every open issue listing \`- [ ] #<n>\` in its checklist gets that line ticked. An issue with boxes left is refused, as a partly done issue stays open, unless --tick ticks them first.`;
|
|
3247
|
+
var fixedExits = [[0, "it closed the issue"], [1, "the issue is already closed, has boxes left or Forgejo refuses"], [2, "a usage error"]];
|
|
3231
3248
|
var fixedOptions = {
|
|
3232
3249
|
message: { type: "string", short: "m", description: 'the line after "Fixed in <sha>:"' },
|
|
3233
3250
|
tick: { type: "boolean", description: "tick the boxes left before closing" },
|
|
@@ -3268,7 +3285,7 @@ async function tickListings(closed, repo) {
|
|
|
3268
3285
|
}
|
|
3269
3286
|
}
|
|
3270
3287
|
async function fixed(args) {
|
|
3271
|
-
const parsed = parse(args, fixedUsage, fixedOptions);
|
|
3288
|
+
const parsed = parse(args, fixedUsage, fixedOptions, { exits: fixedExits });
|
|
3272
3289
|
const { values, positionals } = parsed;
|
|
3273
3290
|
const { number, rest } = await targetIssue(positionals, values.repo, fixedUsage);
|
|
3274
3291
|
const commits = await fixingCommits(number, rest);
|
|
@@ -3306,8 +3323,8 @@ var stateOptions = {
|
|
|
3306
3323
|
message: { type: "string", short: "m", description: "a comment posted first, saying why" },
|
|
3307
3324
|
...repoOption
|
|
3308
3325
|
};
|
|
3309
|
-
async function setState(args, usage, wanted) {
|
|
3310
|
-
const parsed = parse(args, usage, stateOptions);
|
|
3326
|
+
async function setState(args, usage, exits, wanted) {
|
|
3327
|
+
const parsed = parse(args, usage, stateOptions, { exits });
|
|
3311
3328
|
const { values, positionals } = parsed;
|
|
3312
3329
|
for (const number of issueNumbers(positionals, usage)) {
|
|
3313
3330
|
if ((await getIssue(number, values.repo)).state === wanted) {
|
|
@@ -3326,19 +3343,17 @@ async function setState(args, usage, wanted) {
|
|
|
3326
3343
|
}
|
|
3327
3344
|
var closeUsage = `ft close <n>... [-m <reason>]
|
|
3328
3345
|
|
|
3329
|
-
Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed
|
|
3330
|
-
|
|
3331
|
-
Exits 0 when every issue is closed, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3346
|
+
Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed.`;
|
|
3347
|
+
var closeExits = [[0, "every issue is closed"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3332
3348
|
async function closeIssues(args) {
|
|
3333
|
-
return setState(args, closeUsage, "closed");
|
|
3349
|
+
return setState(args, closeUsage, closeExits, "closed");
|
|
3334
3350
|
}
|
|
3335
3351
|
var reopenUsage = `ft reopen <n>... [-m <reason>]
|
|
3336
3352
|
|
|
3337
|
-
Reopens closed issues, posting the -m reason first
|
|
3338
|
-
|
|
3339
|
-
Exits 0 when every issue is open, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3353
|
+
Reopens closed issues, posting the -m reason first.`;
|
|
3354
|
+
var reopenExits = [[0, "every issue is open"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3340
3355
|
async function reopenIssues(args) {
|
|
3341
|
-
return setState(args, reopenUsage, "open");
|
|
3356
|
+
return setState(args, reopenUsage, reopenExits, "open");
|
|
3342
3357
|
}
|
|
3343
3358
|
var LABEL_FLAGS = new Set(["-h", "--help"]);
|
|
3344
3359
|
var REPO_FLAGS = new Set(["-r", "--repo"]);
|
|
@@ -3361,12 +3376,11 @@ function labelChanges(args) {
|
|
|
3361
3376
|
}
|
|
3362
3377
|
var labelUsage = `ft label <n> [+]<label>... -<label>...
|
|
3363
3378
|
|
|
3364
|
-
Adds the labels named bare or with +, removes those named with -, then prints the issue's labels. A label the repository lacks is refused
|
|
3365
|
-
|
|
3366
|
-
Exits 0 when it changed the labels, 1 when Forgejo refuses, 2 on a usage error or a label the repository lacks.`;
|
|
3379
|
+
Adds the labels named bare or with +, removes those named with -, then prints the issue's labels. A label the repository lacks is refused.`;
|
|
3380
|
+
var labelExits = [[0, "it changed the labels"], [1, "Forgejo refuses"], [2, "a usage error or a label the repository lacks"]];
|
|
3367
3381
|
async function label(args) {
|
|
3368
3382
|
const changes = labelChanges(args);
|
|
3369
|
-
const parsed = parse(changes.rest, labelUsage, repoOption);
|
|
3383
|
+
const parsed = parse(changes.rest, labelUsage, repoOption, { exits: labelExits });
|
|
3370
3384
|
const { values, positionals } = parsed;
|
|
3371
3385
|
const number = issueNumber(positionals[0], labelUsage);
|
|
3372
3386
|
const add = [...positionals.slice(1), ...changes.add];
|
|
@@ -3388,9 +3402,8 @@ ${labelUsage}`);
|
|
|
3388
3402
|
// src/commands/issue-write.ts
|
|
3389
3403
|
var newUsage = `ft new -t <title> [-F <file>] [-L a,b] [-m <milestone>]
|
|
3390
3404
|
|
|
3391
|
-
Creates an issue and prints its number and url. The description is read from -F <file>, or from stdin with -F -, and is empty without it. A label or milestone the repository lacks is refused before anything is created
|
|
3392
|
-
|
|
3393
|
-
Exits 0 when it created the issue, 1 when Forgejo refuses, 2 on a usage error or a label or milestone the repository lacks.`;
|
|
3405
|
+
Creates an issue and prints its number and url. The description is read from -F <file>, or from stdin with -F -, and is empty without it. A label or milestone the repository lacks is refused before anything is created.`;
|
|
3406
|
+
var newExits = [[0, "it created the issue"], [1, "Forgejo refuses"], [2, "a usage error or a label or milestone the repository lacks"]];
|
|
3394
3407
|
var newOptions = {
|
|
3395
3408
|
title: { type: "string", short: "t", description: "the issue title" },
|
|
3396
3409
|
file: { type: "string", short: "F", description: "the description: a file, - for stdin" },
|
|
@@ -3404,7 +3417,7 @@ async function milestoneTitle(reference, repo) {
|
|
|
3404
3417
|
return reference.trim() === "" ? "" : (await findMilestone(reference.trim(), repo)).title;
|
|
3405
3418
|
}
|
|
3406
3419
|
async function newIssue(args) {
|
|
3407
|
-
const parsed = parse(args, newUsage, newOptions);
|
|
3420
|
+
const parsed = parse(args, newUsage, newOptions, { exits: newExits });
|
|
3408
3421
|
const { values } = parsed;
|
|
3409
3422
|
if (values.title === undefined || values.title.trim() === "")
|
|
3410
3423
|
fail(`give the issue a title with -t
|
|
@@ -3422,9 +3435,8 @@ var editUsage = `ft edit <n> [-t <title>] [-F <file> [--append]] [--add-box <tex
|
|
|
3422
3435
|
Replaces the title and/or the description of issue <n>, the description from -F <file> or from stdin with -F -.
|
|
3423
3436
|
-m moves it to a milestone given by title or id, and \`-m ''\` takes it out of its milestone.
|
|
3424
3437
|
--append adds the -F text after the description instead, and each --add-box an unticked box after the last one, the rest of the description untouched.
|
|
3425
|
-
\`ft issue <n> --body\` prints the description to edit
|
|
3426
|
-
|
|
3427
|
-
Exits 0 when it edited the issue, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3438
|
+
\`ft issue <n> --body\` prints the description to edit.`;
|
|
3439
|
+
var editExits = [[0, "it edited the issue"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3428
3440
|
var editOptions = {
|
|
3429
3441
|
title: { type: "string", short: "t", description: "the new title" },
|
|
3430
3442
|
file: { type: "string", short: "F", description: "the new description: a file, - for stdin" },
|
|
@@ -3434,7 +3446,7 @@ var editOptions = {
|
|
|
3434
3446
|
...repoOption
|
|
3435
3447
|
};
|
|
3436
3448
|
async function edit(args) {
|
|
3437
|
-
const parsed = parse(args, editUsage, editOptions);
|
|
3449
|
+
const parsed = parse(args, editUsage, editOptions, { exits: editExits });
|
|
3438
3450
|
const { values, positionals } = parsed;
|
|
3439
3451
|
const number = issueNumber(positionals[0], editUsage);
|
|
3440
3452
|
const text = await noteText({ file: values.file });
|
|
@@ -3472,15 +3484,14 @@ ${text}` : body;
|
|
|
3472
3484
|
var commentUsage = `ft comment [<n>] [text]
|
|
3473
3485
|
|
|
3474
3486
|
Posts a comment on issue <n>: the text given, -F <file>, or stdin when neither is, so a heredoc needs no escaping.
|
|
3475
|
-
Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it
|
|
3476
|
-
|
|
3477
|
-
Exits 0 when it posted the comment, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3487
|
+
Without <n> (a first argument that is not a number) it takes the one open issue this session holds (\`ft take\`), and exits 2 when it holds none or several, saying which issue it used. A first argument that is a number is always the issue, so boxes named by number need it.`;
|
|
3488
|
+
var commentExits = [[0, "it posted the comment"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3478
3489
|
var commentOptions = {
|
|
3479
3490
|
file: noteOptions.file,
|
|
3480
3491
|
...repoOption
|
|
3481
3492
|
};
|
|
3482
3493
|
async function commentOn(args) {
|
|
3483
|
-
const parsed = parse(args, commentUsage, commentOptions);
|
|
3494
|
+
const parsed = parse(args, commentUsage, commentOptions, { exits: commentExits });
|
|
3484
3495
|
const { values, positionals } = parsed;
|
|
3485
3496
|
const { number, rest } = await targetIssue(positionals, values.repo, commentUsage);
|
|
3486
3497
|
const given = rest.join(" ") || undefined;
|
|
@@ -3499,9 +3510,8 @@ var issueUsage = `ft issue [<n>...]
|
|
|
3499
3510
|
|
|
3500
3511
|
Prints each issue: its title, state, boxes left and claim, then its description with each checklist box numbered as \`ft tick\` takes it. --open also opens each in the browser.
|
|
3501
3512
|
With --body, prints only the raw description, to edit and give back to \`ft edit -F\`.
|
|
3502
|
-
With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none
|
|
3503
|
-
|
|
3504
|
-
Exits 0 when it printed them, 1 when an issue cannot be read, 2 on a usage error.`;
|
|
3513
|
+
With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none.`;
|
|
3514
|
+
var issueExits = [[0, "it printed them"], [1, "an issue cannot be read"], [2, "a usage error"]];
|
|
3505
3515
|
var issueOptions = {
|
|
3506
3516
|
todo: { type: "boolean", short: "t", description: "only the header and the boxes left to tick" },
|
|
3507
3517
|
comments: { type: "boolean", short: "c", description: "add the comments, each with its author and age" },
|
|
@@ -3554,7 +3564,7 @@ function issueJson(found, comments, author) {
|
|
|
3554
3564
|
};
|
|
3555
3565
|
}
|
|
3556
3566
|
async function issue(args) {
|
|
3557
|
-
const parsed = parse(args, issueUsage, issueOptions);
|
|
3567
|
+
const parsed = parse(args, issueUsage, issueOptions, { exits: issueExits });
|
|
3558
3568
|
const { values, positionals } = parsed;
|
|
3559
3569
|
const held = positionals.length === 0 ? await heldIssues(values.repo) : [];
|
|
3560
3570
|
const numbers = held.length === 0 ? issueNumbers(positionals, issueUsage) : held;
|
|
@@ -3600,9 +3610,8 @@ async function issue(args) {
|
|
|
3600
3610
|
var usage4 = `ft logs <run id>
|
|
3601
3611
|
|
|
3602
3612
|
Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step.
|
|
3603
|
-
With no failed job it prints every job's last lines; --full prints whole logs
|
|
3604
|
-
|
|
3605
|
-
Exits 0 when it printed the logs, 1 when Forgejo cannot be read, 2 on a usage error or a job the run lacks.`;
|
|
3613
|
+
With no failed job it prints every job's last lines; --full prints whole logs.`;
|
|
3614
|
+
var EXITS3 = [[0, "it printed the logs"], [1, "Forgejo cannot be read"], [2, "a usage error or a job the run lacks"]];
|
|
3606
3615
|
var options3 = {
|
|
3607
3616
|
job: { type: "string", short: "j", description: "only this job, by name or id" },
|
|
3608
3617
|
full: { type: "boolean", short: "f", description: "the whole log, timestamps stripped" },
|
|
@@ -3616,7 +3625,7 @@ function pickJobs(jobs, wanted) {
|
|
|
3616
3625
|
return failed.length > 0 ? failed : jobs;
|
|
3617
3626
|
}
|
|
3618
3627
|
async function logs2(args) {
|
|
3619
|
-
const parsed = parse(args, usage4, options3);
|
|
3628
|
+
const parsed = parse(args, usage4, options3, { exits: EXITS3 });
|
|
3620
3629
|
const { values, positionals } = parsed;
|
|
3621
3630
|
if (positionals[0] === undefined)
|
|
3622
3631
|
fail("a run id is needed", 2, runHint("ft runs", "list them"));
|
|
@@ -3647,7 +3656,7 @@ ${await text(job)}`);
|
|
|
3647
3656
|
}
|
|
3648
3657
|
|
|
3649
3658
|
// src/commands/milestone.ts
|
|
3650
|
-
import
|
|
3659
|
+
import process26 from "process";
|
|
3651
3660
|
var TITLE_WIDTH3 = 60;
|
|
3652
3661
|
var LIST_LIMIT = 30;
|
|
3653
3662
|
var CONCURRENCY2 = 4;
|
|
@@ -3656,15 +3665,15 @@ function counts(milestone) {
|
|
|
3656
3665
|
}
|
|
3657
3666
|
function progressBar(milestone) {
|
|
3658
3667
|
const total = milestone.open_issues + milestone.closed_issues;
|
|
3659
|
-
return takesControlCodes(
|
|
3668
|
+
return takesControlCodes(process26.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
3660
3669
|
}
|
|
3661
3670
|
function milestoneCells(each, showState) {
|
|
3662
3671
|
const drawn = progressBar(each);
|
|
3663
3672
|
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] : []];
|
|
3664
3673
|
}
|
|
3665
3674
|
async function printWithIssues(list, repo) {
|
|
3666
|
-
const colors = paint(
|
|
3667
|
-
const id = role("id",
|
|
3675
|
+
const colors = paint(process26.stdout);
|
|
3676
|
+
const id = role("id", process26.stdout);
|
|
3668
3677
|
const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
3669
3678
|
const blocks = list.map((each, index) => {
|
|
3670
3679
|
const byNumber = (left, right) => left.number - right.number;
|
|
@@ -3675,7 +3684,7 @@ async function printWithIssues(list, repo) {
|
|
|
3675
3684
|
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
3676
3685
|
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
3677
3686
|
];
|
|
3678
|
-
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined,
|
|
3687
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process26.stdout, process26.env, "accent"), ...lines].join(`
|
|
3679
3688
|
`);
|
|
3680
3689
|
});
|
|
3681
3690
|
console.log(blocks.join(`
|
|
@@ -3684,9 +3693,8 @@ async function printWithIssues(list, repo) {
|
|
|
3684
3693
|
}
|
|
3685
3694
|
var listUsage = `ft milestones
|
|
3686
3695
|
|
|
3687
|
-
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
|
|
3688
|
-
|
|
3689
|
-
Exits 0 when it listed them, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3696
|
+
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.`;
|
|
3697
|
+
var listExits = [[0, "it listed them"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3690
3698
|
var listOptions = {
|
|
3691
3699
|
state: { type: "string", description: "open (the default), closed or all" },
|
|
3692
3700
|
issues: { type: "boolean", short: "i", description: "list the open and closed issues of each milestone by title" },
|
|
@@ -3695,7 +3703,7 @@ var listOptions = {
|
|
|
3695
3703
|
...repoOption
|
|
3696
3704
|
};
|
|
3697
3705
|
async function milestones(args) {
|
|
3698
|
-
const parsed = parse(args, listUsage, listOptions);
|
|
3706
|
+
const parsed = parse(args, listUsage, listOptions, { exits: listExits });
|
|
3699
3707
|
const { values } = parsed;
|
|
3700
3708
|
const state = values.state ?? "open";
|
|
3701
3709
|
if (state !== "open" && state !== "closed" && state !== "all")
|
|
@@ -3723,16 +3731,15 @@ async function milestones(args) {
|
|
|
3723
3731
|
}
|
|
3724
3732
|
var newUsage2 = `ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
|
|
3725
3733
|
|
|
3726
|
-
Creates a milestone through the API and prints its id. Without --due it has no due date
|
|
3727
|
-
|
|
3728
|
-
Exits 0 when it created the milestone, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3734
|
+
Creates a milestone through the API and prints its id. Without --due it has no due date.`;
|
|
3735
|
+
var newExits2 = [[0, "it created the milestone"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3729
3736
|
var newOptions2 = {
|
|
3730
3737
|
description: { type: "string", short: "d", description: "the milestone description" },
|
|
3731
3738
|
due: { type: "string", description: "the due date, YYYY-MM-DD" },
|
|
3732
3739
|
...repoOption
|
|
3733
3740
|
};
|
|
3734
3741
|
async function create(args) {
|
|
3735
|
-
const parsed = parse(args, newUsage2, newOptions2);
|
|
3742
|
+
const parsed = parse(args, newUsage2, newOptions2, { exits: newExits2 });
|
|
3736
3743
|
const { values, positionals } = parsed;
|
|
3737
3744
|
const title = positionals.join(" ").trim();
|
|
3738
3745
|
if (title === "")
|
|
@@ -3746,15 +3753,14 @@ ${newUsage2}`);
|
|
|
3746
3753
|
}
|
|
3747
3754
|
var closeUsage2 = `ft milestone close <title|id> [--force]
|
|
3748
3755
|
|
|
3749
|
-
Closes a milestone, refused while issues are open in it, which it names. --force closes it with them left
|
|
3750
|
-
|
|
3751
|
-
Exits 0 when it closed the milestone, 1 when issues are open in it or Forgejo refuses, 2 on a usage error.`;
|
|
3756
|
+
Closes a milestone, refused while issues are open in it, which it names. --force closes it with them left.`;
|
|
3757
|
+
var closeExits2 = [[0, "it closed the milestone"], [1, "issues are open in it or Forgejo refuses"], [2, "a usage error"]];
|
|
3752
3758
|
var closeOptions = {
|
|
3753
3759
|
force: { type: "boolean", description: "close it with issues left open" },
|
|
3754
3760
|
...repoOption
|
|
3755
3761
|
};
|
|
3756
3762
|
async function closeOne(args) {
|
|
3757
|
-
const parsed = parse(args, closeUsage2, closeOptions);
|
|
3763
|
+
const parsed = parse(args, closeUsage2, closeOptions, { exits: closeExits2 });
|
|
3758
3764
|
const { values, positionals } = parsed;
|
|
3759
3765
|
const reference = positionals.join(" ").trim();
|
|
3760
3766
|
if (reference === "")
|
|
@@ -3780,16 +3786,15 @@ ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
|
|
|
3780
3786
|
ft milestone close <title|id> [--force]
|
|
3781
3787
|
|
|
3782
3788
|
Shows a milestone with its open issues as \`ft board\` does: available, taken by a session running here, or claimed by one gone, each with its boxes left, at most 30 of each kind (--full for all).
|
|
3783
|
-
\`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id
|
|
3784
|
-
|
|
3785
|
-
Exits 0 when it showed the milestone, 1 when it cannot be read, 2 on a usage error or an unknown milestone.`;
|
|
3789
|
+
\`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id.`;
|
|
3790
|
+
var showExits = [[0, "it showed the milestone"], [1, "it cannot be read"], [2, "a usage error or an unknown milestone"]];
|
|
3786
3791
|
var showOptions = {
|
|
3787
3792
|
...limitOptions(LIST_LIMIT),
|
|
3788
3793
|
json: jsonOption("the milestone (id, title, state, description, open, closed, due) and its open issues as `ft board --json` lists them"),
|
|
3789
3794
|
...repoOption
|
|
3790
3795
|
};
|
|
3791
3796
|
async function show(args) {
|
|
3792
|
-
const parsed = parse(args, showUsage, showOptions);
|
|
3797
|
+
const parsed = parse(args, showUsage, showOptions, { exits: showExits });
|
|
3793
3798
|
const { values, positionals } = parsed;
|
|
3794
3799
|
const reference = positionals.join(" ").trim();
|
|
3795
3800
|
if (reference === "")
|
|
@@ -3876,16 +3881,14 @@ var addUsage = `ft plan add <plan> <n>... [--section "Bugs:"]
|
|
|
3876
3881
|
|
|
3877
3882
|
Lists each issue <n> as \`- [ ] #<n> <title>\` in the checklist of issue <plan>, skipping those already listed.
|
|
3878
3883
|
Lines go under --section, created at the end of the body when missing, or else after the checklist's last box.
|
|
3879
|
-
The body is read again just before it is written, so an edit made meanwhile is kept
|
|
3880
|
-
|
|
3881
|
-
Exits 0 when it listed the issues, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3884
|
+
The body is read again just before it is written, so an edit made meanwhile is kept.`;
|
|
3885
|
+
var addExits = [[0, "it listed the issues"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3882
3886
|
var carryUsage = `ft plan carry <from> <to> [--section "Carried from 1.71.0:"]
|
|
3883
3887
|
|
|
3884
3888
|
Copies the unticked \`#<n>\` lines of issue <from> into issue <to>, skipping those <to> already lists.
|
|
3885
3889
|
Lines go under --section, created at the end of the body when missing, or else after the checklist's last box.
|
|
3886
|
-
The body is read again just before it is written, so an edit made meanwhile is kept
|
|
3887
|
-
|
|
3888
|
-
Exits 0 when it copied the lines, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3890
|
+
The body is read again just before it is written, so an edit made meanwhile is kept.`;
|
|
3891
|
+
var carryExits = [[0, "it copied the lines"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3889
3892
|
var options4 = {
|
|
3890
3893
|
section: { type: "string", short: "s", description: 'the heading the lines go under, e.g. "Bugs:"' },
|
|
3891
3894
|
...repoOption
|
|
@@ -3898,7 +3901,7 @@ var plan = {
|
|
|
3898
3901
|
}
|
|
3899
3902
|
};
|
|
3900
3903
|
async function add(args) {
|
|
3901
|
-
const parsed = parse(args, addUsage, options4);
|
|
3904
|
+
const parsed = parse(args, addUsage, options4, { exits: addExits });
|
|
3902
3905
|
const { section, repo } = parsed.values;
|
|
3903
3906
|
const [target, ...listed] = parsed.positionals;
|
|
3904
3907
|
const planNumber = issueNumber(target, addUsage);
|
|
@@ -3919,7 +3922,7 @@ ${addUsage}`);
|
|
|
3919
3922
|
return 0;
|
|
3920
3923
|
}
|
|
3921
3924
|
async function carry(args) {
|
|
3922
|
-
const parsed = parse(args, carryUsage, options4);
|
|
3925
|
+
const parsed = parse(args, carryUsage, options4, { exits: carryExits });
|
|
3923
3926
|
const { section, repo } = parsed.values;
|
|
3924
3927
|
const from = issueNumber(parsed.positionals[0], carryUsage);
|
|
3925
3928
|
const to = issueNumber(parsed.positionals[1], carryUsage);
|
|
@@ -3941,15 +3944,15 @@ function report2(plan, added, skipped) {
|
|
|
3941
3944
|
|
|
3942
3945
|
// src/commands/release.ts
|
|
3943
3946
|
import { basename as basename3, join as join11 } from "path";
|
|
3944
|
-
import
|
|
3947
|
+
import process28 from "process";
|
|
3945
3948
|
var {$: $2 } = globalThis.Bun;
|
|
3946
3949
|
|
|
3947
3950
|
// src/commands/watch.ts
|
|
3948
3951
|
var usage5 = `ft watch [--after <id>]
|
|
3949
3952
|
|
|
3950
3953
|
Waits for runs to finish: those newer than run <id>, or else the ones in progress now.
|
|
3951
|
-
Prints nothing but failures and each run's final status with --quiet, and a JSON result with --json
|
|
3952
|
-
|
|
3954
|
+
Prints nothing but failures and each run's final status with --quiet, and a JSON result with --json.`;
|
|
3955
|
+
var EXITS4 = [[0, "every one passed or was skipped"], [1, "one failed or was cancelled"], [2, "a timeout or a stalled queue"]];
|
|
3953
3956
|
var options5 = {
|
|
3954
3957
|
after: { type: "string", short: "a", description: "watch the runs newer than this run id, as `ft runs --json` gives it" },
|
|
3955
3958
|
timeout: { type: "string", short: "t", description: "how long before giving up (15m), a bare number in minutes" },
|
|
@@ -4053,7 +4056,7 @@ ${run.html_url}`);
|
|
|
4053
4056
|
}
|
|
4054
4057
|
}
|
|
4055
4058
|
async function watch2(args) {
|
|
4056
|
-
const parsed = parse(args, usage5, options5);
|
|
4059
|
+
const parsed = parse(args, usage5, options5, { exits: EXITS4 });
|
|
4057
4060
|
const { values } = parsed;
|
|
4058
4061
|
const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
|
|
4059
4062
|
const json = values.json === true;
|
|
@@ -4179,12 +4182,12 @@ async function publishable() {
|
|
|
4179
4182
|
|
|
4180
4183
|
// src/commands/release-plan.ts
|
|
4181
4184
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4182
|
-
import
|
|
4185
|
+
import process27 from "process";
|
|
4183
4186
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4184
4187
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4185
4188
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4186
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4187
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4189
|
+
const name = pkg?.name ?? basename2(dir ?? process27.cwd());
|
|
4190
|
+
const where = dir === undefined ? "" : ` in ${relative(process27.cwd(), dir) || "."}`;
|
|
4188
4191
|
let version;
|
|
4189
4192
|
let bump;
|
|
4190
4193
|
if (level === undefined) {
|
|
@@ -4223,12 +4226,12 @@ async function printPlan({ releases, branch, base, timeout, registry }) {
|
|
|
4223
4226
|
}
|
|
4224
4227
|
|
|
4225
4228
|
// src/commands/release-steps.ts
|
|
4226
|
-
import { join as join10, relative as relative2, resolve as
|
|
4229
|
+
import { join as join10, relative as relative2, resolve as resolve5 } from "path";
|
|
4227
4230
|
var {$ } = globalThis.Bun;
|
|
4228
4231
|
var registryWait = { tries: 12, poll: 5000 };
|
|
4229
4232
|
var REGISTRY_INFO_MS = 30000;
|
|
4230
4233
|
async function packageDir(value) {
|
|
4231
|
-
for (const dir of [
|
|
4234
|
+
for (const dir of [resolve5(value), join10(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
|
|
4232
4235
|
if (await Bun.file(join10(dir, "package.json")).exists())
|
|
4233
4236
|
return dir;
|
|
4234
4237
|
}
|
|
@@ -4314,8 +4317,8 @@ Cuts a release from the default branch: first the commit it sits on is pushed an
|
|
|
4314
4317
|
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.
|
|
4315
4318
|
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.
|
|
4316
4319
|
--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.
|
|
4317
|
-
--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
|
|
4318
|
-
|
|
4320
|
+
--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.`;
|
|
4321
|
+
var EXITS5 = [[0, "released or planned"], [1, "a run fails, origin refuses a push or the registry never serves the version"], [2, "a timeout, a stalled queue, a refusal before anything ran (another branch, uncommitted changes, origin ahead) or a usage error"]];
|
|
4319
4322
|
var options6 = {
|
|
4320
4323
|
tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
|
|
4321
4324
|
package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/, several separated by commas" },
|
|
@@ -4326,7 +4329,7 @@ var options6 = {
|
|
|
4326
4329
|
json: jsonOption("what was released and how its runs ended")
|
|
4327
4330
|
};
|
|
4328
4331
|
async function release(args) {
|
|
4329
|
-
const parsed = parse(args, usage6, options6);
|
|
4332
|
+
const parsed = parse(args, usage6, options6, { exits: EXITS5 });
|
|
4330
4333
|
const { values, positionals } = parsed;
|
|
4331
4334
|
const json = values.json === true;
|
|
4332
4335
|
const say = json ? console.error : console.log;
|
|
@@ -4429,7 +4432,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4429
4432
|
if (late !== undefined)
|
|
4430
4433
|
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
4434
|
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 ?
|
|
4435
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process28.stderr : process28.stdout, { json });
|
|
4433
4436
|
if (followed.code !== 0) {
|
|
4434
4437
|
report();
|
|
4435
4438
|
return followed.code;
|
|
@@ -4464,9 +4467,8 @@ var usage7 = `ft remote [--fix]
|
|
|
4464
4467
|
|
|
4465
4468
|
Checks that origin's URLs name the Forgejo host itself: tea only finds the repository when origin's host is the login's ssh_host, never through an ssh alias such as \`forgejo\` or \`gitea\`.
|
|
4466
4469
|
--fix switches every alias URL to \`git@<host>:<owner>/<repo>.git\` and proves it with \`git ls-remote\`.
|
|
4467
|
-
The host comes from --host, else \`remoteHost\` in ~/.config/kaynooo-cli/ft.json; with neither, it checks nothing
|
|
4468
|
-
|
|
4469
|
-
Exits 0 when origin names the Forgejo host (or was switched) or no host is set, 1 when it does not or a switch is still to run, 2 on a usage error.`;
|
|
4470
|
+
The host comes from --host, else \`remoteHost\` in ~/.config/kaynooo-cli/ft.json; with neither, it checks nothing.`;
|
|
4471
|
+
var EXITS6 = [[0, "origin names the Forgejo host (or was switched) or no host is set"], [1, "it does not or a switch is still to run"], [2, "a usage error"]];
|
|
4470
4472
|
var options7 = {
|
|
4471
4473
|
host: { type: "string", description: "the Forgejo ssh host, instead of remoteHost in ~/.config/kaynooo-cli/ft.json" },
|
|
4472
4474
|
fix: { type: "boolean", description: "rewrite the alias URLs" }
|
|
@@ -4500,7 +4502,7 @@ function originHost2(url) {
|
|
|
4500
4502
|
return parseSshRemote(url)?.host ?? (URL.canParse(url) ? new URL(url).hostname : undefined);
|
|
4501
4503
|
}
|
|
4502
4504
|
async function remote(args, home) {
|
|
4503
|
-
const { values } = parse(args, usage7, options7);
|
|
4505
|
+
const { values } = parse(args, usage7, options7, { exits: EXITS6 });
|
|
4504
4506
|
const host = values.host ?? (await loadSettings(home)).remoteHost;
|
|
4505
4507
|
if (host === undefined) {
|
|
4506
4508
|
note(`no Forgejo host to check origin against: pass --host, or set "remoteHost" in ${settingsPath(home)}`);
|
|
@@ -4560,9 +4562,8 @@ var usage8 = `ft runs [--sha <ref>]
|
|
|
4560
4562
|
|
|
4561
4563
|
Lists recent runs with what tea's own listing leaves empty: workflow, ref, duration and age, ten by default with the count of the rest (--full for all of them; --json is never cut unless --limit is given).
|
|
4562
4564
|
|
|
4563
|
-
--open also opens the newest run listed in the browser
|
|
4564
|
-
|
|
4565
|
-
Exits 0 when it listed them, 1 when Forgejo or git cannot be read, 2 on a usage error.`;
|
|
4565
|
+
--open also opens the newest run listed in the browser.`;
|
|
4566
|
+
var EXITS7 = [[0, "it listed them"], [1, "Forgejo or git cannot be read"], [2, "a usage error"]];
|
|
4566
4567
|
var DEFAULT_LIMIT = 10;
|
|
4567
4568
|
var options8 = {
|
|
4568
4569
|
...limitOptions(DEFAULT_LIMIT),
|
|
@@ -4578,7 +4579,7 @@ async function onCommit(sha, repo) {
|
|
|
4578
4579
|
return { runs: found, total: found.length };
|
|
4579
4580
|
}
|
|
4580
4581
|
async function runs(args) {
|
|
4581
|
-
const parsed = parse(args, usage8, options8);
|
|
4582
|
+
const parsed = parse(args, usage8, options8, { exits: EXITS7 });
|
|
4582
4583
|
const { values } = parsed;
|
|
4583
4584
|
const limit = limitOf(values, DEFAULT_LIMIT);
|
|
4584
4585
|
const { runs: found, total } = values.sha === undefined ? await runsListing(limit, values.repo, values.workflow) : await onCommit(values.sha, values.repo);
|
|
@@ -4606,7 +4607,7 @@ async function runs(args) {
|
|
|
4606
4607
|
}
|
|
4607
4608
|
|
|
4608
4609
|
// src/cli.ts
|
|
4609
|
-
|
|
4610
|
+
process29.exitCode = await runCli({
|
|
4610
4611
|
name: "ft",
|
|
4611
4612
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4612
4613
|
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.29.1",
|
|
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",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"@kaynooo/utils": "3.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@kaynooo/cli-kit": "0.
|
|
34
|
+
"@kaynooo/cli-kit": "0.38.2"
|
|
35
35
|
}
|
|
36
36
|
}
|