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.
- package/aim.js +9 -5
- package/call.js +4 -3
- package/merge.js +1 -1
- package/package.json +1 -1
package/aim.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
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) => {
|
|
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.
|
|
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
|
-
//
|
|
27
|
-
script.
|
|
28
|
-
//
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
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;
|