@kaynooo/cli-forgejo 0.15.2 → 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 +324 -145
- package/package.json +1 -1
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: {}
|
|
283
324
|
};
|
|
284
|
-
|
|
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 }
|
|
333
|
+
};
|
|
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 } }));
|
|
@@ -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" }
|
|
@@ -1759,9 +1935,9 @@ function holderSession(holder, sessions) {
|
|
|
1759
1935
|
}
|
|
1760
1936
|
|
|
1761
1937
|
// src/forge.ts
|
|
1762
|
-
import { homedir as
|
|
1763
|
-
import { join as
|
|
1764
|
-
import
|
|
1938
|
+
import { homedir as homedir5 } from "os";
|
|
1939
|
+
import { join as join7 } from "path";
|
|
1940
|
+
import process18 from "process";
|
|
1765
1941
|
|
|
1766
1942
|
// src/remote.ts
|
|
1767
1943
|
var SCP_LIKE = /^(?:([^@/]+)@)?([^:/]+):(?!\/)(.+?)(?:\.git)?\/?$/;
|
|
@@ -1816,8 +1992,8 @@ function loginHosts(config) {
|
|
|
1816
1992
|
return hosts;
|
|
1817
1993
|
}
|
|
1818
1994
|
function teaConfigPath() {
|
|
1819
|
-
const base =
|
|
1820
|
-
return
|
|
1995
|
+
const base = process18.env.XDG_CONFIG_HOME;
|
|
1996
|
+
return join7(base !== undefined && base !== "" ? base : join7(homedir5(), ".config"), "tea", "config.yml");
|
|
1821
1997
|
}
|
|
1822
1998
|
async function readConfig() {
|
|
1823
1999
|
try {
|
|
@@ -2092,6 +2268,9 @@ function standing(claim, sessions) {
|
|
|
2092
2268
|
}
|
|
2093
2269
|
var NOTE_WIDTH = 100;
|
|
2094
2270
|
var STATES = new Set(["available", "taken", "away"]);
|
|
2271
|
+
function dimmed(text) {
|
|
2272
|
+
return text === "" ? "" : paint(process.stdout).dim(text);
|
|
2273
|
+
}
|
|
2095
2274
|
function boxesLeft(issue) {
|
|
2096
2275
|
const list = boxes(issue.body);
|
|
2097
2276
|
return list.length === 0 ? "" : `${list.filter((box) => !box.done).length}/${list.length} left`;
|
|
@@ -2099,7 +2278,7 @@ function boxesLeft(issue) {
|
|
|
2099
2278
|
function claimRow(issue, row, now) {
|
|
2100
2279
|
const holder = row.state === "taken" && row.session.name !== row.claim.holder ? `${row.claim.holder} via ${row.session.name}` : row.claim.holder;
|
|
2101
2280
|
const status = row.state === "taken" ? ` (${row.session.status})` : "";
|
|
2102
|
-
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)];
|
|
2103
2282
|
}
|
|
2104
2283
|
function noteLine(comments, now) {
|
|
2105
2284
|
const note = latestNote(comments);
|
|
@@ -2118,11 +2297,11 @@ function renderBoard(rows, now = Date.now(), limit = Number.POSITIVE_INFINITY) {
|
|
|
2118
2297
|
const taken = claimed("taken");
|
|
2119
2298
|
const away = claimed("away");
|
|
2120
2299
|
const sections = [
|
|
2121
|
-
{ 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(", "))]) },
|
|
2122
2301
|
{ heading: "taken", count: taken.length, ...within(taken, limit, ({ issue, row }) => claimRow(issue, row, now)) },
|
|
2123
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)]) }
|
|
2124
2303
|
].filter((section) => section.count > 0);
|
|
2125
|
-
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})`)}
|
|
2126
2305
|
${lines.join(`
|
|
2127
2306
|
`).replace(LINE_START, " ")}`).join(`
|
|
2128
2307
|
|
|
@@ -2307,7 +2486,7 @@ async function drop(args) {
|
|
|
2307
2486
|
}
|
|
2308
2487
|
|
|
2309
2488
|
// src/commands/ci.ts
|
|
2310
|
-
import
|
|
2489
|
+
import process19 from "process";
|
|
2311
2490
|
|
|
2312
2491
|
// src/git.ts
|
|
2313
2492
|
async function tagsAt(commit) {
|
|
@@ -2563,7 +2742,7 @@ async function ci2(args) {
|
|
|
2563
2742
|
return;
|
|
2564
2743
|
}
|
|
2565
2744
|
const json = values.json === true;
|
|
2566
|
-
const { dim } = paint(
|
|
2745
|
+
const { dim } = paint(process19.stderr);
|
|
2567
2746
|
const runs = await waitForCi({
|
|
2568
2747
|
tool: "ft ci",
|
|
2569
2748
|
short,
|
|
@@ -2588,7 +2767,7 @@ async function ci2(args) {
|
|
|
2588
2767
|
},
|
|
2589
2768
|
lines: (spinner, found, started) => [
|
|
2590
2769
|
`${spinner} CI on ${short} ${dim(formatElapsed(Date.now() - started))}`,
|
|
2591
|
-
...(found ?? []).map((run) => ` ${badge(run.status,
|
|
2770
|
+
...(found ?? []).map((run) => ` ${badge(run.status, process19.stderr)} ${run.workflow_id} ${dim(`run ${run.id}`)}`)
|
|
2592
2771
|
]
|
|
2593
2772
|
});
|
|
2594
2773
|
const status = overall(runs);
|
|
@@ -2618,7 +2797,7 @@ run ${run.id} failed${run.commit_sha === sha ? "" : `, testing every commit from
|
|
|
2618
2797
|
}
|
|
2619
2798
|
|
|
2620
2799
|
// src/commands/digest.ts
|
|
2621
|
-
import
|
|
2800
|
+
import process20 from "process";
|
|
2622
2801
|
var RUNS_SCANNED = 50;
|
|
2623
2802
|
var TITLE_WIDTH2 = 70;
|
|
2624
2803
|
var SHOWN = 8;
|
|
@@ -2668,7 +2847,7 @@ async function quietly(read) {
|
|
|
2668
2847
|
}
|
|
2669
2848
|
}
|
|
2670
2849
|
async function staleTodos() {
|
|
2671
|
-
const bin = Bun.which("todo-scan", { PATH:
|
|
2850
|
+
const bin = Bun.which("todo-scan", { PATH: process20.env.PATH ?? "" });
|
|
2672
2851
|
if (bin === null)
|
|
2673
2852
|
return [];
|
|
2674
2853
|
let found;
|
|
@@ -3511,8 +3690,8 @@ function report(plan, added, skipped) {
|
|
|
3511
3690
|
}
|
|
3512
3691
|
|
|
3513
3692
|
// src/commands/release.ts
|
|
3514
|
-
import { basename as basename3, join as
|
|
3515
|
-
import
|
|
3693
|
+
import { basename as basename3, join as join11 } from "path";
|
|
3694
|
+
import process22 from "process";
|
|
3516
3695
|
var {$: $2 } = globalThis.Bun;
|
|
3517
3696
|
|
|
3518
3697
|
// src/commands/watch.ts
|
|
@@ -3694,7 +3873,7 @@ ${push.stderr.trim()}`, 1);
|
|
|
3694
3873
|
|
|
3695
3874
|
// src/commands/release-many.ts
|
|
3696
3875
|
import { readdir } from "fs/promises";
|
|
3697
|
-
import { join as
|
|
3876
|
+
import { join as join8 } from "path";
|
|
3698
3877
|
|
|
3699
3878
|
// src/commands/release-version.ts
|
|
3700
3879
|
var LEVELS = new Set(["patch", "minor", "major", "prepatch", "preminor", "premajor", "prerelease"]);
|
|
@@ -3743,11 +3922,11 @@ function parseTargets(spec, level) {
|
|
|
3743
3922
|
});
|
|
3744
3923
|
}
|
|
3745
3924
|
async function publishable() {
|
|
3746
|
-
const root =
|
|
3925
|
+
const root = join8(await git(["rev-parse", "--show-toplevel"]), "packages");
|
|
3747
3926
|
const folders = (await readdir(root, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).toSorted();
|
|
3748
3927
|
const found = [];
|
|
3749
3928
|
for (const folder of folders) {
|
|
3750
|
-
const file = Bun.file(
|
|
3929
|
+
const file = Bun.file(join8(root, folder, "package.json"));
|
|
3751
3930
|
if (await file.exists() && (await file.json()).private !== true)
|
|
3752
3931
|
found.push(folder);
|
|
3753
3932
|
}
|
|
@@ -3755,13 +3934,13 @@ async function publishable() {
|
|
|
3755
3934
|
}
|
|
3756
3935
|
|
|
3757
3936
|
// src/commands/release-plan.ts
|
|
3758
|
-
import { basename as basename2, join as
|
|
3759
|
-
import
|
|
3937
|
+
import { basename as basename2, join as join9, relative } from "path";
|
|
3938
|
+
import process21 from "process";
|
|
3760
3939
|
async function printPlan({ level, dir, prefix, branch, base, timeout, registry }) {
|
|
3761
|
-
const file = Bun.file(
|
|
3940
|
+
const file = Bun.file(join9(dir ?? ".", "package.json"));
|
|
3762
3941
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
3763
|
-
const name = pkg?.name ?? basename2(dir ??
|
|
3764
|
-
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) || "."}`;
|
|
3765
3944
|
const sha = base.slice(0, 7);
|
|
3766
3945
|
let version;
|
|
3767
3946
|
let bump;
|
|
@@ -3774,7 +3953,7 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
|
|
|
3774
3953
|
console.log(`would release ${name} ${version}, tagged ${tag}`);
|
|
3775
3954
|
} else {
|
|
3776
3955
|
if (pkg?.version === undefined)
|
|
3777
|
-
fail(`no version in ${
|
|
3956
|
+
fail(`no version in ${join9(dir ?? ".", "package.json")}`);
|
|
3778
3957
|
version = nextVersion(pkg.version, level);
|
|
3779
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}`;
|
|
3780
3959
|
console.log(`would release ${name} ${pkg.version} -> ${version}, tagged ${prefix}${version}`);
|
|
@@ -3794,25 +3973,25 @@ async function printPlan({ level, dir, prefix, branch, base, timeout, registry }
|
|
|
3794
3973
|
}
|
|
3795
3974
|
|
|
3796
3975
|
// src/commands/release-steps.ts
|
|
3797
|
-
import { join as
|
|
3976
|
+
import { join as join10, relative as relative2, resolve as resolve3 } from "path";
|
|
3798
3977
|
var {$ } = globalThis.Bun;
|
|
3799
3978
|
var registryWait = { tries: 12, poll: 5000 };
|
|
3800
3979
|
var REGISTRY_INFO_MS = 30000;
|
|
3801
3980
|
async function packageDir(value) {
|
|
3802
|
-
for (const dir of [
|
|
3803
|
-
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())
|
|
3804
3983
|
return dir;
|
|
3805
3984
|
}
|
|
3806
3985
|
fail(`no package.json in ${value} nor in packages/${value}`);
|
|
3807
3986
|
}
|
|
3808
3987
|
async function commitPackageBump(dir, prefix) {
|
|
3809
|
-
const { version } = await Bun.file(
|
|
3988
|
+
const { version } = await Bun.file(join10(dir, "package.json")).json();
|
|
3810
3989
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
3811
3990
|
const tag = `${prefix}${version}`;
|
|
3812
3991
|
const lock = await $`bun install --lockfile-only`.cwd(root).quiet().nothrow();
|
|
3813
3992
|
if (lock.exitCode !== 0)
|
|
3814
3993
|
fail(`bun install --lockfile-only after the bump: ${lock.stderr.toString().trim()}`);
|
|
3815
|
-
await git(["add",
|
|
3994
|
+
await git(["add", join10(dir, "package.json"), join10(root, "bun.lock")]);
|
|
3816
3995
|
await git(["commit", "-q", "-m", tag]);
|
|
3817
3996
|
await git(["tag", "-a", tag, "-m", tag]);
|
|
3818
3997
|
}
|
|
@@ -3841,11 +4020,11 @@ async function rollBack(preBump, tagsBefore, dir) {
|
|
|
3841
4020
|
await git(["reset", "--keep", preBump]);
|
|
3842
4021
|
if (dir !== undefined) {
|
|
3843
4022
|
const root = await git(["rev-parse", "--show-toplevel"]);
|
|
3844
|
-
const paths = [
|
|
4023
|
+
const paths = [join10(dir, "package.json"), join10(root, "bun.lock")].map((path) => relative2(root, path));
|
|
3845
4024
|
const tracked = (await git(["ls-tree", "-r", "--full-tree", "--name-only", preBump, "--", ...paths])).split(`
|
|
3846
4025
|
`).filter((path) => path !== "");
|
|
3847
4026
|
if (tracked.length > 0)
|
|
3848
|
-
await git(["restore", `--source=${preBump}`, "--staged", "--worktree", "--", ...tracked.map((path) =>
|
|
4027
|
+
await git(["restore", `--source=${preBump}`, "--staged", "--worktree", "--", ...tracked.map((path) => join10(root, path))]);
|
|
3849
4028
|
}
|
|
3850
4029
|
} catch (error) {
|
|
3851
4030
|
warn(`could not undo the bump, back to ${preBump.slice(0, 7)} by hand`, error instanceof Error ? error.message : String(error));
|
|
@@ -4002,7 +4181,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4002
4181
|
if (!pushed && !isPushUnknown && level !== undefined)
|
|
4003
4182
|
await rollBack(preBump, tagsBefore, dir);
|
|
4004
4183
|
}
|
|
4005
|
-
const file = Bun.file(
|
|
4184
|
+
const file = Bun.file(join11(dir ?? ".", "package.json"));
|
|
4006
4185
|
const pkg = await file.exists() ? await file.json() : undefined;
|
|
4007
4186
|
const version = tag.slice(prefix.length);
|
|
4008
4187
|
let followed = { code: 0, runs: [], failedJobs: [] };
|
|
@@ -4020,7 +4199,7 @@ ${push.stderr.trim()}`, signal === undefined ? 1 : exitCodeOf(null, signal));
|
|
|
4020
4199
|
if (late !== undefined)
|
|
4021
4200
|
fail(`interrupted by ${late} after ${tag} was pushed: its runs are not waited for`, exitCodeOf(null, late));
|
|
4022
4201
|
say(`pushed ${branch} and ${tag}, waiting for their runs`);
|
|
4023
|
-
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 });
|
|
4024
4203
|
if (followed.code !== 0) {
|
|
4025
4204
|
outcome(false);
|
|
4026
4205
|
return followed.code;
|
|
@@ -4215,7 +4394,7 @@ async function runs(args) {
|
|
|
4215
4394
|
}
|
|
4216
4395
|
|
|
4217
4396
|
// src/cli.ts
|
|
4218
|
-
|
|
4397
|
+
process23.exitCode = await runCli({
|
|
4219
4398
|
name: "ft",
|
|
4220
4399
|
about: "Forgejo tools over tea, run from a repository whose origin is on Forgejo",
|
|
4221
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",
|