1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.Packager = 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 _builderUtilRuntime() {
|
29 | const data = require("builder-util-runtime");
|
30 |
|
31 | _builderUtilRuntime = 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 _promise() {
|
49 | const data = require("builder-util/out/promise");
|
50 |
|
51 | _promise = function () {
|
52 | return data;
|
53 | };
|
54 |
|
55 | return data;
|
56 | }
|
57 |
|
58 | function _events() {
|
59 | const data = require("events");
|
60 |
|
61 | _events = function () {
|
62 | return data;
|
63 | };
|
64 |
|
65 | return data;
|
66 | }
|
67 |
|
68 | function _fsExtraP() {
|
69 | const data = require("fs-extra-p");
|
70 |
|
71 | _fsExtraP = function () {
|
72 | return data;
|
73 | };
|
74 |
|
75 | return data;
|
76 | }
|
77 |
|
78 | function _isCi() {
|
79 | const data = _interopRequireDefault(require("is-ci"));
|
80 |
|
81 | _isCi = function () {
|
82 | return data;
|
83 | };
|
84 |
|
85 | return data;
|
86 | }
|
87 |
|
88 | function _lazyVal() {
|
89 | const data = require("lazy-val");
|
90 |
|
91 | _lazyVal = function () {
|
92 | return data;
|
93 | };
|
94 |
|
95 | return data;
|
96 | }
|
97 |
|
98 | var path = _interopRequireWildcard(require("path"));
|
99 |
|
100 | function _appInfo() {
|
101 | const data = require("./appInfo");
|
102 |
|
103 | _appInfo = function () {
|
104 | return data;
|
105 | };
|
106 |
|
107 | return data;
|
108 | }
|
109 |
|
110 | function _asar() {
|
111 | const data = require("./asar/asar");
|
112 |
|
113 | _asar = function () {
|
114 | return data;
|
115 | };
|
116 |
|
117 | return data;
|
118 | }
|
119 |
|
120 | function _ElectronFramework() {
|
121 | const data = require("./electron/ElectronFramework");
|
122 |
|
123 | _ElectronFramework = function () {
|
124 | return data;
|
125 | };
|
126 |
|
127 | return data;
|
128 | }
|
129 |
|
130 | function _index() {
|
131 | const data = require("./index");
|
132 |
|
133 | _index = function () {
|
134 | return data;
|
135 | };
|
136 |
|
137 | return data;
|
138 | }
|
139 |
|
140 | function _platformPackager() {
|
141 | const data = require("./platformPackager");
|
142 |
|
143 | _platformPackager = function () {
|
144 | return data;
|
145 | };
|
146 |
|
147 | return data;
|
148 | }
|
149 |
|
150 | function _ProtonFramework() {
|
151 | const data = require("./ProtonFramework");
|
152 |
|
153 | _ProtonFramework = function () {
|
154 | return data;
|
155 | };
|
156 |
|
157 | return data;
|
158 | }
|
159 |
|
160 | function _targetFactory() {
|
161 | const data = require("./targets/targetFactory");
|
162 |
|
163 | _targetFactory = function () {
|
164 | return data;
|
165 | };
|
166 |
|
167 | return data;
|
168 | }
|
169 |
|
170 | function _config() {
|
171 | const data = require("./util/config");
|
172 |
|
173 | _config = function () {
|
174 | return data;
|
175 | };
|
176 |
|
177 | return data;
|
178 | }
|
179 |
|
180 | function _macroExpander() {
|
181 | const data = require("./util/macroExpander");
|
182 |
|
183 | _macroExpander = function () {
|
184 | return data;
|
185 | };
|
186 |
|
187 | return data;
|
188 | }
|
189 |
|
190 | function _packageDependencies() {
|
191 | const data = require("./util/packageDependencies");
|
192 |
|
193 | _packageDependencies = function () {
|
194 | return data;
|
195 | };
|
196 |
|
197 | return data;
|
198 | }
|
199 |
|
200 | function _packageMetadata() {
|
201 | const data = require("./util/packageMetadata");
|
202 |
|
203 | _packageMetadata = function () {
|
204 | return data;
|
205 | };
|
206 |
|
207 | return data;
|
208 | }
|
209 |
|
210 | function _repositoryInfo() {
|
211 | const data = require("./util/repositoryInfo");
|
212 |
|
213 | _repositoryInfo = function () {
|
214 | return data;
|
215 | };
|
216 |
|
217 | return data;
|
218 | }
|
219 |
|
220 | function _yarn() {
|
221 | const data = require("./util/yarn");
|
222 |
|
223 | _yarn = function () {
|
224 | return data;
|
225 | };
|
226 |
|
227 | return data;
|
228 | }
|
229 |
|
230 | let createFrameworkInfo = (() => {
|
231 | var _ref = (0, _bluebirdLst().coroutine)(function* (configuration, packager) {
|
232 | if (configuration.protonNodeVersion != null) {
|
233 |
|
234 | return (0, _ProtonFramework().createProtonFrameworkSupport)(configuration.protonNodeVersion, packager.appInfo);
|
235 | } else {
|
236 | return yield (0, _ElectronFramework().createElectronFrameworkSupport)(configuration, packager);
|
237 | }
|
238 | });
|
239 |
|
240 | return function createFrameworkInfo(_x, _x2) {
|
241 | return _ref.apply(this, arguments);
|
242 | };
|
243 | })();
|
244 |
|
245 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
246 |
|
247 | 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; } }
|
248 |
|
249 | function addHandler(emitter, event, handler) {
|
250 | emitter.on(event, handler);
|
251 | }
|
252 |
|
253 | class Packager {
|
254 |
|
255 | constructor(options, cancellationToken = new (_builderUtilRuntime().CancellationToken)()) {
|
256 | this.cancellationToken = cancellationToken;
|
257 | this._metadata = null;
|
258 | this._nodeModulesHandledExternally = false;
|
259 | this._isPrepackedAppAsar = false;
|
260 | this._devMetadata = null;
|
261 | this._configuration = null;
|
262 | this.isTwoPackageJsonProjectLayoutUsed = false;
|
263 | this.eventEmitter = new (_events().EventEmitter)();
|
264 | this._appInfo = null;
|
265 | this.tempDirManager = new (_builderUtil().TmpDir)("packager");
|
266 | this._repositoryInfo = new (_lazyVal().Lazy)(() => (0, _repositoryInfo().getRepositoryInfo)(this.projectDir, this.metadata, this.devMetadata));
|
267 | this.afterPackHandlers = [];
|
268 | this.debugLogger = new (_builderUtil().DebugLogger)(_builderUtil().log.isDebugEnabled);
|
269 | this._productionDeps = null;
|
270 |
|
271 | this.stageDirPathCustomizer = (target, packager, arch) => {
|
272 | return path.join(target.outDir, `__${target.name}-${_builderUtil().Arch[arch]}`);
|
273 | };
|
274 |
|
275 | this._buildResourcesDir = null;
|
276 | this._framework = null;
|
277 |
|
278 | if ("devMetadata" in options) {
|
279 | throw new (_builderUtil().InvalidConfigurationError)("devMetadata in the options is deprecated, please use config instead");
|
280 | }
|
281 |
|
282 | if ("extraMetadata" in options) {
|
283 | throw new (_builderUtil().InvalidConfigurationError)("extraMetadata in the options is deprecated, please use config.extraMetadata instead");
|
284 | }
|
285 |
|
286 | const targets = options.targets || new Map();
|
287 |
|
288 | if (options.targets == null) {
|
289 | options.targets = targets;
|
290 | }
|
291 |
|
292 | function processTargets(platform, types) {
|
293 | function commonArch(currentIfNotSpecified) {
|
294 | if (platform === _index().Platform.MAC) {
|
295 | return currentIfNotSpecified ? [_builderUtil().Arch.x64] : [];
|
296 | }
|
297 |
|
298 | const result = Array();
|
299 | return result.length === 0 && currentIfNotSpecified ? [(0, _builderUtil().archFromString)(process.arch)] : result;
|
300 | }
|
301 |
|
302 | let archToType = targets.get(platform);
|
303 |
|
304 | if (archToType == null) {
|
305 | archToType = new Map();
|
306 | targets.set(platform, archToType);
|
307 | }
|
308 |
|
309 | if (types.length === 0) {
|
310 | for (const arch of commonArch(false)) {
|
311 | archToType.set(arch, []);
|
312 | }
|
313 |
|
314 | return;
|
315 | }
|
316 |
|
317 | for (const type of types) {
|
318 | const suffixPos = type.lastIndexOf(":");
|
319 |
|
320 | if (suffixPos > 0) {
|
321 | (0, _builderUtil().addValue)(archToType, (0, _builderUtil().archFromString)(type.substring(suffixPos + 1)), type.substring(0, suffixPos));
|
322 | } else {
|
323 | for (const arch of commonArch(true)) {
|
324 | (0, _builderUtil().addValue)(archToType, arch, type);
|
325 | }
|
326 | }
|
327 | }
|
328 | }
|
329 |
|
330 | if (options.mac != null) {
|
331 | processTargets(_index().Platform.MAC, options.mac);
|
332 | }
|
333 |
|
334 | if (options.linux != null) {
|
335 | processTargets(_index().Platform.LINUX, options.linux);
|
336 | }
|
337 |
|
338 | if (options.win != null) {
|
339 | processTargets(_index().Platform.WINDOWS, options.win);
|
340 | }
|
341 |
|
342 | this.projectDir = options.projectDir == null ? process.cwd() : path.resolve(options.projectDir);
|
343 | this._appDir = this.projectDir;
|
344 | this.options = Object.assign({}, options, {
|
345 | prepackaged: options.prepackaged == null ? null : path.resolve(this.projectDir, options.prepackaged)
|
346 | });
|
347 |
|
348 | try {
|
349 | _builderUtil().log.info({
|
350 | version: "20.23.1"
|
351 | }, "electron-builder");
|
352 | } catch (e) {
|
353 |
|
354 | if (!(e instanceof ReferenceError)) {
|
355 | throw e;
|
356 | }
|
357 | }
|
358 | }
|
359 |
|
360 | get appDir() {
|
361 | return this._appDir;
|
362 | }
|
363 |
|
364 | get metadata() {
|
365 | return this._metadata;
|
366 | }
|
367 |
|
368 | get areNodeModulesHandledExternally() {
|
369 | return this._nodeModulesHandledExternally;
|
370 | }
|
371 |
|
372 | get isPrepackedAppAsar() {
|
373 | return this._isPrepackedAppAsar;
|
374 | }
|
375 |
|
376 | get devMetadata() {
|
377 | return this._devMetadata;
|
378 | }
|
379 |
|
380 | get config() {
|
381 | return this._configuration;
|
382 | }
|
383 |
|
384 | get appInfo() {
|
385 | return this._appInfo;
|
386 | }
|
387 |
|
388 | get repositoryInfo() {
|
389 | return this._repositoryInfo.value;
|
390 | }
|
391 |
|
392 | get productionDeps() {
|
393 | var _this = this;
|
394 |
|
395 | let result = this._productionDeps;
|
396 |
|
397 | if (result == null) {
|
398 |
|
399 | result = new (_lazyVal().Lazy)((0, _bluebirdLst().coroutine)(function* () {
|
400 | if (_this.config.beforeBuild == null || (yield (0, _fs().exists)(path.join(_this.appDir, "node_modules")))) {
|
401 | return yield (0, _packageDependencies().getProductionDependencies)(_this.appDir);
|
402 | } else {
|
403 | return [];
|
404 | }
|
405 | }));
|
406 | this._productionDeps = result;
|
407 | }
|
408 |
|
409 | return result;
|
410 | }
|
411 |
|
412 | get buildResourcesDir() {
|
413 | let result = this._buildResourcesDir;
|
414 |
|
415 | if (result == null) {
|
416 | result = path.resolve(this.projectDir, this.relativeBuildResourcesDirname);
|
417 | this._buildResourcesDir = result;
|
418 | }
|
419 |
|
420 | return result;
|
421 | }
|
422 |
|
423 | get relativeBuildResourcesDirname() {
|
424 | return this.config.directories.buildResources;
|
425 | }
|
426 |
|
427 | get framework() {
|
428 | return this._framework;
|
429 | }
|
430 |
|
431 | addAfterPackHandler(handler) {
|
432 | this.afterPackHandlers.push(handler);
|
433 | }
|
434 |
|
435 | artifactCreated(handler) {
|
436 | addHandler(this.eventEmitter, "artifactCreated", handler);
|
437 | return this;
|
438 | }
|
439 |
|
440 | dispatchArtifactCreated(event) {
|
441 | this.eventEmitter.emit("artifactCreated", event);
|
442 | }
|
443 |
|
444 | build() {
|
445 | var _this2 = this;
|
446 |
|
447 | return (0, _bluebirdLst().coroutine)(function* () {
|
448 | let configPath = null;
|
449 | let configFromOptions = _this2.options.config;
|
450 |
|
451 | if (typeof configFromOptions === "string") {
|
452 |
|
453 | configPath = configFromOptions;
|
454 | configFromOptions = null;
|
455 | } else if (configFromOptions != null && configFromOptions.extends != null && configFromOptions.extends.includes(".")) {
|
456 | configPath = configFromOptions.extends;
|
457 | delete configFromOptions.extends;
|
458 | }
|
459 |
|
460 | const projectDir = _this2.projectDir;
|
461 | const devPackageFile = path.join(projectDir, "package.json");
|
462 | _this2._devMetadata = yield (0, _promise().orNullIfFileNotExist)((0, _packageMetadata().readPackageJson)(devPackageFile));
|
463 | const devMetadata = _this2.devMetadata;
|
464 | const configuration = yield (0, _config().getConfig)(projectDir, configPath, configFromOptions, new (_lazyVal().Lazy)(() => Promise.resolve(devMetadata)));
|
465 |
|
466 | if (_builderUtil().log.isDebugEnabled) {
|
467 | _builderUtil().log.debug({
|
468 | config: getSafeEffectiveConfig(configuration)
|
469 | }, "effective config");
|
470 | }
|
471 |
|
472 | _this2._appDir = yield (0, _config().computeDefaultAppDirectory)(projectDir, configuration.directories.app);
|
473 | _this2.isTwoPackageJsonProjectLayoutUsed = _this2._appDir !== projectDir;
|
474 | const appPackageFile = _this2.isTwoPackageJsonProjectLayoutUsed ? path.join(_this2.appDir, "package.json") : devPackageFile;
|
475 |
|
476 | if (_this2.devMetadata != null && !_this2.isTwoPackageJsonProjectLayoutUsed) {
|
477 | _this2._metadata = _this2.devMetadata;
|
478 | } else {
|
479 | _this2._metadata = yield _this2.readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile);
|
480 | }
|
481 |
|
482 | (0, _builderUtil().deepAssign)(_this2.metadata, configuration.extraMetadata);
|
483 |
|
484 | if (_this2.isTwoPackageJsonProjectLayoutUsed) {
|
485 | _builderUtil().log.debug({
|
486 | devPackageFile,
|
487 | appPackageFile
|
488 | }, "two package.json structure is used");
|
489 | }
|
490 |
|
491 | (0, _packageMetadata().checkMetadata)(_this2.metadata, _this2.devMetadata, appPackageFile, devPackageFile);
|
492 | return yield _this2._build(configuration, _this2._metadata, _this2._devMetadata);
|
493 | })();
|
494 | }
|
495 |
|
496 |
|
497 | _build(configuration, metadata, devMetadata, repositoryInfo) {
|
498 | var _this3 = this;
|
499 |
|
500 | return (0, _bluebirdLst().coroutine)(function* () {
|
501 | yield (0, _config().validateConfig)(configuration, _this3.debugLogger);
|
502 | _this3._configuration = configuration;
|
503 | _this3._metadata = metadata;
|
504 | _this3._devMetadata = devMetadata;
|
505 |
|
506 | if (repositoryInfo != null) {
|
507 | _this3._repositoryInfo.value = Promise.resolve(repositoryInfo);
|
508 | }
|
509 |
|
510 | _this3._appInfo = new (_appInfo().AppInfo)(_this3);
|
511 | _this3._framework = yield createFrameworkInfo(_this3.config, _this3);
|
512 | const outDir = path.resolve(_this3.projectDir, (0, _macroExpander().expandMacro)(configuration.directories.output, null, _this3._appInfo));
|
513 |
|
514 | if (!_isCi().default && process.stdout.isTTY) {
|
515 | const effectiveConfigFile = path.join(outDir, "builder-effective-config.yaml");
|
516 |
|
517 | _builderUtil().log.info({
|
518 | file: _builderUtil().log.filePath(effectiveConfigFile)
|
519 | }, "writing effective config");
|
520 |
|
521 | yield (0, _fsExtraP().outputFile)(effectiveConfigFile, getSafeEffectiveConfig(configuration));
|
522 | }
|
523 |
|
524 |
|
525 | const artifactPaths = new Set();
|
526 |
|
527 | _this3.artifactCreated(event => {
|
528 | if (event.file != null) {
|
529 | artifactPaths.add(event.file);
|
530 | }
|
531 | });
|
532 |
|
533 | const platformToTargets = yield (0, _promise().executeFinally)(_this3.doBuild(outDir), (0, _bluebirdLst().coroutine)(function* () {
|
534 | if (_this3.debugLogger.isEnabled) {
|
535 | yield _this3.debugLogger.save(path.join(outDir, "builder-debug.yml"));
|
536 | }
|
537 |
|
538 | yield _this3.tempDirManager.cleanup();
|
539 | }));
|
540 | return {
|
541 | outDir,
|
542 | artifactPaths: Array.from(artifactPaths),
|
543 | platformToTargets,
|
544 | configuration
|
545 | };
|
546 | })();
|
547 | }
|
548 |
|
549 | readProjectMetadataIfTwoPackageStructureOrPrepacked(appPackageFile) {
|
550 | var _this4 = this;
|
551 |
|
552 | return (0, _bluebirdLst().coroutine)(function* () {
|
553 | let data = yield (0, _promise().orNullIfFileNotExist)((0, _packageMetadata().readPackageJson)(appPackageFile));
|
554 |
|
555 | if (data != null) {
|
556 | return data;
|
557 | }
|
558 |
|
559 | data = yield (0, _promise().orNullIfFileNotExist)((0, _asar().readAsarJson)(path.join(_this4.projectDir, "app.asar"), "package.json"));
|
560 |
|
561 | if (data != null) {
|
562 | _this4._isPrepackedAppAsar = true;
|
563 | return data;
|
564 | }
|
565 |
|
566 | throw new Error(`Cannot find package.json in the ${path.dirname(appPackageFile)}`);
|
567 | })();
|
568 | }
|
569 |
|
570 | doBuild(outDir) {
|
571 | var _this5 = this;
|
572 |
|
573 | return (0, _bluebirdLst().coroutine)(function* () {
|
574 | const taskManager = new (_builderUtil().AsyncTaskManager)(_this5.cancellationToken);
|
575 | const platformToTarget = new Map();
|
576 | const createdOutDirs = new Set();
|
577 |
|
578 | for (const [platform, archToType] of _this5.options.targets) {
|
579 | if (_this5.cancellationToken.cancelled) {
|
580 | break;
|
581 | }
|
582 |
|
583 | if (platform === _index().Platform.MAC && process.platform === _index().Platform.WINDOWS.nodeName) {
|
584 | throw new (_builderUtil().InvalidConfigurationError)("Build for macOS is supported only on macOS, please see https://electron.build/multi-platform-build");
|
585 | }
|
586 |
|
587 | const packager = _this5.createHelper(platform);
|
588 |
|
589 | const nameToTarget = new Map();
|
590 | platformToTarget.set(platform, nameToTarget);
|
591 |
|
592 | for (const [arch, targetNames] of (0, _targetFactory().computeArchToTargetNamesMap)(archToType, packager.platformSpecificBuildOptions, platform)) {
|
593 | if (_this5.cancellationToken.cancelled) {
|
594 | break;
|
595 | }
|
596 |
|
597 | yield _this5.installAppDependencies(platform, arch);
|
598 |
|
599 | if (_this5.cancellationToken.cancelled) {
|
600 | break;
|
601 | }
|
602 |
|
603 | const targetList = (0, _targetFactory().createTargets)(nameToTarget, targetNames.length === 0 ? packager.defaultTarget : targetNames, outDir, packager);
|
604 | yield createOutDirIfNeed(targetList, createdOutDirs);
|
605 | yield packager.pack(outDir, arch, targetList, taskManager);
|
606 | }
|
607 |
|
608 | if (_this5.cancellationToken.cancelled) {
|
609 | break;
|
610 | }
|
611 |
|
612 | for (const target of nameToTarget.values()) {
|
613 | taskManager.addTask(target.finishBuild());
|
614 | }
|
615 | }
|
616 |
|
617 | yield taskManager.awaitTasks();
|
618 | return platformToTarget;
|
619 | })();
|
620 | }
|
621 |
|
622 | createHelper(platform) {
|
623 | if (this.options.platformPackagerFactory != null) {
|
624 | return this.options.platformPackagerFactory(this, platform);
|
625 | }
|
626 |
|
627 | switch (platform) {
|
628 | case _index().Platform.MAC:
|
629 | {
|
630 | const helperClass = require("./macPackager").default;
|
631 |
|
632 | return new helperClass(this);
|
633 | }
|
634 |
|
635 | case _index().Platform.WINDOWS:
|
636 | {
|
637 | const helperClass = require("./winPackager").WinPackager;
|
638 |
|
639 | return new helperClass(this);
|
640 | }
|
641 |
|
642 | case _index().Platform.LINUX:
|
643 | return new (require("./linuxPackager").LinuxPackager)(this);
|
644 |
|
645 | default:
|
646 | throw new Error(`Unknown platform: ${platform}`);
|
647 | }
|
648 | }
|
649 |
|
650 | installAppDependencies(platform, arch) {
|
651 | var _this6 = this;
|
652 |
|
653 | return (0, _bluebirdLst().coroutine)(function* () {
|
654 | if (_this6.options.prepackaged != null || _this6.framework.isNpmRebuildRequired !== true) {
|
655 | return;
|
656 | }
|
657 |
|
658 | const frameworkInfo = {
|
659 | version: _this6.framework.version,
|
660 | useCustomDist: _this6.config.muonVersion == null
|
661 | };
|
662 | const config = _this6.config;
|
663 |
|
664 | if (config.nodeGypRebuild === true) {
|
665 | _builderUtil().log.info({
|
666 | arch: _builderUtil().Arch[arch]
|
667 | }, "executing node-gyp rebuild");
|
668 |
|
669 | yield (0, _builderUtil().exec)(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
|
670 | env: (0, _yarn().getGypEnv)(frameworkInfo, platform.nodeName, _builderUtil().Arch[arch], true)
|
671 | });
|
672 | }
|
673 |
|
674 | if (config.npmRebuild === false) {
|
675 | _builderUtil().log.info({
|
676 | reason: "npmRebuild is set to false"
|
677 | }, "skipped app dependencies rebuild");
|
678 |
|
679 | return;
|
680 | }
|
681 |
|
682 | const beforeBuild = (0, _platformPackager().resolveFunction)(config.beforeBuild, "beforeBuild");
|
683 |
|
684 | if (beforeBuild != null) {
|
685 | const performDependenciesInstallOrRebuild = yield beforeBuild({
|
686 | appDir: _this6.appDir,
|
687 | electronVersion: _this6.config.electronVersion,
|
688 | platform,
|
689 | arch: _builderUtil().Arch[arch]
|
690 | });
|
691 |
|
692 | _this6._nodeModulesHandledExternally = !performDependenciesInstallOrRebuild;
|
693 |
|
694 | if (!performDependenciesInstallOrRebuild) {
|
695 | return;
|
696 | }
|
697 | }
|
698 |
|
699 | if (config.buildDependenciesFromSource === true && platform.nodeName !== process.platform) {
|
700 | _builderUtil().log.info({
|
701 | reason: "platform is different and buildDependenciesFromSource is set to true"
|
702 | }, "skipped app dependencies rebuild");
|
703 | } else {
|
704 | yield (0, _yarn().installOrRebuild)(config, _this6.appDir, {
|
705 | frameworkInfo,
|
706 | platform: platform.nodeName,
|
707 | arch: _builderUtil().Arch[arch],
|
708 | productionDeps: _this6.productionDeps
|
709 | });
|
710 | }
|
711 | })();
|
712 | }
|
713 |
|
714 | afterPack(context) {
|
715 | const afterPack = (0, _platformPackager().resolveFunction)(this.config.afterPack, "afterPack");
|
716 | const handlers = this.afterPackHandlers.slice();
|
717 |
|
718 | if (afterPack != null) {
|
719 |
|
720 | handlers.push(afterPack);
|
721 | }
|
722 |
|
723 | return _bluebirdLst().default.each(handlers, it => it(context));
|
724 | }
|
725 |
|
726 | }
|
727 |
|
728 | exports.Packager = Packager;
|
729 |
|
730 | function createOutDirIfNeed(targetList, createdOutDirs) {
|
731 | const ourDirs = new Set();
|
732 |
|
733 | for (const target of targetList) {
|
734 |
|
735 | if (target instanceof _targetFactory().NoOpTarget) {
|
736 | continue;
|
737 | }
|
738 |
|
739 | const outDir = target.outDir;
|
740 |
|
741 | if (!createdOutDirs.has(outDir)) {
|
742 | ourDirs.add(outDir);
|
743 | }
|
744 | }
|
745 |
|
746 | if (ourDirs.size > 0) {
|
747 | return _bluebirdLst().default.map(Array.from(ourDirs).sort(), it => {
|
748 | createdOutDirs.add(it);
|
749 | return (0, _fsExtraP().ensureDir)(it);
|
750 | });
|
751 | }
|
752 |
|
753 | return Promise.resolve();
|
754 | }
|
755 |
|
756 | function getSafeEffectiveConfig(configuration) {
|
757 | const o = JSON.parse((0, _builderUtil().safeStringifyJson)(configuration));
|
758 |
|
759 | if (o.cscLink != null) {
|
760 | o.cscLink = "<hidden by builder>";
|
761 | }
|
762 |
|
763 | return (0, _builderUtil().serializeToYaml)(o, true);
|
764 | }
|
765 |
|
\ | No newline at end of file |