@kaynooo/cli-forgejo 0.15.1 → 0.16.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/dist/cli.js +410 -177
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import
|
|
5
|
+
import process23 from "process";
|
|
6
6
|
// ../kit/src/args.ts
|
|
7
|
-
import
|
|
7
|
+
import process9 from "process";
|
|
8
8
|
import { parseArgs } from "util";
|
|
9
9
|
|
|
10
10
|
// ../kit/src/format.ts
|
|
11
|
-
import
|
|
11
|
+
import process6 from "process";
|
|
12
12
|
|
|
13
13
|
// ../kit/src/style.ts
|
|
14
|
-
import
|
|
14
|
+
import process5 from "process";
|
|
15
15
|
|
|
16
16
|
// ../../node_modules/.bun/@kaynooo+utils@2.31.2+d0769e28dc4dad16/node_modules/@kaynooo/utils/dist/chunk-mtetydvc.js
|
|
17
17
|
function x(s) {
|
|
@@ -274,48 +274,242 @@ function le(i = {}) {
|
|
|
274
274
|
}
|
|
275
275
|
var t = le();
|
|
276
276
|
|
|
277
|
-
// ../kit/src/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
277
|
+
// ../kit/src/theme.ts
|
|
278
|
+
import { existsSync as existsSync3, readFileSync, statSync } from "fs";
|
|
279
|
+
import { homedir as homedir2 } from "os";
|
|
280
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
281
|
+
import process4 from "process";
|
|
282
|
+
|
|
283
|
+
// ../kit/src/config.ts
|
|
284
|
+
import { existsSync } from "fs";
|
|
285
|
+
import { dirname, join, resolve } from "path";
|
|
286
|
+
import process2 from "process";
|
|
287
|
+
function findUp(names, from = process2.cwd(), stop = () => false) {
|
|
288
|
+
const wanted = typeof names === "string" ? [names] : names;
|
|
289
|
+
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
290
|
+
const found = wanted.map((name) => join(dir, name)).find((path) => existsSync(path));
|
|
291
|
+
if (found !== undefined)
|
|
292
|
+
return found;
|
|
293
|
+
if (stop(dir) || dirname(dir) === dir)
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ../kit/src/user-config.ts
|
|
299
|
+
import { existsSync as existsSync2 } from "fs";
|
|
300
|
+
import { homedir } from "os";
|
|
301
|
+
import { join as join2 } from "path";
|
|
302
|
+
import process3 from "process";
|
|
303
|
+
function configBase(where = {}) {
|
|
304
|
+
const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
|
|
305
|
+
return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
|
|
306
|
+
}
|
|
307
|
+
function userConfigPath(bin, where = {}) {
|
|
308
|
+
return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
309
|
+
}
|
|
310
|
+
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
311
|
+
const current = userConfigPath(bin, where);
|
|
312
|
+
if (existsSync2(current))
|
|
313
|
+
return current;
|
|
314
|
+
const base = configBase(where);
|
|
315
|
+
return legacy.map((parts) => join2(base, ...parts)).find((path) => existsSync2(path)) ?? current;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// ../kit/src/theme.ts
|
|
319
|
+
var DEFAULT = {
|
|
320
|
+
colors: { accent: "cyan", id: "yellow", path: "blue", label: "dim", value: "bold", ok: "green", warn: "yellow", problem: "red", note: "dim", passed: "green", failed: "red", running: "cyan", queued: "yellow", skipped: "dim" },
|
|
321
|
+
glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
|
|
322
|
+
accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
|
|
323
|
+
bins: {}
|
|
324
|
+
};
|
|
325
|
+
var BRIGHT = { accent: "cyanBright", id: "yellowBright", path: "blueBright", label: "white", value: "bold whiteBright", ok: "greenBright", warn: "yellowBright", problem: "redBright", note: "white", passed: "greenBright", failed: "redBright", running: "cyanBright", queued: "yellowBright", skipped: "white" };
|
|
326
|
+
var MONO = { accent: "bold", id: "bold", path: "underline", label: "dim", value: "bold", ok: "bold", warn: "bold", problem: "bold", note: "dim", passed: "bold", failed: "bold", running: "bold", queued: "dim", skipped: "dim" };
|
|
327
|
+
var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
|
|
328
|
+
var PRESETS = {
|
|
329
|
+
default: {},
|
|
330
|
+
"high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
|
|
331
|
+
mono: { colors: MONO, accents: ["bold"] },
|
|
332
|
+
ascii: { glyphs: ASCII }
|
|
283
333
|
};
|
|
284
|
-
|
|
334
|
+
var STYLES = new Set(["bold", "dim", "italic", "underline", "inverse", "strikethrough", "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray", "grey", "blackBright", "redBright", "greenBright", "yellowBright", "blueBright", "magentaBright", "cyanBright", "whiteBright"]);
|
|
335
|
+
var HEX = /^#[0-9a-f]{6}$/i;
|
|
336
|
+
var CONTROL = /\p{Cc}/u;
|
|
337
|
+
var MAX_FILE_BYTES = 64 * 1024;
|
|
338
|
+
var SPACES = /\s+/;
|
|
339
|
+
function isColorSpec(spec) {
|
|
340
|
+
if (typeof spec === "number")
|
|
341
|
+
return Number.isInteger(spec) && spec >= 0 && spec <= 255;
|
|
342
|
+
return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
|
|
343
|
+
}
|
|
344
|
+
function tinted(colors, spec) {
|
|
345
|
+
if (typeof spec === "number")
|
|
346
|
+
return colors.ansi256(spec);
|
|
347
|
+
return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
|
|
348
|
+
}
|
|
349
|
+
function isRecord(value) {
|
|
350
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
351
|
+
}
|
|
352
|
+
function readThemeFile(path, warn) {
|
|
353
|
+
try {
|
|
354
|
+
const stat = statSync(path, { throwIfNoEntry: false });
|
|
355
|
+
if (stat === undefined)
|
|
356
|
+
return;
|
|
357
|
+
if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
|
|
358
|
+
warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
362
|
+
if (isRecord(parsed))
|
|
363
|
+
return parsed;
|
|
364
|
+
warn(`${path} is not a JSON object, theme ignored`);
|
|
365
|
+
} catch (error) {
|
|
366
|
+
warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
|
|
367
|
+
}
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
function applyPreset(theme, name, warn, where) {
|
|
371
|
+
if (name === undefined)
|
|
372
|
+
return;
|
|
373
|
+
if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
|
|
374
|
+
warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const preset = PRESETS[name];
|
|
378
|
+
Object.assign(theme.colors, preset.colors);
|
|
379
|
+
Object.assign(theme.glyphs, preset.glyphs);
|
|
380
|
+
if (preset.accents !== undefined)
|
|
381
|
+
theme.accents = [...preset.accents];
|
|
382
|
+
return name;
|
|
383
|
+
}
|
|
384
|
+
function applyFile(theme, file, where, warn) {
|
|
385
|
+
if (isRecord(file.colors)) {
|
|
386
|
+
for (const [key, value] of Object.entries(file.colors)) {
|
|
387
|
+
if (!Object.hasOwn(DEFAULT.colors, key))
|
|
388
|
+
warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
|
|
389
|
+
else if (!isColorSpec(value))
|
|
390
|
+
warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
|
|
391
|
+
else
|
|
392
|
+
theme.colors[key] = value;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (isRecord(file.glyphs)) {
|
|
396
|
+
for (const [key, value] of Object.entries(file.glyphs)) {
|
|
397
|
+
if (!Object.hasOwn(DEFAULT.glyphs, key))
|
|
398
|
+
warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
|
|
399
|
+
else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
|
|
400
|
+
warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
|
|
401
|
+
else
|
|
402
|
+
theme.glyphs[key] = value;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
|
|
406
|
+
theme.accents = [...file.accents];
|
|
407
|
+
else if (file.accents !== undefined)
|
|
408
|
+
warn(`${where}: accents must be a non-empty list of colours`);
|
|
409
|
+
if (isRecord(file.bins)) {
|
|
410
|
+
for (const [bin, value] of Object.entries(file.bins)) {
|
|
411
|
+
if (isColorSpec(value))
|
|
412
|
+
theme.bins[bin] = value;
|
|
413
|
+
else
|
|
414
|
+
warn(`${where}: bin ${bin} has no valid colour`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function endsWalk(home) {
|
|
419
|
+
return (dir) => dir === resolve2(home) || existsSync3(join3(dir, ".git"));
|
|
420
|
+
}
|
|
421
|
+
var warned = new Set;
|
|
422
|
+
function warnOnce(message) {
|
|
423
|
+
if (warned.has(message))
|
|
424
|
+
return;
|
|
425
|
+
warned.add(message);
|
|
426
|
+
console.error(`warning: theme ${message}`);
|
|
427
|
+
}
|
|
428
|
+
function isPath(chosen) {
|
|
429
|
+
return chosen.includes("/") || chosen.endsWith(".json");
|
|
430
|
+
}
|
|
431
|
+
function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
|
|
432
|
+
const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
|
|
433
|
+
const sources = [];
|
|
434
|
+
const chosen = env.KIT_THEME ?? "";
|
|
435
|
+
const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
|
|
436
|
+
if (isPath(chosen))
|
|
437
|
+
wanted.push(resolve2(from, chosen));
|
|
438
|
+
const files = [];
|
|
439
|
+
for (const path of wanted) {
|
|
440
|
+
const file = path === undefined ? undefined : readThemeFile(path, warn);
|
|
441
|
+
if (path !== undefined && file !== undefined)
|
|
442
|
+
files.push({ path, file });
|
|
443
|
+
}
|
|
444
|
+
let preset = "default";
|
|
445
|
+
if (chosen !== "" && !isPath(chosen)) {
|
|
446
|
+
preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
|
|
447
|
+
} else {
|
|
448
|
+
const named = files.findLast(({ file }) => file.preset !== undefined);
|
|
449
|
+
if (named !== undefined)
|
|
450
|
+
preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
|
|
451
|
+
}
|
|
452
|
+
for (const { path, file } of files) {
|
|
453
|
+
applyFile(theme, file, path, warn);
|
|
454
|
+
sources.push(path);
|
|
455
|
+
}
|
|
456
|
+
return { theme, sources, preset };
|
|
457
|
+
}
|
|
458
|
+
var current;
|
|
459
|
+
var currentKey = "";
|
|
460
|
+
function activeTheme() {
|
|
461
|
+
const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
|
|
462
|
+
if (current === undefined || key !== currentKey) {
|
|
463
|
+
current = loadTheme();
|
|
464
|
+
currentKey = key;
|
|
465
|
+
}
|
|
466
|
+
return current;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// ../kit/src/style.ts
|
|
470
|
+
var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
|
|
471
|
+
function takesControlCodes(stream, env = process5.env) {
|
|
285
472
|
return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
|
|
286
473
|
}
|
|
287
|
-
function paint(stream, env =
|
|
474
|
+
function paint(stream, env = process5.env) {
|
|
288
475
|
return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
|
|
289
476
|
}
|
|
290
|
-
function marked(mark, text, stream, detail, env =
|
|
477
|
+
function marked(mark, text, stream, detail, env = process5.env) {
|
|
291
478
|
const colors = paint(stream, env);
|
|
292
|
-
|
|
293
|
-
|
|
479
|
+
let head = MARK_WORDS[mark];
|
|
480
|
+
if (takesControlCodes(stream, env)) {
|
|
481
|
+
const { theme } = activeTheme();
|
|
482
|
+
head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
|
|
483
|
+
}
|
|
294
484
|
return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
|
|
295
485
|
}
|
|
296
486
|
function note(text, detail) {
|
|
297
|
-
console.log(marked("note", text,
|
|
487
|
+
console.log(marked("note", text, process5.stdout, detail));
|
|
298
488
|
}
|
|
299
489
|
function warn(text, detail) {
|
|
300
|
-
console.error(marked("warn", text,
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
490
|
+
console.error(marked("warn", text, process5.stderr, detail));
|
|
491
|
+
}
|
|
492
|
+
function role(name, stream, env = process5.env) {
|
|
493
|
+
const colors = paint(stream, env);
|
|
494
|
+
return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
|
|
495
|
+
}
|
|
496
|
+
var STATUS_WORDS = {
|
|
497
|
+
passed: ["passed", "success", "succeeded", "ok"],
|
|
498
|
+
failed: ["failed", "failure", "error", "errored"],
|
|
499
|
+
running: ["running", "in_progress", "started"],
|
|
500
|
+
queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
|
|
501
|
+
skipped: ["skipped", "cancelled", "canceled", "manual"]
|
|
308
502
|
};
|
|
309
|
-
var STATUS_OF = new Map(Object.entries(
|
|
503
|
+
var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
|
|
310
504
|
function statusOf(word) {
|
|
311
505
|
return STATUS_OF.get(word.toLowerCase());
|
|
312
506
|
}
|
|
313
|
-
function badge(word, stream, env =
|
|
507
|
+
function badge(word, stream, env = process5.env) {
|
|
314
508
|
const status = statusOf(word);
|
|
315
509
|
if (status === undefined || !takesControlCodes(stream, env))
|
|
316
510
|
return word;
|
|
317
|
-
const {
|
|
318
|
-
return
|
|
511
|
+
const { theme } = activeTheme();
|
|
512
|
+
return tinted(paint(stream, env), theme.colors[status])(`${theme.glyphs[status]} ${word}`);
|
|
319
513
|
}
|
|
320
514
|
|
|
321
515
|
// ../kit/src/format.ts
|
|
@@ -358,7 +552,7 @@ var ESCAPE = String.fromCharCode(27);
|
|
|
358
552
|
function textWidth(text) {
|
|
359
553
|
return Bun.stringWidth(text);
|
|
360
554
|
}
|
|
361
|
-
function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
|
|
555
|
+
function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
|
|
362
556
|
const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
|
|
363
557
|
const widths = [];
|
|
364
558
|
for (const row of cells) {
|
|
@@ -366,7 +560,7 @@ function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
|
|
|
366
560
|
widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
|
|
367
561
|
}
|
|
368
562
|
const shown = fit === undefined ? cells : narrow(cells, widths, fit);
|
|
369
|
-
const colors = paint(
|
|
563
|
+
const colors = paint(stream);
|
|
370
564
|
const lines = shown.map((row) => row.map((cell, index) => {
|
|
371
565
|
const width = widths[index] ?? 0;
|
|
372
566
|
const gap = " ".repeat(Math.max(0, width - textWidth(cell)));
|
|
@@ -374,7 +568,8 @@ function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
|
|
|
374
568
|
return `${gap}${cell}`;
|
|
375
569
|
return index === row.length - 1 ? cell : `${cell}${gap}`;
|
|
376
570
|
}).join(" ").trimEnd());
|
|
377
|
-
|
|
571
|
+
const rule = header && takesControlCodes(stream) && lines.length > 1 ? [colors.dim("\u2500".repeat(Math.max(...lines.map(textWidth))))] : [];
|
|
572
|
+
return lines.flatMap((line, index) => header && index === 0 ? [colors.bold(line), ...rule] : [line]).join(`
|
|
378
573
|
`);
|
|
379
574
|
}
|
|
380
575
|
function narrow(rows, widths, limit) {
|
|
@@ -398,27 +593,27 @@ function printJson(value) {
|
|
|
398
593
|
}
|
|
399
594
|
|
|
400
595
|
// ../kit/src/help.ts
|
|
401
|
-
import
|
|
596
|
+
import process7 from "process";
|
|
402
597
|
var OPTIONAL = /\[[^\]]+\]/g;
|
|
403
598
|
var USAGE_PREFIX = /^usage:\s*/i;
|
|
404
599
|
var FULL_STOP = /\.$/;
|
|
405
|
-
function usageLine(usage, colors = paint(
|
|
600
|
+
function usageLine(usage, colors = paint(process7.stdout)) {
|
|
406
601
|
return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
|
|
407
602
|
}
|
|
408
|
-
function helpText(usage, options, colors = paint(
|
|
603
|
+
function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
|
|
409
604
|
return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
|
|
410
605
|
`);
|
|
411
606
|
}
|
|
412
|
-
function exitRows(exits, colors = paint(
|
|
607
|
+
function exitRows(exits, colors = paint(process7.stdout)) {
|
|
413
608
|
if (exits.length === 0)
|
|
414
609
|
return [];
|
|
415
610
|
const width = Math.max(...exits.map(([code]) => String(code).length));
|
|
416
611
|
return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
|
|
417
612
|
}
|
|
418
|
-
function replacesRows(replaces, colors = paint(
|
|
613
|
+
function replacesRows(replaces, colors = paint(process7.stdout)) {
|
|
419
614
|
return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
|
|
420
615
|
}
|
|
421
|
-
function wantsHelpJson(env =
|
|
616
|
+
function wantsHelpJson(env = process7.env) {
|
|
422
617
|
return env.KIT_HELP === "json";
|
|
423
618
|
}
|
|
424
619
|
function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
@@ -437,12 +632,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
|
|
|
437
632
|
...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
|
|
438
633
|
};
|
|
439
634
|
}
|
|
440
|
-
function exampleRows(examples, colors = paint(
|
|
635
|
+
function exampleRows(examples, colors = paint(process7.stdout)) {
|
|
441
636
|
if (examples.length === 0)
|
|
442
637
|
return [];
|
|
443
638
|
return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
|
|
444
639
|
}
|
|
445
|
-
function optionRows(options, colors = paint(
|
|
640
|
+
function optionRows(options, colors = paint(process7.stdout)) {
|
|
446
641
|
const rows = Object.entries(options).map(([name, option]) => {
|
|
447
642
|
const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
|
|
448
643
|
const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
|
|
@@ -474,7 +669,7 @@ function closest(name, names) {
|
|
|
474
669
|
return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
|
|
475
670
|
}
|
|
476
671
|
// ../kit/src/input.ts
|
|
477
|
-
import
|
|
672
|
+
import process8 from "process";
|
|
478
673
|
var WHOLE = /^\d+$/;
|
|
479
674
|
function wholeNumber(value, name, fallback, min = 1) {
|
|
480
675
|
if (value === undefined)
|
|
@@ -497,7 +692,7 @@ function duration(value, name, fallback, unit = "s") {
|
|
|
497
692
|
}
|
|
498
693
|
async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
|
|
499
694
|
if (path === "-") {
|
|
500
|
-
if (
|
|
695
|
+
if (process8.stdin.isTTY)
|
|
501
696
|
fail(noStdin);
|
|
502
697
|
return Bun.stdin.text();
|
|
503
698
|
}
|
|
@@ -556,7 +751,7 @@ var OUTPUT_OPTIONS = {
|
|
|
556
751
|
color: { type: "string", description: "auto (on a terminal alone), always or never" },
|
|
557
752
|
plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
|
|
558
753
|
};
|
|
559
|
-
function applyOutput(color, plain, env =
|
|
754
|
+
function applyOutput(color, plain, env = process9.env) {
|
|
560
755
|
const when = plain === true ? "never" : color ?? "auto";
|
|
561
756
|
if (when === "auto")
|
|
562
757
|
return;
|
|
@@ -726,11 +921,11 @@ function nearestOption(message, options, allowNegative) {
|
|
|
726
921
|
return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
|
|
727
922
|
}
|
|
728
923
|
// ../kit/src/progress.ts
|
|
729
|
-
import
|
|
924
|
+
import process11 from "process";
|
|
730
925
|
|
|
731
926
|
// ../kit/src/process.ts
|
|
732
927
|
import { constants } from "os";
|
|
733
|
-
import
|
|
928
|
+
import process10 from "process";
|
|
734
929
|
var KILL_GRACE_MS = 2000;
|
|
735
930
|
var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
736
931
|
function exitCodeOf(code, signal) {
|
|
@@ -752,7 +947,7 @@ function holdSignals(cleanup) {
|
|
|
752
947
|
},
|
|
753
948
|
release: () => {
|
|
754
949
|
for (const signal of SIGNALS)
|
|
755
|
-
|
|
950
|
+
process10.off(signal, onSignal);
|
|
756
951
|
}
|
|
757
952
|
};
|
|
758
953
|
function onSignal(signal) {
|
|
@@ -765,10 +960,10 @@ function holdSignals(cleanup) {
|
|
|
765
960
|
return;
|
|
766
961
|
held.release();
|
|
767
962
|
cleanup(signal);
|
|
768
|
-
|
|
963
|
+
process10.kill(process10.pid, signal);
|
|
769
964
|
}
|
|
770
965
|
for (const signal of SIGNALS)
|
|
771
|
-
|
|
966
|
+
process10.on(signal, onSignal);
|
|
772
967
|
return held;
|
|
773
968
|
}
|
|
774
969
|
async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
|
|
@@ -782,7 +977,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
|
|
|
782
977
|
return;
|
|
783
978
|
try {
|
|
784
979
|
if (grouped)
|
|
785
|
-
|
|
980
|
+
process10.kill(-proc.pid, killing);
|
|
786
981
|
else
|
|
787
982
|
proc.kill(killing);
|
|
788
983
|
} catch {}
|
|
@@ -861,7 +1056,7 @@ var RESET_STYLE = `${ESC}[0m`;
|
|
|
861
1056
|
var CTRL_C = 3;
|
|
862
1057
|
var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
|
|
863
1058
|
var CONSOLE_METHODS = ["log", "info", "warn", "error", "debug", "dir", "dirxml", "table", "trace", "group", "groupCollapsed", "count", "timeEnd", "timeLog", "assert"];
|
|
864
|
-
function liveRegion(render, stream =
|
|
1059
|
+
function liveRegion(render, stream = process11.stderr, env = process11.env) {
|
|
865
1060
|
if (!takesControlCodes(stream, env))
|
|
866
1061
|
return { redraw: () => {
|
|
867
1062
|
return;
|
|
@@ -902,11 +1097,11 @@ function liveRegion(render, stream = process8.stderr, env = process8.env) {
|
|
|
902
1097
|
clear();
|
|
903
1098
|
restore();
|
|
904
1099
|
release();
|
|
905
|
-
|
|
1100
|
+
process11.off("exit", onExit);
|
|
906
1101
|
signals.release();
|
|
907
1102
|
}
|
|
908
1103
|
timer.unref();
|
|
909
|
-
|
|
1104
|
+
process11.on("exit", onExit);
|
|
910
1105
|
return {
|
|
911
1106
|
redraw: draw,
|
|
912
1107
|
print: (text) => {
|
|
@@ -945,14 +1140,14 @@ function cutToWidth(line, width) {
|
|
|
945
1140
|
return `${kept}${RESET_STYLE}${linked ? CLOSE_LINK : ""}`;
|
|
946
1141
|
}
|
|
947
1142
|
function swallowInput() {
|
|
948
|
-
const input =
|
|
1143
|
+
const input = process11.stdin;
|
|
949
1144
|
if (!input.isTTY)
|
|
950
1145
|
return () => {
|
|
951
1146
|
return;
|
|
952
1147
|
};
|
|
953
1148
|
const onData = (data) => {
|
|
954
1149
|
if (data.includes(CTRL_C))
|
|
955
|
-
|
|
1150
|
+
process11.kill(process11.pid, "SIGINT");
|
|
956
1151
|
};
|
|
957
1152
|
input.setRawMode(true);
|
|
958
1153
|
input.on("data", onData);
|
|
@@ -968,7 +1163,7 @@ function swallowInput() {
|
|
|
968
1163
|
};
|
|
969
1164
|
}
|
|
970
1165
|
function interceptOutput(clear) {
|
|
971
|
-
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [
|
|
1166
|
+
const targets = [...CONSOLE_METHODS.map((name) => [console, name]), [process11.stdout, "write"], [process11.stderr, "write"]];
|
|
972
1167
|
const wrapped = targets.map(([target, name]) => {
|
|
973
1168
|
const original = Reflect.get(target, name);
|
|
974
1169
|
const wrapper = (...args) => {
|
|
@@ -987,11 +1182,11 @@ function interceptOutput(clear) {
|
|
|
987
1182
|
}
|
|
988
1183
|
|
|
989
1184
|
// ../kit/src/tool.ts
|
|
990
|
-
import
|
|
1185
|
+
import process12 from "process";
|
|
991
1186
|
var PERMANENT = /\bHTTP (?:401|403|404)\b|unauthorized|forbidden|not found|couldn't be found|token is required/i;
|
|
992
1187
|
function cwdGone() {
|
|
993
1188
|
try {
|
|
994
|
-
|
|
1189
|
+
process12.cwd();
|
|
995
1190
|
return false;
|
|
996
1191
|
} catch {
|
|
997
1192
|
return true;
|
|
@@ -1018,7 +1213,7 @@ function isPermanentFailure(error) {
|
|
|
1018
1213
|
async function runTool(label, argv, { timeoutMs, cwd, onStart } = {}) {
|
|
1019
1214
|
let ran;
|
|
1020
1215
|
try {
|
|
1021
|
-
ran = await runCommand(argv, { env:
|
|
1216
|
+
ran = await runCommand(argv, { env: process12.env, ...timeoutMs === undefined ? {} : { timeoutMs }, ...cwd === undefined ? {} : { cwd }, ...onStart === undefined ? {} : { onStart } });
|
|
1022
1217
|
} catch (error) {
|
|
1023
1218
|
throw spawnFailure(label, error);
|
|
1024
1219
|
}
|
|
@@ -1103,15 +1298,15 @@ async function waitForCi(wait) {
|
|
|
1103
1298
|
}
|
|
1104
1299
|
}
|
|
1105
1300
|
// ../kit/src/cli.ts
|
|
1106
|
-
import { readFileSync, realpathSync } from "fs";
|
|
1107
|
-
import { dirname as
|
|
1108
|
-
import
|
|
1301
|
+
import { readFileSync as readFileSync2, realpathSync } from "fs";
|
|
1302
|
+
import { dirname as dirname3, join as join5 } from "path";
|
|
1303
|
+
import process14 from "process";
|
|
1109
1304
|
|
|
1110
1305
|
// ../kit/src/usage.ts
|
|
1111
1306
|
import { appendFileSync, mkdirSync } from "fs";
|
|
1112
|
-
import { homedir } from "os";
|
|
1113
|
-
import { dirname, isAbsolute, join } from "path";
|
|
1114
|
-
import
|
|
1307
|
+
import { homedir as homedir3 } from "os";
|
|
1308
|
+
import { dirname as dirname2, isAbsolute, join as join4 } from "path";
|
|
1309
|
+
import process13 from "process";
|
|
1115
1310
|
|
|
1116
1311
|
// ../kit/src/logs.ts
|
|
1117
1312
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -1125,14 +1320,14 @@ var usageError;
|
|
|
1125
1320
|
function noteUsageError(message) {
|
|
1126
1321
|
usageError = message;
|
|
1127
1322
|
}
|
|
1128
|
-
function stateHome(env =
|
|
1323
|
+
function stateHome(env = process13.env) {
|
|
1129
1324
|
const dir = env.XDG_STATE_HOME;
|
|
1130
|
-
return dir !== undefined && isAbsolute(dir) ? dir :
|
|
1325
|
+
return dir !== undefined && isAbsolute(dir) ? dir : join4(homedir3(), ".local", "state");
|
|
1131
1326
|
}
|
|
1132
|
-
function usagePath(env =
|
|
1133
|
-
return
|
|
1327
|
+
function usagePath(env = process13.env) {
|
|
1328
|
+
return join4(stateHome(env), CLI_FOLDER, "usage.jsonl");
|
|
1134
1329
|
}
|
|
1135
|
-
function usageRecorded(env =
|
|
1330
|
+
function usageRecorded(env = process13.env) {
|
|
1136
1331
|
const off = env.KAYNOOO_CLI_NO_USAGE;
|
|
1137
1332
|
return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
|
|
1138
1333
|
}
|
|
@@ -1146,12 +1341,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
|
|
|
1146
1341
|
usageError = undefined;
|
|
1147
1342
|
return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
|
|
1148
1343
|
}
|
|
1149
|
-
function recordUsage(entry, env =
|
|
1344
|
+
function recordUsage(entry, env = process13.env) {
|
|
1150
1345
|
if (!usageRecorded(env))
|
|
1151
1346
|
return;
|
|
1152
1347
|
try {
|
|
1153
1348
|
const path = usagePath(env);
|
|
1154
|
-
mkdirSync(
|
|
1349
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
1155
1350
|
appendFileSync(path, `${JSON.stringify(entry)}
|
|
1156
1351
|
`, { mode: 384 });
|
|
1157
1352
|
} catch {}
|
|
@@ -1237,8 +1432,8 @@ async function help2({ path, header, summary: lazySummary, commands, defaultComm
|
|
|
1237
1432
|
`);
|
|
1238
1433
|
}
|
|
1239
1434
|
function printError(prefix, message, hint, cause) {
|
|
1240
|
-
const colors = paint(
|
|
1241
|
-
const styled = takesControlCodes(
|
|
1435
|
+
const colors = paint(process14.stderr);
|
|
1436
|
+
const styled = takesControlCodes(process14.stderr);
|
|
1242
1437
|
const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
|
|
1243
1438
|
const under = (label, text, tint) => text === undefined ? "" : `
|
|
1244
1439
|
${styled ? tint(label) : `${label}:`} ${text}`;
|
|
@@ -1248,8 +1443,8 @@ function runHint(command, effect) {
|
|
|
1248
1443
|
return `run \`${command}\`${effect === undefined ? "" : ` to ${effect}`}`;
|
|
1249
1444
|
}
|
|
1250
1445
|
function printHint(hint) {
|
|
1251
|
-
const colors = paint(
|
|
1252
|
-
console.error(` ${takesControlCodes(
|
|
1446
|
+
const colors = paint(process14.stderr);
|
|
1447
|
+
console.error(` ${takesControlCodes(process14.stderr) ? colors.yellow("hint") : "hint:"} ${hint}`);
|
|
1253
1448
|
}
|
|
1254
1449
|
function printJsonError(message, hint, cause) {
|
|
1255
1450
|
console.error(JSON.stringify({ error: message, ...hint === undefined ? {} : { hint }, ...cause === undefined ? {} : { cause } }));
|
|
@@ -1264,7 +1459,7 @@ function reportThrown(prefix, error, redact = (text) => text, json = false) {
|
|
|
1264
1459
|
const help = error instanceof UsageError ? `run ${prefix} --help for its options` : undefined;
|
|
1265
1460
|
const named = error instanceof Error && !(error instanceof Exit) && error.name !== "Error" ? `${error.name}: ${error.message}` : undefined;
|
|
1266
1461
|
const cause = error instanceof Error && error.cause instanceof Error ? redact(error.cause.message) : undefined;
|
|
1267
|
-
if (error instanceof
|
|
1462
|
+
if (error instanceof Exit && error.code === 2)
|
|
1268
1463
|
noteUsageError(error.message);
|
|
1269
1464
|
const report = json ? printJsonError : (message, hint, causeText) => printError(prefix, message, hint, causeText);
|
|
1270
1465
|
report(redact(named ?? (error instanceof Error ? error.message : String(error))), error instanceof Exit ? error.hint ?? help : undefined, cause);
|
|
@@ -1288,11 +1483,11 @@ async function dispatch(level, typed, { version, redact }) {
|
|
|
1288
1483
|
}
|
|
1289
1484
|
}
|
|
1290
1485
|
if (name === undefined && level.path.length > 1) {
|
|
1291
|
-
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1486
|
+
console.error(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stderr));
|
|
1292
1487
|
return 2;
|
|
1293
1488
|
}
|
|
1294
1489
|
if (name === undefined || name === "help" || name === "--help" || name === "-h") {
|
|
1295
|
-
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]),
|
|
1490
|
+
console.log(await help2(await expand(level, [...level.path.slice(1), ...argv]), process14.stdout));
|
|
1296
1491
|
return 0;
|
|
1297
1492
|
}
|
|
1298
1493
|
if (level.path.length === 1 && (name === "--version" || name === "-v")) {
|
|
@@ -1409,17 +1604,17 @@ async function printCandidates(found) {
|
|
|
1409
1604
|
return 0;
|
|
1410
1605
|
}
|
|
1411
1606
|
function packageVersion(entry = Bun.main) {
|
|
1412
|
-
for (let dir =
|
|
1607
|
+
for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
|
|
1413
1608
|
try {
|
|
1414
|
-
const { version } = JSON.parse(
|
|
1609
|
+
const { version } = JSON.parse(readFileSync2(join5(dir, "package.json"), "utf8"));
|
|
1415
1610
|
if (typeof version === "string")
|
|
1416
1611
|
return version;
|
|
1417
1612
|
} catch {}
|
|
1418
|
-
if (
|
|
1613
|
+
if (dirname3(dir) === dir)
|
|
1419
1614
|
return "0.0.0";
|
|
1420
1615
|
}
|
|
1421
1616
|
}
|
|
1422
|
-
async function runCli(cli, argv =
|
|
1617
|
+
async function runCli(cli, argv = process14.argv.slice(2)) {
|
|
1423
1618
|
const version = cli.version ?? packageVersion();
|
|
1424
1619
|
if (argv[0] === COMPLETE)
|
|
1425
1620
|
return printCandidates(candidates(scopeOf(cli.commands, cli.extraCommands, cli.aliases), cli.defaultCommand, argv.slice(1)));
|
|
@@ -1447,8 +1642,8 @@ function commandPath(scope, argv) {
|
|
|
1447
1642
|
return path.length === 0 ? undefined : path.join(" ");
|
|
1448
1643
|
}
|
|
1449
1644
|
// ../kit/src/git.ts
|
|
1450
|
-
import { basename, dirname as
|
|
1451
|
-
import
|
|
1645
|
+
import { basename, dirname as dirname4 } from "path";
|
|
1646
|
+
import process15 from "process";
|
|
1452
1647
|
var ORIGIN_PREFIX = /^origin\//;
|
|
1453
1648
|
var GIT_NETWORK_MS = 60000;
|
|
1454
1649
|
async function git(args, timeoutMs) {
|
|
@@ -1478,7 +1673,7 @@ async function defaultBranch() {
|
|
|
1478
1673
|
async function leaveWorktree() {
|
|
1479
1674
|
const common = await git(["rev-parse", "--path-format=absolute", "--git-common-dir"]);
|
|
1480
1675
|
if (basename(common) === ".git")
|
|
1481
|
-
|
|
1676
|
+
process15.chdir(dirname4(common));
|
|
1482
1677
|
}
|
|
1483
1678
|
// ../kit/src/limit.ts
|
|
1484
1679
|
function limitOptions(fallback) {
|
|
@@ -1504,19 +1699,19 @@ function capped(rows, limit) {
|
|
|
1504
1699
|
// ../kit/src/secrets.ts
|
|
1505
1700
|
var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
|
|
1506
1701
|
// ../kit/src/sessions.ts
|
|
1507
|
-
import { homedir as
|
|
1508
|
-
import { join as
|
|
1509
|
-
import
|
|
1702
|
+
import { homedir as homedir4 } from "os";
|
|
1703
|
+
import { join as join6 } from "path";
|
|
1704
|
+
import process16 from "process";
|
|
1510
1705
|
var {Glob } = globalThis.Bun;
|
|
1511
1706
|
var SESSION_FILES = new Glob("*.json");
|
|
1512
1707
|
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
1513
1708
|
async function sessionDirs() {
|
|
1514
|
-
const home =
|
|
1515
|
-
const dirs = new Set([
|
|
1516
|
-
if (
|
|
1517
|
-
dirs.add(
|
|
1709
|
+
const home = homedir4();
|
|
1710
|
+
const dirs = new Set([join6(home, ".claude", "sessions")]);
|
|
1711
|
+
if (process16.env.CLAUDE_CONFIG_DIR !== undefined)
|
|
1712
|
+
dirs.add(join6(process16.env.CLAUDE_CONFIG_DIR, "sessions"));
|
|
1518
1713
|
try {
|
|
1519
|
-
for await (const dir of ACCOUNT_DIRS.scan({ cwd:
|
|
1714
|
+
for await (const dir of ACCOUNT_DIRS.scan({ cwd: join6(home, ".claude-accounts"), onlyFiles: false, absolute: true }))
|
|
1520
1715
|
dirs.add(dir);
|
|
1521
1716
|
} catch {}
|
|
1522
1717
|
return [...dirs];
|
|
@@ -1560,7 +1755,7 @@ async function liveSessions() {
|
|
|
1560
1755
|
}
|
|
1561
1756
|
async function currentSession(sessions) {
|
|
1562
1757
|
const byPid = new Map(sessions.map((session) => [session.pid, session]));
|
|
1563
|
-
let pid =
|
|
1758
|
+
let pid = process16.ppid;
|
|
1564
1759
|
for (let depth = 0;depth < 32 && pid > 1; depth++) {
|
|
1565
1760
|
const session = byPid.get(pid);
|
|
1566
1761
|
if (session !== undefined)
|
|
@@ -1572,25 +1767,6 @@ async function currentSession(sessions) {
|
|
|
1572
1767
|
}
|
|
1573
1768
|
return;
|
|
1574
1769
|
}
|
|
1575
|
-
// ../kit/src/user-config.ts
|
|
1576
|
-
import { existsSync } from "fs";
|
|
1577
|
-
import { homedir as homedir3 } from "os";
|
|
1578
|
-
import { join as join4 } from "path";
|
|
1579
|
-
import process14 from "process";
|
|
1580
|
-
function configBase(where = {}) {
|
|
1581
|
-
const xdg = where.xdg ?? (where.home === undefined ? process14.env.XDG_CONFIG_HOME : undefined);
|
|
1582
|
-
return xdg !== undefined && xdg !== "" ? xdg : join4(where.home ?? homedir3(), ".config");
|
|
1583
|
-
}
|
|
1584
|
-
function userConfigPath(bin, where = {}) {
|
|
1585
|
-
return join4(configBase(where), "kaynooo-cli", `${bin}.json`);
|
|
1586
|
-
}
|
|
1587
|
-
function userConfigReadPath(bin, legacy = [], where = {}) {
|
|
1588
|
-
const current = userConfigPath(bin, where);
|
|
1589
|
-
if (existsSync(current))
|
|
1590
|
-
return current;
|
|
1591
|
-
const base = configBase(where);
|
|
1592
|
-
return legacy.map((parts) => join4(base, ...parts)).find((path) => existsSync(path)) ?? current;
|
|
1593
|
-
}
|
|
1594
1770
|
// src/args.ts
|
|
1595
1771
|
var repoOption = {
|
|
1596
1772
|
repo: { type: "string", short: "r", description: "owner/name of the repository, instead of the one origin points at" }
|
|
@@ -1758,12 +1934,96 @@ function holderSession(holder, sessions) {
|
|
|
1758
1934
|
return lane === undefined ? undefined : sessions.find((session) => session.name.endsWith(`-${lane}`));
|
|
1759
1935
|
}
|
|
1760
1936
|
|
|
1937
|
+
// src/forge.ts
|
|
1938
|
+
import { homedir as homedir5 } from "os";
|
|
1939
|
+
import { join as join7 } from "path";
|
|
1940
|
+
import process18 from "process";
|
|
1941
|
+
|
|
1942
|
+
// src/remote.ts
|
|
1943
|
+
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
1944
|
+
var SSH_URL = /^ssh:\/\/(?:([^@/]+)@)?([^:/]+)(?::(\d+))?\/(.+?)(?:\.git)?\/?$/;
|
|
1945
|
+
var USERINFO = /^([a-z][a-z\d+.-]*:\/\/)[^@/]*@/i;
|
|
1946
|
+
var DEFAULT_PORT = "22";
|
|
1947
|
+
function parseSshRemote(url) {
|
|
1948
|
+
const ssh = SSH_URL.exec(url);
|
|
1949
|
+
const scp = ssh === null && !url.includes("://") ? SCP_LIKE.exec(url) : null;
|
|
1950
|
+
const match = ssh ?? scp;
|
|
1951
|
+
if (match === null || match[2]?.startsWith("-") === true)
|
|
1952
|
+
return;
|
|
1953
|
+
const login = match[1] ?? "git";
|
|
1954
|
+
const user = login.includes(":") ? login.slice(0, login.indexOf(":")) : login;
|
|
1955
|
+
if (ssh === null)
|
|
1956
|
+
return { user, host: match[2] ?? "", path: match[3] ?? "" };
|
|
1957
|
+
return { user, host: match[2] ?? "", path: match[4] ?? "", ...ssh[3] === undefined ? {} : { port: ssh[3] } };
|
|
1958
|
+
}
|
|
1959
|
+
function redactUrl(url) {
|
|
1960
|
+
return url.replace(USERINFO, "$1");
|
|
1961
|
+
}
|
|
1962
|
+
function canonicalRemote(url, host, reaches) {
|
|
1963
|
+
const remote = parseSshRemote(url);
|
|
1964
|
+
if (remote === undefined || remote.host === host || !reaches(remote.host))
|
|
1965
|
+
return;
|
|
1966
|
+
if (remote.port !== undefined && remote.port !== DEFAULT_PORT)
|
|
1967
|
+
return `ssh://${remote.user}@${host}:${remote.port}/${remote.path}.git`;
|
|
1968
|
+
return `${remote.user}@${host}:${remote.path}.git`;
|
|
1969
|
+
}
|
|
1970
|
+
async function reachesHost(hostname, host, hostAddresses, addressesOf) {
|
|
1971
|
+
if (hostname === undefined)
|
|
1972
|
+
return false;
|
|
1973
|
+
return hostname === host || (await addressesOf(hostname)).some((address) => hostAddresses.has(address));
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// src/forge.ts
|
|
1977
|
+
var LOGIN_HOST = /^\s*(?:-\s*)?(?:url|ssh_host):\s*["']?([^\s"']+)/gm;
|
|
1978
|
+
var PORT = /:\d+$/;
|
|
1979
|
+
var SCP_REMOTE = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)/;
|
|
1980
|
+
var URL_REMOTE = /^[a-z+]+:\/\/(?:[^@/\s]+@)?(\[[^\]]+\]|[^:/\s]+)/i;
|
|
1981
|
+
function originHost(remote) {
|
|
1982
|
+
const text = remote.trim();
|
|
1983
|
+
return (URL_REMOTE.exec(text) ?? SCP_REMOTE.exec(text))?.[1]?.toLowerCase();
|
|
1984
|
+
}
|
|
1985
|
+
function loginHosts(config) {
|
|
1986
|
+
const hosts = new Set;
|
|
1987
|
+
for (const [, value = ""] of config.matchAll(LOGIN_HOST)) {
|
|
1988
|
+
const host = URL.canParse(value) ? new URL(value).hostname : value.replace(PORT, "");
|
|
1989
|
+
if (host !== "")
|
|
1990
|
+
hosts.add(host.toLowerCase());
|
|
1991
|
+
}
|
|
1992
|
+
return hosts;
|
|
1993
|
+
}
|
|
1994
|
+
function teaConfigPath() {
|
|
1995
|
+
const base = process18.env.XDG_CONFIG_HOME;
|
|
1996
|
+
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
1997
|
+
}
|
|
1998
|
+
async function readConfig() {
|
|
1999
|
+
try {
|
|
2000
|
+
return await Bun.file(teaConfigPath()).text();
|
|
2001
|
+
} catch {
|
|
2002
|
+
return "";
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
var checked;
|
|
2006
|
+
async function requireForgeOrigin() {
|
|
2007
|
+
checked ??= (async () => {
|
|
2008
|
+
const hosts = loginHosts(await readConfig());
|
|
2009
|
+
if (hosts.size === 0)
|
|
2010
|
+
return;
|
|
2011
|
+
const origin = await runTool("git remote get-url origin", ["git", "remote", "get-url", "origin"], { timeoutMs: 5000 });
|
|
2012
|
+
const host = origin.code === 0 ? originHost(origin.stdout) : undefined;
|
|
2013
|
+
if (host !== undefined && !hosts.has(host))
|
|
2014
|
+
fail(`origin ${redactUrl(origin.stdout.trim())} is not on a Forgejo tea is 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)");
|
|
2015
|
+
})();
|
|
2016
|
+
return checked;
|
|
2017
|
+
}
|
|
2018
|
+
|
|
1761
2019
|
// src/tea.ts
|
|
1762
2020
|
var TEA_MS = 60000;
|
|
1763
2021
|
function repoFlag(repo) {
|
|
1764
2022
|
return repo === undefined ? [] : ["--repo", repo];
|
|
1765
2023
|
}
|
|
1766
2024
|
async function request(path, repo) {
|
|
2025
|
+
if (repo === undefined)
|
|
2026
|
+
await requireForgeOrigin();
|
|
1767
2027
|
const result = await runTool(`tea api ${path}`, ["tea", "api", ...repoFlag(repo), path], { timeoutMs: TEA_MS });
|
|
1768
2028
|
if (result.code !== 0)
|
|
1769
2029
|
throw new Error(`tea api ${path}: ${result.stderr.trim() || `exit ${result.code}`}`);
|
|
@@ -1796,6 +2056,8 @@ async function repoApi(path, repo) {
|
|
|
1796
2056
|
async function repoWrite(method, path, fields, repo) {
|
|
1797
2057
|
const full = `repos/{owner}/{repo}/${path}`;
|
|
1798
2058
|
const flags = Object.entries(fields).flatMap(([name, value]) => ["-f", `${name}=${value}`]);
|
|
2059
|
+
if (repo === undefined)
|
|
2060
|
+
await requireForgeOrigin();
|
|
1799
2061
|
const result = await runTool(`tea api ${full}`, ["tea", "api", ...repoFlag(repo), "-X", method, ...flags, full], { timeoutMs: TEA_MS });
|
|
1800
2062
|
if (result.code !== 0)
|
|
1801
2063
|
throw new Error(`tea api ${full}: ${result.stderr.trim() || `exit ${result.code}`}`);
|
|
@@ -1816,6 +2078,8 @@ async function repoApiText(path, repo) {
|
|
|
1816
2078
|
return text;
|
|
1817
2079
|
}
|
|
1818
2080
|
async function tea(command, args, repo) {
|
|
2081
|
+
if (repo === undefined)
|
|
2082
|
+
await requireForgeOrigin();
|
|
1819
2083
|
const result = await runTool(`tea ${command.join(" ")}`, ["tea", ...command, ...repoFlag(repo), ...args], { timeoutMs: TEA_MS });
|
|
1820
2084
|
if (result.code !== 0)
|
|
1821
2085
|
throw new Error(`tea ${command.join(" ")}: ${result.stderr.trim() || result.stdout.trim() || `exit ${result.code}`}`);
|
|
@@ -2004,6 +2268,9 @@ function standing(claim, sessions) {
|
|
|
2004
2268
|
}
|
|
2005
2269
|
var NOTE_WIDTH = 100;
|
|
2006
2270
|
var STATES = new Set(["available", "taken", "away"]);
|
|
2271
|
+
function dimmed(text) {
|
|
2272
|
+
return text === "" ? "" : paint(process.stdout).dim(text);
|
|
2273
|
+
}
|
|
2007
2274
|
function boxesLeft(issue) {
|
|
2008
2275
|
const list = boxes(issue.body);
|
|
2009
2276
|
return list.length === 0 ? "" : `${list.filter((box) => !box.done).length}/${list.length} left`;
|
|
@@ -2011,7 +2278,7 @@ function boxesLeft(issue) {
|
|
|
2011
2278
|
function claimRow(issue, row, now) {
|
|
2012
2279
|
const holder = row.state === "taken" && row.session.name !== row.claim.holder ? `${row.claim.holder} via ${row.session.name}` : row.claim.holder;
|
|
2013
2280
|
const status = row.state === "taken" ? ` (${row.session.status})` : "";
|
|
2014
|
-
return [`#${issue.number}
|
|
2281
|
+
return [role("id", process.stdout)(`#${issue.number}`), `${holder}${status}`, paint(process.stdout).dim(formatAge(row.claim.at, now)), boxesLeft(issue), truncate(issue.title, TITLE_WIDTH)];
|
|
2015
2282
|
}
|
|
2016
2283
|
function noteLine(comments, now) {
|
|
2017
2284
|
const note = latestNote(comments);
|
|
@@ -2030,11 +2297,11 @@ function renderBoard(rows, now = Date.now(), limit = Number.POSITIVE_INFINITY) {
|
|
|
2030
2297
|
const taken = claimed("taken");
|
|
2031
2298
|
const away = claimed("away");
|
|
2032
2299
|
const sections = [
|
|
2033
|
-
{ heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [`#${issue.number}
|
|
2300
|
+
{ heading: "available", count: available.length, ...within(available, limit, ({ issue }) => [role("id", process.stdout)(`#${issue.number}`), truncate(issue.title, TITLE_WIDTH), dimmed(issue.labels.map((label) => label.name).join(", "))]) },
|
|
2034
2301
|
{ heading: "taken", count: taken.length, ...within(taken, limit, ({ issue, row }) => claimRow(issue, row, now)) },
|
|
2035
2302
|
{ heading: "claimed, no live session here", count: away.length, ...within(away, limit, ({ issue, row }) => claimRow(issue, row, now), (line, index) => [line, ...noteLine(away[index]?.comments ?? [], now)]) }
|
|
2036
2303
|
].filter((section) => section.count > 0);
|
|
2037
|
-
return sections.length === 0 ? "no open issue" : sections.map(({ heading, count, lines }) => `${heading} (${count})
|
|
2304
|
+
return sections.length === 0 ? "no open issue" : sections.map(({ heading, count, lines }) => `${paint(process.stdout).bold(`${heading} (${count})`)}
|
|
2038
2305
|
${lines.join(`
|
|
2039
2306
|
`).replace(LINE_START, " ")}`).join(`
|
|
2040
2307
|
|
|
@@ -2219,7 +2486,7 @@ async function drop(args) {
|
|
|
2219
2486
|
}
|
|
2220
2487
|
|
|
2221
2488
|
// src/commands/ci.ts
|
|
2222
|
-
import
|
|
2489
|
+
import process19 from "process";
|
|
2223
2490
|
|
|
2224
2491
|
// src/git.ts
|
|
2225
2492
|
async function tagsAt(commit) {
|
|
@@ -2475,7 +2742,7 @@ async function ci2(args) {
|
|
|
2475
2742
|
return;
|
|
2476
2743
|
}
|
|
2477
2744
|
const json = values.json === true;
|
|
2478
|
-
const { dim } = paint(
|
|
2745
|
+
const { dim } = paint(process19.stderr);
|
|
2479
2746
|
const runs = await waitForCi({
|
|
2480
2747
|
tool: "ft ci",
|
|
2481
2748
|
short,
|
|
@@ -2500,7 +2767,7 @@ async function ci2(args) {
|
|
|
2500
2767
|
},
|
|
2501
2768
|
lines: (spinner, found, started) => [
|
|
2502
2769
|
`${spinner} CI on ${short} ${dim(formatElapsed(Date.now() - started))}`,
|
|
2503
|
-
...(found ?? []).map((run) => ` ${badge(run.status,
|
|
2770
|
+
...(found ?? []).map((run) => ` ${badge(run.status, process19.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
|
|
2504
2771
|
]
|
|
2505
2772
|
});
|
|
2506
2773
|
const status = overall(runs);
|
|
@@ -2530,7 +2797,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2530
2797
|
}
|
|
2531
2798
|
|
|
2532
2799
|
// src/commands/digest.ts
|
|
2533
|
-
import
|
|
2800
|
+
import process20 from "process";
|
|
2534
2801
|
var RUNS_SCANNED = 50;
|
|
2535
2802
|
var TITLE_WIDTH2 = 70;
|
|
2536
2803
|
var SHOWN = 8;
|
|
@@ -2580,7 +2847,7 @@ async function quietly(read) {
|
|
|
2580
2847
|
}
|
|
2581
2848
|
}
|
|
2582
2849
|
async function staleTodos() {
|
|
2583
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
2850
|
+
const bin = Bun.which("todo-scan", { PATH: process20.env.PATH ?? "" });
|
|
2584
2851
|
if (bin === null)
|
|
2585
2852
|
return [];
|
|
2586
2853
|
let found;
|
|
@@ -3423,8 +3690,8 @@ function report(plan, added, skipped) {
|
|
|
3423
3690
|
}
|
|
3424
3691
|
|
|
3425
3692
|
// src/commands/release.ts
|
|
3426
|
-
import { basename as basename3, join as
|
|
3427
|
-
import
|
|
3693
|
+
import { basename as basename3, join as join11 } from "path";
|
|
3694
|
+
import process22 from "process";
|
|
3428
3695
|
var {$: $2 } = globalThis.Bun;
|
|
3429
3696
|
|
|
3430
3697
|
// src/commands/watch.ts
|
|
@@ -3606,7 +3873,7 @@ ${push.stderr.trim()}`, 1);
|
|
|
3606
3873
|
|
|
3607
3874
|
// src/commands/release-many.ts
|
|
3608
3875
|
import { readdir } from "fs/promises";
|
|
3609
|
-
import { join as
|
|
3876
|
+
import { join as join8 } from "path";
|
|
3610
3877
|
|
|
3611
3878
|
// src/commands/release-version.ts
|
|
3612
3879
|
var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
|
|
@@ -3655,11 +3922,11 @@ function parseTargets(spec, level) {
|
|
|
3655
3922
|
});
|
|
3656
3923
|
}
|
|
3657
3924
|
async function publishable() {
|
|
3658
|
-
const root =
|
|
3925
|
+
const root = join8(await git(["rev-parse", "--show-toplevel"]), "packages");
|
|
3659
3926
|
const folders = (await readdir(root, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted();
|
|
3660
3927
|
const found = [];
|
|
3661
3928
|
for (const folder of folders) {
|
|
3662
|
-
const file = Bun.file(
|
|
3929
|
+
const file = Bun.file(join8(root, folder, "package.json"));
|
|
3663
3930
|
if (await file.exists() && (await file.json()).private !== true)
|
|
3664
3931
|
found.push(folder);
|
|
3665
3932
|
}
|
|
@@ -3667,13 +3934,13 @@ async function publishable() {
|
|
|
3667
3934
|
}
|
|
3668
3935
|
|
|
3669
3936
|
// src/commands/release-plan.ts
|
|
3670
|
-
import { basename as basename2, join as
|
|
3671
|
-
import
|
|
3937
|
+
import { basename as basename2, join as join9, relative } from "path";
|
|
3938
|
+
import process21 from "process";
|
|
3672
3939
|
async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
|
|
3673
|
-
const file = Bun.file(
|
|
3940
|
+
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
3674
3941
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
3675
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
3676
|
-
const where = dir === undefined ? "" : ` in ${relative(
|
|
3942
|
+
const name = pkg?.name ?? basename2(dir ?? process21.cwd());
|
|
3943
|
+
const where = dir === undefined ? "" : ` in ${relative(process21.cwd(), dir) || "."}`;
|
|
3677
3944
|
const sha = base.slice(0, 7);
|
|
3678
3945
|
let version;
|
|
3679
3946
|
let bump;
|
|
@@ -3686,7 +3953,7 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
|
|
|
3686
3953
|
console.log(`would release ${name} ${version}, tagged ${tag}`);
|
|
3687
3954
|
} else {
|
|
3688
3955
|
if (pkg?.version === undefined)
|
|
3689
|
-
fail(`no version in ${
|
|
3956
|
+
fail(`no version in ${join9(dir ?? ".", "package.json")}`);
|
|
3690
3957
|
version = nextVersion(pkg.version, level);
|
|
3691
3958
|
bump = dir === undefined ? `bun pm version ${level}, which commits and tags ${prefix}${version}` : `bun pm version ${level} --no-git-tag-version${where}, then commit it with bun.lock refreshed and tag ${prefix}${version}`;
|
|
3692
3959
|
console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
|
|
@@ -3706,25 +3973,25 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
|
|
|
3706
3973
|
}
|
|
3707
3974
|
|
|
3708
3975
|
// src/commands/release-steps.ts
|
|
3709
|
-
import { join as
|
|
3976
|
+
import { join as join10, relative as relative2, resolve as resolve3 } from "path";
|
|
3710
3977
|
var {$ } = globalThis.Bun;
|
|
3711
3978
|
var registryWait = { tries: 12, poll: 5000 };
|
|
3712
3979
|
var REGISTRY_INFO_MS = 30000;
|
|
3713
3980
|
async function packageDir(value) {
|
|
3714
|
-
for (const dir of [
|
|
3715
|
-
if (await Bun.file(
|
|
3981
|
+
for (const dir of [resolve3(value), join10(await git(["rev-parse", "--show-toplevel"]), "packages", value)]) {
|
|
3982
|
+
if (await Bun.file(join10(dir, "package.json")).exists())
|
|
3716
3983
|
return dir;
|
|
3717
3984
|
}
|
|
3718
3985
|
fail(`no package.json in ${value} nor in packages/${value}`);
|
|
3719
3986
|
}
|
|
3720
3987
|
async function commitPackageBump(dir, prefix) {
|
|
3721
|
-
const { version } = await Bun.file(
|
|
3988
|
+
const { version } = await Bun.file(join10(dir, "package.json")).json();
|
|
3722
3989
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
3723
3990
|
const tag = `${prefix}${version}`;
|
|
3724
3991
|
const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
|
|
3725
3992
|
if (lock.exitCode !== 0)
|
|
3726
3993
|
fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
|
|
3727
|
-
await git(["add",
|
|
3994
|
+
await git(["add", join10(dir, "package.json"), join10(root, "bun.lock")]);
|
|
3728
3995
|
await git(["commit", "-q", "-m", tag]);
|
|
3729
3996
|
await git(["tag", "-a", tag, "-m", tag]);
|
|
3730
3997
|
}
|
|
@@ -3753,11 +4020,11 @@ async function rollBack(preBump, tagsBefore, dir) {
|
|
|
3753
4020
|
await git(["reset", "--keep", preBump]);
|
|
3754
4021
|
if (dir !== undefined) {
|
|
3755
4022
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
3756
|
-
const paths = [
|
|
4023
|
+
const paths = [join10(dir, "package.json"), join10(root, "bun.lock")].map((path) => relative2(root, path));
|
|
3757
4024
|
const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", preBump, "--", ...paths])).split(`
|
|
3758
4025
|
`).filter((path) => path !== "");
|
|
3759
4026
|
if (tracked.length > 0)
|
|
3760
|
-
await git(["restore", `--source=${preBump}`, "--staged", "--worktree", "--", ...tracked.map((path) =>
|
|
4027
|
+
await git(["restore", `--source=${preBump}`, "--staged", "--worktree", "--", ...tracked.map((path) => join10(root, path))]);
|
|
3761
4028
|
}
|
|
3762
4029
|
} catch (error) {
|
|
3763
4030
|
warn(`could not undo the bump, back to ${preBump.slice(0, 7)} by hand`, error instanceof Error ? error.message : String(error));
|
|
@@ -3914,7 +4181,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
3914
4181
|
if (!pushed && !isPushUnknown && level !== undefined)
|
|
3915
4182
|
await rollBack(preBump, tagsBefore, dir);
|
|
3916
4183
|
}
|
|
3917
|
-
const file = Bun.file(
|
|
4184
|
+
const file = Bun.file(join11(dir ?? ".", "package.json"));
|
|
3918
4185
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
3919
4186
|
const version = tag.slice(prefix.length);
|
|
3920
4187
|
let followed = { code: 0, runs: [], failedJobs: [] };
|
|
@@ -3932,7 +4199,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
3932
4199
|
if (late !== undefined)
|
|
3933
4200
|
fail(`interrupted by ${late} after ${tag} was pushed: its runs are not waited for`, exitCodeOf(null, late));
|
|
3934
4201
|
say(`pushed ${branch} and ${tag}, waiting for their runs`);
|
|
3935
|
-
followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2, json ?
|
|
4202
|
+
followed = await followRuns((runs) => runs.filter((run) => run.id > before && run.commit_sha === head), timeout, undefined, NO_RUN2, json ? process22.stderr : process22.stdout, { json });
|
|
3936
4203
|
if (followed.code !== 0) {
|
|
3937
4204
|
outcome(false);
|
|
3938
4205
|
return followed.code;
|
|
@@ -3985,40 +4252,6 @@ async function loadSettings(home) {
|
|
|
3985
4252
|
return typeof host === "string" && host !== "" ? { remoteHost: host } : {};
|
|
3986
4253
|
}
|
|
3987
4254
|
|
|
3988
|
-
// src/remote.ts
|
|
3989
|
-
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
3990
|
-
var SSH_URL = /^ssh:\/\/(?:([^@/]+)@)?([^:/]+)(?::(\d+))?\/(.+?)(?:\.git)?\/?$/;
|
|
3991
|
-
var USERINFO = /^([a-z][a-z\d+.-]*:\/\/)[^@/]*@/i;
|
|
3992
|
-
var DEFAULT_PORT = "22";
|
|
3993
|
-
function parseSshRemote(url) {
|
|
3994
|
-
const ssh = SSH_URL.exec(url);
|
|
3995
|
-
const scp = ssh === null && !url.includes("://") ? SCP_LIKE.exec(url) : null;
|
|
3996
|
-
const match = ssh ?? scp;
|
|
3997
|
-
if (match === null || match[2]?.startsWith("-") === true)
|
|
3998
|
-
return;
|
|
3999
|
-
const login = match[1] ?? "git";
|
|
4000
|
-
const user = login.includes(":") ? login.slice(0, login.indexOf(":")) : login;
|
|
4001
|
-
if (ssh === null)
|
|
4002
|
-
return { user, host: match[2] ?? "", path: match[3] ?? "" };
|
|
4003
|
-
return { user, host: match[2] ?? "", path: match[4] ?? "", ...ssh[3] === undefined ? {} : { port: ssh[3] } };
|
|
4004
|
-
}
|
|
4005
|
-
function redactUrl(url) {
|
|
4006
|
-
return url.replace(USERINFO, "$1");
|
|
4007
|
-
}
|
|
4008
|
-
function canonicalRemote(url, host, reaches) {
|
|
4009
|
-
const remote = parseSshRemote(url);
|
|
4010
|
-
if (remote === undefined || remote.host === host || !reaches(remote.host))
|
|
4011
|
-
return;
|
|
4012
|
-
if (remote.port !== undefined && remote.port !== DEFAULT_PORT)
|
|
4013
|
-
return `ssh://${remote.user}@${host}:${remote.port}/${remote.path}.git`;
|
|
4014
|
-
return `${remote.user}@${host}:${remote.path}.git`;
|
|
4015
|
-
}
|
|
4016
|
-
async function reachesHost(hostname, host, hostAddresses, addressesOf) {
|
|
4017
|
-
if (hostname === undefined)
|
|
4018
|
-
return false;
|
|
4019
|
-
return hostname === host || (await addressesOf(hostname)).some((address) => hostAddresses.has(address));
|
|
4020
|
-
}
|
|
4021
|
-
|
|
4022
4255
|
// src/commands/remote.ts
|
|
4023
4256
|
var usage7 = `ft remote [--fix]
|
|
4024
4257
|
|
|
@@ -4056,7 +4289,7 @@ async function restoreOrigin(fetchUrl, pushUrls, changes) {
|
|
|
4056
4289
|
await git(["remote", "set-url", "--push", "origin", from, to]);
|
|
4057
4290
|
}
|
|
4058
4291
|
}
|
|
4059
|
-
function
|
|
4292
|
+
function originHost2(url) {
|
|
4060
4293
|
return parseSshRemote(url)?.host ?? (URL.canParse(url) ? new URL(url).hostname : undefined);
|
|
4061
4294
|
}
|
|
4062
4295
|
async function remote(args, home) {
|
|
@@ -4083,7 +4316,7 @@ async function remote(args, home) {
|
|
|
4083
4316
|
}
|
|
4084
4317
|
const changes = [fetchUrl, ...pushUrls].map((url) => [url, canonicalRemote(url, host, (alias) => reaching.has(alias))]).filter((change) => change[1] !== undefined);
|
|
4085
4318
|
if (changes.length === 0) {
|
|
4086
|
-
const named =
|
|
4319
|
+
const named = originHost2(fetchUrl);
|
|
4087
4320
|
if (named === host) {
|
|
4088
4321
|
console.log(`origin already names ${host}: ${redactUrl(fetchUrl)}`);
|
|
4089
4322
|
return 0;
|
|
@@ -4161,7 +4394,7 @@ async function runs(args) {
|
|
|
4161
4394
|
}
|
|
4162
4395
|
|
|
4163
4396
|
// src/cli.ts
|
|
4164
|
-
|
|
4397
|
+
process23.exitCode = await runCli({
|
|
4165
4398
|
name: "ft",
|
|
4166
4399
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4167
4400
|
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.16.0",
|
|
5
5
|
"description": "ft: Forgejo CI runs, logs, releases and issue checklists from the terminal, through tea.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"ft": "$npm_execpath src/cli.ts"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@kaynooo/cli-kit": "0.21.
|
|
31
|
+
"@kaynooo/cli-kit": "0.21.1"
|
|
32
32
|
}
|
|
33
33
|
}
|