depvitals 0.1.2 → 0.3.0
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/README.md +39 -61
- package/dist/cli/entry.d.ts +59 -0
- package/dist/cli/entry.d.ts.map +1 -0
- package/dist/cli/entry.js +95 -0
- package/dist/cli/entry.js.map +1 -0
- package/dist/cli/index.js +14 -18
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/notifier/eligibility.d.ts +65 -0
- package/dist/cli/notifier/eligibility.d.ts.map +1 -0
- package/dist/cli/notifier/eligibility.js +123 -0
- package/dist/cli/notifier/eligibility.js.map +1 -0
- package/dist/cli/notifier/registryLookup.d.ts +111 -0
- package/dist/cli/notifier/registryLookup.d.ts.map +1 -0
- package/dist/cli/notifier/registryLookup.js +211 -0
- package/dist/cli/notifier/registryLookup.js.map +1 -0
- package/dist/cli/notifier/updateCache.d.ts +101 -0
- package/dist/cli/notifier/updateCache.d.ts.map +1 -0
- package/dist/cli/notifier/updateCache.js +352 -0
- package/dist/cli/notifier/updateCache.js.map +1 -0
- package/dist/cli/notifier/updateCheck.d.ts +88 -0
- package/dist/cli/notifier/updateCheck.d.ts.map +1 -0
- package/dist/cli/notifier/updateCheck.js +166 -0
- package/dist/cli/notifier/updateCheck.js.map +1 -0
- package/dist/cli/notifier/versionCompare.d.ts +48 -0
- package/dist/cli/notifier/versionCompare.d.ts.map +1 -0
- package/dist/cli/notifier/versionCompare.js +89 -0
- package/dist/cli/notifier/versionCompare.js.map +1 -0
- package/dist/cli/runCli.d.ts +2 -0
- package/dist/cli/runCli.d.ts.map +1 -1
- package/dist/cli/runCli.js +36 -4
- package/dist/cli/runCli.js.map +1 -1
- package/dist/config/ignoreDependencies.d.ts +7 -0
- package/dist/config/ignoreDependencies.d.ts.map +1 -0
- package/dist/config/ignoreDependencies.js +18 -0
- package/dist/config/ignoreDependencies.js.map +1 -0
- package/dist/config/ignorePaths.d.ts +13 -0
- package/dist/config/ignorePaths.d.ts.map +1 -0
- package/dist/config/ignorePaths.js +47 -0
- package/dist/config/ignorePaths.js.map +1 -0
- package/dist/config/projectConfigError.d.ts +7 -0
- package/dist/config/projectConfigError.d.ts.map +1 -0
- package/dist/config/projectConfigError.js +10 -0
- package/dist/config/projectConfigError.js.map +1 -0
- package/dist/config/readProjectConfig.d.ts +23 -0
- package/dist/config/readProjectConfig.d.ts.map +1 -0
- package/dist/config/readProjectConfig.js +106 -0
- package/dist/config/readProjectConfig.js.map +1 -0
- package/dist/core/analyzeProject.d.ts +48 -6
- package/dist/core/analyzeProject.d.ts.map +1 -1
- package/dist/core/analyzeProject.js +123 -16
- package/dist/core/analyzeProject.js.map +1 -1
- package/dist/detectors/eslintManifestConfig.d.ts +111 -0
- package/dist/detectors/eslintManifestConfig.d.ts.map +1 -0
- package/dist/detectors/eslintManifestConfig.js +351 -0
- package/dist/detectors/eslintManifestConfig.js.map +1 -0
- package/dist/detectors/eslintRcJsonConfig.d.ts +85 -0
- package/dist/detectors/eslintRcJsonConfig.d.ts.map +1 -0
- package/dist/detectors/eslintRcJsonConfig.js +189 -0
- package/dist/detectors/eslintRcJsonConfig.js.map +1 -0
- package/dist/detectors/jestManifestConfig.d.ts +76 -0
- package/dist/detectors/jestManifestConfig.d.ts.map +1 -0
- package/dist/detectors/jestManifestConfig.js +294 -0
- package/dist/detectors/jestManifestConfig.js.map +1 -0
- package/dist/reporters/terminalReporter.js +27 -1
- package/dist/reporters/terminalReporter.js.map +1 -1
- package/dist/scanner/moduleSpecifiers.d.ts +9 -1
- package/dist/scanner/moduleSpecifiers.d.ts.map +1 -1
- package/dist/scanner/moduleSpecifiers.js +3317 -205
- package/dist/scanner/moduleSpecifiers.js.map +1 -1
- package/dist/scanner/packageSpecifier.d.ts +26 -2
- package/dist/scanner/packageSpecifier.d.ts.map +1 -1
- package/dist/scanner/packageSpecifier.js +70 -2
- package/dist/scanner/packageSpecifier.js.map +1 -1
- package/dist/scanner/projectManifest.d.ts +31 -1
- package/dist/scanner/projectManifest.d.ts.map +1 -1
- package/dist/scanner/projectManifest.js +83 -4
- package/dist/scanner/projectManifest.js.map +1 -1
- package/dist/scanner/scriptUsage.d.ts +2 -1
- package/dist/scanner/scriptUsage.d.ts.map +1 -1
- package/dist/scanner/scriptUsage.js +216 -39
- package/dist/scanner/scriptUsage.js.map +1 -1
- package/dist/scanner/sourceFiles.d.ts +16 -2
- package/dist/scanner/sourceFiles.d.ts.map +1 -1
- package/dist/scanner/sourceFiles.js +12 -6
- package/dist/scanner/sourceFiles.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `package.json#jest` usage detection.
|
|
3
|
+
*
|
|
4
|
+
* This module answers exactly one narrow question: which declared dependencies are named by the three
|
|
5
|
+
* explicit Jest fields this release understands inside the `jest` block of `package.json` — the
|
|
6
|
+
* top-level `preset` and `testEnvironment` strings and the values of the top-level `transform` map?
|
|
7
|
+
* The result is a set of configuration-only package names handed to the Step 56 analyzer seam, so a
|
|
8
|
+
* recognized name can only suppress an `unused` finding and can never create a `missing` one.
|
|
9
|
+
*
|
|
10
|
+
* It deliberately does not:
|
|
11
|
+
* - execute Jest, `import()`/`require()` its configuration loader, or evaluate any target code;
|
|
12
|
+
* - implement the Jest configuration schema. Only `preset`, `testEnvironment` and `transform` are
|
|
13
|
+
* read, and only through the fixed allowlists below;
|
|
14
|
+
* - read the `transform` map *keys*. Every key of that map is a regular expression selecting the
|
|
15
|
+
* files a transformer applies to, so a key is a pattern and never a package name, even when it
|
|
16
|
+
* literally reads `"ts-jest"`; no regular expression is ever evaluated here;
|
|
17
|
+
* - expand Jest shorthands. In particular `testEnvironment: "jsdom"` is *not* credited to
|
|
18
|
+
* `jest-environment-jsdom`: whether that shorthand is a package reference at all depends on the
|
|
19
|
+
* Jest major version in use, which DepVitals does not read, so it stays outside the supported
|
|
20
|
+
* subset of explicit package names;
|
|
21
|
+
* - interpret `<rootDir>/...`, `./...`, absolute paths, URLs or any other resolver-looking string as a
|
|
22
|
+
* package reference;
|
|
23
|
+
* - read `jest.config.js`/`.cjs`/`.mjs`/`.ts`/`.json` contents. Those files are only checked for
|
|
24
|
+
* presence, never opened here (source detection already handles their imports on its own);
|
|
25
|
+
* - guess a package from arbitrary configuration text, substring-match a value, or invent a name;
|
|
26
|
+
* - report anything about a package the manifest does not declare;
|
|
27
|
+
* - mutate the analyzed project.
|
|
28
|
+
*
|
|
29
|
+
* A conservative precedence guard applies before anything is read: when a root `jest.config.*` file
|
|
30
|
+
* exists, it is not provable which configuration Jest actually loads, so no `package.json#jest`
|
|
31
|
+
* hints are produced. Presence is checked by directory entry name only.
|
|
32
|
+
*
|
|
33
|
+
* The manifest model intentionally does not carry `jest`, so `package.json` is read a second time here
|
|
34
|
+
* as plain text (same trade-off as the legacy ESLint readers): the loader stays the validity gate and
|
|
35
|
+
* the single reporter of a broken manifest, while this detector silently ignores every shape it cannot
|
|
36
|
+
* use. Ignoring is deliberate — an unusable `jest` block is not an error, and diagnosing one here would
|
|
37
|
+
* duplicate the manifest loader.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Match the allowlisted subset of one `jest` configuration against the declared packages.
|
|
41
|
+
*
|
|
42
|
+
* Pure and side-effect free: it takes the raw `package.json#jest` JSON value (any shape, including
|
|
43
|
+
* something that is not an object) and the declared dependency names, and returns the declared
|
|
44
|
+
* packages named by `preset`, `testEnvironment` or the values of `transform`, in alphabetical order.
|
|
45
|
+
* Neither argument is mutated, and a candidate that is not declared is dropped, so this function can
|
|
46
|
+
* never describe an undeclared package as used.
|
|
47
|
+
*
|
|
48
|
+
* @param jestConfig - The raw `package.json#jest` value, validated here and never trusted.
|
|
49
|
+
* @param declaredPackageNames - Declared dependency names, the only names this may return.
|
|
50
|
+
*/
|
|
51
|
+
export declare function findJestConfigUsage(jestConfig: unknown, declaredPackageNames: ReadonlySet<string>): ReadonlySet<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Collect the `package.json#jest` hints for the project rooted at `projectRoot`.
|
|
54
|
+
*
|
|
55
|
+
* The returned set is shaped for the analyzer's `configUsedNames` option (the Step 56 handoff), which
|
|
56
|
+
* is the only way configuration evidence reaches the analyzer. Nothing is decided here: the analyzer
|
|
57
|
+
* stays the sole owner of the unused/missing categories.
|
|
58
|
+
*
|
|
59
|
+
* No configuration problem is reported as an error. A missing manifest, an unreadable or invalid
|
|
60
|
+
* `package.json`, an unusable `jest` shape or an unreadable root all yield the empty set; the analyzer
|
|
61
|
+
* loads the manifest itself and remains the component that reports manifest failures, so this detector
|
|
62
|
+
* never replaces or duplicates that diagnosis.
|
|
63
|
+
*
|
|
64
|
+
* @param projectRoot - Project directory to inspect; resolved to an absolute path.
|
|
65
|
+
*/
|
|
66
|
+
export declare function findJestManifestUsage(projectRoot: string): Promise<ReadonlySet<string>>;
|
|
67
|
+
/**
|
|
68
|
+
* Whether a root Jest configuration file name exists in the project root.
|
|
69
|
+
*
|
|
70
|
+
* The root directory is listed by name only (`readdir`), so no entry is opened, stat-followed, read or
|
|
71
|
+
* executed. An unreadable or missing root simply means no root Jest config is known to be present.
|
|
72
|
+
* Names are compared case-insensitively so a case-insensitive filesystem (typical on Windows and
|
|
73
|
+
* macOS) cannot hide a root Jest config from this guard.
|
|
74
|
+
*/
|
|
75
|
+
export declare function hasRootJestConfigEntry(root: string): Promise<boolean>;
|
|
76
|
+
//# sourceMappingURL=jestManifestConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jestManifestConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/jestManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAwEH;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,OAAO,EACnB,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,GACxC,WAAW,CAAC,MAAM,CAAC,CAqBrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAuB7F;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAW3E"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `package.json#jest` usage detection.
|
|
3
|
+
*
|
|
4
|
+
* This module answers exactly one narrow question: which declared dependencies are named by the three
|
|
5
|
+
* explicit Jest fields this release understands inside the `jest` block of `package.json` — the
|
|
6
|
+
* top-level `preset` and `testEnvironment` strings and the values of the top-level `transform` map?
|
|
7
|
+
* The result is a set of configuration-only package names handed to the Step 56 analyzer seam, so a
|
|
8
|
+
* recognized name can only suppress an `unused` finding and can never create a `missing` one.
|
|
9
|
+
*
|
|
10
|
+
* It deliberately does not:
|
|
11
|
+
* - execute Jest, `import()`/`require()` its configuration loader, or evaluate any target code;
|
|
12
|
+
* - implement the Jest configuration schema. Only `preset`, `testEnvironment` and `transform` are
|
|
13
|
+
* read, and only through the fixed allowlists below;
|
|
14
|
+
* - read the `transform` map *keys*. Every key of that map is a regular expression selecting the
|
|
15
|
+
* files a transformer applies to, so a key is a pattern and never a package name, even when it
|
|
16
|
+
* literally reads `"ts-jest"`; no regular expression is ever evaluated here;
|
|
17
|
+
* - expand Jest shorthands. In particular `testEnvironment: "jsdom"` is *not* credited to
|
|
18
|
+
* `jest-environment-jsdom`: whether that shorthand is a package reference at all depends on the
|
|
19
|
+
* Jest major version in use, which DepVitals does not read, so it stays outside the supported
|
|
20
|
+
* subset of explicit package names;
|
|
21
|
+
* - interpret `<rootDir>/...`, `./...`, absolute paths, URLs or any other resolver-looking string as a
|
|
22
|
+
* package reference;
|
|
23
|
+
* - read `jest.config.js`/`.cjs`/`.mjs`/`.ts`/`.json` contents. Those files are only checked for
|
|
24
|
+
* presence, never opened here (source detection already handles their imports on its own);
|
|
25
|
+
* - guess a package from arbitrary configuration text, substring-match a value, or invent a name;
|
|
26
|
+
* - report anything about a package the manifest does not declare;
|
|
27
|
+
* - mutate the analyzed project.
|
|
28
|
+
*
|
|
29
|
+
* A conservative precedence guard applies before anything is read: when a root `jest.config.*` file
|
|
30
|
+
* exists, it is not provable which configuration Jest actually loads, so no `package.json#jest`
|
|
31
|
+
* hints are produced. Presence is checked by directory entry name only.
|
|
32
|
+
*
|
|
33
|
+
* The manifest model intentionally does not carry `jest`, so `package.json` is read a second time here
|
|
34
|
+
* as plain text (same trade-off as the legacy ESLint readers): the loader stays the validity gate and
|
|
35
|
+
* the single reporter of a broken manifest, while this detector silently ignores every shape it cannot
|
|
36
|
+
* use. Ignoring is deliberate — an unusable `jest` block is not an error, and diagnosing one here would
|
|
37
|
+
* duplicate the manifest loader.
|
|
38
|
+
*/
|
|
39
|
+
import { readdir } from 'node:fs/promises';
|
|
40
|
+
import { resolve } from 'node:path';
|
|
41
|
+
import { loadProjectManifest, ProjectManifestError, readManifestText, } from '../scanner/projectManifest.js';
|
|
42
|
+
import { assertReadableRoot, SourceFilesError } from '../scanner/sourceFiles.js';
|
|
43
|
+
import { classifyPackageSpecifier } from '../scanner/packageSpecifier.js';
|
|
44
|
+
/**
|
|
45
|
+
* The only `preset` packages recognized by this release.
|
|
46
|
+
*
|
|
47
|
+
* A fixed allowlist, not a resolution algorithm: `ts-jest` is supported because it is the published
|
|
48
|
+
* package name of the preset itself, so the string is already a complete package reference and needs
|
|
49
|
+
* no Jest-version knowledge to interpret. Any other preset name is unsupported and contributes no
|
|
50
|
+
* evidence, since guessing what an unknown preset string resolves to would create false confidence.
|
|
51
|
+
*
|
|
52
|
+
* A literal subpath of an allowlisted package (`"ts-jest/presets/default-esm"`) is accepted too,
|
|
53
|
+
* through the existing package-root normalization in {@link classifyPackageSpecifier}: the first path
|
|
54
|
+
* segment of such a specifier is the package that provides the preset.
|
|
55
|
+
*/
|
|
56
|
+
const PRESET_PACKAGE_NAMES = new Set(['ts-jest']);
|
|
57
|
+
/**
|
|
58
|
+
* The only `testEnvironment` packages recognized by this release.
|
|
59
|
+
*
|
|
60
|
+
* Again the complete package name only; the `"jsdom"` shorthand is deliberately absent from this
|
|
61
|
+
* release. Where Jest accepts `"jsdom"`, it does resolve it to the separately installed
|
|
62
|
+
* `jest-environment-jsdom` package - but whether that shorthand is available at all depends on the
|
|
63
|
+
* Jest major version (up to v27 the jsdom environment shipped inside Jest itself, so such a project
|
|
64
|
+
* declares no package to credit), and DepVitals neither reads nor resolves the Jest version of an
|
|
65
|
+
* analyzed project. The supported subset is therefore fixed to the exact package name; shorthand
|
|
66
|
+
* resolution is a separate change that must first define which Jest versions it applies to.
|
|
67
|
+
*/
|
|
68
|
+
const TEST_ENVIRONMENT_PACKAGE_NAMES = new Set(['jest-environment-jsdom']);
|
|
69
|
+
/**
|
|
70
|
+
* The only `transform` packages recognized by this release.
|
|
71
|
+
*
|
|
72
|
+
* A separate fixed allowlist rather than a reuse of the `preset` one: `ts-jest` is the only
|
|
73
|
+
* transformer credited, and it is supported for the same reason as the preset — the string is already
|
|
74
|
+
* the complete published package name, so nothing has to be resolved or versioned to interpret it.
|
|
75
|
+
* `jest-environment-jsdom` is deliberately absent, because a test environment is not a transformer;
|
|
76
|
+
* no other transform module is resolved, guessed, searched for in `node_modules` or matched by
|
|
77
|
+
* prefix, and transform maps are never flattened or searched recursively.
|
|
78
|
+
*/
|
|
79
|
+
const TRANSFORM_PACKAGE_NAMES = new Set(['ts-jest']);
|
|
80
|
+
/**
|
|
81
|
+
* Root Jest configuration file names that disable `package.json#jest` hints.
|
|
82
|
+
*
|
|
83
|
+
* The list is fixed to the extensions named by the supported contract; `jest.config.mts` and other
|
|
84
|
+
* spellings are not part of it, which only makes the guard narrower (it can drop hints, never add
|
|
85
|
+
* them). Presence of any listed name at the project root is enough; the file itself is never read or
|
|
86
|
+
* executed.
|
|
87
|
+
*
|
|
88
|
+
* Compared case-insensitively (see {@link hasRootJestConfigEntry}) because a case-insensitive
|
|
89
|
+
* filesystem treats `Jest.Config.JS` as the same file, and DepVitals must not disagree with itself
|
|
90
|
+
* about one project depending on the platform it runs on.
|
|
91
|
+
*/
|
|
92
|
+
const JEST_CONFIG_ENTRY_NAMES = new Set([
|
|
93
|
+
'jest.config.js',
|
|
94
|
+
'jest.config.mjs',
|
|
95
|
+
'jest.config.cjs',
|
|
96
|
+
'jest.config.ts',
|
|
97
|
+
'jest.config.json',
|
|
98
|
+
]);
|
|
99
|
+
/**
|
|
100
|
+
* Match the allowlisted subset of one `jest` configuration against the declared packages.
|
|
101
|
+
*
|
|
102
|
+
* Pure and side-effect free: it takes the raw `package.json#jest` JSON value (any shape, including
|
|
103
|
+
* something that is not an object) and the declared dependency names, and returns the declared
|
|
104
|
+
* packages named by `preset`, `testEnvironment` or the values of `transform`, in alphabetical order.
|
|
105
|
+
* Neither argument is mutated, and a candidate that is not declared is dropped, so this function can
|
|
106
|
+
* never describe an undeclared package as used.
|
|
107
|
+
*
|
|
108
|
+
* @param jestConfig - The raw `package.json#jest` value, validated here and never trusted.
|
|
109
|
+
* @param declaredPackageNames - Declared dependency names, the only names this may return.
|
|
110
|
+
*/
|
|
111
|
+
export function findJestConfigUsage(jestConfig, declaredPackageNames) {
|
|
112
|
+
if (!isPlainRecord(jestConfig)) {
|
|
113
|
+
return new Set();
|
|
114
|
+
}
|
|
115
|
+
const candidates = [
|
|
116
|
+
...matchAllowedPackage(jestConfig['preset'], PRESET_PACKAGE_NAMES),
|
|
117
|
+
...matchAllowedPackage(jestConfig['testEnvironment'], TEST_ENVIRONMENT_PACKAGE_NAMES),
|
|
118
|
+
...matchTransformValues(jestConfig['transform'], TRANSFORM_PACKAGE_NAMES),
|
|
119
|
+
];
|
|
120
|
+
const used = new Set();
|
|
121
|
+
for (const candidate of candidates) {
|
|
122
|
+
if (declaredPackageNames.has(candidate)) {
|
|
123
|
+
used.add(candidate);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Rebuilt from sorted names so iteration is deterministic for every input.
|
|
127
|
+
return new Set([...used].sort(compareNames));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Collect the `package.json#jest` hints for the project rooted at `projectRoot`.
|
|
131
|
+
*
|
|
132
|
+
* The returned set is shaped for the analyzer's `configUsedNames` option (the Step 56 handoff), which
|
|
133
|
+
* is the only way configuration evidence reaches the analyzer. Nothing is decided here: the analyzer
|
|
134
|
+
* stays the sole owner of the unused/missing categories.
|
|
135
|
+
*
|
|
136
|
+
* No configuration problem is reported as an error. A missing manifest, an unreadable or invalid
|
|
137
|
+
* `package.json`, an unusable `jest` shape or an unreadable root all yield the empty set; the analyzer
|
|
138
|
+
* loads the manifest itself and remains the component that reports manifest failures, so this detector
|
|
139
|
+
* never replaces or duplicates that diagnosis.
|
|
140
|
+
*
|
|
141
|
+
* @param projectRoot - Project directory to inspect; resolved to an absolute path.
|
|
142
|
+
*/
|
|
143
|
+
export async function findJestManifestUsage(projectRoot) {
|
|
144
|
+
const root = resolve(projectRoot);
|
|
145
|
+
if (await hasRootJestConfigEntry(root)) {
|
|
146
|
+
return new Set();
|
|
147
|
+
}
|
|
148
|
+
let packageJsonPath;
|
|
149
|
+
let declaredPackageNames;
|
|
150
|
+
try {
|
|
151
|
+
const manifest = await loadProjectManifest(root);
|
|
152
|
+
packageJsonPath = manifest.packageJsonPath;
|
|
153
|
+
declaredPackageNames = manifest.declaredDependencyNames;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (error instanceof ProjectManifestError || error instanceof SourceFilesError) {
|
|
157
|
+
return new Set();
|
|
158
|
+
}
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
return findJestConfigUsage(await readJestConfigValue(packageJsonPath), declaredPackageNames);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Whether a root Jest configuration file name exists in the project root.
|
|
165
|
+
*
|
|
166
|
+
* The root directory is listed by name only (`readdir`), so no entry is opened, stat-followed, read or
|
|
167
|
+
* executed. An unreadable or missing root simply means no root Jest config is known to be present.
|
|
168
|
+
* Names are compared case-insensitively so a case-insensitive filesystem (typical on Windows and
|
|
169
|
+
* macOS) cannot hide a root Jest config from this guard.
|
|
170
|
+
*/
|
|
171
|
+
export async function hasRootJestConfigEntry(root) {
|
|
172
|
+
let entries;
|
|
173
|
+
try {
|
|
174
|
+
await assertReadableRoot(root);
|
|
175
|
+
entries = await readdir(root);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return entries.some((entry) => JEST_CONFIG_ENTRY_NAMES.has(entry.toLowerCase()));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Read the raw `package.json#jest` value, ignoring everything that cannot be used.
|
|
184
|
+
*
|
|
185
|
+
* The manifest is read as text and parsed with `JSON.parse`, so no target-project code runs. An
|
|
186
|
+
* unreadable file, invalid JSON, a non-object document or an absent `jest` key all yield `undefined`;
|
|
187
|
+
* the loader-facing diagnosis of a broken manifest stays in {@link loadProjectManifest}.
|
|
188
|
+
*/
|
|
189
|
+
async function readJestConfigValue(packageJsonPath) {
|
|
190
|
+
let text;
|
|
191
|
+
try {
|
|
192
|
+
text = await readManifestText(packageJsonPath);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
let parsed;
|
|
198
|
+
try {
|
|
199
|
+
parsed = JSON.parse(text);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
return isPlainRecord(parsed) ? parsed['jest'] : undefined;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The single allowlisted package named by one static string value, if any.
|
|
208
|
+
*
|
|
209
|
+
* Only strings are considered: a number, `null`, an array or an object contributes nothing, so a
|
|
210
|
+
* malformed field never becomes evidence. The string is classified with the shared package-specifier
|
|
211
|
+
* rules, which reject relative and absolute paths (`"./local.js"`, `"/opt/preset.js"`) and URI forms
|
|
212
|
+
* such as `"file:./preset.js"` as internal or unsupported. Whatever package root survives must then
|
|
213
|
+
* be an exact member of `allowedPackages`, and that exact-name rule is what rejects the remaining
|
|
214
|
+
* resolver-shaped values, including `<rootDir>/presets/x.js` (its first segment `<rootDir>` is not a
|
|
215
|
+
* package name DepVitals will ever allow) and `"ts-jest-extras"`. There is no prefix, suffix,
|
|
216
|
+
* substring or case-insensitive matching, so `"jsdom"`, `"TS-Jest"` and
|
|
217
|
+
* `"jest-environment-node"` never match an entry.
|
|
218
|
+
*/
|
|
219
|
+
function matchAllowedPackage(value, allowedPackages) {
|
|
220
|
+
if (typeof value !== 'string') {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
const specifier = classifyPackageSpecifier(value);
|
|
224
|
+
if (specifier.kind !== 'external') {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
return allowedPackages.has(specifier.packageName) ? [specifier.packageName] : [];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The allowlisted packages named by the *values* of one `jest.transform` map.
|
|
231
|
+
*
|
|
232
|
+
* Only values are read: `Object.values` is used precisely so that a key can never become evidence.
|
|
233
|
+
* Every key of a Jest transform map is a regular expression such as `"^.+\\.tsx?$"`, and a key that
|
|
234
|
+
* happens to read `"ts-jest"` is still only a pattern, so it credits nothing. A `transform` field
|
|
235
|
+
* that is not a plain JSON object (an array, a string, a number, `null`, absent) contributes nothing.
|
|
236
|
+
*/
|
|
237
|
+
function matchTransformValues(transform, allowedPackages) {
|
|
238
|
+
if (!isPlainRecord(transform)) {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
const matches = [];
|
|
242
|
+
for (const value of Object.values(transform)) {
|
|
243
|
+
matches.push(...matchTransformValue(value, allowedPackages));
|
|
244
|
+
}
|
|
245
|
+
return matches;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The allowlisted package named by one `jest.transform` value, if any.
|
|
249
|
+
*
|
|
250
|
+
* Exactly two shapes are supported, and no others:
|
|
251
|
+
*
|
|
252
|
+
* - the transformer string itself, `"ts-jest"`, matched by the same rules as the other supported
|
|
253
|
+
* Jest fields - the value is classified first and must then be an exact member of
|
|
254
|
+
* `allowedPackages`, so `"./local-transform.js"`, `"<rootDir>/transform.js"`, `"file:./t.js"`,
|
|
255
|
+
* `""`, `"ts jest"`, `"ts-jest-extras"` and every other module yield nothing. As in `preset`, a
|
|
256
|
+
* literal subpath of an allowlisted package collapses to its package root
|
|
257
|
+
* (`"ts-jest/preprocessor.js"`, the historical ts-jest transformer path), because the first path
|
|
258
|
+
* segment still names the package that provides the transformer;
|
|
259
|
+
* - the `[transformer, options]` tuple: exactly two elements, the second a JSON options object, the
|
|
260
|
+
* first matched as above. The options object is only checked for being an object and is never
|
|
261
|
+
* inspected, so a supported package name that appears only inside it - as a label or an option
|
|
262
|
+
* value - is not evidence.
|
|
263
|
+
*
|
|
264
|
+
* A one- or three-element array, a non-object second tuple element, an object used in place of the
|
|
265
|
+
* whole value or any other shape is outside the supported subset and yields nothing.
|
|
266
|
+
*/
|
|
267
|
+
function matchTransformValue(value, allowedPackages) {
|
|
268
|
+
if (Array.isArray(value)) {
|
|
269
|
+
if (value.length !== 2 || !isPlainRecord(value[1])) {
|
|
270
|
+
return [];
|
|
271
|
+
}
|
|
272
|
+
return matchAllowedPackage(value[0], allowedPackages);
|
|
273
|
+
}
|
|
274
|
+
return matchAllowedPackage(value, allowedPackages);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A JSON object (not an array, not `null`) whose keys are strings.
|
|
278
|
+
*/
|
|
279
|
+
function isPlainRecord(value) {
|
|
280
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Locale-independent lexicographic ordering, so the same configuration always yields the same order.
|
|
284
|
+
*/
|
|
285
|
+
function compareNames(a, b) {
|
|
286
|
+
if (a < b) {
|
|
287
|
+
return -1;
|
|
288
|
+
}
|
|
289
|
+
if (a > b) {
|
|
290
|
+
return 1;
|
|
291
|
+
}
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=jestManifestConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jestManifestConfig.js","sourceRoot":"","sources":["../../src/detectors/jestManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,MAAM,8BAA8B,GAAwB,IAAI,GAAG,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAEhG;;;;;;;;;GASG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAC3D,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;CACnB,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAmB,EACnB,oBAAyC;IAEzC,IAAI,CAAC,aAAa,CAAC,UAAU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c;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -79,7 +79,33 @@ function findingsSections(result) {
|
|
|
79
79
|
function renderSection(section) {
|
|
80
80
|
const names = [...section.names].sort(compareNames);
|
|
81
81
|
const count = String(names.length);
|
|
82
|
-
|
|
82
|
+
// Package names come from target-project source, so a hostile name may carry a terminal control
|
|
83
|
+
// sequence (for example an ESC decoded from `"\x1b[2J"`). Escape C0/C1 control codes and DEL as
|
|
84
|
+
// `\uXXXX` before rendering, so the report can never alter the user's display.
|
|
85
|
+
return [
|
|
86
|
+
`${section.heading} (${count})`,
|
|
87
|
+
...names.map((name) => ` ${escapeControlCharacters(name)}`),
|
|
88
|
+
].join('\n');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Escape C0/C1 control characters and DEL as `\uXXXX` so a package name extracted from target
|
|
92
|
+
* source can never carry a terminal control sequence (such as an ESC from `"\x1b[2J"`) into the
|
|
93
|
+
* rendered report. Printable characters pass through unchanged.
|
|
94
|
+
*
|
|
95
|
+
* The scan is written as explicit code points instead of a control-character regex range so the
|
|
96
|
+
* ESLint `no-control-regex` rule stays meaningful.
|
|
97
|
+
*/
|
|
98
|
+
function escapeControlCharacters(value) {
|
|
99
|
+
let out = '';
|
|
100
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
101
|
+
const code = value.charCodeAt(index);
|
|
102
|
+
if (code < 0x20 || (code >= 0x7f && code <= 0x9f)) {
|
|
103
|
+
out += `\\u${code.toString(16).padStart(4, '0')}`;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
out += value[index] ?? '';
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
83
109
|
}
|
|
84
110
|
/**
|
|
85
111
|
* Locale-independent lexicographic (codepoint) ordering, matching the comparator convention already
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminalReporter.js","sourceRoot":"","sources":["../../src/reporters/terminalReporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,yDAAyD;AACzD,MAAM,MAAM,GAAG,WAAW,CAAC;AAE3B,2EAA2E;AAC3E,MAAM,YAAY,GAAG,GAAG,MAAM,mCAAmC,CAAC;AAQlE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,OAAO,CACL,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;QACpC,MAAM,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC;QACvC,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CACtC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAsB;IACzD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExF,OAAO,GAAG,MAAM,OAAO,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,MAAsB;IAC9C,OAAO;QACL,EAAE,OAAO,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I,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;YAClD,GAAG,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;YAClD,SAAS;QACX,CAAC;QAED,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -48,6 +48,14 @@ export declare class ModuleSpecifierError extends Error {
|
|
|
48
48
|
readonly offset: number;
|
|
49
49
|
constructor(message: string, code: ModuleSpecifierErrorCode, offset: number);
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Options for {@link extractModuleSpecifiers}.
|
|
53
|
+
*/
|
|
54
|
+
export type ExtractModuleSpecifiersOptions = {
|
|
55
|
+
jsx?: boolean;
|
|
56
|
+
/** Explicit module/script grammar, or bounded syntax detection for ambiguous `.js` input. */
|
|
57
|
+
module?: boolean | 'detect';
|
|
58
|
+
};
|
|
51
59
|
/**
|
|
52
60
|
* Extract the statically knowable module specifiers from `source`.
|
|
53
61
|
*
|
|
@@ -56,5 +64,5 @@ export declare class ModuleSpecifierError extends Error {
|
|
|
56
64
|
* @throws {ModuleSpecifierError} when the source reaches an unterminated or malformed lexical state
|
|
57
65
|
* from which the scanner cannot safely continue.
|
|
58
66
|
*/
|
|
59
|
-
export declare function extractModuleSpecifiers(source: string): readonly ModuleSpecifierOccurrence[];
|
|
67
|
+
export declare function extractModuleSpecifiers(source: string, options?: ExtractModuleSpecifiersOptions): readonly ModuleSpecifierOccurrence[];
|
|
60
68
|
//# sourceMappingURL=moduleSpecifiers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moduleSpecifiers.d.ts","sourceRoot":"","sources":["../../src/scanner/moduleSpecifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAExD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM;CAM5E;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"moduleSpecifiers.d.ts","sourceRoot":"","sources":["../../src/scanner/moduleSpecifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF;;;;;;GAM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