@hublo/sentinel 1.4.0-alpha.40 → 1.4.0-alpha.41
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
CHANGED
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
palette,
|
|
16
16
|
registerAdapters,
|
|
17
17
|
resolve
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-2UU57Y2T.js";
|
|
19
19
|
import {
|
|
20
20
|
resolveContext
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-I3FX32E7.js";
|
|
22
22
|
import "../chunk-O7REVMOC.js";
|
|
23
23
|
import "../chunk-QXFCZON7.js";
|
|
24
24
|
import {
|
|
@@ -145,7 +145,7 @@ async function runValidate(ctx) {
|
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
if (!ctx.targets.includes("test")) return 1;
|
|
148
|
-
const { validateModuleTests } = await import("../validate-
|
|
148
|
+
const { validateModuleTests } = await import("../validate-ANM7RQ3C.js");
|
|
149
149
|
const outcomes = modules.flatMap(
|
|
150
150
|
(module) => validateModuleTests(module.name, module.root)
|
|
151
151
|
);
|
|
@@ -1963,6 +1963,25 @@ function rewriteHookReturnValue(source, program) {
|
|
|
1963
1963
|
return { source: result, rewritten: edits.length };
|
|
1964
1964
|
}
|
|
1965
1965
|
|
|
1966
|
+
// src/roles/test/codemod/asyncify.ts
|
|
1967
|
+
function alreadyAPromise(text) {
|
|
1968
|
+
return /^(?:Promise|PromiseLike)\s*</.test(text.trim());
|
|
1969
|
+
}
|
|
1970
|
+
function asyncifyEdits(source, fn) {
|
|
1971
|
+
const edits = [{ start: fn.start, end: fn.start, text: "async " }];
|
|
1972
|
+
const annotation = fn.returnType;
|
|
1973
|
+
const declared = annotation?.typeAnnotation;
|
|
1974
|
+
if (declared?.start === void 0 || declared.end === void 0) return edits;
|
|
1975
|
+
const text = source.slice(declared.start, declared.end);
|
|
1976
|
+
if (alreadyAPromise(text)) return edits;
|
|
1977
|
+
edits.push({
|
|
1978
|
+
start: declared.start,
|
|
1979
|
+
end: declared.end,
|
|
1980
|
+
text: `Promise<${text}>`
|
|
1981
|
+
});
|
|
1982
|
+
return edits;
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1966
1985
|
// src/roles/test/codemod/named-rules.ts
|
|
1967
1986
|
import { existsSync as existsSync11, readFileSync as readFileSync10 } from "node:fs";
|
|
1968
1987
|
import { createRequire as createRequire2 } from "node:module";
|
|
@@ -2474,7 +2493,7 @@ function applyNamedRules(source, program, fileName = "") {
|
|
|
2474
2493
|
}
|
|
2475
2494
|
});
|
|
2476
2495
|
for (const fn of asyncify) {
|
|
2477
|
-
edits.push(
|
|
2496
|
+
edits.push(...asyncifyEdits(source, fn));
|
|
2478
2497
|
}
|
|
2479
2498
|
const namespaceLines = namespaces.planned().map(
|
|
2480
2499
|
({ specifier, binding }) => `import * as ${binding} from '${specifier}'${fileUsesSemicolons(source) ? ";" : ""}`
|
|
@@ -2545,6 +2564,12 @@ function rewriteIsolateModules(source, program) {
|
|
|
2545
2564
|
const refusals = [];
|
|
2546
2565
|
const asyncify = /* @__PURE__ */ new Set();
|
|
2547
2566
|
let rewritten = 0;
|
|
2567
|
+
const awaitedCall = /* @__PURE__ */ new Map();
|
|
2568
|
+
walkWithEnclosingFunction(program, void 0, (node) => {
|
|
2569
|
+
if (node.type !== "AwaitExpression") return;
|
|
2570
|
+
const argument = node.argument;
|
|
2571
|
+
if (argument !== void 0) awaitedCall.set(argument, node);
|
|
2572
|
+
});
|
|
2548
2573
|
walkWithEnclosingFunction(program, void 0, (node, enclosing) => {
|
|
2549
2574
|
const unusable = unusableIsolatingCall(node);
|
|
2550
2575
|
if (unusable !== void 0) {
|
|
@@ -2558,10 +2583,11 @@ function rewriteIsolateModules(source, program) {
|
|
|
2558
2583
|
if (found === void 0) return;
|
|
2559
2584
|
const callbackText = source.slice(found.callback.start, found.callback.end);
|
|
2560
2585
|
const callback = found.callback.async === true ? callbackText : `async ${callbackText}`;
|
|
2561
|
-
const
|
|
2586
|
+
const replaced = awaitedCall.get(found.call) ?? found.call;
|
|
2587
|
+
const indent = indentationAt(source, replaced.start);
|
|
2562
2588
|
edits.push({
|
|
2563
|
-
start:
|
|
2564
|
-
end:
|
|
2589
|
+
start: replaced.start,
|
|
2590
|
+
end: replaced.end,
|
|
2565
2591
|
text: `vi.resetModules()
|
|
2566
2592
|
${indent}await (${callback})()`
|
|
2567
2593
|
});
|
|
@@ -2569,7 +2595,7 @@ ${indent}await (${callback})()`
|
|
|
2569
2595
|
if (enclosing !== void 0 && enclosing.async !== true) asyncify.add(enclosing);
|
|
2570
2596
|
});
|
|
2571
2597
|
for (const fn of asyncify) {
|
|
2572
|
-
edits.push(
|
|
2598
|
+
edits.push(...asyncifyEdits(source, fn));
|
|
2573
2599
|
}
|
|
2574
2600
|
const result = applyEdits(source, edits);
|
|
2575
2601
|
return { source: result, rewritten, refusals };
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
registerAdapters,
|
|
7
7
|
resolve,
|
|
8
8
|
setDefaultRunner
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2UU57Y2T.js";
|
|
10
10
|
import {
|
|
11
11
|
BaseAdapter
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-I3FX32E7.js";
|
|
13
13
|
import "./chunk-O7REVMOC.js";
|
|
14
14
|
import "./chunk-QXFCZON7.js";
|
|
15
15
|
import "./chunk-NW6UHNYX.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hublo/sentinel",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.41",
|
|
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",
|