@midscene/cli 0.2.2-beta-20240809090814.0 → 0.2.2
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/bin/midscene +1 -0
- package/dist/es/help.js +103 -0
- package/dist/es/index.js +1 -42
- package/dist/lib/help.js +104 -0
- package/dist/lib/index.js +1 -42
- package/dist/types/help.d.ts +2 -0
- package/package.json +2 -2
package/bin/midscene
CHANGED
package/dist/es/help.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// package.json
|
|
7
|
+
var require_package = __commonJS({
|
|
8
|
+
"package.json"(exports, module) {
|
|
9
|
+
module.exports = {
|
|
10
|
+
name: "@midscene/cli",
|
|
11
|
+
description: "Cli for Midscene.js",
|
|
12
|
+
version: "0.2.2",
|
|
13
|
+
"jsnext:source": "./src/index.ts",
|
|
14
|
+
main: "./dist/lib/index.js",
|
|
15
|
+
bin: {
|
|
16
|
+
midscene: "./bin/midscene"
|
|
17
|
+
},
|
|
18
|
+
files: [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
scripts: {
|
|
23
|
+
dev: "modern dev",
|
|
24
|
+
build: "modern build",
|
|
25
|
+
"build:watch": "modern build -w",
|
|
26
|
+
new: "modern new",
|
|
27
|
+
upgrade: "modern upgrade",
|
|
28
|
+
test: "vitest --run",
|
|
29
|
+
"test:all": "AITEST=true vitest --run",
|
|
30
|
+
prepublishOnly: "npm run build"
|
|
31
|
+
},
|
|
32
|
+
dependencies: {
|
|
33
|
+
"@midscene/web": "workspace:*",
|
|
34
|
+
"ora-classic": "5.4.2",
|
|
35
|
+
puppeteer: "^22.8.0",
|
|
36
|
+
yargs: "17.7.2"
|
|
37
|
+
},
|
|
38
|
+
devDependencies: {
|
|
39
|
+
"@modern-js/module-tools": "^2.56.1",
|
|
40
|
+
"@types/node": "^18.0.0",
|
|
41
|
+
"@types/yargs": "17.0.32",
|
|
42
|
+
execa: "9.3.0",
|
|
43
|
+
typescript: "~5.0.4",
|
|
44
|
+
vitest: "^1.6.0"
|
|
45
|
+
},
|
|
46
|
+
engines: {
|
|
47
|
+
node: ">=16.0.0"
|
|
48
|
+
},
|
|
49
|
+
publishConfig: {
|
|
50
|
+
access: "public",
|
|
51
|
+
registry: "https://registry.npmjs.org"
|
|
52
|
+
},
|
|
53
|
+
license: "MIT"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// src/help.ts
|
|
59
|
+
if (process.argv.indexOf("--help") !== -1) {
|
|
60
|
+
console.log(`
|
|
61
|
+
Usage: midscene [options] [actions]
|
|
62
|
+
|
|
63
|
+
Options:
|
|
64
|
+
--url <url> The URL to visit, required
|
|
65
|
+
--user-agent <ua> The user agent to use, optional
|
|
66
|
+
--viewport-width <width> The width of the viewport, optional
|
|
67
|
+
--viewport-height <height> The height of the viewport, optional
|
|
68
|
+
--viewport-scale <scale> The device scale factor, optional
|
|
69
|
+
--headed Run in headed mode, default false
|
|
70
|
+
--help Display this help message
|
|
71
|
+
--version Display the version
|
|
72
|
+
|
|
73
|
+
Actions (the order matters, can be used multiple times):
|
|
74
|
+
--action <action> Perform an action, optional
|
|
75
|
+
--assert <assert> Perform an assert, optional
|
|
76
|
+
--query-output <path> Save the result of the query to a file, this must be put before --query, optional
|
|
77
|
+
--query <query> Perform a query, optional
|
|
78
|
+
--sleep <ms> Sleep for a number of milliseconds, optional
|
|
79
|
+
|
|
80
|
+
Examples:
|
|
81
|
+
# headed mode (i.e. visible browser) to visit bing.com and search for 'weather today'
|
|
82
|
+
midscene --headed --url https://wwww.bing.com --action "type 'weather today' in search box, hit enter" --sleep 3000
|
|
83
|
+
|
|
84
|
+
# visit github status page and save the status to ./status.json
|
|
85
|
+
midscene --url https://www.githubstatus.com/ \\
|
|
86
|
+
--query-output status.json \\
|
|
87
|
+
--query '{name: string, status: string}[], service status of github page'
|
|
88
|
+
|
|
89
|
+
Examples with Chinese Prompts
|
|
90
|
+
# headed 模式(即可见浏览器)访问 baidu.com 并搜索“天气”
|
|
91
|
+
midscene --headed --url https://www.baidu.com --action "在搜索框输入 '天气', 敲回车" --sleep 3000
|
|
92
|
+
|
|
93
|
+
# 访问 Github 状态页面并将状态保存到 ./status.json
|
|
94
|
+
midscene --url https://www.githubstatus.com/ \\
|
|
95
|
+
--query-output status.json \\
|
|
96
|
+
--query '{serviceName: string, status: string}[], github 页面的服务状态,返回服务名称'
|
|
97
|
+
`);
|
|
98
|
+
process.exit(0);
|
|
99
|
+
} else if (process.argv.indexOf("--version") !== -1) {
|
|
100
|
+
const versionFromPkgJson = require_package().version;
|
|
101
|
+
console.log(`@midscene/cli version ${versionFromPkgJson}`);
|
|
102
|
+
process.exit(0);
|
|
103
|
+
}
|
package/dist/es/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var require_package = __commonJS({
|
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@midscene/cli",
|
|
11
11
|
description: "Cli for Midscene.js",
|
|
12
|
-
version: "0.2.2
|
|
12
|
+
version: "0.2.2",
|
|
13
13
|
"jsnext:source": "./src/index.ts",
|
|
14
14
|
main: "./dist/lib/index.js",
|
|
15
15
|
bin: {
|
|
@@ -138,47 +138,6 @@ var defaultUA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537
|
|
|
138
138
|
var welcome = "\nWelcome to @midscene/cli\n";
|
|
139
139
|
console.log(welcome);
|
|
140
140
|
var args = parse(process.argv);
|
|
141
|
-
if (findOnlyItemInArgs(args, "help")) {
|
|
142
|
-
console.log(`
|
|
143
|
-
Usage: midscene [options] [actions]
|
|
144
|
-
|
|
145
|
-
Options:
|
|
146
|
-
--url <url> The URL to visit, required
|
|
147
|
-
--user-agent <ua> The user agent to use, optional
|
|
148
|
-
--viewport-width <width> The width of the viewport, optional
|
|
149
|
-
--viewport-height <height> The height of the viewport, optional
|
|
150
|
-
--viewport-scale <scale> The device scale factor, optional
|
|
151
|
-
--headed Run in headed mode, default false
|
|
152
|
-
--help Display this help message
|
|
153
|
-
--version Display the version
|
|
154
|
-
|
|
155
|
-
Actions (the order matters, can be used multiple times):
|
|
156
|
-
--action <action> Perform an action, optional
|
|
157
|
-
--assert <assert> Perform an assert, optional
|
|
158
|
-
--query-output <path> Save the result of the query to a file, this must be put before --query, optional
|
|
159
|
-
--query <query> Perform a query, optional
|
|
160
|
-
--sleep <ms> Sleep for a number of milliseconds, optional
|
|
161
|
-
|
|
162
|
-
Examples:
|
|
163
|
-
# headed mode (i.e. visible browser) to visit bing.com and search for 'weather today'
|
|
164
|
-
midscene --headed --url https://wwww.bing.com --action "type 'weather today' in search box, hit enter" --sleep 3000
|
|
165
|
-
|
|
166
|
-
# visit github status page and save the status to ./status.json
|
|
167
|
-
midscene --url https://www.githubstatus.com/ \\
|
|
168
|
-
--query-output status.json \\
|
|
169
|
-
--query '{name: string, status: string}[], service status of github page'
|
|
170
|
-
|
|
171
|
-
Examples with Chinese Prompts
|
|
172
|
-
# headed 模式(即可见浏览器)访问 baidu.com 并搜索“天气”
|
|
173
|
-
midscene --headed --url https://www.baidu.com --action "在搜索框输入 '天气', 敲回车" --sleep 3000
|
|
174
|
-
|
|
175
|
-
# 访问 Github 状态页面并将状态保存到 ./status.json
|
|
176
|
-
midscene --url https://www.githubstatus.com/ \\
|
|
177
|
-
--query-output status.json \\
|
|
178
|
-
--query '{serviceName: string, status: string}[], github 页面的服务状态,返回服务名称'
|
|
179
|
-
`);
|
|
180
|
-
process.exit(0);
|
|
181
|
-
}
|
|
182
141
|
if (findOnlyItemInArgs(args, "version")) {
|
|
183
142
|
const versionFromPkgJson = require_package().version;
|
|
184
143
|
console.log(`@midscene/cli version ${versionFromPkgJson}`);
|
package/dist/lib/help.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
4
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// package.json
|
|
8
|
+
var require_package = __commonJS({
|
|
9
|
+
"package.json"(exports, module2) {
|
|
10
|
+
module2.exports = {
|
|
11
|
+
name: "@midscene/cli",
|
|
12
|
+
description: "Cli for Midscene.js",
|
|
13
|
+
version: "0.2.2",
|
|
14
|
+
"jsnext:source": "./src/index.ts",
|
|
15
|
+
main: "./dist/lib/index.js",
|
|
16
|
+
bin: {
|
|
17
|
+
midscene: "./bin/midscene"
|
|
18
|
+
},
|
|
19
|
+
files: [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
scripts: {
|
|
24
|
+
dev: "modern dev",
|
|
25
|
+
build: "modern build",
|
|
26
|
+
"build:watch": "modern build -w",
|
|
27
|
+
new: "modern new",
|
|
28
|
+
upgrade: "modern upgrade",
|
|
29
|
+
test: "vitest --run",
|
|
30
|
+
"test:all": "AITEST=true vitest --run",
|
|
31
|
+
prepublishOnly: "npm run build"
|
|
32
|
+
},
|
|
33
|
+
dependencies: {
|
|
34
|
+
"@midscene/web": "workspace:*",
|
|
35
|
+
"ora-classic": "5.4.2",
|
|
36
|
+
puppeteer: "^22.8.0",
|
|
37
|
+
yargs: "17.7.2"
|
|
38
|
+
},
|
|
39
|
+
devDependencies: {
|
|
40
|
+
"@modern-js/module-tools": "^2.56.1",
|
|
41
|
+
"@types/node": "^18.0.0",
|
|
42
|
+
"@types/yargs": "17.0.32",
|
|
43
|
+
execa: "9.3.0",
|
|
44
|
+
typescript: "~5.0.4",
|
|
45
|
+
vitest: "^1.6.0"
|
|
46
|
+
},
|
|
47
|
+
engines: {
|
|
48
|
+
node: ">=16.0.0"
|
|
49
|
+
},
|
|
50
|
+
publishConfig: {
|
|
51
|
+
access: "public",
|
|
52
|
+
registry: "https://registry.npmjs.org"
|
|
53
|
+
},
|
|
54
|
+
license: "MIT"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// src/help.ts
|
|
60
|
+
if (process.argv.indexOf("--help") !== -1) {
|
|
61
|
+
console.log(`
|
|
62
|
+
Usage: midscene [options] [actions]
|
|
63
|
+
|
|
64
|
+
Options:
|
|
65
|
+
--url <url> The URL to visit, required
|
|
66
|
+
--user-agent <ua> The user agent to use, optional
|
|
67
|
+
--viewport-width <width> The width of the viewport, optional
|
|
68
|
+
--viewport-height <height> The height of the viewport, optional
|
|
69
|
+
--viewport-scale <scale> The device scale factor, optional
|
|
70
|
+
--headed Run in headed mode, default false
|
|
71
|
+
--help Display this help message
|
|
72
|
+
--version Display the version
|
|
73
|
+
|
|
74
|
+
Actions (the order matters, can be used multiple times):
|
|
75
|
+
--action <action> Perform an action, optional
|
|
76
|
+
--assert <assert> Perform an assert, optional
|
|
77
|
+
--query-output <path> Save the result of the query to a file, this must be put before --query, optional
|
|
78
|
+
--query <query> Perform a query, optional
|
|
79
|
+
--sleep <ms> Sleep for a number of milliseconds, optional
|
|
80
|
+
|
|
81
|
+
Examples:
|
|
82
|
+
# headed mode (i.e. visible browser) to visit bing.com and search for 'weather today'
|
|
83
|
+
midscene --headed --url https://wwww.bing.com --action "type 'weather today' in search box, hit enter" --sleep 3000
|
|
84
|
+
|
|
85
|
+
# visit github status page and save the status to ./status.json
|
|
86
|
+
midscene --url https://www.githubstatus.com/ \\
|
|
87
|
+
--query-output status.json \\
|
|
88
|
+
--query '{name: string, status: string}[], service status of github page'
|
|
89
|
+
|
|
90
|
+
Examples with Chinese Prompts
|
|
91
|
+
# headed 模式(即可见浏览器)访问 baidu.com 并搜索“天气”
|
|
92
|
+
midscene --headed --url https://www.baidu.com --action "在搜索框输入 '天气', 敲回车" --sleep 3000
|
|
93
|
+
|
|
94
|
+
# 访问 Github 状态页面并将状态保存到 ./status.json
|
|
95
|
+
midscene --url https://www.githubstatus.com/ \\
|
|
96
|
+
--query-output status.json \\
|
|
97
|
+
--query '{serviceName: string, status: string}[], github 页面的服务状态,返回服务名称'
|
|
98
|
+
`);
|
|
99
|
+
process.exit(0);
|
|
100
|
+
} else if (process.argv.indexOf("--version") !== -1) {
|
|
101
|
+
const versionFromPkgJson = require_package().version;
|
|
102
|
+
console.log(`@midscene/cli version ${versionFromPkgJson}`);
|
|
103
|
+
process.exit(0);
|
|
104
|
+
}
|
package/dist/lib/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
module2.exports = {
|
|
32
32
|
name: "@midscene/cli",
|
|
33
33
|
description: "Cli for Midscene.js",
|
|
34
|
-
version: "0.2.2
|
|
34
|
+
version: "0.2.2",
|
|
35
35
|
"jsnext:source": "./src/index.ts",
|
|
36
36
|
main: "./dist/lib/index.js",
|
|
37
37
|
bin: {
|
|
@@ -160,47 +160,6 @@ var defaultUA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537
|
|
|
160
160
|
var welcome = "\nWelcome to @midscene/cli\n";
|
|
161
161
|
console.log(welcome);
|
|
162
162
|
var args = parse(process.argv);
|
|
163
|
-
if (findOnlyItemInArgs(args, "help")) {
|
|
164
|
-
console.log(`
|
|
165
|
-
Usage: midscene [options] [actions]
|
|
166
|
-
|
|
167
|
-
Options:
|
|
168
|
-
--url <url> The URL to visit, required
|
|
169
|
-
--user-agent <ua> The user agent to use, optional
|
|
170
|
-
--viewport-width <width> The width of the viewport, optional
|
|
171
|
-
--viewport-height <height> The height of the viewport, optional
|
|
172
|
-
--viewport-scale <scale> The device scale factor, optional
|
|
173
|
-
--headed Run in headed mode, default false
|
|
174
|
-
--help Display this help message
|
|
175
|
-
--version Display the version
|
|
176
|
-
|
|
177
|
-
Actions (the order matters, can be used multiple times):
|
|
178
|
-
--action <action> Perform an action, optional
|
|
179
|
-
--assert <assert> Perform an assert, optional
|
|
180
|
-
--query-output <path> Save the result of the query to a file, this must be put before --query, optional
|
|
181
|
-
--query <query> Perform a query, optional
|
|
182
|
-
--sleep <ms> Sleep for a number of milliseconds, optional
|
|
183
|
-
|
|
184
|
-
Examples:
|
|
185
|
-
# headed mode (i.e. visible browser) to visit bing.com and search for 'weather today'
|
|
186
|
-
midscene --headed --url https://wwww.bing.com --action "type 'weather today' in search box, hit enter" --sleep 3000
|
|
187
|
-
|
|
188
|
-
# visit github status page and save the status to ./status.json
|
|
189
|
-
midscene --url https://www.githubstatus.com/ \\
|
|
190
|
-
--query-output status.json \\
|
|
191
|
-
--query '{name: string, status: string}[], service status of github page'
|
|
192
|
-
|
|
193
|
-
Examples with Chinese Prompts
|
|
194
|
-
# headed 模式(即可见浏览器)访问 baidu.com 并搜索“天气”
|
|
195
|
-
midscene --headed --url https://www.baidu.com --action "在搜索框输入 '天气', 敲回车" --sleep 3000
|
|
196
|
-
|
|
197
|
-
# 访问 Github 状态页面并将状态保存到 ./status.json
|
|
198
|
-
midscene --url https://www.githubstatus.com/ \\
|
|
199
|
-
--query-output status.json \\
|
|
200
|
-
--query '{serviceName: string, status: string}[], github 页面的服务状态,返回服务名称'
|
|
201
|
-
`);
|
|
202
|
-
process.exit(0);
|
|
203
|
-
}
|
|
204
163
|
if (findOnlyItemInArgs(args, "version")) {
|
|
205
164
|
const versionFromPkgJson = require_package().version;
|
|
206
165
|
console.log(`@midscene/cli version ${versionFromPkgJson}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/cli",
|
|
3
3
|
"description": "Cli for Midscene.js",
|
|
4
|
-
"version": "0.2.2
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"jsnext:source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/lib/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"ora-classic": "5.4.2",
|
|
16
16
|
"puppeteer": "^22.8.0",
|
|
17
17
|
"yargs": "17.7.2",
|
|
18
|
-
"@midscene/web": "0.2.2
|
|
18
|
+
"@midscene/web": "0.2.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@modern-js/module-tools": "^2.56.1",
|