apex-code-coverage-transformer 2.18.2 → 2.19.0
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/CHANGELOG.md +14 -0
- package/README.md +71 -24
- package/lib/handlers/BaseHandler.d.ts +2 -2
- package/lib/handlers/BaseHandler.js.map +1 -1
- package/lib/handlers/clover.js +1 -3
- package/lib/handlers/clover.js.map +1 -1
- package/lib/handlers/cobertura.js +1 -3
- package/lib/handlers/cobertura.js.map +1 -1
- package/lib/handlers/getHandler.d.ts +2 -0
- package/lib/handlers/getHandler.js +2 -0
- package/lib/handlers/getHandler.js.map +1 -1
- package/lib/handlers/githubActions.d.ts +33 -0
- package/lib/handlers/githubActions.js +82 -0
- package/lib/handlers/githubActions.js.map +1 -0
- package/lib/handlers/istanbulJson.d.ts +1 -1
- package/lib/handlers/istanbulJson.js +1 -1
- package/lib/handlers/istanbulJson.js.map +1 -1
- package/lib/handlers/jacoco.d.ts +1 -1
- package/lib/handlers/jacoco.js +1 -1
- package/lib/handlers/jacoco.js.map +1 -1
- package/lib/handlers/lcov.d.ts +1 -1
- package/lib/handlers/lcov.js +2 -4
- package/lib/handlers/lcov.js.map +1 -1
- package/lib/handlers/markdown.d.ts +28 -0
- package/lib/handlers/markdown.js +105 -0
- package/lib/handlers/markdown.js.map +1 -0
- package/lib/handlers/sonar.js +1 -3
- package/lib/handlers/sonar.js.map +1 -1
- package/lib/transformers/generators/generateGitHubActions.d.ts +2 -0
- package/lib/transformers/generators/generateGitHubActions.js +27 -0
- package/lib/transformers/generators/generateGitHubActions.js.map +1 -0
- package/lib/transformers/generators/generateHtml.d.ts +2 -0
- package/lib/transformers/generators/generateHtml.js +399 -0
- package/lib/transformers/generators/generateHtml.js.map +1 -0
- package/lib/transformers/generators/generateMarkdown.d.ts +2 -0
- package/lib/transformers/generators/generateMarkdown.js +39 -0
- package/lib/transformers/generators/generateMarkdown.js.map +1 -0
- package/lib/transformers/reportGenerator.d.ts +2 -2
- package/lib/transformers/reportGenerator.js +28 -449
- package/lib/transformers/reportGenerator.js.map +1 -1
- package/lib/utils/constants.d.ts +17 -0
- package/lib/utils/constants.js +31 -0
- package/lib/utils/constants.js.map +1 -1
- package/lib/utils/types.d.ts +48 -1
- package/messages/transformer.transform.md +2 -0
- package/oclif.manifest.json +5 -1
- package/package.json +30 -18
- package/oclif.lock +0 -10078
|
@@ -2,39 +2,31 @@ import { writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { extname, basename, dirname, join } from 'node:path';
|
|
3
3
|
import XMLBuilder from 'fast-xml-builder';
|
|
4
4
|
import { HandlerRegistry } from '../handlers/HandlerRegistry.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
parseTagValue: false,
|
|
10
|
-
parseNodeValue: false,
|
|
11
|
-
parseAttributeValue: false,
|
|
12
|
-
trimValues: true,
|
|
13
|
-
processEntities: false,
|
|
14
|
-
format: true,
|
|
15
|
-
indentBy: ' ',
|
|
16
|
-
suppressBooleanAttributes: false,
|
|
17
|
-
suppressEmptyNode: true,
|
|
18
|
-
};
|
|
19
|
-
const XML_HEADER_CONFIG = {
|
|
20
|
-
cobertura: {
|
|
21
|
-
xmlDecl: '<?xml version="1.0" ?>',
|
|
22
|
-
doctype: '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">',
|
|
23
|
-
},
|
|
24
|
-
clover: {
|
|
25
|
-
xmlDecl: '<?xml version="1.0" encoding="UTF-8"?>',
|
|
26
|
-
},
|
|
27
|
-
jacoco: {
|
|
28
|
-
xmlDecl: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
|
|
29
|
-
doctype: '<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN" "report.dtd">',
|
|
30
|
-
},
|
|
31
|
-
opencover: {
|
|
32
|
-
xmlDecl: '<?xml version="1.0" encoding="utf-8"?>',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
5
|
+
import { builderOptions, XML_HEADER_CONFIG } from '../utils/constants.js';
|
|
6
|
+
import { generateHtml } from './generators/generateHtml.js';
|
|
7
|
+
import { generateMarkdown } from './generators/generateMarkdown.js';
|
|
8
|
+
import { generateGitHubActions } from './generators/generateGitHubActions.js';
|
|
35
9
|
function isXmlReportFormat(format) {
|
|
36
10
|
return format in XML_HEADER_CONFIG;
|
|
37
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Dispatch table for formats whose final content is plain text or JSON.
|
|
14
|
+
*
|
|
15
|
+
* The format string is validated at the CLI flag level via the
|
|
16
|
+
* `HandlerRegistry`, and each handler emits the matching coverage object
|
|
17
|
+
* shape, so a runtime cast is safe here. Centralising the dispatch keeps
|
|
18
|
+
* `generateReportContent` to a single decision point and avoids a long
|
|
19
|
+
* chain of `format === ... && isXObject(...)` guards.
|
|
20
|
+
*/
|
|
21
|
+
const STRING_FORMAT_RENDERERS = {
|
|
22
|
+
lcovonly: (obj) => generateLcov(obj),
|
|
23
|
+
html: (obj) => generateHtml(obj),
|
|
24
|
+
markdown: (obj) => generateMarkdown(obj),
|
|
25
|
+
'github-actions': (obj) => generateGitHubActions(obj),
|
|
26
|
+
json: (obj) => JSON.stringify(obj, null, 2),
|
|
27
|
+
'json-summary': (obj) => JSON.stringify(obj, null, 2),
|
|
28
|
+
simplecov: (obj) => JSON.stringify(obj, null, 2),
|
|
29
|
+
};
|
|
38
30
|
export async function generateAndWriteReport(outputPath, coverageObj, format, formatAmount) {
|
|
39
31
|
const content = generateReportContent(coverageObj, format);
|
|
40
32
|
const extension = HandlerRegistry.getExtension(format);
|
|
@@ -46,26 +38,17 @@ export async function generateAndWriteReport(outputPath, coverageObj, format, fo
|
|
|
46
38
|
return filePath;
|
|
47
39
|
}
|
|
48
40
|
function generateReportContent(coverageObj, format) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return generateHtml(coverageObj);
|
|
54
|
-
}
|
|
55
|
-
if (format === 'json' || format === 'json-summary' || format === 'simplecov') {
|
|
56
|
-
return JSON.stringify(coverageObj, null, 2);
|
|
57
|
-
}
|
|
41
|
+
const renderer = STRING_FORMAT_RENDERERS[format];
|
|
42
|
+
return renderer ? renderer(coverageObj) : generateXmlContent(coverageObj, format);
|
|
43
|
+
}
|
|
44
|
+
function generateXmlContent(coverageObj, format) {
|
|
58
45
|
const isHeadless = isXmlReportFormat(format);
|
|
59
|
-
const builder = new XMLBuilder(
|
|
60
|
-
...JSON_PARSER_OPTION,
|
|
61
|
-
attributeNamePrefix: '@',
|
|
62
|
-
});
|
|
46
|
+
const builder = new XMLBuilder(builderOptions);
|
|
63
47
|
let xml = builder.build(coverageObj);
|
|
64
48
|
if (isHeadless) {
|
|
65
49
|
xml = xml.replace(/^<\?xml[^>]*>\s*/i, '');
|
|
66
50
|
}
|
|
67
|
-
|
|
68
|
-
return finalXml;
|
|
51
|
+
return prependXmlHeader(xml, format).trimEnd();
|
|
69
52
|
}
|
|
70
53
|
function generateLcov(coverageObj) {
|
|
71
54
|
return coverageObj.files
|
|
@@ -95,408 +78,4 @@ function prependXmlHeader(xml, format) {
|
|
|
95
78
|
export function getExtensionForFormat(format) {
|
|
96
79
|
return HandlerRegistry.getExtension(format);
|
|
97
80
|
}
|
|
98
|
-
function isLcovCoverageObject(obj) {
|
|
99
|
-
return typeof obj === 'object' && obj !== null && 'files' in obj;
|
|
100
|
-
}
|
|
101
|
-
function isHtmlCoverageObject(obj) {
|
|
102
|
-
return typeof obj === 'object' && obj !== null && 'summary' in obj && 'files' in obj;
|
|
103
|
-
}
|
|
104
|
-
function getCoverageColor(lineRate) {
|
|
105
|
-
if (lineRate >= 0.8)
|
|
106
|
-
return '#4caf50';
|
|
107
|
-
if (lineRate >= 0.6)
|
|
108
|
-
return '#ff9800';
|
|
109
|
-
return '#f44336';
|
|
110
|
-
}
|
|
111
|
-
function formatPercent(lineRate) {
|
|
112
|
-
return (lineRate * 100).toFixed(2);
|
|
113
|
-
}
|
|
114
|
-
function buildPackageSummaryRows(packageSummaries) {
|
|
115
|
-
if (packageSummaries.length === 0)
|
|
116
|
-
return '';
|
|
117
|
-
return packageSummaries
|
|
118
|
-
.map((pkg) => {
|
|
119
|
-
const pkgPercent = formatPercent(pkg.lineRate);
|
|
120
|
-
const pkgColor = getCoverageColor(pkg.lineRate);
|
|
121
|
-
return `<tr>
|
|
122
|
-
<td class="package-dir">${escapeHtml(pkg.directory)}</td>
|
|
123
|
-
<td class="package-stat">${pkg.fileCount}</td>
|
|
124
|
-
<td class="package-stat">${pkg.totalLines}</td>
|
|
125
|
-
<td class="package-stat">${pkg.coveredLines}</td>
|
|
126
|
-
<td class="package-stat">${pkg.uncoveredLines}</td>
|
|
127
|
-
<td class="package-pct" style="color: ${pkgColor}">${pkgPercent}%</td>
|
|
128
|
-
<td><span class="coverage-bar" style="background-color: ${pkgColor}; width: ${pkgPercent}%"></span></td>
|
|
129
|
-
</tr>`;
|
|
130
|
-
})
|
|
131
|
-
.join('\n');
|
|
132
|
-
}
|
|
133
|
-
function groupFilesByDir(files) {
|
|
134
|
-
const filesByDir = new Map();
|
|
135
|
-
for (const file of files) {
|
|
136
|
-
const dir = file.filePath.split('/')[0];
|
|
137
|
-
const list = filesByDir.get(dir) ?? [];
|
|
138
|
-
list.push(file);
|
|
139
|
-
filesByDir.set(dir, list);
|
|
140
|
-
}
|
|
141
|
-
return filesByDir;
|
|
142
|
-
}
|
|
143
|
-
function buildLineRow(line) {
|
|
144
|
-
const lineClass = line.covered ? 'covered' : 'uncovered';
|
|
145
|
-
const lineColor = line.covered ? '#c8e6c9' : '#ffcdd2';
|
|
146
|
-
const codeContent = line.content !== undefined ? escapeHtml(line.content) : '';
|
|
147
|
-
return `<tr class="${lineClass}" style="background-color: ${lineColor}">
|
|
148
|
-
<td class="line-number">${line.lineNumber}</td>
|
|
149
|
-
<td class="hit-count">${line.hitCount}</td>
|
|
150
|
-
<td class="line-content">${codeContent}</td>
|
|
151
|
-
</tr>`;
|
|
152
|
-
}
|
|
153
|
-
function buildFileSection(file) {
|
|
154
|
-
const filePercent = formatPercent(file.lineRate);
|
|
155
|
-
const fileColor = getCoverageColor(file.lineRate);
|
|
156
|
-
const lineDetails = file.lines.map(buildLineRow).join('\n');
|
|
157
|
-
const fileId = file.filePath.replace(/[^a-zA-Z0-9]/g, '-');
|
|
158
|
-
const escapedPath = file.filePath.replace(/'/g, "\\'");
|
|
159
|
-
return `
|
|
160
|
-
<div class="file-section">
|
|
161
|
-
<h3 class="file-header" onclick="toggleFile('${escapedPath}')">
|
|
162
|
-
<span class="file-name">${escapeHtml(file.filePath)}</span>
|
|
163
|
-
<span class="file-stats">
|
|
164
|
-
${file.coveredLines}/${file.totalLines} lines (${filePercent}%)
|
|
165
|
-
<span class="coverage-bar" style="background-color: ${fileColor}; width: ${filePercent}%"></span>
|
|
166
|
-
</span>
|
|
167
|
-
</h3>
|
|
168
|
-
<div id="file-${fileId}" class="file-details" style="display: none;">
|
|
169
|
-
<table class="line-coverage">
|
|
170
|
-
<thead>
|
|
171
|
-
<tr>
|
|
172
|
-
<th>Line</th>
|
|
173
|
-
<th>Hits</th>
|
|
174
|
-
<th>Code</th>
|
|
175
|
-
</tr>
|
|
176
|
-
</thead>
|
|
177
|
-
<tbody>
|
|
178
|
-
${lineDetails}
|
|
179
|
-
</tbody>
|
|
180
|
-
</table>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
`;
|
|
184
|
-
}
|
|
185
|
-
function buildFileRows(files) {
|
|
186
|
-
const filesByDir = groupFilesByDir(files);
|
|
187
|
-
const sortedDirs = [...filesByDir.keys()].sort((a, b) => a.localeCompare(b));
|
|
188
|
-
return sortedDirs
|
|
189
|
-
.map((dir) => {
|
|
190
|
-
const dirFiles = filesByDir.get(dir);
|
|
191
|
-
const dirFileSections = dirFiles.map(buildFileSection).join('\n');
|
|
192
|
-
return `
|
|
193
|
-
<div class="package-files-group">
|
|
194
|
-
<h3 class="package-dir-header">${escapeHtml(dir)}/</h3>
|
|
195
|
-
${dirFileSections}
|
|
196
|
-
</div>
|
|
197
|
-
`;
|
|
198
|
-
})
|
|
199
|
-
.join('\n');
|
|
200
|
-
}
|
|
201
|
-
function generateHtml(coverageObj) {
|
|
202
|
-
const { summary, packageSummaries, files } = coverageObj;
|
|
203
|
-
const coveragePercent = formatPercent(summary.lineRate);
|
|
204
|
-
const coverageColor = getCoverageColor(summary.lineRate);
|
|
205
|
-
const packageSummaryRows = buildPackageSummaryRows(packageSummaries);
|
|
206
|
-
const fileRows = buildFileRows(files);
|
|
207
|
-
return `<!DOCTYPE html>
|
|
208
|
-
<html lang="en">
|
|
209
|
-
<head>
|
|
210
|
-
<meta charset="UTF-8">
|
|
211
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
212
|
-
<title>Code Coverage Report</title>
|
|
213
|
-
<style>
|
|
214
|
-
* {
|
|
215
|
-
margin: 0;
|
|
216
|
-
padding: 0;
|
|
217
|
-
box-sizing: border-box;
|
|
218
|
-
}
|
|
219
|
-
body {
|
|
220
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
221
|
-
line-height: 1.6;
|
|
222
|
-
color: #333;
|
|
223
|
-
background-color: #f5f5f5;
|
|
224
|
-
padding: 20px;
|
|
225
|
-
}
|
|
226
|
-
.container {
|
|
227
|
-
max-width: 1200px;
|
|
228
|
-
margin: 0 auto;
|
|
229
|
-
background: white;
|
|
230
|
-
border-radius: 8px;
|
|
231
|
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
232
|
-
padding: 30px;
|
|
233
|
-
}
|
|
234
|
-
h1 {
|
|
235
|
-
color: #2c3e50;
|
|
236
|
-
margin-bottom: 30px;
|
|
237
|
-
border-bottom: 3px solid #3498db;
|
|
238
|
-
padding-bottom: 10px;
|
|
239
|
-
}
|
|
240
|
-
.summary {
|
|
241
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
242
|
-
color: white;
|
|
243
|
-
padding: 25px;
|
|
244
|
-
border-radius: 8px;
|
|
245
|
-
margin-bottom: 30px;
|
|
246
|
-
}
|
|
247
|
-
.summary h2 {
|
|
248
|
-
margin-bottom: 15px;
|
|
249
|
-
font-size: 1.5em;
|
|
250
|
-
}
|
|
251
|
-
.summary-stats {
|
|
252
|
-
display: grid;
|
|
253
|
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
254
|
-
gap: 20px;
|
|
255
|
-
margin-top: 15px;
|
|
256
|
-
}
|
|
257
|
-
.stat-item {
|
|
258
|
-
background: rgba(255, 255, 255, 0.2);
|
|
259
|
-
padding: 15px;
|
|
260
|
-
border-radius: 6px;
|
|
261
|
-
}
|
|
262
|
-
.stat-label {
|
|
263
|
-
font-size: 0.9em;
|
|
264
|
-
opacity: 0.9;
|
|
265
|
-
margin-bottom: 5px;
|
|
266
|
-
}
|
|
267
|
-
.stat-value {
|
|
268
|
-
font-size: 1.8em;
|
|
269
|
-
font-weight: bold;
|
|
270
|
-
}
|
|
271
|
-
.coverage-percent {
|
|
272
|
-
font-size: 3em;
|
|
273
|
-
font-weight: bold;
|
|
274
|
-
margin: 10px 0;
|
|
275
|
-
}
|
|
276
|
-
.package-files-group {
|
|
277
|
-
margin-bottom: 28px;
|
|
278
|
-
}
|
|
279
|
-
.package-dir-header {
|
|
280
|
-
font-size: 1.1em;
|
|
281
|
-
color: #2c3e50;
|
|
282
|
-
margin-bottom: 12px;
|
|
283
|
-
padding-bottom: 6px;
|
|
284
|
-
border-bottom: 2px solid #3498db;
|
|
285
|
-
font-weight: 600;
|
|
286
|
-
}
|
|
287
|
-
.file-section {
|
|
288
|
-
margin-bottom: 20px;
|
|
289
|
-
border: 1px solid #ddd;
|
|
290
|
-
border-radius: 6px;
|
|
291
|
-
overflow: hidden;
|
|
292
|
-
}
|
|
293
|
-
.file-header {
|
|
294
|
-
background: #f8f9fa;
|
|
295
|
-
padding: 15px;
|
|
296
|
-
cursor: pointer;
|
|
297
|
-
display: flex;
|
|
298
|
-
justify-content: space-between;
|
|
299
|
-
align-items: center;
|
|
300
|
-
transition: background-color 0.2s;
|
|
301
|
-
}
|
|
302
|
-
.file-header:hover {
|
|
303
|
-
background: #e9ecef;
|
|
304
|
-
}
|
|
305
|
-
.file-name {
|
|
306
|
-
font-weight: 600;
|
|
307
|
-
color: #2c3e50;
|
|
308
|
-
}
|
|
309
|
-
.file-stats {
|
|
310
|
-
display: flex;
|
|
311
|
-
align-items: center;
|
|
312
|
-
gap: 10px;
|
|
313
|
-
}
|
|
314
|
-
.coverage-bar {
|
|
315
|
-
height: 20px;
|
|
316
|
-
min-width: 100px;
|
|
317
|
-
border-radius: 4px;
|
|
318
|
-
display: inline-block;
|
|
319
|
-
}
|
|
320
|
-
.file-details {
|
|
321
|
-
padding: 0;
|
|
322
|
-
}
|
|
323
|
-
.line-coverage {
|
|
324
|
-
width: 100%;
|
|
325
|
-
border-collapse: collapse;
|
|
326
|
-
font-family: 'Courier New', monospace;
|
|
327
|
-
font-size: 0.9em;
|
|
328
|
-
}
|
|
329
|
-
.line-coverage thead {
|
|
330
|
-
background: #34495e;
|
|
331
|
-
color: white;
|
|
332
|
-
}
|
|
333
|
-
.line-coverage th {
|
|
334
|
-
padding: 10px;
|
|
335
|
-
text-align: left;
|
|
336
|
-
font-weight: 600;
|
|
337
|
-
}
|
|
338
|
-
.line-coverage td {
|
|
339
|
-
padding: 5px 10px;
|
|
340
|
-
border-bottom: 1px solid #eee;
|
|
341
|
-
}
|
|
342
|
-
.line-number {
|
|
343
|
-
text-align: right;
|
|
344
|
-
width: 80px;
|
|
345
|
-
color: #666;
|
|
346
|
-
font-weight: 600;
|
|
347
|
-
}
|
|
348
|
-
.hit-count {
|
|
349
|
-
text-align: right;
|
|
350
|
-
width: 80px;
|
|
351
|
-
color: #666;
|
|
352
|
-
}
|
|
353
|
-
.line-content {
|
|
354
|
-
width: auto;
|
|
355
|
-
white-space: pre;
|
|
356
|
-
}
|
|
357
|
-
.covered {
|
|
358
|
-
background-color: #c8e6c9 !important;
|
|
359
|
-
}
|
|
360
|
-
.uncovered {
|
|
361
|
-
background-color: #ffcdd2 !important;
|
|
362
|
-
}
|
|
363
|
-
.package-summary {
|
|
364
|
-
margin-bottom: 30px;
|
|
365
|
-
}
|
|
366
|
-
.package-summary h2 {
|
|
367
|
-
margin-bottom: 15px;
|
|
368
|
-
color: #2c3e50;
|
|
369
|
-
font-size: 1.25em;
|
|
370
|
-
}
|
|
371
|
-
.package-summary table {
|
|
372
|
-
width: 100%;
|
|
373
|
-
border-collapse: collapse;
|
|
374
|
-
border: 1px solid #ddd;
|
|
375
|
-
border-radius: 6px;
|
|
376
|
-
overflow: hidden;
|
|
377
|
-
}
|
|
378
|
-
.package-summary th {
|
|
379
|
-
background: #34495e;
|
|
380
|
-
color: white;
|
|
381
|
-
padding: 12px;
|
|
382
|
-
text-align: left;
|
|
383
|
-
font-weight: 600;
|
|
384
|
-
}
|
|
385
|
-
.package-summary td {
|
|
386
|
-
padding: 10px 12px;
|
|
387
|
-
border-bottom: 1px solid #eee;
|
|
388
|
-
}
|
|
389
|
-
.package-summary tr:last-child td {
|
|
390
|
-
border-bottom: none;
|
|
391
|
-
}
|
|
392
|
-
.package-summary tr:hover {
|
|
393
|
-
background: #f8f9fa;
|
|
394
|
-
}
|
|
395
|
-
.package-dir {
|
|
396
|
-
font-weight: 600;
|
|
397
|
-
color: #2c3e50;
|
|
398
|
-
}
|
|
399
|
-
.package-stat {
|
|
400
|
-
text-align: right;
|
|
401
|
-
}
|
|
402
|
-
.package-pct {
|
|
403
|
-
font-weight: 600;
|
|
404
|
-
text-align: right;
|
|
405
|
-
}
|
|
406
|
-
.package-summary .coverage-bar {
|
|
407
|
-
display: block;
|
|
408
|
-
min-width: 60px;
|
|
409
|
-
height: 14px;
|
|
410
|
-
border-radius: 4px;
|
|
411
|
-
}
|
|
412
|
-
@media (max-width: 768px) {
|
|
413
|
-
.file-header {
|
|
414
|
-
flex-direction: column;
|
|
415
|
-
align-items: flex-start;
|
|
416
|
-
gap: 10px;
|
|
417
|
-
}
|
|
418
|
-
.summary-stats {
|
|
419
|
-
grid-template-columns: 1fr;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
</style>
|
|
423
|
-
</head>
|
|
424
|
-
<body>
|
|
425
|
-
<div class="container">
|
|
426
|
-
<h1>Code Coverage Report</h1>
|
|
427
|
-
|
|
428
|
-
<div class="summary">
|
|
429
|
-
<h2>Summary</h2>
|
|
430
|
-
<div class="coverage-percent" style="color: ${coverageColor}">${coveragePercent}%</div>
|
|
431
|
-
<div class="summary-stats">
|
|
432
|
-
<div class="stat-item">
|
|
433
|
-
<div class="stat-label">Total Lines</div>
|
|
434
|
-
<div class="stat-value">${summary.totalLines}</div>
|
|
435
|
-
</div>
|
|
436
|
-
<div class="stat-item">
|
|
437
|
-
<div class="stat-label">Covered Lines</div>
|
|
438
|
-
<div class="stat-value">${summary.coveredLines}</div>
|
|
439
|
-
</div>
|
|
440
|
-
<div class="stat-item">
|
|
441
|
-
<div class="stat-label">Uncovered Lines</div>
|
|
442
|
-
<div class="stat-value">${summary.uncoveredLines}</div>
|
|
443
|
-
</div>
|
|
444
|
-
<div class="stat-item">
|
|
445
|
-
<div class="stat-label">Files</div>
|
|
446
|
-
<div class="stat-value">${files.length}</div>
|
|
447
|
-
</div>
|
|
448
|
-
</div>
|
|
449
|
-
</div>
|
|
450
|
-
|
|
451
|
-
${packageSummaryRows
|
|
452
|
-
? `
|
|
453
|
-
<div class="package-summary">
|
|
454
|
-
<h2>Package directory coverage</h2>
|
|
455
|
-
<table>
|
|
456
|
-
<thead>
|
|
457
|
-
<tr>
|
|
458
|
-
<th>Directory</th>
|
|
459
|
-
<th>Files</th>
|
|
460
|
-
<th>Total lines</th>
|
|
461
|
-
<th>Covered</th>
|
|
462
|
-
<th>Uncovered</th>
|
|
463
|
-
<th>Coverage</th>
|
|
464
|
-
<th></th>
|
|
465
|
-
</tr>
|
|
466
|
-
</thead>
|
|
467
|
-
<tbody>
|
|
468
|
-
${packageSummaryRows}
|
|
469
|
-
</tbody>
|
|
470
|
-
</table>
|
|
471
|
-
</div>
|
|
472
|
-
`
|
|
473
|
-
: ''}
|
|
474
|
-
|
|
475
|
-
<h2 style="margin: 30px 0 20px 0; color: #2c3e50;">File Coverage Details</h2>
|
|
476
|
-
|
|
477
|
-
${fileRows}
|
|
478
|
-
</div>
|
|
479
|
-
|
|
480
|
-
<script>
|
|
481
|
-
function toggleFile(filePath) {
|
|
482
|
-
const id = 'file-' + filePath.replace(/[^a-zA-Z0-9]/g, '-');
|
|
483
|
-
const element = document.getElementById(id);
|
|
484
|
-
if (element) {
|
|
485
|
-
element.style.display = element.style.display === 'none' ? 'block' : 'none';
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
</script>
|
|
489
|
-
</body>
|
|
490
|
-
</html>`;
|
|
491
|
-
}
|
|
492
|
-
function escapeHtml(text) {
|
|
493
|
-
const map = {
|
|
494
|
-
'&': '&',
|
|
495
|
-
'<': '<',
|
|
496
|
-
'>': '>',
|
|
497
|
-
'"': '"',
|
|
498
|
-
"'": ''',
|
|
499
|
-
};
|
|
500
|
-
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
501
|
-
}
|
|
502
81
|
//# sourceMappingURL=reportGenerator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportGenerator.js","sourceRoot":"","sources":["../../src/transformers/reportGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,UAAU,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"reportGenerator.js","sourceRoot":"","sources":["../../src/transformers/reportGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,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AC,CAAC;AAC9C,CAAC"}
|
package/lib/utils/constants.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import '../handlers/getHandler.js';
|
|
2
|
+
import { XmlHeaderConfig, XmlReportFormat } from './types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Get available coverage format options.
|
|
4
5
|
* This dynamically retrieves all registered formats from the HandlerRegistry.
|
|
5
6
|
*/
|
|
6
7
|
export declare const formatOptions: string[];
|
|
8
|
+
export declare const builderOptions: {
|
|
9
|
+
commentPropName: string;
|
|
10
|
+
ignoreAttributes: boolean;
|
|
11
|
+
ignoreNameSpace: boolean;
|
|
12
|
+
parseTagValue: boolean;
|
|
13
|
+
parseNodeValue: boolean;
|
|
14
|
+
parseAttributeValue: boolean;
|
|
15
|
+
trimValues: boolean;
|
|
16
|
+
processEntities: boolean;
|
|
17
|
+
format: boolean;
|
|
18
|
+
indentBy: string;
|
|
19
|
+
suppressBooleanAttributes: boolean;
|
|
20
|
+
suppressEmptyNode: boolean;
|
|
21
|
+
attributeNamePrefix: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const XML_HEADER_CONFIG: Record<XmlReportFormat, XmlHeaderConfig>;
|
package/lib/utils/constants.js
CHANGED
|
@@ -6,4 +6,35 @@ import '../handlers/getHandler.js';
|
|
|
6
6
|
* This dynamically retrieves all registered formats from the HandlerRegistry.
|
|
7
7
|
*/
|
|
8
8
|
export const formatOptions = HandlerRegistry.getAvailableFormats();
|
|
9
|
+
export const builderOptions = {
|
|
10
|
+
commentPropName: '#comment',
|
|
11
|
+
ignoreAttributes: false,
|
|
12
|
+
ignoreNameSpace: false,
|
|
13
|
+
parseTagValue: false,
|
|
14
|
+
parseNodeValue: false,
|
|
15
|
+
parseAttributeValue: false,
|
|
16
|
+
trimValues: true,
|
|
17
|
+
processEntities: false,
|
|
18
|
+
format: true,
|
|
19
|
+
indentBy: ' ',
|
|
20
|
+
suppressBooleanAttributes: false,
|
|
21
|
+
suppressEmptyNode: true,
|
|
22
|
+
attributeNamePrefix: '@',
|
|
23
|
+
};
|
|
24
|
+
export const XML_HEADER_CONFIG = {
|
|
25
|
+
cobertura: {
|
|
26
|
+
xmlDecl: '<?xml version="1.0" ?>',
|
|
27
|
+
doctype: '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">',
|
|
28
|
+
},
|
|
29
|
+
clover: {
|
|
30
|
+
xmlDecl: '<?xml version="1.0" encoding="UTF-8"?>',
|
|
31
|
+
},
|
|
32
|
+
jacoco: {
|
|
33
|
+
xmlDecl: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
|
|
34
|
+
doctype: '<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN" "report.dtd">',
|
|
35
|
+
},
|
|
36
|
+
opencover: {
|
|
37
|
+
xmlDecl: '<?xml version="1.0" encoding="utf-8"?>',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
9
40
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,mDAAmD;AACnD,OAAO,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,mDAAmD;AACnD,OAAO,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa,eAAe,CAAC,mBAAmB,EAAE,CAAC;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE,UAAU;IAC3B,gBAAgB,EAAE,KAAK;IACvB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;IACrB,mBAAmB,EAAE,KAAK;IAC1B,UAAU,EAAE,IAAI;IAChB,eAAe,EAAE,KAAK;IACtB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;IACd,yBAAyB,EAAE,KAAK;IAChC,iBAAiB,EAAE,IAAI;IACvB,mBAAmB,EAAE,GAAG;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA6C;IACzE,SAAS,EAAE;QACT,OAAO,EAAE,wBAAwB;QACjC,OAAO,EAAE,mFAAmF;KAC7F;IACD,MAAM,EAAE;QACN,OAAO,EAAE,wCAAwC;KAClD;IACD,MAAM,EAAE;QACN,OAAO,EAAE,yDAAyD;QAClE,OAAO,EAAE,uEAAuE;KACjF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,wCAAwC;KAClD;CACF,CAAC"}
|
package/lib/utils/types.d.ts
CHANGED
|
@@ -155,7 +155,7 @@ export type CloverCoverageObject = {
|
|
|
155
155
|
};
|
|
156
156
|
export type CoverageHandler = {
|
|
157
157
|
processFile(filePath: string, fileName: string, lines: Record<string, number>, sourceContent?: string): void;
|
|
158
|
-
finalize():
|
|
158
|
+
finalize(): AnyCoverageObject;
|
|
159
159
|
};
|
|
160
160
|
type LcovLine = {
|
|
161
161
|
lineNumber: number;
|
|
@@ -344,4 +344,51 @@ export type HtmlCoverageObject = {
|
|
|
344
344
|
packageSummaries: HtmlPackageSummary[];
|
|
345
345
|
files: HtmlFileCoverage[];
|
|
346
346
|
};
|
|
347
|
+
export type MarkdownPackageRow = {
|
|
348
|
+
directory: string;
|
|
349
|
+
fileCount: number;
|
|
350
|
+
totalLines: number;
|
|
351
|
+
coveredLines: number;
|
|
352
|
+
uncoveredLines: number;
|
|
353
|
+
lineRate: number;
|
|
354
|
+
};
|
|
355
|
+
export type MarkdownFileRow = {
|
|
356
|
+
filePath: string;
|
|
357
|
+
totalLines: number;
|
|
358
|
+
coveredLines: number;
|
|
359
|
+
uncoveredLines: number;
|
|
360
|
+
lineRate: number;
|
|
361
|
+
};
|
|
362
|
+
export type MarkdownCoverageObject = {
|
|
363
|
+
summary: {
|
|
364
|
+
totalLines: number;
|
|
365
|
+
coveredLines: number;
|
|
366
|
+
uncoveredLines: number;
|
|
367
|
+
lineRate: number;
|
|
368
|
+
fileCount: number;
|
|
369
|
+
};
|
|
370
|
+
packages: MarkdownPackageRow[];
|
|
371
|
+
files: MarkdownFileRow[];
|
|
372
|
+
};
|
|
373
|
+
export type GitHubActionsUncoveredLine = {
|
|
374
|
+
filePath: string;
|
|
375
|
+
lineNumber: number;
|
|
376
|
+
};
|
|
377
|
+
export type GitHubActionsCoverageObject = {
|
|
378
|
+
summary: {
|
|
379
|
+
totalLines: number;
|
|
380
|
+
coveredLines: number;
|
|
381
|
+
uncoveredLines: number;
|
|
382
|
+
lineRate: number;
|
|
383
|
+
fileCount: number;
|
|
384
|
+
};
|
|
385
|
+
uncoveredLines: GitHubActionsUncoveredLine[];
|
|
386
|
+
};
|
|
387
|
+
/** Union of every format-specific coverage object the report generator can emit. */
|
|
388
|
+
export type AnyCoverageObject = SonarCoverageObject | CoberturaCoverageObject | CloverCoverageObject | LcovCoverageObject | JaCoCoCoverageObject | IstanbulCoverageObject | JsonSummaryCoverageObject | SimpleCovCoverageObject | OpenCoverCoverageObject | HtmlCoverageObject | MarkdownCoverageObject | GitHubActionsCoverageObject;
|
|
389
|
+
export type XmlReportFormat = 'cobertura' | 'clover' | 'jacoco' | 'opencover';
|
|
390
|
+
export type XmlHeaderConfig = {
|
|
391
|
+
xmlDecl: string;
|
|
392
|
+
doctype?: string;
|
|
393
|
+
};
|
|
347
394
|
export {};
|
|
@@ -12,6 +12,8 @@ Transform Salesforce Apex code coverage JSONs created during deployments and tes
|
|
|
12
12
|
- `sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "cobertura"`
|
|
13
13
|
- `sf acc-transformer transform -j "coverage.json" -r "coverage.xml" -f "clover"`
|
|
14
14
|
- `sf acc-transformer transform -j "coverage.json" -r "coverage.info" -f "lcovonly"`
|
|
15
|
+
- `sf acc-transformer transform -j "coverage.json" -r "coverage.md" -f "markdown"`
|
|
16
|
+
- `sf acc-transformer transform -j "coverage.json" -r "coverage.txt" -f "github-actions"`
|
|
15
17
|
- `sf acc-transformer transform -j "coverage.json" -i "force-app"`
|
|
16
18
|
|
|
17
19
|
# flags.coverage-json.summary
|