dependency-cruiser 13.1.2 → 13.1.3

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.
@@ -0,0 +1,212 @@
1
+ export default `<!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>dependency-cruiser - results</title>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+
8
+ <style type="text/css">
9
+ body {
10
+ font-family: sans-serif;
11
+ margin: 0 auto;
12
+ max-width: 90%;
13
+ line-height: 1.6;
14
+ font-size: 14px;
15
+ color: #444;
16
+ padding: 0 10px;
17
+ background-color: #fff;
18
+ }
19
+
20
+ footer {
21
+ color: gray;
22
+ margin-top: 1.4em;
23
+ border-top: solid 1px currentColor
24
+ }
25
+
26
+ a {
27
+ text-decoration: none
28
+ }
29
+
30
+ a.noiseless {
31
+ color: currentColor
32
+ }
33
+
34
+ h1,
35
+ h2,
36
+ h3 {
37
+ line-height: 1.2
38
+ }
39
+
40
+ table {
41
+ border-collapse: collapse;
42
+ width: 100%;
43
+ }
44
+
45
+ th,
46
+ td {
47
+ text-align: left;
48
+ padding: 4px;
49
+ }
50
+
51
+ tbody tr:nth-child(odd) {
52
+ background-color: rgba(128, 128, 128, 0.2);
53
+ }
54
+
55
+ .error {
56
+ color: red;
57
+ }
58
+
59
+ .warn {
60
+ color: orange;
61
+ }
62
+
63
+ .info {
64
+ color: blue;
65
+ }
66
+
67
+ .ignore {
68
+ color:gray;
69
+ }
70
+
71
+ .ok {
72
+ color: limegreen;
73
+ }
74
+
75
+ td.nowrap {
76
+ white-space: nowrap
77
+ }
78
+
79
+ svg {
80
+ fill: currentColor
81
+ }
82
+
83
+ #show-unviolated {
84
+ display: block
85
+ }
86
+
87
+ #hide-unviolated {
88
+ display: none
89
+ }
90
+
91
+ #show-all-the-rules:target #show-unviolated {
92
+ display: none
93
+ }
94
+
95
+ #show-all-the-rules:target #hide-unviolated {
96
+ display: block
97
+ }
98
+
99
+ tr.unviolated {
100
+ display: none
101
+ }
102
+
103
+ #show-all-the-rules:target tr.unviolated {
104
+ display: table-row;
105
+ color: gray;
106
+ }
107
+
108
+ #show-ignored {
109
+ display: block
110
+ }
111
+
112
+ #hide-ignored {
113
+ display: none
114
+ }
115
+
116
+ #show-ignored-violations:target #show-ignored {
117
+ display: none
118
+ }
119
+
120
+ #show-ignored-violations:target #hide-ignored {
121
+ display: block
122
+ }
123
+
124
+ tr.ignored {
125
+ display: none
126
+ }
127
+
128
+ #show-ignored-violations:target tr.ignored {
129
+ display: table-row;
130
+ color: gray;
131
+ }
132
+
133
+ .p__svg--inline {
134
+ vertical-align: top;
135
+ width: 1.2em;
136
+ height: 1.2em
137
+ }
138
+
139
+ .controls {
140
+ background-color: #fff;
141
+ vertical-align: bottom;
142
+ text-align: center
143
+ }
144
+
145
+ .controls:hover {
146
+ opacity: 1;
147
+ }
148
+
149
+ .controls a {
150
+ text-decoration: none;
151
+ color: gray;
152
+ }
153
+
154
+ .controls a:hover {
155
+ text-decoration: underline;
156
+ color: blue;
157
+ }
158
+
159
+ .extra {
160
+ color: gray;
161
+ }
162
+ </style>
163
+ <style type="text/css" media="print">
164
+ th,
165
+ td {
166
+ border: 1px solid #444;
167
+ }
168
+
169
+ .controls {
170
+ display: none
171
+ }
172
+ </style>
173
+ </head>
174
+
175
+ <body>
176
+ <h1>Forbidden dependency check - results</h1>
177
+ <span id="show-all-the-rules">
178
+ <h2><svg class="p__svg--inline" viewBox="0 0 14 16" version="1.1" aria-hidden="true">
179
+ <path fill-rule="evenodd"
180
+ d="M11.5 8L8.8 5.4 6.6 8.5 5.5 1.6 2.38 8H0v2h3.6l.9-1.8.9 5.4L9 8.5l1.6 1.5H14V8h-2.5z"></path>
181
+ </svg> Summary</h2>
182
+ <p>
183
+ <div style="float:left;padding-right:20px">
184
+ <strong>{{totalCruised}}</strong> modules
185
+ </div>
186
+ <div style="float:left;padding-right:20px">
187
+ <strong>{{totalDependenciesCruised}}</strong> dependencies
188
+ </div>
189
+ <div style="float:left;padding-right:20px">
190
+ <strong>{{error}}</strong> errors
191
+ </div>
192
+ <div style="float:left;padding-right:20px">
193
+ <strong>{{warn}}</strong> warnings
194
+ </div>
195
+ <div style="float:left;padding-right:20px">
196
+ <strong>{{info}}</strong> informational
197
+ </div>
198
+ <div style="float:left;padding-right:20px" class="ignore">
199
+ <strong>{{ignore}}</strong> ignored
200
+ </div>
201
+ &nbsp;
202
+ </p>
203
+ {{violatedRulesTable}}
204
+ </span>
205
+
206
+ {{violationsList}}
207
+ <footer>
208
+ <p><a href="https://github.com/sverweij/dependency-cruiser">{{depcruiseVersion}}</a> /
209
+ {{runDate}}</p>
210
+ </footer>
211
+ </body>
212
+ </html>`;
@@ -1,25 +1,165 @@
1
- import Handlebars from "handlebars/runtime.js";
2
- import { formatSummaryForReport, aggregateViolations } from "./utl.mjs";
1
+ import meta from "../../meta.js";
2
+ import {
3
+ determineFromExtras,
4
+ aggregateViolations,
5
+ determineTo,
6
+ } from "./utl.mjs";
7
+ import template from "./error-html-template.mjs";
3
8
 
4
- await import("./error-html.template.js");
9
+ function getViolatedRuleRowClass(pViolatedRule) {
10
+ return pViolatedRule.unviolated ? ' class="unviolated"' : "";
11
+ }
5
12
 
6
- function massageSummaryIntoSomethingUsable(pResults) {
7
- const lSummary = formatSummaryForReport(pResults.summary);
8
- return {
9
- summary: {
10
- ...lSummary,
11
- agggregateViolations: aggregateViolations(
12
- lSummary.violations,
13
- lSummary.ruleSetUsed
14
- ),
15
- },
13
+ function getViolatedRuleOkNokCell(pViolatedRule) {
14
+ if (pViolatedRule.unviolated) {
15
+ return '<span class="ok">&check;</span>';
16
+ }
17
+ return `<span class="${pViolatedRule.severity}">&cross;</span>`;
18
+ }
19
+
20
+ function buildViolatedRuleRow(pViolatedRule) {
21
+ return `<tr${getViolatedRuleRowClass(pViolatedRule)}>
22
+ <td>${getViolatedRuleOkNokCell(pViolatedRule)}</td>
23
+ <td>${pViolatedRule.severity}</td>
24
+ <td class="nowrap">
25
+ <a href="#${pViolatedRule.name}-instance"
26
+ id="${pViolatedRule.name}-definition"
27
+ class="noiseless">${pViolatedRule.name}</a>
28
+ </td>
29
+ <td><strong>${pViolatedRule.count}</strong></td>
30
+ <td><strong>${pViolatedRule.ignoredCount ?? 0}</strong></td>
31
+ <td>${pViolatedRule.comment}</td>
32
+ </tr>`;
33
+ }
34
+
35
+ /**
36
+ * @param {import('../../../types/cruise-result.js')} pResults
37
+ * @returns {string}
38
+ */
39
+ function constructViolatedRulesTable(pResults) {
40
+ return `<table>
41
+ <tbody>
42
+ <thead>
43
+ <tr>
44
+ <th></th>
45
+ <th>severity</th>
46
+ <th>rule</th>
47
+ <th>violations</th>
48
+ <th>ignored</th>
49
+ <th>explanation</th>
50
+ </tr>
51
+ </thead>
52
+ ${aggregateViolations(
53
+ pResults.summary.violations,
54
+ pResults.summary.ruleSetUsed,
55
+ )
56
+ .map(buildViolatedRuleRow)
57
+ .join("\n")}
58
+ <tr>
59
+ <td colspan="6" class="controls">
60
+ <div id="show-unviolated">
61
+ &downarrow; <a href="#show-all-the-rules">also show unviolated rules</a>
62
+ </div>
63
+ <div id="hide-unviolated">
64
+ &uparrow; <a href="">hide unviolated rules</a>
65
+ </div>
66
+ </td>
67
+ </tr>
68
+ </tbody>
69
+ </table>`;
70
+ }
71
+
72
+ function getViolationRowClass(pViolation) {
73
+ return pViolation.ignored ? ' class="ignored"' : "";
74
+ }
75
+
76
+ /**
77
+ * @param {import('../../../types/cruise-result.js').IViolation} pViolation
78
+ * @returns {string}
79
+ */
80
+ function constructViolationRow(pPrefix) {
81
+ return (pViolation) => {
82
+ return ` <tr${getViolationRowClass(pViolation)}>
83
+ <td class="${pViolation.rule.severity}">${pViolation.rule.severity}</td>
84
+ <td class="nowrap">
85
+ <a href="#${pViolation.rule.name}-definition"
86
+ id="${pViolation.rule.name}-instance"
87
+ class="noiseless">${pViolation.rule.name}</a>
88
+ </td>
89
+ <td><a href="${pPrefix}${pViolation.from}">${
90
+ pViolation.from
91
+ }</a>${determineFromExtras(pViolation)}</td>
92
+ <td>${determineTo(pViolation)}</td>
93
+ </tr>`;
16
94
  };
17
95
  }
18
96
 
97
+ /**
98
+ * @param {import('../../../types/cruise-result.js').ICruiseResult} pResults
99
+ * @returns {string}
100
+ */
101
+ function constructViolationsList(pResults) {
102
+ if (pResults.summary.violations.length > 0) {
103
+ return `<span id="show-ignored-violations">
104
+ <h2><svg class="p__svg--inline" viewBox="0 0 12 16" version="1.1" aria-hidden="true">
105
+ <path fill-rule="evenodd"
106
+ d="M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z">
107
+ </path>
108
+ </svg> All violations</h2>
109
+ <table>
110
+ <thead>
111
+ <tr>
112
+ <th>severity</th>
113
+ <th>rule</th>
114
+ <th>from</th>
115
+ <th>to</th>
116
+ </tr>
117
+ </thead>
118
+ <tbody>
119
+ ${pResults.summary.violations
120
+ .map(constructViolationRow(pResults.summary.optionsUsed.prefix ?? ""))
121
+ .join("\n")}
122
+ ${
123
+ pResults.summary.ignore > 0
124
+ ? `<tr>
125
+ <td colspan="4" class="controls">
126
+ <div id="show-ignored">
127
+ &downarrow; <a href="#show-ignored-violations">also show ignored violations</a>
128
+ </div>
129
+ <div id="hide-ignored">
130
+ &uparrow; <a href="">hide ignored violations</a>
131
+ </div>
132
+ </td>
133
+ </tr>`
134
+ : ""
135
+ }
136
+ </tbody>
137
+ </table>
138
+ </span>`;
139
+ }
140
+ return ` <h2><span aria-hidden="true">&hearts;</span> No violations found</h2>
141
+ <p>Get gummy bears to celebrate.</p>`;
142
+ }
143
+
144
+ /**
145
+ * @param {import('../../../types/cruise-result.js')} pResults
146
+ * @returns {string}
147
+ */
19
148
  function report(pResults) {
20
- return Handlebars.templates["error-html.template.hbs"](
21
- massageSummaryIntoSomethingUsable(pResults)
22
- );
149
+ return template
150
+ .replace("{{totalCruised}}", pResults.summary.totalCruised)
151
+ .replace(
152
+ "{{totalDependenciesCruised}}",
153
+ pResults.summary.totalDependenciesCruised,
154
+ )
155
+ .replace("{{error}}", pResults.summary.error)
156
+ .replace("{{warn}}", pResults.summary.warn)
157
+ .replace("{{info}}", pResults.summary.info)
158
+ .replace("{{ignore}}", pResults.summary.ignore ?? 0)
159
+ .replace("{{violatedRulesTable}}", constructViolatedRulesTable(pResults))
160
+ .replace("{{violationsList}}", constructViolationsList(pResults))
161
+ .replace("{{depcruiseVersion}}", `dependency-cruiser@${meta.version}`)
162
+ .replace("{{runDate}}", new Date().toISOString());
23
163
  }
24
164
 
25
165
  /**
@@ -47,11 +47,11 @@ function formatModuleTo() {
47
47
 
48
48
  function formatInstabilityTo(pViolation) {
49
49
  return `${pViolation.to}&nbsp;<span class="extra">(I: ${formatPercentage(
50
- pViolation.metrics.to.instability
50
+ pViolation.metrics.to.instability,
51
51
  )})</span>`;
52
52
  }
53
53
 
54
- function determineTo(pViolation) {
54
+ export function determineTo(pViolation) {
55
55
  const lViolationType2Formatter = {
56
56
  dependency: formatDependencyTo,
57
57
  module: formatModuleTo,
@@ -62,17 +62,17 @@ function determineTo(pViolation) {
62
62
  return formatViolation(
63
63
  pViolation,
64
64
  lViolationType2Formatter,
65
- formatDependencyTo
65
+ formatDependencyTo,
66
66
  );
67
67
  }
68
68
 
69
69
  function formatInstabilityFromExtras(pViolation) {
70
70
  return `&nbsp;<span class="extra">(I: ${formatPercentage(
71
- pViolation.metrics.from.instability
71
+ pViolation.metrics.from.instability,
72
72
  )})</span>`;
73
73
  }
74
74
 
75
- function determineFromExtras(pViolation) {
75
+ export function determineFromExtras(pViolation) {
76
76
  const lViolationType2Formatter = {
77
77
  instability: formatInstabilityFromExtras,
78
78
  };
@@ -132,7 +132,7 @@ export function aggregateViolations(pViolations, pRuleSetUsed) {
132
132
  (pFirst, pSecond) =>
133
133
  Math.sign(pSecond.count - pFirst.count) ||
134
134
  Math.sign(pSecond.ignoredCount - pFirst.ignoredCount) ||
135
- pFirst.name.localeCompare(pSecond.name)
135
+ pFirst.name.localeCompare(pSecond.name),
136
136
  );
137
137
  }
138
138
 
@@ -0,0 +1,184 @@
1
+ export default `<!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>dependency-cruiser output</title>
7
+ <style media="screen">
8
+ html {
9
+ font-family: sans-serif;
10
+ font-size: 10pt;
11
+ }
12
+
13
+ table {
14
+ overflow: hidden;
15
+ }
16
+
17
+ table,
18
+ td.controls {
19
+ transition-duration: 0.3s;
20
+ }
21
+
22
+ table,
23
+ th,
24
+ td {
25
+ border: solid black 1px;
26
+ border-collapse: collapse;
27
+ font-size: inherit;
28
+ }
29
+
30
+ td,
31
+ th {
32
+ position: relative;
33
+ }
34
+
35
+ th {
36
+ text-align: start;
37
+ vertical-align: bottom;
38
+ max-width: 1em;
39
+ max-height: 30em;
40
+ height: 20em;
41
+ font-weight: normal;
42
+ white-space: nowrap;
43
+ overflow: hidden;
44
+ }
45
+
46
+ th div {
47
+ transform: rotateZ(-90deg);
48
+ transform-origin: 0.5em;
49
+ text-align: start;
50
+ height: 1em;
51
+ width: 30em;
52
+ white-space: nowrap;
53
+ overflow: hidden;
54
+ text-overflow: ellipsis;
55
+ }
56
+
57
+ td {
58
+ text-align: center;
59
+ }
60
+
61
+ td.first-cell {
62
+ text-align: left;
63
+ white-space: nowrap;
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ }
67
+
68
+ td.top-left {
69
+ border-top: solid 1px transparent;
70
+ border-left: solid 1px transparent;
71
+ }
72
+
73
+ td.top-right {
74
+ border-top: solid 1px transparent;
75
+ border-right: solid 1px transparent;
76
+ }
77
+
78
+ td.bottom-left {
79
+ border-bottom: solid 1px transparent;
80
+ border-left: solid 1px transparent;
81
+ }
82
+
83
+ td.bottom-right {
84
+ border-bottom: solid 1px transparent;
85
+ border-right: solid 1px transparent;
86
+ }
87
+
88
+ tbody tr:hover {
89
+ background-color: lightgrey;
90
+ }
91
+
92
+ td:hover::after,
93
+ td:focus::after,
94
+ th:hover::after,
95
+ th:focus::after {
96
+ background-color: #00000077;
97
+ content: "";
98
+ height: 5000px;
99
+ left: 0;
100
+ position: absolute;
101
+ top: -2500px;
102
+ width: 100%;
103
+ z-index: -1;
104
+ }
105
+
106
+ #table-rotated:target {
107
+ transform: rotateZ(45deg);
108
+ transform-origin: bottom left;
109
+ }
110
+
111
+ #table-rotated:target #unrotate {
112
+ opacity: 1;
113
+ }
114
+
115
+ #table-rotated:target #rotate {
116
+ opacity: 0;
117
+ }
118
+
119
+ #unrotate {
120
+ opacity: 0;
121
+ }
122
+
123
+ #rotate {
124
+ opacity: 1;
125
+ }
126
+
127
+ .controls {
128
+ opacity: 0.2;
129
+ vertical-align: bottom;
130
+ padding: 0.5em;
131
+ }
132
+
133
+ .controls:hover {
134
+ opacity: 1;
135
+ }
136
+
137
+ .controls a {
138
+ font-style: normal;
139
+ text-decoration: none;
140
+ background-color: #eee;
141
+ padding: 0.2em 0.5em 0.2em 0.5em;
142
+ }
143
+
144
+ .cell-core-module {
145
+ color: grey;
146
+ font-style: italic;
147
+ }
148
+
149
+ .cell-unresolvable-module {
150
+ color: red;
151
+ font-style: italic;
152
+ }
153
+
154
+ .cell-true {
155
+ background-color: black;
156
+ opacity: 0.5;
157
+ }
158
+
159
+ .cell-false {
160
+ background-color: white;
161
+ opacity: 0.5;
162
+ }
163
+
164
+ .cell-error {
165
+ background-color: red;
166
+ opacity: 0.5;
167
+ }
168
+
169
+ .cell-warn {
170
+ background-color: orange;
171
+ opacity: 0.5;
172
+ }
173
+
174
+ .cell-info {
175
+ background-color: blue;
176
+ opacity: 0.5;
177
+ }
178
+ </style>
179
+ </head>
180
+
181
+ <body>
182
+ {{table-here}}
183
+ </body>
184
+ </html>`;