@hublo/sentinel 1.7.0-alpha.22 → 1.7.0-alpha.24

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.
@@ -13,7 +13,7 @@ import {
13
13
  presetNotInstalledYet,
14
14
  registerAdapters,
15
15
  resolve
16
- } from "../chunk-VSUHHETH.js";
16
+ } from "../chunk-EQQMY6NH.js";
17
17
  import {
18
18
  resolveContext,
19
19
  separateToolArgs
@@ -4490,7 +4490,7 @@ function registerLint() {
4490
4490
  // src/roles/sql/adapters/squawk/squawk.adapter.ts
4491
4491
  import { spawnSync as spawnSync8 } from "node:child_process";
4492
4492
  import { existsSync as existsSync18, readFileSync as readFileSync18 } from "node:fs";
4493
- import { join as join30 } from "node:path";
4493
+ import { join as join31 } from "node:path";
4494
4494
 
4495
4495
  // src/core/branch-changes.ts
4496
4496
  import { spawnSync as spawnSync5 } from "node:child_process";
@@ -4582,13 +4582,15 @@ var UNSAFE_RULE = "unsafe-sql-pasted-value";
4582
4582
  var RAW_FRAGMENT_RULE = "unsafe-sql-raw-fragment";
4583
4583
  var APPLIED_RULE = "applied-migration-changed";
4584
4584
  var ENUM_VALUE_RULE = "enum-value-used-before-commit";
4585
+ var FOLDER_RULE = "migration-folder-without-sql";
4585
4586
 
4586
4587
  // src/roles/sql/configs/rule-levels.ts
4587
4588
  var SENTINEL_RULES = [
4588
4589
  UNSAFE_RULE,
4589
4590
  RAW_FRAGMENT_RULE,
4590
4591
  APPLIED_RULE,
4591
- ENUM_VALUE_RULE
4592
+ ENUM_VALUE_RULE,
4593
+ FOLDER_RULE
4592
4594
  ];
4593
4595
  var SYNTAX_ERROR = "syntax-error";
4594
4596
  var NOT_SQUAWK_CONFIG = [...SENTINEL_RULES, SYNTAX_ERROR];
@@ -5052,6 +5054,48 @@ function historyFindings(changes, baseRef2) {
5052
5054
  });
5053
5055
  }
5054
5056
 
5057
+ // src/roles/sql/migration-folders.ts
5058
+ import { readdirSync as readdirSync4 } from "node:fs";
5059
+ import { join as join24 } from "node:path";
5060
+ function foldersWithoutSql(cwd, roots) {
5061
+ const out = [];
5062
+ for (const root of roots) {
5063
+ for (const entry of entriesOf(join24(cwd, root))) {
5064
+ if (!entry.isDirectory()) continue;
5065
+ const folder = root === "." || root === "" ? entry.name : `${root}/${entry.name}`;
5066
+ const holds = entriesOf(join24(cwd, folder)).some(
5067
+ (inner) => inner.name === "migration.sql" && inner.isFile()
5068
+ );
5069
+ if (!holds) out.push(folder);
5070
+ }
5071
+ }
5072
+ return out.sort();
5073
+ }
5074
+ function entriesOf(dir) {
5075
+ try {
5076
+ return readdirSync4(dir, { withFileTypes: true });
5077
+ } catch {
5078
+ return [];
5079
+ }
5080
+ }
5081
+ function folderFindings(folders) {
5082
+ return folders.map((folder) => {
5083
+ const file = `${folder}/migration.sql`;
5084
+ return {
5085
+ file,
5086
+ line: 1,
5087
+ column: 1,
5088
+ endLine: 1,
5089
+ endColumn: 1,
5090
+ rule: FOLDER_RULE,
5091
+ squawkLevel: "Warning",
5092
+ message: `\`${folder}\` holds no \`migration.sql\`: Prisma reads every folder of its migrations directory as a migration, so every deploy stops at this one with P3015 "Could not find the migration file", on a new database as on one that ran all the others, and no migration after it is applied`,
5093
+ note: null,
5094
+ help: "give the folder its `migration.sql`, or move what it holds out of the migrations directory (a migration to undo goes in a new migration, never in an `archive/` there)"
5095
+ };
5096
+ });
5097
+ }
5098
+
5055
5099
  // src/roles/sql/adapters/squawk/rule-notes.ts
5056
5100
  var usesConcurrently = (statement) => /\bconcurrently\b/i.test(statement);
5057
5101
  var toVarcharOrText = (sql) => /\btype\s+(?:varchar|character\s+varying|text)\b/i.test(sql);
@@ -5175,12 +5219,12 @@ var placeOf = (finding3) => `${finding3.file}:${finding3.line}:${finding3.column
5175
5219
 
5176
5220
  // src/roles/sql/report/outputs.ts
5177
5221
  import { existsSync as existsSync16, mkdirSync as mkdirSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
5178
- import { join as join25 } from "node:path";
5222
+ import { join as join26 } from "node:path";
5179
5223
 
5180
5224
  // src/roles/static-analysis/maintainability/size-rules.ts
5181
5225
  import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
5182
5226
  import { tmpdir } from "node:os";
5183
- import { join as join24 } from "node:path";
5227
+ import { join as join25 } from "node:path";
5184
5228
  var GAUGE_THRESHOLDS = {
5185
5229
  // McCabe 1976 says 10, our p90 says 11. The only indicator where two independent candidates agree
5186
5230
  // within one unit, and 94.8% of our functions already sit in the 1-10 band SEI calls low risk.
@@ -5209,7 +5253,7 @@ var GAUGE_THRESHOLDS = {
5209
5253
  "cognitive-complexity": 7
5210
5254
  };
5211
5255
  var COGNITIVE = "cognitive-complexity";
5212
- var cognitivePlugin = () => join24(ownPackageDir(), "plugins", "sonar-cognitive.js");
5256
+ var cognitivePlugin = () => join25(ownPackageDir(), "plugins", "sonar-cognitive.js");
5213
5257
  var CATEGORIES = [
5214
5258
  "correctness",
5215
5259
  "suspicious",
@@ -5241,8 +5285,8 @@ function sizeRulesConfig() {
5241
5285
  };
5242
5286
  }
5243
5287
  function sizeRulesRun(paths2, ignore) {
5244
- const dir = mkdtempSync(join24(tmpdir(), "sentinel-size-"));
5245
- const configPath = join24(dir, "oxlintrc.json");
5288
+ const dir = mkdtempSync(join25(tmpdir(), "sentinel-size-"));
5289
+ const configPath = join25(dir, "oxlintrc.json");
5246
5290
  writeFileSync5(configPath, `${JSON.stringify(sizeRulesConfig(), null, 2)}
5247
5291
  `, "utf8");
5248
5292
  return {
@@ -7174,12 +7218,12 @@ var writesFiles = (shapes) => shapes.some((shape) => shape !== "console");
7174
7218
  function writeOutputs(cwd, report, shapes, now = /* @__PURE__ */ new Date()) {
7175
7219
  if (!writesFiles(shapes)) return [];
7176
7220
  removeOutputs(cwd, shapes);
7177
- mkdirSync2(join25(cwd, REPORT_DIR), { recursive: true });
7221
+ mkdirSync2(join26(cwd, REPORT_DIR), { recursive: true });
7178
7222
  const written = [];
7179
7223
  for (const shape of shapes) {
7180
7224
  if (shape === "console") continue;
7181
- const path2 = join25(REPORT_DIR, SHAPE_FILE2[shape]);
7182
- writeFileSync6(join25(cwd, path2), render(report, shape, now));
7225
+ const path2 = join26(REPORT_DIR, SHAPE_FILE2[shape]);
7226
+ writeFileSync6(join26(cwd, path2), render(report, shape, now));
7183
7227
  written.push(path2);
7184
7228
  }
7185
7229
  return written;
@@ -7187,7 +7231,7 @@ function writeOutputs(cwd, report, shapes, now = /* @__PURE__ */ new Date()) {
7187
7231
  function removeOutputs(cwd, keeping = []) {
7188
7232
  for (const [shape, name] of Object.entries(SHAPE_FILE2)) {
7189
7233
  if (keeping.includes(shape)) continue;
7190
- const path2 = join25(cwd, REPORT_DIR, name);
7234
+ const path2 = join26(cwd, REPORT_DIR, name);
7191
7235
  if (existsSync16(path2)) unlinkSync2(path2);
7192
7236
  }
7193
7237
  }
@@ -7199,7 +7243,7 @@ function render(report, shape, now) {
7199
7243
 
7200
7244
  // src/roles/sql/sources.ts
7201
7245
  import { existsSync as existsSync17, readFileSync as readFileSync16, realpathSync as realpathSync2 } from "node:fs";
7202
- import { dirname as dirname3, join as join26, relative as relative4, resolve as resolve3, sep } from "node:path";
7246
+ import { dirname as dirname3, join as join27, relative as relative4, resolve as resolve3, sep } from "node:path";
7203
7247
  import { globSync } from "tinyglobby";
7204
7248
  var WALK = { onlyFiles: true, dot: false, followSymbolicLinks: false };
7205
7249
  var ADOPTION_FILE = "sql.config.mjs";
@@ -7224,6 +7268,15 @@ function migrationFiles(cwd, settings, nested) {
7224
7268
  ]
7225
7269
  }).sort();
7226
7270
  }
7271
+ function migrationRoots(cwd, settings, migrations, nested) {
7272
+ const locks = globSync(["**/migration_lock.toml"], {
7273
+ ...WALK,
7274
+ cwd,
7275
+ ignore: ["**/node_modules/**", ...settings.ignore, ...adoptedInnerModules(cwd, nested)]
7276
+ }).map((file) => dirname3(file));
7277
+ const holding = migrations.map((file) => dirname3(dirname3(file)));
7278
+ return [.../* @__PURE__ */ new Set([...locks, ...holding])].sort();
7279
+ }
7227
7280
  function codeFiles(cwd, settings, nested) {
7228
7281
  return globSync(["**/*.{ts,mts,cts}"], {
7229
7282
  ...WALK,
@@ -7252,7 +7305,7 @@ var POSTGRES_IMPORT = /from\s*['"]postgres['"]|require\(\s*['"]postgres['"]\s*\)
7252
7305
  var POSTGRES_CALL = /\.unsafe\s*\(/;
7253
7306
  function callsUnsafe(cwd, file) {
7254
7307
  try {
7255
- const text = readFileSync16(join26(cwd, file), "utf8");
7308
+ const text = readFileSync16(join27(cwd, file), "utf8");
7256
7309
  return UNSAFE_CALL.test(text) || PRISMA_IMPORT.test(text) && (RAW_CALL.test(text) || callsPrismaJoin(text)) || PG_IMPORT.test(text) && PG_CALL.test(text) || POSTGRES_IMPORT.test(text) && POSTGRES_CALL.test(text);
7257
7310
  } catch {
7258
7311
  return false;
@@ -7275,7 +7328,7 @@ function rawSqlInParent(cwd) {
7275
7328
  const stop = findWorkspaceRoot(here) ?? findRepositoryRoot(here);
7276
7329
  if (stop === void 0 || dirname3(here) === here) return void 0;
7277
7330
  const parent = findModuleRoot(dirname3(here), stop);
7278
- if (parent === void 0 || existsSync17(join26(parent, ADOPTION_FILE))) return void 0;
7331
+ if (parent === void 0 || existsSync17(join27(parent, ADOPTION_FILE))) return void 0;
7279
7332
  const mine = `${relative4(parent, here).split(sep).join("/")}/`;
7280
7333
  const files = filesWithUnsafeCalls(
7281
7334
  parent,
@@ -7287,14 +7340,14 @@ function rawSqlInParent(cwd) {
7287
7340
  function migrationsInNested(cwd, settings = defaults, nested = adoptedInnerDirs(cwd)) {
7288
7341
  const out = [];
7289
7342
  for (const dir of nested) {
7290
- const count = migrationFiles(join26(cwd, dir), defaults).length;
7343
+ const count = migrationFiles(join27(cwd, dir), defaults).length;
7291
7344
  if (count > 0) out.push({ dir, count, adopted: true });
7292
7345
  }
7293
7346
  const root = resolve3(cwd);
7294
7347
  const owner = /* @__PURE__ */ new Map();
7295
7348
  const counts2 = /* @__PURE__ */ new Map();
7296
7349
  for (const file of migrationFiles(cwd, settings, nested)) {
7297
- const folder = dirname3(join26(root, file));
7350
+ const folder = dirname3(join27(root, file));
7298
7351
  if (!owner.has(folder)) {
7299
7352
  const project = findModuleRoot(folder, root);
7300
7353
  owner.set(
@@ -7310,13 +7363,13 @@ function migrationsInNested(cwd, settings = defaults, nested = adoptedInnerDirs(
7310
7363
  }
7311
7364
 
7312
7365
  // src/roles/sql/unsafe/unsafe-calls.ts
7313
- import { dirname as dirname4, join as join27 } from "node:path";
7366
+ import { dirname as dirname4, join as join28 } from "node:path";
7314
7367
  import { parseSync as parseSync3 } from "oxc-parser";
7315
7368
  var UNSAFE_METHODS = ["$queryRawUnsafe", "$executeRawUnsafe"];
7316
7369
  var BOTH = { methods: true, raw: true };
7317
7370
  var MAX_DEPTH = 12;
7318
7371
  function checkUnsafeCalls(cwd, file, text, readFile, checking = BOTH) {
7319
- const parsed = parse(join27(cwd, file), text);
7372
+ const parsed = parse(join28(cwd, file), text);
7320
7373
  if (!parsed.ok) return parsed;
7321
7374
  const findings = [];
7322
7375
  let calls = 0;
@@ -7448,7 +7501,7 @@ var FileCache = class {
7448
7501
  }
7449
7502
  /** The file a relative specifier names from `from`, or null when it cannot be read or parsed. */
7450
7503
  resolve(from, specifier) {
7451
- for (const candidate of candidatesFor(join27(dirname4(from), specifier))) {
7504
+ for (const candidate of candidatesFor(join28(dirname4(from), specifier))) {
7452
7505
  if (this.parsed.has(candidate)) return this.parsed.get(candidate) ?? null;
7453
7506
  const text = this.readFile(candidate);
7454
7507
  if (text === void 0) continue;
@@ -7469,7 +7522,7 @@ function candidatesFor(base) {
7469
7522
  ...typescript === base ? [] : [typescript],
7470
7523
  base,
7471
7524
  ...RESOLVABLE_EXTENSIONS.map((extension) => `${base}${extension}`),
7472
- ...RESOLVABLE_EXTENSIONS.map((extension) => join27(base, `index${extension}`))
7525
+ ...RESOLVABLE_EXTENSIONS.map((extension) => join28(base, `index${extension}`))
7473
7526
  ];
7474
7527
  }
7475
7528
  var KNOWN_METHODS = /* @__PURE__ */ new Set([...UNSAFE_METHODS, "raw", "join", "query", "unsafe"]);
@@ -7759,11 +7812,11 @@ function exportedConst(file, name) {
7759
7812
  return void 0;
7760
7813
  }
7761
7814
  function isPlaceholderList(call, context2) {
7762
- const join43 = unwrap(call.callee);
7763
- if (!MEMBER_TYPES.has(join43.type) || join43.property.name !== "join") return false;
7815
+ const join44 = unwrap(call.callee);
7816
+ if (!MEMBER_TYPES.has(join44.type) || join44.property.name !== "join") return false;
7764
7817
  const separator = call.arguments[0];
7765
7818
  if (separator !== void 0 && !isSafe(separator, context2)) return false;
7766
- const map = unwrap(join43.object);
7819
+ const map = unwrap(join44.object);
7767
7820
  if (map.type !== "CallExpression") return false;
7768
7821
  const mapCallee = unwrap(map.callee);
7769
7822
  if (!MEMBER_TYPES.has(mapCallee.type) || mapCallee.property.name !== "map")
@@ -7832,7 +7885,7 @@ function readOne(cwd, file, text, readFile, checking) {
7832
7885
  function checkUnsafeFiles(cwd, files, readFile, checking = BOTH) {
7833
7886
  const run = { calls: 0, rawCalls: 0, findings: [], unparsed: [] };
7834
7887
  for (const file of files) {
7835
- const text = readFile(join27(cwd, file));
7888
+ const text = readFile(join28(cwd, file));
7836
7889
  if (text === void 0) {
7837
7890
  run.unparsed.push({ file, reason: "could not be read, so its calls are not checked" });
7838
7891
  continue;
@@ -7861,7 +7914,7 @@ function squawkNotFound(cwd) {
7861
7914
  import { spawnSync as spawnSync7 } from "node:child_process";
7862
7915
  import { mkdtempSync as mkdtempSync3, readFileSync as readFileSync17, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "node:fs";
7863
7916
  import { tmpdir as tmpdir3 } from "node:os";
7864
- import { join as join29 } from "node:path";
7917
+ import { join as join30 } from "node:path";
7865
7918
 
7866
7919
  // src/roles/sql/adapters/squawk/read-output.ts
7867
7920
  function readSquawkOutput(stdout, stderr) {
@@ -7919,7 +7972,7 @@ function toFinding(entry) {
7919
7972
  // src/roles/sql/adapters/squawk/squawk-config.ts
7920
7973
  import { mkdtempSync as mkdtempSync2, rmSync as rmSync4, writeFileSync as writeFileSync7 } from "node:fs";
7921
7974
  import { tmpdir as tmpdir2 } from "node:os";
7922
- import { join as join28 } from "node:path";
7975
+ import { join as join29 } from "node:path";
7923
7976
  function squawkToml(settings) {
7924
7977
  const squawks = (rule) => !NOT_SQUAWK_CONFIG.includes(rule);
7925
7978
  const off = rulesOff(settings.rules ?? {}).filter(squawks);
@@ -7933,9 +7986,9 @@ function squawkToml(settings) {
7933
7986
  ].join("\n");
7934
7987
  }
7935
7988
  function withSquawkConfig(settings, use) {
7936
- const dir = mkdtempSync2(join28(tmpdir2(), "sentinel-squawk-"));
7989
+ const dir = mkdtempSync2(join29(tmpdir2(), "sentinel-squawk-"));
7937
7990
  try {
7938
- const configPath = join28(dir, "squawk.toml");
7991
+ const configPath = join29(dir, "squawk.toml");
7939
7992
  writeFileSync7(configPath, squawkToml(settings));
7940
7993
  return use(configPath);
7941
7994
  } finally {
@@ -8025,9 +8078,9 @@ function quietTimeoutFiles(invocation, readable, statements, wrapped) {
8025
8078
  return new Set([...texts.keys()].filter((file) => !onExisting.has(file)));
8026
8079
  }
8027
8080
  function indexesOnExistingTables(invocation, files) {
8028
- const dir = mkdtempSync3(join29(tmpdir3(), "sentinel-squawk-"));
8081
+ const dir = mkdtempSync3(join30(tmpdir3(), "sentinel-squawk-"));
8029
8082
  try {
8030
- const configPath = join29(dir, "squawk.toml");
8083
+ const configPath = join30(dir, "squawk.toml");
8031
8084
  writeFileSync8(configPath, DEFAULT_SQUAWK_TOML);
8032
8085
  const found = /* @__PURE__ */ new Set();
8033
8086
  for (const batch of batches(files)) {
@@ -8043,7 +8096,7 @@ function indexesOnExistingTables(invocation, files) {
8043
8096
  }
8044
8097
  function readText(cwd, file) {
8045
8098
  try {
8046
- return readFileSync17(join29(cwd, file), "utf8");
8099
+ return readFileSync17(join30(cwd, file), "utf8");
8047
8100
  } catch {
8048
8101
  return void 0;
8049
8102
  }
@@ -8125,7 +8178,7 @@ function openable(cwd, files) {
8125
8178
  const utf8 = new TextDecoder("utf-8", { fatal: true });
8126
8179
  for (const file of files) {
8127
8180
  try {
8128
- utf8.decode(readFileSync17(join29(cwd, file)));
8181
+ utf8.decode(readFileSync17(join30(cwd, file)));
8129
8182
  readable.push(file);
8130
8183
  } catch (error) {
8131
8184
  unread.push({ file, reason: unreadReason(error) });
@@ -8287,7 +8340,7 @@ var SquawkAdapter = class extends BaseAdapter {
8287
8340
  skipped: `no migration (${defaults.migrations.include.join(", ")}) and no raw SQL call in this module: nothing for the ${TARGET} role to read.`
8288
8341
  };
8289
8342
  }
8290
- const hasConfig = existsSync18(join30(context2.cwd, SQL_CONFIG_FILE));
8343
+ const hasConfig = existsSync18(join31(context2.cwd, SQL_CONFIG_FILE));
8291
8344
  const declared = moduleScripts(context2.cwd);
8292
8345
  const missingScripts = Object.keys(scripts()).filter((name) => !(name in declared));
8293
8346
  return {
@@ -8402,6 +8455,7 @@ var SquawkAdapter = class extends BaseAdapter {
8402
8455
  const findings = withNotes(
8403
8456
  [
8404
8457
  ...history.findings,
8458
+ ...missingFiles(ctx.cwd, config, reading, history.findings),
8405
8459
  ...run.findings,
8406
8460
  ...enumFindings(ctx.cwd, config, read, run),
8407
8461
  ...unsafe.findings
@@ -8427,12 +8481,13 @@ var SquawkAdapter = class extends BaseAdapter {
8427
8481
  if (mode.speaking) {
8428
8482
  for (const line of describeRun(outcome, reading, config, selection.quietNote)) this.say(line);
8429
8483
  for (const dir of reading.nested) {
8430
- const count = migrationFiles(join30(ctx.cwd, dir), defaults).length;
8484
+ const count = migrationFiles(join31(ctx.cwd, dir), defaults).length;
8431
8485
  if (count > 0)
8432
8486
  this.say(
8433
8487
  `the ${count} migration(s) under ${dir} are reported by that project, which adopted the role itself.`
8434
8488
  );
8435
8489
  }
8490
+ for (const line of nestedNote(ctx.cwd, config, reading.nested, false)) this.say(line);
8436
8491
  const written = writesFiles(shapes) ? writeOutputs(
8437
8492
  ctx.cwd,
8438
8493
  reportOf(ctx, config, reading, read, unsafeOff ? [] : code, outcome, findings),
@@ -8496,7 +8551,7 @@ var SquawkAdapter = class extends BaseAdapter {
8496
8551
  const expected = Object.keys(scripts());
8497
8552
  const missing = expected.filter((name) => !(name in declared));
8498
8553
  const adopted = missing.length < expected.length;
8499
- const hasConfig = existsSync18(join30(ctx.cwd, SQL_CONFIG_FILE));
8554
+ const hasConfig = existsSync18(join31(ctx.cwd, SQL_CONFIG_FILE));
8500
8555
  return {
8501
8556
  adopted,
8502
8557
  preset: adopted ? ctx.preset : null,
@@ -8528,10 +8583,10 @@ function parentNote(cwd) {
8528
8583
  `the module holding this one (${parent.dir}) makes raw SQL calls in ${parent.files.length} file(s) this module does not read: ${shown}${more}. Adopt it too, from its directory: npx --yes @hublo/sentinel@${readOwnPackage().version} --init --${TARGET}`
8529
8584
  ];
8530
8585
  }
8531
- function nestedNote(cwd) {
8586
+ function nestedNote(cwd, settings = defaults, nested, withAdopted = true) {
8532
8587
  const version = readOwnPackage().version;
8533
- return migrationsInNested(cwd).map(
8534
- (nested) => nested.adopted ? `the project at ${nested.dir} adopted the role itself: its ${nested.count} migration(s) are reported there, not here.` : `${nested.count} migration(s) of this module belong to the project at ${nested.dir}, which has not adopted the role: this module reads them. Once that project adopts it, they are reported there instead, from its directory: npx --yes @hublo/sentinel@${version} --init --${TARGET}`
8588
+ return migrationsInNested(cwd, settings, nested).filter((project) => withAdopted || !project.adopted).map(
8589
+ (nested2) => nested2.adopted ? `the project at ${nested2.dir} adopted the role itself: its ${nested2.count} migration(s) are reported there, not here.` : `${nested2.count} migration(s) of this module belong to the project at ${nested2.dir}, which has not adopted the role: this module reads them. Once that project adopts it, they are reported there instead, from its directory: npx --yes @hublo/sentinel@${version} --init --${TARGET}`
8535
8590
  );
8536
8591
  }
8537
8592
  function formatterReason(pass) {
@@ -8573,6 +8628,14 @@ function appliedChanges(cwd, config, base, nested) {
8573
8628
  if (!reading.ok) return reading;
8574
8629
  return { ok: true, findings: historyFindings(reading.changes, base.ref) };
8575
8630
  }
8631
+ function missingFiles(cwd, config, reading, said) {
8632
+ if (config.rules[FOLDER_RULE] === "off") return [];
8633
+ const already = new Set(said.map((finding3) => finding3.file));
8634
+ const roots = migrationRoots(cwd, config, reading.migrations, reading.nested);
8635
+ return folderFindings(
8636
+ foldersWithoutSql(cwd, roots).filter((folder) => !already.has(`${folder}/migration.sql`))
8637
+ );
8638
+ }
8576
8639
  function enumFindings(cwd, config, files, run) {
8577
8640
  if (config.rules[ENUM_VALUE_RULE] === "off") return [];
8578
8641
  return files.flatMap((file) => {
@@ -8659,7 +8722,7 @@ function readAbsolute(path2) {
8659
8722
  }
8660
8723
  function readText2(cwd, file) {
8661
8724
  try {
8662
- return readFileSync18(join30(cwd, file), "utf8");
8725
+ return readFileSync18(join31(cwd, file), "utf8");
8663
8726
  } catch {
8664
8727
  return void 0;
8665
8728
  }
@@ -8705,7 +8768,7 @@ function registerSql() {
8705
8768
  // src/roles/static-analysis/adapters/jscpd/jscpd.adapter.ts
8706
8769
  import { spawnSync as spawnSync10 } from "node:child_process";
8707
8770
  import { existsSync as existsSync24, mkdirSync as mkdirSync4, readFileSync as readFileSync24, unlinkSync as unlinkSync3, writeFileSync as writeFileSync11 } from "node:fs";
8708
- import { join as join39 } from "node:path";
8771
+ import { join as join40 } from "node:path";
8709
8772
  import { globSync as globSync6 } from "tinyglobby";
8710
8773
 
8711
8774
  // src/roles/static-analysis/bundle/budgets.ts
@@ -8735,20 +8798,20 @@ function bandFor(valueKb, referenceKb) {
8735
8798
 
8736
8799
  // src/roles/static-analysis/bundle/scan.ts
8737
8800
  import { existsSync as existsSync20, readFileSync as readFileSync20 } from "node:fs";
8738
- import { basename as basename2, join as join32 } from "node:path";
8801
+ import { basename as basename2, join as join33 } from "node:path";
8739
8802
  import { pathToFileURL as pathToFileURL3 } from "node:url";
8740
8803
  import { gzipSync } from "node:zlib";
8741
8804
  import { globSync as globSync3 } from "tinyglobby";
8742
8805
 
8743
8806
  // src/roles/static-analysis/bundle/find-build.ts
8744
8807
  import { existsSync as existsSync19, readFileSync as readFileSync19, statSync as statSync5 } from "node:fs";
8745
- import { join as join31 } from "node:path";
8808
+ import { join as join32 } from "node:path";
8746
8809
  import { globSync as globSync2 } from "tinyglobby";
8747
8810
  var MANIFEST_GLOB = "server/_tanstack-start-manifest*.mjs";
8748
8811
  function candidateDirs(cwd) {
8749
8812
  const declared = readProjectPackageJson(cwd).nx?.targets?.build?.["outputs"];
8750
- const fromDeclaration = Array.isArray(declared) ? declared.filter((token) => typeof token === "string").map((token) => join31(cwd, token.replace(/^\{projectRoot\}\//, ""))) : [];
8751
- return [...fromDeclaration, join31(cwd, ".output"), join31(cwd, "dist"), join31(cwd, "build")];
8813
+ const fromDeclaration = Array.isArray(declared) ? declared.filter((token) => typeof token === "string").map((token) => join32(cwd, token.replace(/^\{projectRoot\}\//, ""))) : [];
8814
+ return [...fromDeclaration, join32(cwd, ".output"), join32(cwd, "dist"), join32(cwd, "build")];
8752
8815
  }
8753
8816
  function findBuildOutput(cwd) {
8754
8817
  const lookedIn = [];
@@ -8758,7 +8821,7 @@ function findBuildOutput(cwd) {
8758
8821
  const found = globSync2(MANIFEST_GLOB, { cwd: dir, absolute: true, dot: false });
8759
8822
  if (found.length === 0) continue;
8760
8823
  const manifestPath = found[0];
8761
- const publicDir = join31(dir, "public");
8824
+ const publicDir = join32(dir, "public");
8762
8825
  if (!existsSync19(publicDir)) continue;
8763
8826
  return { manifestPath, publicDir, ...dateOf(dir, manifestPath) };
8764
8827
  }
@@ -8781,7 +8844,7 @@ function findBuildOutput(cwd) {
8781
8844
  };
8782
8845
  }
8783
8846
  function dateOf(dir, manifestPath) {
8784
- const record = join31(dir, "nitro.json");
8847
+ const record = join32(dir, "nitro.json");
8785
8848
  if (existsSync19(record)) {
8786
8849
  try {
8787
8850
  const parsed = JSON.parse(readFileSync19(record, "utf8"));
@@ -8810,9 +8873,9 @@ function kindOf2(path2) {
8810
8873
  return "other";
8811
8874
  }
8812
8875
  function resolveAnnounced(publicDir, announced) {
8813
- const direct = join32(publicDir, announced);
8876
+ const direct = join33(publicDir, announced);
8814
8877
  if (existsSync20(direct)) return direct;
8815
- const stripped = join32(publicDir, announced.replace(/^\/[^/]+\//, "/"));
8878
+ const stripped = join33(publicDir, announced.replace(/^\/[^/]+\//, "/"));
8816
8879
  return existsSync20(stripped) ? stripped : void 0;
8817
8880
  }
8818
8881
  function emptyWeight() {
@@ -8965,22 +9028,22 @@ function scanDynamicLayer(publicDir, references) {
8965
9028
 
8966
9029
  // src/roles/static-analysis/sources.ts
8967
9030
  import { readFileSync as readFileSync21 } from "node:fs";
8968
- import { join as join35 } from "node:path";
9031
+ import { join as join36 } from "node:path";
8969
9032
  import { parseSync as parseSync4 } from "oxc-parser";
8970
9033
  import { globSync as globSync4 } from "tinyglobby";
8971
9034
 
8972
9035
  // src/roles/static-analysis/adapters/jscpd/tool-config.ts
8973
9036
  import { existsSync as existsSync22, mkdtempSync as mkdtempSync4, rmSync as rmSync6, writeFileSync as writeFileSync9 } from "node:fs";
8974
9037
  import { tmpdir as tmpdir4 } from "node:os";
8975
- import { join as join34 } from "node:path";
9038
+ import { join as join35 } from "node:path";
8976
9039
 
8977
9040
  // src/roles/static-analysis/configs/resolve.ts
8978
9041
  import { existsSync as existsSync21 } from "node:fs";
8979
- import { join as join33 } from "node:path";
9042
+ import { join as join34 } from "node:path";
8980
9043
  import { pathToFileURL as pathToFileURL4 } from "node:url";
8981
9044
  var STATIC_CONFIG_FILE = "static-analysis.config.mjs";
8982
9045
  async function loadStaticConfig(cwd) {
8983
- const path2 = join33(cwd, STATIC_CONFIG_FILE);
9046
+ const path2 = join34(cwd, STATIC_CONFIG_FILE);
8984
9047
  if (!existsSync21(path2)) {
8985
9048
  return { config: defineStaticAnalysis(), from: null, unreadable: null };
8986
9049
  }
@@ -9027,7 +9090,7 @@ function exclusions(config, scope = "tests") {
9027
9090
  return [.../* @__PURE__ */ new Set([...config.ignore, ...OWN_ARTEFACTS, ...tests])];
9028
9091
  }
9029
9092
  function measuredRoots(cwd) {
9030
- return existsSync22(join34(cwd, "src")) ? ["src"] : ["."];
9093
+ return existsSync22(join35(cwd, "src")) ? ["src"] : ["."];
9031
9094
  }
9032
9095
  function fileSettings(config, scope, extraEntries = []) {
9033
9096
  return {
@@ -9057,8 +9120,8 @@ function fileSettings(config, scope, extraEntries = []) {
9057
9120
  };
9058
9121
  }
9059
9122
  function duplicationRun(config, paths2, scope) {
9060
- const dir = mkdtempSync4(join34(tmpdir4(), "sentinel-static-"));
9061
- const configPath = join34(dir, "jscpd.json");
9123
+ const dir = mkdtempSync4(join35(tmpdir4(), "sentinel-static-"));
9124
+ const configPath = join35(dir, "jscpd.json");
9062
9125
  writeFileSync9(configPath, `${JSON.stringify(fileSettings(config, scope), null, 2)}
9063
9126
  `, "utf8");
9064
9127
  const args = [
@@ -9084,8 +9147,8 @@ function duplicationRun(config, paths2, scope) {
9084
9147
  return { args, rawReportDir: dir, dispose: () => rmSync6(dir, { force: true, recursive: true }) };
9085
9148
  }
9086
9149
  function deadCodeRun(config, paths2, extraEntries = []) {
9087
- const dir = mkdtempSync4(join34(tmpdir4(), "sentinel-static-"));
9088
- const configPath = join34(dir, "jscpd.json");
9150
+ const dir = mkdtempSync4(join35(tmpdir4(), "sentinel-static-"));
9151
+ const configPath = join35(dir, "jscpd.json");
9089
9152
  writeFileSync9(
9090
9153
  configPath,
9091
9154
  `${JSON.stringify(fileSettings(config, "dead-code", extraEntries), null, 2)}
@@ -9137,7 +9200,7 @@ function readParsed(cwd, files, passes) {
9137
9200
  function parsedSource(cwd, path2) {
9138
9201
  let text;
9139
9202
  try {
9140
- text = readFileSync21(join35(cwd, path2), "utf8");
9203
+ text = readFileSync21(join36(cwd, path2), "utf8");
9141
9204
  } catch {
9142
9205
  return void 0;
9143
9206
  }
@@ -9325,7 +9388,7 @@ function unreadableNote(coverage) {
9325
9388
 
9326
9389
  // src/roles/static-analysis/excerpt.ts
9327
9390
  import { readFileSync as readFileSync22 } from "node:fs";
9328
- import { join as join36 } from "node:path";
9391
+ import { join as join37 } from "node:path";
9329
9392
  var WINDOW = { lines: 10, nesting: { before: 3, after: 6 } };
9330
9393
  var NESTS_UPWARD = /* @__PURE__ */ new Set(["max-depth", "max-nested-callbacks"]);
9331
9394
  var SHOWS_THE_HEAD = /* @__PURE__ */ new Set(["max-lines"]);
@@ -9334,7 +9397,7 @@ function linesOf(cache, cwd, relative6) {
9334
9397
  if (cache.has(relative6)) return cache.get(relative6);
9335
9398
  let lines;
9336
9399
  try {
9337
- lines = readFileSync22(join36(cwd, relative6), "utf8").split("\n");
9400
+ lines = readFileSync22(join37(cwd, relative6), "utf8").split("\n");
9338
9401
  } catch {
9339
9402
  lines = void 0;
9340
9403
  }
@@ -9566,7 +9629,7 @@ var SCRIPT = `(function(){
9566
9629
  })();`;
9567
9630
 
9568
9631
  // src/roles/static-analysis/graph/imports.ts
9569
- import { dirname as dirname5, join as join37 } from "node:path";
9632
+ import { dirname as dirname5, join as join38 } from "node:path";
9570
9633
  var TS_BEHIND_JS = {
9571
9634
  ".js": [".ts", ".tsx"],
9572
9635
  ".mjs": [".mts"],
@@ -9619,7 +9682,7 @@ function specifiersOf(program) {
9619
9682
  }
9620
9683
  function resolveSpecifier(from, specifier, known) {
9621
9684
  if (!specifier.startsWith(".")) return void 0;
9622
- const base = join37(dirname5(from), specifier);
9685
+ const base = join38(dirname5(from), specifier);
9623
9686
  if (known.has(base)) return base;
9624
9687
  for (const extension of RESOLVABLE_EXTENSIONS) {
9625
9688
  if (known.has(base + extension)) return base + extension;
@@ -9630,7 +9693,7 @@ function resolveSpecifier(from, specifier, known) {
9630
9693
  if (known.has(swapped)) return swapped;
9631
9694
  }
9632
9695
  for (const extension of RESOLVABLE_EXTENSIONS) {
9633
- const index = join37(base, `index${extension}`);
9696
+ const index = join38(base, `index${extension}`);
9634
9697
  if (known.has(index)) return index;
9635
9698
  }
9636
9699
  return void 0;
@@ -9744,21 +9807,21 @@ function scanSyntax(cwd, config) {
9744
9807
  // src/roles/static-analysis/workspace/consumers.ts
9745
9808
  import { spawnSync as spawnSync9 } from "node:child_process";
9746
9809
  import { existsSync as existsSync23, mkdirSync as mkdirSync3, readFileSync as readFileSync23, statSync as statSync6, writeFileSync as writeFileSync10 } from "node:fs";
9747
- import { dirname as dirname6, join as join38, relative as relative5, resolve as resolve4, sep as sep2 } from "node:path";
9748
- var CACHE_DIR = join38("node_modules", ".cache", "sentinel");
9810
+ import { dirname as dirname6, join as join39, relative as relative5, resolve as resolve4, sep as sep2 } from "node:path";
9811
+ var CACHE_DIR = join39("node_modules", ".cache", "sentinel");
9749
9812
  var CACHE_FILE = "consumer-index.json";
9750
9813
  var SHAPE = 4;
9751
9814
  function workspaceRootFrom(cwd) {
9752
9815
  let dir = resolve4(cwd);
9753
9816
  for (; ; ) {
9754
- if (existsSync23(join38(dir, WORKSPACE_ROOT_MARKER))) return dir;
9817
+ if (existsSync23(join39(dir, WORKSPACE_ROOT_MARKER))) return dir;
9755
9818
  const parent = dirname6(dir);
9756
9819
  if (parent === dir) return void 0;
9757
9820
  dir = parent;
9758
9821
  }
9759
9822
  }
9760
9823
  function aliasTable(workspaceRoot) {
9761
- const file = join38(workspaceRoot, "tsconfig.base.json");
9824
+ const file = join39(workspaceRoot, "tsconfig.base.json");
9762
9825
  if (!existsSync23(file)) return /* @__PURE__ */ new Map();
9763
9826
  let paths2;
9764
9827
  try {
@@ -9780,7 +9843,7 @@ function aliasTable(workspaceRoot) {
9780
9843
  function resolveSpecifier2(specifier, table, workspaceRoot) {
9781
9844
  const isFile = (candidate) => {
9782
9845
  try {
9783
- return statSync6(join38(workspaceRoot, candidate)).isFile();
9846
+ return statSync6(join39(workspaceRoot, candidate)).isFile();
9784
9847
  } catch {
9785
9848
  return false;
9786
9849
  }
@@ -9817,11 +9880,11 @@ function resolveSpecifier2(specifier, table, workspaceRoot) {
9817
9880
  return void 0;
9818
9881
  }
9819
9882
  function resolveRelative(importer, specifier, workspaceRoot) {
9820
- const base = join38(dirname6(importer), specifier).split(sep2).join("/");
9883
+ const base = join39(dirname6(importer), specifier).split(sep2).join("/");
9821
9884
  if (base.startsWith("..")) return void 0;
9822
9885
  const isFile = (candidate) => {
9823
9886
  try {
9824
- return statSync6(join38(workspaceRoot, candidate)).isFile();
9887
+ return statSync6(join39(workspaceRoot, candidate)).isFile();
9825
9888
  } catch {
9826
9889
  return false;
9827
9890
  }
@@ -9919,7 +9982,7 @@ function hash(text) {
9919
9982
  }
9920
9983
  function consumerIndex(workspaceRoot, moduleRoots) {
9921
9984
  const key = cacheKey(workspaceRoot);
9922
- const file = join38(workspaceRoot, CACHE_DIR, CACHE_FILE);
9985
+ const file = join39(workspaceRoot, CACHE_DIR, CACHE_FILE);
9923
9986
  if (key && existsSync23(file)) {
9924
9987
  try {
9925
9988
  const cached = JSON.parse(readFileSync23(file, "utf8"));
@@ -9936,7 +9999,7 @@ function consumerIndex(workspaceRoot, moduleRoots) {
9936
9999
  const index = buildConsumerIndex(workspaceRoot, moduleRoots());
9937
10000
  if (key) {
9938
10001
  try {
9939
- mkdirSync3(join38(workspaceRoot, CACHE_DIR), { recursive: true });
10002
+ mkdirSync3(join39(workspaceRoot, CACHE_DIR), { recursive: true });
9940
10003
  const payload = {
9941
10004
  key,
9942
10005
  imported: [...index.imported],
@@ -10040,7 +10103,7 @@ var JscpdAdapter = class extends BaseAdapter {
10040
10103
  operations: [
10041
10104
  // `write` and not `merge-json`: this file is code, and the engine's in-place merge is for
10042
10105
  // JSON. A re-init therefore RESTORES the stub, so an existing one is left alone below.
10043
- ...existsSync24(join39(context2.cwd, STATIC_CONFIG_FILE)) ? [] : [{ kind: "write", path: STATIC_CONFIG_FILE, contents: configStub2() }],
10106
+ ...existsSync24(join40(context2.cwd, STATIC_CONFIG_FILE)) ? [] : [{ kind: "write", path: STATIC_CONFIG_FILE, contents: configStub2() }],
10044
10107
  manifestOperation(context2.cwd, scripts2()),
10045
10108
  ...nxTargetOperations({ cwd: context2.cwd, targets: targets2() })
10046
10109
  // The report directory is ignored ONCE at the workspace root, by `--init`'s workspace prep,
@@ -10290,7 +10353,7 @@ var JscpdAdapter = class extends BaseAdapter {
10290
10353
  const declared = moduleScripts(ctx.cwd);
10291
10354
  const missing = Object.keys(scripts2()).filter((name) => !(name in declared));
10292
10355
  const adopted = missing.length < Object.keys(scripts2()).length;
10293
- const hasConfig = existsSync24(join39(ctx.cwd, STATIC_CONFIG_FILE));
10356
+ const hasConfig = existsSync24(join40(ctx.cwd, STATIC_CONFIG_FILE));
10294
10357
  return {
10295
10358
  adopted,
10296
10359
  preset: adopted ? ctx.preset : null,
@@ -10382,7 +10445,7 @@ function runDeadCode(jscpd, config, paths2, cwd, extraEntries = []) {
10382
10445
  try {
10383
10446
  const ran = runTool(jscpd, args, cwd, "dead-code");
10384
10447
  if (ran.kind !== "ran") return ran;
10385
- const path2 = join39(rawReportDir, RAW_REPORT["dead-code"]);
10448
+ const path2 = join40(rawReportDir, RAW_REPORT["dead-code"]);
10386
10449
  if (!existsSync24(path2)) {
10387
10450
  process.stderr.write(
10388
10451
  `sentinel static-analysis(jscpd): the dead-code pass wrote no ${RAW_REPORT["dead-code"]}
@@ -10413,11 +10476,11 @@ function runDeadCode(jscpd, config, paths2, cwd, extraEntries = []) {
10413
10476
  }
10414
10477
  }
10415
10478
  function moduleRelative(name, roots, cwd) {
10416
- if (existsSync24(join39(cwd, name))) return name;
10479
+ if (existsSync24(join40(cwd, name))) return name;
10417
10480
  for (const root of roots) {
10418
10481
  if (root === ".") continue;
10419
10482
  const candidate = `${root}/${name}`;
10420
- if (existsSync24(join39(cwd, candidate))) return candidate;
10483
+ if (existsSync24(join40(cwd, candidate))) return candidate;
10421
10484
  }
10422
10485
  return name;
10423
10486
  }
@@ -10426,7 +10489,7 @@ function runDuplication(jscpd, config, paths2, scope, cwd) {
10426
10489
  try {
10427
10490
  const ran = runTool(jscpd, args, cwd, scope);
10428
10491
  if (ran.kind !== "ran") return ran;
10429
- const path2 = join39(rawReportDir, RAW_REPORT.duplication);
10492
+ const path2 = join40(rawReportDir, RAW_REPORT.duplication);
10430
10493
  const parsed = existsSync24(path2) ? safeParse(readFileSync24(path2, "utf8")) : void 0;
10431
10494
  const total = parsed?.statistics?.total;
10432
10495
  if (!total) {
@@ -10596,7 +10659,7 @@ function outsideOf(cwd) {
10596
10659
  function moduleRootsOf(workspaceRoot) {
10597
10660
  const roots = [];
10598
10661
  for (const area of ["apps", "libs"]) {
10599
- const base = join39(workspaceRoot, area);
10662
+ const base = join40(workspaceRoot, area);
10600
10663
  if (!existsSync24(base)) continue;
10601
10664
  for (const entry of globSync6([`${area}/**/package.json`, `${area}/**/project.json`], {
10602
10665
  cwd: workspaceRoot,
@@ -10939,7 +11002,7 @@ var PICTURE_FILE = `${TARGET2}-graph.svg`;
10939
11002
  function clearStaleOutputs(cwd, keeping) {
10940
11003
  for (const name of [...Object.values(SHAPE_FILE3), PICTURE_FILE]) {
10941
11004
  if (keeping.has(name)) continue;
10942
- const path2 = join39(cwd, REPORT_DIR2, name);
11005
+ const path2 = join40(cwd, REPORT_DIR2, name);
10943
11006
  if (existsSync24(path2)) unlinkSync3(path2);
10944
11007
  }
10945
11008
  }
@@ -10958,11 +11021,11 @@ function drawsPicture(graph, coverage) {
10958
11021
  async function emit(report, shape, cwd, graph, coverage) {
10959
11022
  if (shape === "console") return [];
10960
11023
  const detailed = shape === "markdown" ? report : withExcerpts(report, cwd);
10961
- mkdirSync4(join39(cwd, REPORT_DIR2), { recursive: true });
11024
+ mkdirSync4(join40(cwd, REPORT_DIR2), { recursive: true });
10962
11025
  const written = [];
10963
11026
  if (shape === "html" && drawsPicture(graph, coverage)) {
10964
11027
  const drawn = layOut(graph.graph, graph.communityOf);
10965
- const path2 = join39(cwd, REPORT_DIR2, PICTURE_FILE);
11028
+ const path2 = join40(cwd, REPORT_DIR2, PICTURE_FILE);
10966
11029
  await writeGraphPicture(drawn, path2);
10967
11030
  written.push(`${REPORT_DIR2}/${PICTURE_FILE}`);
10968
11031
  detailed.picture = buildExplorer(drawn, graph.communityOf).markup;
@@ -10970,7 +11033,7 @@ async function emit(report, shape, cwd, graph, coverage) {
10970
11033
  const RENDER = { json: renderJson2, html: renderHtml, markdown: renderMarkdown2 };
10971
11034
  const name = SHAPE_FILE3[shape] ?? `${TARGET2}.${shape}`;
10972
11035
  const body = RENDER[shape](detailed);
10973
- writeFileSync11(join39(cwd, REPORT_DIR2, name), body, "utf8");
11036
+ writeFileSync11(join40(cwd, REPORT_DIR2, name), body, "utf8");
10974
11037
  written.unshift(`${REPORT_DIR2}/${name}`);
10975
11038
  return written;
10976
11039
  }
@@ -11006,7 +11069,7 @@ function registerTest() {
11006
11069
  import { spawnSync as spawnSync11 } from "node:child_process";
11007
11070
  import { existsSync as existsSync25, readFileSync as readFileSync26 } from "node:fs";
11008
11071
  import { createRequire } from "node:module";
11009
- import { join as join41 } from "node:path";
11072
+ import { join as join42 } from "node:path";
11010
11073
 
11011
11074
  // src/roles/typescript/presets/nest.json
11012
11075
  var nest_default = {
@@ -11192,7 +11255,7 @@ function readTsconfigAdoption(cwd) {
11192
11255
 
11193
11256
  // src/roles/typescript/adapters/tsc/plan.ts
11194
11257
  import { readFileSync as readFileSync25 } from "node:fs";
11195
- import { join as join40 } from "node:path";
11258
+ import { join as join41 } from "node:path";
11196
11259
 
11197
11260
  // src/roles/typescript/typecheck-script.ts
11198
11261
  var SENTINEL_TYPECHECK_COMMAND = "sentinel --run --typescript";
@@ -11285,7 +11348,7 @@ function planAdoption(context2) {
11285
11348
  };
11286
11349
  }
11287
11350
  const existing = parseJsonc(
11288
- readFileSync25(join40(context2.cwd, target.path), "utf8"),
11351
+ readFileSync25(join41(context2.cwd, target.path), "utf8"),
11289
11352
  target.path
11290
11353
  );
11291
11354
  const extendsChain = composeExtends(existing.extends, preset);
@@ -11423,7 +11486,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
11423
11486
  let chain;
11424
11487
  try {
11425
11488
  const parsed = parseJsonc(
11426
- readFileSync26(join41(cwd, target.path), "utf8"),
11489
+ readFileSync26(join42(cwd, target.path), "utf8"),
11427
11490
  target.path
11428
11491
  );
11429
11492
  chain = parsed.extends;
@@ -11436,7 +11499,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
11436
11499
  );
11437
11500
  if (preset === void 0) return void 0;
11438
11501
  try {
11439
- createRequire(join41(cwd, "noop.js")).resolve(preset);
11502
+ createRequire(join42(cwd, "noop.js")).resolve(preset);
11440
11503
  return void 0;
11441
11504
  } catch {
11442
11505
  return preset;
@@ -11532,7 +11595,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
11532
11595
  referencedProjects(cwd, config) {
11533
11596
  try {
11534
11597
  const parsed = parseJsonc(
11535
- readFileSync26(join41(cwd, config), "utf8"),
11598
+ readFileSync26(join42(cwd, config), "utf8"),
11536
11599
  config
11537
11600
  );
11538
11601
  const referenced = (parsed.references ?? []).map((reference) => reference.path).filter((path2) => typeof path2 === "string" && path2.length > 0);
@@ -11548,7 +11611,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
11548
11611
  * check.
11549
11612
  */
11550
11613
  typecheckTarget(cwd) {
11551
- if (existsSync25(join41(cwd, "tsconfig.json"))) return "tsconfig.json";
11614
+ if (existsSync25(join42(cwd, "tsconfig.json"))) return "tsconfig.json";
11552
11615
  const target = resolveTsconfigTarget(cwd);
11553
11616
  return target.reason === "none" ? null : target.path;
11554
11617
  }
@@ -11886,8 +11949,8 @@ function applyPlan(cwd, plan3) {
11886
11949
  }
11887
11950
 
11888
11951
  // src/core/config/preset-evidence.ts
11889
- import { existsSync as existsSync27, readdirSync as readdirSync4, readFileSync as readFileSync28 } from "node:fs";
11890
- import { join as join42 } from "node:path";
11952
+ import { existsSync as existsSync27, readdirSync as readdirSync5, readFileSync as readFileSync28 } from "node:fs";
11953
+ import { join as join43 } from "node:path";
11891
11954
  var PATH_SIGNALS = [
11892
11955
  {
11893
11956
  preset: "nest",
@@ -11915,18 +11978,18 @@ function sourceImports(cwd, pattern) {
11915
11978
  const dir = stack.pop();
11916
11979
  let entries;
11917
11980
  try {
11918
- entries = readdirSync4(dir, { withFileTypes: true });
11981
+ entries = readdirSync5(dir, { withFileTypes: true });
11919
11982
  } catch {
11920
11983
  continue;
11921
11984
  }
11922
11985
  for (const entry of entries) {
11923
11986
  if (entry.isDirectory()) {
11924
- if (!NOT_SCANNED.has(entry.name)) stack.push(join42(dir, entry.name));
11987
+ if (!NOT_SCANNED.has(entry.name)) stack.push(join43(dir, entry.name));
11925
11988
  continue;
11926
11989
  }
11927
11990
  if (!SOURCE_FILE.test(entry.name)) continue;
11928
11991
  try {
11929
- if (pattern.test(readFileSync28(join42(dir, entry.name), "utf8"))) return true;
11992
+ if (pattern.test(readFileSync28(join43(dir, entry.name), "utf8"))) return true;
11930
11993
  } catch {
11931
11994
  continue;
11932
11995
  }
@@ -11935,7 +11998,7 @@ function sourceImports(cwd, pattern) {
11935
11998
  return false;
11936
11999
  }
11937
12000
  function dependencyNames(cwd) {
11938
- const path2 = join42(cwd, "package.json");
12001
+ const path2 = join43(cwd, "package.json");
11939
12002
  if (!existsSync27(path2)) return [];
11940
12003
  try {
11941
12004
  const manifest = parseJsonc(
@@ -11954,7 +12017,7 @@ var REACT_TYPESCRIPT_PRESET = "@hublo/sentinel/typescript/react";
11954
12017
  function reactTsconfigEvidence(cwd) {
11955
12018
  let entries;
11956
12019
  try {
11957
- entries = readdirSync4(cwd).filter(
12020
+ entries = readdirSync5(cwd).filter(
11958
12021
  (name) => name.startsWith("tsconfig") && name.endsWith(".json")
11959
12022
  );
11960
12023
  } catch {
@@ -11962,7 +12025,7 @@ function reactTsconfigEvidence(cwd) {
11962
12025
  }
11963
12026
  for (const name of entries) {
11964
12027
  try {
11965
- const config = parseJsonc(readFileSync28(join42(cwd, name), "utf8"), name);
12028
+ const config = parseJsonc(readFileSync28(join43(cwd, name), "utf8"), name);
11966
12029
  if (config.compilerOptions?.jsx !== void 0) return 'its tsconfig sets "jsx"';
11967
12030
  const extended = Array.isArray(config.extends) ? config.extends : config.extends === void 0 ? [] : [config.extends];
11968
12031
  if (extended.some((entry) => entry === REACT_TYPESCRIPT_PRESET)) {
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-VSUHHETH.js";
9
+ } from "./chunk-EQQMY6NH.js";
10
10
  import {
11
11
  BaseAdapter
12
12
  } from "./chunk-F3Q3JQJ6.js";
@@ -62,8 +62,8 @@ the project at src/app/database adopted the role itself: its 131 migration(s) ar
62
62
 
63
63
  A module never reads a nested module that adopted the role itself, so nothing is reported twice;
64
64
  while the nested one has not adopted, its parent reads its files, so nothing is read by no one.
65
- Every `--run` of the service also says when its nested project reports the migrations, so "no
66
- migration in this module" never reads as migrations nobody guards.
65
+ Every `--run` of the service says the same, both ways: who reports the nested project's
66
+ migrations once it adopted, and that the service reads them, with the command, while it has not.
67
67
 
68
68
  A module that holds no migration and no raw SQL call is skipped by name: there is nothing for the
69
69
  role to read. An existing `sql.config.mjs` is the team's and is never rewritten by a re-init.
@@ -98,6 +98,9 @@ checked 1 call(s) taking SQL text ($queryRawUnsafe / $executeRawUnsafe, pg, post
98
98
 
99
99
  This is how the role reads, not a setting.
100
100
 
101
+ One rule reads the whole module: `migration-folder-without-sql`, a listing of the migrations
102
+ directories, since a folder without its `migration.sql` stops every deploy wherever it came from.
103
+
101
104
  **Each migration is read the way Prisma runs it.** Prisma runs a file of one statement as it is,
102
105
  and a file of several inside one transaction. So a file of several statements is read as running in
103
106
  a transaction, and squawk reports what PostgreSQL refuses there:
@@ -141,11 +144,12 @@ which a module may turn off) and the 2 timeouts the key calls for.
141
144
  | sentinel, `unsafe-sql-pasted-value` and `unsafe-sql-raw-fragment` | 2 | **yes**, at `warn` |
142
145
  | sentinel, `applied-migration-changed` | 1 | **yes**, at `warn` |
143
146
  | sentinel, `enum-value-used-before-commit` | 1 | **yes**, at `warn` |
147
+ | sentinel, `migration-folder-without-sql` | 1 | **yes**, at `warn` |
144
148
 
145
- **54 rules run on every module**, the set squawk itself runs, plus sentinel's four. sentinel turns
149
+ **55 rules run on every module**, the set squawk itself runs, plus sentinel's five. sentinel turns
146
150
  no squawk rule off and turns no opt-in rule on: the choice of what runs by default is squawk's, and
147
- a module moves it in its own config. `pnpm exec sentinel --inspect --sql --json` lists all 81 names
148
- with the level each has in this module: squawk's 76, sentinel's four, and `syntax-error`.
151
+ a module moves it in its own config. `pnpm exec sentinel --inspect --sql --json` lists all 82 names
152
+ with the level each has in this module: squawk's 76, sentinel's five, and `syntax-error`.
149
153
 
150
154
  **A migration that does not parse** is reported first, with its first error (the ones squawk gives
151
155
  after it follow from it), and counts as **one finding** under `syntax-error`, at `warn` like every
@@ -387,7 +391,8 @@ file, and a change of mode alone (`chmod`) is no change.
387
391
 
388
392
  A migration moved where the settings no longer see it (`migration.sql` renamed
389
393
  `migration.sql.bak`, its folder moved into `archive/`) is reported **deleted**, whatever its folder
390
- is called: Prisma no longer reads it either. What counts as a migration is `migrations.include`, on
394
+ is called: Prisma no longer reads it either. An `archive/` folder inside the migrations directory
395
+ also stops every deploy, which `migration-folder-without-sql` reports (below). What counts as a migration is `migrations.include`, on
391
396
  both ends of a move.
392
397
 
393
398
  **A folder left without its `migration.sql`** (renamed `.bak`, or deleted beside its `down.sql`) is
@@ -406,6 +411,26 @@ modifications, 34 deletions), and the role agreed with the oracle on all 60. Two
406
411
  were renames that also changed the text: the old name is gone, and the new folder is a migration
407
412
  Prisma has never seen, read as such.
408
413
 
414
+ ## A folder without its `migration.sql`, `migration-folder-without-sql`
415
+
416
+ Prisma reads **every folder** of its migrations directory as a migration, in name order. A folder
417
+ holding no `migration.sql` stops the deploy there with **P3015** "Could not find the migration
418
+ file": the migrations before it are applied, none after it. Proven on PostgreSQL 16.8 with Prisma
419
+ 6.19.3 (a beta tester's report on alpha.22), on a new database and on one that ran every other
420
+ migration:
421
+
422
+ | In the migrations directory | At deploy (proven) | Reported |
423
+ | --------------------------------------------------------------------------- | --------------------------------------------------- | ---------------------------------------------- |
424
+ | a new folder holding only a `.gitkeep`, a `migration.sql.bak`, a `down.sql` | **stops**, P3015, on every database | **yes** |
425
+ | an `archive/` folder the old migrations were moved into | **stops**, P3015 (`archive` sorts after every date) | **yes** |
426
+ | a migration of the base whose `migration.sql` the branch removed | stops a new database only, P3015 | yes, by `applied-migration-changed`, not twice |
427
+ | a file of the directory that is not a folder (a `README.md`) | applies | no |
428
+
429
+ Unlike the other rules, it reads the **whole module**, not only what the branch changed: a listing
430
+ of its migrations directories (each one holding a `migration_lock.toml`, or a migration), cheap,
431
+ and no such folder exists on the monorepo's main (876 folders). The fix it prints: give the folder
432
+ its `migration.sql`, or move what it holds out of the migrations directory.
433
+
409
434
  ## A new enum value used before it is committed, `enum-value-used-before-commit`
410
435
 
411
436
  `ALTER TYPE "Status" ADD VALUE 'ARCHIVED'` then a use of `'ARCHIVED'` in the same migration: Prisma
@@ -420,7 +445,7 @@ squawk 2.72.0 does not see it.
420
445
  | a `COMMIT;` first, or each part in a `BEGIN … COMMIT` of its own | applies | no |
421
446
  | another value added, the same label added to another enum, the value named in a comment only | applies | no |
422
447
  | the value alone in its migration, used in the next one | applies | no |
423
- | the same word written into a **text** column | applies | yes: the rule reads text, not column types, so the message names the value and the enum, and a reviewer tells in one look |
448
+ | the same word written into a **text** or **varchar** column | applies | yes: the rule reads text, not column types, so the message names the value and the enum, and a reviewer tells in one look |
424
449
 
425
450
  The fix it prints: give the `ALTER TYPE … ADD VALUE` a migration of its own, before the one that
426
451
  uses the value. Measured on the monorepo (874 migrations, 68 adding an enum value): no finding, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.7.0-alpha.22",
3
+ "version": "1.7.0-alpha.24",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",