@hublo/sentinel 1.7.0-alpha.33 → 1.7.0-alpha.34
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/bin/sentinel.js +2 -2
- package/dist/{chunk-SHF46ALB.js → chunk-53HYHJTD.js} +3 -2
- package/dist/chunk-53HYHJTD.js.map +1 -0
- package/dist/{chunk-Y7UTRV4W.js → chunk-Z2QRW7T4.js} +399 -120
- package/dist/index.js +2 -2
- package/dist/roles/sql/config.d.ts +10 -0
- package/dist/roles/sql/config.js +1 -1
- package/docs/sql-adoption.md +58 -19
- package/package.json +1 -1
- package/dist/chunk-SHF46ALB.js.map +0 -1
|
@@ -135,7 +135,7 @@ import {
|
|
|
135
135
|
defaults as defaults3,
|
|
136
136
|
defineSql,
|
|
137
137
|
squawkRules
|
|
138
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-53HYHJTD.js";
|
|
139
139
|
import {
|
|
140
140
|
CODE_CHURN_CONFIG_FILE,
|
|
141
141
|
REPORT_DIR as REPORT_DIR2,
|
|
@@ -11233,8 +11233,8 @@ function registerLint() {
|
|
|
11233
11233
|
|
|
11234
11234
|
// src/roles/sql/adapters/squawk/squawk.adapter.ts
|
|
11235
11235
|
import { spawnSync as spawnSync13 } from "node:child_process";
|
|
11236
|
-
import { existsSync as existsSync29, readFileSync as
|
|
11237
|
-
import { join as
|
|
11236
|
+
import { existsSync as existsSync29, readFileSync as readFileSync25 } from "node:fs";
|
|
11237
|
+
import { join as join47 } from "node:path";
|
|
11238
11238
|
|
|
11239
11239
|
// src/roles/sql/configs/resolve.ts
|
|
11240
11240
|
import { existsSync as existsSync26 } from "node:fs";
|
|
@@ -12007,10 +12007,10 @@ function callShape(node, imports) {
|
|
|
12007
12007
|
const object = alias(target) === void 0 ? unwrap(target.object) : void 0;
|
|
12008
12008
|
if (name === "call") return { name: method, object, args: args.slice(1), callee: target };
|
|
12009
12009
|
const list = args[1] === void 0 ? void 0 : unwrap(args[1]);
|
|
12010
|
-
const
|
|
12010
|
+
const applied2 = list === void 0 ? [] : list.type === "ArrayExpression" ? list.elements.filter(
|
|
12011
12011
|
(item) => item !== null
|
|
12012
12012
|
) : [{ type: "SpreadElement", argument: list, start: list.start, end: list.end }];
|
|
12013
|
-
return { name: method, object, args:
|
|
12013
|
+
return { name: method, object, args: applied2, callee: target };
|
|
12014
12014
|
}
|
|
12015
12015
|
return { name, object: unwrap(callee.object), args, callee };
|
|
12016
12016
|
}
|
|
@@ -12227,11 +12227,11 @@ function exportedConst(file, name) {
|
|
|
12227
12227
|
return void 0;
|
|
12228
12228
|
}
|
|
12229
12229
|
function isPlaceholderList(call, context2) {
|
|
12230
|
-
const
|
|
12231
|
-
if (!MEMBER_TYPES.has(
|
|
12230
|
+
const join56 = unwrap(call.callee);
|
|
12231
|
+
if (!MEMBER_TYPES.has(join56.type) || join56.property.name !== "join") return false;
|
|
12232
12232
|
const separator = call.arguments[0];
|
|
12233
12233
|
if (separator !== void 0 && !isSafe(separator, context2)) return false;
|
|
12234
|
-
const map = unwrap(
|
|
12234
|
+
const map = unwrap(join56.object);
|
|
12235
12235
|
if (map.type !== "CallExpression") return false;
|
|
12236
12236
|
const mapCallee = unwrap(map.callee);
|
|
12237
12237
|
if (!MEMBER_TYPES.has(mapCallee.type) || mapCallee.property.name !== "map")
|
|
@@ -12450,7 +12450,11 @@ function readTemplate(template) {
|
|
|
12450
12450
|
if (parsed2.ok) {
|
|
12451
12451
|
return {
|
|
12452
12452
|
kind: "read",
|
|
12453
|
-
reading: readingOf(
|
|
12453
|
+
reading: readingOf(
|
|
12454
|
+
parsed2.statements,
|
|
12455
|
+
{ wrap, before, fill: fillName, values: template.values },
|
|
12456
|
+
text
|
|
12457
|
+
)
|
|
12454
12458
|
};
|
|
12455
12459
|
}
|
|
12456
12460
|
firstError ??= parsed2.message;
|
|
@@ -12458,7 +12462,12 @@ function readTemplate(template) {
|
|
|
12458
12462
|
}
|
|
12459
12463
|
return { kind: "unread", reason: `PostgreSQL's parser does not read it alone (${firstError})` };
|
|
12460
12464
|
}
|
|
12461
|
-
function readingOf(statements, {
|
|
12465
|
+
function readingOf(statements, {
|
|
12466
|
+
wrap,
|
|
12467
|
+
before,
|
|
12468
|
+
fill,
|
|
12469
|
+
values
|
|
12470
|
+
}, text) {
|
|
12462
12471
|
const wrapped = `${before}${text.sql}`;
|
|
12463
12472
|
const indexIn = (location) => indexOfByte(wrapped, location) - before.length;
|
|
12464
12473
|
return {
|
|
@@ -12469,20 +12478,69 @@ function readingOf(statements, { wrap, before, fill }, text) {
|
|
|
12469
12478
|
const index = indexIn(location);
|
|
12470
12479
|
return index >= 0 && index < text.sql.length;
|
|
12471
12480
|
},
|
|
12472
|
-
fileOffset: (location) => fileOffsetOf(text, indexIn(location))
|
|
12481
|
+
fileOffset: (location) => fileOffsetOf(text, indexIn(location)),
|
|
12482
|
+
valueStart: (n) => fill === "value" ? values[n - 1] : void 0
|
|
12473
12483
|
};
|
|
12474
12484
|
}
|
|
12475
12485
|
|
|
12486
|
+
// src/roles/sql/raw/template-rule.ts
|
|
12487
|
+
var NO_CONTEXT = { trigramIndexes: () => [], indexesFrom: [] };
|
|
12488
|
+
|
|
12489
|
+
// src/roles/sql/raw/value-starts.ts
|
|
12490
|
+
var MAX_DEPTH2 = 8;
|
|
12491
|
+
function valueStart(node, bindings, depth = 0) {
|
|
12492
|
+
if (depth > MAX_DEPTH2) return void 0;
|
|
12493
|
+
const current = unwrap(node);
|
|
12494
|
+
const deeper = (next) => valueStart(next, bindings, depth + 1);
|
|
12495
|
+
switch (current.type) {
|
|
12496
|
+
case "Literal":
|
|
12497
|
+
return typeof current.value === "string" ? current.value : void 0;
|
|
12498
|
+
case "TemplateLiteral":
|
|
12499
|
+
return templateStart(current, deeper);
|
|
12500
|
+
case "BinaryExpression":
|
|
12501
|
+
return current.operator === "+" ? sumStart(current, deeper) : void 0;
|
|
12502
|
+
case "Identifier":
|
|
12503
|
+
return nameStart(current.name, bindings, deeper);
|
|
12504
|
+
default:
|
|
12505
|
+
return void 0;
|
|
12506
|
+
}
|
|
12507
|
+
}
|
|
12508
|
+
function templateStart(node, deeper) {
|
|
12509
|
+
const [first] = node.quasis;
|
|
12510
|
+
const value = first?.value;
|
|
12511
|
+
const text = value?.cooked ?? value?.raw;
|
|
12512
|
+
if (text === void 0) return void 0;
|
|
12513
|
+
const [expression] = node.expressions;
|
|
12514
|
+
if (text !== "" || expression === void 0) return text;
|
|
12515
|
+
return deeper(expression);
|
|
12516
|
+
}
|
|
12517
|
+
function sumStart(node, deeper) {
|
|
12518
|
+
const left = deeper(node.left);
|
|
12519
|
+
if (left !== "") return left;
|
|
12520
|
+
return deeper(node.right);
|
|
12521
|
+
}
|
|
12522
|
+
function nameStart(name, bindings, deeper) {
|
|
12523
|
+
const found = bindings.get(name) ?? [];
|
|
12524
|
+
const [binding] = found;
|
|
12525
|
+
if (found.length !== 1 || binding?.kind !== "const") return void 0;
|
|
12526
|
+
return deeper(binding.init);
|
|
12527
|
+
}
|
|
12528
|
+
|
|
12476
12529
|
// src/roles/sql/raw/templates.ts
|
|
12477
12530
|
function sqlTemplatesOf(program, prisma, fileText) {
|
|
12478
12531
|
const templates = [];
|
|
12532
|
+
let bindings;
|
|
12479
12533
|
walk(program, (node) => {
|
|
12480
12534
|
if (node.type !== "TaggedTemplateExpression") return;
|
|
12481
12535
|
const tag = tagOf(node.tag, prisma);
|
|
12482
12536
|
if (tag === void 0) return;
|
|
12483
12537
|
const quasis = node.quasi.quasis;
|
|
12484
12538
|
const parts = quasis.map((element) => partOf(element, fileText));
|
|
12485
|
-
|
|
12539
|
+
bindings ??= bindingsOf(program);
|
|
12540
|
+
const known = bindings;
|
|
12541
|
+
const expressions = node.quasi.expressions;
|
|
12542
|
+
const values = expressions.map((expression) => valueStart(expression, known));
|
|
12543
|
+
templates.push({ tag, parts, values, start: node.start });
|
|
12486
12544
|
});
|
|
12487
12545
|
return templates;
|
|
12488
12546
|
}
|
|
@@ -12504,7 +12562,7 @@ function partOf(element, fileText) {
|
|
|
12504
12562
|
}
|
|
12505
12563
|
|
|
12506
12564
|
// src/roles/sql/raw/check-templates.ts
|
|
12507
|
-
async function checkSqlTemplates(cwd, files, readFile, rules) {
|
|
12565
|
+
async function checkSqlTemplates(cwd, files, readFile, rules, context2 = NO_CONTEXT) {
|
|
12508
12566
|
const run = { templates: 0, read: 0, unread: [], unparsed: [], findings: [] };
|
|
12509
12567
|
if (files.length === 0) return run;
|
|
12510
12568
|
const loaded2 = await parserLoaded();
|
|
@@ -12518,7 +12576,7 @@ async function checkSqlTemplates(cwd, files, readFile, rules) {
|
|
|
12518
12576
|
run.unparsed.push({ file, reason: "could not be read, so its SQL templates are not read" });
|
|
12519
12577
|
continue;
|
|
12520
12578
|
}
|
|
12521
|
-
checkFile({ file, text, rules }, run);
|
|
12579
|
+
checkFile({ file, text, rules, context: context2 }, run);
|
|
12522
12580
|
}
|
|
12523
12581
|
return run;
|
|
12524
12582
|
}
|
|
@@ -12577,7 +12635,7 @@ function checkTemplate(input, template, run) {
|
|
|
12577
12635
|
function checkRule(input, rule, reading, run) {
|
|
12578
12636
|
let hits;
|
|
12579
12637
|
try {
|
|
12580
|
-
hits = rule.check(reading);
|
|
12638
|
+
hits = rule.check(reading, input.context);
|
|
12581
12639
|
} catch {
|
|
12582
12640
|
return;
|
|
12583
12641
|
}
|
|
@@ -12655,6 +12713,62 @@ function firstLocation(node) {
|
|
|
12655
12713
|
function wholeStatement(reading) {
|
|
12656
12714
|
return reading.wrap === "statement" && reading.fill === "value";
|
|
12657
12715
|
}
|
|
12716
|
+
function expressionKey(node) {
|
|
12717
|
+
const column = bodyOf(node, "ColumnRef");
|
|
12718
|
+
if (column) {
|
|
12719
|
+
const name = columnNames(column).at(-1);
|
|
12720
|
+
return name === void 0 || name === "*" || name === "" ? void 0 : name;
|
|
12721
|
+
}
|
|
12722
|
+
const call = bodyOf(node, "FuncCall");
|
|
12723
|
+
if (call) return callKey(call);
|
|
12724
|
+
const cast = bodyOf(node, "TypeCast");
|
|
12725
|
+
if (cast) {
|
|
12726
|
+
const inner = expressionKey(cast.arg);
|
|
12727
|
+
const names = cast.typeName?.names ?? [];
|
|
12728
|
+
const type = bodyOf(names.at(-1), "String")?.sval;
|
|
12729
|
+
return inner === void 0 || typeof type !== "string" ? void 0 : `${inner}::${type}`;
|
|
12730
|
+
}
|
|
12731
|
+
const constant = bodyOf(node, "A_Const");
|
|
12732
|
+
if (constant) return constantKey(constant);
|
|
12733
|
+
const operation = bodyOf(node, "A_Expr");
|
|
12734
|
+
if (operation?.kind === "AEXPR_OP") {
|
|
12735
|
+
const operator = bodyOf(operation.name?.at(-1), "String")?.sval;
|
|
12736
|
+
const left = expressionKey(operation.lexpr);
|
|
12737
|
+
const right = expressionKey(operation.rexpr);
|
|
12738
|
+
if (typeof operator !== "string" || left === void 0 || right === void 0) return void 0;
|
|
12739
|
+
return `${left} ${operator} ${right}`;
|
|
12740
|
+
}
|
|
12741
|
+
return void 0;
|
|
12742
|
+
}
|
|
12743
|
+
function callKey(call) {
|
|
12744
|
+
const name = bodyOf(call.funcname?.at(-1), "String")?.sval;
|
|
12745
|
+
if (typeof name !== "string") return void 0;
|
|
12746
|
+
const args = (call.args ?? []).map(expressionKey);
|
|
12747
|
+
if (args.some((arg) => arg === void 0)) return void 0;
|
|
12748
|
+
return `${name}(${args.join(", ")})`;
|
|
12749
|
+
}
|
|
12750
|
+
function constantKey(constant) {
|
|
12751
|
+
if (constant.isnull === true) return "null";
|
|
12752
|
+
const text = bodyOf(constant, "sval")?.sval;
|
|
12753
|
+
if (typeof text === "string") return `'${text}'`;
|
|
12754
|
+
for (const [kind, zero] of [
|
|
12755
|
+
["ival", "0"],
|
|
12756
|
+
["fval", "0"],
|
|
12757
|
+
["boolval", "false"]
|
|
12758
|
+
]) {
|
|
12759
|
+
const body = bodyOf(constant, kind);
|
|
12760
|
+
if (body) return body[kind] === void 0 ? zero : String(body[kind]);
|
|
12761
|
+
}
|
|
12762
|
+
return void 0;
|
|
12763
|
+
}
|
|
12764
|
+
function qualifiersUnder(node) {
|
|
12765
|
+
const qualifiers = /* @__PURE__ */ new Set();
|
|
12766
|
+
for (const names of columnsUnder(node)) {
|
|
12767
|
+
const qualifier = names.at(-2);
|
|
12768
|
+
if (qualifier !== void 0) qualifiers.add(qualifier);
|
|
12769
|
+
}
|
|
12770
|
+
return qualifiers;
|
|
12771
|
+
}
|
|
12658
12772
|
|
|
12659
12773
|
// src/roles/sql/raw/rules/exists-union-correlated-outside.ts
|
|
12660
12774
|
var existsUnionCorrelatedOutside = {
|
|
@@ -12738,37 +12852,104 @@ function unlistedInsert(statement) {
|
|
|
12738
12852
|
|
|
12739
12853
|
// src/roles/sql/raw/rules/leading-wildcard-like.ts
|
|
12740
12854
|
var QUERIES = /* @__PURE__ */ new Set(["SelectStmt", "UpdateStmt", "DeleteStmt", "InsertStmt"]);
|
|
12855
|
+
var KEEPS_START = /* @__PURE__ */ new Set(["lower", "upper", "unaccent", "immutable_unaccent", "like_escape"]);
|
|
12741
12856
|
var leadingWildcardLike = {
|
|
12742
12857
|
name: LIKE_WILDCARD_RULE,
|
|
12743
|
-
help: "anchor the pattern at its start when the search allows it (`LIKE 'abc%'`); for a search inside the text, a trigram index (`pg_trgm`) is
|
|
12744
|
-
check: (reading) => {
|
|
12858
|
+
help: "anchor the pattern at its start when the search allows it (`LIKE 'abc%'`); for a search inside the text, a trigram index (`pg_trgm`) on this very expression; when that index is in another module's migrations, name their folder in `migrations.indexesFrom`",
|
|
12859
|
+
check: (reading, context2) => {
|
|
12745
12860
|
if (!statementKinds(reading.statements).every((kind) => QUERIES.has(kind))) return [];
|
|
12746
12861
|
return [...pgNodes(reading.statements)].flatMap((node) => {
|
|
12747
|
-
const like =
|
|
12748
|
-
return like
|
|
12862
|
+
const like = unservedLike(node, reading, context2);
|
|
12863
|
+
return like ? [hitOf(like, context2)] : [];
|
|
12749
12864
|
});
|
|
12750
12865
|
}
|
|
12751
12866
|
};
|
|
12752
|
-
function
|
|
12867
|
+
function unservedLike(node, reading, context2) {
|
|
12753
12868
|
const like = bodyOf(node, "A_Expr");
|
|
12754
12869
|
if (like?.kind !== "AEXPR_LIKE" && like?.kind !== "AEXPR_ILIKE") return void 0;
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
if (
|
|
12870
|
+
if (typeof like.location !== "number" || !reading.own(like.location)) return void 0;
|
|
12871
|
+
const pattern = patternStart(like.rexpr, reading);
|
|
12872
|
+
if (!pattern?.text.startsWith("%")) return void 0;
|
|
12873
|
+
const expression = expressionKey(like.lexpr);
|
|
12874
|
+
if (expression === void 0) return void 0;
|
|
12875
|
+
const table = tableOf(like.lexpr, reading);
|
|
12876
|
+
if (served(context2.trigramIndexes(), expression, table)) return void 0;
|
|
12758
12877
|
return {
|
|
12759
12878
|
location: like.location,
|
|
12879
|
+
operator: like.kind === "AEXPR_ILIKE" ? "ILIKE" : "LIKE",
|
|
12760
12880
|
pattern,
|
|
12761
|
-
|
|
12881
|
+
expression,
|
|
12882
|
+
table
|
|
12762
12883
|
};
|
|
12763
12884
|
}
|
|
12764
|
-
function
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12885
|
+
function patternStart(node, reading) {
|
|
12886
|
+
const text = bodyOf(bodyOf(node, "A_Const"), "sval")?.sval;
|
|
12887
|
+
if (typeof text === "string") return { text, shape: `'${text}'` };
|
|
12888
|
+
const parameter = bodyOf(node, "ParamRef")?.number;
|
|
12889
|
+
if (typeof parameter === "number") {
|
|
12890
|
+
const start = reading.valueStart(parameter);
|
|
12891
|
+
return start === void 0 ? void 0 : { text: start, shape: `$${parameter}`, bound: parameter };
|
|
12892
|
+
}
|
|
12893
|
+
const cast = bodyOf(node, "TypeCast");
|
|
12894
|
+
if (cast) return patternStart(cast.arg, reading);
|
|
12895
|
+
const joined2 = bodyOf(node, "A_Expr");
|
|
12896
|
+
if (joined2?.kind === "AEXPR_OP" && operatorOf(joined2) === "||") {
|
|
12897
|
+
return startOfSum(joined2.lexpr, joined2.rexpr, reading, (first2) => `${first2} || \u2026`);
|
|
12898
|
+
}
|
|
12899
|
+
const call = bodyOf(node, "FuncCall");
|
|
12900
|
+
const name = call ? functionName(call) : void 0;
|
|
12901
|
+
const [first, ...rest] = call?.args ?? [];
|
|
12902
|
+
if (name === "concat")
|
|
12903
|
+
return startOfSum(first, rest[0], reading, (inner) => `concat(${inner}, \u2026)`);
|
|
12904
|
+
if (name !== void 0 && KEEPS_START.has(name)) {
|
|
12905
|
+
const inner = patternStart(first, reading);
|
|
12906
|
+
return inner && { ...inner, shape: `${name}(${inner.shape}${rest.length > 0 ? ", \u2026" : ""})` };
|
|
12907
|
+
}
|
|
12908
|
+
return void 0;
|
|
12909
|
+
}
|
|
12910
|
+
function startOfSum(left, right, reading, shapeOf) {
|
|
12911
|
+
const first = patternStart(left, reading);
|
|
12912
|
+
if (first === void 0) return void 0;
|
|
12913
|
+
if (first.text !== "") return { ...first, shape: shapeOf(first.shape) };
|
|
12914
|
+
const next = right === void 0 ? void 0 : patternStart(right, reading);
|
|
12915
|
+
return next && { ...next, shape: shapeOf(first.shape) };
|
|
12916
|
+
}
|
|
12917
|
+
function operatorOf(operation) {
|
|
12918
|
+
const name = bodyOf(operation.name?.at(-1), "String")?.sval;
|
|
12919
|
+
return typeof name === "string" ? name : void 0;
|
|
12920
|
+
}
|
|
12921
|
+
function functionName(call) {
|
|
12922
|
+
const name = bodyOf(call.funcname?.at(-1), "String")?.sval;
|
|
12923
|
+
return typeof name === "string" ? name : void 0;
|
|
12924
|
+
}
|
|
12925
|
+
function tableOf(expression, reading) {
|
|
12926
|
+
const byName = /* @__PURE__ */ new Map();
|
|
12927
|
+
for (const node of pgNodes(reading.statements)) {
|
|
12928
|
+
const range = bodyOf(node, "RangeVar");
|
|
12929
|
+
if (!range || typeof range.relname !== "string") continue;
|
|
12930
|
+
if (typeof range.location !== "number" || !reading.own(range.location)) continue;
|
|
12931
|
+
const alias = range.alias?.aliasname;
|
|
12932
|
+
const name = typeof alias === "string" ? alias : range.relname;
|
|
12933
|
+
byName.set(name, /* @__PURE__ */ new Set([...byName.get(name) ?? [], range.relname]));
|
|
12934
|
+
}
|
|
12935
|
+
const qualifiers = [...qualifiersUnder(expression)];
|
|
12936
|
+
if (qualifiers.length > 1) return void 0;
|
|
12937
|
+
const tables = qualifiers.length === 1 ? [...byName.get(qualifiers[0] ?? "") ?? []] : [...new Set([...byName.values()].flatMap((names) => [...names]))];
|
|
12938
|
+
return tables.length === 1 ? tables[0] : void 0;
|
|
12939
|
+
}
|
|
12940
|
+
function served(indexes, expression, table) {
|
|
12941
|
+
return indexes.some(
|
|
12942
|
+
(index) => index.expression === expression && (table === void 0 || index.table === table)
|
|
12943
|
+
);
|
|
12944
|
+
}
|
|
12945
|
+
function hitOf(like, context2) {
|
|
12946
|
+
const { pattern, operator, expression, table } = like;
|
|
12947
|
+
const bound = pattern.bound === void 0 ? "" : ` (the TypeScript binds \`${pattern.text}\u2026\` to $${pattern.bound})`;
|
|
12948
|
+
const on = `\`${expression}\`${table === void 0 ? "" : ` of \`${table}\``}`;
|
|
12949
|
+
const read2 = context2.indexesFrom.length === 0 ? "the module's own" : `the module's and those of ${context2.indexesFrom.map((folder) => `\`${folder}\``).join(", ")}`;
|
|
12769
12950
|
return {
|
|
12770
|
-
location,
|
|
12771
|
-
message: `the pattern
|
|
12951
|
+
location: like.location,
|
|
12952
|
+
message: `the pattern ${pattern.shape} starts with a wildcard${bound}: no B-tree index can serve this ${operator}, and no trigram index on ${on} is in the migrations read (${read2}; an index created by hand in the database is not seen), so every row is read`
|
|
12772
12953
|
};
|
|
12773
12954
|
}
|
|
12774
12955
|
|
|
@@ -13809,6 +13990,103 @@ function migrationsInNested(cwd, settings = defaults3, nested = adoptedInnerDirs
|
|
|
13809
13990
|
return out.sort((a, b) => a.dir.localeCompare(b.dir));
|
|
13810
13991
|
}
|
|
13811
13992
|
|
|
13993
|
+
// src/roles/sql/trigram-indexes.ts
|
|
13994
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync23 } from "node:fs";
|
|
13995
|
+
import { join as join44 } from "node:path";
|
|
13996
|
+
var TRIGRAM_CLASSES = /* @__PURE__ */ new Set(["gin_trgm_ops", "gist_trgm_ops"]);
|
|
13997
|
+
function trigramContext(cwd, own, indexesFrom) {
|
|
13998
|
+
let indexes;
|
|
13999
|
+
return {
|
|
14000
|
+
indexesFrom,
|
|
14001
|
+
trigramIndexes: () => {
|
|
14002
|
+
indexes ??= trigramIndexesOf([
|
|
14003
|
+
...own.flatMap((file) => readable(cwd, file)),
|
|
14004
|
+
...indexesFrom.flatMap(
|
|
14005
|
+
(folder) => migrationsIn(join44(cwd, folder)).flatMap(
|
|
14006
|
+
(name) => readable(cwd, `${folder}/${name}/migration.sql`)
|
|
14007
|
+
)
|
|
14008
|
+
)
|
|
14009
|
+
]);
|
|
14010
|
+
return indexes;
|
|
14011
|
+
}
|
|
14012
|
+
};
|
|
14013
|
+
}
|
|
14014
|
+
function migrationsIn(directory) {
|
|
14015
|
+
try {
|
|
14016
|
+
return readdirSync5(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
14017
|
+
} catch {
|
|
14018
|
+
return [];
|
|
14019
|
+
}
|
|
14020
|
+
}
|
|
14021
|
+
function readable(cwd, file) {
|
|
14022
|
+
try {
|
|
14023
|
+
return [{ file, text: readFileSync23(join44(cwd, file), "utf8") }];
|
|
14024
|
+
} catch {
|
|
14025
|
+
return [];
|
|
14026
|
+
}
|
|
14027
|
+
}
|
|
14028
|
+
function trigramIndexesOf(migrations) {
|
|
14029
|
+
let indexes = [];
|
|
14030
|
+
for (const { file, text } of migrations) {
|
|
14031
|
+
const parsed2 = parseSql(text);
|
|
14032
|
+
if (!parsed2.ok) continue;
|
|
14033
|
+
for (const statement of parsed2.statements) indexes = applied(indexes, statement, file);
|
|
14034
|
+
}
|
|
14035
|
+
return indexes;
|
|
14036
|
+
}
|
|
14037
|
+
function applied(indexes, statement, file) {
|
|
14038
|
+
const created = bodyOf(statement, "IndexStmt");
|
|
14039
|
+
if (created) return [...indexes, ...indexesOf(created, file)];
|
|
14040
|
+
const dropped = bodyOf(statement, "DropStmt");
|
|
14041
|
+
if (dropped) return withoutDropped(indexes, dropped);
|
|
14042
|
+
const renamed3 = bodyOf(statement, "RenameStmt");
|
|
14043
|
+
if (renamed3) return withRenamed(indexes, renamed3);
|
|
14044
|
+
return indexes;
|
|
14045
|
+
}
|
|
14046
|
+
function indexesOf(index, file) {
|
|
14047
|
+
const table = index.relation?.relname;
|
|
14048
|
+
if (typeof table !== "string") return [];
|
|
14049
|
+
const name = typeof index.idxname === "string" ? index.idxname : void 0;
|
|
14050
|
+
return (index.indexParams ?? []).flatMap((param) => {
|
|
14051
|
+
const element = bodyOf(param, "IndexElem");
|
|
14052
|
+
if (!element || !isTrigram(element)) return [];
|
|
14053
|
+
const expression = typeof element.name === "string" ? element.name : expressionKey(element.expr);
|
|
14054
|
+
return expression === void 0 ? [] : [{ name, table, expression, file }];
|
|
14055
|
+
});
|
|
14056
|
+
}
|
|
14057
|
+
function isTrigram(element) {
|
|
14058
|
+
const classes = element.opclass ?? [];
|
|
14059
|
+
const name = bodyOf(classes.at(-1), "String")?.sval;
|
|
14060
|
+
return typeof name === "string" && TRIGRAM_CLASSES.has(name);
|
|
14061
|
+
}
|
|
14062
|
+
function withoutDropped(indexes, drop) {
|
|
14063
|
+
const names = (drop.objects ?? []).flatMap((object) => {
|
|
14064
|
+
const items = bodyOf(object, "List")?.items ?? [];
|
|
14065
|
+
const last = bodyOf(items.at(-1), "String")?.sval;
|
|
14066
|
+
return typeof last === "string" ? [last] : [];
|
|
14067
|
+
});
|
|
14068
|
+
if (drop.removeType === "OBJECT_INDEX")
|
|
14069
|
+
return indexes.filter((index) => !names.includes(index.name ?? ""));
|
|
14070
|
+
if (drop.removeType === "OBJECT_TABLE")
|
|
14071
|
+
return indexes.filter((index) => !names.includes(index.table));
|
|
14072
|
+
return indexes;
|
|
14073
|
+
}
|
|
14074
|
+
function withRenamed(indexes, rename) {
|
|
14075
|
+
const from = rename.relation?.relname;
|
|
14076
|
+
const to = rename.newname;
|
|
14077
|
+
if (typeof from !== "string" || typeof to !== "string") return indexes;
|
|
14078
|
+
if (rename.renameType === "OBJECT_INDEX")
|
|
14079
|
+
return indexes.map((index) => index.name === from ? { ...index, name: to } : index);
|
|
14080
|
+
if (rename.renameType === "OBJECT_TABLE")
|
|
14081
|
+
return indexes.map((index) => index.table === from ? { ...index, table: to } : index);
|
|
14082
|
+
if (rename.renameType === "OBJECT_COLUMN") {
|
|
14083
|
+
return indexes.map(
|
|
14084
|
+
(index) => index.table === from && index.expression === rename.subname ? { ...index, expression: to } : index
|
|
14085
|
+
);
|
|
14086
|
+
}
|
|
14087
|
+
return indexes;
|
|
14088
|
+
}
|
|
14089
|
+
|
|
13812
14090
|
// src/roles/sql/adapters/squawk/resolve-squawk.ts
|
|
13813
14091
|
function resolveSquawk(cwd) {
|
|
13814
14092
|
return resolveBin(cwd, "squawk") ?? binFromOwnInstall("squawk-cli", "squawk");
|
|
@@ -13819,9 +14097,9 @@ function squawkNotFound(cwd) {
|
|
|
13819
14097
|
|
|
13820
14098
|
// src/roles/sql/adapters/squawk/run-squawk.ts
|
|
13821
14099
|
import { spawnSync as spawnSync12 } from "node:child_process";
|
|
13822
|
-
import { mkdtempSync as mkdtempSync4, readFileSync as
|
|
14100
|
+
import { mkdtempSync as mkdtempSync4, readFileSync as readFileSync24, rmSync as rmSync6, writeFileSync as writeFileSync12 } from "node:fs";
|
|
13823
14101
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
13824
|
-
import { join as
|
|
14102
|
+
import { join as join46 } from "node:path";
|
|
13825
14103
|
|
|
13826
14104
|
// src/roles/sql/adapters/squawk/read-output.ts
|
|
13827
14105
|
function readSquawkOutput(stdout, stderr) {
|
|
@@ -13879,7 +14157,7 @@ function toFinding(entry) {
|
|
|
13879
14157
|
// src/roles/sql/adapters/squawk/squawk-config.ts
|
|
13880
14158
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "node:fs";
|
|
13881
14159
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
13882
|
-
import { join as
|
|
14160
|
+
import { join as join45 } from "node:path";
|
|
13883
14161
|
function squawkToml(settings) {
|
|
13884
14162
|
const squawks = (rule) => !NOT_SQUAWK_CONFIG.includes(rule);
|
|
13885
14163
|
const off = rulesOff(settings.rules ?? {}).filter(squawks);
|
|
@@ -13893,9 +14171,9 @@ function squawkToml(settings) {
|
|
|
13893
14171
|
].join("\n");
|
|
13894
14172
|
}
|
|
13895
14173
|
function withSquawkConfig(settings, use) {
|
|
13896
|
-
const dir = mkdtempSync3(
|
|
14174
|
+
const dir = mkdtempSync3(join45(tmpdir3(), "sentinel-squawk-"));
|
|
13897
14175
|
try {
|
|
13898
|
-
const configPath =
|
|
14176
|
+
const configPath = join45(dir, "squawk.toml");
|
|
13899
14177
|
writeFileSync11(configPath, squawkToml(settings));
|
|
13900
14178
|
return use(configPath);
|
|
13901
14179
|
} finally {
|
|
@@ -13943,14 +14221,14 @@ var BATCH_FILES = 200;
|
|
|
13943
14221
|
var BATCH_CHARACTERS = 2e4;
|
|
13944
14222
|
var OUTPUT_BUFFER = 64 * 1024 * 1024;
|
|
13945
14223
|
function runSquawk(invocation, files) {
|
|
13946
|
-
const { readable, unread } = openable(invocation.cwd, files);
|
|
13947
|
-
const statements = statementsOf(invocation,
|
|
14224
|
+
const { readable: readable2, unread } = openable(invocation.cwd, files);
|
|
14225
|
+
const statements = statementsOf(invocation, readable2);
|
|
13948
14226
|
const wrapped = (file) => (statements.get(file)?.count ?? 0) > 1;
|
|
13949
14227
|
const quietNesting = (file) => !invocation.reportNesting && statements.get(file)?.ownTransaction === "paired";
|
|
13950
14228
|
const findings = [];
|
|
13951
14229
|
for (const [list, inTransaction] of [
|
|
13952
|
-
[
|
|
13953
|
-
[
|
|
14230
|
+
[readable2.filter((file) => !wrapped(file)), false],
|
|
14231
|
+
[readable2.filter(wrapped), true]
|
|
13954
14232
|
]) {
|
|
13955
14233
|
for (const batch of batches(list)) {
|
|
13956
14234
|
const reading = runBatch(invocation, batch, inTransaction);
|
|
@@ -13962,18 +14240,18 @@ function runSquawk(invocation, files) {
|
|
|
13962
14240
|
);
|
|
13963
14241
|
}
|
|
13964
14242
|
}
|
|
13965
|
-
const quietTimeouts = quietTimeoutFiles(invocation,
|
|
14243
|
+
const quietTimeouts = quietTimeoutFiles(invocation, readable2, statements, wrapped);
|
|
13966
14244
|
const kept = findings.filter(
|
|
13967
14245
|
(finding3) => !(TIMEOUTS.has(finding3.rule) && quietTimeouts.has(finding3.file))
|
|
13968
14246
|
);
|
|
13969
|
-
const order = new Map(
|
|
14247
|
+
const order = new Map(readable2.map((file, index) => [file, index]));
|
|
13970
14248
|
kept.sort((a, b) => (order.get(a.file) ?? 0) - (order.get(b.file) ?? 0));
|
|
13971
14249
|
const statementCounts = new Map([...statements].map(([file, read2]) => [file, read2.count]));
|
|
13972
14250
|
return { ok: true, findings: kept, unread, statementCounts };
|
|
13973
14251
|
}
|
|
13974
|
-
function quietTimeoutFiles(invocation,
|
|
14252
|
+
function quietTimeoutFiles(invocation, readable2, statements, wrapped) {
|
|
13975
14253
|
const texts = /* @__PURE__ */ new Map();
|
|
13976
|
-
for (const file of
|
|
14254
|
+
for (const file of readable2) {
|
|
13977
14255
|
const read2 = statements.get(file);
|
|
13978
14256
|
if (read2 === void 0 || !wrapped(file)) continue;
|
|
13979
14257
|
const text = readText(invocation.cwd, file);
|
|
@@ -13985,9 +14263,9 @@ function quietTimeoutFiles(invocation, readable, statements, wrapped) {
|
|
|
13985
14263
|
return new Set([...texts.keys()].filter((file) => !onExisting.has(file)));
|
|
13986
14264
|
}
|
|
13987
14265
|
function indexesOnExistingTables(invocation, files) {
|
|
13988
|
-
const dir = mkdtempSync4(
|
|
14266
|
+
const dir = mkdtempSync4(join46(tmpdir4(), "sentinel-squawk-"));
|
|
13989
14267
|
try {
|
|
13990
|
-
const configPath =
|
|
14268
|
+
const configPath = join46(dir, "squawk.toml");
|
|
13991
14269
|
writeFileSync12(configPath, DEFAULT_SQUAWK_TOML);
|
|
13992
14270
|
const found = /* @__PURE__ */ new Set();
|
|
13993
14271
|
for (const batch of batches(files)) {
|
|
@@ -14003,7 +14281,7 @@ function indexesOnExistingTables(invocation, files) {
|
|
|
14003
14281
|
}
|
|
14004
14282
|
function readText(cwd, file) {
|
|
14005
14283
|
try {
|
|
14006
|
-
return
|
|
14284
|
+
return readFileSync24(join46(cwd, file), "utf8");
|
|
14007
14285
|
} catch {
|
|
14008
14286
|
return void 0;
|
|
14009
14287
|
}
|
|
@@ -14080,18 +14358,18 @@ function jsonObjects(text) {
|
|
|
14080
14358
|
return depth === 0 ? objects : void 0;
|
|
14081
14359
|
}
|
|
14082
14360
|
function openable(cwd, files) {
|
|
14083
|
-
const
|
|
14361
|
+
const readable2 = [];
|
|
14084
14362
|
const unread = [];
|
|
14085
14363
|
const utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
14086
14364
|
for (const file of files) {
|
|
14087
14365
|
try {
|
|
14088
|
-
utf8.decode(
|
|
14089
|
-
|
|
14366
|
+
utf8.decode(readFileSync24(join46(cwd, file)));
|
|
14367
|
+
readable2.push(file);
|
|
14090
14368
|
} catch (error) {
|
|
14091
14369
|
unread.push({ file, reason: unreadReason(error) });
|
|
14092
14370
|
}
|
|
14093
14371
|
}
|
|
14094
|
-
return { readable, unread };
|
|
14372
|
+
return { readable: readable2, unread };
|
|
14095
14373
|
}
|
|
14096
14374
|
function unreadReason(error) {
|
|
14097
14375
|
const code = error?.code;
|
|
@@ -14248,7 +14526,7 @@ var SquawkAdapter = class extends BaseAdapter {
|
|
|
14248
14526
|
skipped: `no migration (${defaults3.migrations.include.join(", ")}) and no raw SQL call in this module: nothing for the ${TARGET3} role to read.`
|
|
14249
14527
|
};
|
|
14250
14528
|
}
|
|
14251
|
-
const hasConfig = existsSync29(
|
|
14529
|
+
const hasConfig = existsSync29(join47(context2.cwd, SQL_CONFIG_FILE));
|
|
14252
14530
|
const declared = moduleScripts(context2.cwd);
|
|
14253
14531
|
const missingScripts = Object.keys(scripts2()).filter((name) => !(name in declared));
|
|
14254
14532
|
return {
|
|
@@ -14359,7 +14637,8 @@ var SquawkAdapter = class extends BaseAdapter {
|
|
|
14359
14637
|
ctx.cwd,
|
|
14360
14638
|
templateCode,
|
|
14361
14639
|
readAbsolute,
|
|
14362
|
-
templateRules(config.rules)
|
|
14640
|
+
templateRules(config.rules),
|
|
14641
|
+
trigramContext(ctx.cwd, reading.migrations, config.migrations.indexesFrom)
|
|
14363
14642
|
);
|
|
14364
14643
|
const findings = withNotes(
|
|
14365
14644
|
[
|
|
@@ -14392,7 +14671,7 @@ var SquawkAdapter = class extends BaseAdapter {
|
|
|
14392
14671
|
if (mode.speaking) {
|
|
14393
14672
|
for (const line of describeRun(outcome, reading, config, selection.quietNote)) this.say(line);
|
|
14394
14673
|
for (const dir of reading.nested) {
|
|
14395
|
-
const count = migrationFiles(
|
|
14674
|
+
const count = migrationFiles(join47(ctx.cwd, dir), defaults3).length;
|
|
14396
14675
|
if (count > 0)
|
|
14397
14676
|
this.say(
|
|
14398
14677
|
`the ${count} migration(s) under ${dir} are reported by that project, which adopted the role itself.`
|
|
@@ -14470,7 +14749,7 @@ var SquawkAdapter = class extends BaseAdapter {
|
|
|
14470
14749
|
const expected = Object.keys(scripts2());
|
|
14471
14750
|
const missing = expected.filter((name) => !(name in declared));
|
|
14472
14751
|
const adopted = missing.length < expected.length;
|
|
14473
|
-
const hasConfig = existsSync29(
|
|
14752
|
+
const hasConfig = existsSync29(join47(ctx.cwd, SQL_CONFIG_FILE));
|
|
14474
14753
|
return {
|
|
14475
14754
|
adopted,
|
|
14476
14755
|
preset: adopted ? ctx.preset : null,
|
|
@@ -14672,14 +14951,14 @@ function reportOf(ctx, config, files, result) {
|
|
|
14672
14951
|
}
|
|
14673
14952
|
function readAbsolute(path2) {
|
|
14674
14953
|
try {
|
|
14675
|
-
return
|
|
14954
|
+
return readFileSync25(path2, "utf8");
|
|
14676
14955
|
} catch {
|
|
14677
14956
|
return void 0;
|
|
14678
14957
|
}
|
|
14679
14958
|
}
|
|
14680
14959
|
function readText2(cwd, file) {
|
|
14681
14960
|
try {
|
|
14682
|
-
return
|
|
14961
|
+
return readFileSync25(join47(cwd, file), "utf8");
|
|
14683
14962
|
} catch {
|
|
14684
14963
|
return void 0;
|
|
14685
14964
|
}
|
|
@@ -14724,8 +15003,8 @@ function registerSql() {
|
|
|
14724
15003
|
|
|
14725
15004
|
// src/roles/static-analysis/adapters/jscpd/jscpd.adapter.ts
|
|
14726
15005
|
import { spawnSync as spawnSync15 } from "node:child_process";
|
|
14727
|
-
import { existsSync as existsSync33, mkdirSync as mkdirSync7, readFileSync as
|
|
14728
|
-
import { join as
|
|
15006
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync7, readFileSync as readFileSync29, unlinkSync as unlinkSync4, writeFileSync as writeFileSync14 } from "node:fs";
|
|
15007
|
+
import { join as join52, relative as relative9, sep as sep6 } from "node:path";
|
|
14729
15008
|
import { globSync as globSync8 } from "tinyglobby";
|
|
14730
15009
|
|
|
14731
15010
|
// src/roles/static-analysis/bundle/budgets.ts
|
|
@@ -14754,21 +15033,21 @@ function bandFor(valueKb, referenceKb) {
|
|
|
14754
15033
|
}
|
|
14755
15034
|
|
|
14756
15035
|
// src/roles/static-analysis/bundle/scan.ts
|
|
14757
|
-
import { existsSync as existsSync31, readFileSync as
|
|
14758
|
-
import { basename as basename4, join as
|
|
15036
|
+
import { existsSync as existsSync31, readFileSync as readFileSync27 } from "node:fs";
|
|
15037
|
+
import { basename as basename4, join as join49 } from "node:path";
|
|
14759
15038
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
14760
15039
|
import { gzipSync } from "node:zlib";
|
|
14761
15040
|
import { globSync as globSync6 } from "tinyglobby";
|
|
14762
15041
|
|
|
14763
15042
|
// src/roles/static-analysis/bundle/find-build.ts
|
|
14764
|
-
import { existsSync as existsSync30, readFileSync as
|
|
14765
|
-
import { join as
|
|
15043
|
+
import { existsSync as existsSync30, readFileSync as readFileSync26, statSync as statSync7 } from "node:fs";
|
|
15044
|
+
import { join as join48 } from "node:path";
|
|
14766
15045
|
import { globSync as globSync5 } from "tinyglobby";
|
|
14767
15046
|
var MANIFEST_GLOB = "server/_tanstack-start-manifest*.mjs";
|
|
14768
15047
|
function candidateDirs(cwd) {
|
|
14769
15048
|
const declared = readProjectPackageJson(cwd).nx?.targets?.build?.["outputs"];
|
|
14770
|
-
const fromDeclaration = Array.isArray(declared) ? declared.filter((token) => typeof token === "string").map((token) =>
|
|
14771
|
-
return [...fromDeclaration,
|
|
15049
|
+
const fromDeclaration = Array.isArray(declared) ? declared.filter((token) => typeof token === "string").map((token) => join48(cwd, token.replace(/^\{projectRoot\}\//, ""))) : [];
|
|
15050
|
+
return [...fromDeclaration, join48(cwd, ".output"), join48(cwd, "dist"), join48(cwd, "build")];
|
|
14772
15051
|
}
|
|
14773
15052
|
function findBuildOutput(cwd) {
|
|
14774
15053
|
const lookedIn = [];
|
|
@@ -14778,7 +15057,7 @@ function findBuildOutput(cwd) {
|
|
|
14778
15057
|
const found = globSync5(MANIFEST_GLOB, { cwd: dir, absolute: true, dot: false });
|
|
14779
15058
|
if (found.length === 0) continue;
|
|
14780
15059
|
const manifestPath = found[0];
|
|
14781
|
-
const publicDir =
|
|
15060
|
+
const publicDir = join48(dir, "public");
|
|
14782
15061
|
if (!existsSync30(publicDir)) continue;
|
|
14783
15062
|
return { manifestPath, publicDir, ...dateOf(dir, manifestPath) };
|
|
14784
15063
|
}
|
|
@@ -14801,10 +15080,10 @@ function findBuildOutput(cwd) {
|
|
|
14801
15080
|
};
|
|
14802
15081
|
}
|
|
14803
15082
|
function dateOf(dir, manifestPath) {
|
|
14804
|
-
const record =
|
|
15083
|
+
const record = join48(dir, "nitro.json");
|
|
14805
15084
|
if (existsSync30(record)) {
|
|
14806
15085
|
try {
|
|
14807
|
-
const parsed2 = JSON.parse(
|
|
15086
|
+
const parsed2 = JSON.parse(readFileSync26(record, "utf8"));
|
|
14808
15087
|
if (typeof parsed2.date === "string") {
|
|
14809
15088
|
const date = new Date(parsed2.date);
|
|
14810
15089
|
if (!Number.isNaN(date.getTime())) return { builtAt: date, builtAtFrom: "build record" };
|
|
@@ -14830,9 +15109,9 @@ function kindOf3(path2) {
|
|
|
14830
15109
|
return "other";
|
|
14831
15110
|
}
|
|
14832
15111
|
function resolveAnnounced(publicDir, announced) {
|
|
14833
|
-
const direct =
|
|
15112
|
+
const direct = join49(publicDir, announced);
|
|
14834
15113
|
if (existsSync31(direct)) return direct;
|
|
14835
|
-
const stripped =
|
|
15114
|
+
const stripped = join49(publicDir, announced.replace(/^\/[^/]+\//, "/"));
|
|
14836
15115
|
return existsSync31(stripped) ? stripped : void 0;
|
|
14837
15116
|
}
|
|
14838
15117
|
function emptyWeight() {
|
|
@@ -14869,7 +15148,7 @@ async function scanBundle(cwd) {
|
|
|
14869
15148
|
unresolved.push(announced);
|
|
14870
15149
|
measured.set(announced, void 0);
|
|
14871
15150
|
} else {
|
|
14872
|
-
const buffer =
|
|
15151
|
+
const buffer = readFileSync27(path2);
|
|
14873
15152
|
measured.set(announced, {
|
|
14874
15153
|
parsed: buffer.length,
|
|
14875
15154
|
transfer: gzipSync(buffer, { level: 9 }).length
|
|
@@ -14956,7 +15235,7 @@ function scanDynamicLayer(publicDir, references) {
|
|
|
14956
15235
|
})) {
|
|
14957
15236
|
const name = basename4(path2);
|
|
14958
15237
|
if (referenced.has(name)) continue;
|
|
14959
|
-
const buffer =
|
|
15238
|
+
const buffer = readFileSync27(path2);
|
|
14960
15239
|
const size = { parsed: buffer.length, transfer: gzipSync(buffer, { level: 9 }).length };
|
|
14961
15240
|
add(all2, size);
|
|
14962
15241
|
const group = groupOf(name);
|
|
@@ -15024,10 +15303,10 @@ function hasUnreadableCode(coverage) {
|
|
|
15024
15303
|
}
|
|
15025
15304
|
function coverageOf(cwd, config) {
|
|
15026
15305
|
const ignore = exclusions(config, "product");
|
|
15027
|
-
const
|
|
15306
|
+
const readable2 = extensionsOf(config.languages).map((extension) => extension.slice(1)).join(",");
|
|
15028
15307
|
const roots = measuredRoots(cwd);
|
|
15029
15308
|
const under2 = (extensions) => roots.map((root) => root === "." ? `**/*.{${extensions}}` : `${root}/**/*.{${extensions}}`);
|
|
15030
|
-
const read2 =
|
|
15309
|
+
const read2 = readable2 ? globSync7(under2(readable2), { cwd, ignore, dot: false }).length : 0;
|
|
15031
15310
|
const unreadable = UNREADABLE_EXTENSIONS.map((extension) => extension.slice(1)).join(",");
|
|
15032
15311
|
const found = globSync7(under2(unreadable), { cwd, ignore, dot: false });
|
|
15033
15312
|
const total = read2 + found.length;
|
|
@@ -15048,7 +15327,7 @@ function unreadableNote(coverage) {
|
|
|
15048
15327
|
import { spawnSync as spawnSync14 } from "node:child_process";
|
|
15049
15328
|
import { existsSync as existsSync32, mkdirSync as mkdirSync6, mkdtempSync as mkdtempSync5, rmSync as rmSync7, writeFileSync as writeFileSync13 } from "node:fs";
|
|
15050
15329
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
15051
|
-
import { join as
|
|
15330
|
+
import { join as join50 } from "node:path";
|
|
15052
15331
|
var ROOT_FILES = ["nx.json", "tsconfig.base.json"];
|
|
15053
15332
|
function git5(cwd, args) {
|
|
15054
15333
|
const run = spawnSync14("git", args, { cwd, encoding: "utf8", maxBuffer: 256 * 1024 * 1024 });
|
|
@@ -15074,9 +15353,9 @@ function checkoutModuleAt(workspaceRoot, modulePath, sha) {
|
|
|
15074
15353
|
if (!listed.ok) return { ok: false, reason: `git could not list the base: ${listed.said}` };
|
|
15075
15354
|
const present = new Set(listed.out.split("\n").filter((line) => line !== ""));
|
|
15076
15355
|
const existed = present.has(modulePath);
|
|
15077
|
-
const root = mkdtempSync5(
|
|
15356
|
+
const root = mkdtempSync5(join50(tmpdir5(), "sentinel-static-base-"));
|
|
15078
15357
|
const dispose = () => rmSync7(root, { recursive: true, force: true });
|
|
15079
|
-
const moduleDir =
|
|
15358
|
+
const moduleDir = join50(root, modulePath);
|
|
15080
15359
|
mkdirSync6(moduleDir, { recursive: true });
|
|
15081
15360
|
const paths2 = [
|
|
15082
15361
|
...ROOT_FILES.filter((file) => present.has(file)),
|
|
@@ -15103,7 +15382,7 @@ function checkoutModuleAt(workspaceRoot, modulePath, sha) {
|
|
|
15103
15382
|
};
|
|
15104
15383
|
}
|
|
15105
15384
|
}
|
|
15106
|
-
if (!existsSync32(
|
|
15385
|
+
if (!existsSync32(join50(root, "nx.json"))) writeFileSync13(join50(root, "nx.json"), "{}\n");
|
|
15107
15386
|
return { ok: true, moduleDir, existed, dispose };
|
|
15108
15387
|
}
|
|
15109
15388
|
|
|
@@ -15200,8 +15479,8 @@ function comparePlaces(branch, base, renames) {
|
|
|
15200
15479
|
}
|
|
15201
15480
|
|
|
15202
15481
|
// src/roles/static-analysis/excerpt.ts
|
|
15203
|
-
import { readFileSync as
|
|
15204
|
-
import { join as
|
|
15482
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
15483
|
+
import { join as join51 } from "node:path";
|
|
15205
15484
|
var WINDOW = { lines: 10, nesting: { before: 3, after: 6 } };
|
|
15206
15485
|
var NESTS_UPWARD = /* @__PURE__ */ new Set(["max-depth", "max-nested-callbacks"]);
|
|
15207
15486
|
var SHOWS_THE_HEAD = /* @__PURE__ */ new Set(["max-lines"]);
|
|
@@ -15210,7 +15489,7 @@ function linesOf(cache, cwd, relative10) {
|
|
|
15210
15489
|
if (cache.has(relative10)) return cache.get(relative10);
|
|
15211
15490
|
let lines;
|
|
15212
15491
|
try {
|
|
15213
|
-
lines =
|
|
15492
|
+
lines = readFileSync28(join51(cwd, relative10), "utf8").split("\n");
|
|
15214
15493
|
} catch {
|
|
15215
15494
|
lines = void 0;
|
|
15216
15495
|
}
|
|
@@ -15528,7 +15807,7 @@ var JscpdAdapter = class extends BaseAdapter {
|
|
|
15528
15807
|
operations: [
|
|
15529
15808
|
// `write` and not `merge-json`: this file is code, and the engine's in-place merge is for
|
|
15530
15809
|
// JSON. A re-init therefore RESTORES the stub, so an existing one is left alone below.
|
|
15531
|
-
...existsSync33(
|
|
15810
|
+
...existsSync33(join52(context2.cwd, STATIC_CONFIG_FILE)) ? [] : [{ kind: "write", path: STATIC_CONFIG_FILE, contents: configStub4() }],
|
|
15532
15811
|
manifestOperation(context2.cwd, scripts3()),
|
|
15533
15812
|
...nxTargetOperations({ cwd: context2.cwd, targets: targets3() })
|
|
15534
15813
|
// The report directory is ignored ONCE at the workspace root, by `--init`'s workspace prep,
|
|
@@ -15746,7 +16025,7 @@ var JscpdAdapter = class extends BaseAdapter {
|
|
|
15746
16025
|
const declared = moduleScripts(ctx.cwd);
|
|
15747
16026
|
const missing = Object.keys(scripts3()).filter((name) => !(name in declared));
|
|
15748
16027
|
const adopted = missing.length < Object.keys(scripts3()).length;
|
|
15749
|
-
const hasConfig = existsSync33(
|
|
16028
|
+
const hasConfig = existsSync33(join52(ctx.cwd, STATIC_CONFIG_FILE));
|
|
15750
16029
|
return {
|
|
15751
16030
|
adopted,
|
|
15752
16031
|
preset: adopted ? ctx.preset : null,
|
|
@@ -15838,7 +16117,7 @@ function runDeadCode(jscpd, config, paths2, cwd, extraEntries = []) {
|
|
|
15838
16117
|
try {
|
|
15839
16118
|
const ran = runTool(jscpd, args, cwd, "dead-code");
|
|
15840
16119
|
if (ran.kind !== "ran") return ran;
|
|
15841
|
-
const path2 =
|
|
16120
|
+
const path2 = join52(rawReportDir, RAW_REPORT["dead-code"]);
|
|
15842
16121
|
if (!existsSync33(path2)) {
|
|
15843
16122
|
process.stderr.write(
|
|
15844
16123
|
`sentinel static-analysis(jscpd): the dead-code pass wrote no ${RAW_REPORT["dead-code"]}
|
|
@@ -15846,7 +16125,7 @@ function runDeadCode(jscpd, config, paths2, cwd, extraEntries = []) {
|
|
|
15846
16125
|
);
|
|
15847
16126
|
return { kind: "failed", code: 1 };
|
|
15848
16127
|
}
|
|
15849
|
-
const parsed2 = safeParseDeadCode(
|
|
16128
|
+
const parsed2 = safeParseDeadCode(readFileSync29(path2, "utf8"));
|
|
15850
16129
|
const statistics = parsed2?.statistics;
|
|
15851
16130
|
if (!statistics) {
|
|
15852
16131
|
process.stderr.write(
|
|
@@ -15869,11 +16148,11 @@ function runDeadCode(jscpd, config, paths2, cwd, extraEntries = []) {
|
|
|
15869
16148
|
}
|
|
15870
16149
|
}
|
|
15871
16150
|
function moduleRelative(name, roots, cwd) {
|
|
15872
|
-
if (existsSync33(
|
|
16151
|
+
if (existsSync33(join52(cwd, name))) return name;
|
|
15873
16152
|
for (const root of roots) {
|
|
15874
16153
|
if (root === ".") continue;
|
|
15875
16154
|
const candidate = `${root}/${name}`;
|
|
15876
|
-
if (existsSync33(
|
|
16155
|
+
if (existsSync33(join52(cwd, candidate))) return candidate;
|
|
15877
16156
|
}
|
|
15878
16157
|
return name;
|
|
15879
16158
|
}
|
|
@@ -15882,8 +16161,8 @@ function runDuplication(jscpd, config, paths2, scope, cwd) {
|
|
|
15882
16161
|
try {
|
|
15883
16162
|
const ran = runTool(jscpd, args, cwd, scope);
|
|
15884
16163
|
if (ran.kind !== "ran") return ran;
|
|
15885
|
-
const path2 =
|
|
15886
|
-
const parsed2 = existsSync33(path2) ? safeParse(
|
|
16164
|
+
const path2 = join52(rawReportDir, RAW_REPORT.duplication);
|
|
16165
|
+
const parsed2 = existsSync33(path2) ? safeParse(readFileSync29(path2, "utf8")) : void 0;
|
|
15887
16166
|
const total = parsed2?.statistics?.total;
|
|
15888
16167
|
if (!total) {
|
|
15889
16168
|
process.stderr.write(
|
|
@@ -16171,7 +16450,7 @@ function moduleRenames(cwd, renames) {
|
|
|
16171
16450
|
function moduleRootsOf(workspaceRoot) {
|
|
16172
16451
|
const roots = [];
|
|
16173
16452
|
for (const area of ["apps", "libs"]) {
|
|
16174
|
-
const base =
|
|
16453
|
+
const base = join52(workspaceRoot, area);
|
|
16175
16454
|
if (!existsSync33(base)) continue;
|
|
16176
16455
|
for (const entry of globSync8([`${area}/**/package.json`, `${area}/**/project.json`], {
|
|
16177
16456
|
cwd: workspaceRoot,
|
|
@@ -16514,7 +16793,7 @@ var PICTURE_FILE = `${TARGET}-graph.svg`;
|
|
|
16514
16793
|
function clearStaleOutputs(cwd, keeping) {
|
|
16515
16794
|
for (const name of [...Object.values(SHAPE_FILE4), PICTURE_FILE]) {
|
|
16516
16795
|
if (keeping.has(name)) continue;
|
|
16517
|
-
const path2 =
|
|
16796
|
+
const path2 = join52(cwd, REPORT_DIR, name);
|
|
16518
16797
|
if (existsSync33(path2)) unlinkSync4(path2);
|
|
16519
16798
|
}
|
|
16520
16799
|
}
|
|
@@ -16533,11 +16812,11 @@ function drawsPicture(graph, coverage) {
|
|
|
16533
16812
|
async function emit(report, shape, cwd, graph, coverage) {
|
|
16534
16813
|
if (shape === "console") return [];
|
|
16535
16814
|
const detailed = shape === "markdown" ? report : withExcerpts(report, cwd);
|
|
16536
|
-
mkdirSync7(
|
|
16815
|
+
mkdirSync7(join52(cwd, REPORT_DIR), { recursive: true });
|
|
16537
16816
|
const written = [];
|
|
16538
16817
|
if (shape === "html" && drawsPicture(graph, coverage)) {
|
|
16539
16818
|
const drawn = layOut(graph.graph, graph.communityOf);
|
|
16540
|
-
const path2 =
|
|
16819
|
+
const path2 = join52(cwd, REPORT_DIR, PICTURE_FILE);
|
|
16541
16820
|
await writeGraphPicture(drawn, path2);
|
|
16542
16821
|
written.push(`${REPORT_DIR}/${PICTURE_FILE}`);
|
|
16543
16822
|
detailed.picture = buildExplorer(drawn, graph.communityOf).markup;
|
|
@@ -16545,7 +16824,7 @@ async function emit(report, shape, cwd, graph, coverage) {
|
|
|
16545
16824
|
const RENDER = { json: renderJson, html: renderHtml, markdown: renderMarkdown };
|
|
16546
16825
|
const name = SHAPE_FILE4[shape] ?? `${TARGET}.${shape}`;
|
|
16547
16826
|
const body = RENDER[shape](detailed);
|
|
16548
|
-
writeFileSync14(
|
|
16827
|
+
writeFileSync14(join52(cwd, REPORT_DIR, name), body, "utf8");
|
|
16549
16828
|
written.unshift(`${REPORT_DIR}/${name}`);
|
|
16550
16829
|
return written;
|
|
16551
16830
|
}
|
|
@@ -16579,9 +16858,9 @@ function registerTest() {
|
|
|
16579
16858
|
|
|
16580
16859
|
// src/roles/typescript/adapters/tsc/tsc.adapter.ts
|
|
16581
16860
|
import { spawnSync as spawnSync16 } from "node:child_process";
|
|
16582
|
-
import { existsSync as existsSync34, readdirSync as
|
|
16861
|
+
import { existsSync as existsSync34, readdirSync as readdirSync6, readFileSync as readFileSync31 } from "node:fs";
|
|
16583
16862
|
import { createRequire } from "node:module";
|
|
16584
|
-
import { join as
|
|
16863
|
+
import { join as join54 } from "node:path";
|
|
16585
16864
|
|
|
16586
16865
|
// src/roles/typescript/config-policy.ts
|
|
16587
16866
|
var PERMITTED_COMPILER_OPTIONS = [
|
|
@@ -16635,11 +16914,11 @@ function standardOverrides(compilerOptions, preset) {
|
|
|
16635
16914
|
}
|
|
16636
16915
|
function legacyCompromises(compilerOptions, preset) {
|
|
16637
16916
|
const stack = preset !== void 0 && hasShippedPreset(preset) ? tsPresetFor(preset).compilerOptions : {};
|
|
16638
|
-
const
|
|
16917
|
+
const applied2 = appliedOptions({ compilerOptions: stack });
|
|
16639
16918
|
return Object.entries(tsLegacyLayer().compilerOptions).filter(
|
|
16640
16919
|
([key]) => !(key in stack) && !(compilerOptions !== void 0 && key in compilerOptions)
|
|
16641
16920
|
).map(([key, value]) => {
|
|
16642
|
-
const standard =
|
|
16921
|
+
const standard = applied2.has(key) ? JSON.parse(applied2.get(key) ?? "null") : null;
|
|
16643
16922
|
return {
|
|
16644
16923
|
rule: key,
|
|
16645
16924
|
value,
|
|
@@ -16694,8 +16973,8 @@ function readTsconfigAdoption(cwd) {
|
|
|
16694
16973
|
}
|
|
16695
16974
|
|
|
16696
16975
|
// src/roles/typescript/adapters/tsc/plan.ts
|
|
16697
|
-
import { readFileSync as
|
|
16698
|
-
import { join as
|
|
16976
|
+
import { readFileSync as readFileSync30 } from "node:fs";
|
|
16977
|
+
import { join as join53 } from "node:path";
|
|
16699
16978
|
|
|
16700
16979
|
// src/roles/typescript/typecheck-script.ts
|
|
16701
16980
|
var SENTINEL_TYPECHECK_COMMAND = "sentinel --run --typescript";
|
|
@@ -16790,7 +17069,7 @@ function planAdoption(context2) {
|
|
|
16790
17069
|
};
|
|
16791
17070
|
}
|
|
16792
17071
|
const existing = parseJsonc(
|
|
16793
|
-
|
|
17072
|
+
readFileSync30(join53(context2.cwd, target.path), "utf8"),
|
|
16794
17073
|
target.path
|
|
16795
17074
|
);
|
|
16796
17075
|
const extendsChain = composeExtends(existing.extends, preset);
|
|
@@ -16850,10 +17129,10 @@ var PHASED_STRICTNESS_WARNING = `sentinel typescript: phase 1 (non-breaking) \u2
|
|
|
16850
17129
|
var TSCONFIG_FILE = /^tsconfig.*\.json$/;
|
|
16851
17130
|
function configStateOf(reason, moduleDir) {
|
|
16852
17131
|
if (reason !== "extends-base") return reason;
|
|
16853
|
-
const onBase =
|
|
17132
|
+
const onBase = readdirSync6(moduleDir).filter((name) => TSCONFIG_FILE.test(name)).some((name) => {
|
|
16854
17133
|
try {
|
|
16855
17134
|
const config = parseJsonc(
|
|
16856
|
-
|
|
17135
|
+
readFileSync31(join54(moduleDir, name), "utf8"),
|
|
16857
17136
|
name
|
|
16858
17137
|
);
|
|
16859
17138
|
return extendsList(config).some(isBaseEntry);
|
|
@@ -16944,7 +17223,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
|
|
|
16944
17223
|
let chain;
|
|
16945
17224
|
try {
|
|
16946
17225
|
const parsed2 = parseJsonc(
|
|
16947
|
-
|
|
17226
|
+
readFileSync31(join54(cwd, target.path), "utf8"),
|
|
16948
17227
|
target.path
|
|
16949
17228
|
);
|
|
16950
17229
|
chain = parsed2.extends;
|
|
@@ -16957,7 +17236,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
|
|
|
16957
17236
|
);
|
|
16958
17237
|
if (preset === void 0) return void 0;
|
|
16959
17238
|
try {
|
|
16960
|
-
createRequire(
|
|
17239
|
+
createRequire(join54(cwd, "noop.js")).resolve(preset);
|
|
16961
17240
|
return void 0;
|
|
16962
17241
|
} catch {
|
|
16963
17242
|
return preset;
|
|
@@ -17053,7 +17332,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
|
|
|
17053
17332
|
referencedProjects(cwd, config) {
|
|
17054
17333
|
try {
|
|
17055
17334
|
const parsed2 = parseJsonc(
|
|
17056
|
-
|
|
17335
|
+
readFileSync31(join54(cwd, config), "utf8"),
|
|
17057
17336
|
config
|
|
17058
17337
|
);
|
|
17059
17338
|
const referenced = (parsed2.references ?? []).map((reference) => reference.path).filter((path2) => typeof path2 === "string" && path2.length > 0);
|
|
@@ -17069,7 +17348,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
|
|
|
17069
17348
|
* check.
|
|
17070
17349
|
*/
|
|
17071
17350
|
typecheckTarget(cwd) {
|
|
17072
|
-
if (existsSync34(
|
|
17351
|
+
if (existsSync34(join54(cwd, "tsconfig.json"))) return "tsconfig.json";
|
|
17073
17352
|
const target = resolveTsconfigTarget(cwd);
|
|
17074
17353
|
return target.reason === "none" ? null : target.path;
|
|
17075
17354
|
}
|
|
@@ -17082,7 +17361,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
|
|
|
17082
17361
|
const target = resolveTsconfigTarget(ctx.cwd);
|
|
17083
17362
|
const { preset } = readTsconfigAdoption(ctx.cwd);
|
|
17084
17363
|
const stack = preset === null ? void 0 : preset.slice(preset.lastIndexOf("/") + 1);
|
|
17085
|
-
const config = this.readConfig(
|
|
17364
|
+
const config = this.readConfig(join54(ctx.cwd, target.path));
|
|
17086
17365
|
const options = config?.compilerOptions;
|
|
17087
17366
|
const overrides = standardOverrides(options, stack);
|
|
17088
17367
|
const legacy = config !== void 0 && extendsList(config).some(isLegacyEntry) ? legacyCompromises(options, stack) : [];
|
|
@@ -17100,7 +17379,7 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
|
|
|
17100
17379
|
readConfig(file) {
|
|
17101
17380
|
if (!existsSync34(file)) return void 0;
|
|
17102
17381
|
try {
|
|
17103
|
-
return parseJsonc(
|
|
17382
|
+
return parseJsonc(readFileSync31(file, "utf8"), file);
|
|
17104
17383
|
} catch {
|
|
17105
17384
|
return void 0;
|
|
17106
17385
|
}
|
|
@@ -17296,7 +17575,7 @@ function replaceLines(current, replacements) {
|
|
|
17296
17575
|
}
|
|
17297
17576
|
|
|
17298
17577
|
// src/core/apply-plan.ts
|
|
17299
|
-
import { existsSync as existsSync35, readFileSync as
|
|
17578
|
+
import { existsSync as existsSync35, readFileSync as readFileSync32, renameSync, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "node:fs";
|
|
17300
17579
|
import { resolve as resolve5, sep as sep7 } from "node:path";
|
|
17301
17580
|
import { applyEdits, findNodeAtLocation, modify, parseTree } from "jsonc-parser";
|
|
17302
17581
|
function resolveWithinRoot(cwd, relativePath) {
|
|
@@ -17308,7 +17587,7 @@ function resolveWithinRoot(cwd, relativePath) {
|
|
|
17308
17587
|
return absolutePath;
|
|
17309
17588
|
}
|
|
17310
17589
|
function readIfExists(absolutePath) {
|
|
17311
|
-
return existsSync35(absolutePath) ?
|
|
17590
|
+
return existsSync35(absolutePath) ? readFileSync32(absolutePath, "utf8") : void 0;
|
|
17312
17591
|
}
|
|
17313
17592
|
function* leaves(value, prefix = []) {
|
|
17314
17593
|
for (const [key, keyValue] of Object.entries(value)) {
|
|
@@ -17426,8 +17705,8 @@ function applyPlan(cwd, plan3) {
|
|
|
17426
17705
|
}
|
|
17427
17706
|
|
|
17428
17707
|
// src/core/config/preset-evidence.ts
|
|
17429
|
-
import { existsSync as existsSync36, readdirSync as
|
|
17430
|
-
import { join as
|
|
17708
|
+
import { existsSync as existsSync36, readdirSync as readdirSync7, readFileSync as readFileSync33 } from "node:fs";
|
|
17709
|
+
import { join as join55 } from "node:path";
|
|
17431
17710
|
var PATH_SIGNALS = [
|
|
17432
17711
|
{
|
|
17433
17712
|
preset: "nest",
|
|
@@ -17455,18 +17734,18 @@ function sourceImports(cwd, pattern) {
|
|
|
17455
17734
|
const dir = stack.pop();
|
|
17456
17735
|
let entries;
|
|
17457
17736
|
try {
|
|
17458
|
-
entries =
|
|
17737
|
+
entries = readdirSync7(dir, { withFileTypes: true });
|
|
17459
17738
|
} catch {
|
|
17460
17739
|
continue;
|
|
17461
17740
|
}
|
|
17462
17741
|
for (const entry of entries) {
|
|
17463
17742
|
if (entry.isDirectory()) {
|
|
17464
|
-
if (!NOT_SCANNED.has(entry.name)) stack.push(
|
|
17743
|
+
if (!NOT_SCANNED.has(entry.name)) stack.push(join55(dir, entry.name));
|
|
17465
17744
|
continue;
|
|
17466
17745
|
}
|
|
17467
17746
|
if (!SOURCE_FILE.test(entry.name)) continue;
|
|
17468
17747
|
try {
|
|
17469
|
-
if (pattern.test(
|
|
17748
|
+
if (pattern.test(readFileSync33(join55(dir, entry.name), "utf8"))) return true;
|
|
17470
17749
|
} catch {
|
|
17471
17750
|
continue;
|
|
17472
17751
|
}
|
|
@@ -17475,11 +17754,11 @@ function sourceImports(cwd, pattern) {
|
|
|
17475
17754
|
return false;
|
|
17476
17755
|
}
|
|
17477
17756
|
function dependencyNames(cwd) {
|
|
17478
|
-
const path2 =
|
|
17757
|
+
const path2 = join55(cwd, "package.json");
|
|
17479
17758
|
if (!existsSync36(path2)) return [];
|
|
17480
17759
|
try {
|
|
17481
17760
|
const manifest = parseJsonc(
|
|
17482
|
-
|
|
17761
|
+
readFileSync33(path2, "utf8"),
|
|
17483
17762
|
path2
|
|
17484
17763
|
);
|
|
17485
17764
|
return [
|
|
@@ -17494,7 +17773,7 @@ var REACT_TYPESCRIPT_PRESET = "@hublo/sentinel/typescript/react";
|
|
|
17494
17773
|
function reactTsconfigEvidence(cwd) {
|
|
17495
17774
|
let entries;
|
|
17496
17775
|
try {
|
|
17497
|
-
entries =
|
|
17776
|
+
entries = readdirSync7(cwd).filter(
|
|
17498
17777
|
(name) => name.startsWith("tsconfig") && name.endsWith(".json")
|
|
17499
17778
|
);
|
|
17500
17779
|
} catch {
|
|
@@ -17502,7 +17781,7 @@ function reactTsconfigEvidence(cwd) {
|
|
|
17502
17781
|
}
|
|
17503
17782
|
for (const name of entries) {
|
|
17504
17783
|
try {
|
|
17505
|
-
const config = parseJsonc(
|
|
17784
|
+
const config = parseJsonc(readFileSync33(join55(cwd, name), "utf8"), name);
|
|
17506
17785
|
if (config.compilerOptions?.jsx !== void 0) return 'its tsconfig sets "jsx"';
|
|
17507
17786
|
const extended = Array.isArray(config.extends) ? config.extends : config.extends === void 0 ? [] : [config.extends];
|
|
17508
17787
|
if (extended.some((entry) => entry === REACT_TYPESCRIPT_PRESET)) {
|