weapp-ide-cli 5.0.0 → 5.0.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/README.md +6 -0
- package/dist/{chunk-RQRH244E.js → chunk-DNENPZKW.js} +63 -2
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +66 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,6 +55,12 @@ weapp alipay preview --project ./dist/mp-alipay
|
|
|
55
55
|
|
|
56
56
|
首次使用前请确认已全局安装 `minidev`(例如执行 `pnpm add -g minidev`)。若命令不存在,CLI 会给出安装提示。
|
|
57
57
|
|
|
58
|
+
也支持通过 `open` 命令直接指定平台为支付宝,此时会自动转发到 `minidev ide`:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
weapp open --platform alipay -p ./dist/dev/mp-alipay
|
|
62
|
+
```
|
|
63
|
+
|
|
58
64
|
## 常用命令速查
|
|
59
65
|
|
|
60
66
|
| 命令 | 说明 |
|
|
@@ -276,6 +276,8 @@ async function resolveCliPath() {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
// src/cli/run.ts
|
|
279
|
+
var MINIDEV_NAMESPACE = /* @__PURE__ */ new Set(["alipay", "ali", "minidev"]);
|
|
280
|
+
var ALIPAY_PLATFORM_ALIASES = /* @__PURE__ */ new Set(["alipay", "ali", "minidev"]);
|
|
279
281
|
var ARG_TRANSFORMS = [
|
|
280
282
|
createAlias({ find: "-p", replacement: "--project" }),
|
|
281
283
|
createPathCompat("--result-output"),
|
|
@@ -287,10 +289,15 @@ var ARG_TRANSFORMS = [
|
|
|
287
289
|
];
|
|
288
290
|
async function parse(argv) {
|
|
289
291
|
const head = argv[0];
|
|
290
|
-
if (head &&
|
|
292
|
+
if (head && MINIDEV_NAMESPACE.has(head)) {
|
|
291
293
|
await runMinidev(argv.slice(1));
|
|
292
294
|
return;
|
|
293
295
|
}
|
|
296
|
+
const formattedArgv = transformArgv(argv, ARG_TRANSFORMS);
|
|
297
|
+
if (shouldDelegateOpenToMinidev(formattedArgv)) {
|
|
298
|
+
await runMinidev(createMinidevOpenArgv(formattedArgv));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
294
301
|
if (!isOperatingSystemSupported(operatingSystemName)) {
|
|
295
302
|
logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
|
|
296
303
|
return;
|
|
@@ -306,9 +313,63 @@ async function parse(argv) {
|
|
|
306
313
|
await promptForCliPath();
|
|
307
314
|
return;
|
|
308
315
|
}
|
|
309
|
-
const formattedArgv = transformArgv(argv, ARG_TRANSFORMS);
|
|
310
316
|
await execute(cliPath, formattedArgv);
|
|
311
317
|
}
|
|
318
|
+
function shouldDelegateOpenToMinidev(argv) {
|
|
319
|
+
if (argv[0] !== "open") {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
const platform = readOptionValue(argv, "--platform");
|
|
323
|
+
if (!platform) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
return ALIPAY_PLATFORM_ALIASES.has(platform);
|
|
327
|
+
}
|
|
328
|
+
function createMinidevOpenArgv(argv) {
|
|
329
|
+
const nextArgv = [...argv];
|
|
330
|
+
nextArgv[0] = "ide";
|
|
331
|
+
return removeOption(nextArgv, "--platform");
|
|
332
|
+
}
|
|
333
|
+
function readOptionValue(argv, optionName) {
|
|
334
|
+
const optionWithEqual = `${optionName}=`;
|
|
335
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
336
|
+
const token = argv[index];
|
|
337
|
+
if (!token) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
if (token === optionName) {
|
|
341
|
+
const value = argv[index + 1];
|
|
342
|
+
return typeof value === "string" ? value.trim().toLowerCase() : void 0;
|
|
343
|
+
}
|
|
344
|
+
if (token.startsWith(optionWithEqual)) {
|
|
345
|
+
const value = token.slice(optionWithEqual.length);
|
|
346
|
+
return value.trim().toLowerCase();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
function removeOption(argv, optionName) {
|
|
352
|
+
const optionWithEqual = `${optionName}=`;
|
|
353
|
+
const nextArgv = [];
|
|
354
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
355
|
+
const token = argv[index];
|
|
356
|
+
if (!token) {
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (token === optionName) {
|
|
360
|
+
const nextToken = argv[index + 1];
|
|
361
|
+
if (nextToken && !nextToken.startsWith("-")) {
|
|
362
|
+
index += 1;
|
|
363
|
+
}
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (token.startsWith(optionWithEqual)) {
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
nextArgv.push(token);
|
|
370
|
+
}
|
|
371
|
+
return nextArgv;
|
|
372
|
+
}
|
|
312
373
|
|
|
313
374
|
export {
|
|
314
375
|
logger_default,
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,56 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 运行支付宝小程序 CLI(minidev)
|
|
3
|
+
*/
|
|
1
4
|
declare function runMinidev(argv: readonly string[]): Promise<void>;
|
|
2
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @description 交互式提示并保存 CLI 路径
|
|
8
|
+
*/
|
|
3
9
|
declare function promptForCliPath(): Promise<string | null>;
|
|
4
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @description 解析 CLI 路径并校验可用性
|
|
13
|
+
*/
|
|
5
14
|
declare function resolveCliPath(): Promise<{
|
|
6
15
|
cliPath: string | null;
|
|
7
16
|
source: ConfigSource;
|
|
8
17
|
}>;
|
|
9
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @description CLI 入口解析与分发
|
|
21
|
+
*/
|
|
10
22
|
declare function parse(argv: string[]): Promise<void>;
|
|
11
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @description 基础配置
|
|
26
|
+
*/
|
|
12
27
|
interface BaseConfig {
|
|
13
28
|
cliPath: string;
|
|
14
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @description 配置来源
|
|
32
|
+
*/
|
|
15
33
|
type ConfigSource = 'custom' | 'default' | 'missing';
|
|
34
|
+
/**
|
|
35
|
+
* @description 解析后的配置
|
|
36
|
+
*/
|
|
16
37
|
interface ResolvedConfig extends BaseConfig {
|
|
17
38
|
source: ConfigSource;
|
|
18
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @description CLI 参数别名配置
|
|
42
|
+
*/
|
|
19
43
|
interface AliasEntry {
|
|
20
44
|
find: string;
|
|
21
45
|
replacement: string;
|
|
22
46
|
}
|
|
23
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @description 写入自定义 CLI 路径配置
|
|
50
|
+
*/
|
|
24
51
|
declare function createCustomConfig(params: BaseConfig): Promise<string>;
|
|
25
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @description 默认自定义配置目录
|
|
55
|
+
*/
|
|
26
56
|
declare const defaultCustomConfigDirPath: string;
|
|
57
|
+
/**
|
|
58
|
+
* @description 默认自定义配置文件路径
|
|
59
|
+
*/
|
|
27
60
|
declare const defaultCustomConfigFilePath: string;
|
|
28
61
|
|
|
62
|
+
/**
|
|
63
|
+
* @description 读取并解析 CLI 配置(自定义优先)
|
|
64
|
+
*/
|
|
29
65
|
declare function getConfig(): Promise<ResolvedConfig>;
|
|
30
66
|
|
|
31
67
|
/**
|
|
32
|
-
* 官方微信开发者工具只支持 Windows、macOS
|
|
68
|
+
* @description 官方微信开发者工具只支持 Windows、macOS,Linux 只有社区版
|
|
69
|
+
* https://github.com/msojocs/wechat-web-devtools-linux
|
|
33
70
|
*/
|
|
34
71
|
declare const SupportedPlatformsMap: {
|
|
35
72
|
readonly Windows_NT: "Windows_NT";
|
|
36
73
|
readonly Darwin: "Darwin";
|
|
37
74
|
readonly Linux: "Linux";
|
|
38
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* @description 支持的系统类型
|
|
78
|
+
*/
|
|
39
79
|
type SupportedPlatform = (typeof SupportedPlatformsMap)[keyof typeof SupportedPlatformsMap];
|
|
80
|
+
/**
|
|
81
|
+
* @description 判断当前系统是否支持微信开发者工具
|
|
82
|
+
*/
|
|
40
83
|
declare function isOperatingSystemSupported(osName?: string): osName is SupportedPlatform;
|
|
84
|
+
/**
|
|
85
|
+
* @description 当前系统名称
|
|
86
|
+
*/
|
|
41
87
|
declare const operatingSystemName: string;
|
|
88
|
+
/**
|
|
89
|
+
* @description 获取默认 CLI 路径(按系统)
|
|
90
|
+
*/
|
|
42
91
|
declare function getDefaultCliPath(targetOs?: string): Promise<string | undefined>;
|
|
43
92
|
|
|
93
|
+
/**
|
|
94
|
+
* @description argv 处理函数
|
|
95
|
+
*/
|
|
44
96
|
type ArgvTransform = (argv: readonly string[]) => string[];
|
|
45
97
|
/**
|
|
46
|
-
*
|
|
98
|
+
* @description 依次应用 argv 处理函数(不修改原始 argv)
|
|
47
99
|
*/
|
|
48
100
|
declare function transformArgv(argv: readonly string[], transforms: readonly ArgvTransform[]): string[];
|
|
101
|
+
/**
|
|
102
|
+
* @description 创建参数别名转换器
|
|
103
|
+
*/
|
|
49
104
|
declare function createAlias(entry: AliasEntry): ArgvTransform;
|
|
105
|
+
/**
|
|
106
|
+
* @description 创建路径参数兼容转换器(补全或规范化路径)
|
|
107
|
+
*/
|
|
50
108
|
declare function createPathCompat(option: string): ArgvTransform;
|
|
51
109
|
|
|
110
|
+
/**
|
|
111
|
+
* @description 执行 CLI 命令并透传输出
|
|
112
|
+
*/
|
|
52
113
|
declare function execute(cliPath: string, argv: string[]): Promise<void>;
|
|
53
114
|
|
|
115
|
+
/**
|
|
116
|
+
* @description 解析为绝对路径(基于当前工作目录)
|
|
117
|
+
*/
|
|
54
118
|
declare function resolvePath(filePath: string): string;
|
|
55
119
|
|
|
56
120
|
export { type ArgvTransform, type BaseConfig, type ConfigSource, type ResolvedConfig, type SupportedPlatform, SupportedPlatformsMap, createAlias, createCustomConfig, createPathCompat, defaultCustomConfigDirPath, defaultCustomConfigFilePath, execute, getConfig, getDefaultCliPath, isOperatingSystemSupported, operatingSystemName, parse, promptForCliPath, resolveCliPath, resolvePath, runMinidev, transformArgv };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-ide-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.2",
|
|
5
5
|
"description": "让微信开发者工具,用起来更加方便!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"execa": "9.6.1",
|
|
66
66
|
"fs-extra": "^11.3.3",
|
|
67
67
|
"pathe": "^2.0.3",
|
|
68
|
-
"@weapp-core/logger": "^3.0.
|
|
68
|
+
"@weapp-core/logger": "^3.0.3"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"dev": "tsup --watch --sourcemap",
|