@kaynooo/cli-check 0.13.0 → 0.14.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 CHANGED
@@ -2,16 +2,16 @@
2
2
  // @bun
3
3
 
4
4
  // src/cli.ts
5
- import process16 from "process";
5
+ import process19 from "process";
6
6
  // ../kit/src/args.ts
7
- import process6 from "process";
7
+ import process9 from "process";
8
8
  import { parseArgs } from "util";
9
9
 
10
10
  // ../kit/src/format.ts
11
- import process3 from "process";
11
+ import process6 from "process";
12
12
 
13
13
  // ../kit/src/style.ts
14
- import process2 from "process";
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,36 +274,232 @@ function le(i = {}) {
274
274
  }
275
275
  var t = le();
276
276
 
277
- // ../kit/src/style.ts
278
- var MARKS = {
279
- ok: { symbol: "\u2713", word: "ok:", paint: (colors) => colors.green },
280
- warn: { symbol: "!", word: "warning:", paint: (colors) => colors.yellow },
281
- problem: { symbol: "\u2717", word: "error:", paint: (colors) => colors.red },
282
- note: { symbol: "\xB7", word: "note:", paint: (colors) => colors.dim }
277
+ // ../kit/src/theme.ts
278
+ import { existsSync as existsSync2, 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 { homedir } from "os";
300
+ import { join as join2 } from "path";
301
+ import process3 from "process";
302
+ function configBase(where = {}) {
303
+ const xdg = where.xdg ?? (where.home === undefined ? process3.env.XDG_CONFIG_HOME : undefined);
304
+ return xdg !== undefined && xdg !== "" ? xdg : join2(where.home ?? homedir(), ".config");
305
+ }
306
+ function userConfigPath(bin, where = {}) {
307
+ return join2(configBase(where), "kaynooo-cli", `${bin}.json`);
308
+ }
309
+
310
+ // ../kit/src/theme.ts
311
+ var DEFAULT = {
312
+ 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" },
313
+ glyphs: { ok: "\u2713", warn: "\u25B2", problem: "\u2717", note: "\u203A", passed: "\u2713", failed: "\u2717", running: "\u25CF", queued: "\u25CB", skipped: "-", bar: "\u2501" },
314
+ accents: ["cyan", "magenta", "green", "blue", "yellow", "redBright"],
315
+ bins: {}
283
316
  };
284
- function takesControlCodes(stream, env = process2.env) {
317
+ 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" };
318
+ 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" };
319
+ var ASCII = { ok: "+", warn: "!", problem: "x", note: ">", passed: "+", failed: "x", running: "*", queued: "o", skipped: "-", bar: "#" };
320
+ var PRESETS = {
321
+ default: {},
322
+ "high-contrast": { colors: BRIGHT, accents: ["cyanBright", "magentaBright", "greenBright", "blueBright", "yellowBright", "redBright"] },
323
+ mono: { colors: MONO, accents: ["bold"] },
324
+ ascii: { glyphs: ASCII }
325
+ };
326
+ 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"]);
327
+ var HEX = /^#[0-9a-f]{6}$/i;
328
+ var CONTROL = /\p{Cc}/u;
329
+ var MAX_FILE_BYTES = 64 * 1024;
330
+ var SPACES = /\s+/;
331
+ function isColorSpec(spec) {
332
+ if (typeof spec === "number")
333
+ return Number.isInteger(spec) && spec >= 0 && spec <= 255;
334
+ return typeof spec === "string" && spec.trim() !== "" && spec.trim().split(SPACES).every((token) => STYLES.has(token) || HEX.test(token));
335
+ }
336
+ function tinted(colors, spec) {
337
+ if (typeof spec === "number")
338
+ return colors.ansi256(spec);
339
+ return spec.trim().split(SPACES).reduce((chain, token) => HEX.test(token) ? chain.hex(token) : chain[token] ?? chain, colors);
340
+ }
341
+ function isRecord(value) {
342
+ return typeof value === "object" && value !== null && !Array.isArray(value);
343
+ }
344
+ function readThemeFile(path, warn) {
345
+ try {
346
+ const stat = statSync(path, { throwIfNoEntry: false });
347
+ if (stat === undefined)
348
+ return;
349
+ if (!stat.isFile() || stat.size > MAX_FILE_BYTES) {
350
+ warn(`${path} is not a regular file under ${MAX_FILE_BYTES / 1024} KiB, theme ignored`);
351
+ return;
352
+ }
353
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
354
+ if (isRecord(parsed))
355
+ return parsed;
356
+ warn(`${path} is not a JSON object, theme ignored`);
357
+ } catch (error) {
358
+ warn(`${path} does not parse (${error instanceof Error ? error.message : String(error)}), theme ignored`);
359
+ }
360
+ return;
361
+ }
362
+ function applyPreset(theme, name, warn, where) {
363
+ if (name === undefined)
364
+ return;
365
+ if (typeof name !== "string" || !Object.hasOwn(PRESETS, name)) {
366
+ warn(`${where}: no preset ${String(name)}, one of ${Object.keys(PRESETS).join(", ")}`);
367
+ return;
368
+ }
369
+ const preset = PRESETS[name];
370
+ Object.assign(theme.colors, preset.colors);
371
+ Object.assign(theme.glyphs, preset.glyphs);
372
+ if (preset.accents !== undefined)
373
+ theme.accents = [...preset.accents];
374
+ return name;
375
+ }
376
+ function applyFile(theme, file, where, warn) {
377
+ if (isRecord(file.colors)) {
378
+ for (const [key, value] of Object.entries(file.colors)) {
379
+ if (!Object.hasOwn(DEFAULT.colors, key))
380
+ warn(`${where}: no colour ${key}, one of ${Object.keys(DEFAULT.colors).join(", ")}`);
381
+ else if (!isColorSpec(value))
382
+ warn(`${where}: colour ${key} is not an ANSI name, \`#rrggbb\` or a number up to 255`);
383
+ else
384
+ theme.colors[key] = value;
385
+ }
386
+ }
387
+ if (isRecord(file.glyphs)) {
388
+ for (const [key, value] of Object.entries(file.glyphs)) {
389
+ if (!Object.hasOwn(DEFAULT.glyphs, key))
390
+ warn(`${where}: no glyph ${key}, one of ${Object.keys(DEFAULT.glyphs).join(", ")}`);
391
+ else if (typeof value !== "string" || CONTROL.test(value) || Bun.stringWidth(value) !== 1)
392
+ warn(`${where}: glyph ${key} must be one visible character wide, with no control character`);
393
+ else
394
+ theme.glyphs[key] = value;
395
+ }
396
+ }
397
+ if (Array.isArray(file.accents) && file.accents.length > 0 && file.accents.every(isColorSpec))
398
+ theme.accents = [...file.accents];
399
+ else if (file.accents !== undefined)
400
+ warn(`${where}: accents must be a non-empty list of colours`);
401
+ if (isRecord(file.bins)) {
402
+ for (const [bin, value] of Object.entries(file.bins)) {
403
+ if (isColorSpec(value))
404
+ theme.bins[bin] = value;
405
+ else
406
+ warn(`${where}: bin ${bin} has no valid colour`);
407
+ }
408
+ }
409
+ }
410
+ function endsWalk(home) {
411
+ return (dir) => dir === resolve2(home) || existsSync2(join3(dir, ".git"));
412
+ }
413
+ var warned = new Set;
414
+ function warnOnce(message) {
415
+ if (warned.has(message))
416
+ return;
417
+ warned.add(message);
418
+ console.error(`warning: theme ${message}`);
419
+ }
420
+ function isPath(chosen) {
421
+ return chosen.includes("/") || chosen.endsWith(".json");
422
+ }
423
+ function loadTheme({ env = process4.env, from = process4.cwd(), home = homedir2(), warn = warnOnce } = {}) {
424
+ const theme = { colors: { ...DEFAULT.colors }, glyphs: { ...DEFAULT.glyphs }, accents: [...DEFAULT.accents], bins: Object.create(null) };
425
+ const sources = [];
426
+ const chosen = env.KIT_THEME ?? "";
427
+ const wanted = chosen === "" ? [userConfigPath("theme", { home, xdg: env.XDG_CONFIG_HOME }), findUp(join3(".kaynooo", "theme.json"), from, endsWalk(home))] : [];
428
+ if (isPath(chosen))
429
+ wanted.push(resolve2(from, chosen));
430
+ const files = [];
431
+ for (const path of wanted) {
432
+ const file = path === undefined ? undefined : readThemeFile(path, warn);
433
+ if (path !== undefined && file !== undefined)
434
+ files.push({ path, file });
435
+ }
436
+ let preset = "default";
437
+ if (chosen !== "" && !isPath(chosen)) {
438
+ preset = applyPreset(theme, chosen, warn, "KIT_THEME") ?? preset;
439
+ } else {
440
+ const named = files.findLast(({ file }) => file.preset !== undefined);
441
+ if (named !== undefined)
442
+ preset = applyPreset(theme, named.file.preset, warn, named.path) ?? preset;
443
+ }
444
+ for (const { path, file } of files) {
445
+ applyFile(theme, file, path, warn);
446
+ sources.push(path);
447
+ }
448
+ return { theme, sources, preset };
449
+ }
450
+ var current;
451
+ var currentKey = "";
452
+ function activeTheme() {
453
+ const key = `${process4.cwd()}\x00${process4.env.KIT_THEME ?? ""}\x00${process4.env.XDG_CONFIG_HOME ?? ""}`;
454
+ if (current === undefined || key !== currentKey) {
455
+ current = loadTheme();
456
+ currentKey = key;
457
+ }
458
+ return current;
459
+ }
460
+
461
+ // ../kit/src/style.ts
462
+ var MARK_WORDS = { ok: "ok:", warn: "warning:", problem: "error:", note: "note:" };
463
+ function takesControlCodes(stream, env = process5.env) {
285
464
  return stream.isTTY === true && env.NO_COLOR === undefined && env.NODE_DISABLE_COLORS === undefined && env.TERM !== "dumb";
286
465
  }
287
- function paint(stream, env = process2.env) {
466
+ function paint(stream, env = process5.env) {
288
467
  return le({ stream: { isTTY: takesControlCodes(stream, env) }, env });
289
468
  }
290
- function marked(mark, text, stream, detail, env = process2.env) {
469
+ function marked(mark, text, stream, detail, env = process5.env) {
291
470
  const colors = paint(stream, env);
292
- const { symbol, word, paint: tint } = MARKS[mark];
293
- const head = takesControlCodes(stream, env) ? tint(colors)(symbol) : word;
471
+ let head = MARK_WORDS[mark];
472
+ if (takesControlCodes(stream, env)) {
473
+ const { theme } = activeTheme();
474
+ head = tinted(colors.bold, theme.colors[mark])(theme.glyphs[mark]);
475
+ }
294
476
  return `${head} ${text}${detail === undefined ? "" : ` ${colors.dim(detail)}`}`;
295
477
  }
296
478
  function warn(text, detail) {
297
- console.error(marked("warn", text, process2.stderr, detail));
298
- }
299
- var STATUSES = {
300
- passed: { symbol: "\u2713", words: ["passed", "success", "succeeded", "ok"], paint: (colors) => colors.green },
301
- failed: { symbol: "\u2717", words: ["failed", "failure", "error", "errored"], paint: (colors) => colors.red },
302
- running: { symbol: "\u25CF", words: ["running", "in_progress", "started"], paint: (colors) => colors.cyan },
303
- queued: { symbol: "\u25CB", words: ["queued", "waiting", "pending", "created", "blocked", "scheduled"], paint: (colors) => colors.yellow },
304
- skipped: { symbol: "-", words: ["skipped", "cancelled", "canceled", "manual"], paint: (colors) => colors.dim }
479
+ console.error(marked("warn", text, process5.stderr, detail));
480
+ }
481
+ function role(name, stream, env = process5.env) {
482
+ const colors = paint(stream, env);
483
+ return takesControlCodes(stream, env) ? tinted(colors, activeTheme().theme.colors[name]) : colors;
484
+ }
485
+ var STATUS_WORDS = {
486
+ passed: ["passed", "success", "succeeded", "ok"],
487
+ failed: ["failed", "failure", "error", "errored"],
488
+ running: ["running", "in_progress", "started"],
489
+ queued: ["queued", "waiting", "pending", "created", "blocked", "scheduled"],
490
+ skipped: ["skipped", "cancelled", "canceled", "manual"]
305
491
  };
306
- var STATUS_OF = new Map(Object.entries(STATUSES).flatMap(([status, { words }]) => words.map((word) => [word, status])));
492
+ var STATUS_OF = new Map(Object.entries(STATUS_WORDS).flatMap(([status, words]) => words.map((word) => [word, status])));
493
+ function header(bin, context, stream, env = process5.env) {
494
+ if (!takesControlCodes(stream, env))
495
+ return "";
496
+ const colors = paint(stream, env);
497
+ const hash = [...bin].reduce((sum, char) => sum + char.charCodeAt(0), 0);
498
+ const { theme } = activeTheme();
499
+ const spec = theme.bins[bin] ?? theme.accents[hash % theme.accents.length];
500
+ const accent = tinted(typeof spec === "string" && spec.split(" ").includes("bold") ? colors : colors.bold, spec);
501
+ return `${accent(bin)}${context === undefined ? "" : colors.dim(` \u203A ${context}`)}`;
502
+ }
307
503
 
308
504
  // ../kit/src/format.ts
309
505
  var UNITS = [["d", 86400], ["h", 3600], ["m", 60], ["s", 1]];
@@ -335,7 +531,7 @@ var ESCAPE = String.fromCharCode(27);
335
531
  function textWidth(text) {
336
532
  return Bun.stringWidth(text);
337
533
  }
338
- function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
534
+ function table(rows, { cellWidth, header = false, align = [], fit, stream = process6.stdout } = {}) {
339
535
  const cells = cellWidth === undefined ? rows : rows.map((row) => row.map((cell) => truncate(cell.replaceAll(LINE_BREAKS, " "), cellWidth)));
340
536
  const widths = [];
341
537
  for (const row of cells) {
@@ -343,7 +539,7 @@ function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
343
539
  widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
344
540
  }
345
541
  const shown = fit === undefined ? cells : narrow(cells, widths, fit);
346
- const colors = paint(process3.stdout);
542
+ const colors = paint(stream);
347
543
  const lines = shown.map((row) => row.map((cell, index) => {
348
544
  const width = widths[index] ?? 0;
349
545
  const gap = " ".repeat(Math.max(0, width - textWidth(cell)));
@@ -351,7 +547,8 @@ function table(rows, { cellWidth, header = false, align = [], fit } = {}) {
351
547
  return `${gap}${cell}`;
352
548
  return index === row.length - 1 ? cell : `${cell}${gap}`;
353
549
  }).join(" ").trimEnd());
354
- return lines.map((line, index) => header && index === 0 ? colors.bold(line) : line).join(`
550
+ const rule = header && takesControlCodes(stream) && lines.length > 1 ? [colors.dim("\u2500".repeat(Math.max(...lines.map(textWidth))))] : [];
551
+ return lines.flatMap((line, index) => header && index === 0 ? [colors.bold(line), ...rule] : [line]).join(`
355
552
  `);
356
553
  }
357
554
  function narrow(rows, widths, limit) {
@@ -375,27 +572,27 @@ function printJson(value) {
375
572
  }
376
573
 
377
574
  // ../kit/src/help.ts
378
- import process4 from "process";
575
+ import process7 from "process";
379
576
  var OPTIONAL = /\[[^\]]+\]/g;
380
577
  var USAGE_PREFIX = /^usage:\s*/i;
381
578
  var FULL_STOP = /\.$/;
382
- function usageLine(usage, colors = paint(process4.stdout)) {
579
+ function usageLine(usage, colors = paint(process7.stdout)) {
383
580
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
384
581
  }
385
- function helpText(usage, options, colors = paint(process4.stdout), { examples = [], replaces, exits = [] } = {}) {
582
+ function helpText(usage, options, colors = paint(process7.stdout), { examples = [], replaces, exits = [] } = {}) {
386
583
  return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
387
584
  `);
388
585
  }
389
- function exitRows(exits, colors = paint(process4.stdout)) {
586
+ function exitRows(exits, colors = paint(process7.stdout)) {
390
587
  if (exits.length === 0)
391
588
  return [];
392
589
  const width = Math.max(...exits.map(([code]) => String(code).length));
393
590
  return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
394
591
  }
395
- function replacesRows(replaces, colors = paint(process4.stdout)) {
592
+ function replacesRows(replaces, colors = paint(process7.stdout)) {
396
593
  return replaces === undefined ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
397
594
  }
398
- function wantsHelpJson(env = process4.env) {
595
+ function wantsHelpJson(env = process7.env) {
399
596
  return env.KIT_HELP === "json";
400
597
  }
401
598
  function description(usage, { examples = [], replaces, exits } = {}, options) {
@@ -414,12 +611,12 @@ function description(usage, { examples = [], replaces, exits } = {}, options) {
414
611
  ...options === undefined ? {} : { options: Object.entries(options).map(([name, { short, description }]) => ({ name, ...short === undefined ? {} : { short }, ...description === undefined ? {} : { description } })) }
415
612
  };
416
613
  }
417
- function exampleRows(examples, colors = paint(process4.stdout)) {
614
+ function exampleRows(examples, colors = paint(process7.stdout)) {
418
615
  if (examples.length === 0)
419
616
  return [];
420
617
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
421
618
  }
422
- function optionRows(options, colors = paint(process4.stdout)) {
619
+ function optionRows(options, colors = paint(process7.stdout)) {
423
620
  const rows = Object.entries(options).map(([name, option]) => {
424
621
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
425
622
  const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
@@ -454,7 +651,7 @@ function closest(name, names) {
454
651
  return best !== undefined && best.far <= (name.length < 4 ? 1 : 2) ? best.known : undefined;
455
652
  }
456
653
  // ../kit/src/input.ts
457
- import process5 from "process";
654
+ import process8 from "process";
458
655
  var DURATION = /^(\d+(?:\.\d+)?)(ms|[smhd])?$/;
459
656
  var UNIT_MS = { ms: 1, s: 1000, m: 60000, h: 3600000, d: 86400000 };
460
657
  function duration(value, name, fallback, unit = "s") {
@@ -468,7 +665,7 @@ function duration(value, name, fallback, unit = "s") {
468
665
  }
469
666
  async function readInput(path, { noStdin = "nothing is piped on stdin" } = {}) {
470
667
  if (path === "-") {
471
- if (process5.stdin.isTTY)
668
+ if (process8.stdin.isTTY)
472
669
  fail(noStdin);
473
670
  return Bun.stdin.text();
474
671
  }
@@ -527,7 +724,7 @@ var OUTPUT_OPTIONS = {
527
724
  color: { type: "string", description: "auto (on a terminal alone), always or never" },
528
725
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
529
726
  };
530
- function applyOutput(color, plain, env = process6.env) {
727
+ function applyOutput(color, plain, env = process9.env) {
531
728
  const when = plain === true ? "never" : color ?? "auto";
532
729
  if (when === "auto")
533
730
  return;
@@ -698,7 +895,7 @@ function nearestOption(message, options, allowNegative) {
698
895
  }
699
896
  // ../kit/src/process.ts
700
897
  import { constants } from "os";
701
- import process7 from "process";
898
+ import process10 from "process";
702
899
  var KILL_GRACE_MS = 2000;
703
900
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
704
901
  function exitCodeOf(code, signal) {
@@ -720,7 +917,7 @@ function holdSignals(cleanup) {
720
917
  },
721
918
  release: () => {
722
919
  for (const signal of SIGNALS)
723
- process7.off(signal, onSignal);
920
+ process10.off(signal, onSignal);
724
921
  }
725
922
  };
726
923
  function onSignal(signal) {
@@ -733,10 +930,10 @@ function holdSignals(cleanup) {
733
930
  return;
734
931
  held.release();
735
932
  cleanup(signal);
736
- process7.kill(process7.pid, signal);
933
+ process10.kill(process10.pid, signal);
737
934
  }
738
935
  for (const signal of SIGNALS)
739
- process7.on(signal, onSignal);
936
+ process10.on(signal, onSignal);
740
937
  return held;
741
938
  }
742
939
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -750,7 +947,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
750
947
  return;
751
948
  try {
752
949
  if (grouped)
753
- process7.kill(-proc.pid, killing);
950
+ process10.kill(-proc.pid, killing);
754
951
  else
755
952
  proc.kill(killing);
756
953
  } catch {}
@@ -824,42 +1021,42 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
824
1021
  var RESET_STYLE = `${ESC}[0m`;
825
1022
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
826
1023
  // ../kit/src/cli.ts
827
- import { readFileSync, realpathSync } from "fs";
828
- import { dirname as dirname2, join as join3 } from "path";
829
- import process10 from "process";
1024
+ import { readFileSync as readFileSync2, realpathSync } from "fs";
1025
+ import { dirname as dirname3, join as join6 } from "path";
1026
+ import process13 from "process";
830
1027
 
831
1028
  // ../kit/src/usage.ts
832
1029
  import { appendFileSync, mkdirSync } from "fs";
833
- import { homedir as homedir2 } from "os";
834
- import { dirname, isAbsolute, join as join2 } from "path";
835
- import process9 from "process";
1030
+ import { homedir as homedir4 } from "os";
1031
+ import { dirname as dirname2, isAbsolute, join as join5 } from "path";
1032
+ import process12 from "process";
836
1033
 
837
1034
  // ../kit/src/logs.ts
838
1035
  import { lstatSync, openSync } from "fs";
839
1036
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
840
- import { homedir, tmpdir } from "os";
841
- import { join } from "path";
842
- import process8 from "process";
1037
+ import { homedir as homedir3, tmpdir } from "os";
1038
+ import { join as join4 } from "path";
1039
+ import process11 from "process";
843
1040
  var DAY_MS = 24 * 60 * 60 * 1000;
844
1041
  var CLI_FOLDER = "kaynooo-cli";
845
1042
  function isPrivateDirectory(path) {
846
1043
  try {
847
1044
  const info = lstatSync(path, { throwIfNoEntry: false });
848
- return info !== undefined && info.isDirectory() && info.uid === (process8.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
1045
+ return info !== undefined && info.isDirectory() && info.uid === (process11.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
849
1046
  } catch {
850
1047
  return false;
851
1048
  }
852
1049
  }
853
- async function privateLogDirectory(name, env = process8.env) {
1050
+ async function privateLogDirectory(name, env = process11.env) {
854
1051
  const runtime = env.XDG_RUNTIME_DIR;
855
- const base = runtime === undefined || runtime === "" ? join(homedir(), ".cache", CLI_FOLDER) : join(runtime, CLI_FOLDER);
856
- const path = join(base, name);
1052
+ const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
1053
+ const path = join4(base, name);
857
1054
  try {
858
1055
  await mkdir(path, { recursive: true, mode: 448 });
859
1056
  if (isPrivateDirectory(path))
860
1057
  return path;
861
1058
  } catch {}
862
- return mkdtemp(join(tmpdir(), `${name.replaceAll("/", "-")}-`));
1059
+ return mkdtemp(join4(tmpdir(), `${name.replaceAll("/", "-")}-`));
863
1060
  }
864
1061
  async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
865
1062
  let names;
@@ -869,7 +1066,7 @@ async function sweepLogs(dir, maxAgeMs = DAY_MS, now = Date.now()) {
869
1066
  return;
870
1067
  }
871
1068
  for (const name of names) {
872
- const path = join(dir, name);
1069
+ const path = join4(dir, name);
873
1070
  try {
874
1071
  const info = await stat(path);
875
1072
  if (info.isDirectory())
@@ -890,14 +1087,14 @@ var usageError;
890
1087
  function noteUsageError(message) {
891
1088
  usageError = message;
892
1089
  }
893
- function stateHome(env = process9.env) {
1090
+ function stateHome(env = process12.env) {
894
1091
  const dir = env.XDG_STATE_HOME;
895
- return dir !== undefined && isAbsolute(dir) ? dir : join2(homedir2(), ".local", "state");
1092
+ return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
896
1093
  }
897
- function usagePath(env = process9.env) {
898
- return join2(stateHome(env), CLI_FOLDER, "usage.jsonl");
1094
+ function usagePath(env = process12.env) {
1095
+ return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
899
1096
  }
900
- function usageRecorded(env = process9.env) {
1097
+ function usageRecorded(env = process12.env) {
901
1098
  const off = env.KAYNOOO_CLI_NO_USAGE;
902
1099
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
903
1100
  }
@@ -911,12 +1108,12 @@ function usageEntry(bin, command, argv, code, now = new Date) {
911
1108
  usageError = undefined;
912
1109
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
913
1110
  }
914
- function recordUsage(entry, env = process9.env) {
1111
+ function recordUsage(entry, env = process12.env) {
915
1112
  if (!usageRecorded(env))
916
1113
  return;
917
1114
  try {
918
1115
  const path = usagePath(env);
919
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
1116
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
920
1117
  appendFileSync(path, `${JSON.stringify(entry)}
921
1118
  `, { mode: 384 });
922
1119
  } catch {}
@@ -929,8 +1126,8 @@ var LEVEL_OPTIONS = {
929
1126
  };
930
1127
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
931
1128
  function printError(prefix, message, hint, cause) {
932
- const colors = paint(process10.stderr);
933
- const styled = takesControlCodes(process10.stderr);
1129
+ const colors = paint(process13.stderr);
1130
+ const styled = takesControlCodes(process13.stderr);
934
1131
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
935
1132
  const under = (label, text, tint) => text === undefined ? "" : `
936
1133
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1013,17 +1210,17 @@ async function printCandidates(found) {
1013
1210
  return 0;
1014
1211
  }
1015
1212
  function packageVersion(entry = Bun.main) {
1016
- for (let dir = dirname2(realpathSync(entry));; dir = dirname2(dir)) {
1213
+ for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1017
1214
  try {
1018
- const { version } = JSON.parse(readFileSync(join3(dir, "package.json"), "utf8"));
1215
+ const { version } = JSON.parse(readFileSync2(join6(dir, "package.json"), "utf8"));
1019
1216
  if (typeof version === "string")
1020
1217
  return version;
1021
1218
  } catch {}
1022
- if (dirname2(dir) === dir)
1219
+ if (dirname3(dir) === dir)
1023
1220
  return "0.0.0";
1024
1221
  }
1025
1222
  }
1026
- async function runMain({ name, version, run, redact, usage }, argv = process10.argv.slice(2)) {
1223
+ async function runMain({ name, version, run, redact, usage }, argv = process13.argv.slice(2)) {
1027
1224
  if (argv[0] === COMPLETE)
1028
1225
  return printCandidates(leafCandidates(run, argv.slice(1)));
1029
1226
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1050,12 +1247,12 @@ var {Glob } = globalThis.Bun;
1050
1247
  var SESSION_FILES = new Glob("*.json");
1051
1248
  var ACCOUNT_DIRS = new Glob("*/sessions");
1052
1249
  // package.json
1053
- var version = "0.13.0";
1250
+ var version = "0.14.0";
1054
1251
 
1055
1252
  // src/check.ts
1056
1253
  import { writeFile as writeFile3 } from "fs/promises";
1057
- import { join as join10 } from "path";
1058
- import process15 from "process";
1254
+ import { basename as basename4, join as join13 } from "path";
1255
+ import process18 from "process";
1059
1256
 
1060
1257
  // ../kit/src/shell.ts
1061
1258
  var SEPARATORS = new Set([`
@@ -1105,10 +1302,10 @@ function shellQuote(word) {
1105
1302
  }
1106
1303
 
1107
1304
  // src/compose.ts
1108
- import { existsSync } from "fs";
1109
- import { homedir as homedir3 } from "os";
1110
- import { basename, dirname as dirname3, join as join4, relative, resolve } from "path";
1111
- import process12 from "process";
1305
+ import { existsSync as existsSync3 } from "fs";
1306
+ import { homedir as homedir5 } from "os";
1307
+ import { basename, dirname as dirname4, join as join7, relative, resolve as resolve3 } from "path";
1308
+ import process15 from "process";
1112
1309
  var COMPOSE_FILES = ["compose.yaml", "compose.yml", "docker-compose.yaml", "docker-compose.yml"];
1113
1310
  var OVERRIDE_FILES = ["compose.override.yaml", "compose.override.yml", "docker-compose.override.yaml", "docker-compose.override.yml"];
1114
1311
  var PS_TIMEOUT_MS = 20000;
@@ -1137,7 +1334,7 @@ function toolWords(program) {
1137
1334
  }
1138
1335
  async function readFiles(dir, names) {
1139
1336
  for (const name of names) {
1140
- const handle = Bun.file(join4(dir, name));
1337
+ const handle = Bun.file(join7(dir, name));
1141
1338
  if (await handle.exists())
1142
1339
  return { name, text: await handle.text() };
1143
1340
  }
@@ -1152,7 +1349,7 @@ async function variables(composeDir) {
1152
1349
  if (match !== null && !line.trimStart().startsWith("#"))
1153
1350
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1154
1351
  }
1155
- for (const [key, value] of Object.entries(process12.env)) {
1352
+ for (const [key, value] of Object.entries(process15.env)) {
1156
1353
  if (value !== undefined)
1157
1354
  env[key] = value;
1158
1355
  }
@@ -1172,10 +1369,10 @@ function interpolate(text, env) {
1172
1369
  function bindSource(source, composeDir, env) {
1173
1370
  const path = interpolate(source, env);
1174
1371
  if (path.startsWith("~"))
1175
- return join4(homedir3(), path.slice(1));
1372
+ return join7(homedir5(), path.slice(1));
1176
1373
  if (path.startsWith("/"))
1177
- return resolve(path);
1178
- return path.startsWith(".") ? resolve(composeDir, path) : undefined;
1374
+ return resolve3(path);
1375
+ return path.startsWith(".") ? resolve3(composeDir, path) : undefined;
1179
1376
  }
1180
1377
  function mountsOf(volumes, composeDir, env) {
1181
1378
  if (!Array.isArray(volumes))
@@ -1217,9 +1414,9 @@ async function composeFiles(composeDir, env) {
1217
1414
  const files = [];
1218
1415
  const separator = env.COMPOSE_PATH_SEPARATOR;
1219
1416
  for (const name of listed.split(separator === undefined || separator === "" ? ":" : separator).filter((entry) => entry !== "")) {
1220
- const file = Bun.file(resolve(composeDir, name));
1417
+ const file = Bun.file(resolve3(composeDir, name));
1221
1418
  if (!await file.exists())
1222
- fail(`COMPOSE_FILE names ${join4(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
1419
+ fail(`COMPOSE_FILE names ${join7(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
1223
1420
  files.push({ name, text: await file.text() });
1224
1421
  }
1225
1422
  return files;
@@ -1241,7 +1438,7 @@ async function readServices(composeDir) {
1241
1438
  try {
1242
1439
  parsed = parseServices(file.text, composeDir, env);
1243
1440
  } catch (error) {
1244
- fail(`cannot read ${join4(composeDir, file.name)}: ${error instanceof Error ? error.message : String(error)}`, 1, "fix the file, or run on the host with --host");
1441
+ fail(`cannot read ${join7(composeDir, file.name)}: ${error instanceof Error ? error.message : String(error)}`, 1, "fix the file, or run on the host with --host");
1245
1442
  }
1246
1443
  for (const [name, extra] of parsed) {
1247
1444
  const known = services.get(name);
@@ -1253,11 +1450,11 @@ async function readServices(composeDir) {
1253
1450
  function climb(dir) {
1254
1451
  const folders = [dir];
1255
1452
  let current = dir;
1256
- while (!existsSync(join4(current, ".git")) && dirname3(current) !== current) {
1257
- current = dirname3(current);
1453
+ while (!existsSync3(join7(current, ".git")) && dirname4(current) !== current) {
1454
+ current = dirname4(current);
1258
1455
  folders.push(current);
1259
1456
  }
1260
- return existsSync(join4(current, ".git")) ? folders : [dir];
1457
+ return existsSync3(join7(current, ".git")) ? folders : [dir];
1261
1458
  }
1262
1459
  function containerPath(service, dir) {
1263
1460
  const holding = service.mounts.filter((mount) => {
@@ -1268,7 +1465,7 @@ function containerPath(service, dir) {
1268
1465
  if (deepest === undefined)
1269
1466
  return;
1270
1467
  const inside = relative(deepest.source, dir);
1271
- return inside === "" ? deepest.target : join4(deepest.target, inside);
1468
+ return inside === "" ? deepest.target : join7(deepest.target, inside);
1272
1469
  }
1273
1470
  var noticed = new Set;
1274
1471
  async function place(dir, program, { service, host } = {}) {
@@ -1288,7 +1485,7 @@ async function place(dir, program, { service, host } = {}) {
1288
1485
  fail(`--in ${service}: no compose project mounts ${dir}`);
1289
1486
  return;
1290
1487
  }
1291
- if (Bun.which("docker", { PATH: process12.env.PATH ?? "" }) === null) {
1488
+ if (Bun.which("docker", { PATH: process15.env.PATH ?? "" }) === null) {
1292
1489
  if (service !== undefined)
1293
1490
  fail(`--in ${service}: docker not found`);
1294
1491
  if (!noticed.has(found.composeDir)) {
@@ -1340,7 +1537,7 @@ class Stack {
1340
1537
  }
1341
1538
  static async running(composeDir) {
1342
1539
  try {
1343
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process12.env, timeoutMs: PS_TIMEOUT_MS });
1540
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process15.env, timeoutMs: PS_TIMEOUT_MS });
1344
1541
  if (ran.code !== 0)
1345
1542
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1346
1543
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1372,14 +1569,14 @@ function placeSettings(values) {
1372
1569
  }
1373
1570
 
1374
1571
  // src/fix.ts
1375
- import { existsSync as existsSync2, statSync } from "fs";
1572
+ import { existsSync as existsSync4, statSync as statSync2 } from "fs";
1376
1573
  import { rename, writeFile as writeFile2 } from "fs/promises";
1377
- import { join as join8 } from "path";
1378
- import process14 from "process";
1574
+ import { join as join11 } from "path";
1575
+ import process17 from "process";
1379
1576
 
1380
1577
  // src/changes.ts
1381
1578
  import { stat as stat2 } from "fs/promises";
1382
- import { join as join5 } from "path";
1579
+ import { join as join8 } from "path";
1383
1580
  var {$ } = globalThis.Bun;
1384
1581
  async function dirtyFiles(dir) {
1385
1582
  const listed = await $`git ls-files -z --modified --others --exclude-standard`.cwd(dir).quiet().nothrow();
@@ -1388,7 +1585,7 @@ async function dirtyFiles(dir) {
1388
1585
  const files = new Map;
1389
1586
  for (const path of listed.stdout.toString().split("\x00").filter(Boolean)) {
1390
1587
  try {
1391
- const { size, mtimeMs } = await stat2(join5(dir, path));
1588
+ const { size, mtimeMs } = await stat2(join8(dir, path));
1392
1589
  files.set(path, `${size}:${mtimeMs}`);
1393
1590
  } catch {
1394
1591
  files.set(path, "");
@@ -1433,7 +1630,7 @@ ${body}`;
1433
1630
 
1434
1631
  // src/steps.ts
1435
1632
  import { readdir as readdir2 } from "fs/promises";
1436
- import { join as join6 } from "path";
1633
+ import { join as join9 } from "path";
1437
1634
  var STEP_NAMES = ["check", "typecheck", "lint", "test"];
1438
1635
  var TARGET2 = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
1439
1636
  var JUSTFILES = ["justfile", "Justfile", ".justfile"];
@@ -1445,7 +1642,7 @@ var PHPUNIT_CONFIGS = ["phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml"];
1445
1642
  var SKIPPED = new Set(["node_modules", "vendor", "dist", "build", "var", "tmp", "coverage"]);
1446
1643
  async function readFirst(dir, files) {
1447
1644
  for (const file of files) {
1448
- const handle = Bun.file(join6(dir, file));
1645
+ const handle = Bun.file(join9(dir, file));
1449
1646
  if (await handle.exists())
1450
1647
  return { file, text: await handle.text() };
1451
1648
  }
@@ -1453,7 +1650,7 @@ async function readFirst(dir, files) {
1453
1650
  }
1454
1651
  async function read(dir, ...files) {
1455
1652
  for (const file of files) {
1456
- const handle = Bun.file(join6(dir, file));
1653
+ const handle = Bun.file(join9(dir, file));
1457
1654
  if (await handle.exists())
1458
1655
  return handle.text();
1459
1656
  }
@@ -1513,7 +1710,7 @@ async function candidates(dir, bin) {
1513
1710
  }
1514
1711
  async function firstFile(dir, names) {
1515
1712
  for (const name of names) {
1516
- if (await Bun.file(join6(dir, name)).exists())
1713
+ if (await Bun.file(join9(dir, name)).exists())
1517
1714
  return name;
1518
1715
  }
1519
1716
  return;
@@ -1540,9 +1737,9 @@ async function discoverProjects(dir) {
1540
1737
  for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {
1541
1738
  if (!entry.isDirectory() || entry.name.startsWith(".") || SKIPPED.has(entry.name))
1542
1739
  continue;
1543
- const steps = await discover(join6(dir, entry.name));
1740
+ const steps = await discover(join9(dir, entry.name));
1544
1741
  if (steps.length > 0)
1545
- projects.push({ name: entry.name, dir: join6(dir, entry.name), steps });
1742
+ projects.push({ name: entry.name, dir: join9(dir, entry.name), steps });
1546
1743
  }
1547
1744
  return projects;
1548
1745
  }
@@ -1584,8 +1781,8 @@ function pick(steps, only, noun = "step") {
1584
1781
 
1585
1782
  // src/run.ts
1586
1783
  import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
1587
- import { basename as basename2, join as join7 } from "path";
1588
- import process13 from "process";
1784
+ import { basename as basename2, join as join10 } from "path";
1785
+ import process16 from "process";
1589
1786
 
1590
1787
  // src/e2e.ts
1591
1788
  var E2E_NOISE = [
@@ -2220,7 +2417,7 @@ var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
2220
2417
  async function logDirectory(cwd) {
2221
2418
  const root = await privateLogDirectory("check");
2222
2419
  await sweepLogs(root, LOG_MAX_AGE_MS);
2223
- const path = join7(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process13.pid}`);
2420
+ const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process16.pid}`);
2224
2421
  await mkdir2(path, { mode: 448 });
2225
2422
  return path;
2226
2423
  }
@@ -2231,7 +2428,7 @@ async function lastFailed(cwd) {
2231
2428
  for (const name of await readdir3(root)) {
2232
2429
  if (!name.startsWith(prefix))
2233
2430
  continue;
2234
- const file = join7(root, name, RESULTS_FILE);
2431
+ const file = join10(root, name, RESULTS_FILE);
2235
2432
  try {
2236
2433
  const { mtimeMs } = await stat3(file);
2237
2434
  if (latest === undefined || mtimeMs > latest.time)
@@ -2246,7 +2443,7 @@ async function lastFailed(cwd) {
2246
2443
  async function saveLog(output) {
2247
2444
  const root = await privateLogDirectory("errs");
2248
2445
  await sweepLogs(root);
2249
- const path = join7(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process13.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2446
+ const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process16.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2250
2447
  await writeFile(path, output, { mode: 384, flag: "wx" });
2251
2448
  return path;
2252
2449
  }
@@ -2254,7 +2451,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2254
2451
  const started = Date.now();
2255
2452
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2256
2453
  cwd,
2257
- env: { ...process13.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2454
+ env: { ...process16.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2258
2455
  ...timeoutMs === undefined ? {} : { timeoutMs },
2259
2456
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2260
2457
  });
@@ -2270,14 +2467,17 @@ function outcomeJson(name, command, logFile, outcome, service) {
2270
2467
  return { name, command, ...service === undefined ? {} : { in: service }, ok: outcome.ok, ms: outcome.ms, log: logFile, ...outcome.timedOut === true ? { timedOut: true } : {}, ...outcome.ok ? {} : { failed: failureExcerpt(outcome.output) } };
2271
2468
  }
2272
2469
  function printOutcome(name, width, command, logFile, outcome) {
2470
+ const colors = paint(process16.stdout);
2471
+ const path = role("path", process16.stdout);
2472
+ const took = colors.dim(formatDuration(outcome.ms));
2273
2473
  if (outcome.ok) {
2274
- console.log(`ok ${name.padEnd(width)} ${formatDuration(outcome.ms)} ${logFile}`);
2474
+ console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
2275
2475
  return;
2276
2476
  }
2277
- const label = outcome.timedOut === true ? "TIME " : "FAIL ";
2278
- console.log(`${label} ${name.padEnd(width)} ${formatDuration(outcome.ms)} ${command} ${logFile}`);
2477
+ const label = outcome.timedOut === true ? colors.bold(colors.yellow("TIME ")) : colors.bold(colors.red("FAIL "));
2478
+ console.log(`${label} ${name.padEnd(width)} ${took} ${colors.dim(command)} ${path(logFile)}`);
2279
2479
  if (outcome.timedOut === true)
2280
- console.log(` timed out after ${formatDuration(outcome.ms)}, the step and what it started were ended`);
2480
+ console.log(colors.yellow(` timed out after ${formatDuration(outcome.ms)}, the step and what it started were ended`));
2281
2481
  console.log(failureExcerpt(outcome.output).split(`
2282
2482
  `).map((line) => ` ${line}`.trimEnd()).join(`
2283
2483
  `));
@@ -2299,8 +2499,8 @@ var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
2299
2499
  var RUFF_SECTION = /^\[tool\.ruff/m;
2300
2500
  var MAX_CHANGED = 30;
2301
2501
  async function replaceFile(path, content) {
2302
- const temporary = `${path}.${process14.pid}.tmp`;
2303
- await writeFile2(temporary, content, { mode: statSync(path).mode & 511 });
2502
+ const temporary = `${path}.${process17.pid}.tmp`;
2503
+ await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
2304
2504
  await rename(temporary, path);
2305
2505
  }
2306
2506
  async function projectFixers(dir) {
@@ -2318,9 +2518,9 @@ async function toolFixers(dir) {
2318
2518
  const ruff = await firstFile(dir, RUFF_CONFIGS) !== undefined || RUFF_SECTION.test(await read(dir, "pyproject.toml") ?? "");
2319
2519
  if (makefile !== undefined) {
2320
2520
  fixers.push({ name: "makefile", command: "declare every target .PHONY", source: makefile, write: async (cwd) => {
2321
- const path = join8(cwd, makefile);
2521
+ const path = join11(cwd, makefile);
2322
2522
  const current = await Bun.file(path).text();
2323
- const { content, targets } = declarePhony(current, (name) => existsSync2(join8(cwd, name)));
2523
+ const { content, targets } = declarePhony(current, (name) => existsSync4(join11(cwd, name)));
2324
2524
  if (content !== current)
2325
2525
  await replaceFile(path, content);
2326
2526
  return `.PHONY: ${targets.join(" ")}`;
@@ -2328,9 +2528,9 @@ async function toolFixers(dir) {
2328
2528
  }
2329
2529
  if (justfile !== undefined)
2330
2530
  fixers.push({ name: "justfile", command: `just --justfile ${justfile} --fmt`, source: justfile, requires: "just" });
2331
- if (await Bun.file(join8(dir, "go.mod")).exists())
2531
+ if (await Bun.file(join11(dir, "go.mod")).exists())
2332
2532
  fixers.push({ name: "go", command: "go fmt ./... && go mod tidy", source: "go.mod", requires: "go" });
2333
- if (await Bun.file(join8(dir, "Cargo.toml")).exists())
2533
+ if (await Bun.file(join11(dir, "Cargo.toml")).exists())
2334
2534
  fixers.push({ name: "rust", command: "cargo fmt", source: "Cargo.toml", requires: "cargo" });
2335
2535
  if (ruff)
2336
2536
  fixers.push({ name: "python", command: "ruff check --fix . && ruff format .", source: "ruff", requires: "ruff" });
@@ -2371,14 +2571,14 @@ function printChanged(changed) {
2371
2571
  if (changed.length > MAX_CHANGED)
2372
2572
  console.log(` and ${changed.length - MAX_CHANGED} more`);
2373
2573
  }
2374
- async function fix(args, cwd = process14.cwd()) {
2574
+ async function fix(args, cwd = process17.cwd()) {
2375
2575
  const parsed = parse(args, fixUsage, fixOptions, { replaces: "running each fixer and formatter by hand, or docker compose exec <service> bun run lint:fix", examples: ["fix", ["fix --list", "the fixers it would run"]] });
2376
2576
  return runFixers(parsed.values, cwd);
2377
2577
  }
2378
2578
  async function runFixers(values, cwd) {
2379
2579
  const parsed = { values };
2380
2580
  const settings = placeSettings(values);
2381
- if (process14.env[RUNNING] !== undefined)
2581
+ if (process17.env[RUNNING] !== undefined)
2382
2582
  fail("a fixer called fix again, which would recurse: give its script another command");
2383
2583
  const found = await fixers(cwd);
2384
2584
  if (found.length === 0)
@@ -2412,11 +2612,11 @@ async function runFixers(values, cwd) {
2412
2612
  break;
2413
2613
  if (missing(fixer)) {
2414
2614
  if (!json)
2415
- console.log(`skip ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2615
+ console.log(`${paint(process17.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2416
2616
  ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
2417
2617
  continue;
2418
2618
  }
2419
- const logFile = join8(directory, `fix-${fixer.name.replaceAll(":", "-")}.log`);
2619
+ const logFile = join11(directory, `fix-${fixer.name.replaceAll(":", "-")}.log`);
2420
2620
  const placement = placements.get(fixer);
2421
2621
  const down = placement === undefined ? undefined : await stack.problem(placement);
2422
2622
  const outcome = down === undefined ? await runFixer(fixer, placement, cwd, logFile, runSettings) : await refusedStep(down, logFile);
@@ -2445,8 +2645,8 @@ async function runFixers(values, cwd) {
2445
2645
  }
2446
2646
 
2447
2647
  // src/narrow.ts
2448
- import { existsSync as existsSync3 } from "fs";
2449
- import { basename as basename3, dirname as dirname4, extname, join as join9 } from "path";
2648
+ import { existsSync as existsSync5 } from "fs";
2649
+ import { basename as basename3, dirname as dirname5, extname, join as join12 } from "path";
2450
2650
  var {$: $2 } = globalThis.Bun;
2451
2651
  var LINTERS = /^(?:keslint|eslint|oxlint)\b/;
2452
2652
  var LINTABLE = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".svelte"]);
@@ -2458,17 +2658,17 @@ async function changedPaths(dir) {
2458
2658
  const untracked = await $2`git ls-files -z --others --exclude-standard`.cwd(dir).quiet().nothrow();
2459
2659
  if (tracked.exitCode !== 0 || untracked.exitCode !== 0)
2460
2660
  return;
2461
- return [...new Set([...tracked.stdout.toString().split("\x00"), ...untracked.stdout.toString().split("\x00")])].filter((path) => path !== "" && existsSync3(join9(dir, path)));
2661
+ return [...new Set([...tracked.stdout.toString().split("\x00"), ...untracked.stdout.toString().split("\x00")])].filter((path) => path !== "" && existsSync5(join12(dir, path)));
2462
2662
  }
2463
2663
  function siblingTests(path, exists) {
2464
2664
  const extension = extname(path);
2465
2665
  const name = basename3(path, extension);
2466
- const dir = dirname4(path);
2467
- const folders = [dir, join9(dir, "tests"), join9(dir, "..", "tests"), join9(dir, "__tests__")];
2666
+ const dir = dirname5(path);
2667
+ const folders = [dir, join12(dir, "tests"), join12(dir, "..", "tests"), join12(dir, "__tests__")];
2468
2668
  const found = new Set;
2469
2669
  for (const folder of folders) {
2470
2670
  for (const kind of ["test", "spec"]) {
2471
- for (const candidate of [`${name}.${kind}${extension}`, `${name}.${kind}.ts`].map((file) => join9(folder, file))) {
2671
+ for (const candidate of [`${name}.${kind}${extension}`, `${name}.${kind}.ts`].map((file) => join12(folder, file))) {
2472
2672
  if (exists(candidate))
2473
2673
  found.add(candidate);
2474
2674
  }
@@ -2492,7 +2692,7 @@ async function narrow2(step, dir, changed) {
2492
2692
  if (TEST_FILE.test(path)) {
2493
2693
  tests.add(path);
2494
2694
  } else {
2495
- for (const test of siblingTests(path, (candidate) => existsSync3(join9(dir, candidate)))) {
2695
+ for (const test of siblingTests(path, (candidate) => existsSync5(join12(dir, candidate)))) {
2496
2696
  tests.add(test);
2497
2697
  }
2498
2698
  }
@@ -2559,7 +2759,14 @@ async function narrowed(steps) {
2559
2759
  function launch(step) {
2560
2760
  return step.placement === undefined ? step.command : shellIn(step.placement, step.command);
2561
2761
  }
2562
- async function check(args, cwd = process15.cwd()) {
2762
+ function summaryLine(outcomes) {
2763
+ const colors = paint(process18.stdout);
2764
+ const failed = outcomes.filter((outcome) => !outcome.ok).length;
2765
+ const passed = outcomes.length - failed;
2766
+ const parts = [colors.green(`${passed} passed`), ...failed === 0 ? [] : [colors.red(`${failed} failed`)], colors.dim(formatDuration(outcomes.reduce((sum, outcome) => sum + outcome.ms, 0)))];
2767
+ return parts.join(colors.dim(" \xB7 "));
2768
+ }
2769
+ async function check(args, cwd = process18.cwd()) {
2563
2770
  const parsed = parse(args, usage2, options, { replaces: "chaining docker compose exec <service> bun run check | tail, lint and test by hand, or bun run check && bun run lint && bun run test read through tail", examples: ["check", ["check --only lint,test", "two of the steps"], ["check --in app", "every step inside the app service"]] });
2564
2771
  const settings = placeSettings(parsed.values);
2565
2772
  if (parsed.values.fix === true) {
@@ -2570,7 +2777,7 @@ async function check(args, cwd = process15.cwd()) {
2570
2777
  return runFixers(parsed.values, cwd);
2571
2778
  }
2572
2779
  const timeoutMs = parsed.values.timeout === undefined ? undefined : duration(parsed.values.timeout, "timeout", 0);
2573
- if (parsed.values.slot === true && Bun.which("slot", { PATH: process15.env.PATH ?? "" }) === null)
2780
+ if (parsed.values.slot === true && Bun.which("slot", { PATH: process18.env.PATH ?? "" }) === null)
2574
2781
  fail("--slot needs the slot bin: bun install -g @kaynooo/cli-wait");
2575
2782
  const projects = await discoverProjects(cwd);
2576
2783
  const found = projects.flatMap((project) => project.steps.map((step) => ({ ...step, project })));
@@ -2600,9 +2807,12 @@ async function check(args, cwd = process15.cwd()) {
2600
2807
  const stack = new Stack;
2601
2808
  const width = Math.max(...steps.map((step) => step.label.length));
2602
2809
  const outcomes = [];
2810
+ const heading = json ? "" : header("check", `${basename4(cwd)} \xB7 ${steps.length} ${steps.length === 1 ? "step" : "steps"}`, process18.stdout);
2811
+ if (heading !== "")
2812
+ console.log(heading);
2603
2813
  try {
2604
2814
  for (const step of steps) {
2605
- const logFile = join10(directory, `${step.label.replaceAll("/", "-")}.log`);
2815
+ const logFile = join13(directory, `${step.label.replaceAll("/", "-")}.log`);
2606
2816
  const down = step.placement === undefined ? undefined : await stack.problem(step.placement);
2607
2817
  const command = parsed.values.slot === true ? slotted(launch(step)) : launch(step);
2608
2818
  const outcome = down === undefined ? await runStep(command, step.dir, logFile, { ...timeoutMs === undefined ? {} : { timeoutMs }, held }) : await refusedStep(down, logFile);
@@ -2615,9 +2825,11 @@ async function check(args, cwd = process15.cwd()) {
2615
2825
  } finally {
2616
2826
  held.release();
2617
2827
  }
2618
- await writeFile3(join10(directory, RESULTS_FILE), JSON.stringify(outcomes.map(({ name, ok }) => ({ name, ok }))), { mode: 384 });
2828
+ await writeFile3(join13(directory, RESULTS_FILE), JSON.stringify(outcomes.map(({ name, ok }) => ({ name, ok }))), { mode: 384 });
2619
2829
  if (json)
2620
2830
  printJson(outcomes);
2831
+ else if (heading !== "")
2832
+ console.log(summaryLine(outcomes));
2621
2833
  if (held.signal !== undefined)
2622
2834
  return exitCodeOf(null, held.signal);
2623
2835
  if (outcomes.some((outcome) => outcome.timedOut === true))
@@ -2626,4 +2838,4 @@ async function check(args, cwd = process15.cwd()) {
2626
2838
  }
2627
2839
 
2628
2840
  // src/cli.ts
2629
- process16.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });
2841
+ process19.exitCode = await runMain({ name: "check", version, run: async (args) => check(args) });