ms-vite-plugin 0.2.7 → 0.2.9

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 +39 -3
  2. package/package.json +4 -4
package/dist/build.js CHANGED
@@ -41,6 +41,7 @@ const zip_a_folder_1 = require("zip-a-folder");
41
41
  const fsExtra = __importStar(require("fs-extra"));
42
42
  const path = __importStar(require("path"));
43
43
  const vite_1 = require("vite");
44
+ const child_process_1 = require("child_process");
44
45
  const vite_plugin_bundle_obfuscator_1 = __importDefault(require("vite-plugin-bundle-obfuscator"));
45
46
  /**
46
47
  * 查找入口文件:main.js/main.ts 和所有以 _thread 结尾的 JS/TS 文件
@@ -107,8 +108,31 @@ function prodReturnMain() {
107
108
  },
108
109
  };
109
110
  }
111
+ /**
112
+ * 检测系统是否存在 Python 3.14
113
+ * - 依次尝试 python3.14、python3、py -3.14(Windows)
114
+ * - 返回检测结果与版本字符串
115
+ */
116
+ function detectPython314() {
117
+ const candidates = [
118
+ { cmd: "python3.14", args: ["--version"] },
119
+ { cmd: "python3", args: ["--version"] },
120
+ ];
121
+ for (const c of candidates) {
122
+ try {
123
+ const r = (0, child_process_1.spawnSync)(c.cmd, c.args, { encoding: "utf8" });
124
+ const out = (r.stdout || r.stderr || "").trim();
125
+ if (out && /Python\s+3\.14(\.\d+)?/i.test(out)) {
126
+ return { ok: true, path: c.cmd, version: out };
127
+ }
128
+ }
129
+ catch { }
130
+ }
131
+ return { ok: false };
132
+ }
110
133
  const buildAll = async (isDev = true, workspacePath) => {
111
134
  const isJs = await fsExtra.pathExists(path.join(workspacePath, "scripts", "main.js"));
135
+ const isPy = await fsExtra.pathExists(path.join(workspacePath, "scripts", "main.py"));
112
136
  if (isJs) {
113
137
  console.log("🚀 开始构建JavaScript项目...");
114
138
  const obfuscatorConfigPath = path.join(workspacePath, "obfuscator.json");
@@ -156,10 +180,22 @@ const buildAll = async (isDev = true, workspacePath) => {
156
180
  if (isDev) {
157
181
  return;
158
182
  }
159
- // 打包完成后执行
160
- await fsExtra.copy(path.join(workspacePath, "res"), path.join(workspacePath, "msbundle", "res"));
161
- await fsExtra.copy(path.join(workspacePath, "ui"), path.join(workspacePath, "msbundle", "ui"));
162
183
  const outPath = path.join(workspacePath, "msbundle");
184
+ await fsExtra.ensureDir(outPath);
185
+ if (isPy) {
186
+ await fsExtra.copy(path.join(workspacePath, "scripts"), path.join(outPath, "scripts"));
187
+ // 获取系统有没有 3.14 版本的 python
188
+ const py = detectPython314();
189
+ if (py.ok) {
190
+ console.log(`✅ 检测到 ${py.version} (${py.path})`);
191
+ }
192
+ else {
193
+ console.warn("⚠️ 未检测到 Python 3.14,请确保在目标运行环境安装 Python 3.14");
194
+ }
195
+ }
196
+ // 打包完成后执行
197
+ await fsExtra.copy(path.join(workspacePath, "res"), path.join(outPath, "res"));
198
+ await fsExtra.copy(path.join(workspacePath, "ui"), path.join(outPath, "ui"));
163
199
  const distPath = path.join(workspacePath, "dist");
164
200
  const src = path.join(workspacePath, "package.json");
165
201
  const dest = path.join(outPath, "package.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -21,13 +21,13 @@
21
21
  "dependencies": {
22
22
  "commander": "^14.0.2",
23
23
  "fs-extra": "^11.3.2",
24
- "vite": "^7.2.2",
24
+ "vite": "^7.2.4",
25
25
  "vite-plugin-bundle-obfuscator": "^1.8.0",
26
- "zip-a-folder": "^3.1.9"
26
+ "zip-a-folder": "^4.0.4"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/fs-extra": "^11.0.4",
30
- "@types/node": "^24.10.0",
30
+ "@types/node": "^24.10.1",
31
31
  "typescript": "~5.9.3"
32
32
  }
33
33
  }