testdriverai 4.0.49 → 4.0.51
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/index.js +23 -3
- package/lib/commands.js +3 -1
- package/lib/config.js +1 -0
- package/lib/focus-application.js +3 -0
- package/lib/init.js +6 -0
- package/lib/redraw.js +19 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const package = require("./package.json");
|
|
|
10
10
|
const fs = require("fs");
|
|
11
11
|
const readline = require("readline");
|
|
12
12
|
const os = require("os");
|
|
13
|
+
const http = require('http');
|
|
13
14
|
|
|
14
15
|
// third party modules
|
|
15
16
|
const path = require("path");
|
|
@@ -29,6 +30,7 @@ const generator = require("./lib/generator");
|
|
|
29
30
|
const sdk = require("./lib/sdk");
|
|
30
31
|
const commands = require("./lib/commands");
|
|
31
32
|
const init = require("./lib/init");
|
|
33
|
+
const config = require("./lib/config");
|
|
32
34
|
|
|
33
35
|
const { showTerminal, hideTerminal } = require("./lib/focus-application");
|
|
34
36
|
const isValidVersion = require("./lib/valid-version");
|
|
@@ -45,8 +47,6 @@ let checkCount = 0;
|
|
|
45
47
|
let checkLimit = 3;
|
|
46
48
|
let rl;
|
|
47
49
|
|
|
48
|
-
require("dotenv").config();
|
|
49
|
-
|
|
50
50
|
// list of prompts that the user has given us
|
|
51
51
|
let tasks = [];
|
|
52
52
|
|
|
@@ -499,7 +499,6 @@ const generate = async (type) => {
|
|
|
499
499
|
}
|
|
500
500
|
let list = testPrompt.listsOrdered[0];
|
|
501
501
|
|
|
502
|
-
list.push(`/save testdriver/${fileName}`);
|
|
503
502
|
let contents = list
|
|
504
503
|
.map((item, index) => `${index + 1}. /explore ${item}`)
|
|
505
504
|
.join("\n");
|
|
@@ -669,6 +668,27 @@ New commands will be appended.
|
|
|
669
668
|
};
|
|
670
669
|
|
|
671
670
|
let setTerminalWindowTransparency = async (hide) => {
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
try {
|
|
674
|
+
await http.get('http://localhost:60305/hide')
|
|
675
|
+
} catch (e) {
|
|
676
|
+
// Suppress error
|
|
677
|
+
console.error('Caught exception:', e);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
try {
|
|
681
|
+
await http.get('http://localhost:60305/show');
|
|
682
|
+
} catch (e) {
|
|
683
|
+
// Suppress error
|
|
684
|
+
console.error('Caught exception:', e);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
if (!config.TD_MINIMIZE) {
|
|
689
|
+
return
|
|
690
|
+
};
|
|
691
|
+
|
|
672
692
|
try {
|
|
673
693
|
if (hide) {
|
|
674
694
|
if (terminalApp) {
|
package/lib/commands.js
CHANGED
|
@@ -122,8 +122,10 @@ const assert = async (assertion, shouldThrow = false, async = false) => {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
const handleAssertResponse = (response) => {
|
|
125
|
+
|
|
126
|
+
logger.prettyMarkdown(response);
|
|
127
|
+
|
|
125
128
|
if (response.indexOf("The task passed") > -1) {
|
|
126
|
-
logger.prettyMarkdown(response);
|
|
127
129
|
return true;
|
|
128
130
|
} else {
|
|
129
131
|
if (shouldThrow) {
|
package/lib/config.js
CHANGED
package/lib/focus-application.js
CHANGED
|
@@ -40,6 +40,7 @@ async function focusApplication(appName) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async function hideTerminal(appName) {
|
|
43
|
+
|
|
43
44
|
try {
|
|
44
45
|
if (platform() == "mac") {
|
|
45
46
|
return await execSync(`osascript -e '${appleScriptMin(appName)}'`);
|
|
@@ -52,6 +53,7 @@ async function hideTerminal(appName) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
async function showTerminal(appName) {
|
|
56
|
+
|
|
55
57
|
try {
|
|
56
58
|
if (platform() == "mac") {
|
|
57
59
|
return await execSync(`osascript -e '${appleScriptMax(appName)}'`);
|
|
@@ -68,3 +70,4 @@ module.exports = {
|
|
|
68
70
|
hideTerminal,
|
|
69
71
|
showTerminal,
|
|
70
72
|
};
|
|
73
|
+
|
package/lib/init.js
CHANGED
|
@@ -81,6 +81,12 @@ module.exports = async () => {
|
|
|
81
81
|
message: "Enable desktop notifications?",
|
|
82
82
|
initial: true,
|
|
83
83
|
},
|
|
84
|
+
{
|
|
85
|
+
type: "confirm",
|
|
86
|
+
name: "TD_MINIMIZE",
|
|
87
|
+
message: "Minimize terminal app?",
|
|
88
|
+
initial: true,
|
|
89
|
+
},
|
|
84
90
|
{
|
|
85
91
|
type: "confirm",
|
|
86
92
|
name: "TD_SPEAK",
|
package/lib/redraw.js
CHANGED
|
@@ -25,34 +25,27 @@ async function start() {
|
|
|
25
25
|
|
|
26
26
|
function wait(timeoutMs) {
|
|
27
27
|
|
|
28
|
-
// wait for a certain amount of time
|
|
29
28
|
return new Promise((resolve) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const startTime = Date.now();
|
|
30
|
+
|
|
31
|
+
async function checkCondition() {
|
|
32
|
+
console.log('check condition')
|
|
33
|
+
let nowImage = await captureScreenPNG();
|
|
34
|
+
let result = await compareImages(startImage, nowImage);
|
|
35
|
+
|
|
36
|
+
if (result) {
|
|
37
|
+
resolve("Condition met");
|
|
38
|
+
} else if (Date.now() - startTime >= timeoutMs) {
|
|
39
|
+
resolve("Timeout reached");
|
|
40
|
+
} else {
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
checkCondition();
|
|
43
|
+
}, 0);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
checkCondition();
|
|
33
48
|
});
|
|
34
|
-
|
|
35
|
-
// return new Promise((resolve) => {
|
|
36
|
-
// const startTime = Date.now();
|
|
37
|
-
|
|
38
|
-
// async function checkCondition() {
|
|
39
|
-
// console.log('check condition')
|
|
40
|
-
// let nowImage = await captureScreenPNG();
|
|
41
|
-
// let result = await compareImages(startImage, nowImage);
|
|
42
|
-
|
|
43
|
-
// if (result) {
|
|
44
|
-
// resolve("Condition met");
|
|
45
|
-
// } else if (Date.now() - startTime >= timeoutMs) {
|
|
46
|
-
// resolve("Timeout reached");
|
|
47
|
-
// } else {
|
|
48
|
-
// setTimeout(() => {
|
|
49
|
-
// checkCondition();
|
|
50
|
-
// }, 0);
|
|
51
|
-
// }
|
|
52
|
-
// }
|
|
53
|
-
|
|
54
|
-
// checkCondition();
|
|
55
|
-
// });
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
module.exports = { start, wait };
|