| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844 |
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
15
1
1
1
1
1
1
1
1
1
1
1
1
1
1
17
| "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NsisTarget = exports.AppPackageHelper = undefined;
var _bluebirdLst;
function _load_bluebirdLst() {
return _bluebirdLst = require("bluebird-lst");
}
var _bluebirdLst2;
function _load_bluebirdLst2() {
return _bluebirdLst2 = _interopRequireDefault(require("bluebird-lst"));
}
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _electronBuilderCore;
function _load_electronBuilderCore() {
return _electronBuilderCore = require("electron-builder-core");
}
var _electronBuilderUtil;
function _load_electronBuilderUtil() {
return _electronBuilderUtil = require("electron-builder-util");
}
var _binDownload;
function _load_binDownload() {
return _binDownload = require("electron-builder-util/out/binDownload");
}
var _fs;
function _load_fs() {
return _fs = require("electron-builder-util/out/fs");
}
var _log;
function _load_log() {
return _log = require("electron-builder-util/out/log");
}
var _promise;
function _load_promise() {
return _promise = require("electron-builder-util/out/promise");
}
var _fsExtraP;
function _load_fsExtraP() {
return _fsExtraP = require("fs-extra-p");
}
var _jsYaml;
function _load_jsYaml() {
return _jsYaml = require("js-yaml");
}
var _path = _interopRequireWildcard(require("path"));
var _sanitizeFilename;
function _load_sanitizeFilename() {
return _sanitizeFilename = _interopRequireDefault(require("sanitize-filename"));
}
var _uuid;
function _load_uuid() {
return _uuid = require("uuid-1345");
}
var _platformPackager;
function _load_platformPackager() {
return _platformPackager = require("../platformPackager");
}
var _windowsCodeSign;
function _load_windowsCodeSign() {
return _windowsCodeSign = require("../windowsCodeSign");
}
var _archive;
function _load_archive() {
return _archive = require("./archive");
}
function _interopRequireWildcard(obj) { Iif (obj && obj.__esModule) { return obj; } else { var newObj = {}; Eif (obj != null) { for (var key in obj) { Eif (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// noinspection SpellCheckingInspection
const ELECTRON_BUILDER_NS_UUID = "50e065bc-3134-11e6-9bab-38c9862bdaf3";
// noinspection SpellCheckingInspection
const nsisPathPromise = (0, (_binDownload || _load_binDownload()).getBinFromBintray)("nsis", "3.0.1.10", "302a8adebf0b553f74cddd494154a586719ff9d4767e94d8a76547a9bb06200c");
// noinspection SpellCheckingInspection
const nsisResourcePathPromise = (0, (_binDownload || _load_binDownload()).getBinFromBintray)("nsis-resources", "3.0.0", "cde0e77b249e29d74250bf006aa355d3e02b32226e1c6431fb48facae41d8a7e");
const USE_NSIS_BUILT_IN_COMPRESSOR = false;
class AppPackageHelper {
constructor() {
this.archToFileInfo = new Map();
this.infoToIsDelete = new Map();
/** @private */
this.refCount = 0;
}
packArch(arch, target) {
var _this = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
let infoPromise = _this.archToFileInfo.get(arch);
if (infoPromise == null) {
infoPromise = (0, (_log || _load_log()).subTask)(`Packaging NSIS installer for arch ${(_electronBuilderCore || _load_electronBuilderCore()).Arch[arch]}`, target.buildAppPackage(target.archs.get(arch), arch)).then(function (it) {
return { file: it };
});
_this.archToFileInfo.set(arch, infoPromise);
}
const info = yield infoPromise;
if (target.isWebInstaller) {
_this.infoToIsDelete.set(info, false);
} else if (!_this.infoToIsDelete.has(info)) {
_this.infoToIsDelete.set(info, true);
}
return info.file;
})();
}
finishBuild() {
var _this2 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
if (--_this2.refCount > 0) {
return;
}
const filesToDelete = [];
for (let _ref of _this2.infoToIsDelete.entries()) {
var _ref2 = _slicedToArray(_ref, 2);
let info = _ref2[0];
let isDelete = _ref2[1];
if (isDelete) {
filesToDelete.push(info.file);
}
}
yield (_bluebirdLst2 || _load_bluebirdLst2()).default.map(filesToDelete, function (it) {
return (0, (_fsExtraP || _load_fsExtraP()).unlink)(it);
});
})();
}
}
exports.AppPackageHelper = AppPackageHelper;
class NsisTarget extends (_electronBuilderCore || _load_electronBuilderCore()).Target {
constructor(packager, outDir, targetName, packageHelper) {
super(targetName);
this.packager = packager;
this.outDir = outDir;
this.packageHelper = packageHelper;
/** @private */
this.archs = new Map();
this.nsisTemplatesDir = _path.join(__dirname, "..", "..", "templates", "nsis");
this.packageHelper.refCount++;
let options = this.packager.config.nsis || Object.create(null);
if (targetName !== "nsis") {
options = Object.assign(options, this.packager.config[targetName === "nsis-web" ? "nsisWeb" : targetName]);
}
this.options = options;
const deps = packager.info.metadata.dependencies;
if (deps != null && deps["electron-squirrel-startup"] != null) {
(0, (_log || _load_log()).warn)('"electron-squirrel-startup" dependency is not required for NSIS');
}
}
build(appOutDir, arch) {
var _this3 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
_this3.archs.set(arch, appOutDir);
})();
}
/** @private */
buildAppPackage(appOutDir, arch) {
var _this4 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
yield (_bluebirdLst2 || _load_bluebirdLst2()).default.all([(0, (_fs || _load_fs()).copyFile)(_path.join((yield nsisPathPromise), "elevate.exe"), _path.join(appOutDir, "resources", "elevate.exe"), null, false), (0, (_fs || _load_fs()).copyFile)(_path.join((yield (0, (_windowsCodeSign || _load_windowsCodeSign()).getSignVendorPath)()), "windows-10", (_electronBuilderCore || _load_electronBuilderCore()).Arch[arch], "signtool.exe"), _path.join(appOutDir, "resources", "signtool.exe"), null, false)]);
const packager = _this4.packager;
const format = _this4.options.useZip ? "zip" : "7z";
const archiveFile = _path.join(_this4.outDir, `${packager.appInfo.name}-${packager.appInfo.version}-${(_electronBuilderCore || _load_electronBuilderCore()).Arch[arch]}.nsis.${format}`);
return yield (0, (_archive || _load_archive()).archive)(packager.config.compression, format, archiveFile, appOutDir, true);
})();
}
// noinspection JSUnusedGlobalSymbols
finishBuild() {
var _this5 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
(0, (_log || _load_log()).log)("Building NSIS installer");
try {
yield _this5.buildInstaller();
} finally {
yield _this5.packageHelper.finishBuild();
}
})();
}
get installerFilenamePattern() {
return "${productName} " + (this.isPortable ? "" : "Setup ") + "${version}.${ext}";
}
get isPortable() {
return this.name === "portable";
}
buildInstaller() {
var _this6 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const isPortable = _this6.isPortable;
const packager = _this6.packager;
const appInfo = packager.appInfo;
const version = appInfo.version;
const options = _this6.options;
const installerFilename = packager.expandArtifactNamePattern(options, "exe", null, _this6.installerFilenamePattern);
const iconPath = (isPortable ? null : yield packager.getResource(options.installerIcon, "installerIcon.ico")) || (yield packager.getIconPath());
const oneClick = options.oneClick !== false;
const installerPath = _path.join(_this6.outDir, installerFilename);
const guid = options.guid || (yield (_bluebirdLst2 || _load_bluebirdLst2()).default.promisify((_uuid || _load_uuid()).v5)({ namespace: ELECTRON_BUILDER_NS_UUID, name: appInfo.id }));
const defines = {
APP_ID: appInfo.id,
APP_GUID: guid,
PRODUCT_NAME: appInfo.productName,
PRODUCT_FILENAME: appInfo.productFilename,
APP_FILENAME: (!oneClick || options.perMachine === true) && /^[-_+0-9a-zA-Z ]+$/.test(appInfo.productFilename) ? appInfo.productFilename : appInfo.name,
APP_DESCRIPTION: appInfo.description,
VERSION: version,
COMPANY_NAME: appInfo.companyName,
PROJECT_DIR: packager.projectDir,
BUILD_RESOURCES_DIR: packager.buildResourcesDir
};
// electron uses product file name as app data, define it as well to remove on uninstall
if (defines.APP_FILENAME != appInfo.productFilename) {
defines.APP_PRODUCT_FILENAME = appInfo.productFilename;
}
const commands = {
OutFile: `"${installerPath}"`,
VIProductVersion: appInfo.versionInWeirdWindowsForm,
VIAddVersionKey: _this6.computeVersionKey(),
Unicode: _this6.isUnicodeEnabled
};
if (iconPath != null) {
if (isPortable) {
commands.Icon = iconPath;
} else {
defines.MUI_ICON = iconPath;
defines.MUI_UNICON = iconPath;
}
}
if (_this6.archs.size === 1 && USE_NSIS_BUILT_IN_COMPRESSOR) {
defines.APP_BUILD_DIR = _this6.archs.get(_this6.archs.keys().next().value);
} else {
yield (_bluebirdLst2 || _load_bluebirdLst2()).default.map(_this6.archs.keys(), (() => {
var _ref3 = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* (arch) {
const file = yield _this6.packageHelper.packArch(arch, _this6);
defines[arch === (_electronBuilderCore || _load_electronBuilderCore()).Arch.x64 ? "APP_64" : "APP_32"] = file;
defines[(arch === (_electronBuilderCore || _load_electronBuilderCore()).Arch.x64 ? "APP_64" : "APP_32") + "_NAME"] = _path.basename(file);
if (_this6.isWebInstaller) {
packager.dispatchArtifactCreated(file, _this6, arch);
}
});
return function (_x) {
return _ref3.apply(this, arguments);
};
})());
}
_this6.configureDefinesForAllTypeOfInstaller(defines);
if (isPortable) {
defines.REQUEST_EXECUTION_LEVEL = options.requestExecutionLevel || "user";
} else {
yield _this6.configureDefines(oneClick, defines);
}
if (packager.config.compression === "store") {
commands.SetCompress = "off";
} else {
commands.SetCompressor = "lzma";
if (!_this6.isWebInstaller) {
defines.COMPRESS = "auto";
}
}
(0, (_electronBuilderUtil || _load_electronBuilderUtil()).debug)(defines);
(0, (_electronBuilderUtil || _load_electronBuilderUtil()).debug)(commands);
if (packager.packagerOptions.effectiveOptionComputed != null && (yield packager.packagerOptions.effectiveOptionComputed([defines, commands]))) {
return;
}
const script = isPortable ? yield (0, (_fsExtraP || _load_fsExtraP()).readFile)(_path.join(_this6.nsisTemplatesDir, "portable.nsi"), "utf8") : yield _this6.computeScriptAndSignUninstaller(defines, commands, installerPath);
yield _this6.executeMakensis(defines, commands, (yield _this6.computeFinalScript(script, true)));
yield packager.sign(installerPath);
packager.dispatchArtifactCreated(installerPath, _this6, _this6.archs.size === 1 ? _this6.archs.keys().next().value : null, _this6.generateGitHubInstallerName());
})();
}
generateGitHubInstallerName() {
const appInfo = this.packager.appInfo;
const classifier = appInfo.name.toLowerCase() === appInfo.name ? "setup-" : "Setup-";
return `${appInfo.name}-${this.isPortable ? "" : classifier}${appInfo.version}.exe`;
}
get isUnicodeEnabled() {
return this.options.unicode == null ? true : this.options.unicode;
}
get isWebInstaller() {
return false;
}
computeScriptAndSignUninstaller(defines, commands, installerPath) {
var _this7 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const packager = _this7.packager;
const customScriptPath = yield packager.getResource(_this7.options.script, "installer.nsi");
const script = yield (0, (_fsExtraP || _load_fsExtraP()).readFile)(customScriptPath || _path.join(_this7.nsisTemplatesDir, "installer.nsi"), "utf8");
if (customScriptPath != null) {
(0, (_log || _load_log()).log)("Custom NSIS script is used - uninstaller is not signed by electron-builder");
return script;
}
const uninstallerPath = yield packager.getTempFile("uninstaller.exe");
const isWin = process.platform === "win32";
defines.BUILD_UNINSTALLER = null;
defines.UNINSTALLER_OUT_FILE = isWin ? uninstallerPath : _path.win32.join("Z:", uninstallerPath);
yield _this7.executeMakensis(defines, commands, (yield _this7.computeFinalScript(script, false)));
yield (0, (_electronBuilderUtil || _load_electronBuilderUtil()).exec)(isWin ? installerPath : "wine", isWin ? [] : [installerPath]);
yield packager.sign(uninstallerPath, " Signing NSIS uninstaller");
delete defines.BUILD_UNINSTALLER;
// platform-specific path, not wine
defines.UNINSTALLER_OUT_FILE = uninstallerPath;
return script;
})();
}
computeVersionKey() {
// Error: invalid VIProductVersion format, should be X.X.X.X
// so, we must strip beta
const localeId = this.options.language || "1033";
const appInfo = this.packager.appInfo;
const versionKey = [`/LANG=${localeId} ProductName "${appInfo.productName}"`, `/LANG=${localeId} ProductVersion "${appInfo.version}"`, `/LANG=${localeId} CompanyName "${appInfo.companyName}"`, `/LANG=${localeId} LegalCopyright "${appInfo.copyright}"`, `/LANG=${localeId} FileDescription "${appInfo.description}"`, `/LANG=${localeId} FileVersion "${appInfo.buildVersion}"`];
(0, (_electronBuilderUtil || _load_electronBuilderUtil()).use)(this.packager.platformSpecificBuildOptions.legalTrademarks, it => versionKey.push(`/LANG=${localeId} LegalTrademarks "${it}"`));
return versionKey;
}
configureDefines(oneClick, defines) {
var _this8 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const packager = _this8.packager;
const options = _this8.options;
if (oneClick) {
defines.ONE_CLICK = null;
if (options.runAfterFinish !== false) {
defines.RUN_AFTER_FINISH = null;
}
const installerHeaderIcon = yield packager.getResource(options.installerHeaderIcon, "installerHeaderIcon.ico");
if (installerHeaderIcon != null) {
defines.HEADER_ICO = installerHeaderIcon;
}
} else {
const installerHeader = yield packager.getResource(options.installerHeader, "installerHeader.bmp");
if (installerHeader != null) {
defines.MUI_HEADERIMAGE = null;
defines.MUI_HEADERIMAGE_RIGHT = null;
defines.MUI_HEADERIMAGE_BITMAP = installerHeader;
}
const bitmap = (yield packager.getResource(options.installerSidebar, "installerSidebar.bmp")) || "${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp";
defines.MUI_WELCOMEFINISHPAGE_BITMAP = bitmap;
defines.MUI_UNWELCOMEFINISHPAGE_BITMAP = (yield packager.getResource(options.uninstallerSidebar, "uninstallerSidebar.bmp")) || bitmap;
if (options.allowElevation !== false) {
defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null;
}
}
if (options.perMachine === true) {
defines.INSTALL_MODE_PER_ALL_USERS = null;
}
if (!oneClick || options.perMachine === true) {
defines.INSTALL_MODE_PER_ALL_USERS_REQUIRED = null;
}
if (options.allowToChangeInstallationDirectory) {
if (oneClick) {
throw new Error("allowToChangeInstallationDirectory makes sense only for boring installer (please set oneClick to false)");
}
defines.allowToChangeInstallationDirectory = null;
}
if (options.menuCategory != null && options.menuCategory !== false) {
const menu = (0, (_sanitizeFilename || _load_sanitizeFilename()).default)(options.menuCategory === true ? packager.appInfo.companyName : options.menuCategory);
if (!(0, (_electronBuilderUtil || _load_electronBuilderUtil()).isEmptyOrSpaces)(menu)) {
defines.MENU_FILENAME = menu;
}
}
if (options.multiLanguageInstaller == null ? _this8.isUnicodeEnabled : options.multiLanguageInstaller) {
defines.MULTI_LANGUAGE_INSTALLER = null;
}
if (options.deleteAppDataOnUninstall) {
defines.DELETE_APP_DATA_ON_UNINSTALL = null;
}
})();
}
configureDefinesForAllTypeOfInstaller(defines) {
const options = this.options;
if (!this.isWebInstaller && defines.APP_BUILD_DIR == null) {
if (options.useZip) {
defines.ZIP_COMPRESSION = null;
}
defines.COMPRESSION_METHOD = options.useZip ? "zip" : "7z";
}
}
executeMakensis(defines, commands, script) {
var _this9 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const args = _this9.options.warningsAsErrors === false ? [] : ["-WX"];
for (const name of Object.keys(defines)) {
const value = defines[name];
if (value == null) {
args.push(`-D${name}`);
} else {
args.push(`-D${name}=${value}`);
}
}
for (const name of Object.keys(commands)) {
const value = commands[name];
if (Array.isArray(value)) {
for (const c of value) {
args.push(`-X${name} ${c}`);
}
} else {
args.push(`-X${name} ${value}`);
}
}
args.push("-");
if ((_electronBuilderUtil || _load_electronBuilderUtil()).debug.enabled) {
process.stdout.write("\n\nNSIS script:\n\n" + script + "\n\n---\nEnd of NSIS script.\n\n");
}
const nsisPath = yield nsisPathPromise;
yield new (_bluebirdLst2 || _load_bluebirdLst2()).default(function (resolve, reject) {
const command = _path.join(nsisPath, process.platform === "darwin" ? "mac" : process.platform === "win32" ? "Bin" : "linux", process.platform === "win32" ? "makensis.exe" : "makensis");
const childProcess = (0, (_electronBuilderUtil || _load_electronBuilderUtil()).doSpawn)(command, args, {
// we use NSIS_CONFIG_CONST_DATA_PATH=no to build makensis on Linux, but in any case it doesn't use stubs as MacOS/Windows version, so, we explicitly set NSISDIR
// set LC_CTYPE to avoid crash https://github.com/electron-userland/electron-builder/issues/503 Even "en_DE.UTF-8" leads to error.
env: Object.assign({}, process.env, { NSISDIR: nsisPath, LC_CTYPE: "en_US.UTF-8" }),
cwd: _this9.nsisTemplatesDir
}, true);
(0, (_electronBuilderUtil || _load_electronBuilderUtil()).handleProcess)("close", childProcess, command, resolve, function (error) {
reject(error + "\nNSIS script:\n" + script);
});
childProcess.stdin.end(script);
});
})();
}
writeCustomLangFile(data) {
var _this10 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const file = yield _this10.packager.getTempFile("messages.nsh");
yield (0, (_fsExtraP || _load_fsExtraP()).outputFile)(file, data);
return file;
})();
}
computeFinalScript(originalScript, isInstaller) {
var _this11 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const packager = _this11.packager;
let scriptHeader = `!addincludedir "${_path.join(__dirname, "..", "..", "templates", "nsis", "include")}"\n`;
const addCustomMessageFileInclude = (() => {
var _ref4 = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* (input) {
return '!include "' + (yield _this11.writeCustomLangFile(computeCustomMessageTranslations((0, (_jsYaml || _load_jsYaml()).safeLoad)((yield (0, (_fsExtraP || _load_fsExtraP()).readFile)(_path.join(_this11.nsisTemplatesDir, input), "utf-8")))).join("\n"))) + '"\n';
});
return function addCustomMessageFileInclude(_x2) {
return _ref4.apply(this, arguments);
};
})();
const tasks = [(0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const pluginArch = _this11.isUnicodeEnabled ? "x86-unicode" : "x86-ansi";
let result = `!addplugindir /${pluginArch} "${_path.join((yield nsisResourcePathPromise), "plugins", pluginArch)}"\n`;
result += `!addplugindir /${pluginArch} "${_path.join(packager.buildResourcesDir, pluginArch)}"\n`;
return result;
}), (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
// http://stackoverflow.com/questions/997456/nsis-license-file-based-on-language-selection
const licensePage = yield _this11.computeLicensePage();
return licensePage == null ? "" : createMacro("licensePage", licensePage);
}), function () {
return addCustomMessageFileInclude("messages.yml");
}];
if (!_this11.isPortable) {
if (_this11.options.oneClick === false) {
tasks.push(function () {
return addCustomMessageFileInclude("boringMessages.yml");
});
}
tasks.push((0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
let result = "";
const customInclude = yield packager.getResource(_this11.options.include, "installer.nsh");
if (customInclude != null) {
result += `!addincludedir "${packager.buildResourcesDir}"\n`;
result += `!include "${customInclude}"\n\n`;
}
return result;
}));
}
for (const s of yield (0, (_promise || _load_promise()).asyncAll)(tasks)) {
scriptHeader += s;
}
if (_this11.isPortable) {
return scriptHeader + originalScript;
}
const fileAssociations = packager.fileAssociations;
if (fileAssociations.length !== 0) {
if (_this11.options.perMachine !== true) {
// https://github.com/electron-userland/electron-builder/issues/772
throw new Error(`Please set perMachine to true — file associations works on Windows only if installed for all users`);
}
scriptHeader += "!include FileAssociation.nsh\n";
if (isInstaller) {
let registerFileAssociationsScript = "";
for (const item of fileAssociations) {
const extensions = (0, (_electronBuilderUtil || _load_electronBuilderUtil()).asArray)(item.ext).map((_platformPackager || _load_platformPackager()).normalizeExt);
for (const ext of extensions) {
const customIcon = yield packager.getResource((0, (_electronBuilderUtil || _load_electronBuilderUtil()).getPlatformIconFileName)(item.icon, false), `${extensions[0]}.ico`);
let installedIconPath = "$appExe,0";
if (customIcon != null) {
installedIconPath = `$INSTDIR\\resources\\${_path.basename(customIcon)}`;
//noinspection SpellCheckingInspection
registerFileAssociationsScript += ` File "/oname=${installedIconPath}" "${customIcon}"\n`;
}
const icon = `"${installedIconPath}"`;
const commandText = `"Open with ${packager.appInfo.productName}"`;
const command = '"$appExe $\\"%1$\\""';
registerFileAssociationsScript += ` !insertmacro APP_ASSOCIATE "${ext}" "${item.name || ext}" "${item.description || ""}" ${icon} ${commandText} ${command}\n`;
}
}
scriptHeader += `!macro registerFileAssociations\n${registerFileAssociationsScript}!macroend\n`;
} else {
let unregisterFileAssociationsScript = "";
for (const item of fileAssociations) {
for (const ext of (0, (_electronBuilderUtil || _load_electronBuilderUtil()).asArray)(item.ext)) {
unregisterFileAssociationsScript += ` !insertmacro APP_UNASSOCIATE "${(0, (_platformPackager || _load_platformPackager()).normalizeExt)(ext)}" "${item.name || ext}"\n`;
}
}
scriptHeader += `!macro unregisterFileAssociations\n${unregisterFileAssociationsScript}!macroend\n`;
}
}
return scriptHeader + originalScript;
})();
}
computeLicensePage() {
var _this12 = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
const packager = _this12.packager;
const license = yield packager.getResource(_this12.options.license, "license.rtf", "license.txt", "eula.rtf", "eula.txt", "LICENSE.rtf", "LICENSE.txt", "EULA.rtf", "EULA.txt", "LICENSE.RTF", "LICENSE.TXT", "EULA.RTF", "EULA.TXT");
if (license != null) {
return [`!insertmacro MUI_PAGE_LICENSE "${license}"`];
}
const licenseFiles = (yield packager.resourceList).filter(function (it) {
const name = it.toLowerCase();
return (name.startsWith("license_") || name.startsWith("eula_")) && (name.endsWith(".rtf") || name.endsWith(".txt"));
});
if (licenseFiles.length === 0) {
return null;
}
const licensePage = [];
const unspecifiedLangs = new Set(bundledLanguages);
let defaultFile = null;
const sortedFiles = licenseFiles.sort(function (a, b) {
const aW = a.indexOf("_en") !== -1 ? 0 : 100;
const bW = b.indexOf("_en") !== -1 ? 0 : 100;
return aW === bW ? a.localeCompare(b) : aW - bW;
});
for (const file of sortedFiles) {
let lang = file.match(/_([^.]+)\./)[1];
let langWithRegion;
if (lang.indexOf("_") !== -1) {
langWithRegion = lang;
} else {
lang = lang.toLowerCase();
langWithRegion = toLangWithRegion(lang);
}
unspecifiedLangs.delete(langWithRegion);
const fullFile = _path.join(packager.buildResourcesDir, file);
if (defaultFile == null) {
defaultFile = fullFile;
}
licensePage.push(`LicenseLangString MUILicense ${lcid[langWithRegion] || lang} "${fullFile}"`);
}
for (const l of unspecifiedLangs) {
licensePage.push(`LicenseLangString MUILicense ${lcid[l]} "${defaultFile}"`);
}
licensePage.push('!insertmacro MUI_PAGE_LICENSE "$(MUILicense)"');
return licensePage;
})();
}
}
exports.NsisTarget = NsisTarget;
function computeCustomMessageTranslations(messages) {
const result = [];
for (const messageId of Object.keys(messages)) {
const langToTranslations = messages[messageId];
const unspecifiedLangs = new Set(bundledLanguages);
for (const lang of Object.keys(langToTranslations)) {
const langWithRegion = toLangWithRegion(lang);
result.push(`LangString ${messageId} ${lcid[langWithRegion]} "${langToTranslations[lang].replace(/\n/g, "$\\r$\\n")}"`);
unspecifiedLangs.delete(langWithRegion);
}
const defaultTranslation = langToTranslations["en"].replace(/\n/g, "$\\r$\\n");
for (const langWithRegion of unspecifiedLangs) {
result.push(`LangString ${messageId} ${lcid[langWithRegion]} "${defaultTranslation}"`);
}
}
return result;
}
function toLangWithRegion(lang) {
let langWithRegion = langToLangWithRegion.get(lang);
if (langWithRegion == null) {
langWithRegion = `${lang}_${lang.toUpperCase()}`;
}
return langWithRegion;
}
function createMacro(name, lines) {
return `\n!macro ${name}\n ${lines.join("\n ")}\n!macroend\n`;
}
const lcid = {
"af_ZA": 1078,
"am_ET": 1118,
"ar_AE": 14337,
"ar_BH": 15361,
"ar_DZ": 5121,
"ar_EG": 3073,
"ar_IQ": 2049,
"ar_JO": 11265,
"ar_KW": 13313,
"ar_LB": 12289,
"ar_LY": 4097,
"ar_MA": 6145,
"ar_OM": 8193,
"ar_QA": 16385,
"ar_SA": 1025,
"ar_SY": 10241,
"ar_TN": 7169,
"ar_YE": 9217,
"arn_CL": 1146,
"as_IN": 1101,
"az_AZ": 2092,
"ba_RU": 1133,
"be_BY": 1059,
"bg_BG": 1026,
"bn_IN": 1093,
"bo_BT": 2129,
"bo_CN": 1105,
"br_FR": 1150,
"bs_BA": 8218,
"ca_ES": 1027,
"co_FR": 1155,
"cs_CZ": 1029,
"cy_GB": 1106,
"da_DK": 1030,
"de_AT": 3079,
"de_CH": 2055,
"de_DE": 1031,
"de_LI": 5127,
"de_LU": 4103,
"div_MV": 1125,
"dsb_DE": 2094,
"el_GR": 1032,
"en_AU": 3081,
"en_BZ": 10249,
"en_CA": 4105,
"en_CB": 9225,
"en_GB": 2057,
"en_IE": 6153,
"en_IN": 18441,
"en_JA": 8201,
"en_MY": 17417,
"en_NZ": 5129,
"en_PH": 13321,
"en_TT": 11273,
"en_US": 1033,
"en_ZA": 7177,
"en_ZW": 12297,
"es_AR": 11274,
"es_BO": 16394,
"es_CL": 13322,
"es_CO": 9226,
"es_CR": 5130,
"es_DO": 7178,
"es_EC": 12298,
"es_ES": 3082,
"es_GT": 4106,
"es_HN": 18442,
"es_MX": 2058,
"es_NI": 19466,
"es_PA": 6154,
"es_PE": 10250,
"es_PR": 20490,
"es_PY": 15370,
"es_SV": 17418,
"es_UR": 14346,
"es_US": 21514,
"es_VE": 8202,
"et_EE": 1061,
"eu_ES": 1069,
"fa_IR": 1065,
"fi_FI": 1035,
"fil_PH": 1124,
"fo_FO": 1080,
"fr_BE": 2060,
"fr_CA": 3084,
"fr_CH": 4108,
"fr_FR": 1036,
"fr_LU": 5132,
"fr_MC": 6156,
"fy_NL": 1122,
"ga_IE": 2108,
"gbz_AF": 1164,
"gl_ES": 1110,
"gsw_FR": 1156,
"gu_IN": 1095,
"ha_NG": 1128,
"he_IL": 1037,
"hi_IN": 1081,
"hr_BA": 4122,
"hr_HR": 1050,
"hu_HU": 1038,
"hy_AM": 1067,
"id_ID": 1057,
"ii_CN": 1144,
"is_IS": 1039,
"it_CH": 2064,
"it_IT": 1040,
"iu_CA": 2141,
"ja_JP": 1041,
"ka_GE": 1079,
"kh_KH": 1107,
"kk_KZ": 1087,
"kl_GL": 1135,
"kn_IN": 1099,
"ko_KR": 1042,
"kok_IN": 1111,
"ky_KG": 1088,
"lb_LU": 1134,
"lo_LA": 1108,
"lt_LT": 1063,
"lv_LV": 1062,
"mi_NZ": 1153,
"mk_MK": 1071,
"ml_IN": 1100,
"mn_CN": 2128,
"mn_MN": 1104,
"moh_CA": 1148,
"mr_IN": 1102,
"ms_BN": 2110,
"ms_MY": 1086,
"mt_MT": 1082,
"my_MM": 1109,
"nb_NO": 1044,
"ne_NP": 1121,
"nl_BE": 2067,
"nl_NL": 1043,
"nn_NO": 2068,
"ns_ZA": 1132,
"oc_FR": 1154,
"or_IN": 1096,
"pa_IN": 1094,
"pl_PL": 1045,
"ps_AF": 1123,
"pt_BR": 1046,
"pt_PT": 2070,
"qut_GT": 1158,
"quz_BO": 1131,
"quz_EC": 2155,
"quz_PE": 3179,
"rm_CH": 1047,
"ro_RO": 1048,
"ru_RU": 1049,
"rw_RW": 1159,
"sa_IN": 1103,
"sah_RU": 1157,
"se_FI": 3131,
"se_NO": 1083,
"se_SE": 2107,
"si_LK": 1115,
"sk_SK": 1051,
"sl_SI": 1060,
"sma_NO": 6203,
"sma_SE": 7227,
"smj_NO": 4155,
"smj_SE": 5179,
"smn_FI": 9275,
"sms_FI": 8251,
"sq_AL": 1052,
"sr_BA": 7194,
"sr_SP": 3098,
"sv_FI": 2077,
"sv_SE": 1053,
"sw_KE": 1089,
"syr_SY": 1114,
"ta_IN": 1097,
"te_IN": 1098,
"tg_TJ": 1064,
"th_TH": 1054,
"tk_TM": 1090,
"tmz_DZ": 2143,
"tn_ZA": 1074,
"tr_TR": 1055,
"tt_RU": 1092,
"ug_CN": 1152,
"uk_UA": 1058,
"ur_IN": 2080,
"ur_PK": 1056,
"uz_UZ": 2115,
"vi_VN": 1066,
"wen_DE": 1070,
"wo_SN": 1160,
"xh_ZA": 1076,
"yo_NG": 1130,
"zh_CHS": 4,
"zh_CHT": 31748,
"zh_CN": 2052,
"zh_HK": 3076,
"zh_MO": 5124,
"zh_SG": 4100,
"zh_TW": 1028,
"zu_ZA": 1077
};
// "el_GR" "lv_LV" "ko_KR" "tr_TR"
const bundledLanguages = ["en_US", "de_DE", "fr_FR", "es_ES", "zh_CN", "zh_TW", "ja_JP", "it_IT", "nl_NL", "ru_RU", "pl_PL", "uk_UA", "cs_CZ", "sv_SE", "nb_NO", "da_DK", "pt_PT"];
const langToLangWithRegion = new Map();
for (const id of bundledLanguages) {
langToLangWithRegion.set(id.substring(0, id.indexOf("_")), id);
}
//# sourceMappingURL=nsis.js.map
|