testilo 7.0.2 → 7.0.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.
Files changed (4) hide show
  1. package/aim.js +9 -5
  2. package/call.js +4 -3
  3. package/merge.js +1 -1
  4. package/package.json +1 -1
package/aim.js CHANGED
@@ -5,7 +5,9 @@
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) => {
10
12
  // Make all url commands in the script visit the host.
11
13
  script.commands.forEach(command => {
@@ -16,15 +18,17 @@ exports.aim = (script, host, requester) => {
16
18
  }
17
19
  });
18
20
  // Add source information to the script.
19
- script.source = {
21
+ script.sources = {
20
22
  script: script.id,
21
23
  host,
22
24
  requester
23
25
  }
24
26
  // Create a job-creation time stamp.
25
27
  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.
28
+ // Change the script ID to a job ID.
29
+ script.id = `${timeStamp}-${script.id}-${host.id}`;
30
+ // Add the job-creation time to the script.
31
+ script.jobCreationTime = nowString();
32
+ // Return the job.
29
33
  return script;
30
34
  };
package/call.js CHANGED
@@ -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 = 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}`);
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.3",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {