weapp-vite 6.6.13 → 6.6.15

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.
Files changed (3) hide show
  1. package/README.md +19 -0
  2. package/dist/cli.mjs +51 -2
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -27,6 +27,7 @@
27
27
 
28
28
  - ⚡️ **Vite 构建**:带来了 `typescript` / `scss` / `less` 等等的原生支持
29
29
  - 🔌 **插件生态**:Vite 插件生态支持,也可以自定义编写插件,方便扩展
30
+ - 🧰 **IDE 命令增强**:可直接透传 `weapp-ide-cli` 全量命令(`preview/upload/config/automator` 等)
30
31
 
31
32
  ## 快速开始
32
33
 
@@ -82,6 +83,24 @@ function handleClick() {
82
83
  - 配置智能提示文档:[docs/volar.md](./docs/volar.md)
83
84
  - defineConfig 重载说明:[docs/define-config-overloads.md](./docs/define-config-overloads.md)
84
85
 
86
+ ## CLI 中调用 weapp-ide-cli
87
+
88
+ `weapp-vite` 内置了对 `weapp-ide-cli` 的透传能力,除了 `dev/build/open/init/generate/analyze/npm` 等原生命令外,其它 IDE 相关命令都可以直接调用:
89
+
90
+ ```sh
91
+ weapp-vite preview --project ./dist/build/mp-weixin
92
+ weapp-vite upload --project ./dist/build/mp-weixin -v 1.0.0 -d "release"
93
+ weapp-vite config lang zh
94
+ weapp-vite navigate pages/index/index --project ./dist/build/mp-weixin
95
+ ```
96
+
97
+ 也支持命名空间写法:
98
+
99
+ ```sh
100
+ weapp-vite ide preview --project ./dist/build/mp-weixin
101
+ weapp-vite ide config show
102
+ ```
103
+
85
104
  ## Contribute
86
105
 
87
106
  我们邀请你来贡献和帮助改进 `weapp-vite` 💚💚💚
package/dist/cli.mjs CHANGED
@@ -2260,6 +2260,49 @@ function handleCLIError(error) {
2260
2260
  default2.error(error);
2261
2261
  }
2262
2262
 
2263
+ // src/cli/ide.ts
2264
+ init_esm_shims();
2265
+ import { isWeappIdeTopLevelCommand, parse as parseWeappIdeCli } from "weapp-ide-cli";
2266
+ var WEAPP_VITE_NATIVE_COMMANDS = /* @__PURE__ */ new Set([
2267
+ "dev",
2268
+ "serve",
2269
+ "build",
2270
+ "analyze",
2271
+ "init",
2272
+ "open",
2273
+ "npm",
2274
+ "build:npm",
2275
+ "build-npm",
2276
+ "generate",
2277
+ "g"
2278
+ ]);
2279
+ async function tryRunIdeCommand(argv) {
2280
+ const command = argv[0];
2281
+ if (!command) {
2282
+ return false;
2283
+ }
2284
+ if (command === "ide") {
2285
+ await parseWeappIdeCli(argv.slice(1));
2286
+ return true;
2287
+ }
2288
+ if (command.startsWith("-")) {
2289
+ return false;
2290
+ }
2291
+ if (command === "help") {
2292
+ const target = argv[1];
2293
+ if (!target || WEAPP_VITE_NATIVE_COMMANDS.has(target) || !isWeappIdeTopLevelCommand(target)) {
2294
+ return false;
2295
+ }
2296
+ await parseWeappIdeCli(argv);
2297
+ return true;
2298
+ }
2299
+ if (WEAPP_VITE_NATIVE_COMMANDS.has(command) || !isWeappIdeTopLevelCommand(command)) {
2300
+ return false;
2301
+ }
2302
+ await parseWeappIdeCli(argv);
2303
+ return true;
2304
+ }
2305
+
2263
2306
  // src/cli.ts
2264
2307
  var cli = cac("weapp-vite");
2265
2308
  try {
@@ -2283,8 +2326,14 @@ registerGenerateCommand(cli);
2283
2326
  cli.help();
2284
2327
  cli.version(VERSION);
2285
2328
  try {
2286
- cli.parse(process9.argv, { run: false });
2287
- Promise.resolve().then(() => cli.runMatchedCommand()).catch((error) => {
2329
+ Promise.resolve().then(async () => {
2330
+ const forwarded = await tryRunIdeCommand(process9.argv.slice(2));
2331
+ if (forwarded) {
2332
+ return;
2333
+ }
2334
+ cli.parse(process9.argv, { run: false });
2335
+ await cli.runMatchedCommand();
2336
+ }).catch((error) => {
2288
2337
  handleCLIError(error);
2289
2338
  process9.exitCode = 1;
2290
2339
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.6.13",
4
+ "version": "6.6.15",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -116,8 +116,8 @@
116
116
  "@wevu/api": "0.1.1",
117
117
  "rolldown-require": "2.0.6",
118
118
  "vite-plugin-performance": "2.0.1",
119
- "weapp-ide-cli": "5.0.4",
120
- "wevu": "6.6.13"
119
+ "weapp-ide-cli": "5.1.0",
120
+ "wevu": "6.6.15"
121
121
  },
122
122
  "publishConfig": {
123
123
  "access": "public",