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 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 the script object, aimed at the host.
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 script, aimed at a host.
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
- script.commands.forEach(command => {
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
- script.source = {
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
- // Add a job-ID property to the script, including the time stamp, the script ID, and the host ID.
27
- script.jobID = `${timeStamp}-${script.id}-${host.id}`;
28
- // Return the host-specific script.
29
- return script;
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 aimedScript = aim(
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 aimedScriptID = aimedScript.id;
69
- await fs.writeFile(`${jobDir}/${aimedScriptID}.json`, JSON.stringify(aimedScript, null, 2));
70
- console.log(`Script ${aimedScriptID}.json has been aimed at ${hostName} and saved in ${jobDir}`);
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 id property to include the time stamp and the host ID.
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "7.0.2",
3
+ "version": "7.0.4",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {