weapp-ide-cli 5.1.2 → 5.1.4
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-g8B8r0xg.js → cli-BkQJ3Aww.js} +175 -353
- package/dist/cli.js +2 -2
- package/dist/{commands-BwCMEmX-.js → commands-CSbpftLN.js} +350 -97
- package/dist/index.d.ts +71 -43
- package/dist/index.js +3 -3
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
1
|
+
import { Element, MiniProgram, Page } from "@weapp-vite/miniprogram-automator";
|
|
2
|
+
import * as cac$1 from "cac";
|
|
3
3
|
import * as execa from "execa";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/automator.d.ts
|
|
6
6
|
interface AutomatorOptions {
|
|
7
7
|
projectPath: string;
|
|
8
8
|
timeout?: number;
|
|
9
|
+
cliPath?: string;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
|
-
* @description
|
|
12
|
+
* @description 判断错误是否属于开发者工具服务端口不可用。
|
|
12
13
|
*/
|
|
13
14
|
declare function isDevtoolsHttpPortError(error: unknown): boolean;
|
|
14
15
|
/**
|
|
15
|
-
* @description
|
|
16
|
+
* @description 判断错误是否属于开发者工具登录失效。
|
|
16
17
|
*/
|
|
17
18
|
declare function isAutomatorLoginError(error: unknown): boolean;
|
|
18
19
|
/**
|
|
19
|
-
* @description
|
|
20
|
+
* @description 格式化开发者工具登录失效错误,便于终端展示。
|
|
20
21
|
*/
|
|
21
22
|
declare function formatAutomatorLoginError(error: unknown): string;
|
|
22
23
|
/**
|
|
23
|
-
* @description
|
|
24
|
+
* @description 基于当前配置解析 CLI 路径,并通过现代化 automator 入口启动会话。
|
|
24
25
|
*/
|
|
25
|
-
declare function launchAutomator(options: AutomatorOptions): Promise<
|
|
26
|
+
declare function launchAutomator(options: AutomatorOptions): Promise<any>;
|
|
26
27
|
//#endregion
|
|
27
28
|
//#region src/cli/automator-argv.d.ts
|
|
28
29
|
interface ParsedAutomatorArgs {
|
|
@@ -53,39 +54,17 @@ interface MiniProgramEventMap {
|
|
|
53
54
|
console: (payload: unknown) => void;
|
|
54
55
|
exception: (payload: unknown) => void;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
type MiniProgramLike = InstanceType<typeof MiniProgram>;
|
|
58
|
+
type MiniProgramPage = InstanceType<typeof Page>;
|
|
59
|
+
type MiniProgramElement = InstanceType<typeof Element> & {
|
|
58
60
|
input?: (value: string) => Promise<void>;
|
|
59
|
-
}
|
|
60
|
-
interface MiniProgramPage {
|
|
61
|
-
path?: string;
|
|
62
|
-
query?: Record<string, unknown>;
|
|
63
|
-
data: (path?: string) => Promise<unknown>;
|
|
64
|
-
$: (selector: string) => Promise<MiniProgramElement | null>;
|
|
65
|
-
}
|
|
66
|
-
interface MiniProgramLike {
|
|
67
|
-
navigateTo: (url: string) => Promise<unknown>;
|
|
68
|
-
redirectTo: (url: string) => Promise<unknown>;
|
|
69
|
-
navigateBack: () => Promise<unknown>;
|
|
70
|
-
reLaunch: (url: string) => Promise<unknown>;
|
|
71
|
-
switchTab: (url: string) => Promise<unknown>;
|
|
72
|
-
pageStack: () => Promise<MiniProgramPage[]>;
|
|
73
|
-
currentPage: () => Promise<MiniProgramPage>;
|
|
74
|
-
systemInfo: () => Promise<unknown>;
|
|
75
|
-
pageScrollTo: (scrollTop: number) => Promise<unknown>;
|
|
76
|
-
stopAudits: () => Promise<unknown>;
|
|
77
|
-
screenshot: () => Promise<string | Buffer>;
|
|
78
|
-
remote: (enable?: boolean) => Promise<unknown>;
|
|
79
|
-
close: () => Promise<void>;
|
|
80
|
-
on: <TEvent extends keyof MiniProgramEventMap>(event: TEvent, listener: MiniProgramEventMap[TEvent]) => MiniProgramLike;
|
|
81
|
-
off?: <TEvent extends keyof MiniProgramEventMap>(event: TEvent, listener: MiniProgramEventMap[TEvent]) => MiniProgramLike;
|
|
82
|
-
}
|
|
61
|
+
};
|
|
83
62
|
/**
|
|
84
63
|
* @description 建立 automator 会话,并统一处理常见连接错误提示。
|
|
85
64
|
*/
|
|
86
65
|
declare function connectMiniProgram(options: AutomatorSessionOptions): Promise<MiniProgramLike>;
|
|
87
66
|
/**
|
|
88
|
-
* @description 统一管理 automator
|
|
67
|
+
* @description 统一管理 automator 会话生命周期。
|
|
89
68
|
*/
|
|
90
69
|
declare function withMiniProgram<T>(options: AutomatorSessionOptions, runner: (miniProgram: MiniProgramLike) => Promise<T>): Promise<T>;
|
|
91
70
|
//#endregion
|
|
@@ -138,20 +117,65 @@ interface PageSnapshot {
|
|
|
138
117
|
path: string;
|
|
139
118
|
query: Record<string, unknown> | undefined;
|
|
140
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* @description 执行保留栈页面跳转。
|
|
122
|
+
*/
|
|
141
123
|
declare function navigateTo(options: NavigateOptions): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* @description 执行关闭当前页的重定向。
|
|
126
|
+
*/
|
|
142
127
|
declare function redirectTo(options: NavigateOptions): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* @description 返回上一页。
|
|
130
|
+
*/
|
|
143
131
|
declare function navigateBack(options: AutomatorCommandOptions): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* @description 重启到指定页面。
|
|
134
|
+
*/
|
|
144
135
|
declare function reLaunch(options: NavigateOptions): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* @description 切换到 tabBar 页面。
|
|
138
|
+
*/
|
|
145
139
|
declare function switchTab(options: NavigateOptions): Promise<void>;
|
|
146
|
-
|
|
140
|
+
/**
|
|
141
|
+
* @description 获取页面栈。
|
|
142
|
+
*/
|
|
143
|
+
declare function pageStack(options: PageInfoOptions): Promise<any>;
|
|
144
|
+
/**
|
|
145
|
+
* @description 获取当前页面信息。
|
|
146
|
+
*/
|
|
147
147
|
declare function currentPage(options: PageInfoOptions): Promise<PageSnapshot>;
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
/**
|
|
149
|
+
* @description 获取系统信息。
|
|
150
|
+
*/
|
|
151
|
+
declare function systemInfo(options: PageInfoOptions): Promise<any>;
|
|
152
|
+
/**
|
|
153
|
+
* @description 获取当前页面数据。
|
|
154
|
+
*/
|
|
155
|
+
declare function pageData(options: PageDataOptions): Promise<any>;
|
|
156
|
+
/**
|
|
157
|
+
* @description 点击页面元素。
|
|
158
|
+
*/
|
|
150
159
|
declare function tap(options: TapOptions): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* @description 向页面元素输入文本。
|
|
162
|
+
*/
|
|
151
163
|
declare function input(options: InputOptions): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* @description 滚动页面到指定位置。
|
|
166
|
+
*/
|
|
152
167
|
declare function scrollTo(options: ScrollOptions): Promise<void>;
|
|
153
|
-
|
|
168
|
+
/**
|
|
169
|
+
* @description 执行体验评分审计。
|
|
170
|
+
*/
|
|
171
|
+
declare function audit(options: AuditOptions): Promise<any>;
|
|
172
|
+
/**
|
|
173
|
+
* @description 获取当前小程序截图。
|
|
174
|
+
*/
|
|
154
175
|
declare function takeScreenshot(options: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
176
|
+
/**
|
|
177
|
+
* @description 开关远程调试。
|
|
178
|
+
*/
|
|
155
179
|
declare function remote(options: RemoteOptions): Promise<void>;
|
|
156
180
|
//#endregion
|
|
157
181
|
//#region src/cli/config-command.d.ts
|
|
@@ -236,6 +260,10 @@ declare function waitForRetryKeypress(options?: RetryKeypressOptions): Promise<R
|
|
|
236
260
|
declare function formatRetryHotkeyPrompt(timeoutMs?: number): string;
|
|
237
261
|
//#endregion
|
|
238
262
|
//#region src/cli/run.d.ts
|
|
263
|
+
/**
|
|
264
|
+
* @description 基于 cac 注册顶层命令,用于统一识别入口。
|
|
265
|
+
*/
|
|
266
|
+
declare function createCli(): cac$1.CAC;
|
|
239
267
|
/**
|
|
240
268
|
* @description CLI 入口解析与分发。
|
|
241
269
|
*/
|
|
@@ -248,13 +276,13 @@ declare const AUTOMATOR_COMMAND_NAMES: string[];
|
|
|
248
276
|
*/
|
|
249
277
|
declare function isAutomatorCommand(command: string | undefined): boolean;
|
|
250
278
|
/**
|
|
251
|
-
* @description
|
|
279
|
+
* @description 获取 automator 子命令帮助文本。
|
|
252
280
|
*/
|
|
253
|
-
declare function
|
|
281
|
+
declare function getAutomatorCommandHelp(command: string): string | undefined;
|
|
254
282
|
/**
|
|
255
|
-
* @description
|
|
283
|
+
* @description 执行 automator 子命令。
|
|
256
284
|
*/
|
|
257
|
-
declare function
|
|
285
|
+
declare function runAutomatorCommand(command: string, argv: string[]): Promise<void>;
|
|
258
286
|
//#endregion
|
|
259
287
|
//#region src/cli/run-login.d.ts
|
|
260
288
|
type LoginRetryMode = 'never' | 'once' | 'always';
|
|
@@ -412,4 +440,4 @@ declare function execute(cliPath: string, argv: string[], options?: ExecuteOptio
|
|
|
412
440
|
*/
|
|
413
441
|
declare function resolvePath(filePath: string): string;
|
|
414
442
|
//#endregion
|
|
415
|
-
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, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import { A as
|
|
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, 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 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 };
|
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
|
+
"version": "5.1.4",
|
|
5
5
|
"description": "让微信开发者工具,用起来更加方便!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,11 +62,12 @@
|
|
|
62
62
|
"registry": "https://registry.npmjs.org/"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
+
"cac": "^7.0.0",
|
|
65
66
|
"execa": "9.6.1",
|
|
66
67
|
"fs-extra": "^11.3.4",
|
|
67
|
-
"miniprogram-automator": "^0.12.1",
|
|
68
68
|
"pathe": "^2.0.3",
|
|
69
|
-
"@weapp-core/logger": "^3.1.1"
|
|
69
|
+
"@weapp-core/logger": "^3.1.1",
|
|
70
|
+
"@weapp-vite/miniprogram-automator": "1.0.1"
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"dev": "tsdown -w --sourcemap",
|