Skip to content

Commit f95b1dc

Browse files
feat: customNsisResources override in 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 f95b1dc

File tree

5 files changed

+96
-8
lines changed

5 files changed

+96
-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": patch
3+
---
4+
5+
Add customNsisResources override to nsis options

packages/app-builder-lib/scheme.json

Lines changed: 57 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,29 @@
479479
],
480480
"type": "object"
481481
},
482+
"CustomNsisResources": {
483+
"additionalProperties": false,
484+
"properties": {
485+
"checksum": {
486+
"default": "Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==",
487+
"type": "string"
488+
},
489+
"url": {
490+
"default": "https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-resources-3.4.1/nsis-resources-3.4.1.7z",
491+
"type": "string"
492+
},
493+
"version": {
494+
"default": "3.4.1",
495+
"type": "string"
496+
}
497+
},
498+
"required": [
499+
"checksum",
500+
"url",
501+
"version"
502+
],
503+
"type": "object"
504+
},
482505
"CustomPublishOptions": {
483506
"additionalProperties": {},
484507
"properties": {
@@ -3914,6 +3937,17 @@
39143937
],
39153938
"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`)"
39163939
},
3940+
"customNsisResources": {
3941+
"anyOf": [
3942+
{
3943+
"$ref": "#/definitions/CustomNsisResources"
3944+
},
3945+
{
3946+
"type": "null"
3947+
}
3948+
],
3949+
"description": "Allows you to provide your own `nsis-resources`"
3950+
},
39173951
"deleteAppDataOnUninstall": {
39183952
"default": false,
39193953
"description": "*one-click installer only.* Whether to delete app data on uninstall.",
@@ -4220,6 +4254,17 @@
42204254
],
42214255
"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`)"
42224256
},
4257+
"customNsisResources": {
4258+
"anyOf": [
4259+
{
4260+
"$ref": "#/definitions/CustomNsisResources"
4261+
},
4262+
{
4263+
"type": "null"
4264+
}
4265+
],
4266+
"description": "Allows you to provide your own `nsis-resources`"
4267+
},
42234268
"deleteAppDataOnUninstall": {
42244269
"default": false,
42254270
"description": "*one-click installer only.* Whether to delete app data on uninstall.",
@@ -5175,6 +5220,17 @@
51755220
],
51765221
"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`)"
51775222
},
5223+
"customNsisResources": {
5224+
"anyOf": [
5225+
{
5226+
"$ref": "#/definitions/CustomNsisResources"
5227+
},
5228+
{
5229+
"type": "null"
5230+
}
5231+
],
5232+
"description": "Allows you to provide your own `nsis-resources`"
5233+
},
51785234
"guid": {
51795235
"description": "See [GUID vs Application Name](./nsis.md#guid-vs-application-name).",
51805236
"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
33+
34+
/**
35+
* @default Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==
36+
*/
37+
readonly checksum: string
38+
39+
/**
40+
* @default 3.4.1
41+
*/
42+
readonly version: string
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ 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+
return getBinFromCustomLoc("nsis-resources", version, url, checksum)
46+
}
47+
return getBinFromUrl("nsis-resources", "3.4.1", "Dqd6g+2buwwvoG1Vyf6BHR1b+25QMmPcwZx40atOT57gH27rkjOei1L0JTldxZu4NFoEmW4kJgZ3DlSWVON3+Q==")
48+
})
49+
}
50+
4151
export interface PackArchResult {
4252
fileInfo: PackageFileInfo
4353
unpackedSize: number

0 commit comments

Comments
 (0)