weapp-ide-cli 4.0.0 → 4.1.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
@@ -10,6 +10,7 @@
10
10
  - 为 `-p / --project`、`--qr-output` 等选项自动补全绝对路径,默认使用当前工作目录。
11
11
  - 使用与官方指令完全一致的调用方式,便于在脚本中无缝迁移。
12
12
  - 支持 macOS、Windows 以及安装了社区版工具的 Linux 桌面环境。
13
+ - 内置支付宝小程序 CLI 入口,直接转发至官方 `minidev` 工具。
13
14
 
14
15
  ## 安装
15
16
 
@@ -40,6 +41,20 @@ weapp upload --project ./dist/build/mp-weixin
40
41
 
41
42
  `weapp` 与 `weapp-ide-cli` 等价,选择任一前缀即可。
42
43
 
44
+ ## 支付宝小程序(minidev)支持
45
+
46
+ 封装内置了支付宝官方 CLI —— `minidev` 的调用入口,可通过 `weapp alipay` 或 `weapp ali` 直接转发指令:
47
+
48
+ ```sh
49
+ # 调用 minidev 登录
50
+ weapp alipay login
51
+
52
+ # 预览支付宝小程序
53
+ weapp alipay preview --project ./dist/mp-alipay
54
+ ```
55
+
56
+ 首次使用前请确认已全局安装 `minidev`(例如执行 `pnpm add -g minidev`)。若命令不存在,CLI 会给出安装提示。
57
+
43
58
  ## 常用命令速查
44
59
 
45
60
  | 命令 | 说明 |
@@ -1,3 +1,7 @@
1
+ // src/logger.ts
2
+ import logger from "@weapp-core/logger";
3
+ var logger_default = logger;
4
+
1
5
  // src/utils/path.ts
2
6
  import process from "process";
3
7
  import path from "pathe";
@@ -8,6 +12,82 @@ function resolvePath(filePath) {
8
12
  return path.resolve(process.cwd(), filePath);
9
13
  }
10
14
 
15
+ // src/utils/argv.ts
16
+ import process2 from "process";
17
+ function ensurePathArgument(argv, optionIndex) {
18
+ const paramIdx = optionIndex + 1;
19
+ const param = argv[paramIdx];
20
+ if (param && !param.startsWith("-")) {
21
+ argv[paramIdx] = resolvePath(param);
22
+ } else {
23
+ argv.splice(paramIdx, 0, process2.cwd());
24
+ }
25
+ return argv;
26
+ }
27
+ function transformArgv(argv, transforms) {
28
+ return transforms.reduce((current, transform) => transform(current), [
29
+ ...argv
30
+ ]);
31
+ }
32
+ function createAlias(entry) {
33
+ return (input2) => {
34
+ const argv = [...input2];
35
+ let optionIndex = argv.indexOf(entry.find);
36
+ if (optionIndex > -1) {
37
+ argv.splice(optionIndex, 1, entry.replacement);
38
+ } else {
39
+ optionIndex = argv.indexOf(entry.replacement);
40
+ }
41
+ if (optionIndex === -1) {
42
+ return argv;
43
+ }
44
+ return ensurePathArgument(argv, optionIndex);
45
+ };
46
+ }
47
+ function createPathCompat(option) {
48
+ return (input2) => {
49
+ const argv = [...input2];
50
+ const optionIndex = argv.indexOf(option);
51
+ if (optionIndex === -1) {
52
+ return argv;
53
+ }
54
+ return ensurePathArgument(argv, optionIndex);
55
+ };
56
+ }
57
+
58
+ // src/utils/exec.ts
59
+ import process3 from "process";
60
+ async function execute(cliPath, argv) {
61
+ const { execa } = await import("execa");
62
+ const task = execa(cliPath, argv);
63
+ task?.stdout?.pipe(process3.stdout);
64
+ task?.stderr?.pipe(process3.stderr);
65
+ await task;
66
+ }
67
+
68
+ // src/cli/minidev.ts
69
+ var MINIDEV_COMMAND = "minidev";
70
+ function isCommandNotFound(error) {
71
+ return Boolean(
72
+ error && typeof error === "object" && "code" in error && error.code === "ENOENT"
73
+ );
74
+ }
75
+ async function runMinidev(argv) {
76
+ try {
77
+ await execute(MINIDEV_COMMAND, [...argv]);
78
+ } catch (error) {
79
+ if (isCommandNotFound(error)) {
80
+ logger_default.error("\u672A\u68C0\u6D4B\u5230\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F CLI\uFF1Aminidev");
81
+ logger_default.log("\u8BF7\u5148\u5B89\u88C5 minidev\uFF0C\u53EF\u4F7F\u7528\u4EE5\u4E0B\u4EFB\u4E00\u547D\u4EE4\uFF1A");
82
+ logger_default.log("- pnpm add -g minidev");
83
+ logger_default.log("- npm install -g minidev");
84
+ logger_default.log("- yarn global add minidev");
85
+ return;
86
+ }
87
+ throw error;
88
+ }
89
+ }
90
+
11
91
  // src/config/paths.ts
12
92
  import os from "os";
13
93
  import path2 from "pathe";
@@ -41,10 +121,6 @@ async function createCustomConfig(params) {
41
121
  return normalizedCliPath;
42
122
  }
43
123
 
44
- // src/logger.ts
45
- import logger from "@weapp-core/logger";
46
- var logger_default = logger;
47
-
48
124
  // src/cli/prompt.ts
49
125
  import { stdin as input, stdout as output } from "process";
50
126
  import { createInterface } from "readline/promises";
@@ -81,7 +157,7 @@ async function promptForCliPath() {
81
157
 
82
158
  // src/runtime/platform.ts
83
159
  import os2 from "os";
84
- import process2 from "process";
160
+ import process4 from "process";
85
161
  import fs3 from "fs-extra";
86
162
  import path3 from "pathe";
87
163
  var SupportedPlatformsMap = {
@@ -137,7 +213,7 @@ async function getDefaultCliPath(targetOs = operatingSystemName) {
137
213
  return resolvedPath;
138
214
  }
139
215
  async function getFirstBinaryPath(command) {
140
- const envPath = process2.env.PATH || "";
216
+ const envPath = process4.env.PATH || "";
141
217
  const pathDirs = envPath.split(path3.delimiter);
142
218
  for (const dir of pathDirs) {
143
219
  const fullPath = path3.join(dir, command);
@@ -199,58 +275,6 @@ async function resolveCliPath() {
199
275
  };
200
276
  }
201
277
 
202
- // src/utils/argv.ts
203
- import process3 from "process";
204
- function ensurePathArgument(argv, optionIndex) {
205
- const paramIdx = optionIndex + 1;
206
- const param = argv[paramIdx];
207
- if (param && !param.startsWith("-")) {
208
- argv[paramIdx] = resolvePath(param);
209
- } else {
210
- argv.splice(paramIdx, 0, process3.cwd());
211
- }
212
- return argv;
213
- }
214
- function transformArgv(argv, transforms) {
215
- return transforms.reduce((current, transform) => transform(current), [
216
- ...argv
217
- ]);
218
- }
219
- function createAlias(entry) {
220
- return (input2) => {
221
- const argv = [...input2];
222
- let optionIndex = argv.indexOf(entry.find);
223
- if (optionIndex > -1) {
224
- argv.splice(optionIndex, 1, entry.replacement);
225
- } else {
226
- optionIndex = argv.indexOf(entry.replacement);
227
- }
228
- if (optionIndex === -1) {
229
- return argv;
230
- }
231
- return ensurePathArgument(argv, optionIndex);
232
- };
233
- }
234
- function createPathCompat(option) {
235
- return (input2) => {
236
- const argv = [...input2];
237
- const optionIndex = argv.indexOf(option);
238
- if (optionIndex === -1) {
239
- return argv;
240
- }
241
- return ensurePathArgument(argv, optionIndex);
242
- };
243
- }
244
-
245
- // src/utils/exec.ts
246
- import process4 from "process";
247
- async function execute(cliPath, argv) {
248
- const { execa } = await import("execa");
249
- const task = execa(cliPath, argv);
250
- task?.stdout?.pipe(process4.stdout);
251
- await task;
252
- }
253
-
254
278
  // src/cli/run.ts
255
279
  var ARG_TRANSFORMS = [
256
280
  createAlias({ find: "-p", replacement: "--project" }),
@@ -262,11 +286,16 @@ var ARG_TRANSFORMS = [
262
286
  createPathCompat("-i")
263
287
  ];
264
288
  async function parse(argv) {
289
+ const head = argv[0];
290
+ if (head && ["alipay", "ali", "minidev"].includes(head)) {
291
+ await runMinidev(argv.slice(1));
292
+ return;
293
+ }
265
294
  if (!isOperatingSystemSupported(operatingSystemName)) {
266
295
  logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
267
296
  return;
268
297
  }
269
- if (argv[0] === "config") {
298
+ if (head === "config") {
270
299
  await promptForCliPath();
271
300
  return;
272
301
  }
@@ -282,11 +311,16 @@ async function parse(argv) {
282
311
  }
283
312
 
284
313
  export {
314
+ logger_default,
285
315
  resolvePath,
316
+ transformArgv,
317
+ createAlias,
318
+ createPathCompat,
319
+ execute,
320
+ runMinidev,
286
321
  defaultCustomConfigDirPath,
287
322
  defaultCustomConfigFilePath,
288
323
  createCustomConfig,
289
- logger_default,
290
324
  promptForCliPath,
291
325
  SupportedPlatformsMap,
292
326
  isOperatingSystemSupported,
@@ -294,9 +328,5 @@ export {
294
328
  getDefaultCliPath,
295
329
  getConfig,
296
330
  resolveCliPath,
297
- transformArgv,
298
- createAlias,
299
- createPathCompat,
300
- execute,
301
331
  parse
302
332
  };
package/dist/cli.cjs CHANGED
@@ -25,13 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  // src/cli.ts
26
26
  var import_node_process6 = __toESM(require("process"), 1);
27
27
 
28
- // src/cli/prompt.ts
29
- var import_node_process2 = require("process");
30
- var import_promises = require("readline/promises");
31
- var import_fs_extra2 = __toESM(require("fs-extra"), 1);
28
+ // src/logger.ts
29
+ var import_logger = __toESM(require("@weapp-core/logger"), 1);
30
+ var logger_default = import_logger.default;
32
31
 
33
- // src/config/custom.ts
34
- var import_fs_extra = __toESM(require("fs-extra"), 1);
32
+ // src/utils/argv.ts
33
+ var import_node_process2 = __toESM(require("process"), 1);
35
34
 
36
35
  // src/utils/path.ts
37
36
  var import_node_process = __toESM(require("process"), 1);
@@ -43,6 +42,89 @@ function resolvePath(filePath) {
43
42
  return import_pathe.default.resolve(import_node_process.default.cwd(), filePath);
44
43
  }
45
44
 
45
+ // src/utils/argv.ts
46
+ function ensurePathArgument(argv2, optionIndex) {
47
+ const paramIdx = optionIndex + 1;
48
+ const param = argv2[paramIdx];
49
+ if (param && !param.startsWith("-")) {
50
+ argv2[paramIdx] = resolvePath(param);
51
+ } else {
52
+ argv2.splice(paramIdx, 0, import_node_process2.default.cwd());
53
+ }
54
+ return argv2;
55
+ }
56
+ function transformArgv(argv2, transforms) {
57
+ return transforms.reduce((current, transform) => transform(current), [
58
+ ...argv2
59
+ ]);
60
+ }
61
+ function createAlias(entry) {
62
+ return (input2) => {
63
+ const argv2 = [...input2];
64
+ let optionIndex = argv2.indexOf(entry.find);
65
+ if (optionIndex > -1) {
66
+ argv2.splice(optionIndex, 1, entry.replacement);
67
+ } else {
68
+ optionIndex = argv2.indexOf(entry.replacement);
69
+ }
70
+ if (optionIndex === -1) {
71
+ return argv2;
72
+ }
73
+ return ensurePathArgument(argv2, optionIndex);
74
+ };
75
+ }
76
+ function createPathCompat(option) {
77
+ return (input2) => {
78
+ const argv2 = [...input2];
79
+ const optionIndex = argv2.indexOf(option);
80
+ if (optionIndex === -1) {
81
+ return argv2;
82
+ }
83
+ return ensurePathArgument(argv2, optionIndex);
84
+ };
85
+ }
86
+
87
+ // src/utils/exec.ts
88
+ var import_node_process3 = __toESM(require("process"), 1);
89
+ async function execute(cliPath, argv2) {
90
+ const { execa } = await import("execa");
91
+ const task = execa(cliPath, argv2);
92
+ task?.stdout?.pipe(import_node_process3.default.stdout);
93
+ task?.stderr?.pipe(import_node_process3.default.stderr);
94
+ await task;
95
+ }
96
+
97
+ // src/cli/minidev.ts
98
+ var MINIDEV_COMMAND = "minidev";
99
+ function isCommandNotFound(error) {
100
+ return Boolean(
101
+ error && typeof error === "object" && "code" in error && error.code === "ENOENT"
102
+ );
103
+ }
104
+ async function runMinidev(argv2) {
105
+ try {
106
+ await execute(MINIDEV_COMMAND, [...argv2]);
107
+ } catch (error) {
108
+ if (isCommandNotFound(error)) {
109
+ logger_default.error("\u672A\u68C0\u6D4B\u5230\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F CLI\uFF1Aminidev");
110
+ logger_default.log("\u8BF7\u5148\u5B89\u88C5 minidev\uFF0C\u53EF\u4F7F\u7528\u4EE5\u4E0B\u4EFB\u4E00\u547D\u4EE4\uFF1A");
111
+ logger_default.log("- pnpm add -g minidev");
112
+ logger_default.log("- npm install -g minidev");
113
+ logger_default.log("- yarn global add minidev");
114
+ return;
115
+ }
116
+ throw error;
117
+ }
118
+ }
119
+
120
+ // src/cli/prompt.ts
121
+ var import_node_process4 = require("process");
122
+ var import_promises = require("readline/promises");
123
+ var import_fs_extra2 = __toESM(require("fs-extra"), 1);
124
+
125
+ // src/config/custom.ts
126
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
127
+
46
128
  // src/config/paths.ts
47
129
  var import_node_os = __toESM(require("os"), 1);
48
130
  var import_pathe2 = __toESM(require("pathe"), 1);
@@ -75,13 +157,9 @@ async function createCustomConfig(params) {
75
157
  return normalizedCliPath;
76
158
  }
77
159
 
78
- // src/logger.ts
79
- var import_logger = __toESM(require("@weapp-core/logger"), 1);
80
- var logger_default = import_logger.default;
81
-
82
160
  // src/cli/prompt.ts
83
161
  async function promptForCliPath() {
84
- const rl = (0, import_promises.createInterface)({ input: import_node_process2.stdin, output: import_node_process2.stdout });
162
+ const rl = (0, import_promises.createInterface)({ input: import_node_process4.stdin, output: import_node_process4.stdout });
85
163
  try {
86
164
  logger_default.log("\u8BF7\u8BBE\u7F6E\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 CLI \u7684\u8DEF\u5F84");
87
165
  logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
@@ -118,7 +196,7 @@ var import_fs_extra4 = __toESM(require("fs-extra"), 1);
118
196
 
119
197
  // src/runtime/platform.ts
120
198
  var import_node_os2 = __toESM(require("os"), 1);
121
- var import_node_process3 = __toESM(require("process"), 1);
199
+ var import_node_process5 = __toESM(require("process"), 1);
122
200
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
123
201
  var import_pathe3 = __toESM(require("pathe"), 1);
124
202
  var SupportedPlatformsMap = {
@@ -174,7 +252,7 @@ async function getDefaultCliPath(targetOs = operatingSystemName) {
174
252
  return resolvedPath;
175
253
  }
176
254
  async function getFirstBinaryPath(command) {
177
- const envPath = import_node_process3.default.env.PATH || "";
255
+ const envPath = import_node_process5.default.env.PATH || "";
178
256
  const pathDirs = envPath.split(import_pathe3.default.delimiter);
179
257
  for (const dir of pathDirs) {
180
258
  const fullPath = import_pathe3.default.join(dir, command);
@@ -234,58 +312,6 @@ async function resolveCliPath() {
234
312
  };
235
313
  }
236
314
 
237
- // src/utils/argv.ts
238
- var import_node_process4 = __toESM(require("process"), 1);
239
- function ensurePathArgument(argv2, optionIndex) {
240
- const paramIdx = optionIndex + 1;
241
- const param = argv2[paramIdx];
242
- if (param && !param.startsWith("-")) {
243
- argv2[paramIdx] = resolvePath(param);
244
- } else {
245
- argv2.splice(paramIdx, 0, import_node_process4.default.cwd());
246
- }
247
- return argv2;
248
- }
249
- function transformArgv(argv2, transforms) {
250
- return transforms.reduce((current, transform) => transform(current), [
251
- ...argv2
252
- ]);
253
- }
254
- function createAlias(entry) {
255
- return (input2) => {
256
- const argv2 = [...input2];
257
- let optionIndex = argv2.indexOf(entry.find);
258
- if (optionIndex > -1) {
259
- argv2.splice(optionIndex, 1, entry.replacement);
260
- } else {
261
- optionIndex = argv2.indexOf(entry.replacement);
262
- }
263
- if (optionIndex === -1) {
264
- return argv2;
265
- }
266
- return ensurePathArgument(argv2, optionIndex);
267
- };
268
- }
269
- function createPathCompat(option) {
270
- return (input2) => {
271
- const argv2 = [...input2];
272
- const optionIndex = argv2.indexOf(option);
273
- if (optionIndex === -1) {
274
- return argv2;
275
- }
276
- return ensurePathArgument(argv2, optionIndex);
277
- };
278
- }
279
-
280
- // src/utils/exec.ts
281
- var import_node_process5 = __toESM(require("process"), 1);
282
- async function execute(cliPath, argv2) {
283
- const { execa } = await import("execa");
284
- const task = execa(cliPath, argv2);
285
- task?.stdout?.pipe(import_node_process5.default.stdout);
286
- await task;
287
- }
288
-
289
315
  // src/cli/run.ts
290
316
  var ARG_TRANSFORMS = [
291
317
  createAlias({ find: "-p", replacement: "--project" }),
@@ -297,11 +323,16 @@ var ARG_TRANSFORMS = [
297
323
  createPathCompat("-i")
298
324
  ];
299
325
  async function parse(argv2) {
326
+ const head = argv2[0];
327
+ if (head && ["alipay", "ali", "minidev"].includes(head)) {
328
+ await runMinidev(argv2.slice(1));
329
+ return;
330
+ }
300
331
  if (!isOperatingSystemSupported(operatingSystemName)) {
301
332
  logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
302
333
  return;
303
334
  }
304
- if (argv2[0] === "config") {
335
+ if (head === "config") {
305
336
  await promptForCliPath();
306
337
  return;
307
338
  }
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  logger_default,
3
3
  parse
4
- } from "./chunk-FJJOQAVP.js";
4
+ } from "./chunk-RQRH244E.js";
5
5
 
6
6
  // src/cli.ts
7
7
  import process from "process";
package/dist/index.cjs CHANGED
@@ -45,17 +45,17 @@ __export(src_exports, {
45
45
  promptForCliPath: () => promptForCliPath,
46
46
  resolveCliPath: () => resolveCliPath,
47
47
  resolvePath: () => resolvePath,
48
+ runMinidev: () => runMinidev,
48
49
  transformArgv: () => transformArgv
49
50
  });
50
51
  module.exports = __toCommonJS(src_exports);
51
52
 
52
- // src/cli/prompt.ts
53
- var import_node_process2 = require("process");
54
- var import_promises = require("readline/promises");
55
- var import_fs_extra2 = __toESM(require("fs-extra"), 1);
53
+ // src/logger.ts
54
+ var import_logger = __toESM(require("@weapp-core/logger"), 1);
55
+ var logger_default = import_logger.default;
56
56
 
57
- // src/config/custom.ts
58
- var import_fs_extra = __toESM(require("fs-extra"), 1);
57
+ // src/utils/argv.ts
58
+ var import_node_process2 = __toESM(require("process"), 1);
59
59
 
60
60
  // src/utils/path.ts
61
61
  var import_node_process = __toESM(require("process"), 1);
@@ -67,6 +67,89 @@ function resolvePath(filePath) {
67
67
  return import_pathe.default.resolve(import_node_process.default.cwd(), filePath);
68
68
  }
69
69
 
70
+ // src/utils/argv.ts
71
+ function ensurePathArgument(argv, optionIndex) {
72
+ const paramIdx = optionIndex + 1;
73
+ const param = argv[paramIdx];
74
+ if (param && !param.startsWith("-")) {
75
+ argv[paramIdx] = resolvePath(param);
76
+ } else {
77
+ argv.splice(paramIdx, 0, import_node_process2.default.cwd());
78
+ }
79
+ return argv;
80
+ }
81
+ function transformArgv(argv, transforms) {
82
+ return transforms.reduce((current, transform) => transform(current), [
83
+ ...argv
84
+ ]);
85
+ }
86
+ function createAlias(entry) {
87
+ return (input2) => {
88
+ const argv = [...input2];
89
+ let optionIndex = argv.indexOf(entry.find);
90
+ if (optionIndex > -1) {
91
+ argv.splice(optionIndex, 1, entry.replacement);
92
+ } else {
93
+ optionIndex = argv.indexOf(entry.replacement);
94
+ }
95
+ if (optionIndex === -1) {
96
+ return argv;
97
+ }
98
+ return ensurePathArgument(argv, optionIndex);
99
+ };
100
+ }
101
+ function createPathCompat(option) {
102
+ return (input2) => {
103
+ const argv = [...input2];
104
+ const optionIndex = argv.indexOf(option);
105
+ if (optionIndex === -1) {
106
+ return argv;
107
+ }
108
+ return ensurePathArgument(argv, optionIndex);
109
+ };
110
+ }
111
+
112
+ // src/utils/exec.ts
113
+ var import_node_process3 = __toESM(require("process"), 1);
114
+ async function execute(cliPath, argv) {
115
+ const { execa } = await import("execa");
116
+ const task = execa(cliPath, argv);
117
+ task?.stdout?.pipe(import_node_process3.default.stdout);
118
+ task?.stderr?.pipe(import_node_process3.default.stderr);
119
+ await task;
120
+ }
121
+
122
+ // src/cli/minidev.ts
123
+ var MINIDEV_COMMAND = "minidev";
124
+ function isCommandNotFound(error) {
125
+ return Boolean(
126
+ error && typeof error === "object" && "code" in error && error.code === "ENOENT"
127
+ );
128
+ }
129
+ async function runMinidev(argv) {
130
+ try {
131
+ await execute(MINIDEV_COMMAND, [...argv]);
132
+ } catch (error) {
133
+ if (isCommandNotFound(error)) {
134
+ logger_default.error("\u672A\u68C0\u6D4B\u5230\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F CLI\uFF1Aminidev");
135
+ logger_default.log("\u8BF7\u5148\u5B89\u88C5 minidev\uFF0C\u53EF\u4F7F\u7528\u4EE5\u4E0B\u4EFB\u4E00\u547D\u4EE4\uFF1A");
136
+ logger_default.log("- pnpm add -g minidev");
137
+ logger_default.log("- npm install -g minidev");
138
+ logger_default.log("- yarn global add minidev");
139
+ return;
140
+ }
141
+ throw error;
142
+ }
143
+ }
144
+
145
+ // src/cli/prompt.ts
146
+ var import_node_process4 = require("process");
147
+ var import_promises = require("readline/promises");
148
+ var import_fs_extra2 = __toESM(require("fs-extra"), 1);
149
+
150
+ // src/config/custom.ts
151
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
152
+
70
153
  // src/config/paths.ts
71
154
  var import_node_os = __toESM(require("os"), 1);
72
155
  var import_pathe2 = __toESM(require("pathe"), 1);
@@ -99,13 +182,9 @@ async function createCustomConfig(params) {
99
182
  return normalizedCliPath;
100
183
  }
101
184
 
102
- // src/logger.ts
103
- var import_logger = __toESM(require("@weapp-core/logger"), 1);
104
- var logger_default = import_logger.default;
105
-
106
185
  // src/cli/prompt.ts
107
186
  async function promptForCliPath() {
108
- const rl = (0, import_promises.createInterface)({ input: import_node_process2.stdin, output: import_node_process2.stdout });
187
+ const rl = (0, import_promises.createInterface)({ input: import_node_process4.stdin, output: import_node_process4.stdout });
109
188
  try {
110
189
  logger_default.log("\u8BF7\u8BBE\u7F6E\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177 CLI \u7684\u8DEF\u5F84");
111
190
  logger_default.log("> \u63D0\u793A\uFF1A\u547D\u4EE4\u884C\u5DE5\u5177\u9ED8\u8BA4\u6240\u5728\u4F4D\u7F6E\uFF1A");
@@ -142,7 +221,7 @@ var import_fs_extra4 = __toESM(require("fs-extra"), 1);
142
221
 
143
222
  // src/runtime/platform.ts
144
223
  var import_node_os2 = __toESM(require("os"), 1);
145
- var import_node_process3 = __toESM(require("process"), 1);
224
+ var import_node_process5 = __toESM(require("process"), 1);
146
225
  var import_fs_extra3 = __toESM(require("fs-extra"), 1);
147
226
  var import_pathe3 = __toESM(require("pathe"), 1);
148
227
  var SupportedPlatformsMap = {
@@ -198,7 +277,7 @@ async function getDefaultCliPath(targetOs = operatingSystemName) {
198
277
  return resolvedPath;
199
278
  }
200
279
  async function getFirstBinaryPath(command) {
201
- const envPath = import_node_process3.default.env.PATH || "";
280
+ const envPath = import_node_process5.default.env.PATH || "";
202
281
  const pathDirs = envPath.split(import_pathe3.default.delimiter);
203
282
  for (const dir of pathDirs) {
204
283
  const fullPath = import_pathe3.default.join(dir, command);
@@ -258,58 +337,6 @@ async function resolveCliPath() {
258
337
  };
259
338
  }
260
339
 
261
- // src/utils/argv.ts
262
- var import_node_process4 = __toESM(require("process"), 1);
263
- function ensurePathArgument(argv, optionIndex) {
264
- const paramIdx = optionIndex + 1;
265
- const param = argv[paramIdx];
266
- if (param && !param.startsWith("-")) {
267
- argv[paramIdx] = resolvePath(param);
268
- } else {
269
- argv.splice(paramIdx, 0, import_node_process4.default.cwd());
270
- }
271
- return argv;
272
- }
273
- function transformArgv(argv, transforms) {
274
- return transforms.reduce((current, transform) => transform(current), [
275
- ...argv
276
- ]);
277
- }
278
- function createAlias(entry) {
279
- return (input2) => {
280
- const argv = [...input2];
281
- let optionIndex = argv.indexOf(entry.find);
282
- if (optionIndex > -1) {
283
- argv.splice(optionIndex, 1, entry.replacement);
284
- } else {
285
- optionIndex = argv.indexOf(entry.replacement);
286
- }
287
- if (optionIndex === -1) {
288
- return argv;
289
- }
290
- return ensurePathArgument(argv, optionIndex);
291
- };
292
- }
293
- function createPathCompat(option) {
294
- return (input2) => {
295
- const argv = [...input2];
296
- const optionIndex = argv.indexOf(option);
297
- if (optionIndex === -1) {
298
- return argv;
299
- }
300
- return ensurePathArgument(argv, optionIndex);
301
- };
302
- }
303
-
304
- // src/utils/exec.ts
305
- var import_node_process5 = __toESM(require("process"), 1);
306
- async function execute(cliPath, argv) {
307
- const { execa } = await import("execa");
308
- const task = execa(cliPath, argv);
309
- task?.stdout?.pipe(import_node_process5.default.stdout);
310
- await task;
311
- }
312
-
313
340
  // src/cli/run.ts
314
341
  var ARG_TRANSFORMS = [
315
342
  createAlias({ find: "-p", replacement: "--project" }),
@@ -321,11 +348,16 @@ var ARG_TRANSFORMS = [
321
348
  createPathCompat("-i")
322
349
  ];
323
350
  async function parse(argv) {
351
+ const head = argv[0];
352
+ if (head && ["alipay", "ali", "minidev"].includes(head)) {
353
+ await runMinidev(argv.slice(1));
354
+ return;
355
+ }
324
356
  if (!isOperatingSystemSupported(operatingSystemName)) {
325
357
  logger_default.log(`\u5FAE\u4FE1web\u5F00\u53D1\u8005\u5DE5\u5177\u4E0D\u652F\u6301\u5F53\u524D\u5E73\u53F0\uFF1A${operatingSystemName} !`);
326
358
  return;
327
359
  }
328
- if (argv[0] === "config") {
360
+ if (head === "config") {
329
361
  await promptForCliPath();
330
362
  return;
331
363
  }
@@ -356,5 +388,6 @@ async function parse(argv) {
356
388
  promptForCliPath,
357
389
  resolveCliPath,
358
390
  resolvePath,
391
+ runMinidev,
359
392
  transformArgv
360
393
  });
package/dist/index.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ declare function runMinidev(argv: readonly string[]): Promise<void>;
2
+
1
3
  declare function promptForCliPath(): Promise<string | null>;
2
4
 
3
5
  declare function resolveCliPath(): Promise<{
@@ -51,4 +53,4 @@ declare function execute(cliPath: string, argv: string[]): Promise<void>;
51
53
 
52
54
  declare function resolvePath(filePath: string): string;
53
55
 
54
- 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, transformArgv };
56
+ 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.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ declare function runMinidev(argv: readonly string[]): Promise<void>;
2
+
1
3
  declare function promptForCliPath(): Promise<string | null>;
2
4
 
3
5
  declare function resolveCliPath(): Promise<{
@@ -51,4 +53,4 @@ declare function execute(cliPath: string, argv: string[]): Promise<void>;
51
53
 
52
54
  declare function resolvePath(filePath: string): string;
53
55
 
54
- 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, transformArgv };
56
+ 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
@@ -14,8 +14,9 @@ import {
14
14
  promptForCliPath,
15
15
  resolveCliPath,
16
16
  resolvePath,
17
+ runMinidev,
17
18
  transformArgv
18
- } from "./chunk-FJJOQAVP.js";
19
+ } from "./chunk-RQRH244E.js";
19
20
  export {
20
21
  SupportedPlatformsMap,
21
22
  createAlias,
@@ -32,5 +33,6 @@ export {
32
33
  promptForCliPath,
33
34
  resolveCliPath,
34
35
  resolvePath,
36
+ runMinidev,
35
37
  transformArgv
36
38
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-ide-cli",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.1.0",
5
5
  "description": "让微信开发者工具,用起来更加方便!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",