weapp-ide-cli 5.0.1 → 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 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 && ["alipay", "ali", "minidev"].includes(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
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  logger_default,
3
3
  parse
4
- } from "./chunk-RQRH244E.js";
4
+ } from "./chunk-DNENPZKW.js";
5
5
 
6
6
  // src/cli.ts
7
7
  import process from "process";
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolvePath,
17
17
  runMinidev,
18
18
  transformArgv
19
- } from "./chunk-RQRH244E.js";
19
+ } from "./chunk-DNENPZKW.js";
20
20
  export {
21
21
  SupportedPlatformsMap,
22
22
  createAlias,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-ide-cli",
3
3
  "type": "module",
4
- "version": "5.0.1",
4
+ "version": "5.0.2",
5
5
  "description": "让微信开发者工具,用起来更加方便!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",