ms-vite-plugin 0.2.6 → 0.2.8
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/dist/build.js +16 -4
- package/dist/cli.js +2 -5
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -109,9 +109,17 @@ function prodReturnMain() {
|
|
|
109
109
|
}
|
|
110
110
|
const buildAll = async (isDev = true, workspacePath) => {
|
|
111
111
|
const isJs = await fsExtra.pathExists(path.join(workspacePath, "scripts", "main.js"));
|
|
112
|
+
const isPy = await fsExtra.pathExists(path.join(workspacePath, "scripts", "main.py"));
|
|
112
113
|
if (isJs) {
|
|
113
114
|
console.log("🚀 开始构建JavaScript项目...");
|
|
114
|
-
const
|
|
115
|
+
const obfuscatorConfigPath = path.join(workspacePath, "obfuscator.json");
|
|
116
|
+
if (!(await fsExtra.pathExists(obfuscatorConfigPath))) {
|
|
117
|
+
console.error("❌ 错误: 当前目录不是有效的 快点JS 项目");
|
|
118
|
+
console.error("请确保目录包含以下文件:");
|
|
119
|
+
console.error(" - obfuscator.json");
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
const obfuscatorConfig = await fsExtra.readJSON(obfuscatorConfigPath);
|
|
115
123
|
const outputDir = path.join(workspacePath, isDev ? "dist" : "msbundle");
|
|
116
124
|
const baseDir = path.join(workspacePath, "scripts");
|
|
117
125
|
const entryFiles = await findEntryFiles(baseDir, baseDir);
|
|
@@ -149,10 +157,14 @@ const buildAll = async (isDev = true, workspacePath) => {
|
|
|
149
157
|
if (isDev) {
|
|
150
158
|
return;
|
|
151
159
|
}
|
|
152
|
-
// 打包完成后执行
|
|
153
|
-
await fsExtra.copy(path.join(workspacePath, "res"), path.join(workspacePath, "msbundle", "res"));
|
|
154
|
-
await fsExtra.copy(path.join(workspacePath, "ui"), path.join(workspacePath, "msbundle", "ui"));
|
|
155
160
|
const outPath = path.join(workspacePath, "msbundle");
|
|
161
|
+
await fsExtra.ensureDir(outPath);
|
|
162
|
+
if (isPy) {
|
|
163
|
+
await fsExtra.copy(path.join(workspacePath, "scripts"), path.join(outPath, "scripts"));
|
|
164
|
+
}
|
|
165
|
+
// 打包完成后执行
|
|
166
|
+
await fsExtra.copy(path.join(workspacePath, "res"), path.join(outPath, "res"));
|
|
167
|
+
await fsExtra.copy(path.join(workspacePath, "ui"), path.join(outPath, "ui"));
|
|
156
168
|
const distPath = path.join(workspacePath, "dist");
|
|
157
169
|
const src = path.join(workspacePath, "package.json");
|
|
158
170
|
const dest = path.join(outPath, "package.json");
|
package/dist/cli.js
CHANGED
|
@@ -47,13 +47,11 @@ async function isValidKuaiJSProject(workspacePath) {
|
|
|
47
47
|
try {
|
|
48
48
|
const packageJsonPath = path.join(workspacePath, "package.json");
|
|
49
49
|
const scriptsPath = path.join(workspacePath, "scripts");
|
|
50
|
-
const
|
|
51
|
-
const [packageExists, scriptsExists, obfuscatorExists] = await Promise.all([
|
|
50
|
+
const [packageExists, scriptsExists] = await Promise.all([
|
|
52
51
|
fsExtra.pathExists(packageJsonPath),
|
|
53
52
|
fsExtra.pathExists(scriptsPath),
|
|
54
|
-
fsExtra.pathExists(obfuscatorPath),
|
|
55
53
|
]);
|
|
56
|
-
return packageExists && scriptsExists
|
|
54
|
+
return packageExists && scriptsExists;
|
|
57
55
|
}
|
|
58
56
|
catch {
|
|
59
57
|
return false;
|
|
@@ -75,7 +73,6 @@ async function buildCommand(options) {
|
|
|
75
73
|
console.error("请确保目录包含以下文件:");
|
|
76
74
|
console.error(" - package.json");
|
|
77
75
|
console.error(" - scripts/ 目录");
|
|
78
|
-
console.error(" - obfuscator.json");
|
|
79
76
|
process.exit(1);
|
|
80
77
|
}
|
|
81
78
|
console.log(`🚀 开始构建项目 (${isDev ? "开发模式" : "生产模式"})...`);
|