dependency-cruiser 13.0.5 → 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
CHANGED
|
@@ -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;
|
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
|
+
}
|