dependency-cruiser 12.11.1 → 13.0.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/README.md +4 -4
- package/bin/{depcruise-baseline.js → depcruise-baseline.mjs} +6 -11
- package/bin/{depcruise-fmt.js → depcruise-fmt.mjs} +10 -17
- package/bin/{dependency-cruise.js → dependency-cruise.mjs} +9 -13
- package/bin/wrap-stream-in-html.mjs +5 -0
- package/configs/plugins/3d-reporter-plugin.js +1 -1
- package/package.json +65 -95
- package/src/cache/{cache.js → cache.mjs} +16 -18
- package/src/cache/{content-strategy.js → content-strategy.mjs} +19 -19
- package/src/cache/{find-content-changes.js → find-content-changes.mjs} +10 -8
- package/src/cache/{utl.js → helpers.mjs} +18 -28
- package/src/cache/{metadata-strategy.js → metadata-strategy.mjs} +14 -16
- package/src/cache/{options-compatible.js → options-compatible.mjs} +8 -18
- package/src/cli/defaults.mjs +17 -0
- package/src/cli/{format-meta-info.js → format-meta-info.mjs} +14 -15
- package/src/cli/format.mjs +26 -0
- package/src/cli/{index.js → index.mjs} +42 -47
- package/src/cli/init-config/{build-config.js → build-config.mjs} +6 -6
- package/src/cli/init-config/{environment-helpers.js → environment-helpers.mjs} +28 -47
- package/src/cli/init-config/{find-extensions.js → find-extensions.mjs} +6 -6
- package/src/cli/init-config/{get-user-input.js → get-user-input.mjs} +6 -6
- package/src/cli/init-config/{index.js → index.mjs} +11 -13
- package/src/cli/init-config/{normalize-init-options.js → normalize-init-options.mjs} +14 -14
- package/src/cli/init-config/utl.mjs +3 -0
- package/src/cli/init-config/{validators.js → validators.mjs} +4 -8
- package/src/cli/init-config/{write-config.js → write-config.mjs} +8 -8
- package/src/cli/init-config/{write-run-scripts-to-manifest.js → write-run-scripts-to-manifest.mjs} +28 -32
- package/src/cli/listeners/{cli-feedback.js → cli-feedback.mjs} +9 -7
- package/src/cli/listeners/{ndjson.js → ndjson.mjs} +4 -4
- package/src/cli/listeners/performance-log/{format-helpers.js → format-helpers.mjs} +6 -14
- package/src/cli/listeners/performance-log/{handlers.js → handlers.mjs} +5 -11
- package/src/cli/listeners/performance-log/{index.js → index.mjs} +4 -4
- package/src/cli/{normalize-cli-options.js → normalize-cli-options.mjs} +39 -39
- package/src/cli/tools/{wrap-stream-in-html.js → wrap-stream-in-html.mjs} +13 -19
- package/src/cli/utl/{io.js → io.mjs} +7 -11
- package/src/cli/utl/validate-file-existence.mjs +11 -0
- package/src/cli/{validate-node-environment.js → validate-node-environment.mjs} +6 -6
- package/src/config-utl/{extract-babel-config.js → extract-babel-config.mjs} +31 -30
- package/src/config-utl/extract-depcruise-config/{index.js → index.mjs} +23 -26
- package/src/config-utl/extract-depcruise-config/{merge-configs.js → merge-configs.mjs} +22 -24
- package/src/config-utl/extract-depcruise-config/read-config.mjs +13 -0
- package/src/config-utl/{extract-known-violations.js → extract-known-violations.mjs} +5 -5
- package/src/config-utl/{extract-ts-config.js → extract-ts-config.mjs} +10 -7
- package/src/config-utl/{extract-webpack-resolve-config.js → extract-webpack-resolve-config.mjs} +51 -37
- package/src/config-utl/make-absolute.mjs +10 -0
- package/src/enrich/{add-validations.js → add-validations.mjs} +7 -6
- package/src/enrich/derive/{circular.js → circular.mjs} +2 -2
- package/src/enrich/derive/dependents/{get-dependents.js → get-dependents.mjs} +3 -3
- package/src/enrich/derive/dependents/index.mjs +8 -0
- package/src/enrich/derive/folders/{aggregate-to-folders.js → aggregate-to-folders.mjs} +11 -11
- package/src/enrich/derive/folders/index.mjs +42 -0
- package/src/enrich/derive/folders/{utl.js → utl.mjs} +8 -16
- package/src/enrich/derive/metrics/{get-module-metrics.js → get-module-metrics.mjs} +9 -9
- package/src/enrich/derive/metrics/{index.js → index.mjs} +4 -4
- package/src/enrich/derive/{module-utl.js → module-utl.mjs} +6 -9
- package/src/enrich/derive/orphan/{index.js → index.mjs} +3 -3
- package/src/enrich/derive/orphan/{is-orphan.js → is-orphan.mjs} +3 -3
- package/src/enrich/derive/{reachable.js → reachable.mjs} +7 -8
- package/src/enrich/{enrich-modules.js → enrich-modules.mjs} +13 -13
- package/src/enrich/{index.js → index.mjs} +8 -8
- package/src/enrich/{soften-known-violations.js → soften-known-violations.mjs} +13 -13
- package/src/enrich/summarize/{add-rule-set-used.js → add-rule-set-used.mjs} +3 -3
- package/src/enrich/summarize/{get-stats.js → get-stats.mjs} +3 -9
- package/src/enrich/summarize/{index.js → index.mjs} +13 -13
- package/src/enrich/summarize/{is-same-violation.js → is-same-violation.mjs} +2 -2
- package/src/enrich/summarize/{summarize-folders.js → summarize-folders.mjs} +4 -4
- package/src/enrich/summarize/{summarize-modules.js → summarize-modules.mjs} +9 -9
- package/src/enrich/summarize/{summarize-options.js → summarize-options.mjs} +3 -3
- package/src/extract/ast-extractors/{estree-helpers.js → estree-helpers.mjs} +1 -1
- package/src/extract/ast-extractors/{extract-amd-deps.js → extract-amd-deps.mjs} +7 -7
- package/src/extract/ast-extractors/{extract-cjs-deps.js → extract-cjs-deps.mjs} +6 -6
- package/src/extract/ast-extractors/{extract-es6-deps.js → extract-es6-deps.mjs} +8 -8
- package/src/extract/ast-extractors/{extract-swc-deps.js → extract-swc-deps.mjs} +3 -7
- package/src/extract/ast-extractors/{extract-typescript-deps.js → extract-typescript-deps.mjs} +11 -8
- package/src/extract/ast-extractors/swc-dependency-visitor.mjs +253 -0
- package/src/extract/clear-caches.mjs +17 -0
- package/src/extract/{gather-initial-sources.js → gather-initial-sources.mjs} +25 -31
- package/src/extract/get-dependencies.mjs +247 -0
- package/src/extract/helpers.mjs +76 -0
- package/src/extract/{index.js → index.mjs} +20 -24
- package/src/extract/parse/{to-javascript-ast.js → to-javascript-ast.mjs} +25 -26
- package/src/extract/parse/{to-swc-ast.js → to-swc-ast.mjs} +9 -8
- package/src/extract/parse/{to-typescript-ast.js → to-typescript-ast.mjs} +16 -12
- package/src/extract/resolve/{determine-dependency-types.js → determine-dependency-types.mjs} +24 -25
- package/src/extract/resolve/{external-module-helpers.js → external-module-helpers.mjs} +18 -21
- package/src/extract/resolve/{get-manifest/index.js → get-manifest.mjs} +19 -18
- package/src/extract/resolve/{index.js → index.mjs} +29 -30
- package/src/extract/resolve/{get-manifest/merge-manifests.js → merge-manifests.mjs} +4 -4
- package/src/extract/resolve/{module-classifiers.js → module-classifiers.mjs} +12 -19
- package/src/extract/resolve/{resolve-amd.js → resolve-amd.mjs} +11 -14
- package/src/extract/resolve/{resolve-cjs.js → resolve-cjs.mjs} +8 -8
- package/src/extract/resolve/resolve-helpers.mjs +30 -0
- package/src/extract/resolve/{resolve.js → resolve.mjs} +6 -7
- package/src/extract/transpile/{babel-wrap.js → babel-wrap.mjs} +4 -4
- package/src/extract/transpile/{coffeescript-wrap.js → coffeescript-wrap.mjs} +10 -10
- package/src/extract/transpile/{index.js → index.mjs} +5 -5
- package/src/extract/transpile/{javascript-wrap.js → javascript-wrap.mjs} +1 -1
- package/src/extract/transpile/livescript-wrap.mjs +15 -0
- package/src/extract/transpile/{meta.js → meta.mjs} +35 -31
- package/src/extract/transpile/{svelte-preprocess.js → svelte-preprocess.mjs} +2 -2
- package/src/extract/transpile/svelte-wrap.mjs +26 -0
- package/src/extract/transpile/{typescript-wrap.js → typescript-wrap.mjs} +8 -5
- package/src/extract/transpile/{vue-template-wrap.js → vue-template-wrap.cjs} +15 -18
- package/src/graph-utl/{add-focus.js → add-focus.mjs} +8 -7
- package/src/graph-utl/{compare.js → compare.mjs} +5 -5
- package/src/graph-utl/{consolidate-module-dependencies.js → consolidate-module-dependencies.mjs} +6 -6
- package/src/graph-utl/{consolidate-modules.js → consolidate-modules.mjs} +6 -6
- package/src/graph-utl/{consolidate-to-folder.js → consolidate-to-folder.mjs} +7 -7
- package/src/graph-utl/{consolidate-to-pattern.js → consolidate-to-pattern.mjs} +4 -4
- package/src/graph-utl/{filter-bank.js → filter-bank.mjs} +17 -25
- package/src/graph-utl/{indexed-module-graph.js → indexed-module-graph.mjs} +2 -2
- package/src/graph-utl/match-facade.mjs +11 -0
- package/src/graph-utl/{rule-set.js → rule-set.mjs} +7 -13
- package/src/graph-utl/{strip-self-transitions.js → strip-self-transitions.mjs} +2 -2
- package/src/main/files-and-dirs/{normalize.js → normalize.mjs} +6 -9
- package/src/main/{utl/normalize-re-properties.js → helpers.mjs} +6 -11
- package/src/main/{index.js → index.mjs} +44 -44
- package/src/main/options/{defaults.js → defaults.mjs} +1 -1
- package/src/main/options/{normalize.js → normalize.mjs} +21 -30
- package/src/main/options/{validate.js → validate.mjs} +8 -14
- package/src/main/{report-wrap.js → report-wrap.mjs} +20 -22
- package/src/main/resolve-options/{normalize.js → normalize.mjs} +33 -35
- package/src/main/rule-set/{normalize.js → normalize.mjs} +11 -11
- package/src/main/rule-set/{validate.js → validate.mjs} +10 -10
- package/src/meta.js +2 -2
- package/src/report/anon/{anonymize-path-element.js → anonymize-path-element.mjs} +5 -7
- package/src/report/anon/{anonymize-path.js → anonymize-path.mjs} +4 -6
- package/src/report/anon/{index.js → index.mjs} +16 -20
- package/src/report/anon/{random-string.js → random-string.mjs} +4 -3
- package/src/report/{baseline.js → baseline.mjs} +4 -4
- package/src/report/{csv.js → csv.mjs} +12 -11
- package/src/report/dot/{default-theme.js → default-theme.mjs} +1 -1
- package/src/report/dot/{index.js → index.mjs} +14 -14
- package/src/report/dot/{module-utl.js → module-utl.mjs} +22 -22
- package/src/report/dot/prepare-custom-level.mjs +23 -0
- package/src/report/dot/prepare-flat-level.mjs +11 -0
- package/src/report/dot/prepare-folder-level.mjs +14 -0
- package/src/report/dot/{theming.js → theming.mjs} +5 -5
- package/src/report/error-html/{index.js → index.mjs} +7 -8
- package/src/report/error-html/{utl.js → utl.mjs} +8 -7
- package/src/report/error-long.mjs +5 -0
- package/src/report/{error.js → error.mjs} +31 -27
- package/src/report/html/{index.js → index.mjs} +7 -8
- package/src/report/{identity.js → identity.mjs} +3 -3
- package/src/report/index.mjs +75 -0
- package/src/report/{json.js → json.mjs} +3 -3
- package/src/report/{markdown.js → markdown.mjs} +18 -18
- package/src/report/{mermaid.js → mermaid.mjs} +7 -7
- package/src/report/{metrics.js → metrics.mjs} +11 -11
- package/src/report/{plugins.js → plugins.mjs} +12 -17
- package/src/report/{teamcity.js → teamcity.mjs} +17 -18
- package/src/report/{text.js → text.mjs} +8 -7
- package/src/report/utl/{dependency-to-incidence-transformer.js → dependency-to-incidence-transformer.mjs} +2 -2
- package/src/report/utl/{index.js → index.mjs} +4 -5
- package/src/schema/baseline-violations.schema.mjs +1 -0
- package/src/schema/configuration.schema.mjs +1 -0
- package/src/schema/cruise-result.schema.mjs +1 -0
- package/src/utl/{array-util.js → array-util.mjs} +1 -5
- package/src/utl/{bus-log-levels.js → bus-log-levels.mjs} +1 -1
- package/src/utl/bus.mjs +5 -0
- package/src/utl/{find-all-files.js → find-all-files.mjs} +6 -6
- package/src/utl/{get-extension.js → get-extension.mjs} +4 -4
- package/src/utl/{path-to-posix.js → path-to-posix.mjs} +3 -3
- package/src/utl/{regex-util.js → regex-util.mjs} +3 -3
- package/src/utl/{wrap-and-indent.js → wrap-and-indent.mjs} +5 -4
- package/src/validate/{index.js → index.mjs} +22 -14
- package/src/validate/{match-dependency-rule.js → match-dependency-rule.mjs} +6 -6
- package/src/validate/{match-folder-dependency-rule.js → match-folder-dependency-rule.mjs} +6 -9
- package/src/validate/{match-module-rule.js → match-module-rule.mjs} +22 -25
- package/src/validate/{matchers.js → matchers.mjs} +4 -4
- package/src/validate/{rule-classifiers.js → rule-classifiers.mjs} +5 -5
- package/src/validate/{violates-required-rule.js → violates-required-rule.mjs} +6 -6
- package/types/README.md +1 -0
- package/types/dependency-cruiser.d.ts +3 -29
- package/bin/wrap-stream-in-html.js +0 -5
- package/src/cli/defaults.js +0 -17
- package/src/cli/format.js +0 -26
- package/src/cli/init-config/utl.js +0 -6
- package/src/cli/utl/validate-file-existence.js +0 -11
- package/src/config-utl/extract-depcruise-config/read-config.js +0 -12
- package/src/config-utl/make-absolute.js +0 -10
- package/src/enrich/derive/dependents/index.js +0 -10
- package/src/enrich/derive/folders/index.js +0 -45
- package/src/extract/ast-extractors/swc-dependency-visitor.js +0 -249
- package/src/extract/clear-caches.js +0 -17
- package/src/extract/get-dependencies.js +0 -243
- package/src/extract/resolve/resolve-helpers.js +0 -35
- package/src/extract/transpile/livescript-wrap.js +0 -12
- package/src/extract/transpile/svelte-wrap.js +0 -26
- package/src/extract/utl/compare.js +0 -17
- package/src/extract/utl/detect-pre-compilation-ness.js +0 -12
- package/src/extract/utl/extract-module-attributes.js +0 -38
- package/src/extract/utl/strip-query-parameters.js +0 -15
- package/src/graph-utl/match-facade.js +0 -17
- package/src/report/dot/prepare-custom-level.js +0 -24
- package/src/report/dot/prepare-flat-level.js +0 -12
- package/src/report/dot/prepare-folder-level.js +0 -19
- package/src/report/error-long.js +0 -5
- package/src/report/index.js +0 -73
- package/src/schema/baseline-violations.schema.js +0 -2
- package/src/schema/configuration.schema.js +0 -2
- package/src/schema/cruise-result.schema.js +0 -2
- package/src/utl/bus.js +0 -5
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { join } from "node:path/posix";
|
|
2
|
+
import bus from "../utl/bus.mjs";
|
|
3
|
+
import busLogLevels from "../utl/bus-log-levels.mjs";
|
|
4
|
+
import findAllFiles from "../utl/find-all-files.mjs";
|
|
5
|
+
import {
|
|
6
6
|
getFileHash,
|
|
7
7
|
excludeFilter,
|
|
8
8
|
includeOnlyFilter,
|
|
9
9
|
hasInterestingExtension,
|
|
10
10
|
moduleIsInterestingForDiff,
|
|
11
|
-
}
|
|
11
|
+
} from "./helpers.mjs";
|
|
12
|
+
|
|
13
|
+
const { DEBUG } = busLogLevels;
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @param {Set<string>} pFileSet
|
|
@@ -68,7 +70,7 @@ function diffCachedModuleAgainstFileSet(
|
|
|
68
70
|
* @param {string} pOptions.baseDir
|
|
69
71
|
* @returns {{source: string; changeType: import("watskeburt").changeTypeType; checksum: string}[]}
|
|
70
72
|
*/
|
|
71
|
-
|
|
73
|
+
export default function findContentChanges(
|
|
72
74
|
pDirectory,
|
|
73
75
|
pCachedCruiseResult,
|
|
74
76
|
pOptions
|
|
@@ -101,4 +103,4 @@ module.exports = function findContentChanges(
|
|
|
101
103
|
|
|
102
104
|
bus.emit("progress", "cache: - returning revision data", { level: DEBUG });
|
|
103
105
|
return lDiffCachedVsNew.concat(lDiffNewVsCached);
|
|
104
|
-
}
|
|
106
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/* eslint-disable import/exports-last */
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { extname } from "node:path";
|
|
5
|
+
import memoize from "lodash/memoize.js";
|
|
6
|
+
import { filenameMatchesPattern } from "../graph-utl/match-facade.mjs";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @param {string} pString
|
|
@@ -24,13 +25,13 @@ function _getFileHash(pFileName) {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const getFileHash = memoize(_getFileHash);
|
|
28
|
+
export const getFileHash = memoize(_getFileHash);
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* @param {import("watskeburt").IChange} pChange
|
|
31
|
-
* @param {import("
|
|
32
|
+
* @param {import("../../types/dependency-cruiser.js").IRevisionChange}
|
|
32
33
|
*/
|
|
33
|
-
function addCheckSumToChange(pChange) {
|
|
34
|
+
export function addCheckSumToChange(pChange) {
|
|
34
35
|
return {
|
|
35
36
|
...pChange,
|
|
36
37
|
checksum: getFileHash(pChange.name),
|
|
@@ -39,10 +40,10 @@ function addCheckSumToChange(pChange) {
|
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
*
|
|
42
|
-
* @param {import("../../types/strict-filter-types").IStrictExcludeType} pExcludeOption
|
|
43
|
+
* @param {import("../../types/strict-filter-types.js").IStrictExcludeType} pExcludeOption
|
|
43
44
|
* @returns {(pFileName: string) => boolean}
|
|
44
45
|
*/
|
|
45
|
-
function excludeFilter(pExcludeOption) {
|
|
46
|
+
export function excludeFilter(pExcludeOption) {
|
|
46
47
|
return (pFileName) => {
|
|
47
48
|
if (pExcludeOption.path) {
|
|
48
49
|
return !filenameMatchesPattern(pFileName, pExcludeOption.path);
|
|
@@ -52,10 +53,10 @@ function excludeFilter(pExcludeOption) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
* @param {import("../../types/strict-filter-types").IStrictIncludeOnlyType} pIncludeOnlyFilter
|
|
56
|
+
* @param {import("../../types/strict-filter-types.js").IStrictIncludeOnlyType} pIncludeOnlyFilter
|
|
56
57
|
* @returns {(pFileName: string) => boolean}
|
|
57
58
|
*/
|
|
58
|
-
function includeOnlyFilter(pIncludeOnlyFilter) {
|
|
59
|
+
export function includeOnlyFilter(pIncludeOnlyFilter) {
|
|
59
60
|
return (pFileName) => {
|
|
60
61
|
if (pIncludeOnlyFilter) {
|
|
61
62
|
return filenameMatchesPattern(pFileName, pIncludeOnlyFilter.path);
|
|
@@ -67,15 +68,15 @@ function includeOnlyFilter(pIncludeOnlyFilter) {
|
|
|
67
68
|
* @param {Set<string>} pExtensions
|
|
68
69
|
* @returns {(pFileName: string) => boolean}
|
|
69
70
|
*/
|
|
70
|
-
function hasInterestingExtension(pExtensions) {
|
|
71
|
-
return (pFileName) => pExtensions.has(
|
|
71
|
+
export function hasInterestingExtension(pExtensions) {
|
|
72
|
+
return (pFileName) => pExtensions.has(extname(pFileName));
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* @param {Set<string>} pExtensions
|
|
76
77
|
* @returns {(pChange: import("watskeburt").IChange) => boolean}
|
|
77
78
|
*/
|
|
78
|
-
function changeHasInterestingExtension(pExtensions) {
|
|
79
|
+
export function changeHasInterestingExtension(pExtensions) {
|
|
79
80
|
return (pChange) =>
|
|
80
81
|
hasInterestingExtension(pExtensions)(pChange.name) ||
|
|
81
82
|
(pChange.oldName && hasInterestingExtension(pExtensions)(pChange.oldName));
|
|
@@ -96,7 +97,7 @@ const DEFAULT_INTERESTING_CHANGE_TYPES = new Set([
|
|
|
96
97
|
* @param {Set<import("watskeburt").changeTypeType>} pInterestingChangeTypes
|
|
97
98
|
* @returns {(pChange: import("watskeburt").IChange) => boolean}
|
|
98
99
|
*/
|
|
99
|
-
function isInterestingChangeType(pInterestingChangeTypes) {
|
|
100
|
+
export function isInterestingChangeType(pInterestingChangeTypes) {
|
|
100
101
|
return (pChange) =>
|
|
101
102
|
(pInterestingChangeTypes ?? DEFAULT_INTERESTING_CHANGE_TYPES).has(
|
|
102
103
|
pChange.changeType
|
|
@@ -106,7 +107,7 @@ function isInterestingChangeType(pInterestingChangeTypes) {
|
|
|
106
107
|
/**
|
|
107
108
|
* @param {pModule:import("../..").IModule} pModule
|
|
108
109
|
*/
|
|
109
|
-
function moduleIsInterestingForDiff(pModule) {
|
|
110
|
+
export function moduleIsInterestingForDiff(pModule) {
|
|
110
111
|
return (
|
|
111
112
|
!pModule.consolidated &&
|
|
112
113
|
!pModule.coreModule &&
|
|
@@ -117,14 +118,3 @@ function moduleIsInterestingForDiff(pModule) {
|
|
|
117
118
|
pModule.followable !== false
|
|
118
119
|
);
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
-
module.exports = {
|
|
122
|
-
getFileHash,
|
|
123
|
-
excludeFilter,
|
|
124
|
-
includeOnlyFilter,
|
|
125
|
-
hasInterestingExtension,
|
|
126
|
-
changeHasInterestingExtension,
|
|
127
|
-
isInterestingChangeType,
|
|
128
|
-
addCheckSumToChange,
|
|
129
|
-
moduleIsInterestingForDiff,
|
|
130
|
-
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import { getSHASync, listSync } from "watskeburt";
|
|
3
|
+
import {
|
|
4
4
|
isInterestingChangeType,
|
|
5
5
|
addCheckSumToChange,
|
|
6
6
|
excludeFilter,
|
|
7
7
|
includeOnlyFilter,
|
|
8
8
|
changeHasInterestingExtension,
|
|
9
|
-
}
|
|
9
|
+
} from "./helpers.mjs";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export default class MetaDataStrategy {
|
|
12
12
|
/**
|
|
13
13
|
* @param {Set<string>} pExtensions
|
|
14
14
|
* @param {Set<import("watskeburt").changeTypeType>} pInterestingChangeTypes
|
|
15
|
-
* @param {import("../../types/strict-options").IStrictCruiseOptions} pCruiseOptions
|
|
15
|
+
* @param {import("../../types/strict-options.js").IStrictCruiseOptions} pCruiseOptions
|
|
16
16
|
* @param {Object} pOptions
|
|
17
17
|
* @param {Set<string>} pOptions.extensions
|
|
18
18
|
* @param {Set<import("watskeburt").changeTypeType>} pOptions.interestingChangeTypes
|
|
19
19
|
* @param {() => string} pOptions.shaRetrievalFn
|
|
20
20
|
* @param {(pString:string) => Array<import("watskeburt").IChange>} pOptions.diffListFn
|
|
21
21
|
* @param {(import("watskeburt").IChange) => import("../..").IRevisionChange} pOptions.checksumFn
|
|
22
|
-
* @returns {import("
|
|
22
|
+
* @returns {import("../../types/dependency-cruiser.js").IRevisionData}
|
|
23
23
|
*/
|
|
24
24
|
getRevisionData(pDirectory, pCachedCruiseResult, pCruiseOptions, pOptions) {
|
|
25
25
|
const lOptions = {
|
|
@@ -44,16 +44,14 @@ module.exports = class MetaDataStrategy {
|
|
|
44
44
|
};
|
|
45
45
|
} catch (pError) {
|
|
46
46
|
throw new Error(
|
|
47
|
-
|
|
48
|
-
"current folder isn't version managed or git isn't installed. Error:" +
|
|
49
|
-
`\n\n ${pError}\n`
|
|
47
|
+
`The --cache option works in concert with git - and it seems either the current folder isn't version managed or git isn't installed. Error:${`\n\n ${pError}\n`}`
|
|
50
48
|
);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
/**
|
|
55
|
-
* @param {import("
|
|
56
|
-
* @param {import("
|
|
53
|
+
* @param {import("../../types/dependency-cruiser.js").IRevisionData} pExistingRevisionData
|
|
54
|
+
* @param {import("../../types/dependency-cruiser.js").IRevisionData} pNewRevisionData
|
|
57
55
|
* @returns {boolean}
|
|
58
56
|
*/
|
|
59
57
|
revisionDataEqual(pExistingRevisionData, pNewRevisionData) {
|
|
@@ -66,9 +64,9 @@ module.exports = class MetaDataStrategy {
|
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
/**
|
|
69
|
-
* @param {import("
|
|
70
|
-
* @param {import("
|
|
71
|
-
* @returns {import("
|
|
67
|
+
* @param {import("../../types/dependency-cruiser.js").ICruiseResult} pCruiseResult
|
|
68
|
+
* @param {import("../../types/dependency-cruiser.js").IRevisionData} pRevisionData
|
|
69
|
+
* @returns {import("../../types/dependency-cruiser.js").ICruiseResult}
|
|
72
70
|
*/
|
|
73
71
|
prepareRevisionDataForSaving(pCruiseResult, pRevisionData) {
|
|
74
72
|
return pRevisionData
|
|
@@ -78,4 +76,4 @@ module.exports = class MetaDataStrategy {
|
|
|
78
76
|
}
|
|
79
77
|
: pCruiseResult;
|
|
80
78
|
}
|
|
81
|
-
}
|
|
79
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
# command line options
|
|
@@ -53,29 +53,29 @@ const { isDeepStrictEqual } = require("util");
|
|
|
53
53
|
- knownViolations
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
|
-
function includeOnlyIsCompatible(pExistingFilter, pNewFilter) {
|
|
56
|
+
export function includeOnlyIsCompatible(pExistingFilter, pNewFilter) {
|
|
57
57
|
return (
|
|
58
58
|
!pExistingFilter || isDeepStrictEqual({ path: pExistingFilter }, pNewFilter)
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function filterOptionIsCompatible(pExistingOption, pNewOption) {
|
|
62
|
+
export function filterOptionIsCompatible(pExistingOption, pNewOption) {
|
|
63
63
|
return !pExistingOption || isDeepStrictEqual(pExistingOption, pNewOption);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function optionIsCompatible(pExistingOption, pNewOption) {
|
|
66
|
+
export function optionIsCompatible(pExistingOption, pNewOption) {
|
|
67
67
|
return isDeepStrictEqual(pExistingOption, pNewOption);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function limitIsCompatible(pExistingLimit, pNewLimit) {
|
|
70
|
+
export function limitIsCompatible(pExistingLimit, pNewLimit) {
|
|
71
71
|
return !pExistingLimit || pExistingLimit >= (pNewLimit || pExistingLimit + 1);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function metricsIsCompatible(pExistingMetrics, pNewMetrics) {
|
|
74
|
+
export function metricsIsCompatible(pExistingMetrics, pNewMetrics) {
|
|
75
75
|
return pExistingMetrics || pExistingMetrics === pNewMetrics;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function cacheOptionIsCompatible(pExistingCacheOption, pNewCacheOption) {
|
|
78
|
+
export function cacheOptionIsCompatible(pExistingCacheOption, pNewCacheOption) {
|
|
79
79
|
if (!pExistingCacheOption || !pNewCacheOption) {
|
|
80
80
|
return false;
|
|
81
81
|
}
|
|
@@ -92,7 +92,7 @@ function cacheOptionIsCompatible(pExistingCacheOption, pNewCacheOption) {
|
|
|
92
92
|
* @returns {boolean}
|
|
93
93
|
*/
|
|
94
94
|
// eslint-disable-next-line complexity
|
|
95
|
-
function optionsAreCompatible(pOldOptions, pNewOptions) {
|
|
95
|
+
export function optionsAreCompatible(pOldOptions, pNewOptions) {
|
|
96
96
|
return (
|
|
97
97
|
pOldOptions.args === pNewOptions.args &&
|
|
98
98
|
pOldOptions.rulesFile === pNewOptions.rulesFile &&
|
|
@@ -131,13 +131,3 @@ function optionsAreCompatible(pOldOptions, pNewOptions) {
|
|
|
131
131
|
cacheOptionIsCompatible(pOldOptions.cache, pNewOptions.cache)
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
|
|
135
|
-
module.exports = {
|
|
136
|
-
optionsAreCompatible,
|
|
137
|
-
filterOptionIsCompatible,
|
|
138
|
-
optionIsCompatible,
|
|
139
|
-
limitIsCompatible,
|
|
140
|
-
metricsIsCompatible,
|
|
141
|
-
includeOnlyIsCompatible,
|
|
142
|
-
cacheOptionIsCompatible,
|
|
143
|
-
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const OLD_DEFAULT_RULES_FILE_NAME = ".dependency-cruiser.json";
|
|
2
|
+
export const RULES_FILE_NAME_SEARCH_ARRAY = [
|
|
3
|
+
".dependency-cruiser.json",
|
|
4
|
+
".dependency-cruiser.js",
|
|
5
|
+
".dependency-cruiser.cjs",
|
|
6
|
+
".dependency-cruiser.mjs",
|
|
7
|
+
];
|
|
8
|
+
export const DEFAULT_BASELINE_FILE_NAME =
|
|
9
|
+
".dependency-cruiser-known-violations.json";
|
|
10
|
+
export const DEFAULT_CONFIG_FILE_NAME = ".dependency-cruiser.js";
|
|
11
|
+
export const WEBPACK_CONFIG = "webpack.config.js";
|
|
12
|
+
export const TYPESCRIPT_CONFIG = "tsconfig.json";
|
|
13
|
+
export const BABEL_CONFIG = ".babelrc";
|
|
14
|
+
export const PACKAGE_MANIFEST = "package.json";
|
|
15
|
+
export const OUTPUT_TYPE = "err";
|
|
16
|
+
export const OUTPUT_TO = "-";
|
|
17
|
+
export const CACHE_FOLDER = "node_modules/.cache/dependency-cruiser";
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import figures from "figures";
|
|
3
|
+
|
|
4
|
+
import { getAvailableTranspilers, allExtensions } from "../main/index.mjs";
|
|
4
5
|
|
|
5
6
|
function bool2Symbol(pBool) {
|
|
6
7
|
return pBool ? chalk.green(figures.tick) : chalk.red(figures.cross);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
function formatTranspilers() {
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
` ${bool2Symbol(true)} javascript (>es1)\n`
|
|
18
|
-
);
|
|
11
|
+
return getAvailableTranspilers().reduce(
|
|
12
|
+
(pAll, pThis) =>
|
|
13
|
+
`${pAll} ${bool2Symbol(pThis.available)} ${pThis.name} (${
|
|
14
|
+
pThis.version
|
|
15
|
+
})\n`,
|
|
16
|
+
` ${bool2Symbol(true)} javascript (>es1)\n`
|
|
17
|
+
);
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
function formatExtensions(pExtensions) {
|
|
@@ -26,7 +25,7 @@ function formatExtensions(pExtensions) {
|
|
|
26
25
|
);
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
export default function formatMetaInfo() {
|
|
30
29
|
return `
|
|
31
30
|
Supported:
|
|
32
31
|
|
|
@@ -41,8 +40,8 @@ module.exports = function formatMetaInfo() {
|
|
|
41
40
|
${formatTranspilers()}
|
|
42
41
|
Extensions:
|
|
43
42
|
|
|
44
|
-
${formatExtensions(
|
|
43
|
+
${formatExtensions(allExtensions)}
|
|
45
44
|
`;
|
|
46
|
-
}
|
|
45
|
+
}
|
|
47
46
|
|
|
48
47
|
/* eslint security/detect-object-injection : 0 */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import getStream from "get-stream";
|
|
2
|
+
import { format as _format } from "../main/index.mjs";
|
|
3
|
+
import validateFileExistence from "./utl/validate-file-existence.mjs";
|
|
4
|
+
import normalizeOptions from "./normalize-cli-options.mjs";
|
|
5
|
+
import { getInStream, write } from "./utl/io.mjs";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {string} pResultFile the name of the file with cruise results
|
|
10
|
+
* @param {import("../../types/dependency-cruiser").IFormatOptions} pOptions
|
|
11
|
+
* @returns {Number} an exitCode
|
|
12
|
+
*/
|
|
13
|
+
export default async function format(pResultFile, pOptions) {
|
|
14
|
+
const lOptions = await normalizeOptions(pOptions);
|
|
15
|
+
|
|
16
|
+
if (pResultFile !== "-") {
|
|
17
|
+
validateFileExistence(pResultFile);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const lResult = await getStream(getInStream(pResultFile));
|
|
21
|
+
|
|
22
|
+
const lReportingResult = await _format(JSON.parse(lResult), lOptions);
|
|
23
|
+
|
|
24
|
+
write(lOptions.outputTo, lReportingResult.output);
|
|
25
|
+
return lReportingResult.exitCode;
|
|
26
|
+
}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
/* eslint-disable import/max-dependencies */
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { glob } from "glob";
|
|
4
|
+
import cloneDeep from "lodash/cloneDeep.js";
|
|
5
|
+
import set from "lodash/set.js";
|
|
6
|
+
import isInstalledGlobally from "is-installed-globally";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
|
|
9
|
+
import { cruise } from "../main/index.mjs";
|
|
10
|
+
import bus from "../utl/bus.mjs";
|
|
11
|
+
|
|
12
|
+
import extractTSConfig from "../config-utl/extract-ts-config.mjs";
|
|
13
|
+
import extractBabelConfig from "../config-utl/extract-babel-config.mjs";
|
|
14
|
+
import extractWebpackResolveConfig from "../config-utl/extract-webpack-resolve-config.mjs";
|
|
15
|
+
import extractKnownViolations from "../config-utl/extract-known-violations.mjs";
|
|
16
|
+
import busLogLevels from "../utl/bus-log-levels.mjs";
|
|
17
|
+
import validateFileExistence from "./utl/validate-file-existence.mjs";
|
|
18
|
+
import normalizeCliOptions from "./normalize-cli-options.mjs";
|
|
19
|
+
import { write } from "./utl/io.mjs";
|
|
20
|
+
import formatMetaInfo from "./format-meta-info.mjs";
|
|
21
|
+
import setUpCliFeedbackListener from "./listeners/cli-feedback.mjs";
|
|
22
|
+
import setUpPerformanceLogListener from "./listeners/performance-log/index.mjs";
|
|
23
|
+
import setUpNDJSONListener from "./listeners/ndjson.mjs";
|
|
24
|
+
import initConfig from "./init-config/index.mjs";
|
|
25
|
+
|
|
26
|
+
async function extractResolveOptions(pCruiseOptions) {
|
|
25
27
|
let lResolveOptions = {};
|
|
26
28
|
const lWebPackConfigFileName =
|
|
27
29
|
pCruiseOptions?.ruleSet?.options?.webpackConfig?.fileName ?? null;
|
|
28
30
|
|
|
29
31
|
if (lWebPackConfigFileName) {
|
|
30
|
-
lResolveOptions = extractWebpackResolveConfig(
|
|
32
|
+
lResolveOptions = await extractWebpackResolveConfig(
|
|
31
33
|
lWebPackConfigFileName,
|
|
32
34
|
pCruiseOptions?.ruleSet?.options?.webpackConfig?.env ?? null,
|
|
33
35
|
pCruiseOptions?.ruleSet?.options?.webpackConfig?.arguments ?? null
|
|
@@ -90,21 +92,22 @@ function setUpListener(pCruiseOptions) {
|
|
|
90
92
|
if (Boolean(lListenerFunction)) {
|
|
91
93
|
lListenerFunction(
|
|
92
94
|
bus,
|
|
93
|
-
pCruiseOptions?.ruleSet?.options?.progress?.maximumLevel ??
|
|
95
|
+
pCruiseOptions?.ruleSet?.options?.progress?.maximumLevel ??
|
|
96
|
+
busLogLevels.INFO
|
|
94
97
|
);
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
101
|
+
async function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
99
102
|
const lCruiseOptions = addKnownViolations(
|
|
100
|
-
normalizeCliOptions(pCruiseOptions)
|
|
103
|
+
await normalizeCliOptions(pCruiseOptions)
|
|
101
104
|
);
|
|
102
105
|
|
|
103
106
|
pFileDirectoryArray
|
|
104
107
|
.filter((pFileOrDirectory) => !glob.hasMagic(pFileOrDirectory))
|
|
105
108
|
.map((pFileOrDirectory) =>
|
|
106
109
|
lCruiseOptions?.ruleSet?.options?.baseDir
|
|
107
|
-
?
|
|
110
|
+
? join(lCruiseOptions.ruleSet.options.baseDir, pFileOrDirectory)
|
|
108
111
|
: pFileOrDirectory
|
|
109
112
|
)
|
|
110
113
|
.forEach(validateFileExistence);
|
|
@@ -112,19 +115,19 @@ function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
|
112
115
|
setUpListener(lCruiseOptions);
|
|
113
116
|
|
|
114
117
|
bus.emit("start");
|
|
115
|
-
const lReportingResult =
|
|
118
|
+
const lReportingResult = await cruise(
|
|
116
119
|
pFileDirectoryArray,
|
|
117
120
|
lCruiseOptions,
|
|
118
|
-
extractResolveOptions(lCruiseOptions),
|
|
121
|
+
await extractResolveOptions(lCruiseOptions),
|
|
119
122
|
{
|
|
120
123
|
tsConfig: extractTSConfigOptions(lCruiseOptions),
|
|
121
|
-
babelConfig: extractBabelConfigOptions(lCruiseOptions),
|
|
124
|
+
babelConfig: await extractBabelConfigOptions(lCruiseOptions),
|
|
122
125
|
}
|
|
123
126
|
);
|
|
124
127
|
|
|
125
128
|
bus.emit("progress", "cli: writing results", { complete: 1 });
|
|
126
129
|
bus.emit("write-start");
|
|
127
|
-
|
|
130
|
+
write(lCruiseOptions.outputTo, lReportingResult.output);
|
|
128
131
|
|
|
129
132
|
return lReportingResult.exitCode;
|
|
130
133
|
}
|
|
@@ -135,7 +138,7 @@ function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
|
135
138
|
* @param {import("../../types/options").ICruiseOptions} lCruiseOptions
|
|
136
139
|
* @returns {number}
|
|
137
140
|
*/
|
|
138
|
-
|
|
141
|
+
export default async function executeCli(pFileDirectoryArray, pCruiseOptions) {
|
|
139
142
|
let lCruiseOptions = pCruiseOptions || {};
|
|
140
143
|
let lExitCode = 0;
|
|
141
144
|
|
|
@@ -143,10 +146,10 @@ module.exports = function executeCli(pFileDirectoryArray, pCruiseOptions) {
|
|
|
143
146
|
/* c8 ignore start */
|
|
144
147
|
if (isInstalledGlobally) {
|
|
145
148
|
process.stderr.write(
|
|
146
|
-
`\n ${yellow(
|
|
149
|
+
`\n ${chalk.yellow(
|
|
147
150
|
"WARNING"
|
|
148
151
|
)}: You're running a globally installed dependency-cruiser.\n\n` +
|
|
149
|
-
` We recommend to ${bold.italic.underline(
|
|
152
|
+
` We recommend to ${chalk.bold.italic.underline(
|
|
150
153
|
"install and run it as a local devDependency"
|
|
151
154
|
)} in\n` +
|
|
152
155
|
` your project instead. There it has your project's environment and\n` +
|
|
@@ -158,23 +161,15 @@ module.exports = function executeCli(pFileDirectoryArray, pCruiseOptions) {
|
|
|
158
161
|
if (lCruiseOptions.info === true) {
|
|
159
162
|
process.stdout.write(formatMetaInfo());
|
|
160
163
|
} else if (lCruiseOptions.init) {
|
|
161
|
-
// requiring init-config took ~100ms (most of it taken up by requiring
|
|
162
|
-
// inquirer, measured on a 2.6GHz quad core i7 with flash storage on
|
|
163
|
-
// macOS 10.15.7). Only requiring it when '--init' is necessary speeds up
|
|
164
|
-
// (the start-up) of cruises by that same amount. We've since replaced
|
|
165
|
-
// inquirer with 'prompts' (which is much smaller), but the same reasoning
|
|
166
|
-
// holds.
|
|
167
|
-
// eslint-disable-next-line node/global-require, import/max-dependencies
|
|
168
|
-
const initConfig = require("./init-config");
|
|
169
164
|
initConfig(lCruiseOptions.init);
|
|
170
165
|
} else {
|
|
171
|
-
lExitCode = runCruise(pFileDirectoryArray, lCruiseOptions);
|
|
166
|
+
lExitCode = await runCruise(pFileDirectoryArray, lCruiseOptions);
|
|
172
167
|
}
|
|
173
168
|
} catch (pError) {
|
|
174
|
-
process.stderr.write(`\n ${red("ERROR")}: ${pError.message}\n`);
|
|
169
|
+
process.stderr.write(`\n ${chalk.red("ERROR")}: ${pError.message}\n`);
|
|
175
170
|
bus.emit("end");
|
|
176
171
|
lExitCode = 1;
|
|
177
172
|
}
|
|
178
173
|
bus.emit("end");
|
|
179
174
|
return lExitCode;
|
|
180
|
-
}
|
|
175
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import Handlebars from "handlebars/runtime.js";
|
|
3
|
+
import { folderNameArrayToRE } from "./utl.mjs";
|
|
4
4
|
|
|
5
5
|
/* eslint import/no-unassigned-import: 0 */
|
|
6
|
-
|
|
6
|
+
await import("./config.js.template.js");
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {string} pString
|
|
@@ -28,12 +28,12 @@ function extensionsToString(pExtensions) {
|
|
|
28
28
|
* Creates a .dependency-cruiser config with a set of basic validations
|
|
29
29
|
* to the current directory.
|
|
30
30
|
*
|
|
31
|
-
* @param {import("./types").IInitConfig} pNormalizedInitOptions Options that influence the shape of
|
|
31
|
+
* @param {import("./types.js").IInitConfig} pNormalizedInitOptions Options that influence the shape of
|
|
32
32
|
* the configuration
|
|
33
33
|
* @returns {string} the configuration as a string
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
export default function buildConfig(pNormalizedInitOptions) {
|
|
37
37
|
return Handlebars.templates["config.js.template.hbs"]({
|
|
38
38
|
...pNormalizedInitOptions,
|
|
39
39
|
|
|
@@ -45,4 +45,4 @@ module.exports = function buildConfig(pNormalizedInitOptions) {
|
|
|
45
45
|
pNormalizedInitOptions.resolutionExtensions
|
|
46
46
|
),
|
|
47
47
|
});
|
|
48
|
-
}
|
|
48
|
+
}
|