@kaynooo/cli-check 0.18.1 → 0.18.3

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/j-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/j-cli.ts
5
- import process22 from "process";
5
+ import process23 from "process";
6
6
  // ../kit/src/args.ts
7
7
  import process10 from "process";
8
8
  import { parseArgs } from "util";
@@ -467,18 +467,14 @@ var FULL_STOP = /\.$/;
467
467
  function usageLine(usage, colors = paint(process8.stdout)) {
468
468
  return `${colors.bold("Usage:")} ${usage.replace(USAGE_PREFIX, "").replaceAll(OPTIONAL, (part) => colors.dim(part))}`;
469
469
  }
470
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], replaces, exits = [] } = {}) {
471
- return [usageLine(usage, colors), ...replacesRows(replaces, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
470
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
471
+ return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
472
472
  `);
473
473
  }
474
474
  function exitRows(exits, colors = paint(process8.stdout)) {
475
475
  if (exits.length === 0)
476
476
  return [];
477
- const width = Math.max(...exits.map(([code]) => String(code).length));
478
- return ["", colors.bold("Exits:"), ...exits.map(([code, meaning]) => ` ${colors.cyan(String(code).padEnd(width))} ${meaning}`)];
479
- }
480
- function replacesRows(replaces, colors = paint(process8.stdout)) {
481
- return replaces === undefined || outputMode() === "agent" ? [] : ["", `${colors.bold("Instead of:")} ${replaces}`];
477
+ return ["", `${colors.bold("Exit codes:")} ${exits.map(([code, meaning]) => `${colors.cyan(String(code))} ${meaning}`).join(", ")}`];
482
478
  }
483
479
  function wantsHelpJson(env = process8.env) {
484
480
  return env.KIT_HELP === "json";
@@ -780,9 +776,33 @@ function nearestOption(message, options, allowNegative) {
780
776
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
781
777
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
782
778
  }
779
+ // ../kit/src/argv.ts
780
+ import { readFileSync as readFileSync3, realpathSync } from "fs";
781
+ import { resolve as resolve3 } from "path";
782
+ import process11 from "process";
783
+ function commandLine() {
784
+ try {
785
+ return readFileSync3("/proc/self/cmdline", "utf8").split("\x00").slice(0, -1);
786
+ } catch {
787
+ return;
788
+ }
789
+ }
790
+ function realPath(word) {
791
+ try {
792
+ return realpathSync(resolve3(word));
793
+ } catch {
794
+ return;
795
+ }
796
+ }
797
+ function scriptArgs(argv = process11.argv.slice(2), cmdline = commandLine(), script = process11.argv[1]) {
798
+ const target = script === undefined ? undefined : realPath(script) ?? script;
799
+ const at = cmdline === undefined || target === undefined ? -1 : cmdline.findIndex((word, index) => index > 0 && (resolve3(word) === script || realPath(word) === target));
800
+ const after = at === -1 ? [] : cmdline.slice(at + 1);
801
+ return after[0] === "--" && after.length === argv.length + 1 && argv.every((word, index) => word === after[index + 1]) ? after : argv;
802
+ }
783
803
  // ../kit/src/process.ts
784
804
  import { constants } from "os";
785
- import process11 from "process";
805
+ import process12 from "process";
786
806
  var KILL_GRACE_MS = 2000;
787
807
  var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
788
808
  function exitCodeOf(code, signal) {
@@ -804,7 +824,7 @@ function holdSignals(cleanup) {
804
824
  },
805
825
  release: () => {
806
826
  for (const signal of SIGNALS)
807
- process11.off(signal, onSignal);
827
+ process12.off(signal, onSignal);
808
828
  }
809
829
  };
810
830
  function onSignal(signal) {
@@ -817,10 +837,10 @@ function holdSignals(cleanup) {
817
837
  return;
818
838
  held.release();
819
839
  cleanup(signal);
820
- process11.kill(process11.pid, signal);
840
+ process12.kill(process12.pid, signal);
821
841
  }
822
842
  for (const signal of SIGNALS)
823
- process11.on(signal, onSignal);
843
+ process12.on(signal, onSignal);
824
844
  return held;
825
845
  }
826
846
  async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal, maxBytes = Infinity, onChunk, onStart } = {}) {
@@ -834,7 +854,7 @@ async function runCommand(argv, { cwd, env, stdin = "ignore", timeoutMs, signal,
834
854
  return;
835
855
  try {
836
856
  if (grouped)
837
- process11.kill(-proc.pid, killing);
857
+ process12.kill(-proc.pid, killing);
838
858
  else
839
859
  proc.kill(killing);
840
860
  } catch {}
@@ -908,33 +928,33 @@ var ESCAPE_CODE = new RegExp(`${ESC}(?:\\[[\\x30-\\x3F]*[\\x20-\\x2F]*[\\x40-\\x
908
928
  var RESET_STYLE = `${ESC}[0m`;
909
929
  var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
910
930
  // ../kit/src/cli.ts
911
- import { readFileSync as readFileSync3, realpathSync } from "fs";
931
+ import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
912
932
  import { dirname as dirname3, join as join6 } from "path";
913
- import process14 from "process";
933
+ import process15 from "process";
914
934
 
915
935
  // ../kit/src/usage.ts
916
936
  import { appendFileSync, mkdirSync } from "fs";
917
937
  import { homedir as homedir4 } from "os";
918
938
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
919
- import process13 from "process";
939
+ import process14 from "process";
920
940
 
921
941
  // ../kit/src/logs.ts
922
942
  import { lstatSync, openSync } from "fs";
923
943
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
924
944
  import { homedir as homedir3, tmpdir } from "os";
925
945
  import { join as join4 } from "path";
926
- import process12 from "process";
946
+ import process13 from "process";
927
947
  var DAY_MS = 24 * 60 * 60 * 1000;
928
948
  var CLI_FOLDER = "kaynooo-cli";
929
949
  function isPrivateDirectory(path) {
930
950
  try {
931
951
  const info = lstatSync(path, { throwIfNoEntry: false });
932
- return info !== undefined && info.isDirectory() && info.uid === (process12.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
952
+ return info !== undefined && info.isDirectory() && info.uid === (process13.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
933
953
  } catch {
934
954
  return false;
935
955
  }
936
956
  }
937
- async function privateLogDirectory(name, env = process12.env) {
957
+ async function privateLogDirectory(name, env = process13.env) {
938
958
  const runtime = env.XDG_RUNTIME_DIR;
939
959
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
940
960
  const path = join4(base, name);
@@ -974,14 +994,14 @@ var usageError;
974
994
  function noteUsageError(message) {
975
995
  usageError = message;
976
996
  }
977
- function stateHome(env = process13.env) {
997
+ function stateHome(env = process14.env) {
978
998
  const dir = env.XDG_STATE_HOME;
979
999
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
980
1000
  }
981
- function usagePath(env = process13.env) {
1001
+ function usagePath(env = process14.env) {
982
1002
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
983
1003
  }
984
- function usageRecorded(env = process13.env) {
1004
+ function usageRecorded(env = process14.env) {
985
1005
  const off = env.KAYNOOO_CLI_NO_USAGE;
986
1006
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
987
1007
  }
@@ -995,7 +1015,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
995
1015
  usageError = undefined;
996
1016
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
997
1017
  }
998
- function recordUsage(entry, env = process13.env) {
1018
+ function recordUsage(entry, env = process14.env) {
999
1019
  if (!usageRecorded(env))
1000
1020
  return;
1001
1021
  try {
@@ -1013,8 +1033,8 @@ var LEVEL_OPTIONS = {
1013
1033
  };
1014
1034
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1015
1035
  function printError(prefix, message, hint, cause) {
1016
- const colors = paint(process14.stderr);
1017
- const styled = takesControlCodes(process14.stderr);
1036
+ const colors = paint(process15.stderr);
1037
+ const styled = takesControlCodes(process15.stderr);
1018
1038
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1019
1039
  const under = (label, text, tint) => text === undefined ? "" : `
1020
1040
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1058,24 +1078,24 @@ function candidateLine(candidate) {
1058
1078
  }
1059
1079
  function positionalBeingTyped(before, { options, positionals }) {
1060
1080
  const takesValue = (word) => !word.includes("=") && Object.entries(options).some(([name, { short, type }]) => type === "string" && (word === `--${name}` || word === `-${short}`));
1061
- let index = 0;
1081
+ const typed = [];
1062
1082
  let at = 0;
1063
1083
  while (at < before.length) {
1064
1084
  const word = before[at];
1065
1085
  if (word === "--") {
1066
- index += before.length - at - 1;
1086
+ typed.push(...before.slice(at + 1));
1067
1087
  break;
1068
1088
  }
1069
1089
  if (!word.startsWith("-"))
1070
- index++;
1090
+ typed.push(word);
1071
1091
  else if (takesValue(word))
1072
1092
  at++;
1073
1093
  at++;
1074
1094
  }
1075
1095
  const last = positionals.at(-1);
1076
- if (index < positionals.length)
1077
- return positionals[index];
1078
- return last?.replace("]", "").endsWith("...") === true ? last : undefined;
1096
+ if (typed.length < positionals.length)
1097
+ return { name: positionals[typed.length], typed };
1098
+ return { name: last?.replace("]", "").endsWith("...") === true ? last : undefined, typed };
1079
1099
  }
1080
1100
  async function leafCandidates(run, words) {
1081
1101
  const completing = await completingOf(run);
@@ -1083,12 +1103,12 @@ async function leafCandidates(run, words) {
1083
1103
  return Object.entries(completing.options).map(([name, option]) => option.description === undefined ? `--${name}` : `--${name} ${option.description}`);
1084
1104
  const flag = words.at(-2);
1085
1105
  const option = flag?.startsWith("-") === true ? Object.entries(completing.options).find(([name, { short }]) => flag === `--${name}` || flag === `-${short}`)?.[1] : undefined;
1106
+ const { name, typed } = positionalBeingTyped(words.slice(0, -1), completing);
1086
1107
  if (option?.type === "string") {
1087
- const values = option.choices === undefined ? await option.candidates?.() : option.choices;
1108
+ const values = option.choices === undefined ? await option.candidates?.(typed) : option.choices;
1088
1109
  return values === undefined ? [FILES] : values.map(candidateLine);
1089
1110
  }
1090
- const name = positionalBeingTyped(words.slice(0, -1), completing);
1091
- const values = name === undefined ? undefined : await completing.candidates[name]?.();
1111
+ const values = name === undefined ? undefined : await completing.candidates[name]?.(typed);
1092
1112
  return values === undefined ? [FILES] : values.map(candidateLine);
1093
1113
  }
1094
1114
  async function printCandidates(found) {
@@ -1097,9 +1117,13 @@ async function printCandidates(found) {
1097
1117
  return 0;
1098
1118
  }
1099
1119
  function packageVersion(entry = Bun.main) {
1100
- for (let dir = dirname3(realpathSync(entry));; dir = dirname3(dir)) {
1120
+ let resolved = entry;
1121
+ try {
1122
+ resolved = realpathSync2(entry);
1123
+ } catch {}
1124
+ for (let dir = dirname3(resolved);; dir = dirname3(dir)) {
1101
1125
  try {
1102
- const { version } = JSON.parse(readFileSync3(join6(dir, "package.json"), "utf8"));
1126
+ const { version } = JSON.parse(readFileSync4(join6(dir, "package.json"), "utf8"));
1103
1127
  if (typeof version === "string")
1104
1128
  return version;
1105
1129
  } catch {}
@@ -1107,7 +1131,7 @@ function packageVersion(entry = Bun.main) {
1107
1131
  return "0.0.0";
1108
1132
  }
1109
1133
  }
1110
- async function runMain({ name, version, run, redact, usage }, argv = process14.argv.slice(2)) {
1134
+ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs()) {
1111
1135
  if (argv[0] === COMPLETE)
1112
1136
  return printCandidates(leafCandidates(run, argv.slice(1)));
1113
1137
  if (argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v")) {
@@ -1141,16 +1165,16 @@ var {Glob } = globalThis.Bun;
1141
1165
  var SESSION_FILES = new Glob("*.json");
1142
1166
  var ACCOUNT_DIRS = new Glob("*/sessions");
1143
1167
  // package.json
1144
- var version = "0.18.1";
1168
+ var version = "0.18.3";
1145
1169
 
1146
1170
  // src/j.ts
1147
- import process21 from "process";
1171
+ import process22 from "process";
1148
1172
 
1149
1173
  // ../kit/src/picker.ts
1150
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync } from "fs";
1174
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "fs";
1151
1175
  import { homedir as homedir5 } from "os";
1152
1176
  import { dirname as dirname4, join as join7 } from "path";
1153
- import process18 from "process";
1177
+ import process19 from "process";
1154
1178
 
1155
1179
  // ../kit/src/picker/score.ts
1156
1180
  var MATCH = 16;
@@ -1421,11 +1445,11 @@ function chosen(state) {
1421
1445
 
1422
1446
  // ../kit/src/picker/terminal.ts
1423
1447
  import { openSync as openSync2 } from "fs";
1424
- import process17 from "process";
1448
+ import process18 from "process";
1425
1449
  import tty from "tty";
1426
1450
 
1427
1451
  // ../kit/src/picker/preview.ts
1428
- import process16 from "process";
1452
+ import process17 from "process";
1429
1453
 
1430
1454
  // ../kit/src/shell.ts
1431
1455
  var SEPARATORS = new Set([`
@@ -1494,7 +1518,7 @@ async function runPreview(template, line, signal, hidden = []) {
1494
1518
  ${previewCommand(template, line, hidden)}`], { stdin: "ignore", stdout: "pipe", stderr: "ignore", detached: true });
1495
1519
  const stop = () => {
1496
1520
  try {
1497
- process16.kill(-proc.pid, "SIGKILL");
1521
+ process17.kill(-proc.pid, "SIGKILL");
1498
1522
  } catch {
1499
1523
  proc.kill();
1500
1524
  }
@@ -1642,7 +1666,7 @@ function openTerminal() {
1642
1666
  return fail("no terminal to read keys from (/dev/tty)");
1643
1667
  }
1644
1668
  const keys = Bun.file("/dev/tty").stream().getReader();
1645
- const out = process17.stderr;
1669
+ const out = process18.stderr;
1646
1670
  let resize;
1647
1671
  async function read(onChunk) {
1648
1672
  const decoder = new TextDecoder;
@@ -1816,9 +1840,9 @@ async function select(rows, settings, terminal = openTerminal()) {
1816
1840
  const ended = new Promise((resolve) => {
1817
1841
  finish = resolve;
1818
1842
  });
1819
- process17.once("exit", restore);
1843
+ process18.once("exit", restore);
1820
1844
  for (const signal of SIGNALS2)
1821
- process17.once(signal, stop);
1845
+ process18.once(signal, stop);
1822
1846
  try {
1823
1847
  terminal.write(`${PASTE_ON}${MOUSE_ON}`);
1824
1848
  terminal.listen(onChunk, () => draw(true));
@@ -1831,8 +1855,8 @@ async function select(rows, settings, terminal = openTerminal()) {
1831
1855
  await ended;
1832
1856
  } finally {
1833
1857
  for (const signal of SIGNALS2)
1834
- process17.off(signal, stop);
1835
- process17.off("exit", restore);
1858
+ process18.off(signal, stop);
1859
+ process18.off("exit", restore);
1836
1860
  restore();
1837
1861
  }
1838
1862
  return state.done === "accept" ? { rows: chosen(state), key: state.key, query: state.query } : undefined;
@@ -1863,23 +1887,23 @@ function heightFor(count) {
1863
1887
  return String(Math.max(15, Math.ceil((count + 4) / 0.6)));
1864
1888
  }
1865
1889
  function historyFile(name) {
1866
- return join7(process18.env.XDG_CACHE_HOME ?? join7(homedir5(), ".cache"), name, "history.json");
1890
+ return join7(process19.env.XDG_CACHE_HOME ?? join7(homedir5(), ".cache"), name, "history.json");
1867
1891
  }
1868
1892
  function history(name) {
1869
1893
  try {
1870
1894
  const file = historyFile(name);
1871
- return existsSync4(file) ? JSON.parse(readFileSync4(file, "utf-8")) : {};
1895
+ return existsSync4(file) ? JSON.parse(readFileSync5(file, "utf-8")) : {};
1872
1896
  } catch {
1873
1897
  return {};
1874
1898
  }
1875
1899
  }
1876
1900
  function runs(name) {
1877
- return history(name)[process18.cwd()] ?? [];
1901
+ return history(name)[process19.cwd()] ?? [];
1878
1902
  }
1879
1903
  function record(name, run) {
1880
1904
  const all = history(name);
1881
1905
  const file = historyFile(name);
1882
- all[process18.cwd()] = [run, ...(all[process18.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
1906
+ all[process19.cwd()] = [run, ...(all[process19.cwd()] ?? []).filter((earlier) => earlier.id !== run.id)].slice(0, REMEMBERED);
1883
1907
  mkdirSync2(dirname4(file), { recursive: true });
1884
1908
  writeFileSync(file, JSON.stringify(all));
1885
1909
  }
@@ -1903,7 +1927,7 @@ function list(rows) {
1903
1927
  }
1904
1928
 
1905
1929
  // ../kit/src/prompt.ts
1906
- import process19 from "process";
1930
+ import process20 from "process";
1907
1931
  var PROMPT_KEYS = new Set(["up", "down", "pageup", "pagedown", "home", "end", "enter", "cancel", "erase"]);
1908
1932
  function readKeys(input, paste = { active: false }) {
1909
1933
  return parseKeys(input, paste).filter((key) => typeof key === "object" ? "text" in key : PROMPT_KEYS.has(key));
@@ -1940,7 +1964,7 @@ async function input2(question, { default: fallback, mask = false, validate, ...
1940
1964
  function answer(colors, question, state, picked) {
1941
1965
  return state === "enter" ? `${colors.green("\u2713")} ${question} ${colors.cyan(picked)}` : `${colors.red("\u2717")} ${question} ${colors.dim("cancelled")}`;
1942
1966
  }
1943
- async function ask(question, { hint, terminal = process19 }, render, press) {
1967
+ async function ask(question, { hint, terminal = process20 }, render, press) {
1944
1968
  const { stdin, stderr } = terminal;
1945
1969
  if (!isInteractive(terminal))
1946
1970
  fail(`cannot ask "${question}" off a terminal`, 2, hint);
@@ -1996,10 +2020,10 @@ async function ask(question, { hint, terminal = process19 }, render, press) {
1996
2020
  }
1997
2021
 
1998
2022
  // src/job-picker.ts
1999
- import process20 from "process";
2023
+ import process21 from "process";
2000
2024
 
2001
2025
  // src/jobs.ts
2002
- import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync5 } from "fs";
2026
+ import { existsSync as existsSync5, readdirSync, readFileSync as readFileSync6 } from "fs";
2003
2027
  import { dirname as dirname5, join as join9, resolve as resolvePath } from "path";
2004
2028
 
2005
2029
  // src/steps.ts
@@ -2008,6 +2032,7 @@ import { join as join8 } from "path";
2008
2032
  var STEP_NAMES = ["check", "typecheck", "lint", "test"];
2009
2033
  var TARGET = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
2010
2034
  var JUSTFILES = ["justfile", "Justfile", ".justfile"];
2035
+ var TASK_RUNNERS = new Set(["Justfile", "Makefile"]);
2011
2036
  var MAKEFILES = ["GNUmakefile", "makefile", "Makefile"];
2012
2037
  var CS_FIXER_CONFIGS = [".php-cs-fixer.php", ".php-cs-fixer.dist.php"];
2013
2038
  var JUST_TIMEOUT_MS = 1e4;
@@ -2119,8 +2144,9 @@ async function discoverProjects(dir) {
2119
2144
  }
2120
2145
  async function discover(dir) {
2121
2146
  const found = await candidates(dir, "check");
2147
+ const runnerCheck = found.find((candidate) => candidate.name === "check" && TASK_RUNNERS.has(candidate.source));
2122
2148
  return STEP_NAMES.flatMap((name) => {
2123
- const step = found.find((candidate) => candidate.name === name);
2149
+ const step = name === "check" && runnerCheck !== undefined ? runnerCheck : found.find((candidate) => candidate.name === name);
2124
2150
  return step === undefined ? [] : [step];
2125
2151
  });
2126
2152
  }
@@ -2253,7 +2279,7 @@ function make(dir) {
2253
2279
  const file = MAKEFILES.find((name) => existsSync5(join9(dir, name)));
2254
2280
  if (file === undefined)
2255
2281
  return [];
2256
- const source = readFileSync5(join9(dir, file), "utf-8");
2282
+ const source = readFileSync6(join9(dir, file), "utf-8");
2257
2283
  return build({ kind: "make", tag: "make", runner: ["make"], separated: false, dir }, targets2(source).map((target) => ({ ...target, body: show(source, target.name) })));
2258
2284
  }
2259
2285
  function manager(dir, manifest) {
@@ -2276,7 +2302,7 @@ function packageScripts(dir, here) {
2276
2302
  const file = locate(dir, here, ["package.json"]);
2277
2303
  if (file === undefined)
2278
2304
  return [];
2279
- const manifest = JSON.parse(readFileSync5(file, "utf-8"));
2305
+ const manifest = JSON.parse(readFileSync6(file, "utf-8"));
2280
2306
  const tool = manager(dirname5(file), manifest);
2281
2307
  const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, body: text2(command) }));
2282
2308
  return build({ kind: "package", tag: tool, runner: [tool, "run"], separated: tool === "npm", dir: dirname5(file) }, items);
@@ -2285,7 +2311,7 @@ function composer(dir, here) {
2285
2311
  const file = locate(dir, here, ["composer.json"]);
2286
2312
  if (file === undefined)
2287
2313
  return [];
2288
- const manifest = JSON.parse(readFileSync5(file, "utf-8"));
2314
+ const manifest = JSON.parse(readFileSync6(file, "utf-8"));
2289
2315
  const descriptions = table2(manifest["scripts-descriptions"]);
2290
2316
  const items = Object.entries(table2(manifest.scripts)).map(([name, command]) => ({ name, doc: field(descriptions, name), body: text2(command) }));
2291
2317
  return build({ kind: "composer", tag: "composer", runner: ["composer", "run"], separated: true, dir: dirname5(file) }, items);
@@ -2294,7 +2320,7 @@ function deno(dir, here) {
2294
2320
  const file = locate(dir, here, ["deno.json", "deno.jsonc"]);
2295
2321
  if (file === undefined)
2296
2322
  return [];
2297
- const manifest = Bun.JSONC.parse(readFileSync5(file, "utf-8"));
2323
+ const manifest = Bun.JSONC.parse(readFileSync6(file, "utf-8"));
2298
2324
  const items = Object.entries(table2(manifest.tasks)).map(([name, task]) => ({ name, doc: field(task, "description"), body: field(task, "command") ?? text2(task) }));
2299
2325
  return build({ kind: "deno", tag: "deno", runner: ["deno", "task"], separated: false, dir: dirname5(file) }, items);
2300
2326
  }
@@ -2302,7 +2328,7 @@ function taskfile(dir, here) {
2302
2328
  const file = locate(dir, here, TASKFILES);
2303
2329
  if (file === undefined)
2304
2330
  return [];
2305
- const tasks = table2(Bun.YAML.parse(readFileSync5(file, "utf-8"))?.tasks);
2331
+ const tasks = table2(Bun.YAML.parse(readFileSync6(file, "utf-8"))?.tasks);
2306
2332
  const items = Object.entries(tasks).filter(([, task]) => !(task !== null && typeof task === "object" && task.internal === true)).map(([name, task]) => ({ name, doc: field(task, "desc") ?? field(task, "summary"), body: text2(task) }));
2307
2333
  return build({ kind: "task", tag: "task", runner: ["task"], separated: true, dir: dirname5(file) }, items);
2308
2334
  }
@@ -2321,7 +2347,7 @@ function pyproject(dir, here) {
2321
2347
  const file = locate(dir, here, ["pyproject.toml"]);
2322
2348
  if (file === undefined)
2323
2349
  return [];
2324
- const manifest = Bun.TOML.parse(readFileSync5(file, "utf-8"));
2350
+ const manifest = Bun.TOML.parse(readFileSync6(file, "utf-8"));
2325
2351
  const tool = table2(manifest.tool);
2326
2352
  const project = table2(manifest.project);
2327
2353
  const uv = locate(dirname5(file), true, ["uv.lock"]) !== undefined;
@@ -2353,9 +2379,9 @@ function readOr(read, fallback) {
2353
2379
  }
2354
2380
  }
2355
2381
  function workspaces() {
2356
- const manifest = readOr(() => JSON.parse(readFileSync5("package.json", "utf-8")), {});
2382
+ const manifest = readOr(() => JSON.parse(readFileSync6("package.json", "utf-8")), {});
2357
2383
  const declared = Array.isArray(manifest.workspaces) ? manifest.workspaces : table2(manifest.workspaces).packages;
2358
- const pnpm = readOr(() => table2(Bun.YAML.parse(readFileSync5("pnpm-workspace.yaml", "utf-8"))).packages, undefined);
2384
+ const pnpm = readOr(() => table2(Bun.YAML.parse(readFileSync6("pnpm-workspace.yaml", "utf-8"))).packages, undefined);
2359
2385
  const patterns = [declared, pnpm].flatMap((value) => Array.isArray(value) ? value.filter((pattern) => typeof pattern === "string") : []);
2360
2386
  const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => new Bun.Glob(pattern.slice(1)));
2361
2387
  return patterns.filter((pattern) => !pattern.startsWith("!")).flatMap((pattern) => [...new Bun.Glob(`${pattern.replace(TRAILING_SLASHES, "")}/package.json`).scanSync({ cwd: "." })].map((file) => dirname5(file))).filter((dir) => !dir.split("/").includes("node_modules") && !excluded.some((glob) => glob.match(dir)));
@@ -2392,7 +2418,7 @@ function key(entry) {
2392
2418
  function id(entry) {
2393
2419
  return `${entry.tag}:${key(entry)}`;
2394
2420
  }
2395
- function resolve3(entries, named) {
2421
+ function resolve4(entries, named) {
2396
2422
  const qualified = QUALIFIED.exec(named);
2397
2423
  const tagged = qualified && entries.some((entry) => entry.tag === qualified[1]) ? qualified : undefined;
2398
2424
  const pool = tagged ? entries.filter((entry) => entry.tag === tagged[1]) : entries;
@@ -2401,7 +2427,7 @@ function resolve3(entries, named) {
2401
2427
  return exact.length > 0 ? exact : pool.filter((entry) => entry.name === rest);
2402
2428
  }
2403
2429
  function shortest(entries, entry) {
2404
- const found = resolve3(entries, key(entry));
2430
+ const found = resolve4(entries, key(entry));
2405
2431
  return found.length === 1 && found[0] === entry ? key(entry) : id(entry);
2406
2432
  }
2407
2433
  function signature(entry) {
@@ -2414,7 +2440,7 @@ function labelled(entries) {
2414
2440
  return new Set(entries.map((entry) => entry.tag)).size > 1;
2415
2441
  }
2416
2442
  function row(entry, labels, signed) {
2417
- const colors = paint(process20.stderr);
2443
+ const colors = paint(process21.stderr);
2418
2444
  const keyed = entry.dir === "." ? entry.name : `${colors.dim(`${entry.dir}/`)}${entry.name}`;
2419
2445
  return {
2420
2446
  hidden: [entry.kind, entry.dir, entry.name, id(entry)],
@@ -2428,7 +2454,7 @@ async function pickJob(entries, narrowed = false) {
2428
2454
  prompt: `${[...new Set(entries.map((entry) => entry.tag))].join("/")}> `,
2429
2455
  searched: labels ? 2 : 1,
2430
2456
  ...narrowed ? { height: heightFor(entries.length) } : {},
2431
- preview: `${process20.execPath} ${process20.argv[1]} --show {1} {2} {3}`
2457
+ preview: `${process21.execPath} ${process21.argv[1]} --show {1} {2} {3}`
2432
2458
  });
2433
2459
  return entries.find((candidate) => id(candidate) === picked?.hidden[3]);
2434
2460
  }
@@ -2440,9 +2466,8 @@ j -
2440
2466
  Without a name, picks a recipe, target, script or task of this folder, its parents and its child folders when a terminal is attached, and runs it. The ones run last come first, per folder. Without a terminal it lists them instead.
2441
2467
  \`j -\` runs the last one again with the same arguments, \`j <name> [args...]\` runs without the picker, the words after the name filling the parameters in order and the required ones left being asked for.
2442
2468
  The sources are a Justfile, a Makefile, the scripts of a package.json (through its package manager), composer.json scripts, deno tasks, a Taskfile, mise tasks and a pyproject (poe tasks and entry points).
2443
- A name is the key behind the folder it runs from, \`api/test\`, bare for this folder. A name several entries share offers them, unless it comes qualified by its runner: \`just:check\`, \`bun:api/test\`.
2444
-
2445
- Exits with the code of the command it ran, 1 when there is nothing to run here or nothing by that name.`;
2469
+ A name is the key behind the folder it runs from, \`api/test\`, bare for this folder. A name several entries share offers them, unless it comes qualified by its runner: \`just:check\`, \`bun:api/test\`.`;
2470
+ var EXITS = [["its own", "the code of the command it ran"], [1, "there is nothing to run here or nothing by that name"]];
2446
2471
  var options = {
2447
2472
  json: jsonOption("[{ id, key, runner, dir, name, doc, parameters }]")
2448
2473
  };
@@ -2450,7 +2475,7 @@ function preview(kind, dir, name) {
2450
2475
  const entry = readKind(kind, dir).find((candidate) => candidate.name === name);
2451
2476
  if (entry === undefined)
2452
2477
  return;
2453
- const colors = paint(process21.stdout);
2478
+ const colors = paint(process22.stdout);
2454
2479
  console.log(`${colors.dim(`$ ${dir === "." ? "" : `env -C ${dir} `}`)}${colors.bold([...entry.runner, entry.name].join(" "))}
2455
2480
  `);
2456
2481
  if (entry.body !== undefined)
@@ -2461,7 +2486,7 @@ function preview(kind, dir, name) {
2461
2486
  function names(found) {
2462
2487
  const described = (entry) => entry.doc === null || entry.doc === "" ? entry.tag : entry.doc;
2463
2488
  return [...new Set(found.map(key))].flatMap((name) => {
2464
- const same = resolve3(found, name);
2489
+ const same = resolve4(found, name);
2465
2490
  return same.length === 1 ? [[name, described(same[0])]] : [[name, same.map((entry) => entry.tag).join(", ")], ...same.map((entry) => [id(entry), described(entry)])];
2466
2491
  });
2467
2492
  }
@@ -2483,7 +2508,7 @@ function listed2(found) {
2483
2508
  }));
2484
2509
  }
2485
2510
  function listing(found) {
2486
- const colors = paint(process21.stdout);
2511
+ const colors = paint(process22.stdout);
2487
2512
  const labels = labelled(found);
2488
2513
  return table(found.map((entry) => [...labels ? [entry.tag] : [], key(entry), signature(entry), colors.dim(entry.doc ?? "")]));
2489
2514
  }
@@ -2520,6 +2545,7 @@ async function j2(argv) {
2520
2545
  const args = emitting ? argv.slice(1) : argv;
2521
2546
  const last = args[0] === "-";
2522
2547
  const parsed = last ? { values: {}, positionals: ["-"], rest: args.slice(1) } : parse(args, usage2, options, {
2548
+ exits: EXITS,
2523
2549
  positionals: ["[name]"],
2524
2550
  candidates: { "[name]": completions },
2525
2551
  trailing: true,
@@ -2553,7 +2579,7 @@ async function j2(argv) {
2553
2579
  }
2554
2580
  entry = await pickJob(byRecency(found, previous, id));
2555
2581
  } else {
2556
- const matching = resolve3(found, named);
2582
+ const matching = resolve4(found, named);
2557
2583
  if (matching.length === 0) {
2558
2584
  const nearest = closest(named, found.map(key));
2559
2585
  fail(`nothing named ${named}${nearest === undefined ? "" : `, did you mean ${nearest}?`}`, 1);
@@ -2583,4 +2609,4 @@ async function j2(argv) {
2583
2609
  }
2584
2610
 
2585
2611
  // src/j-cli.ts
2586
- process22.exitCode = await runMain({ name: "j", version, run: j2 });
2612
+ process23.exitCode = await runMain({ name: "j", version, run: j2 });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-check",
3
3
  "type": "module",
4
- "version": "0.18.1",
4
+ "version": "0.18.3",
5
5
  "description": "check, fix and errs: run a repo's check, typecheck, lint and test steps or its fixers, inside its docker compose service when one mounts the folder, showing only what failed with each full output saved to a file, and turn tsc, eslint, bun test, vitest, playwright, phpunit, phpstan and php-cs-fixer logs into file:line:col errors.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -34,6 +34,6 @@
34
34
  "j": "$npm_execpath src/j-cli.ts"
35
35
  },
36
36
  "devDependencies": {
37
- "@kaynooo/cli-kit": "0.37.0"
37
+ "@kaynooo/cli-kit": "0.38.2"
38
38
  }
39
39
  }