ms-vite-plugin 0.3.1 → 0.3.3

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 (2) hide show
  1. package/dist/build.js +33 -1
  2. package/package.json +2 -1
package/dist/build.js CHANGED
@@ -115,8 +115,9 @@ function prodReturnMain() {
115
115
  */
116
116
  function detectPython314() {
117
117
  const candidates = [
118
- { cmd: "python3.14", args: ["--version"] },
118
+ { cmd: "python", args: ["--version"] },
119
119
  { cmd: "python3", args: ["--version"] },
120
+ { cmd: "python3.14", args: ["--version"] },
120
121
  ];
121
122
  for (const c of candidates) {
122
123
  try {
@@ -259,6 +260,37 @@ const buildAll = async (isDev = true, workspacePath) => {
259
260
  console.warn("⚠️ 未检测到 Python 3.14,请确保在目标运行环境安装 Python 3.14");
260
261
  }
261
262
  }
263
+ else if (isLua) {
264
+ const scriptsDir = path.join(outPath, "scripts");
265
+ // 递归查找所有 .lua 文件
266
+ const luaFiles = [];
267
+ const walk = async (dir) => {
268
+ const entries = await fsExtra.readdir(dir, { withFileTypes: true });
269
+ for (const entry of entries) {
270
+ const full = path.join(dir, entry.name);
271
+ if (entry.isDirectory()) {
272
+ await walk(full);
273
+ }
274
+ else if (entry.isFile() && entry.name.endsWith(".lua")) {
275
+ luaFiles.push(full);
276
+ }
277
+ }
278
+ };
279
+ await walk(scriptsDir);
280
+ // Prometheus CLI 路径(本插件 node_modules 内)
281
+ const cliPath = path.resolve(__dirname, "../node_modules/@gamely/prometheus-cli/bin/cli.js");
282
+ for (const file of luaFiles) {
283
+ const rel = path.relative(scriptsDir, file);
284
+ console.log(`🛠️ 混淆 Lua: ${rel}`);
285
+ const r = (0, child_process_1.spawnSync)(process.execPath, [cliPath, rel, "--preset", "Minify"], { cwd: scriptsDir, encoding: "utf8" });
286
+ if (r.status !== 0) {
287
+ console.error("❌ 混淆 Lua 失败:", rel);
288
+ console.error(r.stderr || r.stdout || "");
289
+ process.exit(1);
290
+ }
291
+ }
292
+ console.log("✅ Lua 混淆完成");
293
+ }
262
294
  // 打包完成后执行
263
295
  await fsExtra.copy(path.join(workspacePath, "res"), path.join(outPath, "res"));
264
296
  await fsExtra.copy(path.join(workspacePath, "ui"), path.join(outPath, "ui"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -19,6 +19,7 @@
19
19
  "prepublishOnly": "npm run build"
20
20
  },
21
21
  "dependencies": {
22
+ "@gamely/prometheus-cli": "^0.0.9",
22
23
  "commander": "^14.0.2",
23
24
  "fs-extra": "^11.3.2",
24
25
  "vite": "^7.2.4",