dependency-cruiser 17.3.2 → 17.3.3-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 +43 -43
- package/bin/depcruise-fmt.mjs +89 -89
- package/bin/dependency-cruise.mjs +171 -171
- package/configs/plugins/3d-reporter-plugin.mjs +36 -36
- package/configs/plugins/stats-reporter-plugin.mjs +51 -51
- package/configs/recommended-strict.cjs +5 -5
- package/configs/recommended-warn-only.cjs +5 -5
- package/configs/recommended.cjs +22 -22
- package/configs/rules/no-circular.cjs +10 -10
- package/configs/rules/no-deprecated-core.cjs +10 -10
- package/configs/rules/no-duplicate-dependency-types.cjs +17 -17
- package/configs/rules/no-non-package-json.cjs +11 -11
- package/configs/rules/no-orphans.cjs +18 -18
- package/configs/rules/not-to-deprecated.cjs +10 -10
- package/configs/rules/not-to-unresolvable.cjs +10 -10
- package/package.json +170 -170
- package/src/cache/cache.mjs +139 -139
- package/src/cache/content-strategy.mjs +88 -88
- package/src/cache/find-content-changes.mjs +58 -58
- package/src/cache/helpers.mjs +52 -52
- package/src/cache/metadata-strategy.mjs +83 -83
- package/src/cache/options-compatible.mjs +56 -109
- package/src/cli/assert-node-environment-suitable.mjs +7 -7
- package/src/cli/defaults.mjs +5 -5
- package/src/cli/format-meta-info.mjs +22 -22
- package/src/cli/format.mjs +28 -28
- package/src/cli/index.mjs +145 -145
- package/src/cli/init-config/build-config.mjs +94 -94
- package/src/cli/init-config/environment-helpers.mjs +77 -77
- package/src/cli/init-config/find-extensions.mjs +27 -27
- package/src/cli/init-config/get-user-input.mjs +151 -151
- package/src/cli/init-config/index.mjs +88 -88
- package/src/cli/init-config/normalize-init-options.mjs +47 -47
- package/src/cli/init-config/utl.mjs +4 -4
- package/src/cli/init-config/validators.mjs +10 -10
- package/src/cli/init-config/write-config.mjs +21 -21
- package/src/cli/init-config/write-run-scripts-to-manifest.mjs +103 -107
- package/src/cli/listeners/cli-feedback.mjs +49 -49
- package/src/cli/listeners/ndjson.mjs +66 -66
- package/src/cli/listeners/performance-log/format-helpers.mjs +63 -63
- package/src/cli/listeners/performance-log/handlers.mjs +56 -56
- package/src/cli/listeners/performance-log/index.mjs +37 -37
- package/src/cli/normalize-cli-options.mjs +182 -182
- package/src/cli/tools/wrap-stream-in-html.mjs +37 -37
- package/src/cli/utl/assert-file-existence.mjs +7 -7
- package/src/cli/utl/io.mjs +28 -31
- package/src/config-utl/extract-babel-config.mjs +69 -69
- package/src/config-utl/extract-depcruise-config/index.mjs +54 -54
- package/src/config-utl/extract-depcruise-config/merge-configs.mjs +63 -63
- package/src/config-utl/extract-depcruise-config/read-config.mjs +9 -9
- package/src/config-utl/extract-depcruise-options.mjs +9 -9
- package/src/config-utl/extract-known-violations.mjs +49 -49
- package/src/config-utl/extract-ts-config.mjs +46 -48
- package/src/config-utl/extract-webpack-resolve-config.mjs +88 -88
- package/src/config-utl/make-absolute.mjs +5 -5
- package/src/enrich/add-validations.mjs +13 -13
- package/src/enrich/derive/circular.mjs +49 -49
- package/src/enrich/derive/dependents.mjs +27 -27
- package/src/enrich/derive/folders/aggregate-to-folders.mjs +104 -104
- package/src/enrich/derive/folders/index.mjs +19 -19
- package/src/enrich/derive/folders/utl.mjs +18 -18
- package/src/enrich/derive/metrics/get-module-metrics.mjs +27 -27
- package/src/enrich/derive/metrics/index.mjs +8 -8
- package/src/enrich/derive/module-utl.mjs +18 -18
- package/src/enrich/derive/orphan/index.mjs +18 -18
- package/src/enrich/derive/orphan/is-orphan.mjs +9 -9
- package/src/enrich/derive/reachable.mjs +165 -168
- package/src/enrich/enrich-modules.mjs +25 -25
- package/src/enrich/index.mjs +15 -15
- package/src/enrich/soften-known-violations.mjs +90 -90
- package/src/enrich/summarize/add-rule-set-used.mjs +13 -13
- package/src/enrich/summarize/get-stats.mjs +17 -17
- package/src/enrich/summarize/index.mjs +18 -18
- package/src/enrich/summarize/is-same-violation.mjs +30 -30
- package/src/enrich/summarize/summarize-folders.mjs +35 -35
- package/src/enrich/summarize/summarize-modules.mjs +97 -97
- package/src/enrich/summarize/summarize-options.mjs +71 -71
- package/src/extract/acorn/estree-helpers.mjs +66 -66
- package/src/extract/acorn/extract-amd-deps.mjs +63 -64
- package/src/extract/acorn/extract-cjs-deps.mjs +83 -83
- package/src/extract/acorn/extract-es6-deps.mjs +54 -54
- package/src/extract/acorn/extract-stats.mjs +4 -4
- package/src/extract/acorn/extract.mjs +28 -28
- package/src/extract/acorn/parse.mjs +37 -37
- package/src/extract/clear-caches.mjs +7 -7
- package/src/extract/extract-dependencies.mjs +109 -109
- package/src/extract/extract-stats.mjs +21 -21
- package/src/extract/gather-initial-sources.mjs +64 -64
- package/src/extract/helpers.mjs +73 -71
- package/src/extract/index.mjs +120 -120
- package/src/extract/resolve/determine-dependency-types.mjs +166 -169
- package/src/extract/resolve/external-module-helpers.mjs +76 -76
- package/src/extract/resolve/get-manifest.mjs +79 -79
- package/src/extract/resolve/index.mjs +175 -164
- package/src/extract/resolve/is-built-in.mjs +22 -24
- package/src/extract/resolve/merge-manifests.mjs +43 -43
- package/src/extract/resolve/module-classifiers.mjs +229 -229
- package/src/extract/resolve/resolve-amd.mjs +44 -44
- package/src/extract/resolve/resolve-cjs.mjs +40 -40
- package/src/extract/resolve/resolve-helpers.mjs +20 -20
- package/src/extract/resolve/resolve.mjs +26 -26
- package/src/extract/swc/dependency-visitor.mjs +211 -211
- package/src/extract/swc/extract-swc-deps.mjs +4 -4
- package/src/extract/swc/extract.mjs +7 -7
- package/src/extract/swc/parse.mjs +12 -12
- package/src/extract/transpile/babel-wrap.mjs +9 -9
- package/src/extract/transpile/coffeescript-wrap.mjs +21 -21
- package/src/extract/transpile/index.mjs +47 -47
- package/src/extract/transpile/javascript-wrap.mjs +6 -6
- package/src/extract/transpile/livescript-wrap.mjs +5 -5
- package/src/extract/transpile/meta.mjs +80 -80
- package/src/extract/transpile/svelte-preprocess.mjs +73 -73
- package/src/extract/transpile/svelte-wrap.mjs +19 -19
- package/src/extract/transpile/try-import-available.mjs +26 -27
- package/src/extract/transpile/typescript-wrap.mjs +39 -39
- package/src/extract/transpile/vue-template-wrap.cjs +43 -43
- package/src/extract/tsc/extract-stats.mjs +4 -4
- package/src/extract/tsc/extract-typescript-deps.mjs +429 -398
- package/src/extract/tsc/extract.mjs +22 -22
- package/src/extract/tsc/parse.mjs +21 -21
- package/src/graph-utl/add-focus.mjs +35 -35
- package/src/graph-utl/compare.mjs +24 -24
- package/src/graph-utl/consolidate-module-dependencies.mjs +35 -35
- package/src/graph-utl/consolidate-modules.mjs +33 -33
- package/src/graph-utl/consolidate-to-folder.mjs +13 -13
- package/src/graph-utl/consolidate-to-pattern.mjs +34 -34
- package/src/graph-utl/filter-bank.mjs +74 -69
- package/src/graph-utl/indexed-module-graph.mjs +227 -225
- package/src/graph-utl/match-facade.mjs +3 -3
- package/src/graph-utl/rule-set.mjs +20 -20
- package/src/graph-utl/strip-self-transitions.mjs +6 -6
- package/src/main/cruise.mjs +81 -81
- package/src/main/files-and-dirs/normalize.mjs +7 -7
- package/src/main/format.mjs +11 -14
- package/src/main/helpers.mjs +25 -25
- package/src/main/index.mjs +8 -8
- package/src/main/options/assert-validity.mjs +100 -100
- package/src/main/options/defaults.mjs +11 -11
- package/src/main/options/normalize.mjs +158 -160
- package/src/main/report-wrap.mjs +37 -37
- package/src/main/resolve-options/normalize.mjs +127 -128
- package/src/main/rule-set/assert-validity.mjs +67 -73
- package/src/main/rule-set/normalize.mjs +81 -79
- package/src/meta.cjs +15 -16
- package/src/report/anon/anonymize-path-element.mjs +20 -34
- package/src/report/anon/anonymize-path.mjs +11 -11
- package/src/report/anon/index.mjs +119 -119
- package/src/report/anon/random-string.mjs +23 -23
- package/src/report/azure-devops.mjs +75 -99
- package/src/report/baseline.mjs +9 -9
- package/src/report/csv.mjs +13 -13
- package/src/report/d2.mjs +105 -105
- package/src/report/dot/default-theme.mjs +152 -152
- package/src/report/dot/index.mjs +146 -146
- package/src/report/dot/module-utl.mjs +72 -72
- package/src/report/dot/prepare-custom-level.mjs +20 -20
- package/src/report/dot/prepare-flat-level.mjs +11 -11
- package/src/report/dot/prepare-folder-level.mjs +12 -13
- package/src/report/dot/theming.mjs +73 -73
- package/src/report/dot-webpage/dot-module.mjs +36 -36
- package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +208 -210
- package/src/report/dot-webpage/svg-in-html-snippets/style.css +51 -51
- package/src/report/dot-webpage/wrap-in-html.mjs +7 -7
- package/src/report/error-html/index.mjs +49 -49
- package/src/report/error-html/utl.mjs +99 -99
- package/src/report/error-long.mjs +1 -1
- package/src/report/error.mjs +93 -93
- package/src/report/html/index.mjs +48 -48
- package/src/report/identity.mjs +4 -4
- package/src/report/index.mjs +33 -33
- package/src/report/json.mjs +4 -4
- package/src/report/markdown.mjs +120 -120
- package/src/report/mermaid.mjs +111 -111
- package/src/report/metrics.mjs +185 -185
- package/src/report/null.mjs +4 -4
- package/src/report/plugins.mjs +41 -41
- package/src/report/teamcity.mjs +150 -150
- package/src/report/text.mjs +42 -42
- package/src/report/utl/dependency-to-incidence-transformer.mjs +32 -32
- package/src/report/utl/index.mjs +53 -53
- package/src/schema/configuration.validate.mjs +1 -0
- package/src/schema/cruise-result.validate.mjs +1 -0
- package/src/schema/utl.mjs +6 -0
- package/src/utl/array-util.mjs +25 -25
- package/src/utl/bus.mjs +12 -12
- package/src/utl/extract-root-module-name.cjs +8 -8
- package/src/utl/find-all-files.mjs +54 -54
- package/src/utl/get-extension.mjs +2 -2
- package/src/utl/object-util.mjs +21 -22
- package/src/utl/path-to-posix.mjs +5 -5
- package/src/utl/regex-util.mjs +20 -20
- package/src/utl/try-import.mjs +42 -41
- package/src/utl/try-require.cjs +23 -23
- package/src/utl/wrap-and-indent.mjs +33 -33
- package/src/validate/index.mjs +65 -65
- package/src/validate/match-dependency-rule.mjs +47 -47
- package/src/validate/match-folder-dependency-rule.mjs +27 -27
- package/src/validate/match-module-rule-helpers.mjs +76 -76
- package/src/validate/match-module-rule.mjs +12 -12
- package/src/validate/matchers.mjs +162 -162
- package/src/validate/rule-classifiers.mjs +9 -9
- package/src/validate/violates-required-rule.mjs +23 -23
- package/types/cache-options.d.mts +27 -27
- package/types/config-utl/extract-babel-config.d.mts +1 -1
- package/types/config-utl/extract-depcruise-config.d.mts +3 -3
- 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 +3 -3
- package/types/configuration.d.mts +10 -10
- package/types/cruise-result.d.mts +414 -414
- package/types/dependency-cruiser.d.mts +52 -52
- package/types/filter-types.d.mts +45 -45
- package/types/options.d.mts +430 -430
- package/types/plugins/3d-reporter-plugin.d.mts +9 -9
- package/types/plugins/mermaid-reporter-plugin.d.mts +10 -10
- package/types/plugins/stats-reporter-plugin.d.mts +9 -9
- package/types/reporter-options.d.mts +196 -196
- package/types/resolve-options.d.mts +23 -23
- package/types/restrictions.d.mts +174 -174
- package/types/rule-set.d.mts +132 -132
- package/types/rule-summary.d.mts +14 -14
- package/types/shared-types.d.mts +89 -89
- package/types/strict-filter-types.d.mts +52 -52
- package/types/strict-options.d.mts +34 -34
- package/types/strict-restrictions.d.mts +25 -25
- package/types/strict-rule-set.d.mts +36 -36
- package/types/violations.d.mts +40 -40
- package/src/schema/README.md +0 -5
- package/src/schema/baseline-violations.schema.mjs +0 -1
- package/src/schema/configuration.schema.mjs +0 -1
- package/src/schema/cruise-result.schema.mjs +0 -1
- package/types/README.md +0 -1
package/src/validate/index.mjs
CHANGED
|
@@ -8,61 +8,61 @@ import matchFolderRule from "./match-folder-dependency-rule.mjs";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
function compareSeverity(pFirst, pSecond) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const lSeverity2Int = {
|
|
12
|
+
error: 1,
|
|
13
|
+
warn: 2,
|
|
14
|
+
info: 3,
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
return lSeverity2Int[pFirst.severity] - lSeverity2Int[pSecond.severity];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function validateAgainstAllowedRules(pRuleSet, pMatchModule, pFrom, pTo) {
|
|
21
|
-
|
|
21
|
+
let lFoundRuleViolations = [];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (pRuleSet.allowed) {
|
|
24
|
+
const lInterestingAllowedRules = pRuleSet.allowed.filter(
|
|
25
|
+
pMatchModule.isInteresting,
|
|
26
|
+
);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
if (
|
|
29
|
+
lInterestingAllowedRules.length > 0 &&
|
|
30
|
+
!lInterestingAllowedRules.some(pMatchModule.match(pFrom, pTo))
|
|
31
|
+
) {
|
|
32
|
+
lFoundRuleViolations.push({
|
|
33
|
+
severity: pRuleSet.allowedSeverity,
|
|
34
|
+
name: "not-in-allowed",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return lFoundRuleViolations;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function validateAgainstForbiddenRules(pRuleSet, pMatchModule, pFrom, pTo) {
|
|
42
|
-
|
|
42
|
+
pRuleSet.forbidden = pRuleSet.forbidden || [];
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
return pRuleSet.forbidden
|
|
45
|
+
.filter(pMatchModule.isInteresting)
|
|
46
|
+
.filter(pMatchModule.match(pFrom, pTo))
|
|
47
|
+
.map((pMatchedRule) => ({
|
|
48
|
+
severity: pMatchedRule.severity,
|
|
49
|
+
name: pMatchedRule.name,
|
|
50
|
+
}));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function validateAgainstRequiredRules(pRuleSet, pModule, pMatchModule) {
|
|
54
|
-
|
|
54
|
+
let lFoundRequiredRuleViolations = [];
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
if (pRuleSet?.required) {
|
|
57
|
+
lFoundRequiredRuleViolations = pRuleSet.required
|
|
58
|
+
.filter(pMatchModule.isInteresting)
|
|
59
|
+
.filter((pRule) => violatesRequiredRule(pRule, pModule))
|
|
60
|
+
.map((pMatchedRule) => ({
|
|
61
|
+
severity: pMatchedRule.severity,
|
|
62
|
+
name: pMatchedRule.name,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
return lFoundRequiredRuleViolations;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -74,38 +74,38 @@ function validateAgainstRequiredRules(pRuleSet, pModule, pMatchModule) {
|
|
|
74
74
|
* @returns {IValidationResult}
|
|
75
75
|
*/
|
|
76
76
|
function validateAgainstRules(pRuleSet, pFrom, pTo, pMatchModule) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/** @type {IValidationResult} */
|
|
78
|
+
let lReturnValue = { valid: true };
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
const lFoundRuleViolations = validateAgainstAllowedRules(
|
|
81
|
+
pRuleSet,
|
|
82
|
+
pMatchModule,
|
|
83
|
+
pFrom,
|
|
84
|
+
pTo,
|
|
85
|
+
)
|
|
86
|
+
.concat(validateAgainstForbiddenRules(pRuleSet, pMatchModule, pFrom, pTo))
|
|
87
|
+
.concat(validateAgainstRequiredRules(pRuleSet, pFrom, pMatchModule))
|
|
88
|
+
.sort(compareSeverity);
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
lReturnValue.valid = lFoundRuleViolations.length === 0;
|
|
91
|
+
if (!lReturnValue.valid) {
|
|
92
|
+
lReturnValue.rules = lFoundRuleViolations;
|
|
93
|
+
}
|
|
94
|
+
return lReturnValue;
|
|
95
95
|
}
|
|
96
96
|
export function validateModule(pRuleSet, pModule) {
|
|
97
|
-
|
|
97
|
+
return validateAgainstRules(pRuleSet, pModule, {}, matchModuleRule);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
export function validateDependency(pRuleSet, pFrom, pTo) {
|
|
101
|
-
|
|
101
|
+
return validateAgainstRules(pRuleSet, pFrom, pTo, matchDependencyRule);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export function validateFolder(pRuleSet, pFromFolder, pToFolder) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
return validateAgainstRules(
|
|
106
|
+
pRuleSet,
|
|
107
|
+
pFromFolder,
|
|
108
|
+
pToFolder,
|
|
109
|
+
matchFolderRule,
|
|
110
|
+
);
|
|
111
111
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { isModuleOnlyRule, isFolderScope } from "./rule-classifiers.mjs";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
propertyEquals,
|
|
5
|
+
propertyMatches,
|
|
6
|
+
propertyMatchesNot,
|
|
7
|
+
matchesAncestor,
|
|
8
|
+
matchesFromPath,
|
|
9
|
+
matchesFromPathNot,
|
|
10
|
+
matchesToPath,
|
|
11
|
+
matchesToPathNot,
|
|
12
|
+
matchesToDependencyTypes,
|
|
13
|
+
matchesToDependencyTypesNot,
|
|
14
|
+
matchesToVia,
|
|
15
|
+
matchesToViaOnly,
|
|
16
|
+
matchesToIsMoreUnstable,
|
|
17
|
+
matchesMoreThanOneDependencyType,
|
|
18
18
|
} from "./matchers.mjs";
|
|
19
19
|
import { extractGroups } from "#utl/regex-util.mjs";
|
|
20
20
|
|
|
@@ -29,37 +29,37 @@ import { extractGroups } from "#utl/regex-util.mjs";
|
|
|
29
29
|
* @returns {(pRule) => boolean}
|
|
30
30
|
*/
|
|
31
31
|
function match(pFrom, pTo) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
// eslint-disable-next-line complexity
|
|
33
|
+
return (pRule) => {
|
|
34
|
+
const lGroups = extractGroups(pRule.from, pFrom.source);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
36
|
+
return (
|
|
37
|
+
matchesFromPath(pRule, pFrom) &&
|
|
38
|
+
matchesFromPathNot(pRule, pFrom) &&
|
|
39
|
+
matchesToPath(pRule, pTo, lGroups) &&
|
|
40
|
+
matchesToPathNot(pRule, pTo, lGroups) &&
|
|
41
|
+
matchesToDependencyTypes(pRule, pTo) &&
|
|
42
|
+
matchesToDependencyTypesNot(pRule, pTo) &&
|
|
43
|
+
matchesMoreThanOneDependencyType(pRule, pTo) &&
|
|
44
|
+
// preCompilationOnly is not a mandatory attribute, but if the attribute
|
|
45
|
+
// is in the rule but not in the dependency there won't be a match
|
|
46
|
+
// anyway, so we can use the default propertyEquals method regardless
|
|
47
|
+
propertyEquals(pRule, pTo, "preCompilationOnly") &&
|
|
48
|
+
// couldNotResolve, circular, dynamic and exoticallyRequired _are_ mandatory
|
|
49
|
+
propertyEquals(pRule, pTo, "couldNotResolve") &&
|
|
50
|
+
propertyEquals(pRule, pTo, "circular") &&
|
|
51
|
+
propertyEquals(pRule, pTo, "dynamic") &&
|
|
52
|
+
propertyEquals(pRule, pTo, "exoticallyRequired") &&
|
|
53
|
+
propertyMatches(pRule, pTo, "license", "license") &&
|
|
54
|
+
propertyMatchesNot(pRule, pTo, "licenseNot", "license") &&
|
|
55
|
+
propertyMatches(pRule, pTo, "exoticRequire", "exoticRequire") &&
|
|
56
|
+
propertyMatchesNot(pRule, pTo, "exoticRequireNot", "exoticRequire") &&
|
|
57
|
+
matchesToVia(pRule, pTo, lGroups) &&
|
|
58
|
+
matchesToViaOnly(pRule, pTo, lGroups) &&
|
|
59
|
+
matchesToIsMoreUnstable(pRule, pFrom, pTo) &&
|
|
60
|
+
matchesAncestor(pRule, pFrom, pTo)
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -67,9 +67,9 @@ function match(pFrom, pTo) {
|
|
|
67
67
|
* @returns boolean
|
|
68
68
|
*/
|
|
69
69
|
const isInteresting = (pRule) =>
|
|
70
|
-
|
|
70
|
+
!isModuleOnlyRule(pRule) && !isFolderScope(pRule);
|
|
71
71
|
|
|
72
72
|
export default {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
match,
|
|
74
|
+
isInteresting,
|
|
75
75
|
};
|
|
@@ -3,27 +3,27 @@ import { propertyEquals, matchesToIsMoreUnstable } from "./matchers.mjs";
|
|
|
3
3
|
import { extractGroups, replaceGroupPlaceholders } from "#utl/regex-util.mjs";
|
|
4
4
|
|
|
5
5
|
function fromFolderPath(pRule, pFromFolder) {
|
|
6
|
-
|
|
6
|
+
return Boolean(!pRule.from.path || pFromFolder.name.match(pRule.from.path));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
function fromFolderPathNot(pRule, pFromFolder) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
return Boolean(
|
|
11
|
+
!pRule.from.pathNot || !pFromFolder.name.match(pRule.from.pathNot),
|
|
12
|
+
);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function toFolderPath(pRule, pToFolder, pGroups) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
return Boolean(
|
|
17
|
+
!pRule.to.path ||
|
|
18
|
+
pToFolder.name.match(replaceGroupPlaceholders(pRule.to.path, pGroups)),
|
|
19
|
+
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function toFolderPathNot(pRule, pToFolder, pGroups) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
return Boolean(
|
|
24
|
+
!pRule.to.pathNot ||
|
|
25
|
+
!pToFolder.name.match(replaceGroupPlaceholders(pRule.to.pathNot, pGroups)),
|
|
26
|
+
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -33,19 +33,19 @@ function toFolderPathNot(pRule, pToFolder, pGroups) {
|
|
|
33
33
|
* @returns {(pRule) => boolean}
|
|
34
34
|
*/
|
|
35
35
|
function match(pFromFolder, pToFolder) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
return (pRule) => {
|
|
37
|
+
const lGroups = extractGroups(pRule.from, pFromFolder.name);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
// TODO: via's
|
|
40
|
+
return (
|
|
41
|
+
fromFolderPath(pRule, pFromFolder) &&
|
|
42
|
+
fromFolderPathNot(pRule, pFromFolder) &&
|
|
43
|
+
toFolderPath(pRule, pToFolder, lGroups) &&
|
|
44
|
+
toFolderPathNot(pRule, pToFolder, lGroups) &&
|
|
45
|
+
matchesToIsMoreUnstable(pRule, pFromFolder, pToFolder) &&
|
|
46
|
+
propertyEquals(pRule, pToFolder, "circular")
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
*
|
|
@@ -53,9 +53,9 @@ function match(pFromFolder, pToFolder) {
|
|
|
53
53
|
* @returns boolean
|
|
54
54
|
*/
|
|
55
55
|
const isInteresting = (pRule) =>
|
|
56
|
-
|
|
56
|
+
isFolderScope(pRule) && !isModuleOnlyRule(pRule);
|
|
57
57
|
|
|
58
58
|
export default {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
match,
|
|
60
|
+
isInteresting,
|
|
61
61
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
matchToModulePath,
|
|
3
|
+
matchToModulePathNot,
|
|
4
|
+
matchesFromPath,
|
|
5
|
+
matchesFromPathNot,
|
|
6
|
+
matchesModulePath,
|
|
7
|
+
matchesModulePathNot,
|
|
8
8
|
} from "./matchers.mjs";
|
|
9
9
|
import { extractGroups } from "#utl/regex-util.mjs";
|
|
10
10
|
|
|
@@ -22,13 +22,13 @@ import { extractGroups } from "#utl/regex-util.mjs";
|
|
|
22
22
|
* @returns {boolean}
|
|
23
23
|
*/
|
|
24
24
|
export function matchesOrphanRule(pRule, pModule) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
return (
|
|
26
|
+
Object.hasOwn(pRule?.from ?? {}, "orphan") &&
|
|
27
|
+
// @ts-expect-error the 'hasOwn' above guarantees there's a 'from.orphan' attribute
|
|
28
|
+
pModule.orphan === pRule.from.orphan &&
|
|
29
|
+
matchesFromPath(pRule, pModule) &&
|
|
30
|
+
matchesFromPathNot(pRule, pModule)
|
|
31
|
+
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -41,27 +41,27 @@ export function matchesOrphanRule(pRule, pModule) {
|
|
|
41
41
|
* @returns {boolean}
|
|
42
42
|
*/
|
|
43
43
|
export function matchesReachableRule(pRule, pModule) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
if (
|
|
45
|
+
Object.hasOwn(pRule?.to ?? {}, "reachable") &&
|
|
46
|
+
Object.hasOwn(pModule, "reachable")
|
|
47
|
+
) {
|
|
48
|
+
// @ts-expect-error the 'hasOwn' above ensures the 'reachable' exists
|
|
49
|
+
const lReachableRecord = pModule.reachable.find(
|
|
50
|
+
(pReachable) =>
|
|
51
|
+
pReachable.asDefinedInRule === pRule.name &&
|
|
52
|
+
// @ts-expect-error the 'hasOwn' above ensures the 'to.reachable' exists
|
|
53
|
+
pReachable.value === pRule.to.reachable,
|
|
54
|
+
);
|
|
55
|
+
if (lReachableRecord) {
|
|
56
|
+
const lGroups = extractGroups(pRule.from, lReachableRecord.matchedFrom);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
return (
|
|
59
|
+
matchToModulePath(pRule, pModule, lGroups) &&
|
|
60
|
+
matchToModulePathNot(pRule, pModule, lGroups)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
@@ -74,20 +74,20 @@ export function matchesReachableRule(pRule, pModule) {
|
|
|
74
74
|
* @returns {boolean}
|
|
75
75
|
*/
|
|
76
76
|
export function matchesReachesRule(pRule, pModule) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
return (
|
|
78
|
+
Object.hasOwn(pRule?.to ?? {}, "reachable") &&
|
|
79
|
+
Object.hasOwn(pModule, "reaches") &&
|
|
80
|
+
// @ts-expect-error the 'hasOwn' above guarantees the .reaches exists
|
|
81
|
+
pModule.reaches.some(
|
|
82
|
+
(pReaches) =>
|
|
83
|
+
pReaches.asDefinedInRule === pRule.name &&
|
|
84
|
+
pReaches.modules.some(
|
|
85
|
+
(pReachesModule) =>
|
|
86
|
+
matchToModulePath(pRule, pReachesModule) &&
|
|
87
|
+
matchToModulePathNot(pRule, pReachesModule),
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
*
|
|
@@ -96,17 +96,17 @@ export function matchesReachesRule(pRule, pModule) {
|
|
|
96
96
|
* @returns {boolean}
|
|
97
97
|
*/
|
|
98
98
|
function dependentsCountsMatch(pRule, pDependents) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
99
|
+
const lMatchingDependentsCount = pDependents.filter(
|
|
100
|
+
(pDependent) =>
|
|
101
|
+
Boolean(!pRule.from.path || pDependent.match(pRule.from.path)) &&
|
|
102
|
+
Boolean(!pRule.from.pathNot || !pDependent.match(pRule.from.pathNot)),
|
|
103
|
+
).length;
|
|
104
|
+
return (
|
|
105
|
+
(!pRule.module.numberOfDependentsLessThan ||
|
|
106
|
+
lMatchingDependentsCount < pRule.module.numberOfDependentsLessThan) &&
|
|
107
|
+
(!pRule.module.numberOfDependentsMoreThan ||
|
|
108
|
+
lMatchingDependentsCount > pRule.module.numberOfDependentsMoreThan)
|
|
109
|
+
);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
@@ -117,22 +117,22 @@ function dependentsCountsMatch(pRule, pDependents) {
|
|
|
117
117
|
*/
|
|
118
118
|
|
|
119
119
|
export function matchesDependentsRule(pRule, pModule) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
if (
|
|
121
|
+
(Object.hasOwn(pModule, "dependents") &&
|
|
122
|
+
Object.hasOwn(pRule?.module ?? {}, "numberOfDependentsLessThan")) ||
|
|
123
|
+
Object.hasOwn(pRule?.module ?? {}, "numberOfDependentsMoreThan")
|
|
124
|
+
) {
|
|
125
|
+
return (
|
|
126
|
+
// group matching seems like a nice idea, however, the 'from' part of the
|
|
127
|
+
// rule is going to match not one module (as with regular dependency rules)
|
|
128
|
+
// but a whole bunch of them, being the 'dependents'. So that match is going
|
|
129
|
+
// to produce not one result, but one per matching dependent. To get meaningful
|
|
130
|
+
// results we'd probably have to loop over these and or the
|
|
131
|
+
// matchToModulePath together.
|
|
132
|
+
matchesModulePath(pRule, pModule) &&
|
|
133
|
+
matchesModulePathNot(pRule, pModule) &&
|
|
134
|
+
dependentsCountsMatch(pRule, pModule.dependents)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
138
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isModuleOnlyRule, isFolderScope } from "./rule-classifiers.mjs";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
matchesOrphanRule,
|
|
4
|
+
matchesReachableRule,
|
|
5
|
+
matchesReachesRule,
|
|
6
|
+
matchesDependentsRule,
|
|
7
7
|
} from "./match-module-rule-helpers.mjs";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
* @returns {(pRule:IAnyRuleType) => boolean}
|
|
17
17
|
*/
|
|
18
18
|
function match(pModule) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
return (pRule) =>
|
|
20
|
+
matchesOrphanRule(pRule, pModule) ||
|
|
21
|
+
matchesReachableRule(pRule, pModule) ||
|
|
22
|
+
matchesReachesRule(pRule, pModule) ||
|
|
23
|
+
matchesDependentsRule(pRule, pModule);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -28,9 +28,9 @@ function match(pModule) {
|
|
|
28
28
|
* @returns boolean
|
|
29
29
|
*/
|
|
30
30
|
const isInteresting = (pRule) =>
|
|
31
|
-
|
|
31
|
+
isModuleOnlyRule(pRule) && !isFolderScope(pRule);
|
|
32
32
|
|
|
33
33
|
export default {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
match,
|
|
35
|
+
isInteresting,
|
|
36
36
|
};
|