@hublo/sentinel 1.4.0-alpha.16 → 1.4.0-alpha.18
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 +1 -1
- package/dist/{chunk-XGC2KK5J.js → chunk-ICGZ3HCR.js} +50 -13
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin/sentinel.js
CHANGED
|
@@ -5738,7 +5738,7 @@ function rewriteAssertionReturnValue(source, program) {
|
|
|
5738
5738
|
for (const reading of readings) {
|
|
5739
5739
|
const from = reading.start;
|
|
5740
5740
|
let to = reading.end;
|
|
5741
|
-
while (to < source.length && /[\
|
|
5741
|
+
while (to < source.length && /[ \t;]/.test(source[to])) to += 1;
|
|
5742
5742
|
let head = from;
|
|
5743
5743
|
while (head > 0 && /[ \t]/.test(source[head - 1])) head -= 1;
|
|
5744
5744
|
if (head > 0 && source[head - 1] === "\n") head -= 1;
|
|
@@ -8446,9 +8446,15 @@ function planJestMigration(context, adoption) {
|
|
|
8446
8446
|
`${SPEC_TSCONFIG} now declares \`${VITEST_GLOBAL_TYPES}\` instead of \`jest\`. Without it the module keeps depending on @types/jest and \`jest.Mock\` still resolves, so the migration would look finished while the dependency it cuts is still declared.`
|
|
8447
8447
|
);
|
|
8448
8448
|
}
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8449
|
+
if (readFormatAdoption(context.cwd).configFile !== null) {
|
|
8450
|
+
notes.push(
|
|
8451
|
+
`the files this rewrote were run through this module's own formatter afterwards. Two things needed it: the Vitest type imports land beside the existing ones, and a rewritten call is often SHORTER than the one it replaced, so the line breaks around it are no longer the ones your config would pick. Neither is a defect, and both would have failed your format check.`
|
|
8452
|
+
);
|
|
8453
|
+
} else {
|
|
8454
|
+
notes.push(
|
|
8455
|
+
`this module has no formatter config, so what was written keeps the shape it was written in, and the Vitest type imports sit beside the existing ones rather than in the position your \`import/order\` wants. That rule is classified by a prefix list this package cannot read, so it is left to the tool that owns it: run your module's own lint fixer (\`nx run <module>:lint --fix\` here) and its formatter before committing.`
|
|
8456
|
+
);
|
|
8457
|
+
}
|
|
8452
8458
|
notes.push(
|
|
8453
8459
|
`then run this module's TYPECHECK, not only its tests. The migration rewrites types as well as calls, and a wrong type is invisible to a green suite: measured on a real module, \`--run --test\` passed while \`--run --typescript\` reported ten errors it had not had before.`
|
|
8454
8460
|
);
|
|
@@ -8922,6 +8928,7 @@ function resolveVitest(cwd) {
|
|
|
8922
8928
|
const fromModule = resolveBin(cwd, "vitest");
|
|
8923
8929
|
return fromModule !== void 0 ? { bin: fromModule, origin: "module" } : { bin: void 0, origin: "module" };
|
|
8924
8930
|
}
|
|
8931
|
+
var FORMATTABLE = /\.(m|c)?(j|t)sx?$|\.json$/;
|
|
8925
8932
|
var VitestAdapter = class extends BaseAdapter {
|
|
8926
8933
|
target = "test";
|
|
8927
8934
|
runner = "vitest";
|
|
@@ -8960,21 +8967,48 @@ var VitestAdapter = class extends BaseAdapter {
|
|
|
8960
8967
|
* MODULE's decision: `printWidth` lives in its own config, and 12 modules already set their
|
|
8961
8968
|
* own. Guessing it is how a tool starts owning a setting it does not own.
|
|
8962
8969
|
*
|
|
8963
|
-
* The same delegation the build role asks a human to do by hand, done.
|
|
8964
|
-
*
|
|
8965
|
-
*
|
|
8970
|
+
* The same delegation the build role asks a human to do by hand, done.
|
|
8971
|
+
*
|
|
8972
|
+
* ## ⚠️ Two boundaries, both learned by crossing them
|
|
8973
|
+
*
|
|
8974
|
+
* ### Only a module that has a formatter CONFIG
|
|
8975
|
+
*
|
|
8976
|
+
* The question is not "can a formatter be found". It always can: sentinel depends on oxfmt and
|
|
8977
|
+
* ships the binary, so `resolveOxfmt` falls back to its own install and never returns undefined
|
|
8978
|
+
* once sentinel is installed. Asking it that way meant a module with no oxfmt config was
|
|
8979
|
+
* formatted with oxfmt's DEFAULTS, which is a style nobody here chose.
|
|
8980
|
+
*
|
|
8981
|
+
* So the CONFIG is read. A module that wrote its own `.oxfmtrc.json` without adopting the role
|
|
8982
|
+
* has still stated a style, and running it is delegation; running oxfmt with no config is us
|
|
8983
|
+
* choosing one.
|
|
8984
|
+
*
|
|
8985
|
+
* Measured on `apps/nest/microservices/institution`, which has not adopted format and whose lint
|
|
8986
|
+
* forbids semicolons: `institution:lint` went from green to failing, thousands of `semi`, on a
|
|
8987
|
+
* module whose 2958 tests pass. So the adoption is read, not the binary.
|
|
8988
|
+
*
|
|
8989
|
+
* ### Only the files this just WROTE
|
|
8990
|
+
*
|
|
8991
|
+
* `--write .` is a whole-directory pass, and that is not a tidy-up. Same measurement: 1813 files
|
|
8992
|
+
* changed, 47333 insertions, 55506 deletions, in a module whose migration touched 268. A
|
|
8993
|
+
* migration diff is read by a person.
|
|
8994
|
+
*
|
|
8995
|
+
* A module that has not adopted format keeps what was written exactly as written, and is told so.
|
|
8996
|
+
* The codemod rewrites tokens in place, so those files keep the shape they already had.
|
|
8966
8997
|
*/
|
|
8967
8998
|
async afterInit(ctx) {
|
|
8968
|
-
const
|
|
8969
|
-
if (
|
|
8999
|
+
const written = (ctx.written ?? []).filter((file) => FORMATTABLE.test(file));
|
|
9000
|
+
if (written.length === 0) return Promise.resolve();
|
|
9001
|
+
if (readFormatAdoption(ctx.cwd).configFile === null) {
|
|
8970
9002
|
this.say(
|
|
8971
|
-
`no formatter
|
|
9003
|
+
`no formatter configured here, so the ${written.length} file(s) this wrote keep the shape they were written in. Run your own formatter over them before committing.`
|
|
8972
9004
|
);
|
|
8973
9005
|
return Promise.resolve();
|
|
8974
9006
|
}
|
|
8975
|
-
const
|
|
9007
|
+
const oxfmt = resolveOxfmt(ctx.cwd);
|
|
9008
|
+
if (oxfmt === void 0) return Promise.resolve();
|
|
9009
|
+
const pass = spawnSync5(oxfmt, ["--write", ...written], { cwd: ctx.cwd, encoding: "utf8" });
|
|
8976
9010
|
this.say(
|
|
8977
|
-
pass.status === 0 ? `formatted
|
|
9011
|
+
pass.status === 0 ? `formatted the ${written.length} file(s) this wrote with the module's own oxfmt config, so its \`--run --format\` passes on files it did not write itself.` : (
|
|
8978
9012
|
// Adoption SUCCEEDED; only the tidy-up did not. Failing here would revert a migration
|
|
8979
9013
|
// over a formatting pass, which is the wrong trade.
|
|
8980
9014
|
`the module's formatter could not run over what this wrote (${pass.status ?? "no exit code"}). Adoption itself is applied; run \`sentinel --run --format --fix\` before committing.`
|
|
@@ -10209,9 +10243,11 @@ async function dispatch(opts) {
|
|
|
10209
10243
|
fix: false
|
|
10210
10244
|
});
|
|
10211
10245
|
}
|
|
10246
|
+
const written = [];
|
|
10212
10247
|
for (const change of applyPlan(opts.cwd, plan4)) {
|
|
10213
10248
|
process.stderr.write(` ${change.deleted ? "removed" : "wrote"} ${change.path}
|
|
10214
10249
|
`);
|
|
10250
|
+
if (!change.deleted) written.push(change.path);
|
|
10215
10251
|
}
|
|
10216
10252
|
for (const note of plan4.notes ?? []) process.stderr.write(` ${note}
|
|
10217
10253
|
`);
|
|
@@ -10223,7 +10259,8 @@ async function dispatch(opts) {
|
|
|
10223
10259
|
cwd: opts.cwd,
|
|
10224
10260
|
preset,
|
|
10225
10261
|
ci: false,
|
|
10226
|
-
fix: true
|
|
10262
|
+
fix: true,
|
|
10263
|
+
written
|
|
10227
10264
|
});
|
|
10228
10265
|
}
|
|
10229
10266
|
return 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,16 @@ interface RunContext {
|
|
|
66
66
|
ci: boolean;
|
|
67
67
|
/** Apply auto-fixes where the tool supports it. */
|
|
68
68
|
fix: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The files `--init` just wrote, relative to `cwd`, for an `afterInit` that tidies up after
|
|
71
|
+
* itself.
|
|
72
|
+
*
|
|
73
|
+
* ⚠️ It exists because the alternative is a whole-directory pass, and that is not a tidy-up.
|
|
74
|
+
* Measured on `apps/nest/microservices/institution`: an `afterInit` running its formatter over
|
|
75
|
+
* `.` reformatted 1813 files, 47333 insertions and 55506 deletions, in a module whose migration
|
|
76
|
+
* touched 268. Only set by the `--init` path, so an adapter must treat it as optional.
|
|
77
|
+
*/
|
|
78
|
+
written?: string[];
|
|
69
79
|
/**
|
|
70
80
|
* Cap on the number of structured diagnostics a `--report` embeds per module (the
|
|
71
81
|
* full count still lives in `errors`, so nothing is hidden silently). `0` means no
|
package/dist/index.js
CHANGED
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.18",
|
|
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",
|