apex-code-coverage-transformer 2.18.1 → 2.18.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.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -2
- 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/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/sonar.js +1 -3
- package/lib/handlers/sonar.js.map +1 -1
- package/lib/transformers/generators/generateHtml.d.ts +3 -0
- package/lib/transformers/generators/generateHtml.js +402 -0
- package/lib/transformers/generators/generateHtml.js.map +1 -0
- package/lib/transformers/reportGenerator.d.ts +2 -2
- package/lib/transformers/reportGenerator.js +5 -439
- 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 +8 -1
- package/oclif.lock +565 -1275
- package/oclif.manifest.json +1 -1
- package/package.json +9 -12
|
@@ -1,37 +1,9 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import { extname, basename, dirname, join } from 'node:path';
|
|
3
|
-
import
|
|
3
|
+
import XMLBuilder from 'fast-xml-builder';
|
|
4
4
|
import { HandlerRegistry } from '../handlers/HandlerRegistry.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ignoreAttributes: false,
|
|
8
|
-
ignoreNameSpace: false,
|
|
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, isHtmlCoverageObject } from './generators/generateHtml.js';
|
|
35
7
|
function isXmlReportFormat(format) {
|
|
36
8
|
return format in XML_HEADER_CONFIG;
|
|
37
9
|
}
|
|
@@ -56,10 +28,7 @@ function generateReportContent(coverageObj, format) {
|
|
|
56
28
|
return JSON.stringify(coverageObj, null, 2);
|
|
57
29
|
}
|
|
58
30
|
const isHeadless = isXmlReportFormat(format);
|
|
59
|
-
const builder = new XMLBuilder(
|
|
60
|
-
...JSON_PARSER_OPTION,
|
|
61
|
-
attributeNamePrefix: '@',
|
|
62
|
-
});
|
|
31
|
+
const builder = new XMLBuilder(builderOptions);
|
|
63
32
|
let xml = builder.build(coverageObj);
|
|
64
33
|
if (isHeadless) {
|
|
65
34
|
xml = xml.replace(/^<\?xml[^>]*>\s*/i, '');
|
|
@@ -90,9 +59,7 @@ function prependXmlHeader(xml, format) {
|
|
|
90
59
|
// Remove any existing XML declaration to avoid duplicates
|
|
91
60
|
const stripped = xml.replace(/^<\?xml[^>]*>\s*/i, '');
|
|
92
61
|
const config = isXmlReportFormat(format) ? XML_HEADER_CONFIG[format] : undefined;
|
|
93
|
-
return [config?.xmlDecl ?? '<?xml version="1.0"?>', config?.doctype, stripped]
|
|
94
|
-
.filter(Boolean)
|
|
95
|
-
.join('\n');
|
|
62
|
+
return [config?.xmlDecl ?? '<?xml version="1.0"?>', config?.doctype, stripped].filter(Boolean).join('\n');
|
|
96
63
|
}
|
|
97
64
|
export function getExtensionForFormat(format) {
|
|
98
65
|
return HandlerRegistry.getExtension(format);
|
|
@@ -100,405 +67,4 @@ export function getExtensionForFormat(format) {
|
|
|
100
67
|
function isLcovCoverageObject(obj) {
|
|
101
68
|
return typeof obj === 'object' && obj !== null && 'files' in obj;
|
|
102
69
|
}
|
|
103
|
-
function isHtmlCoverageObject(obj) {
|
|
104
|
-
return typeof obj === 'object' && obj !== null && 'summary' in obj && 'files' in obj;
|
|
105
|
-
}
|
|
106
|
-
function getCoverageColor(lineRate) {
|
|
107
|
-
if (lineRate >= 0.8)
|
|
108
|
-
return '#4caf50';
|
|
109
|
-
if (lineRate >= 0.6)
|
|
110
|
-
return '#ff9800';
|
|
111
|
-
return '#f44336';
|
|
112
|
-
}
|
|
113
|
-
function formatPercent(lineRate) {
|
|
114
|
-
return (lineRate * 100).toFixed(2);
|
|
115
|
-
}
|
|
116
|
-
function buildPackageSummaryRows(packageSummaries) {
|
|
117
|
-
if (packageSummaries.length === 0)
|
|
118
|
-
return '';
|
|
119
|
-
return packageSummaries
|
|
120
|
-
.map((pkg) => {
|
|
121
|
-
const pkgPercent = formatPercent(pkg.lineRate);
|
|
122
|
-
const pkgColor = getCoverageColor(pkg.lineRate);
|
|
123
|
-
return `<tr>
|
|
124
|
-
<td class="package-dir">${escapeHtml(pkg.directory)}</td>
|
|
125
|
-
<td class="package-stat">${pkg.fileCount}</td>
|
|
126
|
-
<td class="package-stat">${pkg.totalLines}</td>
|
|
127
|
-
<td class="package-stat">${pkg.coveredLines}</td>
|
|
128
|
-
<td class="package-stat">${pkg.uncoveredLines}</td>
|
|
129
|
-
<td class="package-pct" style="color: ${pkgColor}">${pkgPercent}%</td>
|
|
130
|
-
<td><span class="coverage-bar" style="background-color: ${pkgColor}; width: ${pkgPercent}%"></span></td>
|
|
131
|
-
</tr>`;
|
|
132
|
-
})
|
|
133
|
-
.join('\n');
|
|
134
|
-
}
|
|
135
|
-
function groupFilesByDir(files) {
|
|
136
|
-
const filesByDir = new Map();
|
|
137
|
-
for (const file of files) {
|
|
138
|
-
const dir = file.filePath.split('/')[0];
|
|
139
|
-
const list = filesByDir.get(dir) ?? [];
|
|
140
|
-
list.push(file);
|
|
141
|
-
filesByDir.set(dir, list);
|
|
142
|
-
}
|
|
143
|
-
return filesByDir;
|
|
144
|
-
}
|
|
145
|
-
function buildLineRow(line) {
|
|
146
|
-
const lineClass = line.covered ? 'covered' : 'uncovered';
|
|
147
|
-
const lineColor = line.covered ? '#c8e6c9' : '#ffcdd2';
|
|
148
|
-
const codeContent = line.content !== undefined ? escapeHtml(line.content) : '';
|
|
149
|
-
return `<tr class="${lineClass}" style="background-color: ${lineColor}">
|
|
150
|
-
<td class="line-number">${line.lineNumber}</td>
|
|
151
|
-
<td class="hit-count">${line.hitCount}</td>
|
|
152
|
-
<td class="line-content">${codeContent}</td>
|
|
153
|
-
</tr>`;
|
|
154
|
-
}
|
|
155
|
-
function buildFileSection(file) {
|
|
156
|
-
const filePercent = formatPercent(file.lineRate);
|
|
157
|
-
const fileColor = getCoverageColor(file.lineRate);
|
|
158
|
-
const lineDetails = file.lines.map(buildLineRow).join('\n');
|
|
159
|
-
const fileId = file.filePath.replace(/[^a-zA-Z0-9]/g, '-');
|
|
160
|
-
const escapedPath = file.filePath.replace(/'/g, "\\'");
|
|
161
|
-
return `
|
|
162
|
-
<div class="file-section">
|
|
163
|
-
<h3 class="file-header" onclick="toggleFile('${escapedPath}')">
|
|
164
|
-
<span class="file-name">${escapeHtml(file.filePath)}</span>
|
|
165
|
-
<span class="file-stats">
|
|
166
|
-
${file.coveredLines}/${file.totalLines} lines (${filePercent}%)
|
|
167
|
-
<span class="coverage-bar" style="background-color: ${fileColor}; width: ${filePercent}%"></span>
|
|
168
|
-
</span>
|
|
169
|
-
</h3>
|
|
170
|
-
<div id="file-${fileId}" class="file-details" style="display: none;">
|
|
171
|
-
<table class="line-coverage">
|
|
172
|
-
<thead>
|
|
173
|
-
<tr>
|
|
174
|
-
<th>Line</th>
|
|
175
|
-
<th>Hits</th>
|
|
176
|
-
<th>Code</th>
|
|
177
|
-
</tr>
|
|
178
|
-
</thead>
|
|
179
|
-
<tbody>
|
|
180
|
-
${lineDetails}
|
|
181
|
-
</tbody>
|
|
182
|
-
</table>
|
|
183
|
-
</div>
|
|
184
|
-
</div>
|
|
185
|
-
`;
|
|
186
|
-
}
|
|
187
|
-
function buildFileRows(files) {
|
|
188
|
-
const filesByDir = groupFilesByDir(files);
|
|
189
|
-
const sortedDirs = [...filesByDir.keys()].sort((a, b) => a.localeCompare(b));
|
|
190
|
-
return sortedDirs
|
|
191
|
-
.map((dir) => {
|
|
192
|
-
const dirFiles = filesByDir.get(dir);
|
|
193
|
-
const dirFileSections = dirFiles.map(buildFileSection).join('\n');
|
|
194
|
-
return `
|
|
195
|
-
<div class="package-files-group">
|
|
196
|
-
<h3 class="package-dir-header">${escapeHtml(dir)}/</h3>
|
|
197
|
-
${dirFileSections}
|
|
198
|
-
</div>
|
|
199
|
-
`;
|
|
200
|
-
})
|
|
201
|
-
.join('\n');
|
|
202
|
-
}
|
|
203
|
-
function generateHtml(coverageObj) {
|
|
204
|
-
const { summary, packageSummaries, files } = coverageObj;
|
|
205
|
-
const coveragePercent = formatPercent(summary.lineRate);
|
|
206
|
-
const coverageColor = getCoverageColor(summary.lineRate);
|
|
207
|
-
const packageSummaryRows = buildPackageSummaryRows(packageSummaries);
|
|
208
|
-
const fileRows = buildFileRows(files);
|
|
209
|
-
return `<!DOCTYPE html>
|
|
210
|
-
<html lang="en">
|
|
211
|
-
<head>
|
|
212
|
-
<meta charset="UTF-8">
|
|
213
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
214
|
-
<title>Code Coverage Report</title>
|
|
215
|
-
<style>
|
|
216
|
-
* {
|
|
217
|
-
margin: 0;
|
|
218
|
-
padding: 0;
|
|
219
|
-
box-sizing: border-box;
|
|
220
|
-
}
|
|
221
|
-
body {
|
|
222
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
223
|
-
line-height: 1.6;
|
|
224
|
-
color: #333;
|
|
225
|
-
background-color: #f5f5f5;
|
|
226
|
-
padding: 20px;
|
|
227
|
-
}
|
|
228
|
-
.container {
|
|
229
|
-
max-width: 1200px;
|
|
230
|
-
margin: 0 auto;
|
|
231
|
-
background: white;
|
|
232
|
-
border-radius: 8px;
|
|
233
|
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
234
|
-
padding: 30px;
|
|
235
|
-
}
|
|
236
|
-
h1 {
|
|
237
|
-
color: #2c3e50;
|
|
238
|
-
margin-bottom: 30px;
|
|
239
|
-
border-bottom: 3px solid #3498db;
|
|
240
|
-
padding-bottom: 10px;
|
|
241
|
-
}
|
|
242
|
-
.summary {
|
|
243
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
244
|
-
color: white;
|
|
245
|
-
padding: 25px;
|
|
246
|
-
border-radius: 8px;
|
|
247
|
-
margin-bottom: 30px;
|
|
248
|
-
}
|
|
249
|
-
.summary h2 {
|
|
250
|
-
margin-bottom: 15px;
|
|
251
|
-
font-size: 1.5em;
|
|
252
|
-
}
|
|
253
|
-
.summary-stats {
|
|
254
|
-
display: grid;
|
|
255
|
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
256
|
-
gap: 20px;
|
|
257
|
-
margin-top: 15px;
|
|
258
|
-
}
|
|
259
|
-
.stat-item {
|
|
260
|
-
background: rgba(255, 255, 255, 0.2);
|
|
261
|
-
padding: 15px;
|
|
262
|
-
border-radius: 6px;
|
|
263
|
-
}
|
|
264
|
-
.stat-label {
|
|
265
|
-
font-size: 0.9em;
|
|
266
|
-
opacity: 0.9;
|
|
267
|
-
margin-bottom: 5px;
|
|
268
|
-
}
|
|
269
|
-
.stat-value {
|
|
270
|
-
font-size: 1.8em;
|
|
271
|
-
font-weight: bold;
|
|
272
|
-
}
|
|
273
|
-
.coverage-percent {
|
|
274
|
-
font-size: 3em;
|
|
275
|
-
font-weight: bold;
|
|
276
|
-
margin: 10px 0;
|
|
277
|
-
}
|
|
278
|
-
.package-files-group {
|
|
279
|
-
margin-bottom: 28px;
|
|
280
|
-
}
|
|
281
|
-
.package-dir-header {
|
|
282
|
-
font-size: 1.1em;
|
|
283
|
-
color: #2c3e50;
|
|
284
|
-
margin-bottom: 12px;
|
|
285
|
-
padding-bottom: 6px;
|
|
286
|
-
border-bottom: 2px solid #3498db;
|
|
287
|
-
font-weight: 600;
|
|
288
|
-
}
|
|
289
|
-
.file-section {
|
|
290
|
-
margin-bottom: 20px;
|
|
291
|
-
border: 1px solid #ddd;
|
|
292
|
-
border-radius: 6px;
|
|
293
|
-
overflow: hidden;
|
|
294
|
-
}
|
|
295
|
-
.file-header {
|
|
296
|
-
background: #f8f9fa;
|
|
297
|
-
padding: 15px;
|
|
298
|
-
cursor: pointer;
|
|
299
|
-
display: flex;
|
|
300
|
-
justify-content: space-between;
|
|
301
|
-
align-items: center;
|
|
302
|
-
transition: background-color 0.2s;
|
|
303
|
-
}
|
|
304
|
-
.file-header:hover {
|
|
305
|
-
background: #e9ecef;
|
|
306
|
-
}
|
|
307
|
-
.file-name {
|
|
308
|
-
font-weight: 600;
|
|
309
|
-
color: #2c3e50;
|
|
310
|
-
}
|
|
311
|
-
.file-stats {
|
|
312
|
-
display: flex;
|
|
313
|
-
align-items: center;
|
|
314
|
-
gap: 10px;
|
|
315
|
-
}
|
|
316
|
-
.coverage-bar {
|
|
317
|
-
height: 20px;
|
|
318
|
-
min-width: 100px;
|
|
319
|
-
border-radius: 4px;
|
|
320
|
-
display: inline-block;
|
|
321
|
-
}
|
|
322
|
-
.file-details {
|
|
323
|
-
padding: 0;
|
|
324
|
-
}
|
|
325
|
-
.line-coverage {
|
|
326
|
-
width: 100%;
|
|
327
|
-
border-collapse: collapse;
|
|
328
|
-
font-family: 'Courier New', monospace;
|
|
329
|
-
font-size: 0.9em;
|
|
330
|
-
}
|
|
331
|
-
.line-coverage thead {
|
|
332
|
-
background: #34495e;
|
|
333
|
-
color: white;
|
|
334
|
-
}
|
|
335
|
-
.line-coverage th {
|
|
336
|
-
padding: 10px;
|
|
337
|
-
text-align: left;
|
|
338
|
-
font-weight: 600;
|
|
339
|
-
}
|
|
340
|
-
.line-coverage td {
|
|
341
|
-
padding: 5px 10px;
|
|
342
|
-
border-bottom: 1px solid #eee;
|
|
343
|
-
}
|
|
344
|
-
.line-number {
|
|
345
|
-
text-align: right;
|
|
346
|
-
width: 80px;
|
|
347
|
-
color: #666;
|
|
348
|
-
font-weight: 600;
|
|
349
|
-
}
|
|
350
|
-
.hit-count {
|
|
351
|
-
text-align: right;
|
|
352
|
-
width: 80px;
|
|
353
|
-
color: #666;
|
|
354
|
-
}
|
|
355
|
-
.line-content {
|
|
356
|
-
width: auto;
|
|
357
|
-
white-space: pre;
|
|
358
|
-
}
|
|
359
|
-
.covered {
|
|
360
|
-
background-color: #c8e6c9 !important;
|
|
361
|
-
}
|
|
362
|
-
.uncovered {
|
|
363
|
-
background-color: #ffcdd2 !important;
|
|
364
|
-
}
|
|
365
|
-
.package-summary {
|
|
366
|
-
margin-bottom: 30px;
|
|
367
|
-
}
|
|
368
|
-
.package-summary h2 {
|
|
369
|
-
margin-bottom: 15px;
|
|
370
|
-
color: #2c3e50;
|
|
371
|
-
font-size: 1.25em;
|
|
372
|
-
}
|
|
373
|
-
.package-summary table {
|
|
374
|
-
width: 100%;
|
|
375
|
-
border-collapse: collapse;
|
|
376
|
-
border: 1px solid #ddd;
|
|
377
|
-
border-radius: 6px;
|
|
378
|
-
overflow: hidden;
|
|
379
|
-
}
|
|
380
|
-
.package-summary th {
|
|
381
|
-
background: #34495e;
|
|
382
|
-
color: white;
|
|
383
|
-
padding: 12px;
|
|
384
|
-
text-align: left;
|
|
385
|
-
font-weight: 600;
|
|
386
|
-
}
|
|
387
|
-
.package-summary td {
|
|
388
|
-
padding: 10px 12px;
|
|
389
|
-
border-bottom: 1px solid #eee;
|
|
390
|
-
}
|
|
391
|
-
.package-summary tr:last-child td {
|
|
392
|
-
border-bottom: none;
|
|
393
|
-
}
|
|
394
|
-
.package-summary tr:hover {
|
|
395
|
-
background: #f8f9fa;
|
|
396
|
-
}
|
|
397
|
-
.package-dir {
|
|
398
|
-
font-weight: 600;
|
|
399
|
-
color: #2c3e50;
|
|
400
|
-
}
|
|
401
|
-
.package-stat {
|
|
402
|
-
text-align: right;
|
|
403
|
-
}
|
|
404
|
-
.package-pct {
|
|
405
|
-
font-weight: 600;
|
|
406
|
-
text-align: right;
|
|
407
|
-
}
|
|
408
|
-
.package-summary .coverage-bar {
|
|
409
|
-
display: block;
|
|
410
|
-
min-width: 60px;
|
|
411
|
-
height: 14px;
|
|
412
|
-
border-radius: 4px;
|
|
413
|
-
}
|
|
414
|
-
@media (max-width: 768px) {
|
|
415
|
-
.file-header {
|
|
416
|
-
flex-direction: column;
|
|
417
|
-
align-items: flex-start;
|
|
418
|
-
gap: 10px;
|
|
419
|
-
}
|
|
420
|
-
.summary-stats {
|
|
421
|
-
grid-template-columns: 1fr;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
</style>
|
|
425
|
-
</head>
|
|
426
|
-
<body>
|
|
427
|
-
<div class="container">
|
|
428
|
-
<h1>Code Coverage Report</h1>
|
|
429
|
-
|
|
430
|
-
<div class="summary">
|
|
431
|
-
<h2>Summary</h2>
|
|
432
|
-
<div class="coverage-percent" style="color: ${coverageColor}">${coveragePercent}%</div>
|
|
433
|
-
<div class="summary-stats">
|
|
434
|
-
<div class="stat-item">
|
|
435
|
-
<div class="stat-label">Total Lines</div>
|
|
436
|
-
<div class="stat-value">${summary.totalLines}</div>
|
|
437
|
-
</div>
|
|
438
|
-
<div class="stat-item">
|
|
439
|
-
<div class="stat-label">Covered Lines</div>
|
|
440
|
-
<div class="stat-value">${summary.coveredLines}</div>
|
|
441
|
-
</div>
|
|
442
|
-
<div class="stat-item">
|
|
443
|
-
<div class="stat-label">Uncovered Lines</div>
|
|
444
|
-
<div class="stat-value">${summary.uncoveredLines}</div>
|
|
445
|
-
</div>
|
|
446
|
-
<div class="stat-item">
|
|
447
|
-
<div class="stat-label">Files</div>
|
|
448
|
-
<div class="stat-value">${files.length}</div>
|
|
449
|
-
</div>
|
|
450
|
-
</div>
|
|
451
|
-
</div>
|
|
452
|
-
|
|
453
|
-
${packageSummaryRows
|
|
454
|
-
? `
|
|
455
|
-
<div class="package-summary">
|
|
456
|
-
<h2>Package directory coverage</h2>
|
|
457
|
-
<table>
|
|
458
|
-
<thead>
|
|
459
|
-
<tr>
|
|
460
|
-
<th>Directory</th>
|
|
461
|
-
<th>Files</th>
|
|
462
|
-
<th>Total lines</th>
|
|
463
|
-
<th>Covered</th>
|
|
464
|
-
<th>Uncovered</th>
|
|
465
|
-
<th>Coverage</th>
|
|
466
|
-
<th></th>
|
|
467
|
-
</tr>
|
|
468
|
-
</thead>
|
|
469
|
-
<tbody>
|
|
470
|
-
${packageSummaryRows}
|
|
471
|
-
</tbody>
|
|
472
|
-
</table>
|
|
473
|
-
</div>
|
|
474
|
-
`
|
|
475
|
-
: ''}
|
|
476
|
-
|
|
477
|
-
<h2 style="margin: 30px 0 20px 0; color: #2c3e50;">File Coverage Details</h2>
|
|
478
|
-
|
|
479
|
-
${fileRows}
|
|
480
|
-
</div>
|
|
481
|
-
|
|
482
|
-
<script>
|
|
483
|
-
function toggleFile(filePath) {
|
|
484
|
-
const id = 'file-' + filePath.replace(/[^a-zA-Z0-9]/g, '-');
|
|
485
|
-
const element = document.getElementById(id);
|
|
486
|
-
if (element) {
|
|
487
|
-
element.style.display = element.style.display === 'none' ? 'block' : 'none';
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
</script>
|
|
491
|
-
</body>
|
|
492
|
-
</html>`;
|
|
493
|
-
}
|
|
494
|
-
function escapeHtml(text) {
|
|
495
|
-
const map = {
|
|
496
|
-
'&': '&',
|
|
497
|
-
'<': '<',
|
|
498
|
-
'>': '>',
|
|
499
|
-
'"': '"',
|
|
500
|
-
"'": ''',
|
|
501
|
-
};
|
|
502
|
-
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
503
|
-
}
|
|
504
70
|
//# 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,
|
|
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;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,u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AAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACtD,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEjF,OAAO,CAAC,MAAM,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5G,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,OAAO,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACxC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,IAAI,GAAG,CAAC;AACnE,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,11 @@ export type HtmlCoverageObject = {
|
|
|
344
344
|
packageSummaries: HtmlPackageSummary[];
|
|
345
345
|
files: HtmlFileCoverage[];
|
|
346
346
|
};
|
|
347
|
+
/** Union of every format-specific coverage object the report generator can emit. */
|
|
348
|
+
export type AnyCoverageObject = SonarCoverageObject | CoberturaCoverageObject | CloverCoverageObject | LcovCoverageObject | JaCoCoCoverageObject | IstanbulCoverageObject | JsonSummaryCoverageObject | SimpleCovCoverageObject | OpenCoverCoverageObject | HtmlCoverageObject;
|
|
349
|
+
export type XmlReportFormat = 'cobertura' | 'clover' | 'jacoco' | 'opencover';
|
|
350
|
+
export type XmlHeaderConfig = {
|
|
351
|
+
xmlDecl: string;
|
|
352
|
+
doctype?: string;
|
|
353
|
+
};
|
|
347
354
|
export {};
|