@kaynooo/cli-forgejo 0.29.0 → 0.30.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/README.md +1 -1
- package/dist/cli.js +475 -237
- 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 process31 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -568,24 +568,20 @@ function formatPercent(ratio, digits = 0) {
|
|
|
568
568
|
|
|
569
569
|
// ../kit/src/help.ts
|
|
570
570
|
import process8 from "process";
|
|
571
|
-
var OPTIONAL =
|
|
571
|
+
var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
|
|
572
572
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
573
573
|
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";
|
|
@@ -611,29 +607,44 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
|
|
|
611
607
|
return [];
|
|
612
608
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
613
609
|
}
|
|
610
|
+
var MAX_INLINE_CHOICES = 24;
|
|
614
611
|
function optionRows(options, colors = paint(process8.stdout)) {
|
|
615
612
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
616
613
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
617
|
-
const
|
|
614
|
+
const choices = option.choices?.join("|");
|
|
615
|
+
const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
|
|
616
|
+
const named = inline ? `<${choices}>` : "<value>";
|
|
618
617
|
const placeholder = option.optional === undefined ? named : `[${named}]`;
|
|
619
618
|
const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
|
|
620
|
-
|
|
619
|
+
const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
|
|
620
|
+
return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
|
|
621
621
|
});
|
|
622
622
|
const width = Math.max(0, ...rows.map((row) => row.width));
|
|
623
623
|
return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
|
|
624
624
|
}
|
|
625
625
|
|
|
626
626
|
// ../kit/src/text.ts
|
|
627
|
-
var ANSI =
|
|
627
|
+
var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
|
|
628
|
+
function stripAnsi(text) {
|
|
629
|
+
return text.replace(ANSI, "");
|
|
630
|
+
}
|
|
628
631
|
function distance(a, b) {
|
|
629
|
-
|
|
630
|
-
|
|
632
|
+
const left = [...a];
|
|
633
|
+
const right = [...b];
|
|
634
|
+
let before = [];
|
|
635
|
+
let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
636
|
+
for (const [i, x] of left.entries()) {
|
|
631
637
|
const current = [i + 1];
|
|
632
|
-
for (const [j,
|
|
633
|
-
|
|
638
|
+
for (const [j, y] of right.entries()) {
|
|
639
|
+
let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
|
|
640
|
+
if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
|
|
641
|
+
cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
|
|
642
|
+
current.push(cost);
|
|
643
|
+
}
|
|
644
|
+
before = previous;
|
|
634
645
|
previous = current;
|
|
635
646
|
}
|
|
636
|
-
return previous[
|
|
647
|
+
return previous[right.length] ?? 0;
|
|
637
648
|
}
|
|
638
649
|
function closest(name, names) {
|
|
639
650
|
const started = names.find((known) => known.startsWith(name));
|
|
@@ -1356,13 +1367,31 @@ function ciHeader(spinner, label, startedAt, out) {
|
|
|
1356
1367
|
// ../kit/src/cli.ts
|
|
1357
1368
|
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1358
1369
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1359
|
-
import
|
|
1370
|
+
import process18 from "process";
|
|
1371
|
+
|
|
1372
|
+
// ../kit/src/notify.ts
|
|
1373
|
+
import process16 from "process";
|
|
1374
|
+
var NOTIFY_AFTER_MS = 1e4;
|
|
1375
|
+
var CANCELLED = 130;
|
|
1376
|
+
function base64(text) {
|
|
1377
|
+
return Buffer.from(text).toString("base64");
|
|
1378
|
+
}
|
|
1379
|
+
function notification(title, body, env = process16.env) {
|
|
1380
|
+
const id = `kit${process16.pid}`;
|
|
1381
|
+
const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
|
|
1382
|
+
return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
|
|
1383
|
+
}
|
|
1384
|
+
function notifyEnd(command, code, ms, { stream = process16.stderr, env = process16.env } = {}) {
|
|
1385
|
+
if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
|
|
1386
|
+
return;
|
|
1387
|
+
stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
|
|
1388
|
+
}
|
|
1360
1389
|
|
|
1361
1390
|
// ../kit/src/usage.ts
|
|
1362
1391
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1363
1392
|
import { homedir as homedir3 } from "os";
|
|
1364
1393
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1365
|
-
import
|
|
1394
|
+
import process17 from "process";
|
|
1366
1395
|
|
|
1367
1396
|
// ../kit/src/logs.ts
|
|
1368
1397
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1376,14 +1405,14 @@ var usageError;
|
|
|
1376
1405
|
function noteUsageError(message) {
|
|
1377
1406
|
usageError = message;
|
|
1378
1407
|
}
|
|
1379
|
-
function stateHome(env =
|
|
1408
|
+
function stateHome(env = process17.env) {
|
|
1380
1409
|
const dir = env.XDG_STATE_HOME;
|
|
1381
1410
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1382
1411
|
}
|
|
1383
|
-
function usagePath(env =
|
|
1412
|
+
function usagePath(env = process17.env) {
|
|
1384
1413
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1385
1414
|
}
|
|
1386
|
-
function usageRecorded(env =
|
|
1415
|
+
function usageRecorded(env = process17.env) {
|
|
1387
1416
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1388
1417
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1389
1418
|
}
|
|
@@ -1397,7 +1426,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1397
1426
|
usageError = undefined;
|
|
1398
1427
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1399
1428
|
}
|
|
1400
|
-
function recordUsage(entry, env =
|
|
1429
|
+
function recordUsage(entry, env = process17.env) {
|
|
1401
1430
|
if (!usageRecorded(env))
|
|
1402
1431
|
return;
|
|
1403
1432
|
try {
|
|
@@ -1474,7 +1503,6 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1474
1503
|
header(colors, summary),
|
|
1475
1504
|
"",
|
|
1476
1505
|
usageLine(`${prefix} ${defaultCommand === undefined ? colors.cyan("<command>") : `[${colors.cyan("<command>")}]`} [options]`, colors),
|
|
1477
|
-
...replacesRows(replaces, colors),
|
|
1478
1506
|
"",
|
|
1479
1507
|
...await commandRows(commands, colors),
|
|
1480
1508
|
...own.length === 0 ? [] : ["", `${colors.bold(`Options of ${defaultCommand}:`)} ${colors.dim("the command run when none is named")}`, ...optionRows(Object.fromEntries(own), colors)],
|
|
@@ -1488,8 +1516,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1488
1516
|
`);
|
|
1489
1517
|
}
|
|
1490
1518
|
function printError(prefix, message, hint, cause) {
|
|
1491
|
-
const colors = paint(
|
|
1492
|
-
const styled = takesControlCodes(
|
|
1519
|
+
const colors = paint(process18.stderr);
|
|
1520
|
+
const styled = takesControlCodes(process18.stderr);
|
|
1493
1521
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1494
1522
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1495
1523
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1499,8 +1527,8 @@ function runHint(command, effect) {
|
|
|
1499
1527
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1500
1528
|
}
|
|
1501
1529
|
function printHint(hint) {
|
|
1502
|
-
const colors = paint(
|
|
1503
|
-
console.error(` ${takesControlCodes(
|
|
1530
|
+
const colors = paint(process18.stderr);
|
|
1531
|
+
console.error(` ${takesControlCodes(process18.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1504
1532
|
}
|
|
1505
1533
|
function printJsonError(message, hint, cause) {
|
|
1506
1534
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1539,11 +1567,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1539
1567
|
}
|
|
1540
1568
|
}
|
|
1541
1569
|
if (name === undefined && level.path.length > 1) {
|
|
1542
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1570
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process18.stderr));
|
|
1543
1571
|
return 2;
|
|
1544
1572
|
}
|
|
1545
1573
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1546
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1574
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process18.stdout));
|
|
1547
1575
|
return 0;
|
|
1548
1576
|
}
|
|
1549
1577
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1678,10 +1706,13 @@ async function runCli(cli, argv = scriptArgs()) {
|
|
|
1678
1706
|
const version = cli.version ?? packageVersion();
|
|
1679
1707
|
if (argv[0] === COMPLETE)
|
|
1680
1708
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
1709
|
+
const started = performance.now();
|
|
1681
1710
|
const code = await dispatch({ path: [cli.name], header: (colors, about) => `${colors.bold(cli.name)} ${colors.dim(version)} ${about}`, summary: cli.about, ...scopeOf(cli.commands, cli.extraCommands, cli.aliases), defaultCommand: cli.defaultCommand, runBare: cli.runBare === true, examples: cli.examples, replaces: cli.replaces }, argv, { version, redact: cli.redact });
|
|
1711
|
+
const command = commandPath(scopeOf(cli.commands, cli.extraCommands, cli.aliases), argv);
|
|
1712
|
+
notifyEnd(command === undefined ? cli.name : `${cli.name} ${command}`, code, performance.now() - started);
|
|
1682
1713
|
if (cli.usage !== false) {
|
|
1683
1714
|
try {
|
|
1684
|
-
recordUsage(usageEntry(cli.name,
|
|
1715
|
+
recordUsage(usageEntry(cli.name, command, argv, code));
|
|
1685
1716
|
} catch {}
|
|
1686
1717
|
}
|
|
1687
1718
|
return code;
|
|
@@ -1701,11 +1732,130 @@ function commandPath(scope, argv) {
|
|
|
1701
1732
|
}
|
|
1702
1733
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1703
1734
|
}
|
|
1735
|
+
// ../kit/src/excerpt.ts
|
|
1736
|
+
var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
|
|
1737
|
+
var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
|
|
1738
|
+
var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
1739
|
+
var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
|
|
1740
|
+
var TSC_ERROR = /\berror TS\d+/;
|
|
1741
|
+
var TSC_CONTINUATION = /^\s{2,}\S/;
|
|
1742
|
+
var TSC_FRAME = /^\s*[~^|]/;
|
|
1743
|
+
var TSC_SUMMARY = /^Found \d+ errors?/;
|
|
1744
|
+
var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
|
|
1745
|
+
var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
|
|
1746
|
+
var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
|
|
1747
|
+
var PHPSTAN_NOISE = /^\s*\[OK\]/;
|
|
1748
|
+
var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
|
|
1749
|
+
var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
|
|
1750
|
+
var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
|
|
1751
|
+
var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
|
|
1752
|
+
var MAX_LINES = 100;
|
|
1753
|
+
var bunCheck = (lines) => {
|
|
1754
|
+
const text = lines.join(`
|
|
1755
|
+
`);
|
|
1756
|
+
const blocks = text.match(BUN_CHECK_BLOCK);
|
|
1757
|
+
if (blocks === null)
|
|
1758
|
+
return;
|
|
1759
|
+
const errors = blocks.map((block) => {
|
|
1760
|
+
const { file, line, column, code, message } = bunCheckFields(block);
|
|
1761
|
+
return `${file}:${line}:${column} ${code}: ${message}`;
|
|
1762
|
+
});
|
|
1763
|
+
return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
|
|
1764
|
+
};
|
|
1765
|
+
function bunCheckFields(block) {
|
|
1766
|
+
const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
|
|
1767
|
+
`)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
|
|
1768
|
+
return {
|
|
1769
|
+
file: attributes.file ?? "",
|
|
1770
|
+
line: attributes.line ?? "",
|
|
1771
|
+
column: attributes.column ?? "",
|
|
1772
|
+
code: attributes.code ?? "",
|
|
1773
|
+
message: block.replace(BUN_CHECK_SOURCE, "").split(`
|
|
1774
|
+
`).slice(1, -1).join(`
|
|
1775
|
+
`).trim()
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
var tsc = (lines) => {
|
|
1779
|
+
const kept = [];
|
|
1780
|
+
let inError = false;
|
|
1781
|
+
for (const line of lines) {
|
|
1782
|
+
if (TSC_ERROR.test(line)) {
|
|
1783
|
+
inError = true;
|
|
1784
|
+
kept.push(line);
|
|
1785
|
+
} else if (TSC_SUMMARY.test(line)) {
|
|
1786
|
+
inError = false;
|
|
1787
|
+
kept.push(line);
|
|
1788
|
+
} else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
|
|
1789
|
+
kept.push(line);
|
|
1790
|
+
} else {
|
|
1791
|
+
inError = false;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
|
|
1795
|
+
};
|
|
1796
|
+
var eslint = (lines) => {
|
|
1797
|
+
const kept = [];
|
|
1798
|
+
let file = "";
|
|
1799
|
+
let shown = "";
|
|
1800
|
+
for (const line of lines) {
|
|
1801
|
+
if (ESLINT_PROBLEM.test(line)) {
|
|
1802
|
+
if (file !== shown) {
|
|
1803
|
+
kept.push(file);
|
|
1804
|
+
shown = file;
|
|
1805
|
+
}
|
|
1806
|
+
kept.push(line);
|
|
1807
|
+
} else if (ESLINT_SUMMARY.test(line)) {
|
|
1808
|
+
kept.push(line);
|
|
1809
|
+
} else if (line.trim() !== "") {
|
|
1810
|
+
file = line;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
|
|
1814
|
+
};
|
|
1815
|
+
var phpstan = (lines) => {
|
|
1816
|
+
const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
|
|
1817
|
+
return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
|
|
1818
|
+
};
|
|
1819
|
+
var vitest = (lines) => {
|
|
1820
|
+
const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
|
|
1821
|
+
return start === -1 ? undefined : lines.slice(start);
|
|
1822
|
+
};
|
|
1823
|
+
var playwright = (lines) => {
|
|
1824
|
+
const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
|
|
1825
|
+
return start === -1 ? undefined : lines.slice(start);
|
|
1826
|
+
};
|
|
1827
|
+
var phpCsFixer = (lines) => {
|
|
1828
|
+
const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
|
|
1829
|
+
return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
|
|
1830
|
+
};
|
|
1831
|
+
var TOOL_PARSERS = [bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan];
|
|
1832
|
+
function squeeze(lines) {
|
|
1833
|
+
const out = [];
|
|
1834
|
+
for (const line of lines.map((text) => text.trimEnd())) {
|
|
1835
|
+
if (line !== "" || out.at(-1) !== "")
|
|
1836
|
+
out.push(line);
|
|
1837
|
+
}
|
|
1838
|
+
while (out.at(-1) === "")
|
|
1839
|
+
out.pop();
|
|
1840
|
+
return out;
|
|
1841
|
+
}
|
|
1842
|
+
function cut(shown) {
|
|
1843
|
+
return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
|
|
1844
|
+
`) : shown.join(`
|
|
1845
|
+
`);
|
|
1846
|
+
}
|
|
1847
|
+
function recognised(lines, parsers) {
|
|
1848
|
+
return parsers.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
|
|
1849
|
+
}
|
|
1850
|
+
function toolExcerpt(lines) {
|
|
1851
|
+
const found = recognised(lines.map((line) => stripAnsi(line)), TOOL_PARSERS);
|
|
1852
|
+
return found === undefined ? undefined : cut(squeeze(found));
|
|
1853
|
+
}
|
|
1704
1854
|
// ../kit/src/folders.ts
|
|
1705
1855
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1706
1856
|
// ../kit/src/git.ts
|
|
1707
1857
|
import { basename, dirname as dirname4 } from "path";
|
|
1708
|
-
import
|
|
1858
|
+
import process19 from "process";
|
|
1709
1859
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1710
1860
|
var GIT_NETWORK_MS = 60000;
|
|
1711
1861
|
async function git(args, timeoutMs) {
|
|
@@ -1735,7 +1885,7 @@ async function defaultBranch() {
|
|
|
1735
1885
|
async function leaveWorktree() {
|
|
1736
1886
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1737
1887
|
if (basename(common) === ".git")
|
|
1738
|
-
|
|
1888
|
+
process19.chdir(dirname4(common));
|
|
1739
1889
|
}
|
|
1740
1890
|
// ../kit/src/limit.ts
|
|
1741
1891
|
function limitOptions(fallback) {
|
|
@@ -1776,15 +1926,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
|
|
|
1776
1926
|
// ../kit/src/sessions.ts
|
|
1777
1927
|
import { homedir as homedir4 } from "os";
|
|
1778
1928
|
import { join as join6 } from "path";
|
|
1779
|
-
import
|
|
1929
|
+
import process20 from "process";
|
|
1780
1930
|
var {Glob } = globalThis.Bun;
|
|
1781
1931
|
var SESSION_FILES = new Glob("*.json");
|
|
1782
1932
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1783
1933
|
async function sessionDirs() {
|
|
1784
1934
|
const home = homedir4();
|
|
1785
1935
|
const dirs = new Set([join6(home, ".claude", "sessions")]);
|
|
1786
|
-
if (
|
|
1787
|
-
dirs.add(join6(
|
|
1936
|
+
if (process20.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1937
|
+
dirs.add(join6(process20.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1788
1938
|
try {
|
|
1789
1939
|
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1790
1940
|
dirs.add(dir);
|
|
@@ -1830,7 +1980,7 @@ async function liveSessions() {
|
|
|
1830
1980
|
}
|
|
1831
1981
|
async function currentSession(sessions) {
|
|
1832
1982
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1833
|
-
let pid =
|
|
1983
|
+
let pid = process20.ppid;
|
|
1834
1984
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1835
1985
|
const session = byPid.get(pid);
|
|
1836
1986
|
if (session !== undefined)
|
|
@@ -1843,7 +1993,7 @@ async function currentSession(sessions) {
|
|
|
1843
1993
|
return;
|
|
1844
1994
|
}
|
|
1845
1995
|
// ../kit/src/watch.ts
|
|
1846
|
-
import
|
|
1996
|
+
import process21 from "process";
|
|
1847
1997
|
import { format } from "util";
|
|
1848
1998
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1849
1999
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1865,7 +2015,7 @@ function withoutWatch(args) {
|
|
|
1865
2015
|
}
|
|
1866
2016
|
return rest;
|
|
1867
2017
|
}
|
|
1868
|
-
async function watching(value, step, stream =
|
|
2018
|
+
async function watching(value, step, stream = process21.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1869
2019
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1870
2020
|
if (!takesControlCodes(stream))
|
|
1871
2021
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1873,12 +2023,12 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
|
|
|
1873
2023
|
for (let round = 0;round < rounds; round++) {
|
|
1874
2024
|
const held = [];
|
|
1875
2025
|
const { log, info } = console;
|
|
1876
|
-
const write =
|
|
2026
|
+
const write = process21.stdout.write.bind(process21.stdout);
|
|
1877
2027
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1878
2028
|
`);
|
|
1879
2029
|
console.log = hold;
|
|
1880
2030
|
console.info = hold;
|
|
1881
|
-
|
|
2031
|
+
process21.stdout.write = (text) => {
|
|
1882
2032
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1883
2033
|
return true;
|
|
1884
2034
|
};
|
|
@@ -1887,7 +2037,7 @@ async function watching(value, step, stream = process20.stdout, sleep = Bun.slee
|
|
|
1887
2037
|
} finally {
|
|
1888
2038
|
console.log = log;
|
|
1889
2039
|
console.info = info;
|
|
1890
|
-
|
|
2040
|
+
process21.stdout.write = write;
|
|
1891
2041
|
}
|
|
1892
2042
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1893
2043
|
await sleep(interval);
|
|
@@ -2065,9 +2215,9 @@ function holderSession(holder, sessions) {
|
|
|
2065
2215
|
}
|
|
2066
2216
|
|
|
2067
2217
|
// src/good.ts
|
|
2068
|
-
import
|
|
2218
|
+
import process23 from "process";
|
|
2069
2219
|
function good(text) {
|
|
2070
|
-
return role("ok",
|
|
2220
|
+
return role("ok", process23.stdout)(text);
|
|
2071
2221
|
}
|
|
2072
2222
|
|
|
2073
2223
|
// src/config.ts
|
|
@@ -2099,10 +2249,13 @@ async function loadSettings(home) {
|
|
|
2099
2249
|
return typeof host === "string" && host !== "" ? { remoteHost: host } : {};
|
|
2100
2250
|
}
|
|
2101
2251
|
|
|
2252
|
+
// src/tea.ts
|
|
2253
|
+
import process25 from "process";
|
|
2254
|
+
|
|
2102
2255
|
// src/forge.ts
|
|
2103
2256
|
import { homedir as homedir5 } from "os";
|
|
2104
2257
|
import { join as join7 } from "path";
|
|
2105
|
-
import
|
|
2258
|
+
import process24 from "process";
|
|
2106
2259
|
|
|
2107
2260
|
// src/remote.ts
|
|
2108
2261
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2141,6 +2294,8 @@ async function reachesHost(hostname, host, hostAddresses, addressesOf) {
|
|
|
2141
2294
|
// src/forge.ts
|
|
2142
2295
|
var LOGIN_HOST = /^\s*(?:-\s*)?(?:url|ssh_host):\s*["']?([^\s"']+)/gm;
|
|
2143
2296
|
var PORT = /:\d+$/;
|
|
2297
|
+
var LOGIN_LINE = /^\s*(-\s+)?([a-z_]+):(.*)$/;
|
|
2298
|
+
var QUOTES = /^["']|["']$/g;
|
|
2144
2299
|
var SCP_REMOTE = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)/;
|
|
2145
2300
|
var URL_REMOTE = /^[a-z+]+:\/\/(?:[^@/\s]+@)?(\[[^\]]+\]|[^:/\s]+)/i;
|
|
2146
2301
|
function originHost(remote) {
|
|
@@ -2157,7 +2312,7 @@ function loginHosts(config) {
|
|
|
2157
2312
|
return hosts;
|
|
2158
2313
|
}
|
|
2159
2314
|
function teaConfigPath() {
|
|
2160
|
-
const base =
|
|
2315
|
+
const base = process24.env.XDG_CONFIG_HOME;
|
|
2161
2316
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2162
2317
|
}
|
|
2163
2318
|
async function readConfig() {
|
|
@@ -2176,35 +2331,105 @@ async function requireForgeOrigin() {
|
|
|
2176
2331
|
const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
|
|
2177
2332
|
const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
|
|
2178
2333
|
if (host !== undefined && !hosts.has(host))
|
|
2179
|
-
fail(`origin ${redactUrl(origin.stdout.trim())} is not on a Forgejo
|
|
2334
|
+
fail(`origin ${redactUrl(origin.stdout.trim())} is not on a Forgejo you are logged in to (${[...hosts].join(", ")})`, 2, "name the repository with -r owner/name, or run ft in a repository hosted there (an ssh alias origin: ft remote --fix)");
|
|
2180
2335
|
})();
|
|
2181
2336
|
return checked;
|
|
2182
2337
|
}
|
|
2338
|
+
function teaLogins(config) {
|
|
2339
|
+
const logins = [];
|
|
2340
|
+
let current;
|
|
2341
|
+
const finish = () => {
|
|
2342
|
+
if (current?.url !== undefined && current.token !== undefined && current.token !== "")
|
|
2343
|
+
logins.push({ url: current.url, token: current.token, isDefault: current.default === "true" });
|
|
2344
|
+
};
|
|
2345
|
+
for (const line of config.split(`
|
|
2346
|
+
`)) {
|
|
2347
|
+
const entry = LOGIN_LINE.exec(line);
|
|
2348
|
+
if (entry === null)
|
|
2349
|
+
continue;
|
|
2350
|
+
if (entry[1] !== undefined) {
|
|
2351
|
+
finish();
|
|
2352
|
+
current = {};
|
|
2353
|
+
}
|
|
2354
|
+
if (current !== undefined)
|
|
2355
|
+
current[entry[2]] = (entry[3] ?? "").trim().replace(QUOTES, "");
|
|
2356
|
+
}
|
|
2357
|
+
finish();
|
|
2358
|
+
return logins;
|
|
2359
|
+
}
|
|
2360
|
+
async function pickLogin(useOrigin) {
|
|
2361
|
+
const logins = teaLogins(await readConfig());
|
|
2362
|
+
if (useOrigin) {
|
|
2363
|
+
const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
|
|
2364
|
+
const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
|
|
2365
|
+
const match = host === undefined ? undefined : logins.find((each) => URL.canParse(each.url) && new URL(each.url).hostname.toLowerCase() === host);
|
|
2366
|
+
if (match !== undefined)
|
|
2367
|
+
return match;
|
|
2368
|
+
}
|
|
2369
|
+
return logins.find((each) => each.isDefault) ?? logins[0];
|
|
2370
|
+
}
|
|
2183
2371
|
|
|
2184
2372
|
// src/tea.ts
|
|
2185
2373
|
var TEA_MS = 60000;
|
|
2186
2374
|
function repoFlag(repo) {
|
|
2187
2375
|
return repo === undefined ? [] : ["--repo", repo];
|
|
2188
2376
|
}
|
|
2189
|
-
|
|
2377
|
+
function usesGt() {
|
|
2378
|
+
const PATH = process25.env.PATH ?? "";
|
|
2379
|
+
return Bun.which("tea", { PATH }) === null && Bun.which("gt", { PATH }) !== null;
|
|
2380
|
+
}
|
|
2381
|
+
var injected;
|
|
2382
|
+
async function injectLogin(repo) {
|
|
2383
|
+
if (process25.env.GITEA_TOKEN !== undefined && process25.env.GITEA_TOKEN !== "")
|
|
2384
|
+
return;
|
|
2385
|
+
const login = await pickLogin(repo === undefined);
|
|
2386
|
+
if (login === undefined)
|
|
2387
|
+
return;
|
|
2388
|
+
injected = login.token;
|
|
2389
|
+
process25.env.GITEA_TOKEN = login.token;
|
|
2390
|
+
process25.env.GITEA_CLI_HOST = login.url;
|
|
2391
|
+
}
|
|
2392
|
+
function scrub(text) {
|
|
2393
|
+
const token = injected ?? process25.env.GITEA_TOKEN;
|
|
2394
|
+
return token === undefined || token === "" ? text : text.replaceAll(token, "***");
|
|
2395
|
+
}
|
|
2396
|
+
function failureText(stdout, stderr, code) {
|
|
2397
|
+
try {
|
|
2398
|
+
const value = JSON.parse(stdout);
|
|
2399
|
+
if (value !== null && typeof value === "object" && "message" in value && typeof value.message === "string")
|
|
2400
|
+
return scrub(value.message);
|
|
2401
|
+
} catch {}
|
|
2402
|
+
return scrub(stderr.trim() || stdout.trim() || `exit ${code}`);
|
|
2403
|
+
}
|
|
2404
|
+
async function runApi(label, args, repo) {
|
|
2190
2405
|
if (repo === undefined)
|
|
2191
2406
|
await requireForgeOrigin();
|
|
2192
|
-
const
|
|
2407
|
+
const gt = usesGt();
|
|
2408
|
+
const bin = gt ? "gt" : "tea";
|
|
2409
|
+
if (gt)
|
|
2410
|
+
await injectLogin(repo);
|
|
2411
|
+
const result = await runTool(`${bin} api ${label}`, [bin, "api", ...repoFlag(repo), ...args], { timeoutMs: TEA_MS });
|
|
2193
2412
|
if (result.code !== 0)
|
|
2194
|
-
throw new Error(
|
|
2195
|
-
return result.stdout;
|
|
2413
|
+
throw new Error(`${bin} api ${label}: ${gt ? failureText(result.stdout, result.stderr, result.code) : result.stderr.trim() || `exit ${result.code}`}`);
|
|
2414
|
+
return gt ? scrub(result.stdout) : result.stdout;
|
|
2415
|
+
}
|
|
2416
|
+
async function request(path, repo) {
|
|
2417
|
+
return runApi(path, [path], repo);
|
|
2418
|
+
}
|
|
2419
|
+
function clientName() {
|
|
2420
|
+
return usesGt() ? "gt" : "tea";
|
|
2196
2421
|
}
|
|
2197
2422
|
function parseJson(path, text) {
|
|
2198
2423
|
let value;
|
|
2199
2424
|
try {
|
|
2200
2425
|
value = JSON.parse(text);
|
|
2201
2426
|
} catch {
|
|
2202
|
-
throw new Error(
|
|
2427
|
+
throw new Error(`${clientName()} api ${path}: ${upTo(text.trim(), `
|
|
2203
2428
|
`) || "empty answer"}`);
|
|
2204
2429
|
}
|
|
2205
2430
|
const failure = apiError(value);
|
|
2206
2431
|
if (failure !== undefined)
|
|
2207
|
-
throw new Error(
|
|
2432
|
+
throw new Error(`${clientName()} api ${path}: ${failure}`);
|
|
2208
2433
|
return value;
|
|
2209
2434
|
}
|
|
2210
2435
|
function apiError(value) {
|
|
@@ -2218,15 +2443,13 @@ async function api(path, repo) {
|
|
|
2218
2443
|
async function repoApi(path, repo) {
|
|
2219
2444
|
return api(`repos/{owner}/{repo}/${path}`, repo);
|
|
2220
2445
|
}
|
|
2221
|
-
async function
|
|
2446
|
+
async function repoSend(method, path, fields, repo) {
|
|
2222
2447
|
const full = `repos/{owner}/{repo}/${path}`;
|
|
2223
|
-
const flags = Object.entries(fields).flatMap(([name, value]) => ["-f", `${name}=${value}`]);
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
throw new Error(`tea api ${full}: ${result.stderr.trim() || `exit ${result.code}`}`);
|
|
2229
|
-
return parseJson(full, result.stdout);
|
|
2448
|
+
const flags = Object.entries(fields).flatMap(([name, value]) => typeof value === "string" ? ["-f", `${name}=${value}`] : ["-F", `${name}=${JSON.stringify(value)}`]);
|
|
2449
|
+
return runApi(full, ["-X", method, ...flags, full], repo);
|
|
2450
|
+
}
|
|
2451
|
+
async function repoWrite(method, path, fields, repo) {
|
|
2452
|
+
return parseJson(`repos/{owner}/{repo}/${path}`, await repoSend(method, path, fields, repo));
|
|
2230
2453
|
}
|
|
2231
2454
|
async function repoApiText(path, repo) {
|
|
2232
2455
|
const full = `repos/{owner}/{repo}/${path}`;
|
|
@@ -2239,7 +2462,7 @@ async function repoApiText(path, repo) {
|
|
|
2239
2462
|
}
|
|
2240
2463
|
const failure = apiError(value);
|
|
2241
2464
|
if (failure !== undefined)
|
|
2242
|
-
throw new Error(
|
|
2465
|
+
throw new Error(`${clientName()} api ${full}: ${failure}`);
|
|
2243
2466
|
return text;
|
|
2244
2467
|
}
|
|
2245
2468
|
async function tea(command, args, repo) {
|
|
@@ -2251,8 +2474,56 @@ async function tea(command, args, repo) {
|
|
|
2251
2474
|
return result.stdout;
|
|
2252
2475
|
}
|
|
2253
2476
|
|
|
2254
|
-
// src/
|
|
2477
|
+
// src/milestones.ts
|
|
2255
2478
|
var PAGE = 50;
|
|
2479
|
+
var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2480
|
+
var NO_DUE_YEAR = 9999;
|
|
2481
|
+
async function listMilestones(state, repo) {
|
|
2482
|
+
const found = [];
|
|
2483
|
+
for (let page = 1;; page++) {
|
|
2484
|
+
const batch = await repoApi(`milestones?state=${state}&page=${page}&limit=${PAGE}`, repo);
|
|
2485
|
+
found.push(...batch);
|
|
2486
|
+
if (batch.length < PAGE)
|
|
2487
|
+
return found;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
async function findMilestone(reference, repo) {
|
|
2491
|
+
const all = await listMilestones("all", repo);
|
|
2492
|
+
const found = all.find((each) => each.title === reference) ?? all.find((each) => String(each.id) === reference);
|
|
2493
|
+
if (found === undefined)
|
|
2494
|
+
fail(`no milestone ${reference}, ${all.length === 0 ? "the repository has none" : `it has: ${all.map((each) => each.title).join(", ")}`}`, 2, runHint(`ft milestone new ${reference}`, "create it"));
|
|
2495
|
+
return found;
|
|
2496
|
+
}
|
|
2497
|
+
function dueOn(value) {
|
|
2498
|
+
const match = DATE.exec(value);
|
|
2499
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
2500
|
+
if (match === null || Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value || date.getUTCFullYear() < 2000)
|
|
2501
|
+
fail(`--due takes a date as YYYY-MM-DD, not ${value}`);
|
|
2502
|
+
return date.toISOString();
|
|
2503
|
+
}
|
|
2504
|
+
function dueDate(milestone) {
|
|
2505
|
+
if (milestone.due_on === null || new Date(milestone.due_on).getUTCFullYear() >= NO_DUE_YEAR)
|
|
2506
|
+
return "";
|
|
2507
|
+
return milestone.due_on.slice(0, 10);
|
|
2508
|
+
}
|
|
2509
|
+
function progress(milestone) {
|
|
2510
|
+
const total = milestone.open_issues + milestone.closed_issues;
|
|
2511
|
+
return total === 0 ? "" : `${Math.round(milestone.closed_issues / total * 100)}%`;
|
|
2512
|
+
}
|
|
2513
|
+
async function createMilestone(title, description, due, repo) {
|
|
2514
|
+
const fields = { title };
|
|
2515
|
+
if (description !== undefined)
|
|
2516
|
+
fields.description = description;
|
|
2517
|
+
if (due !== undefined)
|
|
2518
|
+
fields.due_on = due;
|
|
2519
|
+
return repoWrite("POST", "milestones", fields, repo);
|
|
2520
|
+
}
|
|
2521
|
+
async function closeMilestone(id, repo) {
|
|
2522
|
+
await repoWrite("PATCH", `milestones/${id}`, { state: "closed" }, repo);
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
// src/issues.ts
|
|
2526
|
+
var PAGE2 = 50;
|
|
2256
2527
|
var CONCURRENCY = 8;
|
|
2257
2528
|
async function getIssue(number, repo) {
|
|
2258
2529
|
return repoApi(`issues/${number}`, repo);
|
|
@@ -2260,9 +2531,9 @@ async function getIssue(number, repo) {
|
|
|
2260
2531
|
async function listIssues(state, filter, repo) {
|
|
2261
2532
|
const issues = [];
|
|
2262
2533
|
for (let page = 1;; page++) {
|
|
2263
|
-
const batch = await repoApi(`issues?state=${state}&type=issues&page=${page}&limit=${
|
|
2534
|
+
const batch = await repoApi(`issues?state=${state}&type=issues&page=${page}&limit=${PAGE2}${filter}`, repo);
|
|
2264
2535
|
issues.push(...batch);
|
|
2265
|
-
if (batch.length <
|
|
2536
|
+
if (batch.length < PAGE2)
|
|
2266
2537
|
return issues;
|
|
2267
2538
|
}
|
|
2268
2539
|
}
|
|
@@ -2281,6 +2552,10 @@ async function commentsOfAll(issues, repo) {
|
|
|
2281
2552
|
return new Map(commented.map((issue, index) => [issue.number, comments[index]]));
|
|
2282
2553
|
}
|
|
2283
2554
|
async function editIssue(number, change, repo) {
|
|
2555
|
+
if (usesGt()) {
|
|
2556
|
+
await repoWrite("PATCH", `issues/${number}`, { ...change.title === undefined ? {} : { title: change.title }, ...change.body === undefined ? {} : { body: change.body }, ...change.milestone === undefined ? {} : { milestone: await milestoneId(change.milestone, repo) } }, repo);
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2284
2559
|
const args = [String(number)];
|
|
2285
2560
|
if (change.title !== undefined)
|
|
2286
2561
|
args.push("-t", change.title);
|
|
@@ -2294,6 +2569,9 @@ async function setBody(number, body, repo) {
|
|
|
2294
2569
|
await editIssue(number, { body }, repo);
|
|
2295
2570
|
}
|
|
2296
2571
|
async function createIssue(title, body, labels, milestone, repo) {
|
|
2572
|
+
if (usesGt()) {
|
|
2573
|
+
return repoWrite("POST", "issues", { title, body, ...labels === undefined ? {} : { labels: await labelIds(labels.split(","), repo) }, ...milestone === undefined ? {} : { milestone: await milestoneId(milestone, repo) } }, repo);
|
|
2574
|
+
}
|
|
2297
2575
|
const args = ["-t", title, "-d", body];
|
|
2298
2576
|
const same = (found) => found.title === title && sameText(found.body, body);
|
|
2299
2577
|
const known = new Set((await openIssues(undefined, repo)).filter(same).map((found) => found.number));
|
|
@@ -2346,21 +2624,32 @@ async function comment(number, body, repo) {
|
|
|
2346
2624
|
await repoWrite("POST", `issues/${number}/comments`, { body }, repo);
|
|
2347
2625
|
}
|
|
2348
2626
|
async function close(number, repo) {
|
|
2627
|
+
if (usesGt())
|
|
2628
|
+
return void await repoWrite("PATCH", `issues/${number}`, { state: "closed" }, repo);
|
|
2349
2629
|
await tea(["issues", "close"], [String(number)], repo);
|
|
2350
2630
|
}
|
|
2351
2631
|
async function reopen(number, repo) {
|
|
2632
|
+
if (usesGt())
|
|
2633
|
+
return void await repoWrite("PATCH", `issues/${number}`, { state: "open" }, repo);
|
|
2352
2634
|
await tea(["issues", "reopen"], [String(number)], repo);
|
|
2353
2635
|
}
|
|
2354
2636
|
async function repoLabels(repo) {
|
|
2355
2637
|
const names = [];
|
|
2356
2638
|
for (let page = 1;; page++) {
|
|
2357
|
-
const batch = await repoApi(`labels?page=${page}&limit=${
|
|
2639
|
+
const batch = await repoApi(`labels?page=${page}&limit=${PAGE2}`, repo);
|
|
2358
2640
|
names.push(...batch.map((each) => each.name));
|
|
2359
|
-
if (batch.length <
|
|
2641
|
+
if (batch.length < PAGE2)
|
|
2360
2642
|
return names;
|
|
2361
2643
|
}
|
|
2362
2644
|
}
|
|
2363
2645
|
async function editLabels(number, add, remove, repo) {
|
|
2646
|
+
if (usesGt()) {
|
|
2647
|
+
if (add.length > 0)
|
|
2648
|
+
await repoSend("POST", `issues/${number}/labels`, { labels: await labelIds(add, repo) }, repo);
|
|
2649
|
+
for (const id of await labelIds(remove, repo))
|
|
2650
|
+
await repoSend("DELETE", `issues/${number}/labels/${id}`, {}, repo);
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2364
2653
|
const args = [String(number)];
|
|
2365
2654
|
if (add.length > 0)
|
|
2366
2655
|
args.push("--add-labels", add.join(","));
|
|
@@ -2368,53 +2657,23 @@ async function editLabels(number, add, remove, repo) {
|
|
|
2368
2657
|
args.push("--remove-labels", remove.join(","));
|
|
2369
2658
|
await tea(["issues", "edit"], args, repo);
|
|
2370
2659
|
}
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
var PAGE2 = 50;
|
|
2374
|
-
var DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2375
|
-
var NO_DUE_YEAR = 9999;
|
|
2376
|
-
async function listMilestones(state, repo) {
|
|
2377
|
-
const found = [];
|
|
2660
|
+
async function labelIds(names, repo) {
|
|
2661
|
+
const all = [];
|
|
2378
2662
|
for (let page = 1;; page++) {
|
|
2379
|
-
const batch = await repoApi(`
|
|
2380
|
-
|
|
2663
|
+
const batch = await repoApi(`labels?page=${page}&limit=${PAGE2}`, repo);
|
|
2664
|
+
all.push(...batch);
|
|
2381
2665
|
if (batch.length < PAGE2)
|
|
2382
|
-
|
|
2666
|
+
break;
|
|
2383
2667
|
}
|
|
2668
|
+
return names.map((name) => name.trim()).filter((name) => name !== "").map((name) => {
|
|
2669
|
+
const found = all.find((each) => each.name === name);
|
|
2670
|
+
if (found === undefined)
|
|
2671
|
+
throw new Error(`no label ${name}, the repository has: ${all.map((each) => each.name).join(", ")}`);
|
|
2672
|
+
return found.id;
|
|
2673
|
+
});
|
|
2384
2674
|
}
|
|
2385
|
-
async function
|
|
2386
|
-
|
|
2387
|
-
const found = all.find((each) => each.title === reference) ?? all.find((each) => String(each.id) === reference);
|
|
2388
|
-
if (found === undefined)
|
|
2389
|
-
fail(`no milestone ${reference}, ${all.length === 0 ? "the repository has none" : `it has: ${all.map((each) => each.title).join(", ")}`}`, 2, runHint(`ft milestone new ${reference}`, "create it"));
|
|
2390
|
-
return found;
|
|
2391
|
-
}
|
|
2392
|
-
function dueOn(value) {
|
|
2393
|
-
const match = DATE.exec(value);
|
|
2394
|
-
const date = new Date(`${value}T00:00:00Z`);
|
|
2395
|
-
if (match === null || Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== value || date.getUTCFullYear() < 2000)
|
|
2396
|
-
fail(`--due takes a date as YYYY-MM-DD, not ${value}`);
|
|
2397
|
-
return date.toISOString();
|
|
2398
|
-
}
|
|
2399
|
-
function dueDate(milestone) {
|
|
2400
|
-
if (milestone.due_on === null || new Date(milestone.due_on).getUTCFullYear() >= NO_DUE_YEAR)
|
|
2401
|
-
return "";
|
|
2402
|
-
return milestone.due_on.slice(0, 10);
|
|
2403
|
-
}
|
|
2404
|
-
function progress(milestone) {
|
|
2405
|
-
const total = milestone.open_issues + milestone.closed_issues;
|
|
2406
|
-
return total === 0 ? "" : `${Math.round(milestone.closed_issues / total * 100)}%`;
|
|
2407
|
-
}
|
|
2408
|
-
async function createMilestone(title, description, due, repo) {
|
|
2409
|
-
const fields = { title };
|
|
2410
|
-
if (description !== undefined)
|
|
2411
|
-
fields.description = description;
|
|
2412
|
-
if (due !== undefined)
|
|
2413
|
-
fields.due_on = due;
|
|
2414
|
-
return repoWrite("POST", "milestones", fields, repo);
|
|
2415
|
-
}
|
|
2416
|
-
async function closeMilestone(id, repo) {
|
|
2417
|
-
await repoWrite("PATCH", `milestones/${id}`, { state: "closed" }, repo);
|
|
2675
|
+
async function milestoneId(title, repo) {
|
|
2676
|
+
return title === "" ? 0 : (await findMilestone(title, repo)).id;
|
|
2418
2677
|
}
|
|
2419
2678
|
|
|
2420
2679
|
// src/commands/board.ts
|
|
@@ -2509,9 +2768,8 @@ var boardUsage = `ft board
|
|
|
2509
2768
|
|
|
2510
2769
|
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.
|
|
2511
2770
|
A claim shows its boxes left, and one no live session holds also the latest comment that is not a claim.
|
|
2512
|
-
A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs
|
|
2513
|
-
|
|
2514
|
-
Exits 0 when it listed them, 1 when the issues cannot be read, 2 on a usage error.`;
|
|
2771
|
+
A lane's claim (lane-<n>-<issue>) is held while the session whose name ends in -<n> runs.`;
|
|
2772
|
+
var boardExits = [[0, "it listed them"], [1, "the issues cannot be read"], [2, "a usage error"]];
|
|
2515
2773
|
var BOARD_LIMIT = 30;
|
|
2516
2774
|
var boardOptions = {
|
|
2517
2775
|
labels: { type: "string", short: "L", description: "only issues with these labels, comma separated" },
|
|
@@ -2524,7 +2782,7 @@ var boardOptions = {
|
|
|
2524
2782
|
...repoOption
|
|
2525
2783
|
};
|
|
2526
2784
|
async function board(args) {
|
|
2527
|
-
const parsed = parse(args, boardUsage, boardOptions);
|
|
2785
|
+
const parsed = parse(args, boardUsage, boardOptions, { exits: boardExits });
|
|
2528
2786
|
const { values } = parsed;
|
|
2529
2787
|
if (values.watch !== undefined)
|
|
2530
2788
|
return watching(values.watch, async () => board(withoutWatch(args)));
|
|
@@ -2561,9 +2819,8 @@ async function me(as, sessions) {
|
|
|
2561
2819
|
var takeUsage = `ft take <n>...
|
|
2562
2820
|
|
|
2563
2821
|
Claims each issue for this Claude Code session with a "Taken by session <name>." comment.
|
|
2564
|
-
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
|
|
2565
|
-
|
|
2566
|
-
Exits 0 when every issue is taken, 1 when one is refused, 2 on a usage error.`;
|
|
2822
|
+
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.`;
|
|
2823
|
+
var takeExits = [[0, "every issue is taken"], [1, "one is refused"], [2, "a usage error"]];
|
|
2567
2824
|
var laneOption = {
|
|
2568
2825
|
lane: { type: "boolean", description: "claim each as lane-<s>-<n>, <s> ending this session's name, so the claim stays live while it runs" }
|
|
2569
2826
|
};
|
|
@@ -2599,7 +2856,7 @@ async function eachIssue(command, numbers, step) {
|
|
|
2599
2856
|
return code;
|
|
2600
2857
|
}
|
|
2601
2858
|
async function take(args) {
|
|
2602
|
-
const parsed = parse(args, takeUsage, takeOptions);
|
|
2859
|
+
const parsed = parse(args, takeUsage, takeOptions, { exits: takeExits });
|
|
2603
2860
|
const { values, positionals } = parsed;
|
|
2604
2861
|
const numbers = issueNumbers(positionals, takeUsage);
|
|
2605
2862
|
const sessions = await liveSessions();
|
|
@@ -2630,9 +2887,8 @@ async function take(args) {
|
|
|
2630
2887
|
var dropUsage = `ft drop <n>... [--stale] | --all-stale [--dry-run]
|
|
2631
2888
|
|
|
2632
2889
|
Gives each issue back with a "Released by session <name>." comment, when this session holds it.
|
|
2633
|
-
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
|
|
2634
|
-
|
|
2635
|
-
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.`;
|
|
2890
|
+
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.`;
|
|
2891
|
+
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"]];
|
|
2636
2892
|
var dropOptions = {
|
|
2637
2893
|
as: { type: "string", description: "the name it was taken as, instead of this session's" },
|
|
2638
2894
|
stale: { type: "boolean", description: "also release a claim no live session here answers to" },
|
|
@@ -2653,7 +2909,7 @@ async function releaseStale(number, me, author, sessions, repo) {
|
|
|
2653
2909
|
console.log(good(`released #${number}, held by ${claim.holder}`));
|
|
2654
2910
|
}
|
|
2655
2911
|
async function drop(args) {
|
|
2656
|
-
const parsed = parse(args, dropUsage, dropOptions);
|
|
2912
|
+
const parsed = parse(args, dropUsage, dropOptions, { exits: dropExits });
|
|
2657
2913
|
const { values, positionals } = parsed;
|
|
2658
2914
|
const sessions = await liveSessions();
|
|
2659
2915
|
const nameFor = await claimant(values, sessions);
|
|
@@ -2693,7 +2949,7 @@ async function drop(args) {
|
|
|
2693
2949
|
}
|
|
2694
2950
|
|
|
2695
2951
|
// src/commands/ci.ts
|
|
2696
|
-
import
|
|
2952
|
+
import process26 from "process";
|
|
2697
2953
|
|
|
2698
2954
|
// src/git.ts
|
|
2699
2955
|
async function tagsAt(commit) {
|
|
@@ -2719,6 +2975,7 @@ var STAMP = /^\S+Z /;
|
|
|
2719
2975
|
var FAILED_STEP = /\u274C\s+Failure - Main /;
|
|
2720
2976
|
var STEP_TAIL = 30;
|
|
2721
2977
|
var TAIL = 40;
|
|
2978
|
+
var TOOL_WINDOW = 200;
|
|
2722
2979
|
function logLines(log) {
|
|
2723
2980
|
return log.split(`
|
|
2724
2981
|
`).map((line) => line.replace(STAMP, ""));
|
|
@@ -2744,7 +3001,7 @@ function excerpt(log) {
|
|
|
2744
3001
|
const parts = failedTests(lines);
|
|
2745
3002
|
for (const [index, line] of lines.entries()) {
|
|
2746
3003
|
if (FAILED_STEP.test(line))
|
|
2747
|
-
parts.push(lines.slice(Math.max(0, index - STEP_TAIL), index + 1).filter((text) => text.trim() !== "" && !text.startsWith(PASS) && !text.startsWith("::")).join(`
|
|
3004
|
+
parts.push(toolExcerpt(lines.slice(Math.max(0, index - TOOL_WINDOW), index)) ?? lines.slice(Math.max(0, index - STEP_TAIL), index + 1).filter((text) => text.trim() !== "" && !text.startsWith(PASS) && !text.startsWith("::")).join(`
|
|
2748
3005
|
`));
|
|
2749
3006
|
}
|
|
2750
3007
|
return parts.length === 0 ? lines.slice(-TAIL).join(`
|
|
@@ -2872,7 +3129,7 @@ async function failedJobsOf(run, repo) {
|
|
|
2872
3129
|
}
|
|
2873
3130
|
return failed;
|
|
2874
3131
|
}
|
|
2875
|
-
function
|
|
3132
|
+
function failureText2(failed, out = process.stderr) {
|
|
2876
3133
|
const problem = role("failed", out);
|
|
2877
3134
|
return failed.map((job) => `${problem(`job ${job.name} of ${job.workflow} failed`)}:
|
|
2878
3135
|
${job.excerpt}`).join(`
|
|
@@ -2892,8 +3149,8 @@ var usage2 = `ft ci [ref]
|
|
|
2892
3149
|
|
|
2893
3150
|
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.
|
|
2894
3151
|
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.
|
|
2895
|
-
--json prints {status, runs, failedJobs, url} on stdout, the progress going to stderr; --quiet prints only the announcement, the failures and the result
|
|
2896
|
-
|
|
3152
|
+
--json prints {status, runs, failedJobs, url} on stdout, the progress going to stderr; --quiet prints only the announcement, the failures and the result.`;
|
|
3153
|
+
var EXITS = [[0, "they pass"], [1, "one fails"], [2, "a timeout, a stalled queue or a commit not on the branch"]];
|
|
2897
3154
|
var options = {
|
|
2898
3155
|
branch: { type: "string", short: "b", description: "branch the commit is on, by default the one origin/HEAD names" },
|
|
2899
3156
|
workflow: { type: "string", short: "w", description: "only this workflow file, e.g. test.yml; by default every workflow a push starts" },
|
|
@@ -2923,7 +3180,7 @@ function settled(latest) {
|
|
|
2923
3180
|
return latest !== undefined && latest.every((run) => FINISHED.has(run.status)) && judge(latest, false, false).kind === "runs" ? latest : undefined;
|
|
2924
3181
|
}
|
|
2925
3182
|
async function ci2(args) {
|
|
2926
|
-
const parsed = parse(args, usage2, options);
|
|
3183
|
+
const parsed = parse(args, usage2, options, { exits: EXITS });
|
|
2927
3184
|
const { values, positionals } = parsed;
|
|
2928
3185
|
const branch = values.branch ?? await defaultBranch();
|
|
2929
3186
|
const giveUp = duration(values.timeout, "timeout", 30 * 60000, "m");
|
|
@@ -2959,7 +3216,7 @@ async function ci2(args) {
|
|
|
2959
3216
|
return;
|
|
2960
3217
|
}
|
|
2961
3218
|
const json = values.json === true;
|
|
2962
|
-
const live = takesControlCodes(
|
|
3219
|
+
const live = takesControlCodes(process26.stderr) && takesControlCodes(process26.stdout) && !json && values.quiet !== true;
|
|
2963
3220
|
const runs = await waitForCi({
|
|
2964
3221
|
tool: "ft ci",
|
|
2965
3222
|
short,
|
|
@@ -2985,8 +3242,8 @@ async function ci2(args) {
|
|
|
2985
3242
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
2986
3243
|
},
|
|
2987
3244
|
lines: (spinner, found, started) => [
|
|
2988
|
-
ciHeader(spinner, `CI on ${short}`, started,
|
|
2989
|
-
...(found ?? []).map((run) => ` ${runLine(run,
|
|
3245
|
+
ciHeader(spinner, `CI on ${short}`, started, process26.stderr),
|
|
3246
|
+
...(found ?? []).map((run) => ` ${runLine(run, process26.stderr, undefined, run.commit_sha.slice(0, 7))}`)
|
|
2990
3247
|
]
|
|
2991
3248
|
});
|
|
2992
3249
|
const status = overall(runs);
|
|
@@ -3003,7 +3260,7 @@ async function ci2(args) {
|
|
|
3003
3260
|
}
|
|
3004
3261
|
if (live) {
|
|
3005
3262
|
for (const run of runs)
|
|
3006
|
-
console.log(runLine(run,
|
|
3263
|
+
console.log(runLine(run, process26.stdout, undefined, run.commit_sha.slice(0, 7)));
|
|
3007
3264
|
}
|
|
3008
3265
|
if (status !== "failure") {
|
|
3009
3266
|
if (live)
|
|
@@ -3014,7 +3271,7 @@ async function ci2(args) {
|
|
|
3014
3271
|
for (const run of runs) {
|
|
3015
3272
|
if (run.status === "failure")
|
|
3016
3273
|
console.error(`
|
|
3017
|
-
${
|
|
3274
|
+
${failureText2(failed.filter((job) => job.run === run.id))}
|
|
3018
3275
|
|
|
3019
3276
|
run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from ${short} to ${run.commit_sha.slice(0, 7)}`}: ${run.html_url}`);
|
|
3020
3277
|
}
|
|
@@ -3022,7 +3279,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
3022
3279
|
}
|
|
3023
3280
|
|
|
3024
3281
|
// src/commands/digest.ts
|
|
3025
|
-
import
|
|
3282
|
+
import process27 from "process";
|
|
3026
3283
|
var RUNS_SCANNED = 50;
|
|
3027
3284
|
var TITLE_WIDTH2 = 70;
|
|
3028
3285
|
var SHOWN = 8;
|
|
@@ -3072,7 +3329,7 @@ async function quietly(read) {
|
|
|
3072
3329
|
}
|
|
3073
3330
|
}
|
|
3074
3331
|
async function staleTodos() {
|
|
3075
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3332
|
+
const bin = Bun.which("todo-scan", { PATH: process27.env.PATH ?? "" });
|
|
3076
3333
|
if (bin === null)
|
|
3077
3334
|
return [];
|
|
3078
3335
|
let found;
|
|
@@ -3094,8 +3351,8 @@ async function staleTodos() {
|
|
|
3094
3351
|
return [...byIssue.values()];
|
|
3095
3352
|
}
|
|
3096
3353
|
function claimLine(row, now) {
|
|
3097
|
-
const id = role("id",
|
|
3098
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
3354
|
+
const id = role("id", process27.stdout);
|
|
3355
|
+
return [id(`#${row.number}`), row.holder, paint(process27.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
|
|
3099
3356
|
}
|
|
3100
3357
|
function capped2(lines) {
|
|
3101
3358
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3106,13 +3363,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3106
3363
|
`) },
|
|
3107
3364
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3108
3365
|
`) },
|
|
3109
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
3366
|
+
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process27.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
|
|
3110
3367
|
`), TITLE_WIDTH2)}`) },
|
|
3111
3368
|
{ 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",
|
|
3369
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process27.stdout)(file.path)}`)) },
|
|
3113
3370
|
{ 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
3371
|
].filter((each) => each.count > 0);
|
|
3115
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
3372
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process27.stdout, process27.env, tone)}
|
|
3116
3373
|
${lines.join(`
|
|
3117
3374
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3118
3375
|
|
|
@@ -3121,16 +3378,15 @@ ${lines.join(`
|
|
|
3121
3378
|
var usage3 = `ft digest
|
|
3122
3379
|
|
|
3123
3380
|
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.
|
|
3124
|
-
A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH
|
|
3125
|
-
|
|
3126
|
-
Exits 0 when it summarised the repository, 1 when Forgejo cannot be read, 2 on a usage error.`;
|
|
3381
|
+
A section with nothing in it is left out, and the stale TODO comments need todo-scan on the PATH.`;
|
|
3382
|
+
var EXITS2 = [[0, "it summarised the repository"], [1, "Forgejo cannot be read"], [2, "a usage error"]];
|
|
3127
3383
|
var options2 = {
|
|
3128
3384
|
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)"),
|
|
3129
3385
|
watch: watchOption("the digest"),
|
|
3130
3386
|
...repoOption
|
|
3131
3387
|
};
|
|
3132
3388
|
async function digest(args) {
|
|
3133
|
-
const parsed = parse(args, usage3, options2);
|
|
3389
|
+
const parsed = parse(args, usage3, options2, { exits: EXITS2 });
|
|
3134
3390
|
const { values } = parsed;
|
|
3135
3391
|
if (values.watch !== undefined)
|
|
3136
3392
|
return watching(values.watch, async () => digest(withoutWatch(args)));
|
|
@@ -3199,9 +3455,8 @@ var tickUsage = `ft tick [<n>] <box>...
|
|
|
3199
3455
|
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.
|
|
3200
3456
|
With --closed, ticks instead every box opening with \`#<issue>\` whose issue is closed, as a release plan lists them.
|
|
3201
3457
|
|
|
3202
|
-
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
|
|
3203
|
-
|
|
3204
|
-
Exits 0 when it ticked the boxes, 1 when Forgejo refuses, 2 on a usage error or a box matching none or several.`;
|
|
3458
|
+
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.`;
|
|
3459
|
+
var tickExits = [[0, "it ticked the boxes"], [1, "Forgejo refuses"], [2, "a usage error or a box matching none or several"]];
|
|
3205
3460
|
var tickOptions = {
|
|
3206
3461
|
undo: { type: "boolean", short: "u", description: "untick them instead" },
|
|
3207
3462
|
closed: { type: "boolean", description: "tick the boxes listing a closed issue, no box to name" },
|
|
@@ -3216,7 +3471,7 @@ function tickedOrFail(number, run) {
|
|
|
3216
3471
|
}
|
|
3217
3472
|
}
|
|
3218
3473
|
async function tick(args) {
|
|
3219
|
-
const parsed = parse(args, tickUsage, tickOptions);
|
|
3474
|
+
const parsed = parse(args, tickUsage, tickOptions, { exits: tickExits });
|
|
3220
3475
|
const { values, positionals } = parsed;
|
|
3221
3476
|
const { number, rest: picks } = await targetIssue(positionals, values.repo, tickUsage);
|
|
3222
3477
|
if (values.closed === true && (picks.length > 0 || values.undo === true))
|
|
@@ -3253,9 +3508,8 @@ var fixedUsage = `ft fixed [<n>] [commit]...
|
|
|
3253
3508
|
|
|
3254
3509
|
Comments "Fixed in <sha>: <message>" on issue <n> and closes it, naming each commit given as "Fixed in <a>, <b> and <c>".
|
|
3255
3510
|
Without a commit it takes those on origin's default branch whose message names #<n>, and says which, or HEAD when none does.
|
|
3256
|
-
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
|
|
3257
|
-
|
|
3258
|
-
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.`;
|
|
3511
|
+
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.`;
|
|
3512
|
+
var fixedExits = [[0, "it closed the issue"], [1, "the issue is already closed, has boxes left or Forgejo refuses"], [2, "a usage error"]];
|
|
3259
3513
|
var fixedOptions = {
|
|
3260
3514
|
message: { type: "string", short: "m", description: 'the line after "Fixed in <sha>:"' },
|
|
3261
3515
|
tick: { type: "boolean", description: "tick the boxes left before closing" },
|
|
@@ -3296,7 +3550,7 @@ async function tickListings(closed, repo) {
|
|
|
3296
3550
|
}
|
|
3297
3551
|
}
|
|
3298
3552
|
async function fixed(args) {
|
|
3299
|
-
const parsed = parse(args, fixedUsage, fixedOptions);
|
|
3553
|
+
const parsed = parse(args, fixedUsage, fixedOptions, { exits: fixedExits });
|
|
3300
3554
|
const { values, positionals } = parsed;
|
|
3301
3555
|
const { number, rest } = await targetIssue(positionals, values.repo, fixedUsage);
|
|
3302
3556
|
const commits = await fixingCommits(number, rest);
|
|
@@ -3334,8 +3588,8 @@ var stateOptions = {
|
|
|
3334
3588
|
message: { type: "string", short: "m", description: "a comment posted first, saying why" },
|
|
3335
3589
|
...repoOption
|
|
3336
3590
|
};
|
|
3337
|
-
async function setState(args, usage, wanted) {
|
|
3338
|
-
const parsed = parse(args, usage, stateOptions);
|
|
3591
|
+
async function setState(args, usage, exits, wanted) {
|
|
3592
|
+
const parsed = parse(args, usage, stateOptions, { exits });
|
|
3339
3593
|
const { values, positionals } = parsed;
|
|
3340
3594
|
for (const number of issueNumbers(positionals, usage)) {
|
|
3341
3595
|
if ((await getIssue(number, values.repo)).state === wanted) {
|
|
@@ -3354,19 +3608,17 @@ async function setState(args, usage, wanted) {
|
|
|
3354
3608
|
}
|
|
3355
3609
|
var closeUsage = `ft close <n>... [-m <reason>]
|
|
3356
3610
|
|
|
3357
|
-
Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed
|
|
3358
|
-
|
|
3359
|
-
Exits 0 when every issue is closed, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3611
|
+
Closes issues without a fix, a duplicate or one dropped, posting the -m reason first. \`ft fixed\` closes one a commit fixed.`;
|
|
3612
|
+
var closeExits = [[0, "every issue is closed"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3360
3613
|
async function closeIssues(args) {
|
|
3361
|
-
return setState(args, closeUsage, "closed");
|
|
3614
|
+
return setState(args, closeUsage, closeExits, "closed");
|
|
3362
3615
|
}
|
|
3363
3616
|
var reopenUsage = `ft reopen <n>... [-m <reason>]
|
|
3364
3617
|
|
|
3365
|
-
Reopens closed issues, posting the -m reason first
|
|
3366
|
-
|
|
3367
|
-
Exits 0 when every issue is open, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3618
|
+
Reopens closed issues, posting the -m reason first.`;
|
|
3619
|
+
var reopenExits = [[0, "every issue is open"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3368
3620
|
async function reopenIssues(args) {
|
|
3369
|
-
return setState(args, reopenUsage, "open");
|
|
3621
|
+
return setState(args, reopenUsage, reopenExits, "open");
|
|
3370
3622
|
}
|
|
3371
3623
|
var LABEL_FLAGS = new Set(["-h", "--help"]);
|
|
3372
3624
|
var REPO_FLAGS = new Set(["-r", "--repo"]);
|
|
@@ -3389,12 +3641,11 @@ function labelChanges(args) {
|
|
|
3389
3641
|
}
|
|
3390
3642
|
var labelUsage = `ft label <n> [+]<label>... -<label>...
|
|
3391
3643
|
|
|
3392
|
-
Adds the labels named bare or with +, removes those named with -, then prints the issue's labels. A label the repository lacks is refused
|
|
3393
|
-
|
|
3394
|
-
Exits 0 when it changed the labels, 1 when Forgejo refuses, 2 on a usage error or a label the repository lacks.`;
|
|
3644
|
+
Adds the labels named bare or with +, removes those named with -, then prints the issue's labels. A label the repository lacks is refused.`;
|
|
3645
|
+
var labelExits = [[0, "it changed the labels"], [1, "Forgejo refuses"], [2, "a usage error or a label the repository lacks"]];
|
|
3395
3646
|
async function label(args) {
|
|
3396
3647
|
const changes = labelChanges(args);
|
|
3397
|
-
const parsed = parse(changes.rest, labelUsage, repoOption);
|
|
3648
|
+
const parsed = parse(changes.rest, labelUsage, repoOption, { exits: labelExits });
|
|
3398
3649
|
const { values, positionals } = parsed;
|
|
3399
3650
|
const number = issueNumber(positionals[0], labelUsage);
|
|
3400
3651
|
const add = [...positionals.slice(1), ...changes.add];
|
|
@@ -3416,9 +3667,8 @@ ${labelUsage}`);
|
|
|
3416
3667
|
// src/commands/issue-write.ts
|
|
3417
3668
|
var newUsage = `ft new -t <title> [-F <file>] [-L a,b] [-m <milestone>]
|
|
3418
3669
|
|
|
3419
|
-
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
|
|
3420
|
-
|
|
3421
|
-
Exits 0 when it created the issue, 1 when Forgejo refuses, 2 on a usage error or a label or milestone the repository lacks.`;
|
|
3670
|
+
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.`;
|
|
3671
|
+
var newExits = [[0, "it created the issue"], [1, "Forgejo refuses"], [2, "a usage error or a label or milestone the repository lacks"]];
|
|
3422
3672
|
var newOptions = {
|
|
3423
3673
|
title: { type: "string", short: "t", description: "the issue title" },
|
|
3424
3674
|
file: { type: "string", short: "F", description: "the description: a file, - for stdin" },
|
|
@@ -3432,7 +3682,7 @@ async function milestoneTitle(reference, repo) {
|
|
|
3432
3682
|
return reference.trim() === "" ? "" : (await findMilestone(reference.trim(), repo)).title;
|
|
3433
3683
|
}
|
|
3434
3684
|
async function newIssue(args) {
|
|
3435
|
-
const parsed = parse(args, newUsage, newOptions);
|
|
3685
|
+
const parsed = parse(args, newUsage, newOptions, { exits: newExits });
|
|
3436
3686
|
const { values } = parsed;
|
|
3437
3687
|
if (values.title === undefined || values.title.trim() === "")
|
|
3438
3688
|
fail(`give the issue a title with -t
|
|
@@ -3450,9 +3700,8 @@ var editUsage = `ft edit <n> [-t <title>] [-F <file> [--append]] [--add-box <tex
|
|
|
3450
3700
|
Replaces the title and/or the description of issue <n>, the description from -F <file> or from stdin with -F -.
|
|
3451
3701
|
-m moves it to a milestone given by title or id, and \`-m ''\` takes it out of its milestone.
|
|
3452
3702
|
--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.
|
|
3453
|
-
\`ft issue <n> --body\` prints the description to edit
|
|
3454
|
-
|
|
3455
|
-
Exits 0 when it edited the issue, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3703
|
+
\`ft issue <n> --body\` prints the description to edit.`;
|
|
3704
|
+
var editExits = [[0, "it edited the issue"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3456
3705
|
var editOptions = {
|
|
3457
3706
|
title: { type: "string", short: "t", description: "the new title" },
|
|
3458
3707
|
file: { type: "string", short: "F", description: "the new description: a file, - for stdin" },
|
|
@@ -3462,7 +3711,7 @@ var editOptions = {
|
|
|
3462
3711
|
...repoOption
|
|
3463
3712
|
};
|
|
3464
3713
|
async function edit(args) {
|
|
3465
|
-
const parsed = parse(args, editUsage, editOptions);
|
|
3714
|
+
const parsed = parse(args, editUsage, editOptions, { exits: editExits });
|
|
3466
3715
|
const { values, positionals } = parsed;
|
|
3467
3716
|
const number = issueNumber(positionals[0], editUsage);
|
|
3468
3717
|
const text = await noteText({ file: values.file });
|
|
@@ -3500,15 +3749,14 @@ ${text}` : body;
|
|
|
3500
3749
|
var commentUsage = `ft comment [<n>] [text]
|
|
3501
3750
|
|
|
3502
3751
|
Posts a comment on issue <n>: the text given, -F <file>, or stdin when neither is, so a heredoc needs no escaping.
|
|
3503
|
-
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
|
|
3504
|
-
|
|
3505
|
-
Exits 0 when it posted the comment, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3752
|
+
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.`;
|
|
3753
|
+
var commentExits = [[0, "it posted the comment"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3506
3754
|
var commentOptions = {
|
|
3507
3755
|
file: noteOptions.file,
|
|
3508
3756
|
...repoOption
|
|
3509
3757
|
};
|
|
3510
3758
|
async function commentOn(args) {
|
|
3511
|
-
const parsed = parse(args, commentUsage, commentOptions);
|
|
3759
|
+
const parsed = parse(args, commentUsage, commentOptions, { exits: commentExits });
|
|
3512
3760
|
const { values, positionals } = parsed;
|
|
3513
3761
|
const { number, rest } = await targetIssue(positionals, values.repo, commentUsage);
|
|
3514
3762
|
const given = rest.join(" ") || undefined;
|
|
@@ -3527,9 +3775,8 @@ var issueUsage = `ft issue [<n>...]
|
|
|
3527
3775
|
|
|
3528
3776
|
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.
|
|
3529
3777
|
With --body, prints only the raw description, to edit and give back to \`ft edit -F\`.
|
|
3530
|
-
With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none
|
|
3531
|
-
|
|
3532
|
-
Exits 0 when it printed them, 1 when an issue cannot be read, 2 on a usage error.`;
|
|
3778
|
+
With no number, prints the open issues this session holds (\`ft take\`), and exits 2 when it holds none.`;
|
|
3779
|
+
var issueExits = [[0, "it printed them"], [1, "an issue cannot be read"], [2, "a usage error"]];
|
|
3533
3780
|
var issueOptions = {
|
|
3534
3781
|
todo: { type: "boolean", short: "t", description: "only the header and the boxes left to tick" },
|
|
3535
3782
|
comments: { type: "boolean", short: "c", description: "add the comments, each with its author and age" },
|
|
@@ -3582,7 +3829,7 @@ function issueJson(found, comments, author) {
|
|
|
3582
3829
|
};
|
|
3583
3830
|
}
|
|
3584
3831
|
async function issue(args) {
|
|
3585
|
-
const parsed = parse(args, issueUsage, issueOptions);
|
|
3832
|
+
const parsed = parse(args, issueUsage, issueOptions, { exits: issueExits });
|
|
3586
3833
|
const { values, positionals } = parsed;
|
|
3587
3834
|
const held = positionals.length === 0 ? await heldIssues(values.repo) : [];
|
|
3588
3835
|
const numbers = held.length === 0 ? issueNumbers(positionals, issueUsage) : held;
|
|
@@ -3627,10 +3874,9 @@ async function issue(args) {
|
|
|
3627
3874
|
// src/commands/logs.ts
|
|
3628
3875
|
var usage4 = `ft logs <run id>
|
|
3629
3876
|
|
|
3630
|
-
Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step.
|
|
3631
|
-
With no failed job it prints every job's last lines; --full prints whole logs
|
|
3632
|
-
|
|
3633
|
-
Exits 0 when it printed the logs, 1 when Forgejo cannot be read, 2 on a usage error or a job the run lacks.`;
|
|
3877
|
+
Prints what the failed jobs of a run say went wrong: each failed bun test's output and the end of each failed step, cut to the errors when it is a tsc, eslint, vitest, playwright, phpstan or php-cs-fixer step.
|
|
3878
|
+
With no failed job it prints every job's last lines; --full prints whole logs.`;
|
|
3879
|
+
var EXITS3 = [[0, "it printed the logs"], [1, "Forgejo cannot be read"], [2, "a usage error or a job the run lacks"]];
|
|
3634
3880
|
var options3 = {
|
|
3635
3881
|
job: { type: "string", short: "j", description: "only this job, by name or id" },
|
|
3636
3882
|
full: { type: "boolean", short: "f", description: "the whole log, timestamps stripped" },
|
|
@@ -3644,7 +3890,7 @@ function pickJobs(jobs, wanted) {
|
|
|
3644
3890
|
return failed.length > 0 ? failed : jobs;
|
|
3645
3891
|
}
|
|
3646
3892
|
async function logs2(args) {
|
|
3647
|
-
const parsed = parse(args, usage4, options3);
|
|
3893
|
+
const parsed = parse(args, usage4, options3, { exits: EXITS3 });
|
|
3648
3894
|
const { values, positionals } = parsed;
|
|
3649
3895
|
if (positionals[0] === undefined)
|
|
3650
3896
|
fail("a run id is needed", 2, runHint("ft runs", "list them"));
|
|
@@ -3675,7 +3921,7 @@ ${await text(job)}`);
|
|
|
3675
3921
|
}
|
|
3676
3922
|
|
|
3677
3923
|
// src/commands/milestone.ts
|
|
3678
|
-
import
|
|
3924
|
+
import process28 from "process";
|
|
3679
3925
|
var TITLE_WIDTH3 = 60;
|
|
3680
3926
|
var LIST_LIMIT = 30;
|
|
3681
3927
|
var CONCURRENCY2 = 4;
|
|
@@ -3684,15 +3930,15 @@ function counts(milestone) {
|
|
|
3684
3930
|
}
|
|
3685
3931
|
function progressBar(milestone) {
|
|
3686
3932
|
const total = milestone.open_issues + milestone.closed_issues;
|
|
3687
|
-
return takesControlCodes(
|
|
3933
|
+
return takesControlCodes(process28.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
3688
3934
|
}
|
|
3689
3935
|
function milestoneCells(each, showState) {
|
|
3690
3936
|
const drawn = progressBar(each);
|
|
3691
3937
|
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] : []];
|
|
3692
3938
|
}
|
|
3693
3939
|
async function printWithIssues(list, repo) {
|
|
3694
|
-
const colors = paint(
|
|
3695
|
-
const id = role("id",
|
|
3940
|
+
const colors = paint(process28.stdout);
|
|
3941
|
+
const id = role("id", process28.stdout);
|
|
3696
3942
|
const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
3697
3943
|
const blocks = list.map((each, index) => {
|
|
3698
3944
|
const byNumber = (left, right) => left.number - right.number;
|
|
@@ -3703,7 +3949,7 @@ async function printWithIssues(list, repo) {
|
|
|
3703
3949
|
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
3704
3950
|
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
3705
3951
|
];
|
|
3706
|
-
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined,
|
|
3952
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process28.stdout, process28.env, "accent"), ...lines].join(`
|
|
3707
3953
|
`);
|
|
3708
3954
|
});
|
|
3709
3955
|
console.log(blocks.join(`
|
|
@@ -3712,9 +3958,8 @@ async function printWithIssues(list, repo) {
|
|
|
3712
3958
|
}
|
|
3713
3959
|
var listUsage = `ft milestones
|
|
3714
3960
|
|
|
3715
|
-
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
|
|
3716
|
-
|
|
3717
|
-
Exits 0 when it listed them, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3961
|
+
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.`;
|
|
3962
|
+
var listExits = [[0, "it listed them"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3718
3963
|
var listOptions = {
|
|
3719
3964
|
state: { type: "string", description: "open (the default), closed or all" },
|
|
3720
3965
|
issues: { type: "boolean", short: "i", description: "list the open and closed issues of each milestone by title" },
|
|
@@ -3723,7 +3968,7 @@ var listOptions = {
|
|
|
3723
3968
|
...repoOption
|
|
3724
3969
|
};
|
|
3725
3970
|
async function milestones(args) {
|
|
3726
|
-
const parsed = parse(args, listUsage, listOptions);
|
|
3971
|
+
const parsed = parse(args, listUsage, listOptions, { exits: listExits });
|
|
3727
3972
|
const { values } = parsed;
|
|
3728
3973
|
const state = values.state ?? "open";
|
|
3729
3974
|
if (state !== "open" && state !== "closed" && state !== "all")
|
|
@@ -3751,16 +3996,15 @@ async function milestones(args) {
|
|
|
3751
3996
|
}
|
|
3752
3997
|
var newUsage2 = `ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
|
|
3753
3998
|
|
|
3754
|
-
Creates a milestone through the API and prints its id. Without --due it has no due date
|
|
3755
|
-
|
|
3756
|
-
Exits 0 when it created the milestone, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
3999
|
+
Creates a milestone through the API and prints its id. Without --due it has no due date.`;
|
|
4000
|
+
var newExits2 = [[0, "it created the milestone"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3757
4001
|
var newOptions2 = {
|
|
3758
4002
|
description: { type: "string", short: "d", description: "the milestone description" },
|
|
3759
4003
|
due: { type: "string", description: "the due date, YYYY-MM-DD" },
|
|
3760
4004
|
...repoOption
|
|
3761
4005
|
};
|
|
3762
4006
|
async function create(args) {
|
|
3763
|
-
const parsed = parse(args, newUsage2, newOptions2);
|
|
4007
|
+
const parsed = parse(args, newUsage2, newOptions2, { exits: newExits2 });
|
|
3764
4008
|
const { values, positionals } = parsed;
|
|
3765
4009
|
const title = positionals.join(" ").trim();
|
|
3766
4010
|
if (title === "")
|
|
@@ -3774,15 +4018,14 @@ ${newUsage2}`);
|
|
|
3774
4018
|
}
|
|
3775
4019
|
var closeUsage2 = `ft milestone close <title|id> [--force]
|
|
3776
4020
|
|
|
3777
|
-
Closes a milestone, refused while issues are open in it, which it names. --force closes it with them left
|
|
3778
|
-
|
|
3779
|
-
Exits 0 when it closed the milestone, 1 when issues are open in it or Forgejo refuses, 2 on a usage error.`;
|
|
4021
|
+
Closes a milestone, refused while issues are open in it, which it names. --force closes it with them left.`;
|
|
4022
|
+
var closeExits2 = [[0, "it closed the milestone"], [1, "issues are open in it or Forgejo refuses"], [2, "a usage error"]];
|
|
3780
4023
|
var closeOptions = {
|
|
3781
4024
|
force: { type: "boolean", description: "close it with issues left open" },
|
|
3782
4025
|
...repoOption
|
|
3783
4026
|
};
|
|
3784
4027
|
async function closeOne(args) {
|
|
3785
|
-
const parsed = parse(args, closeUsage2, closeOptions);
|
|
4028
|
+
const parsed = parse(args, closeUsage2, closeOptions, { exits: closeExits2 });
|
|
3786
4029
|
const { values, positionals } = parsed;
|
|
3787
4030
|
const reference = positionals.join(" ").trim();
|
|
3788
4031
|
if (reference === "")
|
|
@@ -3808,16 +4051,15 @@ ft milestone new <title> [-d <text>] [--due <YYYY-MM-DD>]
|
|
|
3808
4051
|
ft milestone close <title|id> [--force]
|
|
3809
4052
|
|
|
3810
4053
|
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).
|
|
3811
|
-
\`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id
|
|
3812
|
-
|
|
3813
|
-
Exits 0 when it showed the milestone, 1 when it cannot be read, 2 on a usage error or an unknown milestone.`;
|
|
4054
|
+
\`ft milestone new\` and \`ft milestone close\` have their own --help; a milestone titled new or close is named by its id.`;
|
|
4055
|
+
var showExits = [[0, "it showed the milestone"], [1, "it cannot be read"], [2, "a usage error or an unknown milestone"]];
|
|
3814
4056
|
var showOptions = {
|
|
3815
4057
|
...limitOptions(LIST_LIMIT),
|
|
3816
4058
|
json: jsonOption("the milestone (id, title, state, description, open, closed, due) and its open issues as `ft board --json` lists them"),
|
|
3817
4059
|
...repoOption
|
|
3818
4060
|
};
|
|
3819
4061
|
async function show(args) {
|
|
3820
|
-
const parsed = parse(args, showUsage, showOptions);
|
|
4062
|
+
const parsed = parse(args, showUsage, showOptions, { exits: showExits });
|
|
3821
4063
|
const { values, positionals } = parsed;
|
|
3822
4064
|
const reference = positionals.join(" ").trim();
|
|
3823
4065
|
if (reference === "")
|
|
@@ -3904,16 +4146,14 @@ var addUsage = `ft plan add <plan> <n>... [--section "Bugs:"]
|
|
|
3904
4146
|
|
|
3905
4147
|
Lists each issue <n> as \`- [ ] #<n> <title>\` in the checklist of issue <plan>, skipping those already listed.
|
|
3906
4148
|
Lines go under --section, created at the end of the body when missing, or else after the checklist's last box.
|
|
3907
|
-
The body is read again just before it is written, so an edit made meanwhile is kept
|
|
3908
|
-
|
|
3909
|
-
Exits 0 when it listed the issues, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
4149
|
+
The body is read again just before it is written, so an edit made meanwhile is kept.`;
|
|
4150
|
+
var addExits = [[0, "it listed the issues"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3910
4151
|
var carryUsage = `ft plan carry <from> <to> [--section "Carried from 1.71.0:"]
|
|
3911
4152
|
|
|
3912
4153
|
Copies the unticked \`#<n>\` lines of issue <from> into issue <to>, skipping those <to> already lists.
|
|
3913
4154
|
Lines go under --section, created at the end of the body when missing, or else after the checklist's last box.
|
|
3914
|
-
The body is read again just before it is written, so an edit made meanwhile is kept
|
|
3915
|
-
|
|
3916
|
-
Exits 0 when it copied the lines, 1 when Forgejo refuses, 2 on a usage error.`;
|
|
4155
|
+
The body is read again just before it is written, so an edit made meanwhile is kept.`;
|
|
4156
|
+
var carryExits = [[0, "it copied the lines"], [1, "Forgejo refuses"], [2, "a usage error"]];
|
|
3917
4157
|
var options4 = {
|
|
3918
4158
|
section: { type: "string", short: "s", description: 'the heading the lines go under, e.g. "Bugs:"' },
|
|
3919
4159
|
...repoOption
|
|
@@ -3926,7 +4166,7 @@ var plan = {
|
|
|
3926
4166
|
}
|
|
3927
4167
|
};
|
|
3928
4168
|
async function add(args) {
|
|
3929
|
-
const parsed = parse(args, addUsage, options4);
|
|
4169
|
+
const parsed = parse(args, addUsage, options4, { exits: addExits });
|
|
3930
4170
|
const { section, repo } = parsed.values;
|
|
3931
4171
|
const [target, ...listed] = parsed.positionals;
|
|
3932
4172
|
const planNumber = issueNumber(target, addUsage);
|
|
@@ -3947,7 +4187,7 @@ ${addUsage}`);
|
|
|
3947
4187
|
return 0;
|
|
3948
4188
|
}
|
|
3949
4189
|
async function carry(args) {
|
|
3950
|
-
const parsed = parse(args, carryUsage, options4);
|
|
4190
|
+
const parsed = parse(args, carryUsage, options4, { exits: carryExits });
|
|
3951
4191
|
const { section, repo } = parsed.values;
|
|
3952
4192
|
const from = issueNumber(parsed.positionals[0], carryUsage);
|
|
3953
4193
|
const to = issueNumber(parsed.positionals[1], carryUsage);
|
|
@@ -3969,15 +4209,15 @@ function report2(plan, added, skipped) {
|
|
|
3969
4209
|
|
|
3970
4210
|
// src/commands/release.ts
|
|
3971
4211
|
import { basename as basename3, join as join11 } from "path";
|
|
3972
|
-
import
|
|
4212
|
+
import process30 from "process";
|
|
3973
4213
|
var {$: $2 } = globalThis.Bun;
|
|
3974
4214
|
|
|
3975
4215
|
// src/commands/watch.ts
|
|
3976
4216
|
var usage5 = `ft watch [--after <id>]
|
|
3977
4217
|
|
|
3978
4218
|
Waits for runs to finish: those newer than run <id>, or else the ones in progress now.
|
|
3979
|
-
Prints nothing but failures and each run's final status with --quiet, and a JSON result with --json
|
|
3980
|
-
|
|
4219
|
+
Prints nothing but failures and each run's final status with --quiet, and a JSON result with --json.`;
|
|
4220
|
+
var EXITS4 = [[0, "every one passed or was skipped"], [1, "one failed or was cancelled"], [2, "a timeout or a stalled queue"]];
|
|
3981
4221
|
var options5 = {
|
|
3982
4222
|
after: { type: "string", short: "a", description: "watch the runs newer than this run id, as `ft runs --json` gives it" },
|
|
3983
4223
|
timeout: { type: "string", short: "t", description: "how long before giving up (15m), a bare number in minutes" },
|
|
@@ -4032,7 +4272,7 @@ async function followRuns(pick, timeout, repo, idle, out = process.stdout, mode
|
|
|
4032
4272
|
failedJobs.push(...jobs);
|
|
4033
4273
|
if (!json)
|
|
4034
4274
|
console.error(`
|
|
4035
|
-
${
|
|
4275
|
+
${failureText2(jobs)}
|
|
4036
4276
|
|
|
4037
4277
|
${run.html_url}`);
|
|
4038
4278
|
failed.add(run.id);
|
|
@@ -4081,7 +4321,7 @@ ${run.html_url}`);
|
|
|
4081
4321
|
}
|
|
4082
4322
|
}
|
|
4083
4323
|
async function watch2(args) {
|
|
4084
|
-
const parsed = parse(args, usage5, options5);
|
|
4324
|
+
const parsed = parse(args, usage5, options5, { exits: EXITS4 });
|
|
4085
4325
|
const { values } = parsed;
|
|
4086
4326
|
const timeout = duration(values.timeout, "timeout", 15 * 60000, "m");
|
|
4087
4327
|
const json = values.json === true;
|
|
@@ -4207,12 +4447,12 @@ async function publishable() {
|
|
|
4207
4447
|
|
|
4208
4448
|
// src/commands/release-plan.ts
|
|
4209
4449
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4210
|
-
import
|
|
4450
|
+
import process29 from "process";
|
|
4211
4451
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4212
4452
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4213
4453
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4214
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4215
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4454
|
+
const name = pkg?.name ?? basename2(dir ?? process29.cwd());
|
|
4455
|
+
const where = dir === undefined ? "" : ` in ${relative(process29.cwd(), dir) || "."}`;
|
|
4216
4456
|
let version;
|
|
4217
4457
|
let bump;
|
|
4218
4458
|
if (level === undefined) {
|
|
@@ -4342,8 +4582,8 @@ Cuts a release from the default branch: first the commit it sits on is pushed an
|
|
|
4342
4582
|
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.
|
|
4343
4583
|
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.
|
|
4344
4584
|
--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.
|
|
4345
|
-
--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
|
|
4346
|
-
|
|
4585
|
+
--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.`;
|
|
4586
|
+
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"]];
|
|
4347
4587
|
var options6 = {
|
|
4348
4588
|
tagged: { type: "boolean", description: "push the version commit and tag already at HEAD instead of bumping" },
|
|
4349
4589
|
package: { type: "string", short: "p", description: "workspace folder to release, a path or a name under packages/, several separated by commas" },
|
|
@@ -4354,7 +4594,7 @@ var options6 = {
|
|
|
4354
4594
|
json: jsonOption("what was released and how its runs ended")
|
|
4355
4595
|
};
|
|
4356
4596
|
async function release(args) {
|
|
4357
|
-
const parsed = parse(args, usage6, options6);
|
|
4597
|
+
const parsed = parse(args, usage6, options6, { exits: EXITS5 });
|
|
4358
4598
|
const { values, positionals } = parsed;
|
|
4359
4599
|
const json = values.json === true;
|
|
4360
4600
|
const say = json ? console.error : console.log;
|
|
@@ -4457,7 +4697,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4457
4697
|
if (late !== undefined)
|
|
4458
4698
|
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));
|
|
4459
4699
|
say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
|
|
4460
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ?
|
|
4700
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process30.stderr : process30.stdout, { json });
|
|
4461
4701
|
if (followed.code !== 0) {
|
|
4462
4702
|
report();
|
|
4463
4703
|
return followed.code;
|
|
@@ -4492,9 +4732,8 @@ var usage7 = `ft remote [--fix]
|
|
|
4492
4732
|
|
|
4493
4733
|
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\`.
|
|
4494
4734
|
--fix switches every alias URL to \`git@<host>:<owner>/<repo>.git\` and proves it with \`git ls-remote\`.
|
|
4495
|
-
The host comes from --host, else \`remoteHost\` in ~/.config/kaynooo-cli/ft.json; with neither, it checks nothing
|
|
4496
|
-
|
|
4497
|
-
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.`;
|
|
4735
|
+
The host comes from --host, else \`remoteHost\` in ~/.config/kaynooo-cli/ft.json; with neither, it checks nothing.`;
|
|
4736
|
+
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"]];
|
|
4498
4737
|
var options7 = {
|
|
4499
4738
|
host: { type: "string", description: "the Forgejo ssh host, instead of remoteHost in ~/.config/kaynooo-cli/ft.json" },
|
|
4500
4739
|
fix: { type: "boolean", description: "rewrite the alias URLs" }
|
|
@@ -4528,7 +4767,7 @@ function originHost2(url) {
|
|
|
4528
4767
|
return parseSshRemote(url)?.host ?? (URL.canParse(url) ? new URL(url).hostname : undefined);
|
|
4529
4768
|
}
|
|
4530
4769
|
async function remote(args, home) {
|
|
4531
|
-
const { values } = parse(args, usage7, options7);
|
|
4770
|
+
const { values } = parse(args, usage7, options7, { exits: EXITS6 });
|
|
4532
4771
|
const host = values.host ?? (await loadSettings(home)).remoteHost;
|
|
4533
4772
|
if (host === undefined) {
|
|
4534
4773
|
note(`no Forgejo host to check origin against: pass --host, or set "remoteHost" in ${settingsPath(home)}`);
|
|
@@ -4588,9 +4827,8 @@ var usage8 = `ft runs [--sha <ref>]
|
|
|
4588
4827
|
|
|
4589
4828
|
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).
|
|
4590
4829
|
|
|
4591
|
-
--open also opens the newest run listed in the browser
|
|
4592
|
-
|
|
4593
|
-
Exits 0 when it listed them, 1 when Forgejo or git cannot be read, 2 on a usage error.`;
|
|
4830
|
+
--open also opens the newest run listed in the browser.`;
|
|
4831
|
+
var EXITS7 = [[0, "it listed them"], [1, "Forgejo or git cannot be read"], [2, "a usage error"]];
|
|
4594
4832
|
var DEFAULT_LIMIT = 10;
|
|
4595
4833
|
var options8 = {
|
|
4596
4834
|
...limitOptions(DEFAULT_LIMIT),
|
|
@@ -4606,7 +4844,7 @@ async function onCommit(sha, repo) {
|
|
|
4606
4844
|
return { runs: found, total: found.length };
|
|
4607
4845
|
}
|
|
4608
4846
|
async function runs(args) {
|
|
4609
|
-
const parsed = parse(args, usage8, options8);
|
|
4847
|
+
const parsed = parse(args, usage8, options8, { exits: EXITS7 });
|
|
4610
4848
|
const { values } = parsed;
|
|
4611
4849
|
const limit = limitOf(values, DEFAULT_LIMIT);
|
|
4612
4850
|
const { runs: found, total } = values.sha === undefined ? await runsListing(limit, values.repo, values.workflow) : await onCommit(values.sha, values.repo);
|
|
@@ -4634,7 +4872,7 @@ async function runs(args) {
|
|
|
4634
4872
|
}
|
|
4635
4873
|
|
|
4636
4874
|
// src/cli.ts
|
|
4637
|
-
|
|
4875
|
+
process31.exitCode = await runCli({
|
|
4638
4876
|
name: "ft",
|
|
4639
4877
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4640
4878
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|