testdriverai 4.2.13 → 4.2.14
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/lib/commander.js +25 -0
- package/lib/commands.js +23 -1
- package/lib/focus-application.js +1 -1
- package/lib/outputs.js +12 -0
- package/lib/system.js +1 -1
- package/package.json +2 -2
package/lib/commander.js
CHANGED
|
@@ -8,6 +8,19 @@ const notify = require("./notify");
|
|
|
8
8
|
const analytics = require("./analytics");
|
|
9
9
|
const marky = require("marky");
|
|
10
10
|
const sdk = require("./sdk");
|
|
11
|
+
const outputs = require("./outputs");
|
|
12
|
+
|
|
13
|
+
// replace all occurances of ${OUTPUT.ls} with outputs.get("ls") in every possible property of the `object`
|
|
14
|
+
// this is a recursive function that will go through all the properties of the object
|
|
15
|
+
const replaceOutputs = (obj) => {
|
|
16
|
+
for (let key in obj) {
|
|
17
|
+
if (typeof obj[key] === "object") {
|
|
18
|
+
replaceOutputs(obj[key]);
|
|
19
|
+
} else if (typeof obj[key] === "string") {
|
|
20
|
+
obj[key] = obj[key].replace(/\${OUTPUT\.(.*?)}/g, (_, match) => outputs.get(match));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
11
24
|
|
|
12
25
|
// object is a json representation of the individual yml command
|
|
13
26
|
// the process turns markdown -> yml -> json -> js function execution
|
|
@@ -37,6 +50,11 @@ commands:
|
|
|
37
50
|
keys: [command, space]
|
|
38
51
|
\`\`\``;
|
|
39
52
|
} else {
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
replaceOutputs(object);
|
|
57
|
+
|
|
40
58
|
let copy = JSON.parse(JSON.stringify(object));
|
|
41
59
|
|
|
42
60
|
marky.mark(object.command);
|
|
@@ -178,6 +196,13 @@ commands:
|
|
|
178
196
|
notify(generator.jsonToManual(object, false));
|
|
179
197
|
response = await commands.assert(object.expect, object.async);
|
|
180
198
|
break;
|
|
199
|
+
case "exec":
|
|
200
|
+
speak(`exec ${object.cli}`);
|
|
201
|
+
logger.info(generator.jsonToManual(object));
|
|
202
|
+
notify(generator.jsonToManual(object, false));
|
|
203
|
+
response = await commands.exec(object.cli, object.stderr, object.silent);
|
|
204
|
+
outputs.set(object.output, response);
|
|
205
|
+
break;
|
|
181
206
|
default:
|
|
182
207
|
throw new Error(`Command not found: ${object.command}`);
|
|
183
208
|
}
|
package/lib/commands.js
CHANGED
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
const keymap = require("./keymap");
|
|
11
11
|
const { focusApplication } = require("./focus-application");
|
|
12
12
|
const fs = require("fs").promises; // Using the promises version for async operations
|
|
13
|
-
const robot = require("robotjs");
|
|
13
|
+
const robot = require("testdriverai-robotjs");
|
|
14
14
|
const { findTemplateImage } = require("./subimage/index");
|
|
15
15
|
const { cwd } = require("node:process");
|
|
16
16
|
const path = require("path");
|
|
@@ -24,6 +24,8 @@ const {
|
|
|
24
24
|
createMarkdownStreamLogger,
|
|
25
25
|
} = require("./logger");
|
|
26
26
|
const { emitter, events } = require("./events.js");
|
|
27
|
+
const util = require('util');
|
|
28
|
+
const exec = util.promisify(require('child_process').exec);
|
|
27
29
|
|
|
28
30
|
const niceSeconds = (ms) => {
|
|
29
31
|
return Math.round(ms / 1000);
|
|
@@ -662,6 +664,26 @@ let commands = {
|
|
|
662
664
|
assert: async (assertion, async = false) => {
|
|
663
665
|
return await assert(assertion, true, async);
|
|
664
666
|
},
|
|
667
|
+
exec: async (cli_command, use_stderr = false, silent = false) => {
|
|
668
|
+
|
|
669
|
+
let args = {};
|
|
670
|
+
if (silent) {
|
|
671
|
+
args = { stdio: [] };
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
const { stdout, stderr } = await exec(cli_command, args);
|
|
675
|
+
|
|
676
|
+
if (!silent) {
|
|
677
|
+
logger.info(chalk.dim(stdout), true);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (use_stderr) {
|
|
681
|
+
return stderr;
|
|
682
|
+
} else {
|
|
683
|
+
return stdout;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
}
|
|
665
687
|
};
|
|
666
688
|
|
|
667
689
|
module.exports = { commands, assert };
|
package/lib/focus-application.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require("path");
|
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
4
|
const { platform } = require("./system");
|
|
5
5
|
const scriptPath = path.join(__dirname, "focusWindow.ps1");
|
|
6
|
-
const robot = require("robotjs");
|
|
6
|
+
const robot = require("testdriverai-robotjs");
|
|
7
7
|
const { logger } = require("./logger");
|
|
8
8
|
|
|
9
9
|
// apple script that focuses on a window
|
package/lib/outputs.js
ADDED
package/lib/system.js
CHANGED
|
@@ -4,7 +4,7 @@ const os = require("os");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const screenshot = require("screenshot-desktop");
|
|
6
6
|
const si = require("systeminformation");
|
|
7
|
-
const robot = require("robotjs");
|
|
7
|
+
const robot = require("testdriverai-robotjs");
|
|
8
8
|
const sharp = require("sharp");
|
|
9
9
|
const { emitter, events } = require("./events.js");
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testdriverai",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.14",
|
|
4
4
|
"description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"odiff-bin": "^3.1.2",
|
|
39
39
|
"prompts": "^2.4.2",
|
|
40
40
|
"remark-parse": "^11.0.0",
|
|
41
|
-
"robotjs": "^0.6.0",
|
|
41
|
+
"testdriverai-robotjs": "^0.6.0",
|
|
42
42
|
"sanitize-filename": "^1.6.3",
|
|
43
43
|
"say": "^0.16.0",
|
|
44
44
|
"screenshot-desktop": "^1.15.0",
|