testilo 10.0.2 → 10.0.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/call.js +4 -6
- package/digest.js +2 -2
- package/package.json +1 -1
- package/procs/digest/tdp22/index.html +1 -1
- package/procs/digest/tdp22/index.js +28 -29
package/call.js
CHANGED
|
@@ -105,18 +105,16 @@ const callDigest = async (digesterID, selector = '') => {
|
|
|
105
105
|
if (reports.length) {
|
|
106
106
|
const digesterDir = `${functionDir}/digest/${digesterID}`;
|
|
107
107
|
// Get the digester.
|
|
108
|
-
const
|
|
108
|
+
const digester = require(`${digesterDir}/index`).makeQuery;
|
|
109
109
|
// Get the template.
|
|
110
|
-
const template = await fs.readFile(`${digesterDir}/index.html
|
|
110
|
+
const template = await fs.readFile(`${digesterDir}/index.html`, 'utf8');
|
|
111
111
|
// Digest the reports.
|
|
112
112
|
const digestedReports = digest(template, digester, reports);
|
|
113
113
|
const digestedReportDir = `${reportDir}/digested`;
|
|
114
114
|
// For each digested report:
|
|
115
|
-
for (const
|
|
115
|
+
for (const reportID of Object.keys(digestedReports)) {
|
|
116
116
|
// Save it.
|
|
117
|
-
await fs.writeFile(
|
|
118
|
-
`${digestedReportDir}/${digestedReport.id}.json`, JSON.stringify(digestedReport, null, 2)
|
|
119
|
-
);
|
|
117
|
+
await fs.writeFile(`${digestedReportDir}/${reportID}.html`, digestedReports[reportID]);
|
|
120
118
|
};
|
|
121
119
|
}
|
|
122
120
|
// Otherwise, i.e. if no scored reports are to be digested:
|
package/digest.js
CHANGED
|
@@ -14,7 +14,7 @@ const replaceHolders = (content, query) => content
|
|
|
14
14
|
.replace(/__([a-zA-Z]+)__/g, (ph, qp) => query[qp]);
|
|
15
15
|
// Digests the scored reports and returns them, digested.
|
|
16
16
|
exports.digest = (digestTemplate, digester, reports) => {
|
|
17
|
-
const digests =
|
|
17
|
+
const digests = {};
|
|
18
18
|
// Create a query.
|
|
19
19
|
const query = {};
|
|
20
20
|
// For each report:
|
|
@@ -24,7 +24,7 @@ exports.digest = (digestTemplate, digester, reports) => {
|
|
|
24
24
|
// Use it to create a digest.
|
|
25
25
|
const digestedReport = replaceHolders(digestTemplate, query);
|
|
26
26
|
// Add the digest to the array of digests.
|
|
27
|
-
digests.
|
|
27
|
+
digests[report.id] = digestedReport;
|
|
28
28
|
console.log(`Report ${report.id} digested`);
|
|
29
29
|
};
|
|
30
30
|
// Return the digests.
|
package/package.json
CHANGED
|
@@ -29,9 +29,8 @@ const getSpecialPStart = (summary, scoreID) =>
|
|
|
29
29
|
// Adds parameters to a query for a digest.
|
|
30
30
|
exports.makeQuery = (report, query) => {
|
|
31
31
|
// Add an HTML-safe copy of the report to the query to be appended to the digest.
|
|
32
|
-
const {
|
|
33
|
-
const {
|
|
34
|
-
const {host, requester} = sources;
|
|
32
|
+
const {acts, sources, jobData, score} = report;
|
|
33
|
+
const {target, requester} = sources;
|
|
35
34
|
const reportJSON = JSON.stringify(report, null, 2);
|
|
36
35
|
const reportJSONSafe = htmlEscape(reportJSON);
|
|
37
36
|
query.report = reportJSONSafe;
|
|
@@ -41,11 +40,11 @@ exports.makeQuery = (report, query) => {
|
|
|
41
40
|
// Add the job data to the query.
|
|
42
41
|
query.dateISO = jobData.endTime.slice(0, 10);
|
|
43
42
|
query.dateSlash = query.dateISO.replace(/-/g, '/');
|
|
44
|
-
query.org =
|
|
45
|
-
query.url =
|
|
43
|
+
query.org = target.what;
|
|
44
|
+
query.url = acts && acts.length > 1 && acts[1].which;
|
|
46
45
|
query.requester = requester;
|
|
47
|
-
const {
|
|
48
|
-
const {total,
|
|
46
|
+
const {issueDetails, summary} = score;
|
|
47
|
+
const {total, issues} = summary;
|
|
49
48
|
if (typeof total === 'number') {
|
|
50
49
|
query.totalScore = total;
|
|
51
50
|
}
|
|
@@ -62,8 +61,8 @@ exports.makeQuery = (report, query) => {
|
|
|
62
61
|
}
|
|
63
62
|
});
|
|
64
63
|
// Add the group rows of the score-summary table to the query.
|
|
65
|
-
|
|
66
|
-
scoreRows.push(getScoreRow(`${
|
|
64
|
+
issues.forEach(issue => {
|
|
65
|
+
scoreRows.push(getScoreRow(`${issue.issueName}`, issue.score));
|
|
67
66
|
});
|
|
68
67
|
query.scoreRows = scoreRows.join(innerJoiner);
|
|
69
68
|
// If the score has any special components:
|
|
@@ -82,40 +81,40 @@ exports.makeQuery = (report, query) => {
|
|
|
82
81
|
query.specialSummary = '<p>No special issues contributed to the score.</p>'
|
|
83
82
|
}
|
|
84
83
|
// If the score has any classified issues as components:
|
|
85
|
-
if (
|
|
84
|
+
if (issues.length) {
|
|
86
85
|
// Add paragraphs about them for the group summary to the query.
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const {
|
|
90
|
-
const
|
|
91
|
-
const wcagP = `<p>WCAG: ${
|
|
86
|
+
const issueSummaryItems = [];
|
|
87
|
+
issues.forEach(issue => {
|
|
88
|
+
const {issueName, score} = issue;
|
|
89
|
+
const issueHeading = `<h4>Issue ${issueName}</h4>`;
|
|
90
|
+
const wcagP = `<p>WCAG: ${issueDetails.issues[issueName].wcag || 'N/A'}</p>`;
|
|
92
91
|
const scoreP = `<p>Score: ${score}</p>`;
|
|
93
92
|
const issueIntroP = '<p>Issue reports in this category:</p>';
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const testIDs = Object.keys(
|
|
93
|
+
const issueListItems = [];
|
|
94
|
+
const issueData = issueDetails.issues[issueName];
|
|
95
|
+
const toolIDs = Object.keys(issueData.tools);
|
|
96
|
+
toolIDs.forEach(toolID => {
|
|
97
|
+
const testIDs = Object.keys(issueData.tools[toolID]);
|
|
99
98
|
testIDs.forEach(testID => {
|
|
100
|
-
const testData =
|
|
99
|
+
const testData = issueData.tools[toolID][testID];
|
|
101
100
|
const {score, what} = testData;
|
|
102
101
|
const listItem =
|
|
103
|
-
`<li>Package <code>${
|
|
104
|
-
|
|
102
|
+
`<li>Package <code>${toolID}</code>, test <code>${testID}</code>, score ${score} (${what})</li>`;
|
|
103
|
+
issueListItems.push(listItem);
|
|
105
104
|
});
|
|
106
105
|
});
|
|
107
|
-
const
|
|
106
|
+
const issueList = [
|
|
108
107
|
'<ul>',
|
|
109
|
-
|
|
108
|
+
issueListItems.join('\n '),
|
|
110
109
|
'</ul>'
|
|
111
110
|
].join(joiner);
|
|
112
|
-
|
|
111
|
+
issueSummaryItems.push(issueHeading, wcagP, scoreP, issueIntroP, issueList);
|
|
113
112
|
});
|
|
114
|
-
query.
|
|
113
|
+
query.issueSummary = issueSummaryItems.join(joiner);
|
|
115
114
|
}
|
|
116
115
|
// Otherwise, i.e. if the score has no classified issues as components:
|
|
117
116
|
else {
|
|
118
|
-
// Add a paragraph stating this for the
|
|
119
|
-
query.
|
|
117
|
+
// Add a paragraph stating this for the issue summary to the query.
|
|
118
|
+
query.issueSummary = '<p>No classified issues contributed to the score.</p>'
|
|
120
119
|
}
|
|
121
120
|
};
|