dependency-cruiser 18.7.0 → 18.7.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/README.md +0 -1
- package/package.json +2 -2
- package/src/analyze/index.mjs +2 -2
- package/src/cli/defaults.mjs +0 -1
- package/src/config-utl/extract-ts-config.mjs +1 -1
- package/src/extract/swc/parse.mjs +1 -1
- package/src/extract/transpile/index.mjs +1 -1
- package/src/extract/transpile/typescript-wrap.mjs +23 -1
- package/src/graph-utl/add-focus.mjs +2 -2
- package/src/main/cruise.mjs +1 -2
- package/src/main/format.mjs +1 -1
- package/src/main/resolve-options/normalize.mjs +0 -27
- package/src/meta.cjs +1 -1
- package/src/report/anon/index.mjs +1 -1
- package/src/report/azure-devops.mjs +9 -9
- package/src/report/csv.mjs +1 -1
- package/src/report/dot/index.mjs +1 -1
- package/src/report/error.mjs +1 -1
- package/src/report/html/index.mjs +1 -1
- package/src/report/index.mjs +2 -2
- package/src/report/metrics.mjs +3 -3
package/README.md
CHANGED
|
@@ -193,7 +193,6 @@ You've come to the right place :-) :
|
|
|
193
193
|
## Build status
|
|
194
194
|
|
|
195
195
|
[](https://github.com/sverweij/dependency-cruiser/actions/workflows/ci.yml)
|
|
196
|
-
[](https://gitlab.com/sverweij/dependency-cruiser/builds)
|
|
197
196
|
[](https://npmjs.com/package/dependency-cruiser)
|
|
198
197
|
|
|
199
198
|
Made with :metal: in Holland.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "18.7.
|
|
3
|
+
"version": "18.7.1",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"acorn-walk": "8.3.5",
|
|
151
151
|
"commander": "15.0.0",
|
|
152
152
|
"enhanced-resolve": "5.26.0",
|
|
153
|
-
"ignore": "7.0.
|
|
153
|
+
"ignore": "7.0.14",
|
|
154
154
|
"interpret": "3.1.1",
|
|
155
155
|
"is-installed-globally": "1.0.1",
|
|
156
156
|
"json5": "2.2.3",
|
package/src/analyze/index.mjs
CHANGED
|
@@ -11,10 +11,10 @@ import { bus } from "#utl/bus.mjs";
|
|
|
11
11
|
* used in the cruise, so consumers of the cruise result (reporters, depcruise-fmt,
|
|
12
12
|
* caching) can use that.
|
|
13
13
|
*
|
|
14
|
-
* @param {import("../../types/dependency-cruiser.
|
|
14
|
+
* @param {import("../../types/dependency-cruiser.mjs").IModule[]} pModules
|
|
15
15
|
* @param {import("../../types/options.mjs").ICruiseOptions} pOptions
|
|
16
16
|
* @param {string[]} pFileAndDirectoryArray
|
|
17
|
-
* @returns {import("../../types/dependency-cruiser.
|
|
17
|
+
* @returns {import("../../types/dependency-cruiser.mjs").ICruiseResult}
|
|
18
18
|
*/
|
|
19
19
|
export default function analyze(pModules, pOptions, pFileAndDirectoryArray) {
|
|
20
20
|
const lModules = analyzeModules(pModules, pOptions);
|
package/src/cli/defaults.mjs
CHANGED
|
@@ -30,7 +30,7 @@ const CACHE = new Map();
|
|
|
30
30
|
* @param {string} pFileName
|
|
31
31
|
* @returns {ParseOptions}
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
function getOptionsFor(pFileName) {
|
|
34
34
|
return /[.](?:tsx|jsx)$/.test(pFileName)
|
|
35
35
|
? { ...SWC_PARSE_OPTIONS, tsx: true }
|
|
36
36
|
: SWC_PARSE_OPTIONS;
|
|
@@ -13,7 +13,7 @@ const coffeeVanillaWrap = coffeeWrap();
|
|
|
13
13
|
const litCoffeeWrap = coffeeWrap(true);
|
|
14
14
|
const svelteWrap = svelteDingus(typeScriptVanillaWrap);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const EXTENSION2WRAPPER = new Map([
|
|
17
17
|
[".js", javaScriptWrap],
|
|
18
18
|
[".cjs", javaScriptWrap],
|
|
19
19
|
[".mjs", javaScriptWrap],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
1
2
|
import tryImport from "#utl/try-import.mjs";
|
|
2
3
|
import meta from "#meta.cjs";
|
|
3
4
|
|
|
@@ -6,6 +7,16 @@ const typescript = await tryImport(
|
|
|
6
7
|
meta.supportedTranspilers.typescript,
|
|
7
8
|
);
|
|
8
9
|
|
|
10
|
+
// This RE matches
|
|
11
|
+
// - filename.d.ts (, .cts, .mts), but also
|
|
12
|
+
// - filename.d.something.ts (, .cts., .mts).
|
|
13
|
+
// That second one seems a bit odd, but it _is_ possible; see for instance
|
|
14
|
+
// https://www.typescriptlang.org/tsconfig/#allowArbitraryExtensions
|
|
15
|
+
// (and I guess, but haven't seen this confirmed in the field or documentation
|
|
16
|
+
// that it could be possible to have a declaration file variant of
|
|
17
|
+
// https://www.typescriptlang.org/tsconfig/#moduleSuffixes)
|
|
18
|
+
const DECLARATION_FILE_RE = /[.]d([.][^./\\]+)?([.][cm]?ts)$/;
|
|
19
|
+
|
|
9
20
|
function getCompilerOptions(pFlavor, pTSConfig) {
|
|
10
21
|
const lCompilerOptions = {};
|
|
11
22
|
|
|
@@ -32,15 +43,26 @@ function getCompilerOptions(pFlavor, pTSConfig) {
|
|
|
32
43
|
};
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
function getTranspilableFileName(pFileName) {
|
|
47
|
+
if (typeof pFileName !== "string") {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// Declaration files (.d.ts, .d.mts, .d.cts, .d.css.ts) get their
|
|
51
|
+
// non-declaration name, because TypeScript emits nothing for a declaration
|
|
52
|
+
// file and throws "Debug Failure. Output generation failed".
|
|
53
|
+
return resolve(pFileName).replace(DECLARATION_FILE_RE, "$1$2");
|
|
54
|
+
}
|
|
55
|
+
|
|
35
56
|
export default function typescriptWrap(pFlavor) {
|
|
36
57
|
return {
|
|
37
58
|
isAvailable: () => typescript !== false,
|
|
38
59
|
|
|
39
60
|
version: () => `typescript@${typescript.version}`,
|
|
40
61
|
|
|
41
|
-
transpile: (pSource,
|
|
62
|
+
transpile: (pSource, pFileName, pTranspileOptions = {}) =>
|
|
42
63
|
typescript.transpileModule(pSource, {
|
|
43
64
|
...(pTranspileOptions.tsConfig || {}),
|
|
65
|
+
fileName: getTranspilableFileName(pFileName),
|
|
44
66
|
compilerOptions: getCompilerOptions(
|
|
45
67
|
pFlavor,
|
|
46
68
|
pTranspileOptions.tsConfig || {},
|
|
@@ -23,8 +23,8 @@ function scrub(pModuleNamesSet) {
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
*
|
|
26
|
-
* @param {import("../../types/dependency-cruiser.
|
|
27
|
-
* @param {import("../../types/strict-filter-types.
|
|
26
|
+
* @param {import("../../types/dependency-cruiser.mjs").IModule[]} pModules
|
|
27
|
+
* @param {import("../../types/strict-filter-types.mjs").IStrictFocusType} pFilter
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
30
|
export default function addFocus(pModules, pFilter) {
|
package/src/main/cruise.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { clearRegExpCache } from "#utl/regex-util.mjs";
|
|
|
7
7
|
|
|
8
8
|
const TOTAL_STEPS = 10;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function c(pComplete, pTotal = TOTAL_STEPS) {
|
|
11
11
|
return { complete: pComplete / pTotal };
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -81,7 +81,6 @@ export default async function cruise(
|
|
|
81
81
|
const lNormalizedResolveOptions = await normalizeResolveOptions(
|
|
82
82
|
pResolveOptions,
|
|
83
83
|
lCruiseOptions,
|
|
84
|
-
pTranspileOptions?.tsConfig,
|
|
85
84
|
);
|
|
86
85
|
|
|
87
86
|
bus.summary("extract", c(6));
|
package/src/main/format.mjs
CHANGED
|
@@ -11,7 +11,7 @@ function validateResultAgainstSchema(pResult) {
|
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
/** @type {import("../../types/dependency-cruiser.
|
|
14
|
+
/** @type {import("../../types/dependency-cruiser.mjs").format} */
|
|
15
15
|
export default async function format(pResult, pFormatOptions = {}) {
|
|
16
16
|
const lFormatOptions = normalizeFormatOptions(pFormatOptions);
|
|
17
17
|
assertFormatOptionsValid(lFormatOptions);
|
|
@@ -68,7 +68,6 @@ function pushPlugin(pPlugins, pPluginToPush) {
|
|
|
68
68
|
// eslint-disable-next-line max-lines-per-function
|
|
69
69
|
async function compileResolveOptions(
|
|
70
70
|
pResolveOptions,
|
|
71
|
-
pTSConfig,
|
|
72
71
|
pResolveOptionsFromDCConfig,
|
|
73
72
|
) {
|
|
74
73
|
const lResolveOptions = {};
|
|
@@ -86,29 +85,6 @@ async function compileResolveOptions(
|
|
|
86
85
|
// @ts-expect-error TS2351 "TsConfPathsPlugin is not constructable" - is unjustified
|
|
87
86
|
new TsConfigPathsPlugin({
|
|
88
87
|
configFile: pResolveOptions.tsConfig,
|
|
89
|
-
// TsConfigPathsPlugin requires a baseUrl to be present in the tsconfig,
|
|
90
|
-
// otherwise it prints scary messages that it didn't and read the tsConfig
|
|
91
|
-
// (potentially making users think it's dependency-cruiser disregarding the
|
|
92
|
-
// tsconfig). Hence up till version 13.0.4 dependency-cruiser only loaded
|
|
93
|
-
// TsConfigPathsPlugin when an options.baseUrl existed. However, this
|
|
94
|
-
// isn't necessary anymore:
|
|
95
|
-
// - [tsconfig#baseUrl documentation](https://www.typescriptlang.org/tsconfig#baseUrl)
|
|
96
|
-
// UNrecommends the use of the baseUrl for non-AMD projects
|
|
97
|
-
// - [tsconfig-paths PR #207](https://github.com/dividab/tsconfig-paths/pull/208)
|
|
98
|
-
// 'tolerates' undefined baseUrls
|
|
99
|
-
//
|
|
100
|
-
// Hence, until
|
|
101
|
-
// [tpwp issue #99](https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/99)
|
|
102
|
-
// lands:
|
|
103
|
-
// - pass a default baseUrl to TsConfigPathsPlugin if the baseUrl isn't available
|
|
104
|
-
// - pass undefined in all other cases; TsConfigPathsPlugin will read
|
|
105
|
-
// it from the tsconfig.json in that case. Passing the processed baseUrl
|
|
106
|
-
// (pTSConfig?.options?.baseUrl) instead would've been more obvious, but
|
|
107
|
-
// doesn't work, as that is an absolute path and tsconfig-paths(-wpp)
|
|
108
|
-
// seems to process that again resulting in invalid paths and unresolved
|
|
109
|
-
// or erroneous dependencies
|
|
110
|
-
// eslint-disable-next-line no-undefined
|
|
111
|
-
baseUrl: pTSConfig?.options?.baseUrl ? undefined : "./",
|
|
112
88
|
// TsConfigPathsPlugin doesn't (can't) read enhanced-resolve's
|
|
113
89
|
// list of extensions, and the default it uses for extensions
|
|
114
90
|
// so we do it ourselves - either with the extensions passed
|
|
@@ -136,14 +112,12 @@ async function compileResolveOptions(
|
|
|
136
112
|
/**
|
|
137
113
|
* @param {IResolveOptions} pResolveOptions
|
|
138
114
|
* @param {ICruiseOptions} pOptions
|
|
139
|
-
* @param {import("typescript").ParsedTsconfig} pTSConfig
|
|
140
115
|
* @returns
|
|
141
116
|
*/
|
|
142
117
|
// eslint-disable-next-line complexity
|
|
143
118
|
export default async function normalizeResolveOptions(
|
|
144
119
|
pResolveOptions,
|
|
145
120
|
pOptions,
|
|
146
|
-
pTSConfig,
|
|
147
121
|
) {
|
|
148
122
|
const lRuleSet = pOptions?.ruleSet ?? {};
|
|
149
123
|
|
|
@@ -174,7 +148,6 @@ export default async function normalizeResolveOptions(
|
|
|
174
148
|
resolveDeprecations: ruleSetHasDeprecationRule(lRuleSet),
|
|
175
149
|
...pResolveOptions,
|
|
176
150
|
},
|
|
177
|
-
pTSConfig || {},
|
|
178
151
|
pOptions?.enhancedResolveOptions ?? {},
|
|
179
152
|
);
|
|
180
153
|
}
|
package/src/meta.cjs
CHANGED
|
@@ -174,7 +174,7 @@ function sanitizeWordList(pWordList) {
|
|
|
174
174
|
* not passed the reporter uses the string passed
|
|
175
175
|
* in the options (reporterOptions.anon.wordlist)
|
|
176
176
|
* or - if that doesn't exist - the empty array
|
|
177
|
-
* @returns {import("../../../types/dependency-cruiser.
|
|
177
|
+
* @returns {import("../../../types/dependency-cruiser.mjs").IReporterOutput} - output: the results in JSON format (hence adhering to the same json schema)
|
|
178
178
|
* exitCode: 0
|
|
179
179
|
*/
|
|
180
180
|
export default function reportAnonymous(pResults, pAnonymousReporterOptions) {
|
|
@@ -13,7 +13,7 @@ const SEVERITY2VSO_TYPE = new Map([
|
|
|
13
13
|
]);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @param {import("../../types/shared-types.
|
|
16
|
+
* @param {import("../../types/shared-types.mjs").SeverityType} pSeverity
|
|
17
17
|
* @returns {string}
|
|
18
18
|
*/
|
|
19
19
|
function formatSeverity(pSeverity) {
|
|
@@ -21,7 +21,7 @@ function formatSeverity(pSeverity) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @param {import("../../types/violations.
|
|
24
|
+
* @param {import("../../types/violations.mjs").IViolation} pViolation
|
|
25
25
|
* @returns {string}
|
|
26
26
|
*/
|
|
27
27
|
function formatModuleViolation(pViolation) {
|
|
@@ -29,7 +29,7 @@ function formatModuleViolation(pViolation) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @param {import("../../types/violations.
|
|
32
|
+
* @param {import("../../types/violations.mjs").IViolation} pViolation
|
|
33
33
|
* @returns {string}
|
|
34
34
|
*/
|
|
35
35
|
function formatDependencyViolation(pViolation) {
|
|
@@ -37,7 +37,7 @@ function formatDependencyViolation(pViolation) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* @param {import("../../types/violations.
|
|
40
|
+
* @param {import("../../types/violations.mjs").IViolation} pViolation
|
|
41
41
|
* @returns {string}
|
|
42
42
|
*/
|
|
43
43
|
function formatCycleViolation(pViolation) {
|
|
@@ -47,7 +47,7 @@ function formatCycleViolation(pViolation) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* @param {import("../../types/violations.
|
|
50
|
+
* @param {import("../../types/violations.mjs").IViolation} pViolation
|
|
51
51
|
* @returns {string}
|
|
52
52
|
*/
|
|
53
53
|
function formatReachabilityViolation(pViolation) {
|
|
@@ -57,7 +57,7 @@ function formatReachabilityViolation(pViolation) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* @param {import("../../types/violations.
|
|
60
|
+
* @param {import("../../types/violations.mjs").IViolation} pViolation
|
|
61
61
|
* @returns {string}
|
|
62
62
|
*/
|
|
63
63
|
function formatInstabilityViolation(pViolation) {
|
|
@@ -69,7 +69,7 @@ function formatInstabilityViolation(pViolation) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* @param {import("../../types/violations.
|
|
72
|
+
* @param {import("../../types/violations.mjs").IViolation} pViolation
|
|
73
73
|
* @returns {string}
|
|
74
74
|
*/
|
|
75
75
|
function formatViolation(pViolation) {
|
|
@@ -167,8 +167,8 @@ function formatSummary(pSummary) {
|
|
|
167
167
|
* Background documentation:
|
|
168
168
|
* https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#task-commands
|
|
169
169
|
*
|
|
170
|
-
* @param {import("../../types/dependency-cruiser.
|
|
171
|
-
* @returns {import("../../types/dependency-cruiser.
|
|
170
|
+
* @param {import("../../types/dependency-cruiser.mjs").ICruiseResult} pResults
|
|
171
|
+
* @returns {import("../../types/dependency-cruiser.mjs").IReporterOutput}
|
|
172
172
|
*/
|
|
173
173
|
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
174
174
|
export default function azureDevOps(pResults) {
|
package/src/report/csv.mjs
CHANGED
|
@@ -27,7 +27,7 @@ function report(pModules) {
|
|
|
27
27
|
*
|
|
28
28
|
* @param {import("../../types/cruise-result.mjs").ICruiseResult} pResults -
|
|
29
29
|
* the output of a dependency-cruise adhering to ../../schema/cruise-result.schema.json
|
|
30
|
-
* @returns {import("../../types/dependency-cruiser.
|
|
30
|
+
* @returns {import("../../types/dependency-cruiser.mjs").IReporterOutput}
|
|
31
31
|
*/
|
|
32
32
|
export default function csv(pResults) {
|
|
33
33
|
return {
|
package/src/report/dot/index.mjs
CHANGED
|
@@ -214,7 +214,7 @@ function normalizeDotReporterOptions(
|
|
|
214
214
|
* @param {string} pGranularity - either "module" (for fine grained module
|
|
215
215
|
* level) or "folder" (for a report consolidated
|
|
216
216
|
* to folders)
|
|
217
|
-
* @returns {(pResults, pDotReporterOptions) => import("../../../types/dependency-cruiser.
|
|
217
|
+
* @returns {(pResults, pDotReporterOptions) => import("../../../types/dependency-cruiser.mjs").IReporterOutput}
|
|
218
218
|
*/
|
|
219
219
|
export default function produceDotReporter(pGranularity) {
|
|
220
220
|
return function dot(pResults, pDotReporterOptions) {
|
package/src/report/error.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import wrapAndIndent from "#utl/wrap-and-indent.mjs";
|
|
|
11
11
|
/**
|
|
12
12
|
* @import { ICruiseResult, IEnvironmentIssue } from "../../types/cruise-result.mjs"
|
|
13
13
|
* @import { IErrorReporterOptions } from "../../types/reporter-options.mjs"
|
|
14
|
-
* @import { IReporterOutput } from "../../types/dependency-cruiser.
|
|
14
|
+
* @import { IReporterOutput } from "../../types/dependency-cruiser.mjs"
|
|
15
15
|
* @import { SeverityType } from "../../types/shared-types.mjs"
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -110,7 +110,7 @@ function report(pResults) {
|
|
|
110
110
|
* Returns the results of a cruise in an 'incidence matrix'
|
|
111
111
|
*
|
|
112
112
|
* @param {import("../../../types/cruise-result.mjs").ICruiseResult} pResults
|
|
113
|
-
* @returns {import("../../../types/dependency-cruiser.
|
|
113
|
+
* @returns {import("../../../types/dependency-cruiser.mjs").IReporterOutput}
|
|
114
114
|
*/
|
|
115
115
|
export default function html(pResults) {
|
|
116
116
|
return {
|
package/src/report/index.mjs
CHANGED
|
@@ -31,7 +31,7 @@ const TYPE2MODULE = new Map([
|
|
|
31
31
|
* Returns the reporter function associated with given output type,
|
|
32
32
|
* or the identity reporter if that output type wasn't found
|
|
33
33
|
*
|
|
34
|
-
* @param {import("../../types/shared-types.
|
|
34
|
+
* @param {import("../../types/shared-types.mjs").OutputType} pOutputType -
|
|
35
35
|
* @returns {function} - a function that takes an ICruiseResult, optionally
|
|
36
36
|
* an options object (specific to that function)
|
|
37
37
|
* and returns an IReporterOutput
|
|
@@ -52,7 +52,7 @@ export async function getReporter(pOutputType) {
|
|
|
52
52
|
/**
|
|
53
53
|
* Returns a list of all currently available reporters
|
|
54
54
|
*
|
|
55
|
-
* @returns {import("../../types/shared-types.
|
|
55
|
+
* @returns {import("../../types/shared-types.mjs").OutputType[]} -
|
|
56
56
|
*/
|
|
57
57
|
export function getAvailableReporters() {
|
|
58
58
|
return Array.from(TYPE2MODULE.keys());
|
package/src/report/metrics.mjs
CHANGED
|
@@ -266,9 +266,9 @@ function transformMetricsToTable(
|
|
|
266
266
|
* Potential future features:
|
|
267
267
|
* - additional output formats (csv?, html?)
|
|
268
268
|
*
|
|
269
|
-
* @param {import('../../types/dependency-cruiser.
|
|
270
|
-
* @param {import("../../types/reporter-options.
|
|
271
|
-
* @returns {import('../../types/dependency-cruiser.
|
|
269
|
+
* @param {import('../../types/dependency-cruiser.mjs').ICruiseResult} pCruiseResult -
|
|
270
|
+
* @param {import("../../types/reporter-options.mjs").IMetricsReporterOptions} pReporterOptions
|
|
271
|
+
* @returns {import('../../types/dependency-cruiser.mjs').IReporterOutput} -
|
|
272
272
|
*/
|
|
273
273
|
export default function metrics(pCruiseResult, pReporterOptions) {
|
|
274
274
|
const lReporterOptions = pReporterOptions || {};
|