@kaynooo/cli-check 0.22.1 → 0.22.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/cli.js CHANGED
@@ -501,7 +501,7 @@ var init_format = __esm(() => {
501
501
 
502
502
  // ../kit/src/help.ts
503
503
  import process8 from "process";
504
- function usageLine(usage, colors = paint(process8.stdout)) {
504
+ function usageLine(usage, colors = paint(process8.stdout), { summary: withSummary = true } = {}) {
505
505
  const lines = usage.replace(USAGE_PREFIX, "").split(`
506
506
  `);
507
507
  const blank = lines.indexOf("");
@@ -514,7 +514,7 @@ function usageLine(usage, colors = paint(process8.stdout)) {
514
514
  synopses[0] = synopses[0].slice(0, colon);
515
515
  const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
516
516
  `)}`;
517
- const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
517
+ const lead = summary === undefined || !withSummary ? [] : ["", colors.bold(prose(summary, colors))];
518
518
  const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
519
519
  return [head, ...lead, ...rest].join(`
520
520
  `);
@@ -524,8 +524,10 @@ function prose(line, colors) {
524
524
  return line;
525
525
  return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
526
526
  }
527
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
528
- return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
527
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [], bin } = {}) {
528
+ const { summary } = description(usage);
529
+ const head = bin === undefined ? [usageLine(usage, colors)] : [`${colors.bold(bin.name)} ${colors.dim(bin.version())}${summary === "" ? "" : ` ${summary}`}`, "", usageLine(usage, colors, { summary: false })];
530
+ return [...head, "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
529
531
  `);
530
532
  }
531
533
  function exitRows(exits, colors = paint(process8.stdout)) {
@@ -709,7 +711,7 @@ function parse(args, usage, options, settings = {}) {
709
711
  const values = parsed.values;
710
712
  applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
711
713
  if (values.help === true) {
712
- console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, settings));
714
+ console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, { ...settings, bin: heading.bin }));
713
715
  throw new HelpShown;
714
716
  }
715
717
  checkChoices(parsed.values, all);
@@ -846,7 +848,7 @@ function nearestOption(message, options, allowNegative) {
846
848
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
847
849
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
848
850
  }
849
- var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
851
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, heading, OUTPUT_OPTIONS, UNKNOWN_OPTION;
850
852
  var init_args = __esm(() => {
851
853
  init_format();
852
854
  init_help();
@@ -881,6 +883,7 @@ var init_args = __esm(() => {
881
883
  }
882
884
  };
883
885
  completion = { active: false };
886
+ heading = { bin: undefined };
884
887
  OUTPUT_OPTIONS = {
885
888
  color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
886
889
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
@@ -1199,7 +1202,15 @@ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1199
1202
  (( \${#described} )) && _describe -V value described
1200
1203
  (( \${#plain} )) && compadd -- "\${plain[@]}"
1201
1204
  return 0
1202
- }`;
1205
+ }
1206
+ __kaynooo_cli_register() {
1207
+ add-zsh-hook -d precmd __kaynooo_cli_register
1208
+ (( $+functions[compdef] )) || { autoload -Uz compinit && compinit }
1209
+ compdef __kaynooo_cli_complete $__kaynooo_cli_bins
1210
+ }
1211
+ autoload -Uz add-zsh-hook
1212
+ add-zsh-hook precmd __kaynooo_cli_register
1213
+ typeset -gaU __kaynooo_cli_bins`;
1203
1214
  function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1204
1215
  if (shell === "fish")
1205
1216
  return `${header}
@@ -1213,7 +1224,7 @@ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1213
1224
  `;
1214
1225
  return `${header}
1215
1226
  ${ZSH_FUNCTION}
1216
- compdef __kaynooo_cli_complete ${bins.join(" ")}
1227
+ __kaynooo_cli_bins+=(${bins.join(" ")})
1217
1228
  `;
1218
1229
  }
1219
1230
 
@@ -1470,10 +1481,13 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1470
1481
  }
1471
1482
  let code;
1472
1483
  const started = performance.now();
1484
+ heading.bin = { name, version: () => version ?? packageVersion() };
1473
1485
  try {
1474
1486
  code = await run(argv);
1475
1487
  } catch (error) {
1476
1488
  code = reportThrown(name, error, redact, wantsJson(argv));
1489
+ } finally {
1490
+ heading.bin = undefined;
1477
1491
  }
1478
1492
  notifyEnd(name, code, performance.now() - started);
1479
1493
  if (usage !== false) {
@@ -1680,7 +1694,7 @@ init_style();
1680
1694
  // ../kit/src/workspace-root.ts
1681
1695
  init_user_config();
1682
1696
  // package.json
1683
- var version = "0.22.1";
1697
+ var version = "0.22.3";
1684
1698
 
1685
1699
  // src/check.ts
1686
1700
  import { writeFile as writeFile3 } from "fs/promises";
package/dist/errs-cli.js CHANGED
@@ -501,7 +501,7 @@ var init_format = __esm(() => {
501
501
 
502
502
  // ../kit/src/help.ts
503
503
  import process8 from "process";
504
- function usageLine(usage, colors = paint(process8.stdout)) {
504
+ function usageLine(usage, colors = paint(process8.stdout), { summary: withSummary = true } = {}) {
505
505
  const lines = usage.replace(USAGE_PREFIX, "").split(`
506
506
  `);
507
507
  const blank = lines.indexOf("");
@@ -514,7 +514,7 @@ function usageLine(usage, colors = paint(process8.stdout)) {
514
514
  synopses[0] = synopses[0].slice(0, colon);
515
515
  const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
516
516
  `)}`;
517
- const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
517
+ const lead = summary === undefined || !withSummary ? [] : ["", colors.bold(prose(summary, colors))];
518
518
  const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
519
519
  return [head, ...lead, ...rest].join(`
520
520
  `);
@@ -524,8 +524,10 @@ function prose(line, colors) {
524
524
  return line;
525
525
  return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
526
526
  }
527
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
528
- return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
527
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [], bin } = {}) {
528
+ const { summary } = description(usage);
529
+ const head = bin === undefined ? [usageLine(usage, colors)] : [`${colors.bold(bin.name)} ${colors.dim(bin.version())}${summary === "" ? "" : ` ${summary}`}`, "", usageLine(usage, colors, { summary: false })];
530
+ return [...head, "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
529
531
  `);
530
532
  }
531
533
  function exitRows(exits, colors = paint(process8.stdout)) {
@@ -709,7 +711,7 @@ function parse(args, usage, options, settings = {}) {
709
711
  const values = parsed.values;
710
712
  applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
711
713
  if (values.help === true) {
712
- console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, settings));
714
+ console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, { ...settings, bin: heading.bin }));
713
715
  throw new HelpShown;
714
716
  }
715
717
  checkChoices(parsed.values, all);
@@ -846,7 +848,7 @@ function nearestOption(message, options, allowNegative) {
846
848
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
847
849
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
848
850
  }
849
- var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
851
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, heading, OUTPUT_OPTIONS, UNKNOWN_OPTION;
850
852
  var init_args = __esm(() => {
851
853
  init_format();
852
854
  init_help();
@@ -881,6 +883,7 @@ var init_args = __esm(() => {
881
883
  }
882
884
  };
883
885
  completion = { active: false };
886
+ heading = { bin: undefined };
884
887
  OUTPUT_OPTIONS = {
885
888
  color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
886
889
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
@@ -1199,7 +1202,15 @@ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1199
1202
  (( \${#described} )) && _describe -V value described
1200
1203
  (( \${#plain} )) && compadd -- "\${plain[@]}"
1201
1204
  return 0
1202
- }`;
1205
+ }
1206
+ __kaynooo_cli_register() {
1207
+ add-zsh-hook -d precmd __kaynooo_cli_register
1208
+ (( $+functions[compdef] )) || { autoload -Uz compinit && compinit }
1209
+ compdef __kaynooo_cli_complete $__kaynooo_cli_bins
1210
+ }
1211
+ autoload -Uz add-zsh-hook
1212
+ add-zsh-hook precmd __kaynooo_cli_register
1213
+ typeset -gaU __kaynooo_cli_bins`;
1203
1214
  function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1204
1215
  if (shell === "fish")
1205
1216
  return `${header}
@@ -1213,7 +1224,7 @@ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1213
1224
  `;
1214
1225
  return `${header}
1215
1226
  ${ZSH_FUNCTION}
1216
- compdef __kaynooo_cli_complete ${bins.join(" ")}
1227
+ __kaynooo_cli_bins+=(${bins.join(" ")})
1217
1228
  `;
1218
1229
  }
1219
1230
 
@@ -1470,10 +1481,13 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1470
1481
  }
1471
1482
  let code;
1472
1483
  const started = performance.now();
1484
+ heading.bin = { name, version: () => version ?? packageVersion() };
1473
1485
  try {
1474
1486
  code = await run(argv);
1475
1487
  } catch (error) {
1476
1488
  code = reportThrown(name, error, redact, wantsJson(argv));
1489
+ } finally {
1490
+ heading.bin = undefined;
1477
1491
  }
1478
1492
  notifyEnd(name, code, performance.now() - started);
1479
1493
  if (usage !== false) {
@@ -1680,7 +1694,7 @@ init_style();
1680
1694
  // ../kit/src/workspace-root.ts
1681
1695
  init_user_config();
1682
1696
  // package.json
1683
- var version = "0.22.1";
1697
+ var version = "0.22.3";
1684
1698
 
1685
1699
  // src/errs.ts
1686
1700
  import { relative as relative2 } from "path";
package/dist/j-cli.js CHANGED
@@ -501,7 +501,7 @@ var init_format = __esm(() => {
501
501
 
502
502
  // ../kit/src/help.ts
503
503
  import process8 from "process";
504
- function usageLine(usage, colors = paint(process8.stdout)) {
504
+ function usageLine(usage, colors = paint(process8.stdout), { summary: withSummary = true } = {}) {
505
505
  const lines = usage.replace(USAGE_PREFIX, "").split(`
506
506
  `);
507
507
  const blank = lines.indexOf("");
@@ -514,7 +514,7 @@ function usageLine(usage, colors = paint(process8.stdout)) {
514
514
  synopses[0] = synopses[0].slice(0, colon);
515
515
  const head = `${colors.bold("Usage:")} ${synopses.map((line) => line.replaceAll(OPTIONAL, (part) => colors.dim(part))).join(`
516
516
  `)}`;
517
- const lead = summary === undefined ? [] : ["", colors.bold(prose(summary, colors))];
517
+ const lead = summary === undefined || !withSummary ? [] : ["", colors.bold(prose(summary, colors))];
518
518
  const rest = details.length === 0 ? [] : ["", ...details.map((line) => prose(line, colors))];
519
519
  return [head, ...lead, ...rest].join(`
520
520
  `);
@@ -524,8 +524,10 @@ function prose(line, colors) {
524
524
  return line;
525
525
  return line.replaceAll(PROSE_MARKS, (match, code, flag) => code === undefined ? colors.cyan(flag ?? match) : colors.bold(code));
526
526
  }
527
- function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [] } = {}) {
528
- return [usageLine(usage, colors), "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
527
+ function helpText(usage, options, colors = paint(process8.stdout), { examples = [], exits = [], bin } = {}) {
528
+ const { summary } = description(usage);
529
+ const head = bin === undefined ? [usageLine(usage, colors)] : [`${colors.bold(bin.name)} ${colors.dim(bin.version())}${summary === "" ? "" : ` ${summary}`}`, "", usageLine(usage, colors, { summary: false })];
530
+ return [...head, "", colors.bold("Options:"), ...optionRows(options, colors), ...exitRows(exits, colors), ...exampleRows(examples, colors)].join(`
529
531
  `);
530
532
  }
531
533
  function exitRows(exits, colors = paint(process8.stdout)) {
@@ -709,7 +711,7 @@ function parse(args, usage, options, settings = {}) {
709
711
  const values = parsed.values;
710
712
  applyOutput("color" in output ? values.color : undefined, "plain" in output ? values.plain : undefined);
711
713
  if (values.help === true) {
712
- console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, settings));
714
+ console.log(wantsHelpJson() ? JSON.stringify(description(usage, settings, listing)) : helpText(usage, listing, undefined, { ...settings, bin: heading.bin }));
713
715
  throw new HelpShown;
714
716
  }
715
717
  checkChoices(parsed.values, all);
@@ -846,7 +848,7 @@ function nearestOption(message, options, allowNegative) {
846
848
  const meant = closest(word, known.map((flag) => flag.replace(DASHES, "")));
847
849
  return meant === undefined ? undefined : `did you mean ${known.find((flag) => flag.replace(DASHES, "") === meant)}?`;
848
850
  }
849
- var DASHES, EXIT, Exit, UsageError, HelpShown, completion, OUTPUT_OPTIONS, UNKNOWN_OPTION;
851
+ var DASHES, EXIT, Exit, UsageError, HelpShown, completion, heading, OUTPUT_OPTIONS, UNKNOWN_OPTION;
850
852
  var init_args = __esm(() => {
851
853
  init_format();
852
854
  init_help();
@@ -881,6 +883,7 @@ var init_args = __esm(() => {
881
883
  }
882
884
  };
883
885
  completion = { active: false };
886
+ heading = { bin: undefined };
884
887
  OUTPUT_OPTIONS = {
885
888
  color: { type: "string", choices: ["auto", "always", "never"], description: "auto (the default) colours on a terminal alone" },
886
889
  plain: { type: "boolean", description: "plain text, no colour or spinner: --color never" }
@@ -1824,7 +1827,15 @@ var ZSH_FUNCTION = `__kaynooo_cli_complete() {
1824
1827
  (( \${#described} )) && _describe -V value described
1825
1828
  (( \${#plain} )) && compadd -- "\${plain[@]}"
1826
1829
  return 0
1827
- }`;
1830
+ }
1831
+ __kaynooo_cli_register() {
1832
+ add-zsh-hook -d precmd __kaynooo_cli_register
1833
+ (( $+functions[compdef] )) || { autoload -Uz compinit && compinit }
1834
+ compdef __kaynooo_cli_complete $__kaynooo_cli_bins
1835
+ }
1836
+ autoload -Uz add-zsh-hook
1837
+ add-zsh-hook precmd __kaynooo_cli_register
1838
+ typeset -gaU __kaynooo_cli_bins`;
1828
1839
  function completionScript(shell, bins, header = `# Generated by \`${bins[0]} --completions ${shell}\``) {
1829
1840
  if (shell === "fish")
1830
1841
  return `${header}
@@ -1838,7 +1849,7 @@ complete -F __kaynooo_cli_complete ${bins.join(" ")}
1838
1849
  `;
1839
1850
  return `${header}
1840
1851
  ${ZSH_FUNCTION}
1841
- compdef __kaynooo_cli_complete ${bins.join(" ")}
1852
+ __kaynooo_cli_bins+=(${bins.join(" ")})
1842
1853
  `;
1843
1854
  }
1844
1855
 
@@ -2095,10 +2106,13 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
2095
2106
  }
2096
2107
  let code;
2097
2108
  const started = performance.now();
2109
+ heading.bin = { name, version: () => version ?? packageVersion() };
2098
2110
  try {
2099
2111
  code = await run(argv);
2100
2112
  } catch (error) {
2101
2113
  code = reportThrown(name, error, redact, wantsJson(argv));
2114
+ } finally {
2115
+ heading.bin = undefined;
2102
2116
  }
2103
2117
  notifyEnd(name, code, performance.now() - started);
2104
2118
  if (usage !== false) {
@@ -2305,7 +2319,7 @@ init_style();
2305
2319
  // ../kit/src/workspace-root.ts
2306
2320
  init_user_config();
2307
2321
  // package.json
2308
- var version = "0.22.1";
2322
+ var version = "0.22.3";
2309
2323
 
2310
2324
  // src/j.ts
2311
2325
  import process26 from "process";
@@ -3005,6 +3019,8 @@ var BLANKS = /\s+/;
3005
3019
  var TRAILING_SLASHES = /\/+$/;
3006
3020
  var VERSION_SUFFIX = /@.*/;
3007
3021
  var LEADING_HASHES = /^#*/;
3022
+ var INCLUDE = /^(?:-|s)?include[ \t]+([^#]+)/;
3023
+ var GLOB_CHARS2 = /[*?[]/;
3008
3024
  var installed = new Map;
3009
3025
  function has(tool) {
3010
3026
  if (!installed.has(tool))
@@ -3113,11 +3129,28 @@ function show(source, target) {
3113
3129
  return lines.slice(start, end).join(`
3114
3130
  `).trimEnd();
3115
3131
  }
3132
+ function withIncludes(source, dir, seen) {
3133
+ return source.split(`
3134
+ `).map((line) => {
3135
+ const match = INCLUDE.exec(line);
3136
+ if (!match)
3137
+ return line;
3138
+ const paths = match[1].trim().split(BLANKS).flatMap((path) => GLOB_CHARS2.test(path) ? [...new Bun.Glob(path).scanSync({ cwd: dir })].sort() : [path]);
3139
+ const files = paths.map((path) => resolvePath(dir, path)).filter((file) => !seen.has(file) && existsSync5(file));
3140
+ return files.map((file) => {
3141
+ seen.add(file);
3142
+ return withIncludes(readFileSync8(file, "utf-8"), dir, seen);
3143
+ }).join(`
3144
+ `);
3145
+ }).join(`
3146
+ `);
3147
+ }
3116
3148
  function make(dir) {
3117
3149
  const file = MAKEFILES.find((name) => existsSync5(join11(dir, name)));
3118
3150
  if (file === undefined)
3119
3151
  return [];
3120
- const source = readFileSync8(join11(dir, file), "utf-8");
3152
+ const path = resolvePath(dir, file);
3153
+ const source = withIncludes(readFileSync8(path, "utf-8"), dir, new Set([path]));
3121
3154
  return build({ kind: "make", tag: "make", runner: ["make"], separated: false, dir }, targets2(source).map((target) => ({ ...target, body: show(source, target.name) })));
3122
3155
  }
3123
3156
  function manager(dir, manifest) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-check",
3
3
  "type": "module",
4
- "version": "0.22.1",
4
+ "version": "0.22.3",
5
5
  "description": "check and errs: run a repo's check, typecheck, lint, format check and test steps or, with --fix, 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",
@@ -22,9 +22,6 @@
22
22
  "engines": {
23
23
  "bun": ">=1.4.3"
24
24
  },
25
- "publishConfig": {
26
- "registry": "https://git.kaynooo.fr/api/packages/kaynooo/npm/"
27
- },
28
25
  "scripts": {
29
26
  "build": "$npm_execpath build src/cli.ts src/errs-cli.ts src/j-cli.ts --target bun --outdir dist && $npm_execpath ../../scripts/shell-shebang.ts",
30
27
  "check": "$npm_execpath src/cli.ts",
@@ -32,6 +29,6 @@
32
29
  "j": "$npm_execpath src/j-cli.ts"
33
30
  },
34
31
  "devDependencies": {
35
- "@kaynooo/cli-kit": "0.46.4"
32
+ "@kaynooo/cli-kit": "0.48.0"
36
33
  }
37
34
  }