@kaynooo/cli-check 0.18.3 → 0.20.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/fix-cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // @bun
3
3
 
4
4
  // src/fix-cli.ts
5
- import process20 from "process";
5
+ import process22 from "process";
6
6
  // ../kit/src/args.ts
7
7
  import process10 from "process";
8
8
  import { parseArgs } from "util";
@@ -461,7 +461,7 @@ function printJson(value) {
461
461
 
462
462
  // ../kit/src/help.ts
463
463
  import process8 from "process";
464
- var OPTIONAL = /\[[^\]]+\]/g;
464
+ var OPTIONAL = /(?<!\x1B)\[[^\]]+\]/g;
465
465
  var USAGE_PREFIX = /^usage:\s*/i;
466
466
  var FULL_STOP = /\.$/;
467
467
  function usageLine(usage, colors = paint(process8.stdout)) {
@@ -500,32 +500,44 @@ function exampleRows(examples, colors = paint(process8.stdout)) {
500
500
  return [];
501
501
  return ["", colors.bold("Examples:"), ...examples.map((example) => typeof example === "string" ? ` ${example}` : ` ${example[0]} ${colors.dim(`# ${example[1]}`)}`)];
502
502
  }
503
+ var MAX_INLINE_CHOICES = 24;
503
504
  function optionRows(options, colors = paint(process8.stdout)) {
504
505
  const rows = Object.entries(options).map(([name, option]) => {
505
506
  const short = option.short === undefined ? " " : `${colors.cyan(`-${option.short}`)}, `;
506
- const named = option.choices === undefined ? "<value>" : `<${option.choices.join("|")}>`;
507
+ const choices = option.choices?.join("|");
508
+ const inline = choices !== undefined && choices.length <= MAX_INLINE_CHOICES;
509
+ const named = inline ? `<${choices}>` : "<value>";
507
510
  const placeholder = option.optional === undefined ? named : `[${named}]`;
508
511
  const value = option.type === "string" ? ` ${colors.dim(placeholder)}` : "";
509
- return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: option.description ?? "" };
512
+ const described = choices === undefined || inline ? option.description ?? "" : [option.description, `one of ${option.choices.join(", ")}`].filter(Boolean).join("; ");
513
+ return { flag: `${short}${colors.cyan(`--${name}`)}${value}`, width: `-x, --${name}`.length + (option.type === "string" ? placeholder.length + 1 : 0), description: described };
510
514
  });
511
515
  const width = Math.max(0, ...rows.map((row) => row.width));
512
516
  return rows.map((row) => row.description === "" ? ` ${row.flag}` : ` ${row.flag}${" ".repeat(width - row.width)} ${colors.dim(row.description)}`);
513
517
  }
514
518
 
515
519
  // ../kit/src/text.ts
516
- var ANSI = new RegExp(`${String.fromCharCode(27)}\\[[\\d;?]*[a-z]`, "gi");
520
+ var ANSI = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[\x40-\x5A\x5C-\x5F])/g;
517
521
  function stripAnsi(text) {
518
522
  return text.replace(ANSI, "");
519
523
  }
520
524
  function distance(a, b) {
521
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
522
- for (const [i, left] of [...a].entries()) {
525
+ const left = [...a];
526
+ const right = [...b];
527
+ let before = [];
528
+ let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
529
+ for (const [i, x] of left.entries()) {
523
530
  const current = [i + 1];
524
- for (const [j, right] of [...b].entries())
525
- current.push(Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (left === right ? 0 : 1)));
531
+ for (const [j, y] of right.entries()) {
532
+ let cost = Math.min((previous[j + 1] ?? 0) + 1, (current[j] ?? 0) + 1, (previous[j] ?? 0) + (x === y ? 0 : 1));
533
+ if (i > 0 && j > 0 && x === right[j - 1] && left[i - 1] === y)
534
+ cost = Math.min(cost, (before[j - 1] ?? 0) + 1);
535
+ current.push(cost);
536
+ }
537
+ before = previous;
526
538
  previous = current;
527
539
  }
528
- return previous[b.length] ?? 0;
540
+ return previous[right.length] ?? 0;
529
541
  }
530
542
  function closest(name, names) {
531
543
  const started = names.find((known) => known.startsWith(name));
@@ -930,31 +942,49 @@ var CLOSE_LINK = `${ESC}]8;;${ESC}\\`;
930
942
  // ../kit/src/cli.ts
931
943
  import { readFileSync as readFileSync4, realpathSync as realpathSync2 } from "fs";
932
944
  import { dirname as dirname3, join as join6 } from "path";
933
- import process15 from "process";
945
+ import process16 from "process";
946
+
947
+ // ../kit/src/notify.ts
948
+ import process13 from "process";
949
+ var NOTIFY_AFTER_MS = 1e4;
950
+ var CANCELLED = 130;
951
+ function base64(text) {
952
+ return Buffer.from(text).toString("base64");
953
+ }
954
+ function notification(title, body, env = process13.env) {
955
+ const id = `kit${process13.pid}`;
956
+ const codes = [`\x1B]99;i=${id}:d=0:o=unfocused:e=1;${base64(title)}\x1B\\`, `\x1B]99;i=${id}:p=body:e=1;${base64(body)}\x1B\\`];
957
+ return codes.map((code) => env.TMUX === undefined || env.TMUX === "" ? code : `\x1BPtmux;${code.replaceAll("\x1B", "\x1B\x1B")}\x1B\\`).join("");
958
+ }
959
+ function notifyEnd(command, code, ms, { stream = process13.stderr, env = process13.env } = {}) {
960
+ if (ms < NOTIFY_AFTER_MS || code === CANCELLED || outputMode(stream, env) !== "terminal")
961
+ return;
962
+ stream.write(notification(command, code === 0 ? `done in ${formatDuration(ms)}` : `failed with exit ${code} after ${formatDuration(ms)}`, env));
963
+ }
934
964
 
935
965
  // ../kit/src/usage.ts
936
966
  import { appendFileSync, mkdirSync } from "fs";
937
967
  import { homedir as homedir4 } from "os";
938
968
  import { dirname as dirname2, isAbsolute, join as join5 } from "path";
939
- import process14 from "process";
969
+ import process15 from "process";
940
970
 
941
971
  // ../kit/src/logs.ts
942
972
  import { lstatSync, openSync } from "fs";
943
973
  import { mkdir, mkdtemp, readdir, rm, stat } from "fs/promises";
944
974
  import { homedir as homedir3, tmpdir } from "os";
945
975
  import { join as join4 } from "path";
946
- import process13 from "process";
976
+ import process14 from "process";
947
977
  var DAY_MS = 24 * 60 * 60 * 1000;
948
978
  var CLI_FOLDER = "kaynooo-cli";
949
979
  function isPrivateDirectory(path) {
950
980
  try {
951
981
  const info = lstatSync(path, { throwIfNoEntry: false });
952
- return info !== undefined && info.isDirectory() && info.uid === (process13.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
982
+ return info !== undefined && info.isDirectory() && info.uid === (process14.getuid?.() ?? info.uid) && (info.mode & 63) === 0;
953
983
  } catch {
954
984
  return false;
955
985
  }
956
986
  }
957
- async function privateLogDirectory(name, env = process13.env) {
987
+ async function privateLogDirectory(name, env = process14.env) {
958
988
  const runtime = env.XDG_RUNTIME_DIR;
959
989
  const base = runtime === undefined || runtime === "" ? join4(homedir3(), ".cache", CLI_FOLDER) : join4(runtime, CLI_FOLDER);
960
990
  const path = join4(base, name);
@@ -994,14 +1024,14 @@ var usageError;
994
1024
  function noteUsageError(message) {
995
1025
  usageError = message;
996
1026
  }
997
- function stateHome(env = process14.env) {
1027
+ function stateHome(env = process15.env) {
998
1028
  const dir = env.XDG_STATE_HOME;
999
1029
  return dir !== undefined && isAbsolute(dir) ? dir : join5(homedir4(), ".local", "state");
1000
1030
  }
1001
- function usagePath(env = process14.env) {
1031
+ function usagePath(env = process15.env) {
1002
1032
  return join5(stateHome(env), CLI_FOLDER, "usage.jsonl");
1003
1033
  }
1004
- function usageRecorded(env = process14.env) {
1034
+ function usageRecorded(env = process15.env) {
1005
1035
  const off = env.KAYNOOO_CLI_NO_USAGE;
1006
1036
  return env.NODE_ENV !== "test" && (off === undefined || off === "" || off === "0");
1007
1037
  }
@@ -1015,7 +1045,7 @@ function usageEntry(bin, command, argv, code, now = new Date) {
1015
1045
  usageError = undefined;
1016
1046
  return { at: now.toISOString(), bin, ...command === undefined ? {} : { command }, flags: flagNames(argv), code, ...unknown === undefined ? {} : { unknown } };
1017
1047
  }
1018
- function recordUsage(entry, env = process14.env) {
1048
+ function recordUsage(entry, env = process15.env) {
1019
1049
  if (!usageRecorded(env))
1020
1050
  return;
1021
1051
  try {
@@ -1033,8 +1063,8 @@ var LEVEL_OPTIONS = {
1033
1063
  };
1034
1064
  var TOP_OPTIONS = { ...LEVEL_OPTIONS, version: { type: "boolean", short: "v", description: "print the version" } };
1035
1065
  function printError(prefix, message, hint, cause) {
1036
- const colors = paint(process15.stderr);
1037
- const styled = takesControlCodes(process15.stderr);
1066
+ const colors = paint(process16.stderr);
1067
+ const styled = takesControlCodes(process16.stderr);
1038
1068
  const head = styled ? `${colors.red.bold("error")} ${colors.dim(`${prefix}:`)}` : `error: ${prefix}:`;
1039
1069
  const under = (label, text, tint) => text === undefined ? "" : `
1040
1070
  ${styled ? tint(label) : `${label}:`} ${text}`;
@@ -1139,11 +1169,13 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1139
1169
  return 0;
1140
1170
  }
1141
1171
  let code;
1172
+ const started = performance.now();
1142
1173
  try {
1143
1174
  code = await run(argv);
1144
1175
  } catch (error) {
1145
1176
  code = reportThrown(name, error, redact, wantsJson(argv));
1146
1177
  }
1178
+ notifyEnd(name, code, performance.now() - started);
1147
1179
  if (usage !== false) {
1148
1180
  try {
1149
1181
  recordUsage(usageEntry(name, undefined, argv, code));
@@ -1151,13 +1183,174 @@ async function runMain({ name, version, run, redact, usage }, argv = scriptArgs(
1151
1183
  }
1152
1184
  return code;
1153
1185
  }
1186
+ // ../kit/src/excerpt.ts
1187
+ var BASH_ECHO = /^\$ /;
1188
+ var DURATION2 = / \[[\d.]+m?s\]$/;
1189
+ var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
1190
+ var BUN_TEST_SUMMARY = /^\s*\d+ (?:pass|fail|skip|todo)$|^Ran \d+ tests?/;
1191
+ var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
1192
+ var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
1193
+ var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
1194
+ var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
1195
+ var TSC_ERROR = /\berror TS\d+/;
1196
+ var TSC_CONTINUATION = /^\s{2,}\S/;
1197
+ var TSC_FRAME = /^\s*[~^|]/;
1198
+ var TSC_SUMMARY = /^Found \d+ errors?/;
1199
+ var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
1200
+ var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
1201
+ var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
1202
+ var PHPSTAN_NOISE = /^\s*\[OK\]/;
1203
+ var PHP_FAILURES = /^(?:There w(?:as|ere) \d+ (?:failure|error|risky|warning)|\s+(?:FAIL|FAILED)\s+\S|In \S+\.php line \d+:$)/;
1204
+ var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
1205
+ var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
1206
+ var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
1207
+ var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
1208
+ var MAX_TESTS = 10;
1209
+ var MAX_LINES = 100;
1210
+ var TAIL = 30;
1211
+ var bunTest = (lines) => {
1212
+ const seen = new Set;
1213
+ const blocks = [];
1214
+ for (const [index, line] of lines.entries()) {
1215
+ const name = line.replace(DURATION2, "");
1216
+ if (!line.startsWith("(fail) ") || seen.has(name))
1217
+ continue;
1218
+ seen.add(name);
1219
+ if (blocks.length < MAX_TESTS)
1220
+ blocks.push(lines.slice(lines.findLastIndex((text, at) => at < index && BOUNDARY.test(text)) + 1, index + 1).join(`
1221
+ `).trim());
1222
+ }
1223
+ if (blocks.length === 0)
1224
+ return;
1225
+ if (seen.size > MAX_TESTS)
1226
+ blocks.push(`and ${seen.size - MAX_TESTS} more failed tests`);
1227
+ return [...blocks.join(`
1228
+
1229
+ `).split(`
1230
+ `), "", ...lines.filter((line) => BUN_TEST_SUMMARY.test(line)).map((line) => line.trim())];
1231
+ };
1232
+ var bunCheck = (lines) => {
1233
+ const text = lines.join(`
1234
+ `);
1235
+ const blocks = text.match(BUN_CHECK_BLOCK);
1236
+ if (blocks === null)
1237
+ return;
1238
+ const errors = blocks.map((block) => {
1239
+ const { file, line, column, code, message } = bunCheckFields(block);
1240
+ return `${file}:${line}:${column} ${code}: ${message}`;
1241
+ });
1242
+ return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
1243
+ };
1244
+ function bunCheckFields(block) {
1245
+ const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
1246
+ `)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
1247
+ return {
1248
+ file: attributes.file ?? "",
1249
+ line: attributes.line ?? "",
1250
+ column: attributes.column ?? "",
1251
+ code: attributes.code ?? "",
1252
+ message: block.replace(BUN_CHECK_SOURCE, "").split(`
1253
+ `).slice(1, -1).join(`
1254
+ `).trim()
1255
+ };
1256
+ }
1257
+ var tsc = (lines) => {
1258
+ const kept = [];
1259
+ let inError = false;
1260
+ for (const line of lines) {
1261
+ if (TSC_ERROR.test(line)) {
1262
+ inError = true;
1263
+ kept.push(line);
1264
+ } else if (TSC_SUMMARY.test(line)) {
1265
+ inError = false;
1266
+ kept.push(line);
1267
+ } else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
1268
+ kept.push(line);
1269
+ } else {
1270
+ inError = false;
1271
+ }
1272
+ }
1273
+ return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
1274
+ };
1275
+ var eslint = (lines) => {
1276
+ const kept = [];
1277
+ let file = "";
1278
+ let shown = "";
1279
+ for (const line of lines) {
1280
+ if (ESLINT_PROBLEM.test(line)) {
1281
+ if (file !== shown) {
1282
+ kept.push(file);
1283
+ shown = file;
1284
+ }
1285
+ kept.push(line);
1286
+ } else if (ESLINT_SUMMARY.test(line)) {
1287
+ kept.push(line);
1288
+ } else if (line.trim() !== "") {
1289
+ file = line;
1290
+ }
1291
+ }
1292
+ return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
1293
+ };
1294
+ var phpstan = (lines) => {
1295
+ const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
1296
+ return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
1297
+ };
1298
+ var php = (lines) => {
1299
+ const start = lines.findIndex((line) => PHP_FAILURES.test(line));
1300
+ return start === -1 ? undefined : lines.slice(start);
1301
+ };
1302
+ var vitest = (lines) => {
1303
+ const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
1304
+ return start === -1 ? undefined : lines.slice(start);
1305
+ };
1306
+ var playwright = (lines) => {
1307
+ const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
1308
+ return start === -1 ? undefined : lines.slice(start);
1309
+ };
1310
+ var phpCsFixer = (lines) => {
1311
+ const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
1312
+ return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
1313
+ };
1314
+ var PARSERS = [bunTest, bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan, php];
1315
+ function squeeze(lines) {
1316
+ const out = [];
1317
+ for (const line of lines.map((text) => text.trimEnd())) {
1318
+ if (line !== "" || out.at(-1) !== "")
1319
+ out.push(line);
1320
+ }
1321
+ while (out.at(-1) === "")
1322
+ out.pop();
1323
+ return out;
1324
+ }
1325
+ function cut(shown) {
1326
+ return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
1327
+ `) : shown.join(`
1328
+ `);
1329
+ }
1330
+ function recognised(lines, parsers) {
1331
+ return parsers.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
1332
+ }
1333
+ function failureExcerpt(output) {
1334
+ const lines = stripAnsi(output).split(`
1335
+ `);
1336
+ if (BASH_ECHO.test(lines[0] ?? ""))
1337
+ lines.shift();
1338
+ return cut(squeeze(recognised(lines, PARSERS) ?? lines.slice(-TAIL)));
1339
+ }
1340
+ var LOG_PATTERNS = { BASH_ECHO, DURATION: DURATION2, BOUNDARY, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_CONTINUATION, TSC_FRAME, TSC_SUMMARY, ESLINT_PROBLEM, ESLINT_SUMMARY };
1154
1341
  // ../kit/src/folders.ts
1342
+ import { homedir as homedir5 } from "os";
1343
+ import { join as join7 } from "path";
1344
+ import process17 from "process";
1155
1345
  var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1156
1346
  function ignoredFolders(extra = [], where = {}) {
1157
1347
  const configured = readUserConfig("config", where).ignore;
1158
1348
  const names = Array.isArray(configured) ? configured.filter((name) => typeof name === "string" && name !== "") : [];
1159
1349
  return new Set([...SKIPPED_FOLDERS, ...extra, ...names]);
1160
1350
  }
1351
+ function cacheFolder({ home = homedir5(), env = process17.env } = {}) {
1352
+ return env.XDG_CACHE_HOME ?? join7(home, ".cache");
1353
+ }
1161
1354
  // ../kit/src/secrets.ts
1162
1355
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1163
1356
  // ../kit/src/sessions.ts
@@ -1165,17 +1358,17 @@ var {Glob } = globalThis.Bun;
1165
1358
  var SESSION_FILES = new Glob("*.json");
1166
1359
  var ACCOUNT_DIRS = new Glob("*/sessions");
1167
1360
  // package.json
1168
- var version = "0.18.3";
1361
+ var version = "0.20.0";
1169
1362
 
1170
1363
  // src/fix.ts
1171
1364
  import { existsSync as existsSync5, statSync as statSync2 } from "fs";
1172
1365
  import { rename, writeFile as writeFile2 } from "fs/promises";
1173
- import { join as join11 } from "path";
1174
- import process19 from "process";
1366
+ import { join as join12 } from "path";
1367
+ import process21 from "process";
1175
1368
 
1176
1369
  // src/changes.ts
1177
1370
  import { stat as stat2 } from "fs/promises";
1178
- import { join as join7 } from "path";
1371
+ import { join as join8 } from "path";
1179
1372
  var {$ } = globalThis.Bun;
1180
1373
  async function dirtyFiles(dir) {
1181
1374
  const listed = await $`git ls-files -z --modified --others --exclude-standard`.cwd(dir).quiet().nothrow();
@@ -1184,7 +1377,7 @@ async function dirtyFiles(dir) {
1184
1377
  const files = new Map;
1185
1378
  for (const path of listed.stdout.toString().split("\x00").filter(Boolean)) {
1186
1379
  try {
1187
- const { size, mtimeMs } = await stat2(join7(dir, path));
1380
+ const { size, mtimeMs } = await stat2(join8(dir, path));
1188
1381
  files.set(path, `${size}:${mtimeMs}`);
1189
1382
  } catch {
1190
1383
  files.set(path, "");
@@ -1198,9 +1391,9 @@ function changedFiles(before, after) {
1198
1391
 
1199
1392
  // src/compose.ts
1200
1393
  import { existsSync as existsSync4 } from "fs";
1201
- import { homedir as homedir5 } from "os";
1202
- import { basename, dirname as dirname4, join as join8, relative, resolve as resolve4 } from "path";
1203
- import process17 from "process";
1394
+ import { homedir as homedir6 } from "os";
1395
+ import { basename, dirname as dirname4, join as join9, relative, resolve as resolve4 } from "path";
1396
+ import process19 from "process";
1204
1397
 
1205
1398
  // ../kit/src/shell.ts
1206
1399
  var SEPARATORS = new Set([`
@@ -1278,7 +1471,7 @@ function toolWords(program) {
1278
1471
  }
1279
1472
  async function readFiles(dir, names) {
1280
1473
  for (const name of names) {
1281
- const handle = Bun.file(join8(dir, name));
1474
+ const handle = Bun.file(join9(dir, name));
1282
1475
  if (await handle.exists())
1283
1476
  return { name, text: await handle.text() };
1284
1477
  }
@@ -1293,7 +1486,7 @@ async function variables(composeDir) {
1293
1486
  if (match !== null && !line.trimStart().startsWith("#"))
1294
1487
  env[match[1] ?? ""] = (match[2] ?? "").trim().replace(QUOTED, "$2");
1295
1488
  }
1296
- for (const [key, value] of Object.entries(process17.env)) {
1489
+ for (const [key, value] of Object.entries(process19.env)) {
1297
1490
  if (value !== undefined)
1298
1491
  env[key] = value;
1299
1492
  }
@@ -1313,7 +1506,7 @@ function interpolate(text, env) {
1313
1506
  function bindSource(source, composeDir, env) {
1314
1507
  const path = interpolate(source, env);
1315
1508
  if (path.startsWith("~"))
1316
- return join8(homedir5(), path.slice(1));
1509
+ return join9(homedir6(), path.slice(1));
1317
1510
  if (path.startsWith("/"))
1318
1511
  return resolve4(path);
1319
1512
  return path.startsWith(".") ? resolve4(composeDir, path) : undefined;
@@ -1360,7 +1553,7 @@ async function composeFiles(composeDir, env) {
1360
1553
  for (const name of listed.split(separator === undefined || separator === "" ? ":" : separator).filter((entry) => entry !== "")) {
1361
1554
  const file = Bun.file(resolve4(composeDir, name));
1362
1555
  if (!await file.exists())
1363
- fail(`COMPOSE_FILE names ${join8(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
1556
+ fail(`COMPOSE_FILE names ${join9(composeDir, name)}, which does not exist`, 1, "fix COMPOSE_FILE, or run on the host with --host");
1364
1557
  files.push({ name, text: await file.text() });
1365
1558
  }
1366
1559
  return files;
@@ -1382,7 +1575,7 @@ async function readServices(composeDir) {
1382
1575
  try {
1383
1576
  parsed = parseServices(file.text, composeDir, env);
1384
1577
  } catch (error) {
1385
- fail(`cannot read ${join8(composeDir, file.name)}: ${error instanceof Error ? error.message : String(error)}`, 1, "fix the file, or run on the host with --host");
1578
+ fail(`cannot read ${join9(composeDir, file.name)}: ${error instanceof Error ? error.message : String(error)}`, 1, "fix the file, or run on the host with --host");
1386
1579
  }
1387
1580
  for (const [name, extra] of parsed) {
1388
1581
  const known = services.get(name);
@@ -1394,11 +1587,11 @@ async function readServices(composeDir) {
1394
1587
  function climb(dir) {
1395
1588
  const folders = [dir];
1396
1589
  let current = dir;
1397
- while (!existsSync4(join8(current, ".git")) && dirname4(current) !== current) {
1590
+ while (!existsSync4(join9(current, ".git")) && dirname4(current) !== current) {
1398
1591
  current = dirname4(current);
1399
1592
  folders.push(current);
1400
1593
  }
1401
- return existsSync4(join8(current, ".git")) ? folders : [dir];
1594
+ return existsSync4(join9(current, ".git")) ? folders : [dir];
1402
1595
  }
1403
1596
  function containerPath(service, dir) {
1404
1597
  const holding = service.mounts.filter((mount) => {
@@ -1409,7 +1602,7 @@ function containerPath(service, dir) {
1409
1602
  if (deepest === undefined)
1410
1603
  return;
1411
1604
  const inside = relative(deepest.source, dir);
1412
- return inside === "" ? deepest.target : join8(deepest.target, inside);
1605
+ return inside === "" ? deepest.target : join9(deepest.target, inside);
1413
1606
  }
1414
1607
  var noticed = new Set;
1415
1608
  async function place(dir, program, { service, host } = {}) {
@@ -1429,7 +1622,7 @@ async function place(dir, program, { service, host } = {}) {
1429
1622
  fail(`--in ${service}: no compose project mounts ${dir}`);
1430
1623
  return;
1431
1624
  }
1432
- if (Bun.which("docker", { PATH: process17.env.PATH ?? "" }) === null) {
1625
+ if (Bun.which("docker", { PATH: process19.env.PATH ?? "" }) === null) {
1433
1626
  if (service !== undefined)
1434
1627
  fail(`--in ${service}: docker not found`);
1435
1628
  if (!noticed.has(found.composeDir)) {
@@ -1481,7 +1674,7 @@ class Stack {
1481
1674
  }
1482
1675
  static async running(composeDir) {
1483
1676
  try {
1484
- const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process17.env, timeoutMs: PS_TIMEOUT_MS });
1677
+ const ran = await runCommand(["docker", "compose", "ps", "--services", "--status", "running"], { cwd: composeDir, env: process19.env, timeoutMs: PS_TIMEOUT_MS });
1485
1678
  if (ran.code !== 0)
1486
1679
  return `docker compose ps failed in ${composeDir}: ${ran.text.trim().split(`
1487
1680
  `).at(-1) ?? `exit ${ran.code}`}`;
@@ -1545,7 +1738,7 @@ ${body}`;
1545
1738
 
1546
1739
  // src/steps.ts
1547
1740
  import { readdir as readdir2 } from "fs/promises";
1548
- import { join as join9 } from "path";
1741
+ import { join as join10 } from "path";
1549
1742
  var STEP_NAMES = ["check", "typecheck", "lint", "test"];
1550
1743
  var TARGET2 = /^@?([\w-]+)(?:[ \t][^:=\n]*)?:(?!=)/gm;
1551
1744
  var JUSTFILES = ["justfile", "Justfile", ".justfile"];
@@ -1557,7 +1750,7 @@ var PHPSTAN_CONFIGS = ["phpstan.neon", "phpstan.neon.dist", "phpstan.dist.neon"]
1557
1750
  var PHPUNIT_CONFIGS = ["phpunit.xml", "phpunit.xml.dist", "phpunit.dist.xml"];
1558
1751
  async function readFirst(dir, files) {
1559
1752
  for (const file of files) {
1560
- const handle = Bun.file(join9(dir, file));
1753
+ const handle = Bun.file(join10(dir, file));
1561
1754
  if (await handle.exists())
1562
1755
  return { file, text: await handle.text() };
1563
1756
  }
@@ -1565,7 +1758,7 @@ async function readFirst(dir, files) {
1565
1758
  }
1566
1759
  async function read(dir, ...files) {
1567
1760
  for (const file of files) {
1568
- const handle = Bun.file(join9(dir, file));
1761
+ const handle = Bun.file(join10(dir, file));
1569
1762
  if (await handle.exists())
1570
1763
  return handle.text();
1571
1764
  }
@@ -1625,7 +1818,7 @@ async function candidates(dir, bin) {
1625
1818
  }
1626
1819
  async function firstFile(dir, names) {
1627
1820
  for (const name of names) {
1628
- if (await Bun.file(join9(dir, name)).exists())
1821
+ if (await Bun.file(join10(dir, name)).exists())
1629
1822
  return name;
1630
1823
  }
1631
1824
  return;
@@ -1653,9 +1846,9 @@ async function discoverProjects(dir) {
1653
1846
  for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {
1654
1847
  if (!entry.isDirectory() || entry.name.startsWith(".") || ignored.has(entry.name))
1655
1848
  continue;
1656
- const steps = await discover(join9(dir, entry.name));
1849
+ const steps = await discover(join10(dir, entry.name));
1657
1850
  if (steps.length > 0)
1658
- projects.push({ name: entry.name, dir: join9(dir, entry.name), steps });
1851
+ projects.push({ name: entry.name, dir: join10(dir, entry.name), steps });
1659
1852
  }
1660
1853
  return projects;
1661
1854
  }
@@ -1682,7 +1875,9 @@ var options = {
1682
1875
  quiet: { type: "boolean", short: "q", description: "print nothing for a passing step, and nothing at all when every step passes" },
1683
1876
  failed: { type: "boolean", description: "run only the steps that failed in the last run of this folder, read from the run folder" },
1684
1877
  changed: { type: "boolean", short: "c", description: "narrow lint and test to the files changed against HEAD (a bare linter script, a bare bun test script), every other step runs in full and says so" },
1685
- slot: { type: "boolean", description: "run each step through slot, queued behind the machine-wide slots of the other sessions (needs the slot bin)" }
1878
+ slot: { type: "boolean", description: "run each step through slot, queued behind the machine-wide slots of the other sessions, as it does by default when the slot bin is installed; fails without the bin" },
1879
+ "no-slot": { type: "boolean", description: "run the steps at once, without queueing behind the other sessions' slots" },
1880
+ parallel: { type: "boolean", description: "run the steps at the same time, printing each one's output in step order" }
1686
1881
  };
1687
1882
  var COMMA = /\s*,\s*/;
1688
1883
  function pick(steps, only, noun = "step") {
@@ -1699,654 +1894,26 @@ function pick(steps, only, noun = "step") {
1699
1894
 
1700
1895
  // src/run.ts
1701
1896
  import { mkdir as mkdir2, readdir as readdir3, stat as stat3, writeFile } from "fs/promises";
1702
- import { basename as basename2, join as join10 } from "path";
1703
- import process18 from "process";
1704
-
1705
- // src/e2e.ts
1706
- var E2E_NOISE = [
1707
- /^(?:Running \d+ tests? using|\(node:\d+\) Warning|\(Use `node|\[\d+\/\d+\] |\s+[-\u2713\u2718\u00B0\u00D7]\s+\d+|To open last HTML|Serving HTML report|\s*npx playwright show-report)/,
1708
- /^[\u00B7F\u00D7\u00B0T\u00B1]+$/,
1709
- /^(?: RUN {2}v|\s*[\u276F\u2713\u00D7\u2193] |\s+(?:Test Files|Tests|Start at|Duration|Errors) {2}|\u23AF)/
1710
- ];
1711
- var PLAYWRIGHT_HEADER = /^ {2}\d+\) (?:\[([^\]]+)\] \u203A )?(.+?):(\d+):(\d+) \u203A (.+?) \u2500+$/;
1712
- var PLAYWRIGHT_SUMMARY = /^ {2}\d+ (failed|flaky|passed|skipped|did not run|interrupted)\b/;
1713
- var PLAYWRIGHT_ENTRY = /^ {4}(?:\[([^\]]+)\] \u203A )?(.+?):(\d+):(\d+) \u203A (.+?) \u2500+$/;
1714
- var PLAYWRIGHT_RETRY = /^\s+Retry #\d+ \u2500+$/;
1715
- var FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
1716
- var EXPECTED = /^\s+Expected: (.*)$/;
1717
- var RECEIVED = /^\s+Received: (.*)$/;
1718
- var VITEST_FAIL = /^ FAIL {2}(?:\|[^|]+\| )?(.+)$/;
1719
- var VITEST_SUITE = /^(.+?) \[ .+ \]$/;
1720
- var VITEST_FRAME = /^\s*\u276F (\S+):(\d+):(\d+)$/;
1721
- function key(project, file, line, column, title) {
1722
- return `${project ?? ""}|${file}:${line}:${column} \u203A ${title}`;
1723
- }
1724
- function firstFrame(block) {
1725
- return block.map((line) => FRAME.exec(line)).find((match) => match !== null && !match[1]?.includes("node_modules")) ?? undefined;
1726
- }
1727
- var collectPlaywright = (lines, used) => {
1728
- const flaky = new Set;
1729
- let section = "";
1730
- for (const [index, line] of lines.entries()) {
1731
- const summary = PLAYWRIGHT_SUMMARY.exec(line);
1732
- const entry = PLAYWRIGHT_ENTRY.exec(line);
1733
- if (summary !== null) {
1734
- section = summary[1] ?? "";
1735
- used.add(index);
1736
- } else if (entry !== null && section !== "") {
1737
- if (section === "flaky")
1738
- flaky.add(key(entry[1], entry[2], entry[3], entry[4], entry[5]));
1739
- used.add(index);
1740
- }
1741
- }
1742
- const errors = [];
1743
- for (let index = 0;index < lines.length; index++) {
1744
- const header = PLAYWRIGHT_HEADER.exec(lines[index] ?? "");
1745
- if (header === null)
1746
- continue;
1747
- let end = index + 1;
1748
- while (end < lines.length && !PLAYWRIGHT_HEADER.test(lines[end] ?? "") && !PLAYWRIGHT_SUMMARY.test(lines[end] ?? ""))
1749
- end++;
1750
- for (let at = index;at < end; at++)
1751
- used.add(at);
1752
- const [, project, file, line, column, title] = header;
1753
- const retry = lines.findIndex((text, at) => at > index && at < end && PLAYWRIGHT_RETRY.test(text));
1754
- const block = lines.slice(index + 1, retry === -1 ? end : retry);
1755
- const frame = firstFrame(block);
1756
- const message = block.find((text) => text.trim() !== "")?.trim() ?? "failed";
1757
- const expected = block.map((text) => EXPECTED.exec(text)?.[1]?.trim()).find((text) => text !== undefined);
1758
- const received = block.map((text) => RECEIVED.exec(text)?.[1]?.trim()).find((text) => text !== undefined);
1759
- const values = expected === undefined || received === undefined ? "" : ` (expected ${expected}, received ${received})`;
1760
- index = end - 1;
1761
- if (flaky.has(key(project, file, line, column, title)))
1762
- continue;
1763
- errors.push({ tool: "playwright", file: frame?.[1] ?? file ?? "", line: Number(frame?.[2] ?? line), column: Number(frame?.[3] ?? column), severity: "error", message: `${message}${values}`, test: `${project === undefined ? "" : `[${project}] `}${title}` });
1764
- }
1765
- return errors;
1766
- };
1767
- var collectVitest = (lines, used) => {
1768
- const errors = [];
1769
- for (let index = 0;index < lines.length; index++) {
1770
- const header = VITEST_FAIL.exec(lines[index] ?? "")?.[1];
1771
- if (header === undefined)
1772
- continue;
1773
- let end = index + 1;
1774
- while (end < lines.length && !(lines[end] ?? "").startsWith("\u23AF") && !VITEST_FAIL.test(lines[end] ?? ""))
1775
- end++;
1776
- for (let at = index;at < end; at++)
1777
- used.add(at);
1778
- const block = lines.slice(index + 1, end);
1779
- const frame = block.map((text) => VITEST_FRAME.exec(text)).find((match) => match !== null && !match[1]?.includes("node_modules"));
1780
- const suite = VITEST_SUITE.exec(header)?.[1];
1781
- const [file = "", ...names] = (suite ?? header).split(" > ");
1782
- errors.push({ tool: "vitest", file: frame?.[1] ?? file, line: Number(frame?.[2] ?? 0), column: Number(frame?.[3] ?? 0), severity: "error", message: block.find((text) => text.trim() !== "")?.trim() ?? "failed", ...suite === undefined && names.length > 0 ? { test: names.join(" > ") } : {} });
1783
- index = end - 1;
1784
- }
1785
- return errors;
1786
- };
1787
-
1788
- // src/php.ts
1789
- var PHP_NOISE = [
1790
- /^(?:PHPUnit \d|ParaTest v|Runtime: |Configuration: |Processes: |Random Seed: |Time: |Tests: |OK(?:,| \()|FAILURES!|ERRORS!|WARNINGS!|No tests executed|--$)/,
1791
- /^[.FEWRISD]+\s+\d+ \/ \d+ \(\d+%\)$/,
1792
- /^ -{3,}(?: -{3,})*\s*$/,
1793
- /^\s*\d+\/\d+ \[[=>\-\u2593\u2591 ]*\]\s+\d+%/,
1794
- /^(?:Note: Using configuration file|\s*\[(?:OK|ERROR)\] )/,
1795
- /^(?:Loaded config|PHP runtime:|PHP CS Fixer \d|Running analysis|Parallel runner|Using cache file|Paths from configuration|Rules from configuration|Setting PHP_CS_FIXER|Unable to determine minimum|If you need help|Found \d+ of \d+ files|Checked all files|Fixed \d+ of \d+ files|Legend:)/
1796
- ];
1797
- var MAX_DIFF_LINES = 6;
1798
- var PHPUNIT_HEADER = /^There (?:was|were) \d+ ([a-z ]+?)s?:$/i;
1799
- var PHPUNIT_TRIGGERED = /^\d+ tests? triggered \d+ [\w ]+?s?:$/;
1800
- var PHPUNIT_END = /^(?:--|FAILURES!|ERRORS!|WARNINGS!|OK\b.*|Tests: .*|No tests executed!)$/;
1801
- var PHPUNIT_ITEM = /^\d+\) (.*)$/;
1802
- var PHP_LOCATION = /^([\w./-]+\.php):(\d+)$/;
1803
- var PHPSTAN_FILE = /^ {2}Line {3}(\S.*)$/;
1804
- var PHPSTAN_GENERAL = /^ {2}Error\s*$/;
1805
- var PHPSTAN_MESSAGE = /^ {2}(\S.*)$/;
1806
- var PHPSTAN_ROW = /^ {2}(\d+|-) +(\S.*)$/;
1807
- var PHPSTAN_CONTINUATION = /^ {9}(\S.*)$/;
1808
- var PHPSTAN_IDENTIFIER = /^ {9}\uD83E\uDEAA\s+(\S+)\s*$/;
1809
- var PHPSTAN_TIP = /^ {9}\uD83D\uDCA1/;
1810
- var PHPSTAN_BORDER = /^ -{3,}(?: -{3,})*\s*$/;
1811
- var PHPSTAN_RAW = /^(\S.*?\.(?:php|phtml|twig|neon|inc)):(\d+):(\S.*)$/;
1812
- var PHPSTAN_JSON = /^\{.*"totals"/;
1813
- var CS_FIXER_FILE = /^\s+\d+\) (\S.*?\.php)(?: \((.+)\))?$/;
1814
- var CS_FIXER_DIFF_START = /^\s+-+ begin diff -+$/;
1815
- var CS_FIXER_DIFF_END = /^\s+-+ end diff -+$/;
1816
- function isHeader(line) {
1817
- return PHPUNIT_HEADER.test(line) || PHPUNIT_TRIGGERED.test(line);
1818
- }
1819
- function diffSummary(message) {
1820
- const start = message.findIndex((line) => line === "+++ Actual");
1821
- if (start === -1)
1822
- return "";
1823
- const changed = message.slice(start + 1).filter((line) => line.startsWith("-") || line.startsWith("+")).map((line) => `${line[0]} ${line.slice(1).trim()}`);
1824
- const shown = changed.slice(0, MAX_DIFF_LINES).join(" | ");
1825
- return changed.length === 0 ? "" : ` (${shown}${changed.length > MAX_DIFF_LINES ? " | ..." : ""})`;
1826
- }
1827
- function phpunitError(test, body) {
1828
- const at = body.findIndex((line) => PHP_LOCATION.test(line));
1829
- const location = PHP_LOCATION.exec(body[at] ?? "");
1830
- const message = body.slice(0, at === -1 ? body.length : at).map((line) => line.trimEnd());
1831
- const first = message.find((line) => line.trim() !== "") ?? "failed";
1832
- return { tool: "phpunit", file: location?.[1] ?? "", line: Number(location?.[2] ?? 0), column: 0, severity: "error", message: `${first}${diffSummary(message)}`, test };
1833
- }
1834
- var collectPhpunit = (lines, used) => {
1835
- const errors = [];
1836
- for (let index = 0;index < lines.length; index++) {
1837
- const line = lines[index] ?? "";
1838
- const kind = PHPUNIT_HEADER.exec(line)?.[1];
1839
- if (kind === undefined && !PHPUNIT_TRIGGERED.test(line))
1840
- continue;
1841
- let end = index + 1;
1842
- while (end < lines.length && !PHPUNIT_END.test(lines[end] ?? "") && !isHeader(lines[end] ?? ""))
1843
- end++;
1844
- for (let at = index;at < end; at++)
1845
- used.add(at);
1846
- if (kind === "error" || kind === "failure") {
1847
- const starts = Array.from({ length: end - index - 1 }, (_, at) => index + 1 + at).filter((at) => PHPUNIT_ITEM.test(lines[at] ?? ""));
1848
- for (const [position, start] of starts.entries())
1849
- errors.push(phpunitError(PHPUNIT_ITEM.exec(lines[start] ?? "")?.[1] ?? "", lines.slice(start + 1, starts[position + 1] ?? end)));
1850
- }
1851
- index = end - 1;
1852
- }
1853
- return errors;
1854
- };
1855
- function appendMessage(error, text) {
1856
- error.message = `${error.message} ${text}`;
1857
- }
1858
- function phpstanJson(text) {
1859
- try {
1860
- const report = JSON.parse(text);
1861
- const fromFiles = Object.entries(report.files ?? {}).flatMap(([file, entry]) => entry.messages.map((message) => ({ file, line: message.line ?? 0, message: message.message, ...message.identifier === undefined ? {} : { rule: message.identifier } })));
1862
- return [...fromFiles, ...(report.errors ?? []).map((message) => ({ file: "", line: 0, message }))];
1863
- } catch {
1864
- return;
1865
- }
1866
- }
1867
- var collectPhpstan = (lines, used) => {
1868
- const errors = [];
1869
- let file;
1870
- let current;
1871
- let rows = 0;
1872
- let tip = false;
1873
- let general = false;
1874
- for (const [index, text] of lines.entries()) {
1875
- const line = text.trimEnd();
1876
- if (used.has(index))
1877
- continue;
1878
- if (PHPSTAN_JSON.test(line)) {
1879
- const parsed = phpstanJson(line);
1880
- for (const entry of parsed ?? []) {
1881
- errors.push({ tool: "phpstan", file: entry.file, line: entry.line, column: 0, severity: "error", message: entry.message, ...entry.rule === undefined ? {} : { rule: entry.rule } });
1882
- }
1883
- if (parsed !== undefined)
1884
- used.add(index);
1885
- continue;
1886
- }
1887
- const raw = PHPSTAN_RAW.exec(line);
1888
- if (raw !== null) {
1889
- errors.push({ tool: "phpstan", file: raw[1] ?? "", line: Number(raw[2]), column: 0, severity: "error", message: raw[3] ?? "" });
1890
- used.add(index);
1891
- continue;
1892
- }
1893
- const header = PHPSTAN_FILE.exec(line);
1894
- if (header !== null || PHPSTAN_GENERAL.test(line)) {
1895
- file = header?.[1] ?? "";
1896
- general = header === null;
1897
- current = undefined;
1898
- rows = 0;
1899
- used.add(index);
1900
- continue;
1901
- }
1902
- if (file === undefined)
1903
- continue;
1904
- const message = PHPSTAN_MESSAGE.exec(line)?.[1];
1905
- if (general && message !== undefined && !PHPSTAN_BORDER.test(line)) {
1906
- errors.push({ tool: "phpstan", file: "", line: 0, column: 0, severity: "error", message });
1907
- rows++;
1908
- used.add(index);
1909
- continue;
1910
- }
1911
- const row = PHPSTAN_ROW.exec(line);
1912
- const identifier = PHPSTAN_IDENTIFIER.exec(line)?.[1];
1913
- const continuation = PHPSTAN_CONTINUATION.exec(line)?.[1];
1914
- if (PHPSTAN_BORDER.test(line) && rows > 0) {
1915
- file = undefined;
1916
- general = false;
1917
- current = undefined;
1918
- } else if (row !== null) {
1919
- current = { tool: "phpstan", file, line: row[1] === "-" ? 0 : Number(row[1]), column: 0, severity: "error", message: row[2] ?? "" };
1920
- errors.push(current);
1921
- rows++;
1922
- tip = false;
1923
- used.add(index);
1924
- } else if (identifier !== undefined && current !== undefined) {
1925
- current.rule = identifier;
1926
- used.add(index);
1927
- } else if (PHPSTAN_TIP.test(line)) {
1928
- tip = true;
1929
- used.add(index);
1930
- } else if (continuation !== undefined && current !== undefined) {
1931
- if (!tip)
1932
- appendMessage(current, continuation);
1933
- used.add(index);
1934
- }
1935
- }
1936
- return errors;
1937
- };
1938
- var collectCsFixer = (lines, used) => {
1939
- const errors = [];
1940
- for (let index = 0;index < lines.length; index++) {
1941
- const match = CS_FIXER_FILE.exec(lines[index] ?? "");
1942
- if (match === null)
1943
- continue;
1944
- errors.push({ tool: "php-cs-fixer", file: match[1] ?? "", line: 0, column: 0, ...match[2] === undefined ? {} : { rule: match[2] }, severity: "error", message: "style issues to fix" });
1945
- used.add(index);
1946
- if (!CS_FIXER_DIFF_START.test(lines[index + 1] ?? ""))
1947
- continue;
1948
- const end = lines.findIndex((text, at) => at > index && CS_FIXER_DIFF_END.test(text));
1949
- for (let at = index + 1;at <= (end === -1 ? index + 1 : end); at++)
1950
- used.add(at);
1951
- index = end === -1 ? index + 1 : end;
1952
- }
1953
- return errors;
1954
- };
1955
-
1956
- // src/output.ts
1957
- var BASH_ECHO = /^\$ /;
1958
- var DURATION2 = / \[[\d.]+m?s\]$/;
1959
- var BOUNDARY = /^(?:\((?:pass|fail|skip|todo)\) |\S+\.test\.[jt]sx?:$)/;
1960
- var BUN_TEST_SUMMARY = /^\s*\d+ (?:pass|fail|skip|todo)$|^Ran \d+ tests?/;
1961
- var BUN_CHECK_BLOCK = /<error file=[\s\S]*?<\/error>/g;
1962
- var BUN_CHECK_SOURCE = /<source>[\s\S]*?<\/source>\n?/g;
1963
- var BUN_CHECK_ATTRIBUTE = /(\w+)="([^"]*)"/g;
1964
- var BUN_CHECK_SUMMARY = /^Found \d+ errors?/;
1965
- var TSC_ERROR = /\berror TS\d+/;
1966
- var TSC_CONTINUATION = /^\s{2,}\S/;
1967
- var TSC_FRAME = /^\s*[~^|]/;
1968
- var TSC_SUMMARY = /^Found \d+ errors?/;
1969
- var ESLINT_PROBLEM = /^\s+\d+:\d+\s+(?:error|warning)\s/;
1970
- var ESLINT_SUMMARY = /^(?:\u2716 )?\d+ problems? \(/;
1971
- var PHPSTAN_TABLE = /^\s*-{3,} -{3,}/;
1972
- var PHPSTAN_NOISE = /^\s*\[OK\]/;
1973
- var PHP_FAILURES = /^(?:There w(?:as|ere) \d+ (?:failure|error|risky|warning)|\s+(?:FAIL|FAILED)\s+\S|In \S+\.php line \d+:$)/;
1974
- var VITEST_FAIL_LINE = /^ FAIL {2}\S/;
1975
- var PLAYWRIGHT_FAIL_LINE = /^ {2}1\) .+:\d+:\d+ \u203A .+ \u2500+$/;
1976
- var CS_FIXER_LINE = /^\s+\d+\) \S.*\.php(?: \(.+\))?$/;
1977
- var CS_FIXER_TOTAL = /^Found \d+ of \d+ files/;
1978
- var MAX_TESTS = 10;
1979
- var MAX_LINES = 100;
1980
- var TAIL = 30;
1981
- var bunTest = (lines) => {
1982
- const seen = new Set;
1983
- const blocks = [];
1984
- for (const [index, line] of lines.entries()) {
1985
- const name = line.replace(DURATION2, "");
1986
- if (!line.startsWith("(fail) ") || seen.has(name))
1987
- continue;
1988
- seen.add(name);
1989
- if (blocks.length < MAX_TESTS)
1990
- blocks.push(lines.slice(lines.findLastIndex((text, at) => at < index && BOUNDARY.test(text)) + 1, index + 1).join(`
1991
- `).trim());
1992
- }
1993
- if (blocks.length === 0)
1994
- return;
1995
- if (seen.size > MAX_TESTS)
1996
- blocks.push(`and ${seen.size - MAX_TESTS} more failed tests`);
1997
- return [...blocks.join(`
1998
-
1999
- `).split(`
2000
- `), "", ...lines.filter((line) => BUN_TEST_SUMMARY.test(line)).map((line) => line.trim())];
2001
- };
2002
- var bunCheck = (lines) => {
2003
- const text = lines.join(`
2004
- `);
2005
- const blocks = text.match(BUN_CHECK_BLOCK);
2006
- if (blocks === null)
2007
- return;
2008
- const errors = blocks.map((block) => {
2009
- const { file, line, column, code, message } = bunCheckFields(block);
2010
- return `${file}:${line}:${column} ${code}: ${message}`;
2011
- });
2012
- return [...errors, ...lines.filter((line) => BUN_CHECK_SUMMARY.test(line))];
2013
- };
2014
- function bunCheckFields(block) {
2015
- const attributes = Object.fromEntries([...block.slice(0, block.indexOf(`
2016
- `)).matchAll(BUN_CHECK_ATTRIBUTE)].map((match) => [match[1] ?? "", match[2] ?? ""]));
2017
- return {
2018
- file: attributes.file ?? "",
2019
- line: attributes.line ?? "",
2020
- column: attributes.column ?? "",
2021
- code: attributes.code ?? "",
2022
- message: block.replace(BUN_CHECK_SOURCE, "").split(`
2023
- `).slice(1, -1).join(`
2024
- `).trim()
2025
- };
2026
- }
2027
- var tsc = (lines) => {
2028
- const kept = [];
2029
- let inError = false;
2030
- for (const line of lines) {
2031
- if (TSC_ERROR.test(line)) {
2032
- inError = true;
2033
- kept.push(line);
2034
- } else if (TSC_SUMMARY.test(line)) {
2035
- inError = false;
2036
- kept.push(line);
2037
- } else if (inError && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
2038
- kept.push(line);
2039
- } else {
2040
- inError = false;
2041
- }
2042
- }
2043
- return kept.some((line) => TSC_ERROR.test(line)) ? kept : undefined;
2044
- };
2045
- var eslint = (lines) => {
2046
- const kept = [];
2047
- let file = "";
2048
- let shown = "";
2049
- for (const line of lines) {
2050
- if (ESLINT_PROBLEM.test(line)) {
2051
- if (file !== shown) {
2052
- kept.push(file);
2053
- shown = file;
2054
- }
2055
- kept.push(line);
2056
- } else if (ESLINT_SUMMARY.test(line)) {
2057
- kept.push(line);
2058
- } else if (line.trim() !== "") {
2059
- file = line;
2060
- }
2061
- }
2062
- return kept.some((line) => ESLINT_PROBLEM.test(line)) ? kept : undefined;
2063
- };
2064
- var phpstan = (lines) => {
2065
- const start = lines.findIndex((line) => PHPSTAN_TABLE.test(line));
2066
- return start === -1 ? undefined : lines.slice(start).filter((line) => !PHPSTAN_NOISE.test(line));
2067
- };
2068
- var php = (lines) => {
2069
- const start = lines.findIndex((line) => PHP_FAILURES.test(line));
2070
- return start === -1 ? undefined : lines.slice(start);
2071
- };
2072
- var vitest = (lines) => {
2073
- const start = lines.findIndex((line) => VITEST_FAIL_LINE.test(line));
2074
- return start === -1 ? undefined : lines.slice(start);
2075
- };
2076
- var playwright = (lines) => {
2077
- const start = lines.findIndex((line) => PLAYWRIGHT_FAIL_LINE.test(line));
2078
- return start === -1 ? undefined : lines.slice(start);
2079
- };
2080
- var phpCsFixer = (lines) => {
2081
- const files = lines.filter((line) => CS_FIXER_LINE.test(line) || CS_FIXER_TOTAL.test(line));
2082
- return files.some((line) => CS_FIXER_LINE.test(line)) ? files : undefined;
2083
- };
2084
- var PARSERS = [bunTest, bunCheck, tsc, eslint, vitest, playwright, phpCsFixer, phpstan, php];
2085
- function squeeze(lines) {
2086
- const out = [];
2087
- for (const line of lines.map((text) => text.trimEnd())) {
2088
- if (line !== "" || out.at(-1) !== "")
2089
- out.push(line);
2090
- }
2091
- while (out.at(-1) === "")
2092
- out.pop();
2093
- return out;
2094
- }
2095
- function failureExcerpt(output) {
2096
- const lines = stripAnsi(output).split(`
2097
- `);
2098
- if (BASH_ECHO.test(lines[0] ?? ""))
2099
- lines.shift();
2100
- const parsed = PARSERS.map((parser) => parser(lines)).find((result) => result !== undefined && result.some((line) => line.trim() !== ""));
2101
- const shown = squeeze(parsed ?? lines.slice(-TAIL));
2102
- return shown.length > MAX_LINES ? [...shown.slice(0, MAX_LINES), `... ${shown.length - MAX_LINES} more lines`].join(`
2103
- `) : shown.join(`
2104
- `);
2105
- }
2106
- var TSC_PLAIN_ERROR = /^(.+?)\((\d+),(\d+)\): error (TS\d+): (.*)$/;
2107
- var TSC_PRETTY_ERROR = /^(.+?):(\d+):(\d+) - error (TS\d+): (.*)$/;
2108
- var TSC_SOURCE_LINE = /^\d+ /;
2109
- var ESLINT_FIELDS = /^ +(\d+):(\d+) +(error|warning) +(\S.*)$/;
2110
- var ESLINT_RULE = / {2,}(\S+)$/;
2111
- var BUN_TEST_EXPECTED = /^Expected: (.*)$/;
2112
- var BUN_TEST_RECEIVED = /^Received: (.*)$/;
2113
- var BUN_TEST_FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
2114
- var BUN_TEST_FILE = /^\S+\.test\.[jt]sx?:$/;
2115
- var GO_ERROR = /^\s*(?:vet: )?(\S+\.go):(\d+):(?:(\d+):)? (.+)$/;
2116
- var GO_NOISE = /^# \S+(?: \[\S+\])?$/;
2117
- var ARROW = /^\s*--> (.+?):(\d+):(\d+)$/;
2118
- var CARGO_HEADER = /^(error|warning)(?:\[(\w+)\])?: (.*)$/;
2119
- var CARGO_NOISE = /^(?:\s+(?:Compiling|Finished|Checking|Fresh|Running|Blocking) |error: (?:aborting due to|could not compile)|warning: .* generated \d+ warnings?|Some errors have detailed explanations|For more information about (?:this|an) error|To learn more, run the command again)/;
2120
- var RUFF_CONCISE = /^(\S+\.pyi?):(\d+):(\d+): ([A-Z]+\d+) (?:\[\*\] )?(.*)$/;
2121
- var RUFF_HEADER = /^([A-Z]{1,5}\d{1,4}) (?:\[\*\] )?(.+)$/;
2122
- var RUFF_NOISE = /^(?:Found \d+ errors?\.|\[\*\] \d+ fixable|No fixes available|All checks passed|help: |\s*(?:\|\s*)?$)/;
2123
- var PYTEST_LOCATION = /^(\S+\.py):(\d+): (\S.*)$/;
2124
- var PYTEST_E_LINE = /^E {3}(.*)$/;
2125
- var PYTEST_BANNER = /^={3,} (.*?) ={3,}$/;
2126
- var PYTEST_FAILURES = new Set(["FAILURES", "ERRORS"]);
2127
- var PYTEST_SUMMARY_LINE = /^(?:FAILED|ERROR) \S/;
2128
- var PYTEST_FRAME = /^in \S/;
2129
- var PYTEST_SECTION = /^_{3,} .* _{3,}$/;
2130
- var PYTEST_EXCEPTION_END = /[\s:]/;
2131
- var PYTEST_NOISE = /^(?:platform |rootdir: |collected |plugins: |configfile: |cachedir: |\S+\.pyi? [.FEsxXR]+ +\[ *\d+%\]$|\S+\.py:\d+: $)/;
2132
- var NOISE = /^(?:bun test v|Errors {2}Files$|Ran \d+ tests?|note: |\s*\d+ expect\(\) calls|\s+\d+\s+\S+:\d+$|\s*\d+ errors? and \d+ warnings? potentially fixable)/;
2133
- function isNoise(line) {
2134
- return line.trim() === "" || [NOISE, BUN_TEST_SUMMARY, BUN_CHECK_SUMMARY, TSC_SUMMARY, ESLINT_SUMMARY, BOUNDARY, BASH_ECHO, GO_NOISE, CARGO_NOISE, RUFF_NOISE, PYTEST_NOISE, PYTEST_BANNER, ...PHP_NOISE, ...E2E_NOISE].some((pattern) => pattern.test(line));
2135
- }
2136
- var collectBunCheck = (lines, used) => {
2137
- const errors = [];
2138
- for (let index = 0;index < lines.length; index++) {
2139
- if (!(lines[index] ?? "").startsWith("<error file="))
2140
- continue;
2141
- const end = lines.findIndex((line, at) => at >= index && line === "</error>");
2142
- if (end === -1)
2143
- break;
2144
- const { file, line, column, code, message } = bunCheckFields(lines.slice(index, end + 1).join(`
2145
- `));
2146
- errors.push({ tool: "bun check", file, line: Number(line), column: Number(column), rule: code, severity: "error", message: message.replaceAll(/\s*\n\s*/g, " ") });
2147
- for (let at = index;at <= end; at++)
2148
- used.add(at);
2149
- index = end;
2150
- }
2151
- return errors;
2152
- };
2153
- var collectBunTest = (lines, used) => {
2154
- const errors = [];
2155
- const seen = new Set;
2156
- for (const [index, line] of lines.entries()) {
2157
- if (!line.startsWith("(fail) "))
2158
- continue;
2159
- used.add(index);
2160
- const test = line.slice("(fail) ".length).replace(DURATION2, "");
2161
- if (seen.has(test))
2162
- continue;
2163
- seen.add(test);
2164
- const start = lines.findLastIndex((text, at) => at < index && BOUNDARY.test(text)) + 1;
2165
- const block = lines.slice(start, index);
2166
- const failure = block.findIndex((text) => text.startsWith("error:"));
2167
- for (let at = start;at < index; at++)
2168
- used.add(at);
2169
- const frame = block.slice(Math.max(failure, 0)).map((text) => BUN_TEST_FRAME.exec(text)).find((match) => match !== null);
2170
- const header = lines.slice(0, index).findLast((text) => BUN_TEST_FILE.test(text));
2171
- const expected = block.map((text) => BUN_TEST_EXPECTED.exec(text)?.[1]).find((text) => text !== undefined);
2172
- const received = block.map((text) => BUN_TEST_RECEIVED.exec(text)?.[1]).find((text) => text !== undefined);
2173
- const reason = failure === -1 ? "failed" : (block[failure] ?? "").slice("error:".length).trim();
2174
- const values = expected === undefined || received === undefined ? "" : ` (expected ${expected}, received ${received})`;
2175
- errors.push({
2176
- tool: "bun test",
2177
- file: frame?.[1] ?? header?.replace(":", "") ?? "",
2178
- line: Number(frame?.[2] ?? 0),
2179
- column: Number(frame?.[3] ?? 0),
2180
- severity: "error",
2181
- message: `${reason}${values}`,
2182
- test
2183
- });
2184
- }
2185
- return errors;
2186
- };
2187
- var collectTsc = (lines, used) => {
2188
- const errors = [];
2189
- let current;
2190
- let pretty = false;
2191
- for (const [index, line] of lines.entries()) {
2192
- if (used.has(index))
2193
- continue;
2194
- const plain = TSC_PLAIN_ERROR.exec(line);
2195
- const match = plain ?? TSC_PRETTY_ERROR.exec(line);
2196
- if (match !== null) {
2197
- current = { tool: "tsc", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3]), rule: match[4], severity: "error", message: match[5] ?? "" };
2198
- pretty = plain === null;
2199
- errors.push(current);
2200
- used.add(index);
2201
- } else if (current !== undefined && TSC_CONTINUATION.test(line) && !TSC_FRAME.test(line)) {
2202
- current.message += ` ${line.trim()}`;
2203
- used.add(index);
2204
- } else if (current !== undefined && pretty && (TSC_FRAME.test(line) || TSC_SOURCE_LINE.test(line))) {
2205
- used.add(index);
2206
- } else if (!(pretty && line.trim() === "")) {
2207
- current = undefined;
2208
- }
2209
- }
2210
- return errors;
2211
- };
2212
- var collectEslint = (lines, used) => {
2213
- const errors = [];
2214
- let file;
2215
- for (const [index, line] of lines.entries()) {
2216
- if (used.has(index))
2217
- continue;
2218
- const match = ESLINT_PROBLEM.test(line) ? ESLINT_FIELDS.exec(line) : null;
2219
- if (match !== null && file !== undefined) {
2220
- const text = match[4] ?? "";
2221
- const rule = ESLINT_RULE.exec(text);
2222
- errors.push({ tool: "eslint", file: (lines[file] ?? "").trim(), line: Number(match[1]), column: Number(match[2]), rule: rule?.[1], severity: match[3] === "warning" ? "warning" : "error", message: rule === null ? text : text.slice(0, rule.index) });
2223
- used.add(index);
2224
- used.add(file);
2225
- } else if (!isNoise(line)) {
2226
- file = index;
2227
- }
2228
- }
2229
- return errors;
2230
- };
2231
- var collectGo = (lines, used) => {
2232
- const errors = [];
2233
- for (const [index, line] of lines.entries()) {
2234
- const match = used.has(index) ? null : GO_ERROR.exec(line);
2235
- if (match === null)
2236
- continue;
2237
- errors.push({ tool: "go", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3] ?? 0), severity: "error", message: match[4] ?? "" });
2238
- used.add(index);
2239
- }
2240
- return errors;
2241
- };
2242
- var collectArrowed = (lines, used) => {
2243
- const errors = [];
2244
- for (const [index, line] of lines.entries()) {
2245
- const arrow = used.has(index) || index === 0 ? null : ARROW.exec(line);
2246
- const header = arrow === null ? null : lines[index - 1] ?? "";
2247
- const cargo = header === null ? null : CARGO_HEADER.exec(header);
2248
- const ruff = header === null || cargo !== null ? null : RUFF_HEADER.exec(header);
2249
- if (arrow === null || cargo === null && ruff === null || used.has(index - 1))
2250
- continue;
2251
- const [, file, row, column] = arrow;
2252
- const fields = { file: file ?? "", line: Number(row), column: Number(column) };
2253
- errors.push(cargo === null ? { tool: "ruff", ...fields, rule: ruff?.[1], severity: "error", message: ruff?.[2] ?? "" } : { tool: "cargo", ...fields, rule: cargo[2], severity: cargo[1] === "warning" ? "warning" : "error", message: cargo[3] ?? "" });
2254
- used.add(index - 1);
2255
- used.add(index);
2256
- for (let frame = index + 1;frame < lines.length && (lines[frame] ?? "").trim() !== ""; frame++) {
2257
- if (CARGO_HEADER.test(lines[frame] ?? "") || RUFF_HEADER.test(lines[frame] ?? ""))
2258
- break;
2259
- used.add(frame);
2260
- }
2261
- }
2262
- return errors;
2263
- };
2264
- var collectRuff = (lines, used) => {
2265
- const errors = [];
2266
- for (const [index, line] of lines.entries()) {
2267
- const match = used.has(index) ? null : RUFF_CONCISE.exec(line);
2268
- if (match === null)
2269
- continue;
2270
- errors.push({ tool: "ruff", file: match[1] ?? "", line: Number(match[2]), column: Number(match[3]), rule: match[4], severity: "error", message: match[5] ?? "" });
2271
- used.add(index);
2272
- }
2273
- return errors;
2274
- };
2275
- var collectPytest = (lines, used) => {
2276
- const errors = [];
2277
- const title = (line) => PYTEST_BANNER.exec(line ?? "")?.[1];
2278
- const start = lines.findIndex((line) => PYTEST_FAILURES.has(title(line) ?? ""));
2279
- if (start === -1)
2280
- return errors;
2281
- const end = lines.findIndex((line, index) => index > start && title(line) !== undefined && !PYTEST_FAILURES.has(title(line) ?? ""));
2282
- const stop = end === -1 ? lines.length : end;
2283
- let message = [];
2284
- let frame;
2285
- for (let index = start;index < stop; index++) {
2286
- const line = lines[index] ?? "";
2287
- const failure = PYTEST_E_LINE.exec(line);
2288
- if (failure !== null) {
2289
- message.push((failure[1] ?? "").trim());
2290
- } else {
2291
- if (frame !== undefined && message.length > 0) {
2292
- errors.push({ tool: "pytest", ...frame, column: 0, severity: "error", message: message[0] ?? "" });
2293
- frame = undefined;
2294
- }
2295
- const location = PYTEST_LOCATION.exec(line);
2296
- if (location !== null && PYTEST_FRAME.test(location[3] ?? "")) {
2297
- frame = { file: location[1] ?? "", line: Number(location[2]) };
2298
- } else if (location !== null) {
2299
- const [exception = ""] = (location[3] ?? "").split(PYTEST_EXCEPTION_END);
2300
- const first = message[0] ?? "";
2301
- const text = first === "" || first.startsWith(exception) ? first || (location[3] ?? "") : `${location[3] ?? ""}: ${first}`;
2302
- errors.push({ tool: "pytest", file: location[1] ?? "", line: Number(location[2]), column: 0, severity: "error", message: text });
2303
- }
2304
- if (PYTEST_SECTION.test(line))
2305
- frame = undefined;
2306
- if (line.trim() !== "")
2307
- message = [];
2308
- }
2309
- used.add(index);
2310
- }
2311
- if (frame !== undefined && message.length > 0)
2312
- errors.push({ tool: "pytest", ...frame, column: 0, severity: "error", message: message[0] ?? "" });
2313
- for (let index = stop;index < lines.length; index++) {
2314
- if (PYTEST_SUMMARY_LINE.test(lines[index] ?? ""))
2315
- used.add(index);
2316
- }
2317
- return errors;
2318
- };
2319
- var COLLECTORS = [collectBunCheck, collectBunTest, collectVitest, collectPlaywright, collectPhpunit, collectPhpstan, collectCsFixer, collectPytest, collectArrowed, collectRuff, collectGo, collectTsc, collectEslint];
2320
- function parseErrors(output) {
2321
- const lines = stripAnsi(output).split(`
2322
- `);
2323
- if (BASH_ECHO.test(lines[0] ?? ""))
2324
- lines.shift();
2325
- const used = new Set;
2326
- const errors = COLLECTORS.flatMap((collect) => collect(lines, used));
2327
- const unrecognised = lines.filter((line, index) => !used.has(index) && !isNoise(line)).length;
2328
- return { errors, unrecognised };
2329
- }
2330
-
2331
- // src/run.ts
1897
+ import { basename as basename2, join as join11 } from "path";
1898
+ import process20 from "process";
2332
1899
  var LOG_MAX_AGE_MS = 3 * 24 * 60 * 60 * 1000;
2333
1900
  var RESULTS_FILE = "results.json";
2334
1901
  var runPrefix = (cwd) => `${basename2(cwd)}-${Bun.hash(cwd).toString(36)}-`;
2335
1902
  async function logDirectory(cwd) {
2336
1903
  const root = await privateLogDirectory("check");
2337
1904
  await sweepLogs(root, LOG_MAX_AGE_MS);
2338
- const path = join10(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process18.pid}`);
1905
+ const path = join11(root, `${runPrefix(cwd)}${Date.now().toString(36)}-${process20.pid}`);
2339
1906
  await mkdir2(path, { mode: 448 });
2340
1907
  return path;
2341
1908
  }
2342
- async function lastFailed(cwd) {
1909
+ async function lastResults(cwd) {
2343
1910
  const root = await privateLogDirectory("check");
2344
1911
  const prefix = runPrefix(cwd);
2345
1912
  let latest;
2346
1913
  for (const name of await readdir3(root)) {
2347
1914
  if (!name.startsWith(prefix))
2348
1915
  continue;
2349
- const file = join10(root, name, RESULTS_FILE);
1916
+ const file = join11(root, name, RESULTS_FILE);
2350
1917
  try {
2351
1918
  const { mtimeMs } = await stat3(file);
2352
1919
  if (latest === undefined || mtimeMs > latest.time)
@@ -2355,13 +1922,15 @@ async function lastFailed(cwd) {
2355
1922
  }
2356
1923
  if (latest === undefined)
2357
1924
  return;
2358
- const results = JSON.parse(await Bun.file(latest.file).text());
2359
- return results.filter((result) => !result.ok).map((result) => result.name);
1925
+ return JSON.parse(await Bun.file(latest.file).text());
1926
+ }
1927
+ async function lastFailed(cwd) {
1928
+ return (await lastResults(cwd))?.filter((result) => !result.ok).map((result) => result.name);
2360
1929
  }
2361
1930
  async function saveLog(output) {
2362
1931
  const root = await privateLogDirectory("errs");
2363
1932
  await sweepLogs(root);
2364
- const path = join10(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process18.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
1933
+ const path = join11(root, `${new Date().toISOString().replaceAll(/[:.]/g, "-")}-${process20.pid}-${crypto.randomUUID().slice(0, 8)}.log`);
2365
1934
  await writeFile(path, output, { mode: 384, flag: "wx" });
2366
1935
  return path;
2367
1936
  }
@@ -2369,7 +1938,7 @@ async function runStep(command, cwd, logFile, { env = {}, timeoutMs, held } = {}
2369
1938
  const started = Date.now();
2370
1939
  const { code, text, timedOut } = await runCommand(["sh", "-c", `${command} 2>&1`], {
2371
1940
  cwd,
2372
- env: { ...process18.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
1941
+ env: { ...process20.env, NO_COLOR: "1", FORCE_COLOR: "0", ...env },
2373
1942
  ...timeoutMs === undefined ? {} : { timeoutMs },
2374
1943
  ...held === undefined ? {} : { onStart: (child) => held.forward(child) }
2375
1944
  });
@@ -2385,8 +1954,8 @@ function outcomeJson(name, command, logFile, outcome, service) {
2385
1954
  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) } };
2386
1955
  }
2387
1956
  function printOutcome(name, width, command, logFile, outcome) {
2388
- const colors = paint(process18.stdout);
2389
- const path = role("path", process18.stdout);
1957
+ const colors = paint(process20.stdout);
1958
+ const path = role("path", process20.stdout);
2390
1959
  const took = colors.dim(formatDuration(outcome.ms));
2391
1960
  if (outcome.ok) {
2392
1961
  console.log(`${colors.bold(colors.green("ok "))} ${name.padEnd(width)} ${took} ${path(logFile)}`);
@@ -2417,7 +1986,7 @@ var RUFF_CONFIGS = ["ruff.toml", ".ruff.toml"];
2417
1986
  var RUFF_SECTION = /^\[tool\.ruff/m;
2418
1987
  var MAX_CHANGED = 30;
2419
1988
  async function replaceFile(path, content) {
2420
- const temporary = `${path}.${process19.pid}.tmp`;
1989
+ const temporary = `${path}.${process21.pid}.tmp`;
2421
1990
  await writeFile2(temporary, content, { mode: statSync2(path).mode & 511 });
2422
1991
  await rename(temporary, path);
2423
1992
  }
@@ -2436,9 +2005,9 @@ async function toolFixers(dir) {
2436
2005
  const ruff = await firstFile(dir, RUFF_CONFIGS) !== undefined || RUFF_SECTION.test(await read(dir, "pyproject.toml") ?? "");
2437
2006
  if (makefile !== undefined) {
2438
2007
  fixers.push({ name: "makefile", command: "declare every target .PHONY", source: makefile, write: async (cwd) => {
2439
- const path = join11(cwd, makefile);
2008
+ const path = join12(cwd, makefile);
2440
2009
  const current = await Bun.file(path).text();
2441
- const { content, targets } = declarePhony(current, (name) => existsSync5(join11(cwd, name)));
2010
+ const { content, targets } = declarePhony(current, (name) => existsSync5(join12(cwd, name)));
2442
2011
  if (content !== current)
2443
2012
  await replaceFile(path, content);
2444
2013
  return `.PHONY: ${targets.join(" ")}`;
@@ -2446,9 +2015,9 @@ async function toolFixers(dir) {
2446
2015
  }
2447
2016
  if (justfile !== undefined)
2448
2017
  fixers.push({ name: "justfile", command: `just --justfile ${justfile} --fmt`, source: justfile, requires: "just" });
2449
- if (await Bun.file(join11(dir, "go.mod")).exists())
2018
+ if (await Bun.file(join12(dir, "go.mod")).exists())
2450
2019
  fixers.push({ name: "go", command: "go fmt ./... && go mod tidy", source: "go.mod", requires: "go" });
2451
- if (await Bun.file(join11(dir, "Cargo.toml")).exists())
2020
+ if (await Bun.file(join12(dir, "Cargo.toml")).exists())
2452
2021
  fixers.push({ name: "rust", command: "cargo fmt", source: "Cargo.toml", requires: "cargo" });
2453
2022
  if (ruff)
2454
2023
  fixers.push({ name: "python", command: "ruff check --fix . && ruff format .", source: "ruff", requires: "ruff" });
@@ -2489,14 +2058,14 @@ function printChanged(changed) {
2489
2058
  if (changed.length > MAX_CHANGED)
2490
2059
  console.log(` and ${changed.length - MAX_CHANGED} more`);
2491
2060
  }
2492
- async function fix(args, cwd = process19.cwd()) {
2061
+ async function fix(args, cwd = process21.cwd()) {
2493
2062
  const parsed = parse(args, fixUsage, fixOptions, { exits: EXITS, 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"]] });
2494
2063
  return runFixers(parsed.values, cwd);
2495
2064
  }
2496
2065
  async function runFixers(values, cwd) {
2497
2066
  const parsed = { values };
2498
2067
  const settings = placeSettings(values);
2499
- if (process19.env[RUNNING] !== undefined)
2068
+ if (process21.env[RUNNING] !== undefined)
2500
2069
  fail("a fixer called fix again, which would recurse: give its script another command");
2501
2070
  const found = await fixers(cwd);
2502
2071
  if (found.length === 0)
@@ -2530,11 +2099,11 @@ async function runFixers(values, cwd) {
2530
2099
  break;
2531
2100
  if (missing(fixer)) {
2532
2101
  if (!json)
2533
- console.log(`${paint(process19.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2102
+ console.log(`${paint(process21.stdout).yellow("skip ")} ${fixer.name.padEnd(width)} ${fixer.requires} is not installed`);
2534
2103
  ran.push({ name: fixer.name, command: fixer.command, skipped: `${fixer.requires} is not installed` });
2535
2104
  continue;
2536
2105
  }
2537
- const logFile = join11(directory, `fix-${fixer.name.replaceAll(":", "-")}.log`);
2106
+ const logFile = join12(directory, `fix-${fixer.name.replaceAll(":", "-")}.log`);
2538
2107
  const placement = placements.get(fixer);
2539
2108
  const down = placement === undefined ? undefined : await stack.problem(placement);
2540
2109
  const outcome = down === undefined ? await runFixer(fixer, placement, cwd, logFile, runSettings) : await refusedStep(down, logFile);
@@ -2563,4 +2132,4 @@ async function runFixers(values, cwd) {
2563
2132
  }
2564
2133
 
2565
2134
  // src/fix-cli.ts
2566
- process20.exitCode = await runMain({ name: "fix", version, run: async (args) => fix(args) });
2135
+ process22.exitCode = await runMain({ name: "fix", version, run: async (args) => fix(args) });