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/src/validate/index.mjs
CHANGED
|
@@ -3,6 +3,10 @@ import matchDependencyRule from "./match-dependency-rule.mjs";
|
|
|
3
3
|
import violatesRequiredRule from "./violates-required-rule.mjs";
|
|
4
4
|
import matchFolderRule from "./match-folder-dependency-rule.mjs";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @import { IValidationResult } from "./index.d.ts";
|
|
8
|
+
*/
|
|
9
|
+
|
|
6
10
|
function compareSeverity(pFirst, pSecond) {
|
|
7
11
|
const lSeverity2Int = {
|
|
8
12
|
error: 1,
|
|
@@ -67,10 +71,10 @@ function validateAgainstRequiredRules(pRuleSet, pModule, pMatchModule) {
|
|
|
67
71
|
* @param {*} pFrom
|
|
68
72
|
* @param {*} pTo
|
|
69
73
|
* @param {*} pMatchModule
|
|
70
|
-
* @returns {
|
|
74
|
+
* @returns {IValidationResult}
|
|
71
75
|
*/
|
|
72
76
|
function validateAgainstRules(pRuleSet, pFrom, pTo, pMatchModule) {
|
|
73
|
-
/** @type {
|
|
77
|
+
/** @type {IValidationResult} */
|
|
74
78
|
let lReturnValue = { valid: true };
|
|
75
79
|
|
|
76
80
|
const lFoundRuleViolations = validateAgainstAllowedRules(
|
|
@@ -18,9 +18,13 @@ import {
|
|
|
18
18
|
import { extractGroups } from "#utl/regex-util.mjs";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
|
|
21
|
+
* @import { IDependency, IModule } from "../../types/cruise-result.mjs";
|
|
22
|
+
* @import { IAnyRuleType } from "../../types/rule-set.mjs";
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {IModule} pFrom
|
|
27
|
+
* @param {IDependency} pTo
|
|
24
28
|
* @returns {(pRule) => boolean}
|
|
25
29
|
*/
|
|
26
30
|
function match(pFrom, pTo) {
|
|
@@ -57,7 +61,7 @@ function match(pFrom, pTo) {
|
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
/**
|
|
60
|
-
* @param {
|
|
64
|
+
* @param {IAnyRuleType} pRule
|
|
61
65
|
* @returns boolean
|
|
62
66
|
*/
|
|
63
67
|
const isInteresting = (pRule) =>
|
|
@@ -7,12 +7,18 @@ import {
|
|
|
7
7
|
matchesModulePathNot,
|
|
8
8
|
} from "./matchers.mjs";
|
|
9
9
|
import { extractGroups } from "#utl/regex-util.mjs";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @import { IModule } from "../../types/cruise-result.mjs";
|
|
13
|
+
* @import { IAnyRuleType } from "../../types/rule-set.mjs";
|
|
14
|
+
*/
|
|
15
|
+
|
|
10
16
|
/**
|
|
11
17
|
* Returns true if pRule is an orphan rule and pModule is an orphan.
|
|
12
18
|
* Returns false in all other cases
|
|
13
19
|
*
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
20
|
+
* @param {IAnyRuleType} pRule
|
|
21
|
+
* @param {IModule} pModule
|
|
16
22
|
* @returns {boolean}
|
|
17
23
|
*/
|
|
18
24
|
export function matchesOrphanRule(pRule, pModule) {
|
|
@@ -30,8 +36,8 @@ export function matchesOrphanRule(pRule, pModule) {
|
|
|
30
36
|
* criteria.
|
|
31
37
|
* Returns false in all other cases
|
|
32
38
|
*
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
39
|
+
* @param {IAnyRuleType} pRule
|
|
40
|
+
* @param {IModule} pModule
|
|
35
41
|
* @returns {boolean}
|
|
36
42
|
*/
|
|
37
43
|
export function matchesReachableRule(pRule, pModule) {
|
|
@@ -63,8 +69,8 @@ export function matchesReachableRule(pRule, pModule) {
|
|
|
63
69
|
* criteria.
|
|
64
70
|
* Returns false in all other cases
|
|
65
71
|
*
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {
|
|
72
|
+
* @param {IAnyRuleType} pRule
|
|
73
|
+
* @param {IModule} pModule
|
|
68
74
|
* @returns {boolean}
|
|
69
75
|
*/
|
|
70
76
|
export function matchesReachesRule(pRule, pModule) {
|
|
@@ -85,7 +91,7 @@ export function matchesReachesRule(pRule, pModule) {
|
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
93
|
*
|
|
88
|
-
* @param {
|
|
94
|
+
* @param {IAnyRuleType} pRule
|
|
89
95
|
* @param {string[]} pDependents
|
|
90
96
|
* @returns {boolean}
|
|
91
97
|
*/
|
|
@@ -105,11 +111,11 @@ function dependentsCountsMatch(pRule, pDependents) {
|
|
|
105
111
|
|
|
106
112
|
/**
|
|
107
113
|
*
|
|
108
|
-
* @param {
|
|
109
|
-
* @param {
|
|
114
|
+
* @param {IAnyRuleType} pRule
|
|
115
|
+
* @param {IModule} pModule
|
|
110
116
|
* @returns {boolean}
|
|
111
117
|
*/
|
|
112
|
-
|
|
118
|
+
|
|
113
119
|
export function matchesDependentsRule(pRule, pModule) {
|
|
114
120
|
if (
|
|
115
121
|
(Object.hasOwn(pModule, "dependents") &&
|
|
@@ -7,9 +7,13 @@ import {
|
|
|
7
7
|
} from "./match-module-rule-helpers.mjs";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
|
|
10
|
+
* @import { IModule } from "../../types/cruise-result.mjs";
|
|
11
|
+
* @import { IAnyRuleType } from "../../types/rule-set.mjs";
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {IModule} pModule
|
|
16
|
+
* @returns {(pRule:IAnyRuleType) => boolean}
|
|
13
17
|
*/
|
|
14
18
|
function match(pModule) {
|
|
15
19
|
return (pRule) =>
|
|
@@ -20,8 +24,7 @@ function match(pModule) {
|
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {import("../../types/rule-set.mjs").IAnyRuleType} pRule
|
|
27
|
+
* @param {IAnyRuleType} pRule
|
|
25
28
|
* @returns boolean
|
|
26
29
|
*/
|
|
27
30
|
const isInteresting = (pRule) =>
|
|
@@ -85,7 +85,7 @@ export function matchToModulePath(pRule, pModule, pGroups) {
|
|
|
85
85
|
|
|
86
86
|
function _toPathNot(pRule, pString, pGroups = []) {
|
|
87
87
|
return (
|
|
88
|
-
!
|
|
88
|
+
!pRule.to.pathNot ||
|
|
89
89
|
!pString.match(replaceGroupPlaceholders(pRule.to.pathNot, pGroups))
|
|
90
90
|
);
|
|
91
91
|
}
|
|
@@ -112,7 +112,6 @@ export function matchesToDependencyTypesNot(pRule, pDependency) {
|
|
|
112
112
|
);
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
// eslint-disable-next-line complexity
|
|
116
115
|
export function matchesToVia(pRule, pDependency, pGroups) {
|
|
117
116
|
let lReturnValue = true;
|
|
118
117
|
if (pRule.to.via && pDependency.cycle) {
|
|
@@ -144,7 +143,6 @@ export function matchesToVia(pRule, pDependency, pGroups) {
|
|
|
144
143
|
return lReturnValue;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
// eslint-disable-next-line complexity
|
|
148
146
|
export function matchesToViaOnly(pRule, pDependency, pGroups) {
|
|
149
147
|
let lReturnValue = true;
|
|
150
148
|
if (pRule.to.viaOnly && pDependency.cycle) {
|
package/types/options.d.mts
CHANGED
|
@@ -144,6 +144,11 @@ export interface ICruiseOptions {
|
|
|
144
144
|
* defaults to ["es6", "cjs", "amd"]
|
|
145
145
|
*/
|
|
146
146
|
moduleSystems?: ModuleSystemType[];
|
|
147
|
+
/**
|
|
148
|
+
* When true, dependency-cruiser will detect dependencies in JSDoc-style
|
|
149
|
+
* import statements. Implies `"parser": "tsc"`. Defaults to false.'
|
|
150
|
+
*/
|
|
151
|
+
detectJSDocImports?: boolean;
|
|
147
152
|
/**
|
|
148
153
|
* one of "json", "html", "dot", "csv" or "err". When left
|
|
149
154
|
* out the function will return a javascript object as dependencies
|