diff --git a/electron-builder.config.mjs b/electron-builder.config.mjs index da35036..1f8e328 100644 --- a/electron-builder.config.mjs +++ b/electron-builder.config.mjs @@ -20,6 +20,10 @@ export default { "out/**/*", "package.json" ], + extraResources: [ + { from: path.join(root, "resources", "catalog.json"), to: "catalog.json" }, + { from: path.join(root, "resources", "fixture"), to: "fixture" } + ], asar: true, compression: "maximum", npmRebuild: false, @@ -45,4 +49,4 @@ export default { deleteAppDataOnUninstall: false }, publish: null -}; \ No newline at end of file +}; diff --git a/scripts/package.mjs b/scripts/package.mjs index 2b92d49..6a48e7b 100644 --- a/scripts/package.mjs +++ b/scripts/package.mjs @@ -107,6 +107,15 @@ if (!fs.existsSync(builderSetupPath)) { if (!fs.existsSync(path.join(builderUnpacked, "RPA Studio.exe"))) { 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.copyFileSync(builderSetupPath, setupPath); removeTree(builderWork); @@ -198,6 +207,9 @@ if (installed.status !== 0 || installed.error) { if (!fs.existsSync(path.join(installSmokeTarget, "RPA Studio.exe"))) { 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"); removeTree(installSmokeRoot); @@ -207,4 +219,4 @@ const sums = [ ]; 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)); \ No newline at end of file +console.log(JSON.stringify({ productFolder, zipPath, setupPath, zipSha256, setupSha256 }, null, 2));