1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.CopyElevateHelper = exports.AppPackageHelper = exports.NSIS_PATH = exports.nsisTemplatesDir = void 0;
|
7 |
|
8 | function _bluebirdLst() {
|
9 | const data = _interopRequireWildcard(require("bluebird-lst"));
|
10 |
|
11 | _bluebirdLst = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 | function _builderUtil() {
|
19 | const data = require("builder-util");
|
20 |
|
21 | _builderUtil = function () {
|
22 | return data;
|
23 | };
|
24 |
|
25 | return data;
|
26 | }
|
27 |
|
28 | function _binDownload() {
|
29 | const data = require("builder-util/out/binDownload");
|
30 |
|
31 | _binDownload = function () {
|
32 | return data;
|
33 | };
|
34 |
|
35 | return data;
|
36 | }
|
37 |
|
38 | function _fs() {
|
39 | const data = require("builder-util/out/fs");
|
40 |
|
41 | _fs = function () {
|
42 | return data;
|
43 | };
|
44 |
|
45 | return data;
|
46 | }
|
47 |
|
48 | function _fsExtraP() {
|
49 | const data = require("fs-extra-p");
|
50 |
|
51 | _fsExtraP = function () {
|
52 | return data;
|
53 | };
|
54 |
|
55 | return data;
|
56 | }
|
57 |
|
58 | function _lazyVal() {
|
59 | const data = require("lazy-val");
|
60 |
|
61 | _lazyVal = function () {
|
62 | return data;
|
63 | };
|
64 |
|
65 | return data;
|
66 | }
|
67 |
|
68 | var path = _interopRequireWildcard(require("path"));
|
69 |
|
70 | function _pathManager() {
|
71 | const data = require("../../util/pathManager");
|
72 |
|
73 | _pathManager = function () {
|
74 | return data;
|
75 | };
|
76 |
|
77 | return data;
|
78 | }
|
79 |
|
80 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
81 |
|
82 | const nsisTemplatesDir = (0, _pathManager().getTemplatePath)("nsis");
|
83 | exports.nsisTemplatesDir = nsisTemplatesDir;
|
84 | const NSIS_PATH = new (_lazyVal().Lazy)(() => {
|
85 | const custom = process.env.ELECTRON_BUILDER_NSIS_DIR;
|
86 |
|
87 | if (custom != null && custom.length > 0) {
|
88 | return Promise.resolve(custom.trim());
|
89 | }
|
90 |
|
91 |
|
92 | return (0, _binDownload().getBinFromGithub)("nsis", "3.0.3.1", "rYRTO0OqNStw1uFP1RJ4aCGyK+GCz4AIy4uSO3g/sPmuONYDPhp8B0Q6xUx4aTb8hLaFeWyvo7tsp++9nrMoSw==");
|
93 | });
|
94 | exports.NSIS_PATH = NSIS_PATH;
|
95 |
|
96 | class AppPackageHelper {
|
97 | constructor(elevateHelper) {
|
98 | this.elevateHelper = elevateHelper;
|
99 | this.archToFileInfo = new Map();
|
100 | this.infoToIsDelete = new Map();
|
101 |
|
102 |
|
103 | this.refCount = 0;
|
104 | }
|
105 |
|
106 | packArch(arch, target) {
|
107 | var _this = this;
|
108 |
|
109 | return (0, _bluebirdLst().coroutine)(function* () {
|
110 | let infoPromise = _this.archToFileInfo.get(arch);
|
111 |
|
112 | if (infoPromise == null) {
|
113 | const appOutDir = target.archs.get(arch);
|
114 | infoPromise = _this.elevateHelper.copy(appOutDir, target).then(() => target.buildAppPackage(appOutDir, arch));
|
115 |
|
116 | _this.archToFileInfo.set(arch, infoPromise);
|
117 | }
|
118 |
|
119 | const info = yield infoPromise;
|
120 |
|
121 | if (target.isWebInstaller) {
|
122 | _this.infoToIsDelete.set(info, false);
|
123 | } else if (!_this.infoToIsDelete.has(info)) {
|
124 | _this.infoToIsDelete.set(info, true);
|
125 | }
|
126 |
|
127 | return info;
|
128 | })();
|
129 | }
|
130 |
|
131 | finishBuild() {
|
132 | var _this2 = this;
|
133 |
|
134 | return (0, _bluebirdLst().coroutine)(function* () {
|
135 | if (--_this2.refCount > 0) {
|
136 | return;
|
137 | }
|
138 |
|
139 | const filesToDelete = [];
|
140 |
|
141 | for (const [info, isDelete] of _this2.infoToIsDelete.entries()) {
|
142 | if (isDelete) {
|
143 | filesToDelete.push(info.path);
|
144 | }
|
145 | }
|
146 |
|
147 | yield _bluebirdLst().default.map(filesToDelete, it => (0, _fsExtraP().unlink)(it));
|
148 | })();
|
149 | }
|
150 |
|
151 | }
|
152 |
|
153 | exports.AppPackageHelper = AppPackageHelper;
|
154 |
|
155 | class CopyElevateHelper {
|
156 | constructor() {
|
157 | this.copied = new Map();
|
158 | }
|
159 |
|
160 | copy(appOutDir, target) {
|
161 | let isPackElevateHelper = target.options.packElevateHelper;
|
162 |
|
163 | if (isPackElevateHelper === false && target.options.perMachine === true) {
|
164 | isPackElevateHelper = true;
|
165 |
|
166 | _builderUtil().log.warn("`packElevateHelper = false` is ignored, because `perMachine` is set to `true`");
|
167 | }
|
168 |
|
169 | if (isPackElevateHelper === false) {
|
170 | return Promise.resolve();
|
171 | }
|
172 |
|
173 | let promise = this.copied.get(appOutDir);
|
174 |
|
175 | if (promise != null) {
|
176 | return promise;
|
177 | }
|
178 |
|
179 | promise = NSIS_PATH.value.then(it => {
|
180 | const outFile = path.join(appOutDir, "resources", "elevate.exe");
|
181 | const promise = (0, _fs().copyFile)(path.join(it, "elevate.exe"), outFile, false);
|
182 |
|
183 | if (target.packager.platformSpecificBuildOptions.signAndEditExecutable !== false) {
|
184 | return promise.then(() => target.packager.sign(outFile));
|
185 | }
|
186 |
|
187 | return promise;
|
188 | });
|
189 | this.copied.set(appOutDir, promise);
|
190 | return promise;
|
191 | }
|
192 |
|
193 | } exports.CopyElevateHelper = CopyElevateHelper;
|
194 |
|
\ | No newline at end of file |