fix: 随包分发运行时资源目录

This commit is contained in:
yu committed 2026-10-28 10:06:37 +08:00
1 parent cf05e4aa6f
commit 4fb0f64d4f
2 files changed
+18 -2

No files matched your search

+5 -1
View File
@@ -20,6 +20,10 @@ export default {
"out/**/*", "out/**/*",
"package.json" "package.json"
], ],
extraResources: [
{ from: path.join(root, "resources", "catalog.json"), to: "catalog.json" },
{ from: path.join(root, "resources", "fixture"), to: "fixture" }
],
asar: true, asar: true,
compression: "maximum", compression: "maximum",
npmRebuild: false, npmRebuild: false,
@@ -45,4 +49,4 @@ export default {
deleteAppDataOnUninstall: false deleteAppDataOnUninstall: false
}, },
publish: null publish: null
}; };
+13 -1
View File
@@ -107,6 +107,15 @@ if (!fs.existsSync(builderSetupPath)) {
if (!fs.existsSync(path.join(builderUnpacked, "RPA Studio.exe"))) { if (!fs.existsSync(path.join(builderUnpacked, "RPA Studio.exe"))) {
throw new Error(`electron-builder 未生成应用目录:${builderUnpacked}`); throw new Error(`electron-builder 未生成应用目录:${builderUnpacked}`);
} }
const packagedCatalogPath = path.join(builderUnpacked, "resources", "catalog.json");
const packagedFixturePath = path.join(builderUnpacked, "resources", "fixture", "index.html");
if (!fs.existsSync(packagedCatalogPath) || !fs.existsSync(packagedFixturePath)) {
throw new Error("打包产物缺少运行资源:resources/catalog.json 或 resources/fixture/index.html");
}
const packagedCatalog = JSON.parse(fs.readFileSync(packagedCatalogPath, "utf8"));
if (!Array.isArray(packagedCatalog.components) || packagedCatalog.components.length === 0) {
throw new Error("打包产物 resources/catalog.json 无效:组件目录为空");
}
fs.cpSync(builderUnpacked, productFolder, { recursive: true }); fs.cpSync(builderUnpacked, productFolder, { recursive: true });
fs.copyFileSync(builderSetupPath, setupPath); fs.copyFileSync(builderSetupPath, setupPath);
removeTree(builderWork); removeTree(builderWork);
@@ -198,6 +207,9 @@ if (installed.status !== 0 || installed.error) {
if (!fs.existsSync(path.join(installSmokeTarget, "RPA Studio.exe"))) { if (!fs.existsSync(path.join(installSmokeTarget, "RPA Studio.exe"))) {
throw new Error("NSIS 安装包冒烟失败:未生成主程序"); throw new Error("NSIS 安装包冒烟失败:未生成主程序");
} }
if (!fs.existsSync(path.join(installSmokeTarget, "resources", "catalog.json"))) {
throw new Error("NSIS 安装包冒烟失败:catalog.json 未安装");
}
await verifyLaunch(path.join(installSmokeTarget, "RPA Studio.exe"), "installed"); await verifyLaunch(path.join(installSmokeTarget, "RPA Studio.exe"), "installed");
removeTree(installSmokeRoot); removeTree(installSmokeRoot);
@@ -207,4 +219,4 @@ const sums = [
]; ];
fs.writeFileSync(path.join(releaseRoot, "SHA256SUMS.txt"), `${sums.join("\r\n")}\r\n`, "utf8"); fs.writeFileSync(path.join(releaseRoot, "SHA256SUMS.txt"), `${sums.join("\r\n")}\r\n`, "utf8");
console.log(JSON.stringify({ productFolder, zipPath, setupPath, zipSha256, setupSha256 }, null, 2)); console.log(JSON.stringify({ productFolder, zipPath, setupPath, zipSha256, setupSha256 }, null, 2));