testilo 7.0.3 → 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
@@ -9,8 +9,10 @@
9
9
  const nowString = () => (new Date()).toISOString().slice(0, 19);
10
10
  // Returns a script, aimed at a host, as a job.
11
11
  exports.aim = (script, host, requester) => {
12
+ // Initialize a job based on the script.
13
+ const job = JSON.parse(JSON.stringify(script));
12
14
  // Make all url commands in the script visit the host.
13
- script.commands.forEach(command => {
15
+ job.commands.forEach(command => {
14
16
  if (command.type === 'url') {
15
17
  command.id = host.id;
16
18
  command.which = host.which;
@@ -18,7 +20,7 @@ exports.aim = (script, host, requester) => {
18
20
  }
19
21
  });
20
22
  // Add source information to the script.
21
- script.sources = {
23
+ job.sources = {
22
24
  script: script.id,
23
25
  host,
24
26
  requester
@@ -26,9 +28,11 @@ exports.aim = (script, host, requester) => {
26
28
  // Create a job-creation time stamp.
27
29
  const timeStamp = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
28
30
  // Change the script ID to a job ID.
29
- script.id = `${timeStamp}-${script.id}-${host.id}`;
31
+ job.id = `${timeStamp}-${script.id}-${host.id}`;
30
32
  // Add the job-creation time to the script.
31
- script.jobCreationTime = nowString();
33
+ job.jobCreationTime = nowString();
34
+ // Add the time stamp to the job.
35
+ job.timeStamp = timeStamp;
32
36
  // Return the job.
33
- return script;
37
+ return job;
34
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,10 +65,10 @@ const callAim = async (scriptName, hostURL, hostName, hostID, requester) => {
65
65
  },
66
66
  requester
67
67
  );
68
- const scriptID = script.sources.script;
69
- const jobID = aimedScript.id;
70
- await fs.writeFile(`${jobDir}/${jobID}.json`, `${JSON.stringify(aimedScript, null, 2)}\n`);
71
- console.log(`Script ${scriptID} aimed at ${hostName} saved as ${jobID}.json 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}`);
72
72
  };
73
73
  // Fulfills a merger request.
74
74
  const callMerge = async (scriptName, batchName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {