testilo 3.1.1 → 3.2.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/README.md +34 -18
- package/compare.js +38 -0
- package/digest.js +19 -10
- package/package.json +1 -1
- package/procs/compare/cp0/index.html +41 -0
- package/procs/compare/cp0/index.js +72 -0
- package/procs/digest/{tsp10a → dp10a}/index.html +13 -5
- package/procs/digest/{tsp10a → dp10a}/index.js +11 -4
- package/procs/digest/{tsp09a → tdp09a}/index.html +0 -0
- package/procs/digest/{tsp09a → tdp09a}/index.js +0 -0
- package/procs/score/{tsp10a.js → sp10a.js} +31 -3
- package/reports/comparative/35k1r-.html +41 -0
- package/reports/comparative/style.css +85 -0
- package/reports/digested/35k1r-railpass.html +9302 -0
- package/reports/digested/style.css +4 -0
- package/reports/raw/35k1r-railpass.json +3192 -68
- package/reports/scored/35k1r-railpass.json +8982 -0
- package/score.js +17 -9
package/score.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
score.js
|
|
3
3
|
Testilo scoring script.
|
|
4
|
+
Usage example: node score 35k1r-railpass sp10a
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
// ########## IMPORTS
|
|
@@ -8,26 +9,33 @@
|
|
|
8
9
|
// Module to keep secrets.
|
|
9
10
|
require('dotenv').config();
|
|
10
11
|
// Module to read and write files.
|
|
11
|
-
const fs = require('fs')
|
|
12
|
+
const fs = require('fs/promises');
|
|
12
13
|
|
|
13
14
|
// ########## CONSTANTS
|
|
14
15
|
|
|
15
16
|
const reportDirRaw = process.env.REPORTDIR_RAW || 'reports/raw';
|
|
16
17
|
const reportDirScored = process.env.REPORTDIR_SCORED || 'reports/scored';
|
|
17
|
-
const
|
|
18
|
+
const reportIDStart = process.argv[2];
|
|
18
19
|
const scoreProcID = process.argv[3];
|
|
19
20
|
|
|
20
21
|
// ########## FUNCTIONS
|
|
21
22
|
|
|
22
23
|
const score = async () => {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
24
|
+
const reportDirRawAbs = `${__dirname}/${reportDirRaw}`;
|
|
25
|
+
const allReportFileNames = await fs.readdir(reportDirRawAbs);
|
|
26
|
+
const sourceReportFileNames = allReportFileNames
|
|
27
|
+
.filter(fileName => fileName.startsWith(reportIDStart) && fileName.endsWith('.json'));
|
|
25
28
|
const {scorer} = require(`./procs/score/${scoreProcID}`);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
for (const fileName of sourceReportFileNames) {
|
|
30
|
+
const reportJSON = await fs
|
|
31
|
+
.readFile(`${reportDirRawAbs}/${fileName}`, 'utf8');
|
|
32
|
+
const report = JSON.parse(reportJSON);
|
|
33
|
+
scorer(report);
|
|
34
|
+
report.score.scoreProcID = scoreProcID;
|
|
35
|
+
const scoredReportJSON = JSON.stringify(report, null, 2);
|
|
36
|
+
await fs.writeFile(`${__dirname}/${reportDirScored}/${fileName}`, `${scoredReportJSON}\n`);
|
|
37
|
+
console.log(`Report ${fileName.slice(0, -5)} scored and saved`);
|
|
38
|
+
};
|
|
31
39
|
};
|
|
32
40
|
|
|
33
41
|
// ########## OPERATION
|