testilo 3.1.2 → 3.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.
- package/digest.js +17 -9
- package/package.json +1 -1
- package/reports/scored/35k1r-railpass.json +1 -1
- package/score.js +15 -8
package/digest.js
CHANGED
|
@@ -14,7 +14,7 @@ const fs = require('fs').promises;
|
|
|
14
14
|
|
|
15
15
|
const reportDirScored = process.env.REPORTDIR_SCORED || 'reports/scored';
|
|
16
16
|
const reportDirDigested = process.env.REPORTDIR_DIGESTED || 'reports/digested';
|
|
17
|
-
const
|
|
17
|
+
const reportIDStart = process.argv[2];
|
|
18
18
|
const digesterID = process.argv[3];
|
|
19
19
|
|
|
20
20
|
// ########## FUNCTIONS
|
|
@@ -24,15 +24,23 @@ const replaceHolders = (content, query) => content
|
|
|
24
24
|
.replace(/__([a-zA-Z]+)__/g, (ph, qp) => query[qp]);
|
|
25
25
|
// Creates a digest.
|
|
26
26
|
const digest = async () => {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const reportDirScoredAbs = `${__dirname}/${reportDirScored}`;
|
|
28
|
+
const allReportFileNames = await fs.readdir(reportDirScoredAbs);
|
|
29
|
+
const sourceReportFileNames = allReportFileNames
|
|
30
|
+
.filter(fileName => fileName.startsWith(reportIDStart) && fileName.endsWith('.json'));
|
|
29
31
|
const {makeQuery} = require(`${__dirname}/procs/digest/${digesterID}/index.js`);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
for (const fileName of sourceReportFileNames) {
|
|
33
|
+
const reportJSON = await fs.readFile(`${reportDirScoredAbs}/${fileName}`, 'utf8');
|
|
34
|
+
const report = JSON.parse(reportJSON);
|
|
35
|
+
const query = {};
|
|
36
|
+
makeQuery(report, query);
|
|
37
|
+
const template = await fs
|
|
38
|
+
.readFile(`${__dirname}/procs/digest/${digesterID}/index.html`, 'utf8');
|
|
39
|
+
const digest = replaceHolders(template, query);
|
|
40
|
+
const fileNameBase = fileName.slice(0, -5);
|
|
41
|
+
await fs.writeFile(`${__dirname}/${reportDirDigested}/${fileNameBase}.html`, digest);
|
|
42
|
+
console.log(`Report ${fileNameBase} digested and saved`);
|
|
43
|
+
};
|
|
36
44
|
};
|
|
37
45
|
|
|
38
46
|
// ########## OPERATION
|
package/package.json
CHANGED
package/score.js
CHANGED
|
@@ -14,20 +14,27 @@ const fs = require('fs').promises;
|
|
|
14
14
|
|
|
15
15
|
const reportDirRaw = process.env.REPORTDIR_RAW || 'reports/raw';
|
|
16
16
|
const reportDirScored = process.env.REPORTDIR_SCORED || 'reports/scored';
|
|
17
|
-
const
|
|
17
|
+
const reportIDStart = process.argv[2];
|
|
18
18
|
const scoreProcID = process.argv[3];
|
|
19
19
|
|
|
20
20
|
// ########## FUNCTIONS
|
|
21
21
|
|
|
22
22
|
const score = async () => {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const reportDirRawAbs = `${__dirname}/${reportDirRaw}`;
|
|
24
|
+
const allReportFileNames = await fs.readdir(reportDirRawAbs);
|
|
25
|
+
const sourceReportFileNames = allReportFileNames
|
|
26
|
+
.filter(fileName => fileName.startsWith(reportIDStart) && fileName.endsWith('.json'));
|
|
25
27
|
const {scorer} = require(`./procs/score/${scoreProcID}`);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
for (const fileName of sourceReportFileNames) {
|
|
29
|
+
const reportJSON = await fs
|
|
30
|
+
.readFile(`${reportDirRawAbs}/${fileName}`, 'utf8');
|
|
31
|
+
const report = JSON.parse(reportJSON);
|
|
32
|
+
scorer(report);
|
|
33
|
+
report.score.scoreProcID = scoreProcID;
|
|
34
|
+
const scoredReportJSON = JSON.stringify(report, null, 2);
|
|
35
|
+
await fs.writeFile(`${__dirname}/${reportDirScored}/${fileName}`, scoredReportJSON);
|
|
36
|
+
console.log(`Report ${fileName.slice(0, -5)} scored and saved`);
|
|
37
|
+
};
|
|
31
38
|
};
|
|
32
39
|
|
|
33
40
|
// ########## OPERATION
|