weapp-ide-cli 5.1.0 → 5.1.1
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/dist/cli-Dv5EAvYh.js +1350 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +17 -21
- package/dist/commands-9F3ycbXU.js +342 -0
- package/dist/index.d.ts +111 -90
- package/dist/index.js +3 -136
- package/package.json +6 -5
- package/dist/chunk-C2MXNGAM.js +0 -1472
- package/dist/chunk-NSYCXXXT.js +0 -427
- package/dist/commands-QGH4FNJB.js +0 -34
package/dist/chunk-NSYCXXXT.js
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
// src/cli/commands.ts
|
|
2
|
-
import { Buffer } from "buffer";
|
|
3
|
-
import fs from "fs/promises";
|
|
4
|
-
|
|
5
|
-
// src/i18n.ts
|
|
6
|
-
import process from "process";
|
|
7
|
-
var currentLocale = "zh";
|
|
8
|
-
function setLocale(locale) {
|
|
9
|
-
currentLocale = normalizeLocale(locale);
|
|
10
|
-
}
|
|
11
|
-
function configureLocaleFromArgv(argv, fallbackLocale) {
|
|
12
|
-
const localeFromArgv = readLangOption(argv);
|
|
13
|
-
if (localeFromArgv) {
|
|
14
|
-
setLocale(localeFromArgv);
|
|
15
|
-
return currentLocale;
|
|
16
|
-
}
|
|
17
|
-
if (fallbackLocale) {
|
|
18
|
-
setLocale(fallbackLocale);
|
|
19
|
-
return currentLocale;
|
|
20
|
-
}
|
|
21
|
-
const localeFromEnv = process.env.WEAPP_IDE_CLI_LANG || process.env.LANG;
|
|
22
|
-
if (localeFromEnv) {
|
|
23
|
-
setLocale(localeFromEnv);
|
|
24
|
-
return currentLocale;
|
|
25
|
-
}
|
|
26
|
-
setLocale("zh");
|
|
27
|
-
return currentLocale;
|
|
28
|
-
}
|
|
29
|
-
function i18nText(zh, en) {
|
|
30
|
-
return currentLocale === "en" ? en : zh;
|
|
31
|
-
}
|
|
32
|
-
function validateLocaleOption(argv) {
|
|
33
|
-
const localeFromArgv = readLangOption(argv);
|
|
34
|
-
if (!localeFromArgv) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (!isLocaleTokenSupported(localeFromArgv)) {
|
|
38
|
-
throw new Error(`\u4E0D\u652F\u6301\u7684\u8BED\u8A00: ${localeFromArgv}\uFF0C\u4EC5\u652F\u6301 zh \u6216 en`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function normalizeLocale(raw) {
|
|
42
|
-
if (!raw) {
|
|
43
|
-
return "zh";
|
|
44
|
-
}
|
|
45
|
-
const normalized = raw.trim().toLowerCase();
|
|
46
|
-
if (normalized === "en" || normalized.startsWith("en_") || normalized.startsWith("en-")) {
|
|
47
|
-
return "en";
|
|
48
|
-
}
|
|
49
|
-
return "zh";
|
|
50
|
-
}
|
|
51
|
-
function isLocaleTokenSupported(raw) {
|
|
52
|
-
const normalized = raw.trim().toLowerCase();
|
|
53
|
-
return normalized === "zh" || normalized === "en" || normalized.startsWith("zh_") || normalized.startsWith("zh-") || normalized.startsWith("en_") || normalized.startsWith("en-");
|
|
54
|
-
}
|
|
55
|
-
function readLangOption(argv) {
|
|
56
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
57
|
-
const token = argv[index];
|
|
58
|
-
if (!token) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if (token === "--lang") {
|
|
62
|
-
const value = argv[index + 1];
|
|
63
|
-
return typeof value === "string" ? value : void 0;
|
|
64
|
-
}
|
|
65
|
-
if (token.startsWith("--lang=")) {
|
|
66
|
-
return token.slice("--lang=".length);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return void 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/logger.ts
|
|
73
|
-
import logger, { colors } from "@weapp-core/logger";
|
|
74
|
-
var logger_default = logger;
|
|
75
|
-
|
|
76
|
-
// src/cli/automator.ts
|
|
77
|
-
import automator from "miniprogram-automator";
|
|
78
|
-
var DEVTOOLS_HTTP_PORT_ERROR = "Failed to launch wechat web devTools, please make sure http port is open";
|
|
79
|
-
var DEVTOOLS_INFRA_ERROR_PATTERNS = [
|
|
80
|
-
/listen EPERM/i,
|
|
81
|
-
/operation not permitted 0\.0\.0\.0/i,
|
|
82
|
-
/EACCES/i,
|
|
83
|
-
/ECONNREFUSED/i,
|
|
84
|
-
/connect ECONNREFUSED/i
|
|
85
|
-
];
|
|
86
|
-
var DEVTOOLS_LOGIN_REQUIRED_PATTERNS = [
|
|
87
|
-
/code\s*[:=]\s*10/i,
|
|
88
|
-
/需要重新登录/,
|
|
89
|
-
/need\s+re-?login/i,
|
|
90
|
-
/re-?login/i
|
|
91
|
-
];
|
|
92
|
-
function extractErrorText(error) {
|
|
93
|
-
if (!error || typeof error !== "object") {
|
|
94
|
-
return "";
|
|
95
|
-
}
|
|
96
|
-
const parts = [];
|
|
97
|
-
const candidate = error;
|
|
98
|
-
for (const field of [candidate.message, candidate.shortMessage, candidate.stderr, candidate.stdout]) {
|
|
99
|
-
if (typeof field === "string" && field.trim()) {
|
|
100
|
-
parts.push(field);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return parts.join("\n");
|
|
104
|
-
}
|
|
105
|
-
function extractLoginRequiredMessage(text) {
|
|
106
|
-
if (!text) {
|
|
107
|
-
return "";
|
|
108
|
-
}
|
|
109
|
-
if (/需要重新登录/.test(text)) {
|
|
110
|
-
return "\u9700\u8981\u91CD\u65B0\u767B\u5F55";
|
|
111
|
-
}
|
|
112
|
-
const englishMatch = text.match(/need\s+re-?login|re-?login/i);
|
|
113
|
-
if (englishMatch?.[0]) {
|
|
114
|
-
return englishMatch[0].toLowerCase();
|
|
115
|
-
}
|
|
116
|
-
const firstLine = text.split(/\r?\n/).map((line) => line.trim()).find((line) => Boolean(line) && !line.startsWith("at "));
|
|
117
|
-
if (!firstLine) {
|
|
118
|
-
return "";
|
|
119
|
-
}
|
|
120
|
-
return firstLine.replace(/^\[error\]\s*/i, "").replace(/^error\s*:\s*/i, "").slice(0, 120);
|
|
121
|
-
}
|
|
122
|
-
function isDevtoolsHttpPortError(error) {
|
|
123
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
124
|
-
return message.includes(DEVTOOLS_HTTP_PORT_ERROR) || DEVTOOLS_INFRA_ERROR_PATTERNS.some((pattern) => pattern.test(message));
|
|
125
|
-
}
|
|
126
|
-
function isAutomatorLoginError(error) {
|
|
127
|
-
const text = extractErrorText(error);
|
|
128
|
-
if (!text) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
return DEVTOOLS_LOGIN_REQUIRED_PATTERNS.some((pattern) => pattern.test(text));
|
|
132
|
-
}
|
|
133
|
-
function formatAutomatorLoginError(error) {
|
|
134
|
-
const text = extractErrorText(error);
|
|
135
|
-
const code = text.match(/code\s*[:=]\s*(\d+)/i)?.[1];
|
|
136
|
-
const message = extractLoginRequiredMessage(text);
|
|
137
|
-
const lines = ["\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\u8FD4\u56DE\u767B\u5F55\u9519\u8BEF\uFF1A"];
|
|
138
|
-
if (code) {
|
|
139
|
-
lines.push(`- code: ${code}`);
|
|
140
|
-
}
|
|
141
|
-
if (message) {
|
|
142
|
-
lines.push(`- message: ${message}`);
|
|
143
|
-
}
|
|
144
|
-
if (!code && !message) {
|
|
145
|
-
lines.push("- message: \u9700\u8981\u91CD\u65B0\u767B\u5F55");
|
|
146
|
-
}
|
|
147
|
-
return lines.join("\n");
|
|
148
|
-
}
|
|
149
|
-
async function launchAutomator(options) {
|
|
150
|
-
const { projectPath, timeout = 3e4 } = options;
|
|
151
|
-
return automator.launch({
|
|
152
|
-
projectPath,
|
|
153
|
-
timeout
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// src/cli/automator-session.ts
|
|
158
|
-
async function withMiniProgram(options, runner) {
|
|
159
|
-
let miniProgram = null;
|
|
160
|
-
try {
|
|
161
|
-
miniProgram = await launchAutomator(options);
|
|
162
|
-
return await runner(miniProgram);
|
|
163
|
-
} catch (error) {
|
|
164
|
-
if (isAutomatorLoginError(error)) {
|
|
165
|
-
logger_default.error(i18nText(
|
|
166
|
-
"\u68C0\u6D4B\u5230\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\u767B\u5F55\u72B6\u6001\u5931\u6548\uFF0C\u8BF7\u5148\u767B\u5F55\u540E\u91CD\u8BD5\u3002",
|
|
167
|
-
"Wechat DevTools login has expired. Please login and retry."
|
|
168
|
-
));
|
|
169
|
-
logger_default.warn(formatAutomatorLoginError(error));
|
|
170
|
-
throw new Error("DEVTOOLS_LOGIN_REQUIRED");
|
|
171
|
-
}
|
|
172
|
-
if (isDevtoolsHttpPortError(error)) {
|
|
173
|
-
logger_default.error(i18nText(
|
|
174
|
-
"\u65E0\u6CD5\u8FDE\u63A5\u5230\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u5F00\u542F HTTP \u670D\u52A1\u7AEF\u53E3\u3002",
|
|
175
|
-
"Cannot connect to Wechat DevTools. Please ensure HTTP service port is enabled."
|
|
176
|
-
));
|
|
177
|
-
logger_default.warn(i18nText(
|
|
178
|
-
"\u8BF7\u5728\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\u4E2D\uFF1A\u8BBE\u7F6E -> \u5B89\u5168\u8BBE\u7F6E -> \u5F00\u542F\u670D\u52A1\u7AEF\u53E3",
|
|
179
|
-
"Please enable service port in Wechat DevTools: Settings -> Security -> Service Port"
|
|
180
|
-
));
|
|
181
|
-
throw new Error("DEVTOOLS_HTTP_PORT_ERROR");
|
|
182
|
-
}
|
|
183
|
-
throw error;
|
|
184
|
-
} finally {
|
|
185
|
-
if (miniProgram) {
|
|
186
|
-
await miniProgram.close();
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// src/cli/commands.ts
|
|
192
|
-
async function navigateTo(options) {
|
|
193
|
-
await runRouteCommand(
|
|
194
|
-
options,
|
|
195
|
-
i18nText(`\u6B63\u5728\u8DF3\u8F6C\u5230 ${colors.cyan(options.url)}...`, `Navigating to ${colors.cyan(options.url)}...`),
|
|
196
|
-
i18nText(`\u5DF2\u8DF3\u8F6C\u5230 ${colors.cyan(options.url)}`, `Navigated to ${colors.cyan(options.url)}`),
|
|
197
|
-
(miniProgram) => miniProgram.navigateTo(options.url)
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
async function redirectTo(options) {
|
|
201
|
-
await runRouteCommand(
|
|
202
|
-
options,
|
|
203
|
-
i18nText(`\u6B63\u5728\u91CD\u5B9A\u5411\u5230 ${colors.cyan(options.url)}...`, `Redirecting to ${colors.cyan(options.url)}...`),
|
|
204
|
-
i18nText(`\u5DF2\u91CD\u5B9A\u5411\u5230 ${colors.cyan(options.url)}`, `Redirected to ${colors.cyan(options.url)}`),
|
|
205
|
-
(miniProgram) => miniProgram.redirectTo(options.url)
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
async function navigateBack(options) {
|
|
209
|
-
await runRouteCommand(
|
|
210
|
-
options,
|
|
211
|
-
i18nText("\u6B63\u5728\u8FD4\u56DE\u4E0A\u4E00\u9875...", "Navigating back..."),
|
|
212
|
-
i18nText("\u5DF2\u8FD4\u56DE\u4E0A\u4E00\u9875", "Navigated back"),
|
|
213
|
-
(miniProgram) => miniProgram.navigateBack()
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
async function reLaunch(options) {
|
|
217
|
-
await runRouteCommand(
|
|
218
|
-
options,
|
|
219
|
-
i18nText(`\u6B63\u5728\u91CD\u542F\u5230 ${colors.cyan(options.url)}...`, `Relaunching to ${colors.cyan(options.url)}...`),
|
|
220
|
-
i18nText(`\u5DF2\u91CD\u542F\u5230 ${colors.cyan(options.url)}`, `Relaunched to ${colors.cyan(options.url)}`),
|
|
221
|
-
(miniProgram) => miniProgram.reLaunch(options.url)
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
async function switchTab(options) {
|
|
225
|
-
await runRouteCommand(
|
|
226
|
-
options,
|
|
227
|
-
i18nText(`\u6B63\u5728\u5207\u6362 tab \u5230 ${colors.cyan(options.url)}...`, `Switching tab to ${colors.cyan(options.url)}...`),
|
|
228
|
-
i18nText(`\u5DF2\u5207\u6362 tab \u5230 ${colors.cyan(options.url)}`, `Switched tab to ${colors.cyan(options.url)}`),
|
|
229
|
-
(miniProgram) => miniProgram.switchTab(options.url)
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
async function pageStack(options) {
|
|
233
|
-
return withMiniProgram(options, async (miniProgram) => {
|
|
234
|
-
const stack = await miniProgram.pageStack();
|
|
235
|
-
const result = stack.map(toPageSnapshot);
|
|
236
|
-
printStructuredResult(result, options.json, i18nText("\u9875\u9762\u6808\uFF1A", "Page stack:"));
|
|
237
|
-
return result;
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
async function currentPage(options) {
|
|
241
|
-
return withMiniProgram(options, async (miniProgram) => {
|
|
242
|
-
const result = toPageSnapshot(await miniProgram.currentPage());
|
|
243
|
-
if (options.json) {
|
|
244
|
-
console.log(JSON.stringify(result, null, 2));
|
|
245
|
-
} else {
|
|
246
|
-
logger_default.info(i18nText(
|
|
247
|
-
`\u5F53\u524D\u9875\u9762: ${result.path}${result.query ? ` ${JSON.stringify(result.query)}` : ""}`,
|
|
248
|
-
`Current page: ${result.path}${result.query ? ` ${JSON.stringify(result.query)}` : ""}`
|
|
249
|
-
));
|
|
250
|
-
}
|
|
251
|
-
return result;
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
async function systemInfo(options) {
|
|
255
|
-
return withMiniProgram(options, async (miniProgram) => {
|
|
256
|
-
const info = await miniProgram.systemInfo();
|
|
257
|
-
printStructuredResult(info, options.json, i18nText("\u7CFB\u7EDF\u4FE1\u606F\uFF1A", "System info:"));
|
|
258
|
-
return info;
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
async function pageData(options) {
|
|
262
|
-
return withMiniProgram(options, async (miniProgram) => {
|
|
263
|
-
const page = await miniProgram.currentPage();
|
|
264
|
-
const data = await page.data(options.path);
|
|
265
|
-
printStructuredResult(data, options.json, i18nText("\u9875\u9762\u6570\u636E\uFF1A", "Page data:"));
|
|
266
|
-
return data;
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
async function tap(options) {
|
|
270
|
-
await withMiniProgram(options, async (miniProgram) => {
|
|
271
|
-
logger_default.info(i18nText(
|
|
272
|
-
`\u6B63\u5728\u70B9\u51FB\u5143\u7D20 ${colors.cyan(options.selector)}...`,
|
|
273
|
-
`Tapping element ${colors.cyan(options.selector)}...`
|
|
274
|
-
));
|
|
275
|
-
const page = await miniProgram.currentPage();
|
|
276
|
-
const element = await requireElement(page, options.selector);
|
|
277
|
-
await element.tap();
|
|
278
|
-
logger_default.success(i18nText(
|
|
279
|
-
`\u5DF2\u70B9\u51FB\u5143\u7D20 ${colors.cyan(options.selector)}`,
|
|
280
|
-
`Tapped element ${colors.cyan(options.selector)}`
|
|
281
|
-
));
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
async function input(options) {
|
|
285
|
-
await withMiniProgram(options, async (miniProgram) => {
|
|
286
|
-
logger_default.info(i18nText(
|
|
287
|
-
`\u6B63\u5728\u5411 ${colors.cyan(options.selector)} \u8F93\u5165 "${colors.cyan(options.value)}"...`,
|
|
288
|
-
`Inputting "${colors.cyan(options.value)}" into ${colors.cyan(options.selector)}...`
|
|
289
|
-
));
|
|
290
|
-
const page = await miniProgram.currentPage();
|
|
291
|
-
const element = await requireElement(page, options.selector);
|
|
292
|
-
if (typeof element.input !== "function") {
|
|
293
|
-
throw new TypeError(i18nText(
|
|
294
|
-
`\u5143\u7D20\u4E0D\u652F\u6301\u8F93\u5165: ${options.selector}`,
|
|
295
|
-
`Element does not support input: ${options.selector}`
|
|
296
|
-
));
|
|
297
|
-
}
|
|
298
|
-
await element.input(options.value);
|
|
299
|
-
logger_default.success(i18nText(
|
|
300
|
-
`\u5DF2\u5411 ${colors.cyan(options.selector)} \u8F93\u5165 "${colors.cyan(options.value)}"`,
|
|
301
|
-
`Inputted "${colors.cyan(options.value)}" into ${colors.cyan(options.selector)}`
|
|
302
|
-
));
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
async function scrollTo(options) {
|
|
306
|
-
await withMiniProgram(options, async (miniProgram) => {
|
|
307
|
-
logger_default.info(i18nText(
|
|
308
|
-
`\u6B63\u5728\u6EDA\u52A8\u5230\u4F4D\u7F6E ${colors.cyan(String(options.scrollTop))}...`,
|
|
309
|
-
`Scrolling to position ${colors.cyan(String(options.scrollTop))}...`
|
|
310
|
-
));
|
|
311
|
-
await miniProgram.pageScrollTo(options.scrollTop);
|
|
312
|
-
logger_default.success(i18nText(
|
|
313
|
-
`\u5DF2\u6EDA\u52A8\u5230\u4F4D\u7F6E ${colors.cyan(String(options.scrollTop))}`,
|
|
314
|
-
`Scrolled to position ${colors.cyan(String(options.scrollTop))}`
|
|
315
|
-
));
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
async function audit(options) {
|
|
319
|
-
return withMiniProgram(options, async (miniProgram) => {
|
|
320
|
-
logger_default.info(i18nText("\u6B63\u5728\u6267\u884C\u4F53\u9A8C\u5BA1\u8BA1...", "Running experience audit..."));
|
|
321
|
-
const result = await miniProgram.stopAudits();
|
|
322
|
-
if (options.outputPath) {
|
|
323
|
-
await fs.writeFile(options.outputPath, JSON.stringify(result, null, 2));
|
|
324
|
-
logger_default.success(i18nText(
|
|
325
|
-
`\u5BA1\u8BA1\u62A5\u544A\u5DF2\u4FDD\u5B58\u5230 ${colors.cyan(options.outputPath)}`,
|
|
326
|
-
`Audit report saved to ${colors.cyan(options.outputPath)}`
|
|
327
|
-
));
|
|
328
|
-
return result;
|
|
329
|
-
}
|
|
330
|
-
console.log(JSON.stringify(result, null, 2));
|
|
331
|
-
return result;
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
async function takeScreenshot(options) {
|
|
335
|
-
return withMiniProgram(options, async (miniProgram) => {
|
|
336
|
-
logger_default.info(i18nText(
|
|
337
|
-
`\u6B63\u5728\u8FDE\u63A5 DevTools\uFF1A${colors.cyan(options.projectPath)}...`,
|
|
338
|
-
`Connecting to DevTools at ${colors.cyan(options.projectPath)}...`
|
|
339
|
-
));
|
|
340
|
-
if (options.page) {
|
|
341
|
-
logger_default.info(i18nText(
|
|
342
|
-
`\u6B63\u5728\u8DF3\u8F6C\u9875\u9762 ${colors.cyan(options.page)}...`,
|
|
343
|
-
`Navigating to page ${colors.cyan(options.page)}...`
|
|
344
|
-
));
|
|
345
|
-
await miniProgram.reLaunch(options.page);
|
|
346
|
-
}
|
|
347
|
-
logger_default.info(i18nText("\u6B63\u5728\u622A\u56FE...", "Taking screenshot..."));
|
|
348
|
-
const screenshot = await miniProgram.screenshot();
|
|
349
|
-
const base64 = typeof screenshot === "string" ? screenshot : Buffer.from(screenshot).toString("base64");
|
|
350
|
-
if (!base64) {
|
|
351
|
-
throw new Error(i18nText("\u622A\u56FE\u5931\u8D25", "Failed to capture screenshot"));
|
|
352
|
-
}
|
|
353
|
-
if (options.outputPath) {
|
|
354
|
-
await fs.writeFile(options.outputPath, Buffer.from(base64, "base64"));
|
|
355
|
-
logger_default.success(i18nText(
|
|
356
|
-
`\u622A\u56FE\u5DF2\u4FDD\u5B58\u5230 ${colors.cyan(options.outputPath)}`,
|
|
357
|
-
`Screenshot saved to ${colors.cyan(options.outputPath)}`
|
|
358
|
-
));
|
|
359
|
-
return { path: options.outputPath };
|
|
360
|
-
}
|
|
361
|
-
return { base64 };
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
async function remote(options) {
|
|
365
|
-
const enable = options.enable ?? true;
|
|
366
|
-
await withMiniProgram(options, async (miniProgram) => {
|
|
367
|
-
logger_default.info(enable ? i18nText("\u6B63\u5728\u5F00\u542F\u8FDC\u7A0B\u8C03\u8BD5...", "Enabling remote debugging...") : i18nText("\u6B63\u5728\u5173\u95ED\u8FDC\u7A0B\u8C03\u8BD5...", "Disabling remote debugging..."));
|
|
368
|
-
await miniProgram.remote(enable);
|
|
369
|
-
logger_default.success(enable ? i18nText("\u8FDC\u7A0B\u8C03\u8BD5\u5DF2\u5F00\u542F", "Remote debugging enabled") : i18nText("\u8FDC\u7A0B\u8C03\u8BD5\u5DF2\u5173\u95ED", "Remote debugging disabled"));
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
async function runRouteCommand(options, startMessage, successMessage, run) {
|
|
373
|
-
await withMiniProgram(options, async (miniProgram) => {
|
|
374
|
-
logger_default.info(startMessage);
|
|
375
|
-
await run(miniProgram);
|
|
376
|
-
logger_default.success(successMessage);
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
function toPageSnapshot(page) {
|
|
380
|
-
return {
|
|
381
|
-
path: page.path ?? "",
|
|
382
|
-
query: page.query
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function printStructuredResult(result, json, title) {
|
|
386
|
-
if (json) {
|
|
387
|
-
console.log(JSON.stringify(result, null, 2));
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
logger_default.info(title);
|
|
391
|
-
console.log(JSON.stringify(result, null, 2));
|
|
392
|
-
}
|
|
393
|
-
async function requireElement(page, selector) {
|
|
394
|
-
const element = await page.$(selector);
|
|
395
|
-
if (!element) {
|
|
396
|
-
throw new Error(i18nText(`\u672A\u627E\u5230\u5143\u7D20: ${selector}`, `Element not found: ${selector}`));
|
|
397
|
-
}
|
|
398
|
-
return element;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
export {
|
|
402
|
-
isDevtoolsHttpPortError,
|
|
403
|
-
isAutomatorLoginError,
|
|
404
|
-
formatAutomatorLoginError,
|
|
405
|
-
launchAutomator,
|
|
406
|
-
configureLocaleFromArgv,
|
|
407
|
-
i18nText,
|
|
408
|
-
validateLocaleOption,
|
|
409
|
-
colors,
|
|
410
|
-
logger_default,
|
|
411
|
-
withMiniProgram,
|
|
412
|
-
navigateTo,
|
|
413
|
-
redirectTo,
|
|
414
|
-
navigateBack,
|
|
415
|
-
reLaunch,
|
|
416
|
-
switchTab,
|
|
417
|
-
pageStack,
|
|
418
|
-
currentPage,
|
|
419
|
-
systemInfo,
|
|
420
|
-
pageData,
|
|
421
|
-
tap,
|
|
422
|
-
input,
|
|
423
|
-
scrollTo,
|
|
424
|
-
audit,
|
|
425
|
-
takeScreenshot,
|
|
426
|
-
remote
|
|
427
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
audit,
|
|
3
|
-
currentPage,
|
|
4
|
-
input,
|
|
5
|
-
navigateBack,
|
|
6
|
-
navigateTo,
|
|
7
|
-
pageData,
|
|
8
|
-
pageStack,
|
|
9
|
-
reLaunch,
|
|
10
|
-
redirectTo,
|
|
11
|
-
remote,
|
|
12
|
-
scrollTo,
|
|
13
|
-
switchTab,
|
|
14
|
-
systemInfo,
|
|
15
|
-
takeScreenshot,
|
|
16
|
-
tap
|
|
17
|
-
} from "./chunk-NSYCXXXT.js";
|
|
18
|
-
export {
|
|
19
|
-
audit,
|
|
20
|
-
currentPage,
|
|
21
|
-
input,
|
|
22
|
-
navigateBack,
|
|
23
|
-
navigateTo,
|
|
24
|
-
pageData,
|
|
25
|
-
pageStack,
|
|
26
|
-
reLaunch,
|
|
27
|
-
redirectTo,
|
|
28
|
-
remote,
|
|
29
|
-
scrollTo,
|
|
30
|
-
switchTab,
|
|
31
|
-
systemInfo,
|
|
32
|
-
takeScreenshot,
|
|
33
|
-
tap
|
|
34
|
-
};
|