@myerscarpenter/quest-dev 1.0.0
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/.github/workflows/publish.yml +41 -0
- package/build/commands/open.d.ts +9 -0
- package/build/commands/open.d.ts.map +1 -0
- package/build/commands/open.js +111 -0
- package/build/commands/open.js.map +1 -0
- package/build/commands/screenshot.d.ts +9 -0
- package/build/commands/screenshot.d.ts.map +1 -0
- package/build/commands/screenshot.js +92 -0
- package/build/commands/screenshot.js.map +1 -0
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +59 -0
- package/build/index.js.map +1 -0
- package/build/utils/adb.d.ts +32 -0
- package/build/utils/adb.d.ts.map +1 -0
- package/build/utils/adb.js +191 -0
- package/build/utils/adb.js.map +1 -0
- package/build/utils/exec.d.ts +17 -0
- package/build/utils/exec.d.ts.map +1 -0
- package/build/utils/exec.js +66 -0
- package/build/utils/exec.js.map +1 -0
- package/package.json +63 -0
- package/src/commands/open.ts +138 -0
- package/src/commands/screenshot.ts +102 -0
- package/src/index.ts +77 -0
- package/src/utils/adb.ts +197 -0
- package/src/utils/exec.ts +83 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell command execution utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { spawn } from 'child_process';
|
|
6
|
+
|
|
7
|
+
export interface ExecResult {
|
|
8
|
+
stdout: string;
|
|
9
|
+
stderr: string;
|
|
10
|
+
code: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Execute a shell command and return a promise with stdout
|
|
15
|
+
*/
|
|
16
|
+
export function execCommand(command: string, args: string[] = []): Promise<string> {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const proc = spawn(command, args, {
|
|
19
|
+
stdio: 'pipe',
|
|
20
|
+
shell: true
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
let stdout = '';
|
|
24
|
+
let stderr = '';
|
|
25
|
+
|
|
26
|
+
if (proc.stdout) {
|
|
27
|
+
proc.stdout.on('data', (data) => {
|
|
28
|
+
stdout += data.toString();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (proc.stderr) {
|
|
33
|
+
proc.stderr.on('data', (data) => {
|
|
34
|
+
stderr += data.toString();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
proc.on('close', (code) => {
|
|
39
|
+
if (code === 0) {
|
|
40
|
+
resolve(stdout);
|
|
41
|
+
} else {
|
|
42
|
+
reject(new Error(`Command failed with code ${code}: ${stderr}`));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
proc.on('error', reject);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Execute a shell command and return full result (doesn't throw on non-zero exit)
|
|
52
|
+
*/
|
|
53
|
+
export function execCommandFull(command: string, args: string[] = []): Promise<ExecResult> {
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
const proc = spawn(command, args, {
|
|
56
|
+
stdio: 'pipe',
|
|
57
|
+
shell: true
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
let stdout = '';
|
|
61
|
+
let stderr = '';
|
|
62
|
+
|
|
63
|
+
if (proc.stdout) {
|
|
64
|
+
proc.stdout.on('data', (data) => {
|
|
65
|
+
stdout += data.toString();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (proc.stderr) {
|
|
70
|
+
proc.stderr.on('data', (data) => {
|
|
71
|
+
stderr += data.toString();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
proc.on('close', (code) => {
|
|
76
|
+
resolve({ stdout, stderr, code: code ?? 1 });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
proc.on('error', (err) => {
|
|
80
|
+
resolve({ stdout, stderr: err.message, code: 1 });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"outDir": "./build",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"types": ["node"]
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*"],
|
|
20
|
+
"exclude": ["node_modules", "build"]
|
|
21
|
+
}
|