@kaynooo/cli-forgejo 0.28.1 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli.js +180 -132
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ Needs [tea](https://gitea.com/gitea/tea) logged in to the Forgejo instance (`tea
|
|
|
33
33
|
| `ft milestone <title\|id>` | shows a milestone's open issues as `ft board` does (available, taken, claimed by one gone); `ft milestone new <title> [-d text] [--due YYYY-MM-DD]` creates one through the API, sending no `due_on` unless `--due` is given, never a zero date; `ft milestone close <m>` refuses while issues are open in it, naming them, unless `--force` |
|
|
34
34
|
| `ft remote [--fix]` | switches an origin using an ssh alias (`forgejo:owner/repo`) to `git@<host>:owner/repo.git`, which tea matches; the host comes from `--host` or `remoteHost` in `~/.config/kaynooo-cli/ft.json` (`{"remoteHost": "git.example.com"}`; the older `~/.config/ft/config.json` is read while the new file is missing), and with neither it checks nothing |
|
|
35
35
|
|
|
36
|
+
`concurrency` (a positive whole number) in the same `ft.json` sets how many forge calls run at once when `ft` reads comments (8 by default) and milestone issues (4 by default).
|
|
37
|
+
|
|
36
38
|
`ft <command> --help` lists each command's options. Waiting commands show one line per run with how long it has been waiting or running (`● running for 1m 12s`), redrawn in place on a terminal and left at its last status with the time it took (`✓ success in 3m 2s`), and a line per status change in a log or a pipe; they exit 0 when the runs pass, 1 when one fails, 2 on a timeout, a stalled queue or bad usage; the other commands exit 0 when done, 1 when Forgejo refuses or a check fails, 2 on a usage error.
|
|
37
39
|
|
|
38
40
|
## CI
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process29 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
7
|
import process10 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
@@ -124,7 +124,7 @@ function Fe(r = {}) {
|
|
|
124
124
|
var o = Fe();
|
|
125
125
|
|
|
126
126
|
// ../kit/src/theme.ts
|
|
127
|
-
import { existsSync as existsSync3, readFileSync, statSync } from "fs";
|
|
127
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } from "fs";
|
|
128
128
|
import { homedir as homedir2 } from "os";
|
|
129
129
|
import { join as join3, resolve as resolve2 } from "path";
|
|
130
130
|
import process5 from "process";
|
|
@@ -145,7 +145,7 @@ function findUp(names, from = process3.cwd(), stop = () => false) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// ../kit/src/user-config.ts
|
|
148
|
-
import { existsSync as existsSync2 } from "fs";
|
|
148
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
149
149
|
import { homedir } from "os";
|
|
150
150
|
import { join as join2 } from "path";
|
|
151
151
|
import process4 from "process";
|
|
@@ -163,6 +163,21 @@ function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
|
163
163
|
const base = configBase(where);
|
|
164
164
|
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
165
165
|
}
|
|
166
|
+
function readUserConfig(bin, where = {}, legacy = []) {
|
|
167
|
+
const path = userConfigReadPath(bin, legacy, where);
|
|
168
|
+
if (!existsSync2(path))
|
|
169
|
+
return {};
|
|
170
|
+
try {
|
|
171
|
+
const parsed = Bun.JSONC.parse(readFileSync(path, "utf8"));
|
|
172
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : {};
|
|
173
|
+
} catch {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function configuredNumber(bin, key, fallback, where = {}, legacy = []) {
|
|
178
|
+
const value = readUserConfig(bin, where, legacy)[key];
|
|
179
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : fallback;
|
|
180
|
+
}
|
|
166
181
|
|
|
167
182
|
// ../kit/src/theme.ts
|
|
168
183
|
function toLinear(channel) {
|
|
@@ -264,7 +279,7 @@ function readThemeFile(path, warn) {
|
|
|
264
279
|
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
265
280
|
return;
|
|
266
281
|
}
|
|
267
|
-
const parsed = JSON.parse(
|
|
282
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
268
283
|
if (isRecord(parsed))
|
|
269
284
|
return parsed;
|
|
270
285
|
warn(`${path} is not a JSON object, theme ignored`);
|
|
@@ -403,6 +418,9 @@ function note(text, detail) {
|
|
|
403
418
|
function warn(text, detail) {
|
|
404
419
|
console.error(marked("warn", text, process6.stderr, detail));
|
|
405
420
|
}
|
|
421
|
+
function problem(text, detail) {
|
|
422
|
+
console.error(marked("problem", text, process6.stderr, detail));
|
|
423
|
+
}
|
|
406
424
|
function role(name, stream, env = process6.env) {
|
|
407
425
|
const colors = paint(stream, env);
|
|
408
426
|
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name], env) : colors;
|
|
@@ -879,11 +897,35 @@ function nearestOption(message, options, allowNegative) {
|
|
|
879
897
|
const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
|
|
880
898
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
881
899
|
}
|
|
882
|
-
// ../kit/src/
|
|
900
|
+
// ../kit/src/argv.ts
|
|
901
|
+
import { readFileSync as readFileSync3, realpathSync } from "fs";
|
|
902
|
+
import { resolve as resolve3 } from "path";
|
|
883
903
|
import process11 from "process";
|
|
904
|
+
function commandLine() {
|
|
905
|
+
try {
|
|
906
|
+
return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
|
|
907
|
+
} catch {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
function realPath(word) {
|
|
912
|
+
try {
|
|
913
|
+
return realpathSync(resolve3(word));
|
|
914
|
+
} catch {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
|
|
919
|
+
const target = script === undefined ? undefined : realPath(script) ?? script;
|
|
920
|
+
const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
|
|
921
|
+
const after = at === -1 ? [] : cmdline.slice(at + 1);
|
|
922
|
+
return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
|
|
923
|
+
}
|
|
924
|
+
// ../kit/src/chart.ts
|
|
925
|
+
import process12 from "process";
|
|
884
926
|
var FILLED = "\u2501";
|
|
885
927
|
var EMPTY = "\u2500";
|
|
886
|
-
function bar(ratio, { width = 20, stream =
|
|
928
|
+
function bar(ratio, { width = 20, stream = process12.stdout, env = process12.env } = {}) {
|
|
887
929
|
if (outputMode(stream, env) === "agent")
|
|
888
930
|
return formatPercent(Math.min(1, Math.max(0, ratio)));
|
|
889
931
|
const colors = paint(stream, env);
|
|
@@ -894,12 +936,12 @@ function bar(ratio, { width = 20, stream = process11.stdout, env = process11.env
|
|
|
894
936
|
return `${shaded(theme, colors, theme.glyphs.bar, filled, width, env)}${colors.dim(theme.glyphs.bar.repeat(width - filled))}`;
|
|
895
937
|
}
|
|
896
938
|
// ../kit/src/progress.ts
|
|
897
|
-
import
|
|
939
|
+
import process14 from "process";
|
|
898
940
|
|
|
899
941
|
// ../kit/src/process.ts
|
|
900
942
|
import { constants } from "os";
|
|
901
|
-
import { resolve as
|
|
902
|
-
import
|
|
943
|
+
import { resolve as resolve4 } from "path";
|
|
944
|
+
import process13 from "process";
|
|
903
945
|
var KILL_GRACE_MS = 2000;
|
|
904
946
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
905
947
|
var SCHEME = /^[a-z][\w+.-]+:/i;
|
|
@@ -923,7 +965,7 @@ function holdSignals(cleanup) {
|
|
|
923
965
|
},
|
|
924
966
|
release: () => {
|
|
925
967
|
for (const signal of SIGNALS)
|
|
926
|
-
|
|
968
|
+
process13.off(signal, onSignal);
|
|
927
969
|
}
|
|
928
970
|
};
|
|
929
971
|
function onSignal(signal) {
|
|
@@ -936,16 +978,16 @@ function holdSignals(cleanup) {
|
|
|
936
978
|
return;
|
|
937
979
|
held.release();
|
|
938
980
|
cleanup(signal);
|
|
939
|
-
|
|
981
|
+
process13.kill(process13.pid, signal);
|
|
940
982
|
}
|
|
941
983
|
for (const signal of SIGNALS)
|
|
942
|
-
|
|
984
|
+
process13.on(signal, onSignal);
|
|
943
985
|
return held;
|
|
944
986
|
}
|
|
945
|
-
function openUrl(target, env =
|
|
987
|
+
function openUrl(target, env = process13.env, platform = process13.platform) {
|
|
946
988
|
const opener = env.BROWSER === undefined || env.BROWSER === "" ? OPENERS[platform] ?? ["xdg-open"] : [env.BROWSER];
|
|
947
989
|
try {
|
|
948
|
-
Bun.spawn([...opener, SCHEME.test(target) ? target :
|
|
990
|
+
Bun.spawn([...opener, SCHEME.test(target) ? target : resolve4(target)], { env, stdio: ["ignore", "ignore", "ignore"] }).unref();
|
|
949
991
|
return true;
|
|
950
992
|
} catch {
|
|
951
993
|
return false;
|
|
@@ -979,7 +1021,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
979
1021
|
return;
|
|
980
1022
|
try {
|
|
981
1023
|
if (grouped)
|
|
982
|
-
|
|
1024
|
+
process13.kill(-proc.pid, killing);
|
|
983
1025
|
else
|
|
984
1026
|
proc.kill(killing);
|
|
985
1027
|
} catch {}
|
|
@@ -1050,15 +1092,14 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
1050
1092
|
// ../kit/src/progress.ts
|
|
1051
1093
|
var FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1052
1094
|
var FRAME_MS = 200;
|
|
1053
|
-
var
|
|
1054
|
-
var LINE_UP = "\x1B[1A\x1B[2K";
|
|
1095
|
+
var CLEAR_BELOW = "\r\x1B[J";
|
|
1055
1096
|
var ESC = String.fromCharCode(27);
|
|
1056
1097
|
var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x7E]|\\][^\\u0007${ESC}]*(?:\\u0007|${ESC}\\\\))`, "y");
|
|
1057
1098
|
var RESET_STYLE = `${ESC}[0m`;
|
|
1058
1099
|
var CTRL_C = 3;
|
|
1059
1100
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
1060
1101
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
1061
|
-
function liveRegion(render, stream =
|
|
1102
|
+
function liveRegion(render, stream = process14.stderr, env = process14.env) {
|
|
1062
1103
|
if (!takesControlCodes(stream, env))
|
|
1063
1104
|
return { redraw: () => {
|
|
1064
1105
|
return;
|
|
@@ -1068,13 +1109,15 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1068
1109
|
} };
|
|
1069
1110
|
const write = stream.write.bind(stream);
|
|
1070
1111
|
let frame = 0;
|
|
1071
|
-
let drawn =
|
|
1072
|
-
const columns = () =>
|
|
1073
|
-
|
|
1112
|
+
let drawn = false;
|
|
1113
|
+
const columns = () => {
|
|
1114
|
+
const now = stream.getWindowSize?.()[0] ?? stream.columns;
|
|
1115
|
+
return now === undefined || now === 0 ? 80 : now;
|
|
1116
|
+
};
|
|
1074
1117
|
const clear = () => {
|
|
1075
|
-
if (drawn
|
|
1076
|
-
write(
|
|
1077
|
-
drawn =
|
|
1118
|
+
if (drawn)
|
|
1119
|
+
write(CLEAR_BELOW);
|
|
1120
|
+
drawn = false;
|
|
1078
1121
|
};
|
|
1079
1122
|
const draw = () => {
|
|
1080
1123
|
const width = columns() - 1;
|
|
@@ -1084,9 +1127,9 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1084
1127
|
clear();
|
|
1085
1128
|
return;
|
|
1086
1129
|
}
|
|
1087
|
-
write(`${
|
|
1088
|
-
`)}`);
|
|
1089
|
-
drawn =
|
|
1130
|
+
write(`${CLEAR_BELOW}${lines.join(`
|
|
1131
|
+
`)}${lines.length > 1 ? `\x1B[${lines.length - 1}A` : ""}\r`);
|
|
1132
|
+
drawn = true;
|
|
1090
1133
|
};
|
|
1091
1134
|
const timer = setInterval(draw, FRAME_MS);
|
|
1092
1135
|
stream.on?.("resize", draw);
|
|
@@ -1103,11 +1146,11 @@ function liveRegion(render, stream = process13.stderr, env = process13.env) {
|
|
|
1103
1146
|
clear();
|
|
1104
1147
|
restore();
|
|
1105
1148
|
release();
|
|
1106
|
-
|
|
1149
|
+
process14.off("exit", onExit);
|
|
1107
1150
|
signals.release();
|
|
1108
1151
|
}
|
|
1109
1152
|
timer.unref();
|
|
1110
|
-
|
|
1153
|
+
process14.on("exit", onExit);
|
|
1111
1154
|
return {
|
|
1112
1155
|
redraw: draw,
|
|
1113
1156
|
print: (text) => {
|
|
@@ -1146,14 +1189,14 @@ function cutToWidth(line, width) {
|
|
|
1146
1189
|
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
1147
1190
|
}
|
|
1148
1191
|
function swallowInput() {
|
|
1149
|
-
const input =
|
|
1192
|
+
const input = process14.stdin;
|
|
1150
1193
|
if (!input.isTTY)
|
|
1151
1194
|
return () => {
|
|
1152
1195
|
return;
|
|
1153
1196
|
};
|
|
1154
1197
|
const onData = (data) => {
|
|
1155
1198
|
if (data.includes(CTRL_C))
|
|
1156
|
-
|
|
1199
|
+
process14.kill(process14.pid, "SIGINT");
|
|
1157
1200
|
};
|
|
1158
1201
|
input.setRawMode(true);
|
|
1159
1202
|
input.on("data", onData);
|
|
@@ -1169,7 +1212,7 @@ function swallowInput() {
|
|
|
1169
1212
|
};
|
|
1170
1213
|
}
|
|
1171
1214
|
function interceptOutput(clear) {
|
|
1172
|
-
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [
|
|
1215
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process14.stdout, "write"], [process14.stderr, "write"]];
|
|
1173
1216
|
const wrapped = targets.map(([target, name]) => {
|
|
1174
1217
|
const original = Reflect.get(target, name);
|
|
1175
1218
|
const wrapper = (...args) => {
|
|
@@ -1188,11 +1231,11 @@ function interceptOutput(clear) {
|
|
|
1188
1231
|
}
|
|
1189
1232
|
|
|
1190
1233
|
// ../kit/src/tool.ts
|
|
1191
|
-
import
|
|
1234
|
+
import process15 from "process";
|
|
1192
1235
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
1193
1236
|
function cwdGone() {
|
|
1194
1237
|
try {
|
|
1195
|
-
|
|
1238
|
+
process15.cwd();
|
|
1196
1239
|
return false;
|
|
1197
1240
|
} catch {
|
|
1198
1241
|
return true;
|
|
@@ -1219,7 +1262,7 @@ function isPermanentFailure(error) {
|
|
|
1219
1262
|
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1220
1263
|
let ran;
|
|
1221
1264
|
try {
|
|
1222
|
-
ran = await runCommand(argv, { env:
|
|
1265
|
+
ran = await runCommand(argv, { env: process15.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1223
1266
|
} catch (error) {
|
|
1224
1267
|
throw spawnFailure(label, error);
|
|
1225
1268
|
}
|
|
@@ -1311,15 +1354,15 @@ function ciHeader(spinner, label, startedAt, out) {
|
|
|
1311
1354
|
return `${spinner} ${label} ${paint(out).dim(formatElapsed(Date.now() - startedAt))}`;
|
|
1312
1355
|
}
|
|
1313
1356
|
// ../kit/src/cli.ts
|
|
1314
|
-
import { readFileSync as
|
|
1357
|
+
import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
|
|
1315
1358
|
import { dirname as dirname3, join as join5 } from "path";
|
|
1316
|
-
import
|
|
1359
|
+
import process17 from "process";
|
|
1317
1360
|
|
|
1318
1361
|
// ../kit/src/usage.ts
|
|
1319
1362
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1320
1363
|
import { homedir as homedir3 } from "os";
|
|
1321
1364
|
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1322
|
-
import
|
|
1365
|
+
import process16 from "process";
|
|
1323
1366
|
|
|
1324
1367
|
// ../kit/src/logs.ts
|
|
1325
1368
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1333,14 +1376,14 @@ var usageError;
|
|
|
1333
1376
|
function noteUsageError(message) {
|
|
1334
1377
|
usageError = message;
|
|
1335
1378
|
}
|
|
1336
|
-
function stateHome(env =
|
|
1379
|
+
function stateHome(env = process16.env) {
|
|
1337
1380
|
const dir = env.XDG_STATE_HOME;
|
|
1338
1381
|
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1339
1382
|
}
|
|
1340
|
-
function usagePath(env =
|
|
1383
|
+
function usagePath(env = process16.env) {
|
|
1341
1384
|
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1342
1385
|
}
|
|
1343
|
-
function usageRecorded(env =
|
|
1386
|
+
function usageRecorded(env = process16.env) {
|
|
1344
1387
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1345
1388
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1346
1389
|
}
|
|
@@ -1354,7 +1397,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1354
1397
|
usageError = undefined;
|
|
1355
1398
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1356
1399
|
}
|
|
1357
|
-
function recordUsage(entry, env =
|
|
1400
|
+
function recordUsage(entry, env = process16.env) {
|
|
1358
1401
|
if (!usageRecorded(env))
|
|
1359
1402
|
return;
|
|
1360
1403
|
try {
|
|
@@ -1445,8 +1488,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1445
1488
|
`);
|
|
1446
1489
|
}
|
|
1447
1490
|
function printError(prefix, message, hint, cause) {
|
|
1448
|
-
const colors = paint(
|
|
1449
|
-
const styled = takesControlCodes(
|
|
1491
|
+
const colors = paint(process17.stderr);
|
|
1492
|
+
const styled = takesControlCodes(process17.stderr);
|
|
1450
1493
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1451
1494
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1452
1495
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1456,8 +1499,8 @@ function runHint(command, effect) {
|
|
|
1456
1499
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1457
1500
|
}
|
|
1458
1501
|
function printHint(hint) {
|
|
1459
|
-
const colors = paint(
|
|
1460
|
-
console.error(` ${takesControlCodes(
|
|
1502
|
+
const colors = paint(process17.stderr);
|
|
1503
|
+
console.error(` ${takesControlCodes(process17.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1461
1504
|
}
|
|
1462
1505
|
function printJsonError(message, hint, cause) {
|
|
1463
1506
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1496,11 +1539,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1496
1539
|
}
|
|
1497
1540
|
}
|
|
1498
1541
|
if (name === undefined && level.path.length > 1) {
|
|
1499
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1542
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stderr));
|
|
1500
1543
|
return 2;
|
|
1501
1544
|
}
|
|
1502
1545
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1503
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1546
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process17.stdout));
|
|
1504
1547
|
return 0;
|
|
1505
1548
|
}
|
|
1506
1549
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1556,24 +1599,24 @@ function candidateLine(candidate) {
|
|
|
1556
1599
|
}
|
|
1557
1600
|
function positionalBeingTyped(before, { options, positionals }) {
|
|
1558
1601
|
const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
|
|
1559
|
-
|
|
1602
|
+
const typed = [];
|
|
1560
1603
|
let at = 0;
|
|
1561
1604
|
while (at < before.length) {
|
|
1562
1605
|
const word = before[at];
|
|
1563
1606
|
if (word === "--") {
|
|
1564
|
-
|
|
1607
|
+
typed.push(...before.slice(at + 1));
|
|
1565
1608
|
break;
|
|
1566
1609
|
}
|
|
1567
1610
|
if (!word.startsWith("-"))
|
|
1568
|
-
|
|
1611
|
+
typed.push(word);
|
|
1569
1612
|
else if (takesValue(word))
|
|
1570
1613
|
at++;
|
|
1571
1614
|
at++;
|
|
1572
1615
|
}
|
|
1573
1616
|
const last = positionals.at(-1);
|
|
1574
|
-
if (
|
|
1575
|
-
return positionals[
|
|
1576
|
-
return last?.replace("]", "").endsWith("...") === true ? last : undefined;
|
|
1617
|
+
if (typed.length < positionals.length)
|
|
1618
|
+
return { name: positionals[typed.length], typed };
|
|
1619
|
+
return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
|
|
1577
1620
|
}
|
|
1578
1621
|
async function leafCandidates(run, words) {
|
|
1579
1622
|
const completing = await completingOf(run);
|
|
@@ -1581,12 +1624,12 @@ async function leafCandidates(run, words) {
|
|
|
1581
1624
|
return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
|
|
1582
1625
|
const flag = words.at(-2);
|
|
1583
1626
|
const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
|
|
1627
|
+
const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
|
|
1584
1628
|
if (option?.type === "string") {
|
|
1585
|
-
const values = option.choices === undefined ? await option.candidates?.() : option.choices;
|
|
1629
|
+
const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
|
|
1586
1630
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1587
1631
|
}
|
|
1588
|
-
const
|
|
1589
|
-
const values = name === undefined ? undefined : await completing.candidates[name]?.();
|
|
1632
|
+
const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
|
|
1590
1633
|
return values === undefined ? [FILES] : values.map(candidateLine);
|
|
1591
1634
|
}
|
|
1592
1635
|
async function candidates(scope, defaultCommand, words, before = []) {
|
|
@@ -1617,9 +1660,13 @@ async function printCandidates(found) {
|
|
|
1617
1660
|
return 0;
|
|
1618
1661
|
}
|
|
1619
1662
|
function packageVersion(entry = Bun.main) {
|
|
1620
|
-
|
|
1663
|
+
let resolved = entry;
|
|
1664
|
+
try {
|
|
1665
|
+
resolved = realpathSync2(entry);
|
|
1666
|
+
} catch {}
|
|
1667
|
+
for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
|
|
1621
1668
|
try {
|
|
1622
|
-
const { version } = JSON.parse(
|
|
1669
|
+
const { version } = JSON.parse(readFileSync4(join5(dir, "package.json"), "utf8"));
|
|
1623
1670
|
if (typeof version === "string")
|
|
1624
1671
|
return version;
|
|
1625
1672
|
} catch {}
|
|
@@ -1627,7 +1674,7 @@ function packageVersion(entry = Bun.main) {
|
|
|
1627
1674
|
return "0.0.0";
|
|
1628
1675
|
}
|
|
1629
1676
|
}
|
|
1630
|
-
async function runCli(cli, argv =
|
|
1677
|
+
async function runCli(cli, argv = scriptArgs()) {
|
|
1631
1678
|
const version = cli.version ?? packageVersion();
|
|
1632
1679
|
if (argv[0] === COMPLETE)
|
|
1633
1680
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1658,7 +1705,7 @@ function commandPath(scope, argv) {
|
|
|
1658
1705
|
var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
|
|
1659
1706
|
// ../kit/src/git.ts
|
|
1660
1707
|
import { basename, dirname as dirname4 } from "path";
|
|
1661
|
-
import
|
|
1708
|
+
import process18 from "process";
|
|
1662
1709
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1663
1710
|
var GIT_NETWORK_MS = 60000;
|
|
1664
1711
|
async function git(args, timeoutMs) {
|
|
@@ -1688,7 +1735,7 @@ async function defaultBranch() {
|
|
|
1688
1735
|
async function leaveWorktree() {
|
|
1689
1736
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1690
1737
|
if (basename(common) === ".git")
|
|
1691
|
-
|
|
1738
|
+
process18.chdir(dirname4(common));
|
|
1692
1739
|
}
|
|
1693
1740
|
// ../kit/src/limit.ts
|
|
1694
1741
|
function limitOptions(fallback) {
|
|
@@ -1729,15 +1776,15 @@ var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "ses
|
|
|
1729
1776
|
// ../kit/src/sessions.ts
|
|
1730
1777
|
import { homedir as homedir4 } from "os";
|
|
1731
1778
|
import { join as join6 } from "path";
|
|
1732
|
-
import
|
|
1779
|
+
import process19 from "process";
|
|
1733
1780
|
var {Glob } = globalThis.Bun;
|
|
1734
1781
|
var SESSION_FILES = new Glob("*.json");
|
|
1735
1782
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1736
1783
|
async function sessionDirs() {
|
|
1737
1784
|
const home = homedir4();
|
|
1738
1785
|
const dirs = new Set([join6(home, ".claude", "sessions")]);
|
|
1739
|
-
if (
|
|
1740
|
-
dirs.add(join6(
|
|
1786
|
+
if (process19.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1787
|
+
dirs.add(join6(process19.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1741
1788
|
try {
|
|
1742
1789
|
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1743
1790
|
dirs.add(dir);
|
|
@@ -1783,7 +1830,7 @@ async function liveSessions() {
|
|
|
1783
1830
|
}
|
|
1784
1831
|
async function currentSession(sessions) {
|
|
1785
1832
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1786
|
-
let pid =
|
|
1833
|
+
let pid = process19.ppid;
|
|
1787
1834
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1788
1835
|
const session = byPid.get(pid);
|
|
1789
1836
|
if (session !== undefined)
|
|
@@ -1796,7 +1843,7 @@ async function currentSession(sessions) {
|
|
|
1796
1843
|
return;
|
|
1797
1844
|
}
|
|
1798
1845
|
// ../kit/src/watch.ts
|
|
1799
|
-
import
|
|
1846
|
+
import process20 from "process";
|
|
1800
1847
|
import { format } from "util";
|
|
1801
1848
|
var CLEAR_SCREEN = "\x1B[H\x1B[2J";
|
|
1802
1849
|
var DEFAULT_SECONDS = 2;
|
|
@@ -1818,7 +1865,7 @@ function withoutWatch(args) {
|
|
|
1818
1865
|
}
|
|
1819
1866
|
return rest;
|
|
1820
1867
|
}
|
|
1821
|
-
async function watching(value, step, stream =
|
|
1868
|
+
async function watching(value, step, stream = process20.stdout, sleep = Bun.sleep, rounds = Number.POSITIVE_INFINITY) {
|
|
1822
1869
|
const interval = value === "" ? DEFAULT_SECONDS * 1000 : duration(value, "watch", DEFAULT_SECONDS * 1000);
|
|
1823
1870
|
if (!takesControlCodes(stream))
|
|
1824
1871
|
badUsage("--watch redraws the screen, so it needs a terminal");
|
|
@@ -1826,12 +1873,12 @@ async function watching(value, step, stream = process19.stdout, sleep = Bun.slee
|
|
|
1826
1873
|
for (let round = 0;round < rounds; round++) {
|
|
1827
1874
|
const held = [];
|
|
1828
1875
|
const { log, info } = console;
|
|
1829
|
-
const write =
|
|
1876
|
+
const write = process20.stdout.write.bind(process20.stdout);
|
|
1830
1877
|
const hold = (...parts) => void held.push(`${format(...parts)}
|
|
1831
1878
|
`);
|
|
1832
1879
|
console.log = hold;
|
|
1833
1880
|
console.info = hold;
|
|
1834
|
-
|
|
1881
|
+
process20.stdout.write = (text) => {
|
|
1835
1882
|
held.push(typeof text === "string" ? text : Buffer.from(text).toString());
|
|
1836
1883
|
return true;
|
|
1837
1884
|
};
|
|
@@ -1840,7 +1887,7 @@ async function watching(value, step, stream = process19.stdout, sleep = Bun.slee
|
|
|
1840
1887
|
} finally {
|
|
1841
1888
|
console.log = log;
|
|
1842
1889
|
console.info = info;
|
|
1843
|
-
|
|
1890
|
+
process20.stdout.write = write;
|
|
1844
1891
|
}
|
|
1845
1892
|
stream.write(`${CLEAR_SCREEN}${held.join("")}`);
|
|
1846
1893
|
await sleep(interval);
|
|
@@ -2018,15 +2065,44 @@ function holderSession(holder, sessions) {
|
|
|
2018
2065
|
}
|
|
2019
2066
|
|
|
2020
2067
|
// src/good.ts
|
|
2021
|
-
import
|
|
2068
|
+
import process22 from "process";
|
|
2022
2069
|
function good(text) {
|
|
2023
|
-
return role("ok",
|
|
2070
|
+
return role("ok", process22.stdout)(text);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
// src/config.ts
|
|
2074
|
+
function concurrencyOf(fallback, home) {
|
|
2075
|
+
return configuredNumber("ft", "concurrency", fallback, { home }, [["ft", "config.json"]]);
|
|
2076
|
+
}
|
|
2077
|
+
function settingsPath(home) {
|
|
2078
|
+
return userConfigReadPath("ft", [["ft", "config.json"]], { home });
|
|
2079
|
+
}
|
|
2080
|
+
async function loadSettings(home) {
|
|
2081
|
+
const path = settingsPath(home);
|
|
2082
|
+
const file = Bun.file(path);
|
|
2083
|
+
if (!await file.exists())
|
|
2084
|
+
return {};
|
|
2085
|
+
let raw;
|
|
2086
|
+
try {
|
|
2087
|
+
raw = await file.json();
|
|
2088
|
+
} catch (error) {
|
|
2089
|
+
warn(`${path} is not valid JSON, so its settings are ignored`, error instanceof Error ? error.message : String(error));
|
|
2090
|
+
return {};
|
|
2091
|
+
}
|
|
2092
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
2093
|
+
warn(`${path} is not a JSON object, so its settings are ignored`);
|
|
2094
|
+
return {};
|
|
2095
|
+
}
|
|
2096
|
+
const host = "remoteHost" in raw ? raw.remoteHost : undefined;
|
|
2097
|
+
if (host !== undefined && (typeof host !== "string" || host === ""))
|
|
2098
|
+
warn(`remoteHost in ${path} must be a non-empty string, so it is ignored`);
|
|
2099
|
+
return typeof host === "string" && host !== "" ? { remoteHost: host } : {};
|
|
2024
2100
|
}
|
|
2025
2101
|
|
|
2026
2102
|
// src/forge.ts
|
|
2027
2103
|
import { homedir as homedir5 } from "os";
|
|
2028
2104
|
import { join as join7 } from "path";
|
|
2029
|
-
import
|
|
2105
|
+
import process23 from "process";
|
|
2030
2106
|
|
|
2031
2107
|
// src/remote.ts
|
|
2032
2108
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -2081,7 +2157,7 @@ function loginHosts(config) {
|
|
|
2081
2157
|
return hosts;
|
|
2082
2158
|
}
|
|
2083
2159
|
function teaConfigPath() {
|
|
2084
|
-
const base =
|
|
2160
|
+
const base = process23.env.XDG_CONFIG_HOME;
|
|
2085
2161
|
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
2086
2162
|
}
|
|
2087
2163
|
async function readConfig() {
|
|
@@ -2201,7 +2277,7 @@ async function commentsOf(number, repo) {
|
|
|
2201
2277
|
}
|
|
2202
2278
|
async function commentsOfAll(issues, repo) {
|
|
2203
2279
|
const commented = issues.filter((issue) => issue.comments > 0);
|
|
2204
|
-
const comments = await pool(commented, CONCURRENCY, async (issue) => commentsOf(issue.number, repo));
|
|
2280
|
+
const comments = await pool(commented, concurrencyOf(CONCURRENCY), async (issue) => commentsOf(issue.number, repo));
|
|
2205
2281
|
return new Map(commented.map((issue, index) => [issue.number, comments[index]]));
|
|
2206
2282
|
}
|
|
2207
2283
|
async function editIssue(number, change, repo) {
|
|
@@ -2514,7 +2590,7 @@ async function eachIssue(command, numbers, step) {
|
|
|
2514
2590
|
} catch (error) {
|
|
2515
2591
|
if (!(error instanceof Exit) || numbers.length === 1)
|
|
2516
2592
|
throw error;
|
|
2517
|
-
|
|
2593
|
+
problem(`ft ${command}: ${error.message}`);
|
|
2518
2594
|
if (error.hint !== undefined)
|
|
2519
2595
|
printHint(error.hint);
|
|
2520
2596
|
code = Math.max(code, error.code);
|
|
@@ -2617,7 +2693,7 @@ async function drop(args) {
|
|
|
2617
2693
|
}
|
|
2618
2694
|
|
|
2619
2695
|
// src/commands/ci.ts
|
|
2620
|
-
import
|
|
2696
|
+
import process24 from "process";
|
|
2621
2697
|
|
|
2622
2698
|
// src/git.ts
|
|
2623
2699
|
async function tagsAt(commit) {
|
|
@@ -2883,7 +2959,7 @@ async function ci2(args) {
|
|
|
2883
2959
|
return;
|
|
2884
2960
|
}
|
|
2885
2961
|
const json = values.json === true;
|
|
2886
|
-
const live = takesControlCodes(
|
|
2962
|
+
const live = takesControlCodes(process24.stderr) && takesControlCodes(process24.stdout) && !json && values.quiet !== true;
|
|
2887
2963
|
const runs = await waitForCi({
|
|
2888
2964
|
tool: "ft ci",
|
|
2889
2965
|
short,
|
|
@@ -2909,8 +2985,8 @@ async function ci2(args) {
|
|
|
2909
2985
|
return stall === undefined ? undefined : { message: `runs queued on ${short} are not moving: ${stall.reason}`, certain: stall.certain };
|
|
2910
2986
|
},
|
|
2911
2987
|
lines: (spinner, found, started) => [
|
|
2912
|
-
ciHeader(spinner, `CI on ${short}`, started,
|
|
2913
|
-
...(found ?? []).map((run) => ` ${runLine(run,
|
|
2988
|
+
ciHeader(spinner, `CI on ${short}`, started, process24.stderr),
|
|
2989
|
+
...(found ?? []).map((run) => ` ${runLine(run, process24.stderr, undefined, run.commit_sha.slice(0, 7))}`)
|
|
2914
2990
|
]
|
|
2915
2991
|
});
|
|
2916
2992
|
const status = overall(runs);
|
|
@@ -2927,7 +3003,7 @@ async function ci2(args) {
|
|
|
2927
3003
|
}
|
|
2928
3004
|
if (live) {
|
|
2929
3005
|
for (const run of runs)
|
|
2930
|
-
console.log(runLine(run,
|
|
3006
|
+
console.log(runLine(run, process24.stdout, undefined, run.commit_sha.slice(0, 7)));
|
|
2931
3007
|
}
|
|
2932
3008
|
if (status !== "failure") {
|
|
2933
3009
|
if (live)
|
|
@@ -2946,7 +3022,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2946
3022
|
}
|
|
2947
3023
|
|
|
2948
3024
|
// src/commands/digest.ts
|
|
2949
|
-
import
|
|
3025
|
+
import process25 from "process";
|
|
2950
3026
|
var RUNS_SCANNED = 50;
|
|
2951
3027
|
var TITLE_WIDTH2 = 70;
|
|
2952
3028
|
var SHOWN = 8;
|
|
@@ -2996,7 +3072,7 @@ async function quietly(read) {
|
|
|
2996
3072
|
}
|
|
2997
3073
|
}
|
|
2998
3074
|
async function staleTodos() {
|
|
2999
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
3075
|
+
const bin = Bun.which("todo-scan", { PATH: process25.env.PATH ?? "" });
|
|
3000
3076
|
if (bin === null)
|
|
3001
3077
|
return [];
|
|
3002
3078
|
let found;
|
|
@@ -3018,8 +3094,8 @@ async function staleTodos() {
|
|
|
3018
3094
|
return [...byIssue.values()];
|
|
3019
3095
|
}
|
|
3020
3096
|
function claimLine(row, now) {
|
|
3021
|
-
const id = role("id",
|
|
3022
|
-
return [id(`#${row.number}`), row.holder, paint(
|
|
3097
|
+
const id = role("id", process25.stdout);
|
|
3098
|
+
return [id(`#${row.number}`), row.holder, paint(process25.stdout).dim(formatAge(row.since, now)), row.boxesTotal === 0 ? "" : `${row.boxesLeft}/${row.boxesTotal} left`, truncate(row.title, TITLE_WIDTH2)];
|
|
3023
3099
|
}
|
|
3024
3100
|
function capped2(lines) {
|
|
3025
3101
|
return lines.length > SHOWN ? [...lines.slice(0, SHOWN), `... ${lines.length - SHOWN} more`] : lines;
|
|
@@ -3030,13 +3106,13 @@ function renderDigest(digest, now = Date.now()) {
|
|
|
3030
3106
|
`) },
|
|
3031
3107
|
{ heading: "claimed, no live session here", tone: "warn", count: digest.away.length, lines: table(digest.away.map((row) => claimLine(row, now))).split(`
|
|
3032
3108
|
`) },
|
|
3033
|
-
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status,
|
|
3109
|
+
{ heading: "CI on the default branch", tone: "failed", count: digest.ci.length, lines: digest.ci.map((run) => `${run.workflow} ${badge(run.status, process25.stdout)} (run ${run.id}) ${truncate(upTo(run.title, `
|
|
3034
3110
|
`), TITLE_WIDTH2)}`) },
|
|
3035
3111
|
{ heading: "unpushed commits", tone: "queued", count: digest.unpushed.length, lines: capped2(digest.unpushed) },
|
|
3036
|
-
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path",
|
|
3112
|
+
{ heading: "dirty files", tone: "warn", count: digest.dirty.length, lines: capped2(digest.dirty.map((file) => `${file.status} ${role("path", process25.stdout)(file.path)}`)) },
|
|
3037
3113
|
{ 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(", ")}`)) }
|
|
3038
3114
|
].filter((each) => each.count > 0);
|
|
3039
|
-
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count,
|
|
3115
|
+
return sections.length === 0 ? "nothing to pick up" : sections.map(({ heading, tone, count, lines }) => `${section(heading, count, process25.stdout, process25.env, tone)}
|
|
3040
3116
|
${lines.join(`
|
|
3041
3117
|
`).replace(LINE_START2, " ")}`).join(`
|
|
3042
3118
|
|
|
@@ -3524,7 +3600,7 @@ async function issue(args) {
|
|
|
3524
3600
|
if (values.copy === true && !await copyText(bodies.join(`
|
|
3525
3601
|
|
|
3526
3602
|
`)))
|
|
3527
|
-
|
|
3603
|
+
warn("no clipboard tool found (wl-copy, xclip, xsel, pbcopy)");
|
|
3528
3604
|
return 0;
|
|
3529
3605
|
}
|
|
3530
3606
|
const read = await Promise.all(numbers.map(async (number) => Promise.all([getIssue(number, values.repo), commentsOf(number, values.repo)])));
|
|
@@ -3599,7 +3675,7 @@ ${await text(job)}`);
|
|
|
3599
3675
|
}
|
|
3600
3676
|
|
|
3601
3677
|
// src/commands/milestone.ts
|
|
3602
|
-
import
|
|
3678
|
+
import process26 from "process";
|
|
3603
3679
|
var TITLE_WIDTH3 = 60;
|
|
3604
3680
|
var LIST_LIMIT = 30;
|
|
3605
3681
|
var CONCURRENCY2 = 4;
|
|
@@ -3608,16 +3684,16 @@ function counts(milestone) {
|
|
|
3608
3684
|
}
|
|
3609
3685
|
function progressBar(milestone) {
|
|
3610
3686
|
const total = milestone.open_issues + milestone.closed_issues;
|
|
3611
|
-
return takesControlCodes(
|
|
3687
|
+
return takesControlCodes(process26.stdout) ? bar(total === 0 ? 0 : milestone.closed_issues / total, { width: 16 }) : "";
|
|
3612
3688
|
}
|
|
3613
3689
|
function milestoneCells(each, showState) {
|
|
3614
3690
|
const drawn = progressBar(each);
|
|
3615
3691
|
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] : []];
|
|
3616
3692
|
}
|
|
3617
3693
|
async function printWithIssues(list, repo) {
|
|
3618
|
-
const colors = paint(
|
|
3619
|
-
const id = role("id",
|
|
3620
|
-
const issuesOf = await pool(list, CONCURRENCY2, async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
3694
|
+
const colors = paint(process26.stdout);
|
|
3695
|
+
const id = role("id", process26.stdout);
|
|
3696
|
+
const issuesOf = await pool(list, concurrencyOf(CONCURRENCY2), async (each) => Promise.all([openIssues(undefined, repo, each.id), closedIssues(each.id, repo)]));
|
|
3621
3697
|
const blocks = list.map((each, index) => {
|
|
3622
3698
|
const byNumber = (left, right) => left.number - right.number;
|
|
3623
3699
|
const [open, closed] = issuesOf[index].map((found) => found.toSorted(byNumber));
|
|
@@ -3627,7 +3703,7 @@ async function printWithIssues(list, repo) {
|
|
|
3627
3703
|
...open.map((issue) => ` ${id(`#${issue.number}`)} ${truncate(issue.title, TITLE_WIDTH3)}`),
|
|
3628
3704
|
...closed.map((issue) => colors.dim(` #${issue.number} ${truncate(issue.title, TITLE_WIDTH3)} (closed)`))
|
|
3629
3705
|
];
|
|
3630
|
-
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined,
|
|
3706
|
+
return [section(`${each.title}${drawn === "" ? "" : ` ${drawn}`} ${facts}`, undefined, process26.stdout, process26.env, "accent"), ...lines].join(`
|
|
3631
3707
|
`);
|
|
3632
3708
|
});
|
|
3633
3709
|
console.log(blocks.join(`
|
|
@@ -3893,7 +3969,7 @@ function report2(plan, added, skipped) {
|
|
|
3893
3969
|
|
|
3894
3970
|
// src/commands/release.ts
|
|
3895
3971
|
import { basename as basename3, join as join11 } from "path";
|
|
3896
|
-
import
|
|
3972
|
+
import process28 from "process";
|
|
3897
3973
|
var {$: $2 } = globalThis.Bun;
|
|
3898
3974
|
|
|
3899
3975
|
// src/commands/watch.ts
|
|
@@ -4131,12 +4207,12 @@ async function publishable() {
|
|
|
4131
4207
|
|
|
4132
4208
|
// src/commands/release-plan.ts
|
|
4133
4209
|
import { basename as basename2, join as join9, relative } from "path";
|
|
4134
|
-
import
|
|
4210
|
+
import process27 from "process";
|
|
4135
4211
|
async function planOf({ level, dir, prefix }, registry) {
|
|
4136
4212
|
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
4137
4213
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4138
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
4139
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
4214
|
+
const name = pkg?.name ?? basename2(dir ?? process27.cwd());
|
|
4215
|
+
const where = dir === undefined ? "" : ` in ${relative(process27.cwd(), dir) || "."}`;
|
|
4140
4216
|
let version;
|
|
4141
4217
|
let bump;
|
|
4142
4218
|
if (level === undefined) {
|
|
@@ -4175,12 +4251,12 @@ async function printPlan({ releases, branch, base, timeout, registry }) {
|
|
|
4175
4251
|
}
|
|
4176
4252
|
|
|
4177
4253
|
// src/commands/release-steps.ts
|
|
4178
|
-
import { join as join10, relative as relative2, resolve as
|
|
4254
|
+
import { join as join10, relative as relative2, resolve as resolve5 } from "path";
|
|
4179
4255
|
var {$ } = globalThis.Bun;
|
|
4180
4256
|
var registryWait = { tries: 12, poll: 5000 };
|
|
4181
4257
|
var REGISTRY_INFO_MS = 30000;
|
|
4182
4258
|
async function packageDir(value) {
|
|
4183
|
-
for (const dir of [
|
|
4259
|
+
for (const dir of [resolve5(value), join10(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
|
|
4184
4260
|
if (await Bun.file(join10(dir, "package.json")).exists())
|
|
4185
4261
|
return dir;
|
|
4186
4262
|
}
|
|
@@ -4381,7 +4457,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4381
4457
|
if (late !== undefined)
|
|
4382
4458
|
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));
|
|
4383
4459
|
say(`pushed ${branch} and ${bumped.map((each) => each.tag).join(", ")}, waiting for their runs`);
|
|
4384
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ?
|
|
4460
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && heads.has(run.commit_sha)), timeout, undefined, NO_RUN2, json ? process28.stderr : process28.stdout, { json });
|
|
4385
4461
|
if (followed.code !== 0) {
|
|
4386
4462
|
report();
|
|
4387
4463
|
return followed.code;
|
|
@@ -4412,34 +4488,6 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4412
4488
|
// src/commands/remote.ts
|
|
4413
4489
|
import { lookup } from "dns/promises";
|
|
4414
4490
|
var {$: $3 } = globalThis.Bun;
|
|
4415
|
-
|
|
4416
|
-
// src/config.ts
|
|
4417
|
-
function settingsPath(home) {
|
|
4418
|
-
return userConfigReadPath("ft", [["ft", "config.json"]], { home });
|
|
4419
|
-
}
|
|
4420
|
-
async function loadSettings(home) {
|
|
4421
|
-
const path = settingsPath(home);
|
|
4422
|
-
const file = Bun.file(path);
|
|
4423
|
-
if (!await file.exists())
|
|
4424
|
-
return {};
|
|
4425
|
-
let raw;
|
|
4426
|
-
try {
|
|
4427
|
-
raw = await file.json();
|
|
4428
|
-
} catch (error) {
|
|
4429
|
-
warn(`${path} is not valid JSON, so its settings are ignored`, error instanceof Error ? error.message : String(error));
|
|
4430
|
-
return {};
|
|
4431
|
-
}
|
|
4432
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
4433
|
-
warn(`${path} is not a JSON object, so its settings are ignored`);
|
|
4434
|
-
return {};
|
|
4435
|
-
}
|
|
4436
|
-
const host = "remoteHost" in raw ? raw.remoteHost : undefined;
|
|
4437
|
-
if (host !== undefined && (typeof host !== "string" || host === ""))
|
|
4438
|
-
warn(`remoteHost in ${path} must be a non-empty string, so it is ignored`);
|
|
4439
|
-
return typeof host === "string" && host !== "" ? { remoteHost: host } : {};
|
|
4440
|
-
}
|
|
4441
|
-
|
|
4442
|
-
// src/commands/remote.ts
|
|
4443
4491
|
var usage7 = `ft remote [--fix]
|
|
4444
4492
|
|
|
4445
4493
|
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\`.
|
|
@@ -4586,7 +4634,7 @@ async function runs(args) {
|
|
|
4586
4634
|
}
|
|
4587
4635
|
|
|
4588
4636
|
// src/cli.ts
|
|
4589
|
-
|
|
4637
|
+
process29.exitCode = await runCli({
|
|
4590
4638
|
name: "ft",
|
|
4591
4639
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4592
4640
|
replaces: "tea api calls piped through jq, and sleep loops waiting on CI",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/cli-forgejo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"description": "ft: Forgejo CI runs, logs, releases and issue checklists from the terminal, through tea.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"@kaynooo/utils": "3.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@kaynooo/cli-kit": "0.
|
|
34
|
+
"@kaynooo/cli-kit": "0.38.2"
|
|
35
35
|
}
|
|
36
36
|
}
|