1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const builder_util_1 = require("builder-util");
|
4 | const builder_util_runtime_1 = require("builder-util-runtime");
|
5 | const path = require("path");
|
6 | const MsiTarget_1 = require("./MsiTarget");
|
7 | const ELECTRON_MSI_WRAPPED_NS_UUID = builder_util_runtime_1.UUID.parse("467f7bb2-a83c-442f-b776-394d316e8e53");
|
8 | class MsiWrappedTarget extends MsiTarget_1.default {
|
9 | constructor(packager, outDir) {
|
10 |
|
11 | super(packager, outDir, "msiWrapped", false);
|
12 | this.outDir = outDir;
|
13 | this.options = (0, builder_util_1.deepAssign)(this.packager.platformSpecificBuildOptions, this.packager.config.msiWrapped);
|
14 |
|
15 | this.archs = new Map();
|
16 | }
|
17 | get productId() {
|
18 |
|
19 |
|
20 |
|
21 | return builder_util_runtime_1.UUID.v5(this.packager.appInfo.id, ELECTRON_MSI_WRAPPED_NS_UUID).toUpperCase();
|
22 | }
|
23 | validatePrerequisites() {
|
24 | const config = this.packager.config;
|
25 |
|
26 |
|
27 | if (!config.win || !config.win.target || !Array.isArray(config.win.target)) {
|
28 | throw new Error("No windows target found!");
|
29 | }
|
30 | const target = config.win.target;
|
31 | const nsisTarget = "nsis";
|
32 | if (!target
|
33 | .map((t) => {
|
34 | const result = typeof t === "string" ? t : t.target;
|
35 | return result.toLowerCase().trim();
|
36 | })
|
37 | .some(t => t === nsisTarget)) {
|
38 | throw new Error("No nsis target found! Please specify an nsis target");
|
39 | }
|
40 | }
|
41 | build(appOutDir, arch) {
|
42 | this.archs.set(arch, appOutDir);
|
43 | return Promise.resolve();
|
44 | }
|
45 | finishBuild() {
|
46 |
|
47 |
|
48 |
|
49 | const [arch, appOutDir] = this.archs.entries().next().value;
|
50 | this.validatePrerequisites();
|
51 | return super.build(appOutDir, arch);
|
52 | }
|
53 | get installerFilenamePattern() {
|
54 |
|
55 |
|
56 | return "${productName} Setup ${version}.${ext}";
|
57 | }
|
58 | getExeSourcePath(arch) {
|
59 | const packager = this.packager;
|
60 |
|
61 | const artifactName = packager.expandArtifactNamePattern(this.options, "exe", arch, this.installerFilenamePattern, false, this.packager.platformSpecificBuildOptions.defaultArch);
|
62 | const artifactPath = path.join(this.outDir, artifactName);
|
63 | return artifactPath;
|
64 | }
|
65 | async writeManifest(_appOutDir, arch, commonOptions) {
|
66 | const exeSourcePath = this.getExeSourcePath(arch);
|
67 | const options = this.options;
|
68 | return (await this.projectTemplate.value)({
|
69 | ...(await this.getBaseOptions(commonOptions)),
|
70 | exeSourcePath: exeSourcePath,
|
71 | productId: this.productId,
|
72 | impersonate: options.impersonate === true ? "yes" : "no",
|
73 | wrappedInstallerArgs: options.wrappedInstallerArgs,
|
74 | });
|
75 | }
|
76 | }
|
77 | exports.default = MsiWrappedTarget;
|
78 |
|
\ | No newline at end of file |