@hublo/sentinel 1.4.3 → 1.5.0-alpha.1
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 +15 -6
- package/dist/chunk-3VJGWCAG.js +83 -0
- package/dist/chunk-3VJGWCAG.js.map +1 -0
- package/dist/{chunk-DYK6UEMO.js → chunk-AKAAYAB2.js} +501 -57
- package/dist/{chunk-TDNPPNGK.js → chunk-E3MYVYEZ.js} +35 -7
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4 -3
- package/dist/roles/static-analysis/config.d.ts +50 -0
- package/dist/roles/static-analysis/config.js +7 -0
- package/dist/roles/static-analysis/config.js.map +1 -0
- package/dist/roles/test/setup/file-boundary.js +3 -3
- package/dist/{validate-3QMCX2HW.js → validate-STUK2AGG.js} +2 -2
- package/docs/static-analysis-study.md +788 -0
- package/docs/typescript-traces.md +1 -1
- package/package.json +7 -1
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
matchesTsconfigPattern
|
|
3
|
-
} from "./chunk-O7REVMOC.js";
|
|
4
|
-
import {
|
|
5
|
-
parseJsonc
|
|
6
|
-
} from "./chunk-QXFCZON7.js";
|
|
7
1
|
import {
|
|
8
2
|
DEFAULT_MAX_DIAGNOSTICS,
|
|
9
3
|
WORKSPACE_ROOT_MARKER,
|
|
@@ -13,6 +7,12 @@ import {
|
|
|
13
7
|
readOwnPackage,
|
|
14
8
|
readProjectPackageJson
|
|
15
9
|
} from "./chunk-KMKQDGI6.js";
|
|
10
|
+
import {
|
|
11
|
+
matchesTsconfigPattern
|
|
12
|
+
} from "./chunk-O7REVMOC.js";
|
|
13
|
+
import {
|
|
14
|
+
parseJsonc
|
|
15
|
+
} from "./chunk-QXFCZON7.js";
|
|
16
16
|
|
|
17
17
|
// src/core/base-adapter.ts
|
|
18
18
|
var BaseAdapter = class {
|
|
@@ -5341,6 +5341,28 @@ function specTypesOperation(cwd) {
|
|
|
5341
5341
|
}
|
|
5342
5342
|
};
|
|
5343
5343
|
}
|
|
5344
|
+
function specTypesCleanupOperation(cwd) {
|
|
5345
|
+
const path = join25(cwd, SPEC_TSCONFIG);
|
|
5346
|
+
if (!existsSync19(path)) return void 0;
|
|
5347
|
+
let config;
|
|
5348
|
+
try {
|
|
5349
|
+
config = parseJsonc(
|
|
5350
|
+
readFileSync21(path, "utf8"),
|
|
5351
|
+
SPEC_TSCONFIG
|
|
5352
|
+
);
|
|
5353
|
+
} catch {
|
|
5354
|
+
return void 0;
|
|
5355
|
+
}
|
|
5356
|
+
const types = config?.compilerOptions?.types;
|
|
5357
|
+
if (!Array.isArray(types) || !types.includes("jest")) return void 0;
|
|
5358
|
+
const remaining = types.filter((entry) => entry !== "jest");
|
|
5359
|
+
if (remaining.length === 0) return void 0;
|
|
5360
|
+
return {
|
|
5361
|
+
kind: "merge-json",
|
|
5362
|
+
path: SPEC_TSCONFIG,
|
|
5363
|
+
value: { compilerOptions: { types: remaining } }
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5344
5366
|
function shippedTypesPath(cwd, declaration) {
|
|
5345
5367
|
try {
|
|
5346
5368
|
const manifest = createRequire5(join25(cwd, "noop.cjs")).resolve("@hublo/sentinel/package.json");
|
|
@@ -5703,6 +5725,8 @@ function plan(context) {
|
|
|
5703
5725
|
keys: [["targets", TEST_SCRIPT_NAME]]
|
|
5704
5726
|
});
|
|
5705
5727
|
}
|
|
5728
|
+
const specTypes = specTypesCleanupOperation(context.cwd);
|
|
5729
|
+
if (specTypes !== void 0) operations2.push(specTypes);
|
|
5706
5730
|
if (operations2.length === 0) {
|
|
5707
5731
|
return {
|
|
5708
5732
|
operations: [],
|
|
@@ -5715,7 +5739,11 @@ function plan(context) {
|
|
|
5715
5739
|
// Names what is actually removed, never a shape this module does not have: half of these
|
|
5716
5740
|
// modules carry a config with no target behind it, and claiming otherwise would describe
|
|
5717
5741
|
// an operation the plan never performs.
|
|
5718
|
-
`this module has no test file, so this is a cleanup rather than an adoption: ${[
|
|
5742
|
+
`this module has no test file, so this is a cleanup rather than an adoption: ${[
|
|
5743
|
+
...adoption.jestConfigs,
|
|
5744
|
+
...hasTarget ? ["the jest target it feeds"] : [],
|
|
5745
|
+
...specTypes !== void 0 ? ["the jest entry in tsconfig.spec.json"] : []
|
|
5746
|
+
].join(" and ")} removed, so nothing here breaks the day jest leaves the workspace. No test config is written in exchange, because there is nothing to configure.`
|
|
5719
5747
|
]
|
|
5720
5748
|
};
|
|
5721
5749
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -111,6 +111,15 @@ interface RunContext {
|
|
|
111
111
|
* calls. The engine echoes them on stderr and carries them in the `--json` envelope.
|
|
112
112
|
*/
|
|
113
113
|
toolArgs?: readonly string[];
|
|
114
|
+
/**
|
|
115
|
+
* The output shape a caller asked for, from `--output`. A role that can produce more than a
|
|
116
|
+
* console summary reads it; every other role ignores it.
|
|
117
|
+
*
|
|
118
|
+
* Left a plain string rather than a union on purpose: which shapes exist is a property of the
|
|
119
|
+
* role that writes them, and the engine has no business holding a list it cannot validate.
|
|
120
|
+
* The role rejects a shape it does not know, by name.
|
|
121
|
+
*/
|
|
122
|
+
output?: string;
|
|
114
123
|
}
|
|
115
124
|
/**
|
|
116
125
|
* A single, DECLARATIVE file operation an `--init` wants to happen. Adapters
|
package/dist/index.js
CHANGED
|
@@ -6,13 +6,14 @@ import {
|
|
|
6
6
|
registerAdapters,
|
|
7
7
|
resolve,
|
|
8
8
|
setDefaultRunner
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AKAAYAB2.js";
|
|
10
10
|
import {
|
|
11
11
|
BaseAdapter
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-E3MYVYEZ.js";
|
|
13
|
+
import "./chunk-KMKQDGI6.js";
|
|
14
|
+
import "./chunk-3VJGWCAG.js";
|
|
13
15
|
import "./chunk-O7REVMOC.js";
|
|
14
16
|
import "./chunk-QXFCZON7.js";
|
|
15
|
-
import "./chunk-KMKQDGI6.js";
|
|
16
17
|
export {
|
|
17
18
|
BaseAdapter,
|
|
18
19
|
all,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
type StaticDefaults = {
|
|
2
|
+
entry: string[];
|
|
3
|
+
ignore: string[];
|
|
4
|
+
languages: string[];
|
|
5
|
+
journeys: Record<string, string[]>;
|
|
6
|
+
duplication: {
|
|
7
|
+
minTokens: number;
|
|
8
|
+
minLines: number;
|
|
9
|
+
kinds: string[];
|
|
10
|
+
};
|
|
11
|
+
deadCode: {
|
|
12
|
+
minConfidence: number;
|
|
13
|
+
categories: string[];
|
|
14
|
+
};
|
|
15
|
+
thresholds: {
|
|
16
|
+
duplicatedLinesPercent: number;
|
|
17
|
+
deadCodePercent: number;
|
|
18
|
+
};
|
|
19
|
+
tools: {
|
|
20
|
+
jscpd: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type DeepPartial<T> = {
|
|
25
|
+
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
26
|
+
};
|
|
27
|
+
/** What a module's config file passes. Everything is optional, including the file itself. */
|
|
28
|
+
interface StaticAnalysisInput {
|
|
29
|
+
/** The module's own directory, normally `import.meta.dirname`. */
|
|
30
|
+
root?: string;
|
|
31
|
+
/** Files that run although nothing imports them. ADDED to the shipped patterns. */
|
|
32
|
+
entry?: string[];
|
|
33
|
+
/** Named journeys, as `{ name: [globs] }`. MERGED by name with any shipped ones. */
|
|
34
|
+
journeys?: Record<string, string[]>;
|
|
35
|
+
/** The seam. Replaces whatever it names, and every path it sets lands in `moved`. */
|
|
36
|
+
overrides?: DeepPartial<StaticDefaults>;
|
|
37
|
+
}
|
|
38
|
+
interface ResolvedStaticConfig extends StaticDefaults {
|
|
39
|
+
/** The module's directory, or null when its config file did not say. */
|
|
40
|
+
root: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Dotted paths the module set through `overrides`, so the report can mark them. Sorted, so
|
|
43
|
+
* two runs on the same config produce the same report.
|
|
44
|
+
*/
|
|
45
|
+
moved: string[];
|
|
46
|
+
}
|
|
47
|
+
/** Resolve a module's declaration against this role's defaults. */
|
|
48
|
+
declare function defineStaticAnalysis(input?: StaticAnalysisInput): ResolvedStaticConfig;
|
|
49
|
+
|
|
50
|
+
export { type ResolvedStaticConfig, type StaticAnalysisInput, defineStaticAnalysis };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
alreadyInstalled
|
|
3
|
+
} from "../../../chunk-NUOQXAYR.js";
|
|
1
4
|
import {
|
|
2
5
|
CURRENT_FILE_MOCKS,
|
|
3
6
|
PHASE,
|
|
4
7
|
SHARED_WORKER
|
|
5
8
|
} from "../../../chunk-H3GSGAX2.js";
|
|
6
|
-
import {
|
|
7
|
-
alreadyInstalled
|
|
8
|
-
} from "../../../chunk-NUOQXAYR.js";
|
|
9
9
|
import {
|
|
10
10
|
fromModule
|
|
11
11
|
} from "../../../chunk-ELZHIN6E.js";
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
readTestAdoption,
|
|
8
8
|
resolveVitest,
|
|
9
9
|
suiteOf
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-E3MYVYEZ.js";
|
|
11
|
+
import "./chunk-KMKQDGI6.js";
|
|
11
12
|
import "./chunk-O7REVMOC.js";
|
|
12
13
|
import "./chunk-QXFCZON7.js";
|
|
13
|
-
import "./chunk-KMKQDGI6.js";
|
|
14
14
|
|
|
15
15
|
// src/roles/test/validate.ts
|
|
16
16
|
import { execFileSync } from "node:child_process";
|