dependency-cruiser 13.0.4 → 13.1.0-beta-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/package.json +23 -12
- package/src/main/resolve-options/normalize.mjs +28 -13
- package/src/meta.js +1 -1
- package/src/report/azure-devops.mjs +103 -0
- package/src/report/index.mjs +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.1.0-beta-1",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -154,11 +154,11 @@
|
|
|
154
154
|
"acorn-loose": "8.3.0",
|
|
155
155
|
"acorn-walk": "8.2.0",
|
|
156
156
|
"ajv": "8.12.0",
|
|
157
|
-
"chalk": "5.
|
|
157
|
+
"chalk": "5.3.0",
|
|
158
158
|
"commander": "11.0.0",
|
|
159
159
|
"enhanced-resolve": "5.15.0",
|
|
160
160
|
"figures": "5.0.0",
|
|
161
|
-
"glob": "10.
|
|
161
|
+
"glob": "10.3.1",
|
|
162
162
|
"handlebars": "4.7.7",
|
|
163
163
|
"ignore": "5.2.4",
|
|
164
164
|
"indent-string": "5.0.0",
|
|
@@ -169,8 +169,8 @@
|
|
|
169
169
|
"prompts": "2.4.2",
|
|
170
170
|
"rechoir": "^0.8.0",
|
|
171
171
|
"safe-regex": "2.1.1",
|
|
172
|
-
"semver": "^7.5.
|
|
173
|
-
"semver-try-require": "6.2.
|
|
172
|
+
"semver": "^7.5.3",
|
|
173
|
+
"semver-try-require": "6.2.3",
|
|
174
174
|
"teamcity-service-messages": "0.1.14",
|
|
175
175
|
"tsconfig-paths-webpack-plugin": "4.0.1",
|
|
176
176
|
"watskeburt": "0.11.5",
|
|
@@ -180,18 +180,18 @@
|
|
|
180
180
|
"@babel/core": "7.22.5",
|
|
181
181
|
"@babel/plugin-transform-modules-commonjs": "7.22.5",
|
|
182
182
|
"@babel/preset-typescript": "7.22.5",
|
|
183
|
-
"@swc/core": "1.3.
|
|
183
|
+
"@swc/core": "1.3.67",
|
|
184
184
|
"@types/lodash": "4.14.195",
|
|
185
|
-
"@types/node": "20.3.
|
|
185
|
+
"@types/node": "20.3.3",
|
|
186
186
|
"@types/prompts": "2.4.4",
|
|
187
|
-
"@typescript-eslint/eslint-plugin": "5.60.
|
|
188
|
-
"@typescript-eslint/parser": "5.60.
|
|
187
|
+
"@typescript-eslint/eslint-plugin": "5.60.1",
|
|
188
|
+
"@typescript-eslint/parser": "5.60.1",
|
|
189
189
|
"@vue/compiler-sfc": "3.3.4",
|
|
190
190
|
"c8": "8.0.0",
|
|
191
191
|
"chai": "4.3.7",
|
|
192
192
|
"chai-json-schema": "1.5.1",
|
|
193
193
|
"coffeescript": "2.7.0",
|
|
194
|
-
"eslint": "8.
|
|
194
|
+
"eslint": "8.44.0",
|
|
195
195
|
"eslint-config-moving-meadow": "4.0.2",
|
|
196
196
|
"eslint-config-prettier": "8.8.0",
|
|
197
197
|
"eslint-plugin-budapestian": "5.0.1",
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
"eslint-plugin-unicorn": "^47.0.0",
|
|
204
204
|
"husky": "8.0.3",
|
|
205
205
|
"intercept-stdout": "0.1.2",
|
|
206
|
-
"lint-staged": "13.2.
|
|
206
|
+
"lint-staged": "13.2.3",
|
|
207
207
|
"mocha": "10.2.0",
|
|
208
208
|
"normalize-newline": "4.1.0",
|
|
209
209
|
"npm-run-all": "4.1.5",
|
|
@@ -212,11 +212,17 @@
|
|
|
212
212
|
"shx": "0.3.4",
|
|
213
213
|
"svelte": "3.59.1",
|
|
214
214
|
"symlink-dir": "5.1.1",
|
|
215
|
-
"typescript": "5.1.
|
|
215
|
+
"typescript": "5.1.6",
|
|
216
216
|
"upem": "8.0.0",
|
|
217
217
|
"vue-template-compiler": "2.7.14",
|
|
218
218
|
"yarn": "1.22.19"
|
|
219
219
|
},
|
|
220
|
+
"overrides": {
|
|
221
|
+
"semver": "^7.5.3"
|
|
222
|
+
},
|
|
223
|
+
"resolutions": {
|
|
224
|
+
"semver": "^7.5.3"
|
|
225
|
+
},
|
|
220
226
|
"upem": {
|
|
221
227
|
"policies": [
|
|
222
228
|
{
|
|
@@ -228,6 +234,11 @@
|
|
|
228
234
|
"package": "rechoir",
|
|
229
235
|
"policy": "wanted",
|
|
230
236
|
"because": "we want to keep rechoir ~similar to what webpack-cli uses (which is ^0.8.0 since 2022-11-15). See https://github.com/webpack/webpack-cli/blame/master/packages/webpack-cli/package.json"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"package": "svelte",
|
|
240
|
+
"policy": "pin",
|
|
241
|
+
"because": "upgrading to supporting svelte 4 will require a non-trivial amount of labour (which we are going to invest, but not right now)"
|
|
231
242
|
}
|
|
232
243
|
]
|
|
233
244
|
},
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import has from "lodash/has.js";
|
|
3
|
-
import omit from "lodash/omit.js";
|
|
4
2
|
import enhancedResolve from "enhanced-resolve";
|
|
3
|
+
import omit from "lodash/omit.js";
|
|
5
4
|
import { scannableExtensions } from "../../extract/transpile/meta.mjs";
|
|
6
5
|
import {
|
|
7
|
-
ruleSetHasLicenseRule,
|
|
8
6
|
ruleSetHasDeprecationRule,
|
|
7
|
+
ruleSetHasLicenseRule,
|
|
9
8
|
} from "../../graph-utl/rule-set.mjs";
|
|
10
9
|
|
|
11
10
|
const DEFAULT_CACHE_DURATION = 4000;
|
|
@@ -63,10 +62,7 @@ function pushPlugin(pPlugins, pPluginToPush) {
|
|
|
63
62
|
return (pPlugins || []).concat(pPluginToPush);
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
return has(pTSConfig, "options.baseUrl");
|
|
68
|
-
}
|
|
69
|
-
|
|
65
|
+
// eslint-disable-next-line max-lines-per-function
|
|
70
66
|
async function compileResolveOptions(
|
|
71
67
|
pResolveOptions,
|
|
72
68
|
pTSConfig,
|
|
@@ -74,16 +70,12 @@ async function compileResolveOptions(
|
|
|
74
70
|
) {
|
|
75
71
|
let lResolveOptions = {};
|
|
76
72
|
|
|
77
|
-
//
|
|
78
|
-
// otherwise it prints scary messages that it didn't and read the tsConfig
|
|
79
|
-
// (potentially making users think it's dependency-cruiser disregarding the
|
|
80
|
-
// tsconfig). Hence: only load TsConfigPathsPlugin when an options.baseUrl exists
|
|
81
|
-
// Also: there's a performance impact of ~1 ms per resolve even when there
|
|
73
|
+
// There's a performance impact of ~1 ms per resolve even when there
|
|
82
74
|
// are 0 paths in the tsconfig, so not loading it when not necessary
|
|
83
75
|
// will be a win.
|
|
84
76
|
// Also: requiring the plugin only when it's necessary will save some
|
|
85
77
|
// startup time (especially on a cold require cache)
|
|
86
|
-
if (pResolveOptions.tsConfig
|
|
78
|
+
if (pResolveOptions.tsConfig) {
|
|
87
79
|
const { default: TsConfigPathsPlugin } = await import(
|
|
88
80
|
"tsconfig-paths-webpack-plugin"
|
|
89
81
|
);
|
|
@@ -92,6 +84,29 @@ async function compileResolveOptions(
|
|
|
92
84
|
// @ts-expect-error TS2351 "TsConfPathsPlugin is not constructable" - is unjustified
|
|
93
85
|
new TsConfigPathsPlugin({
|
|
94
86
|
configFile: pResolveOptions.tsConfig,
|
|
87
|
+
// TsConfigPathsPlugin requires a baseUrl to be present in the tsconfig,
|
|
88
|
+
// otherwise it prints scary messages that it didn't and read the tsConfig
|
|
89
|
+
// (potentially making users think it's dependency-cruiser disregarding the
|
|
90
|
+
// tsconfig). Hence up till version 13.0.4 dependency-cruiser only loaded
|
|
91
|
+
// TsConfigPathsPlugin when an options.baseUrl existed. However, this
|
|
92
|
+
// isn't necessary anymore:
|
|
93
|
+
// - [tsconfig#baseUrl documentation](https://www.typescriptlang.org/tsconfig#baseUrl)
|
|
94
|
+
// UNrecommends the use of the baseUrl for non-AMD projects
|
|
95
|
+
// - [tsconfig-paths PR #207](https://github.com/dividab/tsconfig-paths/pull/208)
|
|
96
|
+
// 'tolerates' undefined baseUrls
|
|
97
|
+
//
|
|
98
|
+
// Hence, until
|
|
99
|
+
// [tpwp issue #99](https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/99)
|
|
100
|
+
// lands:
|
|
101
|
+
// - pass a default baseUrl to TsConfigPathsPlugin if the baseUrl isn't available
|
|
102
|
+
// - pass undefined in all other cases; TsConfigPathsPlugin will read
|
|
103
|
+
// it from the tsconfig.json in that case. Passing the processed baseUrl
|
|
104
|
+
// (pTSConfig?.options?.baseUrl) instead would've been more obvious, but
|
|
105
|
+
// doesn't work, as that is an absolute path and tsconfig-paths(-wpp)
|
|
106
|
+
// seems to process that again resulting in invalid paths and unresolved
|
|
107
|
+
// or erroneous dependencies
|
|
108
|
+
// eslint-disable-next-line no-undefined
|
|
109
|
+
baseUrl: pTSConfig?.options?.baseUrl ? undefined : "./",
|
|
95
110
|
// TsConfigPathsPlugin doesn't (can't) read enhanced-resolve's
|
|
96
111
|
// list of extensions, and the default it uses for extensions
|
|
97
112
|
// so we do it ourselves - either with the extensions passed
|
package/src/meta.js
CHANGED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Message grouping
|
|
3
|
+
##[group]Beginning of a group
|
|
4
|
+
##[warning]Warning message
|
|
5
|
+
##[error]Error message
|
|
6
|
+
##[section]Start of a section
|
|
7
|
+
##[debug]Debug text
|
|
8
|
+
##[command]Command-line being run
|
|
9
|
+
##[endgroup]
|
|
10
|
+
|
|
11
|
+
Warnings and errors:
|
|
12
|
+
|
|
13
|
+
##vso[task.logissue type=warning;sourcepath=consoleapp/main.cs;linenumber=1;columnnumber=1;code=100;]Found something that could be a problem.
|
|
14
|
+
|
|
15
|
+
Progress
|
|
16
|
+
##vso[task.setprogress]current operation
|
|
17
|
+
|
|
18
|
+
Complete
|
|
19
|
+
##vso[task.complete]current operation
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { EOL } from "node:os";
|
|
23
|
+
|
|
24
|
+
const SEVERITY2VSO_TYPE = new Map([
|
|
25
|
+
// "error" | "warn" | "info" | "ignore
|
|
26
|
+
["error", "error"],
|
|
27
|
+
["warn", "warning"],
|
|
28
|
+
// azure devops doesn't seem to understand 'info'. We still want to
|
|
29
|
+
// show them, though, hence:
|
|
30
|
+
["info", "warning"],
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {import("../../types/shared-types.js").SeverityType} pSeverity
|
|
36
|
+
*/
|
|
37
|
+
function formatSeverity(pSeverity) {
|
|
38
|
+
return SEVERITY2VSO_TYPE.get(pSeverity) ?? "warning";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {import("../../types/violations.js").IViolation} pViolation
|
|
44
|
+
*/
|
|
45
|
+
function formatViolation(pViolation) {
|
|
46
|
+
return `##vso[task.logissue type=${formatSeverity(
|
|
47
|
+
pViolation.rule.severity
|
|
48
|
+
)};sourcepath=${pViolation.from}]${pViolation.rule.name}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {number} pNumberOfErrors
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
function formatSuccess(pNumberOfErrors) {
|
|
57
|
+
return pNumberOfErrors === 0 ? "Succeeded" : "Failed";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @param {import("../../types/cruise-result.js").ISummary} pSummary
|
|
63
|
+
*/
|
|
64
|
+
function formatSummary(pSummary) {
|
|
65
|
+
return `##vso[task.complete result=${formatSuccess(pSummary.error)};] ${
|
|
66
|
+
pSummary.totalCruised
|
|
67
|
+
} modules, ${pSummary.totalDependenciesCruised} dependencies cruised`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns a bunch of Azure DevOps log messages:
|
|
72
|
+
* - for each violated rule in the passed results: gnork
|
|
73
|
+
* - for each violation in the passed results: bork
|
|
74
|
+
*
|
|
75
|
+
* https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#task-commands
|
|
76
|
+
*
|
|
77
|
+
* @param {import("../../types/dependency-cruiser.js").ICruiseResult} pResults
|
|
78
|
+
* @returns {import("../../types/dependency-cruiser.js").IReporterOutput}
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
81
|
+
export default function azureDevOps(pResults) {
|
|
82
|
+
// this is the documented way to get tsm to emit strings
|
|
83
|
+
// Alternatively we could've used the 'low level API', which
|
|
84
|
+
// involves creating new `Message`s and stringifying those.
|
|
85
|
+
// The abstraction of the 'higher level API' makes this
|
|
86
|
+
// reporter more easy to implement and maintain, despite
|
|
87
|
+
// setting this property directly
|
|
88
|
+
|
|
89
|
+
const lViolations = (pResults?.summary?.violations ?? []).filter(
|
|
90
|
+
(pViolation) => pViolation.rule.severity !== "ignore"
|
|
91
|
+
);
|
|
92
|
+
const lIgnoredCount = pResults?.summary?.ignore ?? 0;
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
output: lViolations
|
|
96
|
+
.map(formatViolation)
|
|
97
|
+
.join(EOL)
|
|
98
|
+
.concat(EOL)
|
|
99
|
+
.concat(formatSummary(pResults.summary))
|
|
100
|
+
.concat(EOL),
|
|
101
|
+
exitCode: pResults.summary.error,
|
|
102
|
+
};
|
|
103
|
+
}
|