dependency-cruiser 18.1.0 → 18.1.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/configs/plugins/3d-reporter-plugin.mjs +1 -1
- package/configs/plugins/stats-reporter-plugin.mjs +2 -2
- package/package.json +3 -3
- package/src/analyze/add-validations.mjs +1 -1
- package/src/analyze/derive/folders/utl.mjs +2 -2
- package/src/analyze/summarize/summarize-modules.mjs +1 -1
- package/src/cache/cache.mjs +4 -4
- package/src/cache/helpers.mjs +2 -2
- package/src/cli/format-meta-info.mjs +3 -3
- package/src/cli/index.mjs +2 -2
- package/src/cli/init-config/check-and-warn-inconsistencies.mjs +3 -3
- package/src/cli/init-config/environment-helpers.mjs +4 -4
- package/src/cli/init-config/get-user-input.mjs +1 -1
- package/src/cli/init-config/index.mjs +1 -1
- package/src/cli/init-config/normalize-init-options.mjs +3 -3
- package/src/cli/init-config/validators.mjs +1 -1
- package/src/cli/init-config/write-run-scripts-to-manifest.mjs +2 -2
- package/src/cli/listeners/ndjson.mjs +1 -1
- package/src/cli/listeners/performance-log/index.mjs +1 -1
- package/src/cli/normalize-cli-options.mjs +6 -4
- package/src/cli/utl/assert-file-existence.mjs +1 -1
- package/src/config-utl/extract-babel-config.mjs +3 -1
- package/src/config-utl/extract-depcruise-config/index.mjs +1 -1
- package/src/config-utl/extract-depcruise-config/merge-configs.mjs +5 -3
- package/src/config-utl/extract-ts-config.mjs +1 -1
- package/src/config-utl/extract-webpack-resolve-config.mjs +2 -2
- package/src/extract/acorn/extract.mjs +1 -1
- package/src/extract/acorn/parse.mjs +2 -2
- package/src/extract/extract-dependencies.mjs +1 -1
- package/src/extract/extract-stats.mjs +1 -1
- package/src/extract/gather-initial-sources.mjs +1 -1
- package/src/extract/helpers.mjs +1 -1
- package/src/extract/index.mjs +1 -1
- package/src/extract/resolve/determine-dependency-types.mjs +3 -2
- package/src/extract/resolve/external-module-helpers.mjs +8 -8
- package/src/extract/resolve/get-manifest.mjs +7 -7
- package/src/extract/resolve/index.mjs +2 -1
- package/src/extract/resolve/merge-manifests.mjs +2 -2
- package/src/extract/resolve/module-classifiers.mjs +1 -1
- package/src/extract/resolve/resolve-amd.mjs +1 -1
- package/src/extract/resolve/resolve-cjs.mjs +2 -2
- package/src/extract/resolve/resolve-helpers.mjs +1 -1
- package/src/extract/resolve/resolve.mjs +2 -2
- package/src/extract/swc/dependency-visitor.mjs +1 -0
- package/src/extract/swc/parse.mjs +2 -2
- package/src/extract/transpile/index.mjs +1 -1
- package/src/extract/transpile/meta.mjs +1 -1
- package/src/extract/transpile/try-import-available.mjs +1 -1
- package/src/extract/transpile/typescript-wrap.mjs +1 -1
- package/src/extract/tsc/extract-typescript-deps.mjs +1 -1
- package/src/extract/tsc/parse.mjs +3 -3
- package/src/graph-utl/add-focus.mjs +1 -1
- package/src/graph-utl/consolidate-to-pattern.mjs +1 -0
- package/src/graph-utl/indexed-module-graph.mjs +6 -6
- package/src/graph-utl/module-graph-with-dependency-set.mjs +1 -1
- package/src/graph-utl/rule-set.mjs +3 -3
- package/src/main/cruise.mjs +1 -1
- package/src/main/helpers.mjs +1 -1
- package/src/main/options/normalize.mjs +2 -2
- package/src/main/resolve-options/normalize.mjs +2 -2
- package/src/main/rule-set/assert-validity.mjs +1 -1
- package/src/main/rule-set/normalize.mjs +1 -1
- package/src/meta.cjs +1 -1
- package/src/report/anon/anonymize-path-element.mjs +1 -1
- package/src/report/anon/index.mjs +1 -1
- package/src/report/anon/random-string.mjs +1 -1
- package/src/report/azure-devops.mjs +2 -2
- package/src/report/baseline.mjs +1 -1
- package/src/report/d2.mjs +3 -3
- package/src/report/dot/index.mjs +1 -1
- package/src/report/dot/module-utl.mjs +2 -2
- package/src/report/dot/theming.mjs +12 -6
- package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +7 -7
- package/src/report/error.mjs +1 -1
- package/src/report/html/index.mjs +2 -2
- package/src/report/index.mjs +1 -0
- package/src/report/markdown.mjs +3 -3
- package/src/report/mermaid.mjs +3 -3
- package/src/report/metrics.mjs +2 -2
- package/src/report/plugins.mjs +2 -1
- package/src/report/teamcity.mjs +2 -2
- package/src/report/utl/dependency-to-incidence-transformer.mjs +1 -1
- package/src/report/utl/index.mjs +1 -1
- package/src/utl/array-util.mjs +1 -1
- package/src/utl/find-all-files.mjs +1 -1
- package/src/utl/get-extension.mjs +1 -1
- package/src/utl/path-to-posix.mjs +1 -1
- package/src/utl/regex-util.mjs +3 -1
- package/src/utl/try-import.mjs +1 -1
- package/src/utl/try-require.cjs +3 -3
- package/src/validate/index.mjs +2 -2
- package/types/config-utl/extract-babel-config.d.mts +1 -1
- package/types/config-utl/extract-depcruise-config.d.mts +1 -1
- package/types/config-utl/extract-depcruise-options.d.mts +1 -1
- package/types/config-utl/extract-ts-config.d.mts +1 -1
- package/types/config-utl/extract-webpack-resolve-config.d.mts +1 -1
- package/types/plugins/3d-reporter-plugin.d.mts +1 -1
- package/types/plugins/mermaid-reporter-plugin.d.mts +1 -1
- package/types/plugins/stats-reporter-plugin.d.mts +1 -1
|
@@ -114,7 +114,7 @@ function render3DThing(pCruiseResult) {
|
|
|
114
114
|
* @param {import('../../types/dependency-cruiser').ICruiseResult} pCruiseResult -
|
|
115
115
|
* the output of a dependency-cruise adhering to dependency-cruiser's
|
|
116
116
|
* cruise result schema
|
|
117
|
-
* @
|
|
117
|
+
* @returns {import('../../types/dependency-cruiser').IReporterOutput} -
|
|
118
118
|
* output: a string
|
|
119
119
|
* exitCode: 0
|
|
120
120
|
*/
|
|
@@ -34,7 +34,7 @@ function doMagic(pCruiseResult) {
|
|
|
34
34
|
* got passed
|
|
35
35
|
*
|
|
36
36
|
* @param {import('../../types/dependency-cruiser').ICruiseResult} pCruiseResult - a result from a cruise.
|
|
37
|
-
* @
|
|
37
|
+
* @returns {string} an object with some stats
|
|
38
38
|
*/
|
|
39
39
|
function samplePluginReporter(pCruiseResult) {
|
|
40
40
|
const lDependencyCounts = pCruiseResult.modules
|
|
@@ -68,7 +68,7 @@ function samplePluginReporter(pCruiseResult) {
|
|
|
68
68
|
* @param {import('../../types/dependency-cruiser').ICruiseResult} pCruiseResult -
|
|
69
69
|
* the output of a dependency-cruise adhering to dependency-cruiser's
|
|
70
70
|
* cruise result schema
|
|
71
|
-
* @
|
|
71
|
+
* @returns {import('../../types/dependency-cruiser').IReporterOutput} -
|
|
72
72
|
* output: some stats on modules and dependencies in json format
|
|
73
73
|
* exitCode: 0
|
|
74
74
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.1",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -143,13 +143,13 @@
|
|
|
143
143
|
"README.md"
|
|
144
144
|
],
|
|
145
145
|
"dependencies": {
|
|
146
|
-
"acorn": "8.
|
|
146
|
+
"acorn": "8.18.0",
|
|
147
147
|
"acorn-jsx": "5.3.2",
|
|
148
148
|
"acorn-jsx-walk": "2.0.0",
|
|
149
149
|
"acorn-loose": "8.5.2",
|
|
150
150
|
"acorn-walk": "8.3.5",
|
|
151
151
|
"commander": "15.0.0",
|
|
152
|
-
"enhanced-resolve": "5.24.
|
|
152
|
+
"enhanced-resolve": "5.24.5",
|
|
153
153
|
"ignore": "7.0.6",
|
|
154
154
|
"interpret": "3.1.1",
|
|
155
155
|
"is-installed-globally": "1.0.0",
|
|
@@ -17,7 +17,7 @@ function addDependencyViolations(pModule, pDependency, pRuleSet, pValidate) {
|
|
|
17
17
|
* @param {Partial<import("../../types/cruise-result.mjs").IModule>[]} pModules array of modules
|
|
18
18
|
* @param {import("../../types/rule-set.mjs").IFlattenedRuleSet} pRuleSet normalized & validated rule set
|
|
19
19
|
* @param {boolean} pValidate - whether or not to validate (typically you want to pass 'true' here)
|
|
20
|
-
* @
|
|
20
|
+
* @returns {import("../../types/cruise-result.mjs").IModule[]} the same array of modules, with for each
|
|
21
21
|
* of them added whether or not it is
|
|
22
22
|
* valid and if not which rules were violated
|
|
23
23
|
*/
|
|
@@ -23,8 +23,8 @@ export function getEfferentCouplings(pModule, pDirname) {
|
|
|
23
23
|
* @returns string[]
|
|
24
24
|
*/
|
|
25
25
|
export function getParentFolders(pPath) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const lFragments = pPath.split("/");
|
|
27
|
+
const lReturnValue = [];
|
|
28
28
|
|
|
29
29
|
while (lFragments.length > 0) {
|
|
30
30
|
lReturnValue.push(lFragments.join("/"));
|
|
@@ -69,7 +69,7 @@ function toDependencyViolationSummary(pRule, pModule, pDependency, pRuleSet) {
|
|
|
69
69
|
*
|
|
70
70
|
* @param {any} pModules an array of modules
|
|
71
71
|
* @param {any} pRuleSet? a rule set
|
|
72
|
-
* @
|
|
72
|
+
* @returns {any} an array of violations
|
|
73
73
|
*/
|
|
74
74
|
function extractDependencyViolations(pModules, pRuleSet) {
|
|
75
75
|
return pModules
|
package/src/cache/cache.mjs
CHANGED
|
@@ -115,7 +115,7 @@ export default class Cache {
|
|
|
115
115
|
lPayload = await readFile(join(pCacheFolder, CACHE_FILE_NAME), "utf8");
|
|
116
116
|
}
|
|
117
117
|
return JSON.parse(lPayload);
|
|
118
|
-
} catch
|
|
118
|
+
} catch {
|
|
119
119
|
return EMPTY_CACHE;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -123,7 +123,7 @@ export default class Cache {
|
|
|
123
123
|
/**
|
|
124
124
|
* @param {string} pPayload
|
|
125
125
|
* @param {boolean} pCompress
|
|
126
|
-
* @
|
|
126
|
+
* @returns {Buffer|string}
|
|
127
127
|
*/
|
|
128
128
|
#compact(pPayload, pCompress) {
|
|
129
129
|
if (pCompress) {
|
|
@@ -144,7 +144,7 @@ export default class Cache {
|
|
|
144
144
|
* @param {IRevisionData=} pRevisionData
|
|
145
145
|
*/
|
|
146
146
|
async write(pCacheFolder, pCruiseResult, pRevisionData) {
|
|
147
|
-
|
|
147
|
+
const lRevisionData = pRevisionData ?? this.#revisionData;
|
|
148
148
|
|
|
149
149
|
await mkdir(pCacheFolder, { recursive: true });
|
|
150
150
|
const lUncompressedPayload = JSON.stringify(
|
|
@@ -153,7 +153,7 @@ export default class Cache {
|
|
|
153
153
|
lRevisionData,
|
|
154
154
|
),
|
|
155
155
|
);
|
|
156
|
-
|
|
156
|
+
const lPayload = this.#compact(lUncompressedPayload, this.#compress);
|
|
157
157
|
|
|
158
158
|
// relying on writeFile defaults to 'do the right thing' (i.e. utf8
|
|
159
159
|
// when the payload is a string; raw buffer otherwise)
|
package/src/cache/helpers.mjs
CHANGED
|
@@ -37,7 +37,7 @@ export function getFileHashSync(pFileName) {
|
|
|
37
37
|
let lHashedFileName = "file not found";
|
|
38
38
|
try {
|
|
39
39
|
lHashedFileName = hash(readFileSync(pFileName, "utf8"));
|
|
40
|
-
} catch
|
|
40
|
+
} catch {
|
|
41
41
|
// will return "file not found" as per default
|
|
42
42
|
}
|
|
43
43
|
HASHES_CACHE.set(pFileName, lHashedFileName);
|
|
@@ -46,7 +46,7 @@ export function getFileHashSync(pFileName) {
|
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* @param {IChange} pChange
|
|
49
|
-
* @
|
|
49
|
+
* @returns {IRevisionChange}
|
|
50
50
|
*/
|
|
51
51
|
export function addCheckSumToChangeSync(pChange) {
|
|
52
52
|
return {
|
|
@@ -10,12 +10,12 @@ const MAX_TRANSPILER_NAME_LENGTH = 22;
|
|
|
10
10
|
const MAX_VERSION_STRING_LENGTH = 24;
|
|
11
11
|
|
|
12
12
|
function formatTranspilers(pAvailableTranspilers) {
|
|
13
|
-
|
|
13
|
+
const lTranspilerTableHeader = styleText(
|
|
14
14
|
"bold",
|
|
15
15
|
` ✔ ${"transpiler".padEnd(MAX_TRANSPILER_NAME_LENGTH)} ${"versions supported".padEnd(MAX_VERSION_RANGE_STRING_LENGTH)} version found`,
|
|
16
16
|
);
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const lTranspilerTableDivider = ` - ${"-".repeat(MAX_TRANSPILER_NAME_LENGTH)} ${"-".repeat(MAX_VERSION_RANGE_STRING_LENGTH)} ${"-".repeat(MAX_VERSION_STRING_LENGTH)}`;
|
|
18
|
+
const lTranspilerTable = pAvailableTranspilers
|
|
19
19
|
.map(
|
|
20
20
|
(pTranspiler) =>
|
|
21
21
|
` ${bool2Symbol(pTranspiler.available)} ${pTranspiler.name.padEnd(MAX_TRANSPILER_NAME_LENGTH)} ${pTranspiler.version.padEnd(MAX_VERSION_RANGE_STRING_LENGTH)} ${pTranspiler.currentVersion}`,
|
package/src/cli/index.mjs
CHANGED
|
@@ -41,7 +41,7 @@ async function addKnownViolations(pCruiseOptions) {
|
|
|
41
41
|
|
|
42
42
|
// Check against json schema is already done in src/main/options/validate
|
|
43
43
|
// so here we can just concentrate on the io
|
|
44
|
-
|
|
44
|
+
const lCruiseOptions = structuredClone(pCruiseOptions);
|
|
45
45
|
set(lCruiseOptions, "ruleSet.options.knownViolations", lKnownViolations);
|
|
46
46
|
return lCruiseOptions;
|
|
47
47
|
}
|
|
@@ -150,7 +150,7 @@ export default async function executeCli(
|
|
|
150
150
|
stderr: process.stderr,
|
|
151
151
|
...(pStreams || {}),
|
|
152
152
|
};
|
|
153
|
-
|
|
153
|
+
const lCruiseOptions = pCruiseOptions || {};
|
|
154
154
|
let lExitCode = 0;
|
|
155
155
|
|
|
156
156
|
try {
|
|
@@ -16,7 +16,7 @@ import { getAvailableTranspilers } from "#extract/transpile/meta.mjs";
|
|
|
16
16
|
*
|
|
17
17
|
* @param {IInitConfig} pInitOptions
|
|
18
18
|
* @param {IAvailableTranspiler[]} pAvailableTranspilers
|
|
19
|
-
* @
|
|
19
|
+
* @returns {boolean}
|
|
20
20
|
*/
|
|
21
21
|
function typescriptIsConsistent(pInitOptions, pAvailableTranspilers) {
|
|
22
22
|
if (pInitOptions.usesTypeScript) {
|
|
@@ -37,7 +37,7 @@ function typescriptIsConsistent(pInitOptions, pAvailableTranspilers) {
|
|
|
37
37
|
*
|
|
38
38
|
* @param {IInitConfig} pInitOptions
|
|
39
39
|
* @param {IAvailableTranspiler[]} pAvailableTranspilers
|
|
40
|
-
* @
|
|
40
|
+
* @returns {boolean}
|
|
41
41
|
*/
|
|
42
42
|
function babelIsConsistent(pInitOptions, pAvailableTranspilers) {
|
|
43
43
|
if (pInitOptions.babelConfig) {
|
|
@@ -57,7 +57,7 @@ function babelIsConsistent(pInitOptions, pAvailableTranspilers) {
|
|
|
57
57
|
* @param {IInitConfig} pInitOptions
|
|
58
58
|
* @param {NodeJS.WritableStream} [pErrorStream]
|
|
59
59
|
* @param {typeof getAvailableTranspilers} [pAvailableTranspilerFunction]
|
|
60
|
-
* @
|
|
60
|
+
* @returns {IInitConfig} pInitOptions
|
|
61
61
|
*/
|
|
62
62
|
export function checkAndWarnInconsistencies(
|
|
63
63
|
pInitOptions,
|
|
@@ -38,7 +38,7 @@ export function readManifest(pManifestFileName = "./package.json") {
|
|
|
38
38
|
export function fileExists(pFile) {
|
|
39
39
|
try {
|
|
40
40
|
accessSync(pFile, constants.R_OK);
|
|
41
|
-
} catch
|
|
41
|
+
} catch {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
return true;
|
|
@@ -53,7 +53,7 @@ function babelIsConfiguredInManifest() {
|
|
|
53
53
|
try {
|
|
54
54
|
// @ts-expect-error defaultly tsc doesn't know about newfangled stuff like hasOwn
|
|
55
55
|
lReturnValue = Object.hasOwn(readManifest(), "babel");
|
|
56
|
-
} catch
|
|
56
|
+
} catch {
|
|
57
57
|
// silently ignore - we'll return false anyway then
|
|
58
58
|
}
|
|
59
59
|
return lReturnValue;
|
|
@@ -67,7 +67,7 @@ export function isTypeModule() {
|
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
69
|
lReturnValue = (readManifest()?.type ?? "commonjs") === "module";
|
|
70
|
-
} catch
|
|
70
|
+
} catch {
|
|
71
71
|
// silently ignore - we'll return false anyway then
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -112,7 +112,7 @@ function getPackageManager(pManifest) {
|
|
|
112
112
|
if (Object.hasOwn(lManifest, "packageManager")) {
|
|
113
113
|
lReturnValue = lManifest.packageManager;
|
|
114
114
|
}
|
|
115
|
-
} catch
|
|
115
|
+
} catch {
|
|
116
116
|
// silently ignore - we'll return the empty string anyway then
|
|
117
117
|
}
|
|
118
118
|
return lReturnValue;
|
|
@@ -163,7 +163,7 @@ const QUESTIONS = [
|
|
|
163
163
|
];
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
* @
|
|
166
|
+
* @returns {Promise<import("./types.d.mts").IPartialInitConfig>}
|
|
167
167
|
*/
|
|
168
168
|
export default function getUserInput() {
|
|
169
169
|
return prompts(QUESTIONS);
|
|
@@ -33,7 +33,7 @@ const PACKAGE_MANIFEST = `./${_PACKAGE_MANIFEST}`;
|
|
|
33
33
|
* (e.g. a tsconfig exists => use it and assume typescript is used)
|
|
34
34
|
*
|
|
35
35
|
* @param {OneShotConfigIDType} pOneShotConfigId
|
|
36
|
-
* @
|
|
36
|
+
* @returns {IPartialInitConfig} an initialization configuration
|
|
37
37
|
*/
|
|
38
38
|
function getOneShotConfig(pOneShotConfigId) {
|
|
39
39
|
/** @type {IPartialInitConfig} */
|
|
@@ -43,7 +43,7 @@ function getExtensions(pInitOptions) {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* @param {IPartialInitConfig} pInitOptions
|
|
46
|
-
* @
|
|
46
|
+
* @returns {IPartialInitConfig}
|
|
47
47
|
*/
|
|
48
48
|
function populate(pInitOptions) {
|
|
49
49
|
const lReturnValue = {
|
|
@@ -71,10 +71,10 @@ function populate(pInitOptions) {
|
|
|
71
71
|
/**
|
|
72
72
|
*
|
|
73
73
|
* @param {IPartialInitConfig} pInitOptions
|
|
74
|
-
* @
|
|
74
|
+
* @returns {IInitConfig}
|
|
75
75
|
*/
|
|
76
76
|
export default function normalizeInitOptions(pInitOptions) {
|
|
77
|
-
|
|
77
|
+
const lReturnValue = populate(pInitOptions);
|
|
78
78
|
if (!Object.hasOwn(lReturnValue, "hasTestsOutsideSource")) {
|
|
79
79
|
lReturnValue.hasTestsOutsideSource =
|
|
80
80
|
!pInitOptions.isMonoRepo &&
|
|
@@ -7,7 +7,7 @@ export function validateLocation(pLocations) {
|
|
|
7
7
|
if (!statSync(lLocation).isDirectory()) {
|
|
8
8
|
return `'${lLocation}' doesn't seem to be a folder - please try again`;
|
|
9
9
|
}
|
|
10
|
-
} catch
|
|
10
|
+
} catch {
|
|
11
11
|
return `'${lLocation}' doesn't seem to exist - please try again`;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -60,7 +60,7 @@ const EXPERIMENTAL_SCRIPT_DOC = [
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param {import("./types.d.mts").IInitConfig} pInitOptions
|
|
63
|
-
* @
|
|
63
|
+
* @returns {any} an bunch of key value pairs that can be plonked into a `scripts` attribute in a package.json
|
|
64
64
|
*/
|
|
65
65
|
export function compileRunScripts(pInitOptions) {
|
|
66
66
|
let lReturnValue = {};
|
|
@@ -91,7 +91,7 @@ export function compileRunScripts(pInitOptions) {
|
|
|
91
91
|
* @param {any} pAdditionalRunScripts
|
|
92
92
|
* @param {any} pExistingRunScripts
|
|
93
93
|
*
|
|
94
|
-
* @
|
|
94
|
+
* @returns {any} the scripts in pAdditionalRunScripts that don't yet exist in
|
|
95
95
|
* pExistingRunScripts
|
|
96
96
|
*/
|
|
97
97
|
function filterNewScriptEntries(pExistingRunScripts, pAdditionalRunScripts) {
|
|
@@ -88,7 +88,7 @@ export default function setUpNDJSONListener(
|
|
|
88
88
|
pMaxLevel = INFO,
|
|
89
89
|
pStream = process.stderr,
|
|
90
90
|
) {
|
|
91
|
-
|
|
91
|
+
const lState = {
|
|
92
92
|
runStartTime: new Date(Date.now()).toISOString(),
|
|
93
93
|
runId: randomInt(MIN_RUN_ID, MAX_RUN_ID),
|
|
94
94
|
previousMessage: "startup: nodejs loading",
|
|
@@ -19,7 +19,7 @@ function getOptionValue(pDefault) {
|
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line complexity
|
|
21
21
|
function normalizeConfigFileName(pCliOptions, pConfigWrapperName, pDefault) {
|
|
22
|
-
|
|
22
|
+
const lOptions = structuredClone(pCliOptions);
|
|
23
23
|
|
|
24
24
|
if (Object.hasOwn(lOptions, pConfigWrapperName)) {
|
|
25
25
|
set(
|
|
@@ -45,12 +45,13 @@ function fileExists(pFileName) {
|
|
|
45
45
|
try {
|
|
46
46
|
accessSync(pFileName, constants.R_OK);
|
|
47
47
|
return true;
|
|
48
|
-
} catch
|
|
48
|
+
} catch {
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function validateAndGetCustomRulesFileName(pValidate) {
|
|
54
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
54
55
|
let lReturnValue = "";
|
|
55
56
|
|
|
56
57
|
if (fileExists(pValidate)) {
|
|
@@ -66,7 +67,7 @@ function validateAndGetCustomRulesFileName(pValidate) {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
function validateAndGetDefaultRulesFileName() {
|
|
69
|
-
|
|
70
|
+
const lReturnValue = RULES_FILE_NAME_SEARCH_ARRAY.find(fileExists);
|
|
70
71
|
|
|
71
72
|
if (typeof lReturnValue === "undefined") {
|
|
72
73
|
throw new TypeError(
|
|
@@ -79,6 +80,7 @@ function validateAndGetDefaultRulesFileName() {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
function validateAndNormalizeRulesFileName(pValidate) {
|
|
83
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
82
84
|
let lReturnValue = "";
|
|
83
85
|
|
|
84
86
|
if (typeof pValidate === "string") {
|
|
@@ -196,7 +198,7 @@ function normalizeCache(pCliOptions) {
|
|
|
196
198
|
*
|
|
197
199
|
* @param {object} pOptionsAsPassedFromCommander [description]
|
|
198
200
|
* @param {any} pKnownCliOptions [description]
|
|
199
|
-
* @
|
|
201
|
+
* @returns {import("../../types/options.mjs").ICruiseOptions} [description]
|
|
200
202
|
*/
|
|
201
203
|
export default async function normalizeOptions(pOptionsAsPassedFromCommander) {
|
|
202
204
|
let lOptions = {
|
|
@@ -3,7 +3,7 @@ import { accessSync, constants } from "node:fs";
|
|
|
3
3
|
export default function assertFileExistence(pDirectoryOrFile) {
|
|
4
4
|
try {
|
|
5
5
|
accessSync(pDirectoryOrFile, constants.R_OK);
|
|
6
|
-
} catch
|
|
6
|
+
} catch {
|
|
7
7
|
throw new Error(
|
|
8
8
|
`Can't open '${pDirectoryOrFile}' for reading. Does it exist?\n`,
|
|
9
9
|
);
|
|
@@ -6,6 +6,7 @@ import tryImport from "#utl/try-import.mjs";
|
|
|
6
6
|
import meta from "#meta.cjs";
|
|
7
7
|
|
|
8
8
|
async function getJSConfig(pBabelConfigFileName) {
|
|
9
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
9
10
|
let lReturnValue = {};
|
|
10
11
|
|
|
11
12
|
try {
|
|
@@ -34,6 +35,7 @@ async function getJSConfig(pBabelConfigFileName) {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
async function getJSON5Config(pBabelConfigFileName) {
|
|
38
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
37
39
|
let lReturnValue = {};
|
|
38
40
|
const { default: json5 } = await import("json5");
|
|
39
41
|
|
|
@@ -78,7 +80,7 @@ async function getConfig(pBabelConfigFileName) {
|
|
|
78
80
|
* Silently fails if a supported @babel/core version can't be found
|
|
79
81
|
*
|
|
80
82
|
* @param {string} pBabelConfigFileName
|
|
81
|
-
* @
|
|
83
|
+
* @returns {object} babel config as an object
|
|
82
84
|
* @throws {Error} when the babel config has an unknown extension OR
|
|
83
85
|
* when the babel config is invalid OR
|
|
84
86
|
* when dependency-cruiser can't yet process it
|
|
@@ -47,7 +47,7 @@ async function processExtends(pReturnValue, pAlreadyVisited, pBaseDirectory) {
|
|
|
47
47
|
* @param {string} pConfigFileName
|
|
48
48
|
* @param {Set?} pAlreadyVisited
|
|
49
49
|
* @param {string?} pBaseDirectory
|
|
50
|
-
* @
|
|
50
|
+
* @returns {import('../../../types/configuration.mjs').IConfiguration} dependency-cruiser options
|
|
51
51
|
* @throws {Error} when the config is not valid (/ does not exist/ isn't readable)
|
|
52
52
|
*/
|
|
53
53
|
export default async function extractDepcruiseConfig(
|
|
@@ -6,7 +6,9 @@ function extendNamedRule(pExtendedRule, pForbiddenArrayBase) {
|
|
|
6
6
|
.filter(({ name }) => name === pExtendedRule.name)
|
|
7
7
|
.reduce(
|
|
8
8
|
(pAll, pBaseRule) => ({
|
|
9
|
+
/* oxlint-disable-next-line no-accumulating-spread */
|
|
9
10
|
...pBaseRule,
|
|
11
|
+
/* oxlint-disable-next-line no-accumulating-spread */
|
|
10
12
|
...pAll,
|
|
11
13
|
}),
|
|
12
14
|
pExtendedRule,
|
|
@@ -25,11 +27,11 @@ function extendNamedRule(pExtendedRule, pForbiddenArrayBase) {
|
|
|
25
27
|
* @param {*} pRuleArrayExtended - array of 'forbidden' rules that extend the ...
|
|
26
28
|
* @param {*} pRuleArrayBase - array of 'forbidden' rules to extend
|
|
27
29
|
*
|
|
28
|
-
* @
|
|
30
|
+
* @returns {Array} - the merged array
|
|
29
31
|
*/
|
|
30
32
|
function mergeRules(pRuleArrayExtended, pRuleArrayBase) {
|
|
31
33
|
// merge anonymous on 100% equality
|
|
32
|
-
|
|
34
|
+
const lAnonymousRules = uniqWith(
|
|
33
35
|
pRuleArrayExtended.concat(pRuleArrayBase).filter(({ name }) => !name),
|
|
34
36
|
isDeepStrictEqual,
|
|
35
37
|
);
|
|
@@ -61,7 +63,7 @@ function mergeRules(pRuleArrayExtended, pRuleArrayBase) {
|
|
|
61
63
|
* @param {*} pAllowedArrayExtended - array of 'allowed' rules that extend the ///
|
|
62
64
|
* @param {*} pAllowedArrayBase - array of 'allowed' rules to extend
|
|
63
65
|
*
|
|
64
|
-
* @
|
|
66
|
+
* @returns {Array} - the merged array
|
|
65
67
|
*/
|
|
66
68
|
function mergeAllowedRules(pAllowedArrayExtended, pAllowedArrayBase) {
|
|
67
69
|
return uniqWith(
|
|
@@ -34,7 +34,7 @@ const FORMAT_DIAGNOSTICS_HOST = {
|
|
|
34
34
|
* Silently fails if a supported version of the typescript compiler isn't available
|
|
35
35
|
*
|
|
36
36
|
* @param {string} pTSConfigFileName
|
|
37
|
-
* @
|
|
37
|
+
* @returns {import("typescript").ParsedCommandLine} tsconfig as an object
|
|
38
38
|
* @throws {Error} when the tsconfig is invalid/ has errors
|
|
39
39
|
* @throws {TypeError} when the tsconfig is unreadable
|
|
40
40
|
*/
|
|
@@ -90,7 +90,7 @@ async function attemptImport(pAbsoluteWebpackConfigFileName) {
|
|
|
90
90
|
* module system. If we'd use a dynamic import, these monkey-patches wouldn't
|
|
91
91
|
* be used.
|
|
92
92
|
*/
|
|
93
|
-
/*
|
|
93
|
+
/* oxlint-disable-next-line no-dynamic-require */
|
|
94
94
|
return require(pAbsoluteWebpackConfigFileName);
|
|
95
95
|
}
|
|
96
96
|
} catch (pError) {
|
|
@@ -112,7 +112,7 @@ async function attemptImport(pAbsoluteWebpackConfigFileName) {
|
|
|
112
112
|
* @param {string} pWebpackConfigFilename
|
|
113
113
|
* @param {{ [key: string]: any }=} pEnvironment
|
|
114
114
|
* @param {webpackArgumentsType=} pArguments
|
|
115
|
-
* @
|
|
115
|
+
* @returns {Promise<import("enhanced-resolve").ResolveOptions|{}>} webpack resolve config as an object
|
|
116
116
|
* @throws {Error} when the webpack config isn't usable (e.g. because it
|
|
117
117
|
* doesn't exist, or because it's invalid)
|
|
118
118
|
*/
|
|
@@ -46,7 +46,7 @@ export function getASTFromSource(pFileRecord, pTranspileOptions) {
|
|
|
46
46
|
// ecmaVersion 11 necessary for acorn to understand dynamic imports
|
|
47
47
|
// explicitly passing ecmaVersion is recommended from acorn 8
|
|
48
48
|
return acornParse(lJavaScriptSource, ACORN_OPTIONS);
|
|
49
|
-
} catch
|
|
49
|
+
} catch {
|
|
50
50
|
return acornLooseParse(lJavaScriptSource, ACORN_OPTIONS);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -62,7 +62,7 @@ export function getASTFromSource(pFileRecord, pTranspileOptions) {
|
|
|
62
62
|
*
|
|
63
63
|
* @param {string} pFileName - the name of the file to compile
|
|
64
64
|
* @param {any} pTranspileOptions - options for the transpiler(s) - typically a tsconfig or a babel config
|
|
65
|
-
* @
|
|
65
|
+
* @returns {acorn.Node} - a (javascript) AST
|
|
66
66
|
*/
|
|
67
67
|
export function getASTCached(pFileName, pTranspileOptions) {
|
|
68
68
|
// taking the transpile options into account of the cache key seems like
|
|
@@ -154,7 +154,7 @@ function compareDeps(pLeft, pRight) {
|
|
|
154
154
|
* @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
|
|
155
155
|
* ('flattened' so there's no need for file access on any
|
|
156
156
|
* 'extends' option in there)
|
|
157
|
-
* @
|
|
157
|
+
* @returns {IDependency[]} an array of dependency objects (see above)
|
|
158
158
|
*/
|
|
159
159
|
export default function getDependencies(
|
|
160
160
|
pFileName,
|
|
@@ -32,7 +32,7 @@ function determineExtractionFunction(pCruiseOptions, pFileName) {
|
|
|
32
32
|
* @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
|
|
33
33
|
* ('flattened' so there's no need for file access on any
|
|
34
34
|
* 'extends' option in there)
|
|
35
|
-
* @
|
|
35
|
+
* @returns {IDependency[]} an array of dependency objects (see above)
|
|
36
36
|
*/
|
|
37
37
|
export default function extractStats(
|
|
38
38
|
pFileName,
|
|
@@ -100,7 +100,7 @@ function expandGlob(pBaseDirectory, pScannedGlob) {
|
|
|
100
100
|
* notably useful attributes:
|
|
101
101
|
* - exclude - regexp of what to exclude
|
|
102
102
|
* - includeOnly - regexp what to include
|
|
103
|
-
* @
|
|
103
|
+
* @returns {string[]} paths to files to be gathered.
|
|
104
104
|
*/
|
|
105
105
|
export default function gatherInitialSources(
|
|
106
106
|
pFileDirectoryAndGlobArray,
|
package/src/extract/helpers.mjs
CHANGED
|
@@ -75,7 +75,7 @@ function getCanonicalModuleName(pModuleName, pProtocol) {
|
|
|
75
75
|
*/
|
|
76
76
|
// eslint-disable-next-line complexity
|
|
77
77
|
export function extractModuleAttributes(pString) {
|
|
78
|
-
|
|
78
|
+
const lReturnValue = { module: pString };
|
|
79
79
|
const lModuleAttributes = pString.match(
|
|
80
80
|
// eslint-disable-next-line security/detect-unsafe-regex
|
|
81
81
|
/^(?<protocol>node:|file:|data:|bun:)(?:(?<mimeType>[^,]+),)?(?<module>.+)$/,
|
package/src/extract/index.mjs
CHANGED
|
@@ -115,7 +115,7 @@ function determineNodeModuleDependencyTypes(
|
|
|
115
115
|
pResolveOptions,
|
|
116
116
|
) {
|
|
117
117
|
/** @type { DependencyType[] } */
|
|
118
|
-
|
|
118
|
+
const lReturnValue = determineManifestDependencyTypes(
|
|
119
119
|
getPackageRoot(pModuleName),
|
|
120
120
|
pPackageDeps,
|
|
121
121
|
pResolveOptions.modules,
|
|
@@ -151,6 +151,7 @@ function determineExternalModuleDependencyTypes(
|
|
|
151
151
|
pBaseDirectory,
|
|
152
152
|
) {
|
|
153
153
|
/** @type { DependencyType[] } */
|
|
154
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
154
155
|
let lReturnValue = [];
|
|
155
156
|
|
|
156
157
|
if (
|
|
@@ -179,7 +180,7 @@ function determineExternalModuleDependencyTypes(
|
|
|
179
180
|
* @param {string} pBaseDirectory the base directory dependency cruise is run on
|
|
180
181
|
* @param {ITranspileOptions} pTranspileOptions
|
|
181
182
|
*
|
|
182
|
-
* @
|
|
183
|
+
* @returns { DependencyType[] }an array of dependency types for the dependency
|
|
183
184
|
*/
|
|
184
185
|
// eslint-disable-next-line max-lines-per-function
|
|
185
186
|
export default function determineDependencyTypes(
|