dependency-cruiser 16.6.0 → 16.7.0-beta-2
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/bin/depcruise-baseline.mjs +1 -1
- package/package.json +6 -6
- package/src/cache/cache.mjs +3 -4
- package/src/cache/content-strategy.mjs +5 -7
- package/src/cache/find-content-changes.mjs +11 -5
- package/src/cache/helpers.mjs +8 -8
- package/src/cache/metadata-strategy.mjs +6 -8
- package/src/cache/options-compatible.mjs +2 -1
- package/src/cli/index.mjs +4 -2
- package/src/cli/init-config/build-config.mjs +13 -9
- package/src/cli/init-config/config-template.mjs +11 -0
- package/src/cli/init-config/index.mjs +10 -6
- package/src/cli/init-config/normalize-init-options.mjs +10 -6
- package/src/cli/listeners/performance-log/format-helpers.mjs +1 -1
- package/src/cli/normalize-cli-options.mjs +1 -0
- package/src/cli/utl/io.mjs +1 -2
- package/src/config-utl/extract-babel-config.mjs +0 -1
- package/src/config-utl/extract-depcruise-options.mjs +8 -4
- package/src/config-utl/extract-known-violations.mjs +6 -6
- package/src/config-utl/extract-webpack-resolve-config.mjs +1 -1
- package/src/enrich/soften-known-violations.mjs +1 -1
- package/src/enrich/summarize/add-rule-set-used.mjs +1 -0
- package/src/enrich/summarize/summarize-modules.mjs +0 -1
- package/src/enrich/summarize/summarize-options.mjs +2 -0
- package/src/extract/extract-dependencies.mjs +16 -11
- package/src/extract/extract-stats.mjs +9 -4
- package/src/extract/gather-initial-sources.mjs +8 -5
- package/src/extract/index.mjs +9 -4
- package/src/extract/resolve/determine-dependency-types.mjs +22 -15
- package/src/extract/resolve/external-module-helpers.mjs +4 -4
- package/src/extract/resolve/index.mjs +11 -5
- package/src/extract/resolve/module-classifiers.mjs +9 -4
- package/src/extract/resolve/resolve-helpers.mjs +3 -3
- package/src/extract/swc/dependency-visitor.mjs +2 -6
- package/src/extract/swc/parse.mjs +8 -4
- package/src/extract/tsc/extract-typescript-deps.mjs +121 -16
- package/src/extract/tsc/extract.mjs +2 -1
- package/src/graph-utl/consolidate-module-dependencies.mjs +8 -4
- package/src/graph-utl/filter-bank.mjs +8 -4
- package/src/graph-utl/indexed-module-graph.mjs +7 -11
- package/src/graph-utl/rule-set.mjs +9 -5
- package/src/main/cruise.mjs +2 -2
- package/src/main/format.mjs +0 -1
- package/src/main/options/assert-validity.mjs +13 -9
- package/src/main/options/defaults.mjs +1 -0
- package/src/main/options/normalize.mjs +23 -13
- package/src/main/report-wrap.mjs +12 -7
- package/src/main/resolve-options/normalize.mjs +10 -5
- package/src/main/rule-set/assert-validity.mjs +5 -2
- package/src/main/rule-set/normalize.mjs +21 -11
- package/src/meta.cjs +1 -1
- package/src/report/anon/anonymize-path.mjs +1 -1
- package/src/report/d2.mjs +2 -2
- package/src/report/dot/index.mjs +3 -3
- package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +4 -4
- package/src/report/markdown.mjs +41 -30
- package/src/report/mermaid.mjs +2 -2
- package/src/report/teamcity.mjs +1 -0
- package/src/schema/baseline-violations.schema.mjs +1 -1
- package/src/schema/configuration.schema.mjs +1 -1
- package/src/schema/cruise-result.schema.mjs +1 -1
- package/src/utl/get-extension.mjs +1 -1
- package/src/utl/try-import.mjs +0 -1
- package/src/utl/try-require.cjs +2 -2
- package/src/validate/index.mjs +6 -2
- package/src/validate/match-dependency-rule.mjs +8 -4
- package/src/validate/match-module-rule-helpers.mjs +16 -10
- package/src/validate/match-module-rule.mjs +8 -5
- package/src/validate/matchers.mjs +1 -3
- package/types/options.d.mts +5 -0
- package/types/shared-types.d.mts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.7.0-beta-2",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -159,19 +159,19 @@
|
|
|
159
159
|
"safe-regex": "^2.1.1",
|
|
160
160
|
"semver": "^7.6.3",
|
|
161
161
|
"teamcity-service-messages": "^0.1.14",
|
|
162
|
-
"tsconfig-paths-webpack-plugin": "^4.
|
|
163
|
-
"watskeburt": "^4.1.
|
|
162
|
+
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
|
163
|
+
"watskeburt": "^4.1.1"
|
|
164
164
|
},
|
|
165
165
|
"overrides": {
|
|
166
|
-
"
|
|
166
|
+
"cross-spawn": ">=6.0.6"
|
|
167
167
|
},
|
|
168
168
|
"resolutions": {
|
|
169
|
-
"
|
|
169
|
+
"cross-spawn": ">=6.0.6"
|
|
170
170
|
},
|
|
171
171
|
"engines": {
|
|
172
172
|
"node": "^18.17||>=20"
|
|
173
173
|
},
|
|
174
174
|
"scripts": {
|
|
175
|
-
"test": "echo for test, build and
|
|
175
|
+
"test": "echo see github for test, build and analysis scripts"
|
|
176
176
|
}
|
|
177
177
|
}
|
package/src/cache/cache.mjs
CHANGED
|
@@ -13,10 +13,9 @@ import { scannableExtensions } from "#extract/transpile/meta.mjs";
|
|
|
13
13
|
import { bus } from "#utl/bus.mjs";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @typedef {import("../../types/cache-options.mjs").cacheStrategyType} cacheStrategyType
|
|
16
|
+
* @import { IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs";
|
|
17
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs";
|
|
18
|
+
* @import { cacheStrategyType } from "../../types/cache-options.mjs";
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
21
|
const CACHE_FILE_NAME = "cache.json";
|
|
@@ -10,11 +10,9 @@ import {
|
|
|
10
10
|
} from "./helpers.mjs";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @typedef {import("../../types/dependency-cruiser.mjs").ICruiseResult} ICruiseResult
|
|
17
|
-
* @typedef {import("../../types/strict-options.mjs").IStrictCruiseOptions} IStrictCruiseOptions
|
|
13
|
+
* @import { IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
|
|
14
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
|
|
15
|
+
* @import { changeType, getSHA } from "watskeburt"
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -56,10 +54,10 @@ export default class ContentStrategy {
|
|
|
56
54
|
* @param {IStrictCruiseOptions} pCruiseOptions
|
|
57
55
|
* @param {Object} pOptions
|
|
58
56
|
* @param {Set<string>} pOptions.extensions
|
|
59
|
-
* @param {Set<
|
|
57
|
+
* @param {Set<changeType>=} pOptions.interestingChangeTypes?
|
|
60
58
|
* @param {string=} pOptions.baseDir
|
|
61
59
|
* @param {typeof findContentChanges=} pOptions.diffListFn
|
|
62
|
-
* @param {typeof
|
|
60
|
+
* @param {typeof getSHA=} pOptions.checksumFn
|
|
63
61
|
* @returns {IRevisionData}
|
|
64
62
|
*/
|
|
65
63
|
getRevisionData(pDirectory, pCachedCruiseResult, pCruiseOptions, pOptions) {
|
|
@@ -11,10 +11,16 @@ import {
|
|
|
11
11
|
import { bus } from "#utl/bus.mjs";
|
|
12
12
|
import findAllFiles from "#utl/find-all-files.mjs";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @import { IModule, IRevisionChange } from "../../types/dependency-cruiser.mjs"
|
|
16
|
+
* @import { ICruiseResult } from "../../types/cruise-result.mjs"
|
|
17
|
+
* @import { IStrictExcludeType, IStrictIncludeOnlyType } from "../../types/strict-filter-types.mjs"
|
|
18
|
+
*/
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* @param {Set<string>} pFileSet
|
|
16
22
|
* @param {typeof getFileHashSync} pFileHashFunction
|
|
17
|
-
* @returns {(pModule:
|
|
23
|
+
* @returns {(pModule:IModule) => IRevisionChange}
|
|
18
24
|
*/
|
|
19
25
|
function diffCachedModuleAgainstFileSet(
|
|
20
26
|
pFileSet,
|
|
@@ -63,13 +69,13 @@ function diffCachedModuleAgainstFileSet(
|
|
|
63
69
|
- there is a cache, but it doesn't contain checksums => same as before, except
|
|
64
70
|
all files will be marked as 'modified'
|
|
65
71
|
* @param {string} pDirectory
|
|
66
|
-
* @param {
|
|
72
|
+
* @param {ICruiseResult} pCachedCruiseResult
|
|
67
73
|
* @param {Object} pOptions
|
|
68
74
|
* @param {Set<string>} pOptions.extensions
|
|
69
75
|
* @param {string} pOptions.baseDir
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {
|
|
72
|
-
* @returns {
|
|
76
|
+
* @param {IStrictExcludeType} pOptions.exclude
|
|
77
|
+
* @param {IStrictIncludeOnlyType=} pOptions.includeOnly
|
|
78
|
+
* @returns {IRevisionChange[]}
|
|
73
79
|
*/
|
|
74
80
|
export default function findContentChanges(
|
|
75
81
|
pDirectory,
|
package/src/cache/helpers.mjs
CHANGED
|
@@ -6,10 +6,10 @@ import memoize from "memoize";
|
|
|
6
6
|
import { filenameMatchesPattern } from "#graph-utl/match-facade.mjs";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
9
|
+
* @import { IModule, IRevisionChange, } from "../../types/dependency-cruiser.mjs"
|
|
10
|
+
* @import { IExcludeType } from "../../types/filter-types.mjs"
|
|
11
|
+
* @import { IStrictIncludeOnlyType } from "../../types/strict-filter-types.mjs"
|
|
12
|
+
* @import { changeType, IChange } from "watskeburt"
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -35,7 +35,7 @@ function _getFileHashSync(pFileName) {
|
|
|
35
35
|
export const getFileHashSync = memoize(_getFileHashSync);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* @param {
|
|
38
|
+
* @param {IChange} pChange
|
|
39
39
|
* @return {IRevisionChange}
|
|
40
40
|
*/
|
|
41
41
|
export function addCheckSumToChangeSync(pChange) {
|
|
@@ -80,7 +80,7 @@ export function hasInterestingExtension(pExtensions) {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* @param {Set<string>} pExtensions
|
|
83
|
-
* @returns {(pChange:
|
|
83
|
+
* @returns {(pChange: IChange) => boolean}
|
|
84
84
|
*/
|
|
85
85
|
export function changeHasInterestingExtension(pExtensions) {
|
|
86
86
|
return (pChange) => {
|
|
@@ -106,8 +106,8 @@ const DEFAULT_INTERESTING_CHANGE_TYPES = new Set([
|
|
|
106
106
|
]);
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* @param {Set<
|
|
110
|
-
* @returns {(pChange:
|
|
109
|
+
* @param {Set<changeType>=} pInterestingChangeTypes
|
|
110
|
+
* @returns {(pChange: IChange) => boolean}
|
|
111
111
|
*/
|
|
112
112
|
export function isInterestingChangeType(pInterestingChangeTypes) {
|
|
113
113
|
return (pChange) =>
|
|
@@ -12,20 +12,18 @@ import {
|
|
|
12
12
|
import { bus } from "#utl/bus.mjs";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @typedef {import("../../types/dependency-cruiser.mjs").ICruiseResult} ICruiseResult
|
|
19
|
-
* @typedef {import("../../types/strict-options.mjs").IStrictCruiseOptions} IStrictCruiseOptions
|
|
15
|
+
* @import {IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
|
|
16
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
|
|
17
|
+
* @import { changeType, IChange } from "watskeburt"
|
|
20
18
|
*/
|
|
21
19
|
|
|
22
20
|
export default class MetaDataStrategy {
|
|
23
21
|
/**
|
|
24
22
|
* @param {string} _pDirectory
|
|
25
|
-
* @param {
|
|
23
|
+
* @param {ICruiseResult} _pCachedCruiseResult
|
|
26
24
|
* @param {Object} pOptions
|
|
27
25
|
* @param {Set<string>} pOptions.extensions
|
|
28
|
-
* @param {Set<
|
|
26
|
+
* @param {Set<changeType>=} pOptions.interestingChangeTypes
|
|
29
27
|
* @param {typeof getSHA=} pOptions.shaRetrievalFn
|
|
30
28
|
* @param {typeof list=} pOptions.diffListFn
|
|
31
29
|
* @param {typeof addCheckSumToChangeSync=} pOptions.checksumFn
|
|
@@ -47,7 +45,7 @@ export default class MetaDataStrategy {
|
|
|
47
45
|
bus.debug("cache: - getting sha");
|
|
48
46
|
const lSHA = await lOptions.shaRetrievalFn();
|
|
49
47
|
bus.debug("cache: - getting diff");
|
|
50
|
-
const lDiff = /** @type {
|
|
48
|
+
const lDiff = /** @type {IChange[]} */ (
|
|
51
49
|
await lOptions.diffListFn({ oldRevision: lSHA })
|
|
52
50
|
);
|
|
53
51
|
const lChanges = lDiff
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isDeepStrictEqual } from "node:util";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/*
|
|
@@ -105,6 +105,7 @@ export function optionsAreCompatible(pOldOptions, pNewOptions) {
|
|
|
105
105
|
pOldOptions.preserveSymlinks === pNewOptions.preserveSymlinks &&
|
|
106
106
|
pOldOptions.combinedDependencies === pNewOptions.combinedDependencies &&
|
|
107
107
|
pOldOptions.experimentalStats === pNewOptions.experimentalStats &&
|
|
108
|
+
pOldOptions.detectJSDocImports === pNewOptions.detectJSDocImports &&
|
|
108
109
|
metricsIsCompatible(pOldOptions.metrics, pNewOptions.metrics) &&
|
|
109
110
|
// includeOnly suffers from a backwards compatibility disease
|
|
110
111
|
includeOnlyIsCompatible(pOldOptions.includeOnly, pNewOptions.includeOnly) &&
|
package/src/cli/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { set } from "#utl/object-util.mjs";
|
|
|
13
13
|
import cruise from "#main/cruise.mjs";
|
|
14
14
|
import { INFO, bus } from "#utl/bus.mjs";
|
|
15
15
|
|
|
16
|
+
// eslint-disable-next-line complexity
|
|
16
17
|
async function extractResolveOptions(pCruiseOptions) {
|
|
17
18
|
let lResolveOptions = {};
|
|
18
19
|
const lWebPackConfigFileName =
|
|
@@ -78,6 +79,7 @@ async function extractBabelConfigOptions(pCruiseOptions) {
|
|
|
78
79
|
return lReturnValue;
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
// eslint-disable-next-line complexity
|
|
81
83
|
function setUpListener(pCruiseOptions) {
|
|
82
84
|
const lString2Listener = new Map([
|
|
83
85
|
["cli-feedback", setUpCliFeedbackListener],
|
|
@@ -90,7 +92,7 @@ function setUpListener(pCruiseOptions) {
|
|
|
90
92
|
|
|
91
93
|
const lListenerFunction = lString2Listener.get(lListenerID);
|
|
92
94
|
/* c8 ignore next 6 */
|
|
93
|
-
if (
|
|
95
|
+
if (lListenerFunction) {
|
|
94
96
|
lListenerFunction(
|
|
95
97
|
bus,
|
|
96
98
|
pCruiseOptions?.ruleSet?.options?.progress?.maximumLevel ?? INFO,
|
|
@@ -141,7 +143,7 @@ async function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
|
141
143
|
* @param {{stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream}=} pStreams
|
|
142
144
|
* @returns {number}
|
|
143
145
|
*/
|
|
144
|
-
|
|
146
|
+
|
|
145
147
|
export default async function executeCli(
|
|
146
148
|
pFileDirectoryArray,
|
|
147
149
|
pCruiseOptions,
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { folderNameArrayToRE } from "./utl.mjs";
|
|
3
3
|
import configTemplate from "./config-template.mjs";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @import { IInitConfig } from "./types.js";
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* @param {string} pString
|
|
7
11
|
* @returns {string}
|
|
@@ -22,7 +26,7 @@ function extensionsToString(pExtensions) {
|
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
|
-
* @param {
|
|
29
|
+
* @param {IInitConfig} pInitOptions
|
|
26
30
|
* @returns {string}
|
|
27
31
|
*/
|
|
28
32
|
function buildNotToTestRule(pInitOptions) {
|
|
@@ -49,7 +53,7 @@ function buildNotToTestRule(pInitOptions) {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
|
-
* @param {
|
|
56
|
+
* @param {IInitConfig} pInitOptions
|
|
53
57
|
* @returns {string}
|
|
54
58
|
*/
|
|
55
59
|
function buildTsPreCompilationDepsAttribute(pInitOptions) {
|
|
@@ -59,7 +63,7 @@ function buildTsPreCompilationDepsAttribute(pInitOptions) {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
|
-
* @param {
|
|
66
|
+
* @param {IInitConfig} pInitOptions
|
|
63
67
|
* @returns {string}
|
|
64
68
|
*/
|
|
65
69
|
function buildCombinedDependenciesAttribute(pInitOptions) {
|
|
@@ -69,7 +73,7 @@ function buildCombinedDependenciesAttribute(pInitOptions) {
|
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
|
-
* @param {
|
|
76
|
+
* @param {IInitConfig} pInitOptions
|
|
73
77
|
* @returns {string}
|
|
74
78
|
*/
|
|
75
79
|
function buildTsOrJsConfigAttribute(pInitOptions) {
|
|
@@ -89,7 +93,7 @@ function buildTsOrJsConfigAttribute(pInitOptions) {
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
|
-
* @param {
|
|
96
|
+
* @param {IInitConfig} pInitOptions
|
|
93
97
|
* @returns {string}
|
|
94
98
|
*/
|
|
95
99
|
function buildWebpackConfigAttribute(pInitOptions) {
|
|
@@ -107,7 +111,7 @@ function buildWebpackConfigAttribute(pInitOptions) {
|
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
/**
|
|
110
|
-
* @param {
|
|
114
|
+
* @param {IInitConfig} pInitOptions
|
|
111
115
|
* @returns {string}
|
|
112
116
|
*/
|
|
113
117
|
function buildBabelConfigAttribute(pInitOptions) {
|
|
@@ -121,7 +125,7 @@ function buildBabelConfigAttribute(pInitOptions) {
|
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
/**
|
|
124
|
-
* @param {
|
|
128
|
+
* @param {IInitConfig} pInitOptions
|
|
125
129
|
* @returns {string}
|
|
126
130
|
*/
|
|
127
131
|
function buildExtensionsAttribute(pInitOptions) {
|
|
@@ -131,7 +135,7 @@ function buildExtensionsAttribute(pInitOptions) {
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
/**
|
|
134
|
-
* @param {
|
|
138
|
+
* @param {IInitConfig} pInitOptions
|
|
135
139
|
* @returns {string}
|
|
136
140
|
*/
|
|
137
141
|
function buildMainFieldsAttribute(pInitOptions) {
|
|
@@ -149,7 +153,7 @@ function buildMainFieldsAttribute(pInitOptions) {
|
|
|
149
153
|
* Creates a .dependency-cruiser config with a set of basic validations
|
|
150
154
|
* to the current directory.
|
|
151
155
|
*
|
|
152
|
-
* @param {
|
|
156
|
+
* @param {IInitConfig} pInitOptions ('Normalized') options that influence the shape of
|
|
153
157
|
* the configuration
|
|
154
158
|
* @returns {string} the configuration as a string
|
|
155
159
|
*/
|
|
@@ -228,6 +228,17 @@ module.exports = {
|
|
|
228
228
|
|
|
229
229
|
// moduleSystems: ['cjs', 'es6'],
|
|
230
230
|
|
|
231
|
+
/*
|
|
232
|
+
false: don't look at JSDoc imports
|
|
233
|
+
true: dependency-cruiser will detect dependencies in JSDoc-style
|
|
234
|
+
import statements. Implies "parser": "tsc", so the dependency-cruiser
|
|
235
|
+
will use the typescript parser for JavaScript files.
|
|
236
|
+
|
|
237
|
+
For this to work the typescript compiler will need to be installed in the
|
|
238
|
+
same spot as you're running dependency-cruiser from.
|
|
239
|
+
*/
|
|
240
|
+
// detectJSDocImports: true,
|
|
241
|
+
|
|
231
242
|
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
|
|
232
243
|
to open it on your online repo or \`vscode://file/$\{process.cwd()}/\` to
|
|
233
244
|
open it in visual studio code),
|
|
@@ -20,17 +20,21 @@ import {
|
|
|
20
20
|
} from "./environment-helpers.mjs";
|
|
21
21
|
import { writeRunScriptsToManifest } from "./write-run-scripts-to-manifest.mjs";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @import { IInitConfig, IPartialInitConfig, OneShotConfigIDType } from "./types.js";
|
|
25
|
+
*/
|
|
26
|
+
|
|
23
27
|
const PACKAGE_MANIFEST = `./${_PACKAGE_MANIFEST}`;
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* Create a initialization configuration based on guessed defaults
|
|
27
31
|
* (e.g. a tsconfig exists => use it and assume typescript is used)
|
|
28
32
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @return {
|
|
33
|
+
* @param {OneShotConfigIDType} pOneShotConfigId
|
|
34
|
+
* @return {IPartialInitConfig} an initialization configuration
|
|
31
35
|
*/
|
|
32
36
|
function getOneShotConfig(pOneShotConfigId) {
|
|
33
|
-
/** @type {
|
|
37
|
+
/** @type {IPartialInitConfig} */
|
|
34
38
|
const lBaseConfig = {
|
|
35
39
|
isMonoRepo: isLikelyMonoRepo(),
|
|
36
40
|
isTypeModule: isTypeModule(),
|
|
@@ -46,7 +50,7 @@ function getOneShotConfig(pOneShotConfigId) {
|
|
|
46
50
|
babelConfig: getBabelConfigCandidates().shift(),
|
|
47
51
|
specifyResolutionExtensions: true,
|
|
48
52
|
};
|
|
49
|
-
/** @type {Map<
|
|
53
|
+
/** @type {Map<OneShotConfigIDType, IPartialInitConfig>} */
|
|
50
54
|
const lOneShotConfigs = new Map([
|
|
51
55
|
["yes", lBaseConfig],
|
|
52
56
|
[
|
|
@@ -63,7 +67,7 @@ function getOneShotConfig(pOneShotConfigId) {
|
|
|
63
67
|
|
|
64
68
|
/**
|
|
65
69
|
*
|
|
66
|
-
* @param {
|
|
70
|
+
* @param {IInitConfig} pNormalizedInitConfig
|
|
67
71
|
*/
|
|
68
72
|
function manifestIsUpdatable(pNormalizedInitConfig) {
|
|
69
73
|
return (
|
|
@@ -73,7 +77,7 @@ function manifestIsUpdatable(pNormalizedInitConfig) {
|
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/**
|
|
76
|
-
* @param {boolean|
|
|
80
|
+
* @param {boolean|OneShotConfigIDType} pInit
|
|
77
81
|
* @param {string=} pConfigFileName
|
|
78
82
|
* @param {{stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream}=} pStreams
|
|
79
83
|
*/
|
|
@@ -8,7 +8,11 @@ import findExtensions from "./find-extensions.mjs";
|
|
|
8
8
|
import meta from "#meta.cjs";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
11
|
+
* @import { IInitConfig, IPartialInitConfig } from "./types.js";
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {IInitConfig} pInitOptions
|
|
12
16
|
* @param {string[]} pExtensions
|
|
13
17
|
* @returns {boolean}
|
|
14
18
|
*/
|
|
@@ -25,7 +29,7 @@ function usesTypeScript(pInitOptions, pExtensions) {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
|
-
* @param {
|
|
32
|
+
* @param {IInitConfig} pInitOptions
|
|
29
33
|
* @returns {string[]}
|
|
30
34
|
*/
|
|
31
35
|
function getExtensions(pInitOptions) {
|
|
@@ -38,8 +42,8 @@ function getExtensions(pInitOptions) {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
|
-
* @param {
|
|
42
|
-
* @return {
|
|
45
|
+
* @param {IPartialInitConfig} pInitOptions
|
|
46
|
+
* @return {IPartialInitConfig}
|
|
43
47
|
*/
|
|
44
48
|
function populate(pInitOptions) {
|
|
45
49
|
const lReturnValue = {
|
|
@@ -66,8 +70,8 @@ function populate(pInitOptions) {
|
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
72
|
*
|
|
69
|
-
* @param {
|
|
70
|
-
* @return {
|
|
73
|
+
* @param {IPartialInitConfig} pInitOptions
|
|
74
|
+
* @return {IInitConfig}
|
|
71
75
|
*/
|
|
72
76
|
export default function normalizeInitOptions(pInitOptions) {
|
|
73
77
|
let lReturnValue = populate(pInitOptions);
|
|
@@ -17,6 +17,7 @@ function getOptionValue(pDefault) {
|
|
|
17
17
|
return (pValue) => (typeof pValue === "string" ? pValue : pDefault);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// eslint-disable-next-line complexity
|
|
20
21
|
function normalizeConfigFileName(pCliOptions, pConfigWrapperName, pDefault) {
|
|
21
22
|
let lOptions = structuredClone(pCliOptions);
|
|
22
23
|
|
package/src/cli/utl/io.mjs
CHANGED
|
@@ -28,10 +28,9 @@ function writeToFile(pOutputTo, pDependencyString) {
|
|
|
28
28
|
*/
|
|
29
29
|
function writeToStdOut(pString, pBufferSize = PIPE_BUFFER_SIZE) {
|
|
30
30
|
const lNumberOfChunks = Math.ceil(pString.length / pBufferSize);
|
|
31
|
-
let lIndex = 0;
|
|
32
31
|
|
|
33
32
|
/* eslint no-plusplus: 0 */
|
|
34
|
-
for (lIndex = 0; lIndex < lNumberOfChunks; lIndex++) {
|
|
33
|
+
for (let lIndex = 0; lIndex < lNumberOfChunks; lIndex++) {
|
|
35
34
|
const lChunkStart = lIndex * pBufferSize;
|
|
36
35
|
process.stdout.write(
|
|
37
36
|
pString.substring(lChunkStart, lChunkStart + pBufferSize),
|
|
@@ -68,7 +68,6 @@ async function getConfig(pBabelConfigFileName) {
|
|
|
68
68
|
`${`The babel config '${pBabelConfigFileName}' is in a format ('${lExtension}')\n`} dependency-cruiser doesn't support yet.\n`,
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
-
// eslint-disable-next-line no-return-await
|
|
72
71
|
return await lExtensionToParseFunction.get(lExtension)(pBabelConfigFileName);
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import extractDepcruiseConfig from "./extract-depcruise-config/index.mjs";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
|
|
4
|
+
* @import { IConfiguration } from "../../types/configuration.mjs";
|
|
5
|
+
* @import { ICruiseOptions } from "../../types/options.mjs";
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {IConfiguration} pConfiguration
|
|
10
|
+
* @returns {ICruiseOptions}
|
|
7
11
|
*/
|
|
8
12
|
function configuration2options(pConfiguration) {
|
|
9
13
|
/* c8 ignore next 1 */
|
|
@@ -20,7 +24,7 @@ function configuration2options(pConfiguration) {
|
|
|
20
24
|
/**
|
|
21
25
|
*
|
|
22
26
|
* @param {string} pConfigFileName
|
|
23
|
-
* @returns {Promise<
|
|
27
|
+
* @returns {Promise<ICruiseOptions>}
|
|
24
28
|
*/
|
|
25
29
|
export default async function extractDepcruiseOptions(pConfigFileName) {
|
|
26
30
|
const lReturnValue = await extractDepcruiseConfig(pConfigFileName);
|
|
@@ -3,8 +3,8 @@ import json5 from "json5";
|
|
|
3
3
|
import makeAbsolute from "./make-absolute.mjs";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
6
|
+
* @import { IViolation } from "../../types/violations.mjs"
|
|
7
|
+
* @import { DependencyType } from "../../types/shared-types.mjs"
|
|
8
8
|
*
|
|
9
9
|
* @typedef {IViolation & {cycle: Array<{name: string, dependencyTypes: Array<DependencyType>}>} | {cycle: Array<DependencyType>}} IMaybeOldFormatViolation
|
|
10
10
|
*/
|
|
@@ -21,11 +21,11 @@ import makeAbsolute from "./make-absolute.mjs";
|
|
|
21
21
|
*/
|
|
22
22
|
function makeForwardCompatible(pKnownViolation) {
|
|
23
23
|
let lReturnValue = pKnownViolation;
|
|
24
|
-
if (
|
|
24
|
+
if (pKnownViolation.cycle) {
|
|
25
25
|
lReturnValue = {
|
|
26
26
|
...pKnownViolation,
|
|
27
27
|
cycle: pKnownViolation.cycle.map((pModule) => {
|
|
28
|
-
if (
|
|
28
|
+
if (pModule.name) {
|
|
29
29
|
return pModule;
|
|
30
30
|
}
|
|
31
31
|
return {
|
|
@@ -35,11 +35,11 @@ function makeForwardCompatible(pKnownViolation) {
|
|
|
35
35
|
}),
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (pKnownViolation.via) {
|
|
39
39
|
lReturnValue = {
|
|
40
40
|
...pKnownViolation,
|
|
41
41
|
via: pKnownViolation.via.map((pModule) => {
|
|
42
|
-
if (
|
|
42
|
+
if (pModule.name) {
|
|
43
43
|
return pModule;
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
@@ -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
|
-
/* eslint
|
|
93
|
+
/* eslint n/global-require:0, security/detect-non-literal-require:0, import/no-dynamic-require:0 */
|
|
94
94
|
return require(pAbsoluteWebpackConfigFileName);
|
|
95
95
|
}
|
|
96
96
|
} catch (pError) {
|
|
@@ -116,7 +116,7 @@ export default function softenKnownViolations(
|
|
|
116
116
|
pKnownViolations,
|
|
117
117
|
pSoftenedSeverity = "ignore",
|
|
118
118
|
) {
|
|
119
|
-
if (
|
|
119
|
+
if (pKnownViolations) {
|
|
120
120
|
bus.info("analyzing: comparing against known errors");
|
|
121
121
|
return pModules.map((pModule) =>
|
|
122
122
|
softenKnownViolation(pModule, pKnownViolations, pSoftenedSeverity),
|
|
@@ -4,6 +4,7 @@ const SHAREABLE_OPTIONS = [
|
|
|
4
4
|
"cache",
|
|
5
5
|
"collapse",
|
|
6
6
|
"combinedDependencies",
|
|
7
|
+
"detectJSDocImports",
|
|
7
8
|
"doNotFollow",
|
|
8
9
|
"enhancedResolveOptions",
|
|
9
10
|
"exclude",
|
|
@@ -20,6 +21,7 @@ const SHAREABLE_OPTIONS = [
|
|
|
20
21
|
"moduleSystems",
|
|
21
22
|
"outputTo",
|
|
22
23
|
"outputType",
|
|
24
|
+
"parser",
|
|
23
25
|
"prefix",
|
|
24
26
|
"preserveSymlinks",
|
|
25
27
|
"reaches",
|