weapp-ide-cli 5.1.4 → 5.2.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/README.md CHANGED
@@ -37,6 +37,8 @@ weapp open --project ./dist/dev/mp-weixin
37
37
  # 执行预览、上传等官方支持的命令
38
38
  weapp preview
39
39
  weapp upload --project ./dist/build/mp-weixin
40
+ weapp cache --clean compile
41
+ weapp cache --clean all
40
42
  ```
41
43
 
42
44
  `weapp` 与 `weapp-ide-cli` 等价,选择任一前缀即可。
@@ -92,6 +94,35 @@ weapp open --platform alipay -p ./dist/dev/mp-alipay
92
94
 
93
95
  - <https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html>
94
96
 
97
+ 其中 `weapp cloud` 为云开发命令族入口,可继续透传官方子命令,例如:
98
+
99
+ ```bash
100
+ weapp cloud env list
101
+ weapp cloud functions list
102
+ weapp cloud functions info --name hello
103
+ weapp cloud functions deploy --name hello
104
+ weapp cloud functions inc-deploy --name hello
105
+ weapp cloud functions download --name hello
106
+ ```
107
+
108
+ 缓存清理示例:
109
+
110
+ ```bash
111
+ weapp cache --clean compile
112
+ weapp cache --clean network
113
+ weapp cache --clean all
114
+ ```
115
+
116
+ 支持的缓存类型:
117
+
118
+ - `storage`
119
+ - `file`
120
+ - `compile`
121
+ - `auth`
122
+ - `network`
123
+ - `session`
124
+ - `all`
125
+
95
126
  ### 2. automator 增强命令
96
127
 
97
128
  `weapp-ide-cli` 内置 automator 子命令:
@@ -99,6 +130,7 @@ weapp open --platform alipay -p ./dist/dev/mp-alipay
99
130
  | 命令 | 说明 |
100
131
  | -------------------------------- | ------------------------------ |
101
132
  | `weapp screenshot` | 截图(支持 base64 / 文件输出) |
133
+ | `weapp compare` | 截图对比(pixelmatch) |
102
134
  | `weapp navigate <url>` | 保留栈跳转页面 |
103
135
  | `weapp redirect <url>` | 重定向页面 |
104
136
  | `weapp back` | 页面返回 |
@@ -1,6 +1,9 @@
1
- import { A as createLocaleConfig, B as operatingSystemName, E as resolveCliPath, F as defaultCustomConfigFilePath, H as logger_default, I as resolvePath, M as readCustomConfig, N as removeCustomConfigKey, O as getConfiguredLocale, V as colors, _ as connectMiniProgram, a as navigateBack, b as i18nText, c as pageStack, d as remote, f as scrollTo, g as tap, i as input, j as overwriteCustomConfig, k as createCustomConfig, l as reLaunch, m as systemInfo, o as navigateTo, p as switchTab, r as currentPage, s as pageData, t as audit, u as redirectTo, x as validateLocaleOption, y as configureLocaleFromArgv, z as isOperatingSystemSupported } from "./commands-CSbpftLN.js";
2
- import fs from "fs-extra";
1
+ import { A as createCustomConfig, B as isOperatingSystemSupported, D as resolveCliPath, H as colors, I as defaultCustomConfigFilePath, L as resolvePath, M as overwriteCustomConfig, N as readCustomConfig, P as removeCustomConfigKey, S as validateLocaleOption, U as logger_default, V as operatingSystemName, _ as tap, a as input, b as configureLocaleFromArgv, c as pageData, d as redirectTo, f as remote, h as systemInfo, i as currentPage, j as createLocaleConfig, k as getConfiguredLocale, l as pageStack, m as switchTab, n as captureScreenshotBuffer, o as navigateBack, p as scrollTo, s as navigateTo, t as audit, u as reLaunch, v as connectMiniProgram, x as i18nText } from "./commands-BfdE1eYN.js";
2
+ import { fs } from "@weapp-core/shared";
3
3
  import process, { stdin, stdout } from "node:process";
4
+ import fs$1 from "node:fs/promises";
5
+ import pixelmatch from "pixelmatch";
6
+ import { PNG } from "pngjs";
4
7
  import { createInterface } from "node:readline/promises";
5
8
  import { inspect } from "node:util";
6
9
  import { emitKeypressEvents } from "node:readline";
@@ -105,6 +108,204 @@ function takesValue(optionName) {
105
108
  return optionName === "-p" || optionName === "--project" || optionName === "-t" || optionName === "--timeout" || optionName === "-o" || optionName === "--output" || optionName === "--page" || optionName === "--login-retry" || optionName === "--login-retry-timeout" || optionName === "--lang" || optionName === "--platform" || optionName === "--qr-output" || optionName === "-r" || optionName === "--result-output" || optionName === "--info-output" || optionName === "-i";
106
109
  }
107
110
  //#endregion
111
+ //#region src/cli/imageDiff.ts
112
+ function readPng(buffer, label) {
113
+ try {
114
+ return PNG.sync.read(buffer);
115
+ } catch (error) {
116
+ throw new Error(i18nText(`${label} 不是有效的 PNG 文件`, `${label} is not a valid PNG file`), { cause: error });
117
+ }
118
+ }
119
+ /**
120
+ * @description 将当前截图与基准图做像素对比,并按需输出当前图与 diff 图。
121
+ */
122
+ async function comparePngWithBaseline(options) {
123
+ let baselineBuffer;
124
+ try {
125
+ baselineBuffer = await fs$1.readFile(options.baselinePath);
126
+ } catch (error) {
127
+ throw new Error(i18nText(`无法读取基准图: ${options.baselinePath}`, `Failed to read baseline image: ${options.baselinePath}`), { cause: error });
128
+ }
129
+ const baselinePng = readPng(baselineBuffer, i18nText("基准图", "Baseline image"));
130
+ const currentPng = readPng(options.currentPngBuffer, i18nText("当前截图", "Current screenshot"));
131
+ if (baselinePng.width !== currentPng.width || baselinePng.height !== currentPng.height) throw new Error(i18nText("基准图与当前截图尺寸不一致", "Baseline image size does not match current screenshot"));
132
+ if (options.currentOutputPath) await fs$1.writeFile(options.currentOutputPath, options.currentPngBuffer);
133
+ const diffPng = new PNG({
134
+ width: currentPng.width,
135
+ height: currentPng.height
136
+ });
137
+ const diffPixels = pixelmatch(baselinePng.data, currentPng.data, diffPng.data, currentPng.width, currentPng.height, { threshold: options.threshold });
138
+ if (options.diffOutputPath) await fs$1.writeFile(options.diffOutputPath, PNG.sync.write(diffPng));
139
+ return {
140
+ baselinePath: options.baselinePath,
141
+ currentPath: options.currentOutputPath,
142
+ diffPath: options.diffOutputPath,
143
+ width: currentPng.width,
144
+ height: currentPng.height,
145
+ diffPixels,
146
+ diffRatio: diffPixels / (currentPng.width * currentPng.height)
147
+ };
148
+ }
149
+ //#endregion
150
+ //#region src/cli/compare.ts
151
+ function createCliError(message, exitCode, cause) {
152
+ const error = new Error(message, cause ? { cause } : void 0);
153
+ error.exitCode = exitCode;
154
+ return error;
155
+ }
156
+ function parseNonNegativeInteger(rawValue, optionName) {
157
+ if (rawValue == null) return;
158
+ const value = Number(rawValue);
159
+ if (!Number.isInteger(value) || value < 0) throw createCliError(i18nText(`${optionName} 必须是大于等于 0 的整数`, `${optionName} must be an integer greater than or equal to 0`), 2);
160
+ return value;
161
+ }
162
+ function parseRatio(rawValue, optionName) {
163
+ if (rawValue == null) return;
164
+ const value = Number(rawValue);
165
+ if (!Number.isFinite(value) || value < 0 || value > 1) throw createCliError(i18nText(`${optionName} 必须是 0 到 1 之间的数字`, `${optionName} must be a number between 0 and 1`), 2);
166
+ return value;
167
+ }
168
+ /**
169
+ * @description 输出 compare 命令帮助信息。
170
+ */
171
+ function printCompareHelp() {
172
+ console.log(i18nText(`
173
+ ${colors.bold("Usage:")} weapp compare [options]
174
+
175
+ ${colors.bold("参数:")}
176
+ -p, --project <path> 项目路径(默认:当前目录)
177
+ --baseline <path> 基准图路径(必填)
178
+ --current-output <path> 当前截图输出路径
179
+ --diff-output <path> diff 图片输出路径
180
+ --page <path> 对比前先跳转页面
181
+ --threshold <number> pixelmatch threshold(默认:0.1)
182
+ --max-diff-pixels <count> 最大允许差异像素数
183
+ --max-diff-ratio <number> 最大允许差异占比(0-1)
184
+ -t, --timeout <ms> 连接超时时间(默认:30000)
185
+ --json 以 JSON 格式输出
186
+ --lang <lang> 语言切换:zh | en(默认:zh)
187
+ -h, --help 显示此帮助信息
188
+
189
+ ${colors.bold("规则:")}
190
+ - 必须提供 --baseline
191
+ - 必须至少提供 --max-diff-pixels 或 --max-diff-ratio 之一
192
+ - baseline 与当前截图尺寸不一致时直接失败
193
+
194
+ ${colors.bold("示例:")}
195
+ weapp compare -p ./dist/build/mp-weixin --page pages/index/index --baseline .screenshots/baseline/index.png --current-output .screenshots/current/index.png --diff-output .screenshots/diff/index.diff.png --max-diff-pixels 100 --json
196
+
197
+ weapp compare -p ./dist/build/mp-weixin --baseline .screenshots/baseline/index.png --max-diff-ratio 0.001
198
+ `, `
199
+ ${colors.bold("Usage:")} weapp compare [options]
200
+
201
+ ${colors.bold("Options:")}
202
+ -p, --project <path> Project path (default: current directory)
203
+ --baseline <path> Baseline image path (required)
204
+ --current-output <path> Output file path for current screenshot
205
+ --diff-output <path> Output file path for diff image
206
+ --page <path> Navigate to page before comparison
207
+ --threshold <number> Pixelmatch threshold (default: 0.1)
208
+ --max-diff-pixels <count> Maximum allowed diff pixels
209
+ --max-diff-ratio <number> Maximum allowed diff ratio (0-1)
210
+ -t, --timeout <ms> Connection timeout in milliseconds (default: 30000)
211
+ --json Output as JSON format
212
+ --lang <lang> Language: zh | en (default: zh)
213
+ -h, --help Show this help message
214
+
215
+ ${colors.bold("Rules:")}
216
+ - --baseline is required
217
+ - At least one of --max-diff-pixels or --max-diff-ratio is required
218
+ - Baseline and current screenshot must have identical dimensions
219
+
220
+ ${colors.bold("Examples:")}
221
+ weapp compare -p ./dist/build/mp-weixin --page pages/index/index --baseline .screenshots/baseline/index.png --current-output .screenshots/current/index.png --diff-output .screenshots/diff/index.diff.png --max-diff-pixels 100 --json
222
+
223
+ weapp compare -p ./dist/build/mp-weixin --baseline .screenshots/baseline/index.png --max-diff-ratio 0.001
224
+ `));
225
+ }
226
+ /**
227
+ * @description 解析 compare 命令参数。
228
+ */
229
+ function parseCompareArgs(argv) {
230
+ const parsed = parseAutomatorArgs(argv);
231
+ const baselinePath = readOptionValue(argv, "--baseline");
232
+ if (!baselinePath) throw createCliError(i18nText("compare 命令缺少 --baseline 参数", "Missing --baseline option for compare command"), 2);
233
+ const threshold = parseRatio(readOptionValue(argv, "--threshold"), "--threshold") ?? .1;
234
+ const maxDiffPixels = parseNonNegativeInteger(readOptionValue(argv, "--max-diff-pixels"), "--max-diff-pixels");
235
+ const maxDiffRatio = parseRatio(readOptionValue(argv, "--max-diff-ratio"), "--max-diff-ratio");
236
+ if (maxDiffPixels == null && maxDiffRatio == null) throw createCliError(i18nText("compare 命令至少需要提供 --max-diff-pixels 或 --max-diff-ratio 之一", "compare command requires at least one of --max-diff-pixels or --max-diff-ratio"), 2);
237
+ return {
238
+ projectPath: parsed.projectPath,
239
+ timeout: parsed.timeout,
240
+ page: readOptionValue(argv, "--page"),
241
+ baselinePath,
242
+ currentOutputPath: readOptionValue(argv, "--current-output"),
243
+ diffOutputPath: readOptionValue(argv, "--diff-output"),
244
+ threshold,
245
+ maxDiffPixels,
246
+ maxDiffRatio
247
+ };
248
+ }
249
+ function resolveComparePassed(diff, options) {
250
+ if (options.maxDiffPixels != null && diff.diffPixels > options.maxDiffPixels) return false;
251
+ if (options.maxDiffRatio != null && diff.diffRatio > options.maxDiffRatio) return false;
252
+ return true;
253
+ }
254
+ function printCompareSummary(result) {
255
+ const summary = result.passed ? i18nText(`compare passed: diffPixels=${result.diffPixels} diffRatio=${result.diffRatio}`, `compare passed: diffPixels=${result.diffPixels} diffRatio=${result.diffRatio}`) : i18nText(`compare failed: diffPixels=${result.diffPixels} diffRatio=${result.diffRatio}`, `compare failed: diffPixels=${result.diffPixels} diffRatio=${result.diffRatio}`);
256
+ console.log(summary);
257
+ const pathSummary = [
258
+ `baseline=${result.baselinePath}`,
259
+ result.currentPath ? `current=${result.currentPath}` : void 0,
260
+ result.diffPath ? `diff=${result.diffPath}` : void 0
261
+ ].filter(Boolean).join(" ");
262
+ if (pathSummary) console.log(pathSummary);
263
+ }
264
+ /**
265
+ * @description 运行 compare 命令并输出对比结果。
266
+ */
267
+ async function runCompare(argv) {
268
+ if (argv.includes("-h") || argv.includes("--help")) {
269
+ printCompareHelp();
270
+ return;
271
+ }
272
+ const options = parseCompareArgs(argv);
273
+ let currentPngBuffer;
274
+ try {
275
+ currentPngBuffer = await captureScreenshotBuffer(options);
276
+ } catch (error) {
277
+ throw createCliError(error instanceof Error ? error.message : i18nText("截图失败", "Failed to capture screenshot"), 3, error);
278
+ }
279
+ let diff;
280
+ try {
281
+ diff = await comparePngWithBaseline({
282
+ baselinePath: options.baselinePath,
283
+ currentPngBuffer,
284
+ currentOutputPath: options.currentOutputPath,
285
+ diffOutputPath: options.diffOutputPath,
286
+ threshold: options.threshold
287
+ });
288
+ } catch (error) {
289
+ throw createCliError(error instanceof Error ? error.message : i18nText("截图对比失败", "Screenshot comparison failed"), 3, error);
290
+ }
291
+ const result = {
292
+ passed: resolveComparePassed(diff, options),
293
+ baselinePath: options.baselinePath,
294
+ currentPath: diff.currentPath,
295
+ diffPath: diff.diffPath,
296
+ width: diff.width,
297
+ height: diff.height,
298
+ diffPixels: diff.diffPixels,
299
+ diffRatio: diff.diffRatio,
300
+ threshold: options.threshold,
301
+ maxDiffPixels: options.maxDiffPixels,
302
+ maxDiffRatio: options.maxDiffRatio
303
+ };
304
+ if (argv.includes("--json")) console.log(JSON.stringify(result, null, 2));
305
+ else printCompareSummary(result);
306
+ if (!result.passed) process.exitCode = 1;
307
+ }
308
+ //#endregion
108
309
  //#region src/cli/screenshot.ts
109
310
  /**
110
311
  * @description Print help for screenshot command
@@ -182,7 +383,7 @@ async function runScreenshot(argv) {
182
383
  }
183
384
  const options = parseScreenshotArgs(argv);
184
385
  const isJsonOutput = argv.includes("--json");
185
- const { takeScreenshot } = await import("./commands-CSbpftLN.js").then((n) => n.n);
386
+ const { takeScreenshot } = await import("./commands-BfdE1eYN.js").then((n) => n.r);
186
387
  const result = await takeScreenshot(options);
187
388
  if (isJsonOutput) {
188
389
  console.log(JSON.stringify(result, null, 2));
@@ -461,7 +662,11 @@ const COMMAND_DEFINITIONS = {
461
662
  }
462
663
  })
463
664
  };
464
- const AUTOMATOR_COMMAND_NAMES = ["screenshot", ...Object.keys(COMMAND_DEFINITIONS)];
665
+ const AUTOMATOR_COMMAND_NAMES = [
666
+ "screenshot",
667
+ "compare",
668
+ ...Object.keys(COMMAND_DEFINITIONS)
669
+ ];
465
670
  const AUTOMATOR_COMMAND_SET = new Set(AUTOMATOR_COMMAND_NAMES);
466
671
  /**
467
672
  * @description 判断是否属于 automator 子命令。
@@ -500,6 +705,10 @@ async function runAutomatorCommand(command, argv) {
500
705
  await runScreenshot(argv);
501
706
  return;
502
707
  }
708
+ if (command === "compare") {
709
+ await runCompare(argv);
710
+ return;
711
+ }
503
712
  const definition = COMMAND_DEFINITIONS[command];
504
713
  if (!definition) throw new Error(i18nText(`未知 automator 命令: ${command}`, `Unknown automator command: ${command}`));
505
714
  if (argv.includes("-h") || argv.includes("--help")) {
@@ -1108,6 +1317,36 @@ function flushExecutionOutput(result) {
1108
1317
  }
1109
1318
  //#endregion
1110
1319
  //#region src/cli/wechat-command-schema.ts
1320
+ const CACHE_CLEAN_TYPES = [
1321
+ "storage",
1322
+ "file",
1323
+ "compile",
1324
+ "auth",
1325
+ "network",
1326
+ "session",
1327
+ "all"
1328
+ ];
1329
+ function isNonEmptyText(value) {
1330
+ return typeof value === "string" && value.trim().length > 0;
1331
+ }
1332
+ function validatePortOption(argv) {
1333
+ const port = readOptionValue(argv, "--port");
1334
+ if (!port) return;
1335
+ const parsed = Number.parseInt(port, 10);
1336
+ if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(i18nText(`无效的 --port 值: ${port}(必须为正整数)`, `Invalid --port value: ${port} (must be a positive integer)`));
1337
+ }
1338
+ function validateProjectLocator(command, argv) {
1339
+ const projectPath = readOptionValue(argv, "--project");
1340
+ const appid = readOptionValue(argv, "--appid");
1341
+ if (isNonEmptyText(projectPath) || isNonEmptyText(appid)) return;
1342
+ throw new Error(i18nText(`${command} 命令需要提供 --project 或 --appid`, `${command} command requires --project or --appid`));
1343
+ }
1344
+ function validateExtAppidDependency(argv) {
1345
+ if (!isNonEmptyText(readOptionValue(argv, "--ext-appid"))) return;
1346
+ if (isNonEmptyText(readOptionValue(argv, "--project"))) return;
1347
+ if (isNonEmptyText(readOptionValue(argv, "--appid"))) return;
1348
+ throw new Error(i18nText("--ext-appid 需要和 --appid 一起使用(当未提供 --project 时)", "--ext-appid requires --appid when --project is not provided"));
1349
+ }
1111
1350
  /**
1112
1351
  * @description 在调用官方微信 CLI 前做轻量参数校验。
1113
1352
  */
@@ -1131,29 +1370,13 @@ function validateWechatCliCommandArgs(argv) {
1131
1370
  "base64"
1132
1371
  ].includes(qrFormat.toLowerCase())) throw new Error(i18nText(`preview 命令的二维码格式无效: ${qrFormat}(仅支持 terminal/image/base64)`, `Invalid preview qr format: ${qrFormat} (supported: terminal/image/base64)`));
1133
1372
  }
1373
+ if (command === "cache") {
1374
+ const cleanType = readOptionValue(argv, "--clean") || readOptionValue(argv, "-c");
1375
+ if (!isNonEmptyText(cleanType)) throw new Error(i18nText("cache 命令缺少必填参数:--clean/-c", "cache command requires --clean/-c"));
1376
+ if (!CACHE_CLEAN_TYPES.includes(cleanType)) throw new Error(i18nText(`cache 命令的清理类型无效: ${cleanType}(仅支持 ${CACHE_CLEAN_TYPES.join("/")})`, `Invalid cache clean type: ${cleanType} (supported: ${CACHE_CLEAN_TYPES.join("/")})`));
1377
+ }
1134
1378
  if (command === "upload" || command === "auto" || command === "auto-preview") validateProjectLocator(command, argv);
1135
1379
  }
1136
- function validatePortOption(argv) {
1137
- const port = readOptionValue(argv, "--port");
1138
- if (!port) return;
1139
- const parsed = Number.parseInt(port, 10);
1140
- if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(i18nText(`无效的 --port 值: ${port}(必须为正整数)`, `Invalid --port value: ${port} (must be a positive integer)`));
1141
- }
1142
- function validateProjectLocator(command, argv) {
1143
- const projectPath = readOptionValue(argv, "--project");
1144
- const appid = readOptionValue(argv, "--appid");
1145
- if (isNonEmptyText(projectPath) || isNonEmptyText(appid)) return;
1146
- throw new Error(i18nText(`${command} 命令需要提供 --project 或 --appid`, `${command} command requires --project or --appid`));
1147
- }
1148
- function validateExtAppidDependency(argv) {
1149
- if (!isNonEmptyText(readOptionValue(argv, "--ext-appid"))) return;
1150
- if (isNonEmptyText(readOptionValue(argv, "--project"))) return;
1151
- if (isNonEmptyText(readOptionValue(argv, "--appid"))) return;
1152
- throw new Error(i18nText("--ext-appid 需要和 --appid 一起使用(当未提供 --project 时)", "--ext-appid requires --appid when --project is not provided"));
1153
- }
1154
- function isNonEmptyText(value) {
1155
- return typeof value === "string" && value.trim().length > 0;
1156
- }
1157
1380
  //#endregion
1158
1381
  //#region src/cli/run.ts
1159
1382
  const MINIDEV_NAMESPACE = new Set(MINIDEV_NAMESPACE_COMMAND_NAMES);
@@ -1179,23 +1402,7 @@ function createCli() {
1179
1402
  for (const command of WECHAT_CLI_COMMAND_NAMES) cli.command(command, "微信开发者工具官方命令透传").allowUnknownOptions();
1180
1403
  for (const command of MINIDEV_NAMESPACE_COMMAND_NAMES) cli.command(`${command} [...args]`, "支付宝 minidev 命令透传").allowUnknownOptions();
1181
1404
  cli.command(`${CONFIG_COMMAND_NAME} [...args]`, "配置 weapp-ide-cli").allowUnknownOptions();
1182
- for (const command of [
1183
- "screenshot",
1184
- "navigate",
1185
- "redirect",
1186
- "back",
1187
- "relaunch",
1188
- "switch-tab",
1189
- "page-stack",
1190
- "current-page",
1191
- "system-info",
1192
- "page-data",
1193
- "tap",
1194
- "input",
1195
- "scroll",
1196
- "audit",
1197
- "remote"
1198
- ]) cli.command(`${command} [...args]`, "automator 增强命令").allowUnknownOptions();
1405
+ for (const command of AUTOMATOR_COMMAND_NAMES) cli.command(`${command} [...args]`, "automator 增强命令").allowUnknownOptions();
1199
1406
  return cli;
1200
1407
  }
1201
1408
  async function handleHelpCommand(args) {
@@ -1208,6 +1415,10 @@ async function handleHelpCommand(args) {
1208
1415
  printScreenshotHelp();
1209
1416
  return;
1210
1417
  }
1418
+ if (targetCommand === "compare") {
1419
+ printCompareHelp();
1420
+ return;
1421
+ }
1211
1422
  if (isAutomatorCommand(targetCommand)) {
1212
1423
  const help = getAutomatorCommandHelp(targetCommand);
1213
1424
  if (help) {
@@ -1286,4 +1497,4 @@ async function parse(argv) {
1286
1497
  await runWechatCliWithRetry(cliPath, formattedArgv);
1287
1498
  }
1288
1499
  //#endregion
1289
- export { parseAutomatorArgs as A, isWeappIdeTopLevelCommand as C, runAutomatorCommand as D, isAutomatorCommand as E, removeOption as M, parseScreenshotArgs as O, WECHAT_CLI_COMMAND_NAMES as S, getAutomatorCommandHelp as T, handleConfigCommand as _, createWechatIdeLoginRequiredExitError as a, MINIDEV_NAMESPACE_COMMAND_NAMES as b, formatWechatIdeLoginRequiredError as c, runMinidev as d, execute as f, startForwardConsole as g, transformArgv as h, runWechatCliWithRetry as i, readOptionValue as j, printScreenshotHelp as k, isWechatIdeLoginRequiredError as l, createPathCompat as m, parse as n, extractExecutionErrorText as o, createAlias as p, validateWechatCliCommandArgs as r, formatRetryHotkeyPrompt as s, createCli as t, waitForRetryKeypress as u, promptForCliPath as v, AUTOMATOR_COMMAND_NAMES as w, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES as x, CONFIG_COMMAND_NAME as y };
1500
+ export { parseCompareArgs as A, isWeappIdeTopLevelCommand as C, runAutomatorCommand as D, isAutomatorCommand as E, parseAutomatorArgs as M, readOptionValue as N, parseScreenshotArgs as O, removeOption as P, WECHAT_CLI_COMMAND_NAMES as S, getAutomatorCommandHelp as T, handleConfigCommand as _, createWechatIdeLoginRequiredExitError as a, MINIDEV_NAMESPACE_COMMAND_NAMES as b, formatWechatIdeLoginRequiredError as c, runMinidev as d, execute as f, startForwardConsole as g, transformArgv as h, runWechatCliWithRetry as i, printCompareHelp as j, printScreenshotHelp as k, isWechatIdeLoginRequiredError as l, createPathCompat as m, parse as n, extractExecutionErrorText as o, createAlias as p, validateWechatCliCommandArgs as r, formatRetryHotkeyPrompt as s, createCli as t, waitForRetryKeypress as u, promptForCliPath as v, AUTOMATOR_COMMAND_NAMES as w, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES as x, CONFIG_COMMAND_NAME as y };
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
- import { H as logger_default } from "./commands-CSbpftLN.js";
2
- import { n as parse } from "./cli-BkQJ3Aww.js";
1
+ import { U as logger_default } from "./commands-BfdE1eYN.js";
2
+ import { n as parse } from "./cli-DXJCUYYI.js";
3
3
  import process from "node:process";
4
4
  //#region src/cli.ts
5
5
  parse(process.argv.slice(2)).catch((err) => {
@@ -1,5 +1,5 @@
1
1
  import { Launcher } from "@weapp-vite/miniprogram-automator";
2
- import fs from "fs-extra";
2
+ import { fs } from "@weapp-core/shared";
3
3
  import logger, { colors } from "@weapp-core/logger";
4
4
  import os from "node:os";
5
5
  import process from "node:process";
@@ -41,6 +41,18 @@ function isOperatingSystemSupported(osName = os.type()) {
41
41
  * @description 当前系统名称
42
42
  */
43
43
  const operatingSystemName = os.type();
44
+ async function getFirstBinaryPath(command) {
45
+ const pathDirs = (process.env.PATH || "").split(path.delimiter);
46
+ for (const dir of pathDirs) {
47
+ const fullPath = path.join(dir, command);
48
+ try {
49
+ await fs.access(fullPath, fs.constants.X_OK);
50
+ return fullPath;
51
+ } catch {
52
+ continue;
53
+ }
54
+ }
55
+ }
44
56
  function createLinuxCliResolver() {
45
57
  let resolvedPath;
46
58
  let attempted = false;
@@ -78,18 +90,6 @@ async function getDefaultCliPath(targetOs = operatingSystemName) {
78
90
  const resolver = cliPathResolvers[targetOs];
79
91
  return await resolver();
80
92
  }
81
- async function getFirstBinaryPath(command) {
82
- const pathDirs = (process.env.PATH || "").split(path.delimiter);
83
- for (const dir of pathDirs) {
84
- const fullPath = path.join(dir, command);
85
- try {
86
- await fs.access(fullPath, fs.constants.X_OK);
87
- return fullPath;
88
- } catch {
89
- continue;
90
- }
91
- }
92
- }
93
93
  //#endregion
94
94
  //#region src/utils/path.ts
95
95
  /**
@@ -116,6 +116,28 @@ const JSON_OPTIONS = {
116
116
  encoding: "utf8",
117
117
  spaces: 2
118
118
  };
119
+ async function readCustomConfig() {
120
+ if (!await fs.pathExists(defaultCustomConfigFilePath)) return {};
121
+ try {
122
+ const config = await fs.readJSON(defaultCustomConfigFilePath);
123
+ if (!config || typeof config !== "object") return {};
124
+ const candidate = config;
125
+ const next = {};
126
+ if (typeof candidate.cliPath === "string" && candidate.cliPath.trim()) next.cliPath = candidate.cliPath.trim();
127
+ if (candidate.locale === "zh" || candidate.locale === "en") next.locale = candidate.locale;
128
+ return next;
129
+ } catch {
130
+ return {};
131
+ }
132
+ }
133
+ async function writeCustomConfig(patch, options = {}) {
134
+ const nextConfig = {
135
+ ...options.replace ? {} : await readCustomConfig(),
136
+ ...patch
137
+ };
138
+ await fs.ensureDir(defaultCustomConfigDirPath);
139
+ await fs.writeJSON(defaultCustomConfigFilePath, nextConfig, JSON_OPTIONS);
140
+ }
119
141
  /**
120
142
  * @description 写入自定义 CLI 路径配置
121
143
  */
@@ -152,31 +174,6 @@ async function overwriteCustomConfig(config) {
152
174
  if (config.locale === "zh" || config.locale === "en") nextConfig.locale = config.locale;
153
175
  await writeCustomConfig(nextConfig, { replace: true });
154
176
  }
155
- /**
156
- * @description 读取原始自定义配置。
157
- */
158
- async function readCustomConfig() {
159
- if (!await fs.pathExists(defaultCustomConfigFilePath)) return {};
160
- try {
161
- const config = await fs.readJSON(defaultCustomConfigFilePath);
162
- if (!config || typeof config !== "object") return {};
163
- const candidate = config;
164
- const next = {};
165
- if (typeof candidate.cliPath === "string" && candidate.cliPath.trim()) next.cliPath = candidate.cliPath.trim();
166
- if (candidate.locale === "zh" || candidate.locale === "en") next.locale = candidate.locale;
167
- return next;
168
- } catch {
169
- return {};
170
- }
171
- }
172
- async function writeCustomConfig(patch, options = {}) {
173
- const nextConfig = {
174
- ...options.replace ? {} : await readCustomConfig(),
175
- ...patch
176
- };
177
- await fs.ensureDir(defaultCustomConfigDirPath);
178
- await fs.writeJSON(defaultCustomConfigFilePath, nextConfig, JSON_OPTIONS);
179
- }
180
177
  //#endregion
181
178
  //#region src/config/resolver.ts
182
179
  /**
@@ -431,6 +428,7 @@ async function withMiniProgram(options, runner) {
431
428
  //#region src/cli/commands.ts
432
429
  var commands_exports = /* @__PURE__ */ __exportAll({
433
430
  audit: () => audit,
431
+ captureScreenshotBuffer: () => captureScreenshotBuffer,
434
432
  currentPage: () => currentPage,
435
433
  input: () => input,
436
434
  navigateBack: () => navigateBack,
@@ -592,9 +590,9 @@ async function audit(options) {
592
590
  });
593
591
  }
594
592
  /**
595
- * @description 获取当前小程序截图。
593
+ * @description 捕获当前页面截图并返回二进制内容。
596
594
  */
597
- async function takeScreenshot(options) {
595
+ async function captureScreenshotBuffer(options) {
598
596
  return await withMiniProgram(options, async (miniProgram) => {
599
597
  logger_default.info(i18nText(`正在连接 DevTools:${colors.cyan(options.projectPath)}...`, `Connecting to DevTools at ${colors.cyan(options.projectPath)}...`));
600
598
  if (options.page) {
@@ -603,17 +601,25 @@ async function takeScreenshot(options) {
603
601
  }
604
602
  logger_default.info(i18nText("正在截图...", "Taking screenshot..."));
605
603
  const screenshot = await miniProgram.screenshot();
606
- const base64 = typeof screenshot === "string" ? screenshot : Buffer$1.from(screenshot).toString("base64");
607
- if (!base64) throw new Error(i18nText("截图失败", "Failed to capture screenshot"));
608
- if (options.outputPath) {
609
- await fs$1.writeFile(options.outputPath, Buffer$1.from(base64, "base64"));
610
- logger_default.success(i18nText(`截图已保存到 ${colors.cyan(options.outputPath)}`, `Screenshot saved to ${colors.cyan(options.outputPath)}`));
611
- return { path: options.outputPath };
612
- }
613
- return { base64 };
604
+ const buffer = typeof screenshot === "string" ? Buffer$1.from(screenshot, "base64") : Buffer$1.from(screenshot);
605
+ if (buffer.length === 0) throw new Error(i18nText("截图失败", "Failed to capture screenshot"));
606
+ return buffer;
614
607
  });
615
608
  }
616
609
  /**
610
+ * @description 获取当前小程序截图。
611
+ */
612
+ async function takeScreenshot(options) {
613
+ const screenshotBuffer = await captureScreenshotBuffer(options);
614
+ const base64 = screenshotBuffer.toString("base64");
615
+ if (options.outputPath) {
616
+ await fs$1.writeFile(options.outputPath, screenshotBuffer);
617
+ logger_default.success(i18nText(`截图已保存到 ${colors.cyan(options.outputPath)}`, `Screenshot saved to ${colors.cyan(options.outputPath)}`));
618
+ return { path: options.outputPath };
619
+ }
620
+ return { base64 };
621
+ }
622
+ /**
617
623
  * @description 开关远程调试。
618
624
  */
619
625
  async function remote(options) {
@@ -625,4 +631,4 @@ async function remote(options) {
625
631
  });
626
632
  }
627
633
  //#endregion
628
- export { createLocaleConfig as A, operatingSystemName as B, isAutomatorLoginError as C, getConfig as D, resolveCliPath as E, defaultCustomConfigFilePath as F, logger_default as H, resolvePath as I, SupportedPlatformsMap as L, readCustomConfig as M, removeCustomConfigKey as N, getConfiguredLocale as O, defaultCustomConfigDirPath as P, getDefaultCliPath as R, formatAutomatorLoginError as S, launchAutomator as T, colors as V, connectMiniProgram as _, navigateBack as a, i18nText as b, pageStack as c, remote as d, scrollTo as f, tap as g, takeScreenshot as h, input as i, overwriteCustomConfig as j, createCustomConfig as k, reLaunch as l, systemInfo as m, commands_exports as n, navigateTo as o, switchTab as p, currentPage as r, pageData as s, audit as t, redirectTo as u, withMiniProgram as v, isDevtoolsHttpPortError as w, validateLocaleOption as x, configureLocaleFromArgv as y, isOperatingSystemSupported as z };
634
+ export { createCustomConfig as A, isOperatingSystemSupported as B, formatAutomatorLoginError as C, resolveCliPath as D, launchAutomator as E, defaultCustomConfigDirPath as F, colors as H, defaultCustomConfigFilePath as I, resolvePath as L, overwriteCustomConfig as M, readCustomConfig as N, getConfig as O, removeCustomConfigKey as P, SupportedPlatformsMap as R, validateLocaleOption as S, isDevtoolsHttpPortError as T, logger_default as U, operatingSystemName as V, tap as _, input as a, configureLocaleFromArgv as b, pageData as c, redirectTo as d, remote as f, takeScreenshot as g, systemInfo as h, currentPage as i, createLocaleConfig as j, getConfiguredLocale as k, pageStack as l, switchTab as m, captureScreenshotBuffer as n, navigateBack as o, scrollTo as p, commands_exports as r, navigateTo as s, audit as t, reLaunch as u, connectMiniProgram as v, isAutomatorLoginError as w, i18nText as x, withMiniProgram as y, getDefaultCliPath as z };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Element, MiniProgram, Page } from "@weapp-vite/miniprogram-automator";
2
+ import { Buffer } from "node:buffer";
2
3
  import * as cac$1 from "cac";
3
4
  import * as execa from "execa";
4
5
 
@@ -169,6 +170,10 @@ declare function scrollTo(options: ScrollOptions): Promise<void>;
169
170
  * @description 执行体验评分审计。
170
171
  */
171
172
  declare function audit(options: AuditOptions): Promise<any>;
173
+ /**
174
+ * @description 捕获当前页面截图并返回二进制内容。
175
+ */
176
+ declare function captureScreenshotBuffer(options: ScreenshotOptions): Promise<Buffer>;
172
177
  /**
173
178
  * @description 获取当前小程序截图。
174
179
  */
@@ -178,6 +183,24 @@ declare function takeScreenshot(options: ScreenshotOptions): Promise<ScreenshotR
178
183
  */
179
184
  declare function remote(options: RemoteOptions): Promise<void>;
180
185
  //#endregion
186
+ //#region src/cli/compare.d.ts
187
+ interface CompareOptions extends ScreenshotOptions {
188
+ baselinePath: string;
189
+ currentOutputPath?: string;
190
+ diffOutputPath?: string;
191
+ threshold: number;
192
+ maxDiffPixels?: number;
193
+ maxDiffRatio?: number;
194
+ }
195
+ /**
196
+ * @description 输出 compare 命令帮助信息。
197
+ */
198
+ declare function printCompareHelp(): void;
199
+ /**
200
+ * @description 解析 compare 命令参数。
201
+ */
202
+ declare function parseCompareArgs(argv: string[]): CompareOptions;
203
+ //#endregion
181
204
  //#region src/cli/config-command.d.ts
182
205
  /**
183
206
  * @description 处理 config 子命令。
@@ -338,6 +361,7 @@ interface CustomConfigFile {
338
361
  cliPath?: string;
339
362
  locale?: 'zh' | 'en';
340
363
  }
364
+ declare function readCustomConfig(): Promise<CustomConfigFile>;
341
365
  /**
342
366
  * @description 写入自定义 CLI 路径配置
343
367
  */
@@ -354,10 +378,6 @@ declare function removeCustomConfigKey(key: keyof CustomConfigFile): Promise<voi
354
378
  * @description 覆盖写入配置内容(会替换原内容)。
355
379
  */
356
380
  declare function overwriteCustomConfig(config: CustomConfigFile): Promise<void>;
357
- /**
358
- * @description 读取原始自定义配置。
359
- */
360
- declare function readCustomConfig(): Promise<CustomConfigFile>;
361
381
  //#endregion
362
382
  //#region src/config/paths.d.ts
363
383
  /**
@@ -440,4 +460,4 @@ declare function execute(cliPath: string, argv: string[], options?: ExecuteOptio
440
460
  */
441
461
  declare function resolvePath(filePath: string): string;
442
462
  //#endregion
443
- export { AUTOMATOR_COMMAND_NAMES, ArgvTransform, AuditOptions, AutomatorCommandOptions, AutomatorOptions, AutomatorSessionOptions, type BaseConfig, CONFIG_COMMAND_NAME, type ConfigSource, ForwardConsoleEvent, ForwardConsoleLogLevel, ForwardConsoleOptions, ForwardConsoleSession, InputOptions, LoginRetryMode, MINIDEV_NAMESPACE_COMMAND_NAMES, MiniProgramElement, MiniProgramEventMap, MiniProgramLike, MiniProgramPage, NavigateOptions, PageDataOptions, PageInfoOptions, ParsedAutomatorArgs, RemoteOptions, type ResolvedConfig, RetryKeypressOptions, RetryPromptResult, type ScreenshotOptions, type ScreenshotResult, ScrollOptions, SelectorOptions, SupportedPlatform, SupportedPlatformsMap, TapOptions, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, WECHAT_CLI_COMMAND_NAMES, audit, connectMiniProgram, createAlias, createCli, createCustomConfig, createLocaleConfig, createPathCompat, createWechatIdeLoginRequiredExitError, currentPage, defaultCustomConfigDirPath, defaultCustomConfigFilePath, execute, extractExecutionErrorText, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getAutomatorCommandHelp, getConfig, getConfiguredLocale, getDefaultCliPath, handleConfigCommand, input, isAutomatorCommand, isAutomatorLoginError, isDevtoolsHttpPortError, isOperatingSystemSupported, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, navigateBack, navigateTo, operatingSystemName, overwriteCustomConfig, pageData, pageStack, parse, parseAutomatorArgs, parseScreenshotArgs, printScreenshotHelp, promptForCliPath, reLaunch, readCustomConfig, readOptionValue, redirectTo, remote, removeCustomConfigKey, removeOption, resolveCliPath, resolvePath, runAutomatorCommand, runMinidev, runWechatCliWithRetry, scrollTo, startForwardConsole, switchTab, systemInfo, takeScreenshot, tap, transformArgv, validateWechatCliCommandArgs, waitForRetryKeypress, withMiniProgram };
463
+ export { AUTOMATOR_COMMAND_NAMES, ArgvTransform, AuditOptions, AutomatorCommandOptions, AutomatorOptions, AutomatorSessionOptions, type BaseConfig, CONFIG_COMMAND_NAME, type ConfigSource, ForwardConsoleEvent, ForwardConsoleLogLevel, ForwardConsoleOptions, ForwardConsoleSession, InputOptions, LoginRetryMode, MINIDEV_NAMESPACE_COMMAND_NAMES, MiniProgramElement, MiniProgramEventMap, MiniProgramLike, MiniProgramPage, NavigateOptions, PageDataOptions, PageInfoOptions, ParsedAutomatorArgs, RemoteOptions, type ResolvedConfig, RetryKeypressOptions, RetryPromptResult, type ScreenshotOptions, type ScreenshotResult, ScrollOptions, SelectorOptions, SupportedPlatform, SupportedPlatformsMap, TapOptions, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, WECHAT_CLI_COMMAND_NAMES, audit, captureScreenshotBuffer, connectMiniProgram, createAlias, createCli, createCustomConfig, createLocaleConfig, createPathCompat, createWechatIdeLoginRequiredExitError, currentPage, defaultCustomConfigDirPath, defaultCustomConfigFilePath, execute, extractExecutionErrorText, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getAutomatorCommandHelp, getConfig, getConfiguredLocale, getDefaultCliPath, handleConfigCommand, input, isAutomatorCommand, isAutomatorLoginError, isDevtoolsHttpPortError, isOperatingSystemSupported, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, navigateBack, navigateTo, operatingSystemName, overwriteCustomConfig, pageData, pageStack, parse, parseAutomatorArgs, parseCompareArgs, parseScreenshotArgs, printCompareHelp, printScreenshotHelp, promptForCliPath, reLaunch, readCustomConfig, readOptionValue, redirectTo, remote, removeCustomConfigKey, removeOption, resolveCliPath, resolvePath, runAutomatorCommand, runMinidev, runWechatCliWithRetry, scrollTo, startForwardConsole, switchTab, systemInfo, takeScreenshot, tap, transformArgv, validateWechatCliCommandArgs, waitForRetryKeypress, withMiniProgram };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { A as createLocaleConfig, B as operatingSystemName, C as isAutomatorLoginError, D as getConfig, E as resolveCliPath, F as defaultCustomConfigFilePath, I as resolvePath, L as SupportedPlatformsMap, M as readCustomConfig, N as removeCustomConfigKey, O as getConfiguredLocale, P as defaultCustomConfigDirPath, R as getDefaultCliPath, S as formatAutomatorLoginError, T as launchAutomator, _ as connectMiniProgram, a as navigateBack, c as pageStack, d as remote, f as scrollTo, g as tap, h as takeScreenshot, i as input, j as overwriteCustomConfig, k as createCustomConfig, l as reLaunch, m as systemInfo, o as navigateTo, p as switchTab, r as currentPage, s as pageData, t as audit, u as redirectTo, v as withMiniProgram, w as isDevtoolsHttpPortError, z as isOperatingSystemSupported } from "./commands-CSbpftLN.js";
2
- import { A as parseAutomatorArgs, C as isWeappIdeTopLevelCommand, D as runAutomatorCommand, E as isAutomatorCommand, M as removeOption, O as parseScreenshotArgs, S as WECHAT_CLI_COMMAND_NAMES, T as getAutomatorCommandHelp, _ as handleConfigCommand, a as createWechatIdeLoginRequiredExitError, b as MINIDEV_NAMESPACE_COMMAND_NAMES, c as formatWechatIdeLoginRequiredError, d as runMinidev, f as execute, g as startForwardConsole, h as transformArgv, i as runWechatCliWithRetry, j as readOptionValue, k as printScreenshotHelp, l as isWechatIdeLoginRequiredError, m as createPathCompat, n as parse, o as extractExecutionErrorText, p as createAlias, r as validateWechatCliCommandArgs, s as formatRetryHotkeyPrompt, t as createCli, u as waitForRetryKeypress, v as promptForCliPath, w as AUTOMATOR_COMMAND_NAMES, x as WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, y as CONFIG_COMMAND_NAME } from "./cli-BkQJ3Aww.js";
3
- export { AUTOMATOR_COMMAND_NAMES, CONFIG_COMMAND_NAME, MINIDEV_NAMESPACE_COMMAND_NAMES, SupportedPlatformsMap, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, WECHAT_CLI_COMMAND_NAMES, audit, connectMiniProgram, createAlias, createCli, createCustomConfig, createLocaleConfig, createPathCompat, createWechatIdeLoginRequiredExitError, currentPage, defaultCustomConfigDirPath, defaultCustomConfigFilePath, execute, extractExecutionErrorText, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getAutomatorCommandHelp, getConfig, getConfiguredLocale, getDefaultCliPath, handleConfigCommand, input, isAutomatorCommand, isAutomatorLoginError, isDevtoolsHttpPortError, isOperatingSystemSupported, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, navigateBack, navigateTo, operatingSystemName, overwriteCustomConfig, pageData, pageStack, parse, parseAutomatorArgs, parseScreenshotArgs, printScreenshotHelp, promptForCliPath, reLaunch, readCustomConfig, readOptionValue, redirectTo, remote, removeCustomConfigKey, removeOption, resolveCliPath, resolvePath, runAutomatorCommand, runMinidev, runWechatCliWithRetry, scrollTo, startForwardConsole, switchTab, systemInfo, takeScreenshot, tap, transformArgv, validateWechatCliCommandArgs, waitForRetryKeypress, withMiniProgram };
1
+ import { A as createCustomConfig, B as isOperatingSystemSupported, C as formatAutomatorLoginError, D as resolveCliPath, E as launchAutomator, F as defaultCustomConfigDirPath, I as defaultCustomConfigFilePath, L as resolvePath, M as overwriteCustomConfig, N as readCustomConfig, O as getConfig, P as removeCustomConfigKey, R as SupportedPlatformsMap, T as isDevtoolsHttpPortError, V as operatingSystemName, _ as tap, a as input, c as pageData, d as redirectTo, f as remote, g as takeScreenshot, h as systemInfo, i as currentPage, j as createLocaleConfig, k as getConfiguredLocale, l as pageStack, m as switchTab, n as captureScreenshotBuffer, o as navigateBack, p as scrollTo, s as navigateTo, t as audit, u as reLaunch, v as connectMiniProgram, w as isAutomatorLoginError, y as withMiniProgram, z as getDefaultCliPath } from "./commands-BfdE1eYN.js";
2
+ import { A as parseCompareArgs, C as isWeappIdeTopLevelCommand, D as runAutomatorCommand, E as isAutomatorCommand, M as parseAutomatorArgs, N as readOptionValue, O as parseScreenshotArgs, P as removeOption, S as WECHAT_CLI_COMMAND_NAMES, T as getAutomatorCommandHelp, _ as handleConfigCommand, a as createWechatIdeLoginRequiredExitError, b as MINIDEV_NAMESPACE_COMMAND_NAMES, c as formatWechatIdeLoginRequiredError, d as runMinidev, f as execute, g as startForwardConsole, h as transformArgv, i as runWechatCliWithRetry, j as printCompareHelp, k as printScreenshotHelp, l as isWechatIdeLoginRequiredError, m as createPathCompat, n as parse, o as extractExecutionErrorText, p as createAlias, r as validateWechatCliCommandArgs, s as formatRetryHotkeyPrompt, t as createCli, u as waitForRetryKeypress, v as promptForCliPath, w as AUTOMATOR_COMMAND_NAMES, x as WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, y as CONFIG_COMMAND_NAME } from "./cli-DXJCUYYI.js";
3
+ export { AUTOMATOR_COMMAND_NAMES, CONFIG_COMMAND_NAME, MINIDEV_NAMESPACE_COMMAND_NAMES, SupportedPlatformsMap, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, WECHAT_CLI_COMMAND_NAMES, audit, captureScreenshotBuffer, connectMiniProgram, createAlias, createCli, createCustomConfig, createLocaleConfig, createPathCompat, createWechatIdeLoginRequiredExitError, currentPage, defaultCustomConfigDirPath, defaultCustomConfigFilePath, execute, extractExecutionErrorText, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getAutomatorCommandHelp, getConfig, getConfiguredLocale, getDefaultCliPath, handleConfigCommand, input, isAutomatorCommand, isAutomatorLoginError, isDevtoolsHttpPortError, isOperatingSystemSupported, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, navigateBack, navigateTo, operatingSystemName, overwriteCustomConfig, pageData, pageStack, parse, parseAutomatorArgs, parseCompareArgs, parseScreenshotArgs, printCompareHelp, printScreenshotHelp, promptForCliPath, reLaunch, readCustomConfig, readOptionValue, redirectTo, remote, removeCustomConfigKey, removeOption, resolveCliPath, resolvePath, runAutomatorCommand, runMinidev, runWechatCliWithRetry, scrollTo, startForwardConsole, switchTab, systemInfo, takeScreenshot, tap, transformArgv, validateWechatCliCommandArgs, waitForRetryKeypress, withMiniProgram };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-ide-cli",
3
3
  "type": "module",
4
- "version": "5.1.4",
4
+ "version": "5.2.0",
5
5
  "description": "让微信开发者工具,用起来更加方便!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -64,9 +64,11 @@
64
64
  "dependencies": {
65
65
  "cac": "^7.0.0",
66
66
  "execa": "9.6.1",
67
- "fs-extra": "^11.3.4",
68
67
  "pathe": "^2.0.3",
68
+ "pixelmatch": "^7.1.0",
69
+ "pngjs": "^7.0.0",
69
70
  "@weapp-core/logger": "^3.1.1",
71
+ "@weapp-core/shared": "^3.0.3",
70
72
  "@weapp-vite/miniprogram-automator": "1.0.1"
71
73
  },
72
74
  "scripts": {