Skip to content

Commit 30e86c1

Browse files
Add customNsisResources override to nsis options
Prior to this change `customNsisBinary` could be used to override the url of `nsis-*.7z` from the `electron-builder-binaries` repo to a custom location. However, there was no option to change the url of the `nsis-resources-*.7z` file. With this chcange the url of the NSIS resources could also be overriden.
1 parent 6a83607 commit 30e86c1

File tree

5 files changed

+106
-8
lines changed

5 files changed

+106
-8
lines changed

.changeset/four-cheetahs-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": minor
3+
---
4+
5+
Add customNsisResources override to nsis options

packages/app-builder-lib/scheme.json

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@
460460
]
461461
},
462462
"url": {
463-
"default": "https://github.com/electron-userland/electron-builder-binaries/releases/download",
463+
"default": "https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z",
464464
"type": [
465465
"null",
466466
"string"
@@ -479,6 +479,36 @@
479479
],
480480
"type": "object"
481481
},
482+
"CustomNsisResources": {
483+
"additionalProperties": false,
484+
"properties": {
485+
"checksum": {
486+
"default": "Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==",
487+
"type": [
488+
"null",
489+
"string"
490+
]
491+
},
492+
"url": {
493+
"default": "https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z",
494+
"type": [
495+
"null",
496+
"string"
497+
]
498+
},
499+
"version": {
500+
"default": "3.4.1",
501+
"type": [
502+
"null",
503+
"string"
504+
]
505+
}
506+
},
507+
"required": [
508+
"url"
509+
],
510+
"type": "object"
511+
},
482512
"CustomPublishOptions": {
483513
"additionalProperties": {},
484514
"properties": {
@@ -3914,6 +3944,17 @@
39143944
],
39153945
"description": "Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)"
39163946
},
3947+
"customNsisResources": {
3948+
"anyOf": [
3949+
{
3950+
"$ref": "#/definitions/CustomNsisResources"
3951+
},
3952+
{
3953+
"type": "null"
3954+
}
3955+
],
3956+
"description": "Allows you to provide your own `nsis-resources`"
3957+
},
39173958
"deleteAppDataOnUninstall": {
39183959
"default": false,
39193960
"description": "*one-click installer only.* Whether to delete app data on uninstall.",
@@ -4220,6 +4261,17 @@
42204261
],
42214262
"description": "Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)"
42224263
},
4264+
"customNsisResources": {
4265+
"anyOf": [
4266+
{
4267+
"$ref": "#/definitions/CustomNsisResources"
4268+
},
4269+
{
4270+
"type": "null"
4271+
}
4272+
],
4273+
"description": "Allows you to provide your own `nsis-resources`"
4274+
},
42234275
"deleteAppDataOnUninstall": {
42244276
"default": false,
42254277
"description": "*one-click installer only.* Whether to delete app data on uninstall.",
@@ -5175,6 +5227,17 @@
51755227
],
51765228
"description": "Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)"
51775229
},
5230+
"customNsisResources": {
5231+
"anyOf": [
5232+
{
5233+
"$ref": "#/definitions/CustomNsisResources"
5234+
},
5235+
{
5236+
"type": "null"
5237+
}
5238+
],
5239+
"description": "Allows you to provide your own `nsis-resources`"
5240+
},
51785241
"guid": {
51795242
"description": "See [GUID vs Application Name](./nsis.md#guid-vs-application-name).",
51805243
"type": [

packages/app-builder-lib/src/targets/nsis/NsisTarget.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import _debug from "debug"
2020
import * as fs from "fs"
2121
import { readFile, stat, unlink } from "fs-extra"
2222
import * as path from "path"
23-
import { getBinFromUrl } from "../../binDownload"
2423
import { Target } from "../../core"
2524
import { DesktopShortcutCreationPolicy, getEffectiveOptions } from "../../options/CommonWindowsInstallerConfiguration"
2625
import { chooseNotNull, computeSafeArtifactNameIfNeeded, normalizeExt } from "../../platformPackager"
@@ -38,16 +37,13 @@ import { addCustomMessageFileInclude, createAddLangsMacro, LangConfigurator } fr
3837
import { computeLicensePage } from "./nsisLicense"
3938
import { NsisOptions, PortableOptions } from "./nsisOptions"
4039
import { NsisScriptGenerator } from "./nsisScriptGenerator"
41-
import { AppPackageHelper, NSIS_PATH, NsisTargetOptions, nsisTemplatesDir, UninstallerReader } from "./nsisUtil"
40+
import { AppPackageHelper, NSIS_PATH, NSIS_RESOURCES_PATH, NsisTargetOptions, nsisTemplatesDir, UninstallerReader } from "./nsisUtil"
4241

4342
const debug = _debug("electron-builder:nsis")
4443

4544
// noinspection SpellCheckingInspection
4645
const ELECTRON_BUILDER_NS_UUID = UUID.parse("50e065bc-3134-11e6-9bab-38c9862bdaf3")
4746

48-
// noinspection SpellCheckingInspection
49-
const nsisResourcePathPromise = () => getBinFromUrl("nsis-resources", "3.4.1", "Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==")
50-
5147
const USE_NSIS_BUILT_IN_COMPRESSOR = false
5248

5349
export class NsisTarget extends Target {
@@ -666,7 +662,7 @@ export class NsisTarget extends Target {
666662

667663
const pluginArch = this.isUnicodeEnabled ? "x86-unicode" : "x86-ansi"
668664
taskManager.add(async () => {
669-
scriptGenerator.addPluginDir(pluginArch, path.join(await nsisResourcePathPromise(), "plugins", pluginArch))
665+
scriptGenerator.addPluginDir(pluginArch, path.join(await NSIS_RESOURCES_PATH(), "plugins", pluginArch))
670666
})
671667

672668
taskManager.add(async () => {

packages/app-builder-lib/src/targets/nsis/nsisOptions.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TargetSpecificOptions } from "../../core"
33

44
export interface CustomNsisBinary {
55
/**
6-
* @default https://github.com/electron-userland/electron-builder-binaries/releases/download
6+
* @default https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.1/nsis-3.0.4.1.7z
77
*/
88
readonly url: string | null
99

@@ -25,6 +25,22 @@ export interface CustomNsisBinary {
2525
*/
2626
readonly debugLogging?: boolean | null
2727
}
28+
export interface CustomNsisResources {
29+
/**
30+
* @default https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z
31+
*/
32+
readonly url: string | null
33+
34+
/**
35+
* @default Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==
36+
*/
37+
readonly checksum?: string | null
38+
39+
/**
40+
* @default 3.4.1
41+
*/
42+
readonly version?: string | null
43+
}
2844
export interface CommonNsisOptions {
2945
/**
3046
* Whether to create [Unicode installer](http://nsis.sourceforge.net/Docs/Chapter1.html#intro-unicode).
@@ -53,6 +69,11 @@ export interface CommonNsisOptions {
5369
* Allows you to provide your own `makensis`, such as one with support for debug logging via LogSet and LogText. (Logging also requires option `debugLogging = true`)
5470
*/
5571
readonly customNsisBinary?: CustomNsisBinary | null
72+
73+
/**
74+
* Allows you to provide your own `nsis-resources`
75+
*/
76+
readonly customNsisResources?: CustomNsisResources | null
5677
}
5778

5879
export interface NsisOptions extends CommonNsisOptions, CommonWindowsInstallerConfiguration, TargetSpecificOptions {

packages/app-builder-lib/src/targets/nsis/nsisUtil.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ export const NSIS_PATH = () => {
3838
})
3939
}
4040

41+
export const NSIS_RESOURCES_PATH = () => {
42+
return NsisTargetOptions.then((options: NsisOptions) => {
43+
if (options.customNsisResources) {
44+
const { checksum, url, version } = options.customNsisResources
45+
if (checksum && url) {
46+
const binaryVersion = version || checksum.substr(0, 8)
47+
return getBinFromCustomLoc("nsis-resources", binaryVersion, url, checksum)
48+
}
49+
}
50+
return getBinFromUrl("nsis-resources", "3.4.1", "Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==")
51+
})
52+
}
53+
4154
export interface PackArchResult {
4255
fileInfo: PackageFileInfo
4356
unpackedSize: number

0 commit comments

Comments
 (0)