testilo 7.0.2 → 7.0.4
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 +1 -1
- package/aim.js +15 -7
- package/call.js +5 -4
- package/merge.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ node call aim tp25 https://w3.org/ 'World Wide Web Consortium' w3c developer@w3c
|
|
|
74
74
|
|
|
75
75
|
In these examples, a copy of the script file named `tp25.json` in the `SCRIPTDIR` directory is aimed at the World Wide Web Consortium and then saved in the `JOBDIR` directory.
|
|
76
76
|
|
|
77
|
-
The `aim` function neither reads nor writes files. Its arguments are a script object, a host object, and a requester-email-address string, and it returns
|
|
77
|
+
The `aim` function neither reads nor writes files. Its arguments are a script object, a host object, and a requester-email-address string, and it returns a job object, aimed at the host.
|
|
78
78
|
|
|
79
79
|
### `merge`
|
|
80
80
|
|
package/aim.js
CHANGED
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
// ########## FUNCTIONS
|
|
7
7
|
|
|
8
|
-
// Returns a
|
|
8
|
+
// Returns a string representing the date and time.
|
|
9
|
+
const nowString = () => (new Date()).toISOString().slice(0, 19);
|
|
10
|
+
// Returns a script, aimed at a host, as a job.
|
|
9
11
|
exports.aim = (script, host, requester) => {
|
|
12
|
+
// Initialize a job based on the script.
|
|
13
|
+
const job = JSON.parse(JSON.stringify(script));
|
|
10
14
|
// Make all url commands in the script visit the host.
|
|
11
|
-
|
|
15
|
+
job.commands.forEach(command => {
|
|
12
16
|
if (command.type === 'url') {
|
|
13
17
|
command.id = host.id;
|
|
14
18
|
command.which = host.which;
|
|
@@ -16,15 +20,19 @@ exports.aim = (script, host, requester) => {
|
|
|
16
20
|
}
|
|
17
21
|
});
|
|
18
22
|
// Add source information to the script.
|
|
19
|
-
|
|
23
|
+
job.sources = {
|
|
20
24
|
script: script.id,
|
|
21
25
|
host,
|
|
22
26
|
requester
|
|
23
27
|
}
|
|
24
28
|
// Create a job-creation time stamp.
|
|
25
29
|
const timeStamp = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
+
// Change the script ID to a job ID.
|
|
31
|
+
job.id = `${timeStamp}-${script.id}-${host.id}`;
|
|
32
|
+
// Add the job-creation time to the script.
|
|
33
|
+
job.jobCreationTime = nowString();
|
|
34
|
+
// Add the time stamp to the job.
|
|
35
|
+
job.timeStamp = timeStamp;
|
|
36
|
+
// Return the job.
|
|
37
|
+
return job;
|
|
30
38
|
};
|
package/call.js
CHANGED
|
@@ -56,7 +56,7 @@ const fnArgs = process.argv.slice(3);
|
|
|
56
56
|
const callAim = async (scriptName, hostURL, hostName, hostID, requester) => {
|
|
57
57
|
const scriptJSON = await fs.readFile(`${scriptDir}/${scriptName}.json`, 'utf8');
|
|
58
58
|
const script = JSON.parse(scriptJSON);
|
|
59
|
-
const
|
|
59
|
+
const job = aim(
|
|
60
60
|
script,
|
|
61
61
|
{
|
|
62
62
|
id: hostID,
|
|
@@ -65,9 +65,10 @@ const callAim = async (scriptName, hostURL, hostName, hostID, requester) => {
|
|
|
65
65
|
},
|
|
66
66
|
requester
|
|
67
67
|
);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
const scriptID = job.sources.script;
|
|
69
|
+
const jobID = job.id;
|
|
70
|
+
await fs.writeFile(`${jobDir}/${jobID}.json`, `${JSON.stringify(job, null, 2)}\n`);
|
|
71
|
+
console.log(`Script ${scriptID} aimed at ${hostName} saved as job ${jobID}.json in ${jobDir}`);
|
|
71
72
|
};
|
|
72
73
|
// Fulfills a merger request.
|
|
73
74
|
const callMerge = async (scriptName, batchName) => {
|
package/merge.js
CHANGED
|
@@ -56,7 +56,7 @@ exports.merge = async (scriptName, batchName) => {
|
|
|
56
56
|
}
|
|
57
57
|
// Add the job-creation time to the script.
|
|
58
58
|
newScript.jobCreationTime = nowString();
|
|
59
|
-
// Change the script
|
|
59
|
+
// Change the script ID to a job ID.
|
|
60
60
|
newScript.id = `${timeStamp}-${newScript.id}-${host.id}`;
|
|
61
61
|
// Return the host-specific script.
|
|
62
62
|
return newScript;
|