Skip to content

Commit 969c0eb

Browse files
committed
feat(nsis): metro sidebar, customizable sidebar
Close #1248
1 parent 3bb2ab8 commit 969c0eb

File tree

20 files changed

+5980
-6777
lines changed

20 files changed

+5980
-6777
lines changed

.idea/dictionaries/develar.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ install:
3232
- nvm install $NODE_VERSION
3333
- nvm use --delete-prefix $NODE_VERSION
3434
- ln -sf $PWD/test/vendor/yarn.js /usr/local/bin/yarn
35-
- yarn install --pure-lockfile
35+
- yarn --link-duplicates --pure-lockfile
3636
- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" && "$TRAVIS_TAG" == "" && "$PUBLISH_TO_NPM" == "true" ]]; then yarn add @develar/semantic-release@next --dev ; fi
3737

3838
script:
39-
- yarn run test
39+
- yarn test
4040

4141
after_success:
4242
- if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" && "$TRAVIS_TAG" == "" && "$PUBLISH_TO_NPM" == "true" ]]; then npm run semantic-release ; fi

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ _Note: Platform specific `7zip-bin-*` packages are `optionalDependencies`, which
3434

3535
1. Specify the standard fields in the application `package.json`[name](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata-name), `description`, `version` and [author](https://docs.npmjs.com/files/package.json#people-fields-author-contributors).
3636

37-
2. Specify the [build](https://github.com/electron-userland/electron-builder/wiki/Options#build) configuration in the development `package.json` as follows:
37+
2. Specify the [build](https://github.com/electron-userland/electron-builder/wiki/Options#build) configuration in the `package.json` as follows:
3838
```json
3939
"build": {
4040
"appId": "your.id",
4141
"mac": {
4242
"category": "your.app.category.type"
43-
},
44-
"win": {
45-
"iconUrl": "(windows-only) https link to icon"
4643
}
4744
}
4845
```

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- sudo apt-get install git-lfs=1.3.0
1515
- ssh git@github.com git-lfs-authenticate $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git download
1616
- git lfs pull
17-
- docker run --rm --env-file ./test/docker-env.list -v ${PWD}:/project -v ~/.electron:/root/.electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/electron-builder:wine /bin/bash -c "node ./test/vendor/yarn.js && node ./test/vendor/yarn.js test"
17+
- docker run --rm --env-file ./test/docker-env.list -v ${PWD}:/project -v ~/.electron:/root/.electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/electron-builder:wine /bin/bash -c "node ./test/vendor/yarn.js --link-duplicates --pure-lockfile && node ./test/vendor/yarn.js test"
1818

1919
test:
2020
override:

docs/Options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
181181
| guid | <a name="NsisOptions-guid"></a>See [GUID vs Application Name](https://github.com/electron-userland/electron-builder/wiki/NSIS#guid-vs-application-name).
182182
| installerIcon | <a name="NsisOptions-installerIcon"></a>The path to installer icon. Defaults to `build/installerIcon.ico` or application icon.
183183
| installerHeader | <a name="NsisOptions-installerHeader"></a>*boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp`
184+
| installerSidebar | <a name="NsisOptions-installerSidebar"></a>*boring installer only.* `MUI_WELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
185+
| uninstallerSidebar | <a name="NsisOptions-uninstallerSidebar"></a>*boring installer only.* `MUI_UNWELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `installerSidebar` option or `build/uninstallerSidebar.bmp` or `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
184186
| installerHeaderIcon | <a name="NsisOptions-installerHeaderIcon"></a>*one-click installer only.* The path to header icon (above the progress bar), relative to the project directory. Defaults to `build/installerHeaderIcon.ico` or application icon.
185187
| include | <a name="NsisOptions-include"></a>The path to NSIS include script to customize installer. Defaults to `build/installer.nsh`. See [Custom NSIS script](https://github.com/electron-userland/electron-builder/wiki/NSIS#custom-nsis-script).
186188
| script | <a name="NsisOptions-script"></a>The path to NSIS script to customize installer. Defaults to `build/installer.nsi`. See [Custom NSIS script](https://github.com/electron-userland/electron-builder/wiki/NSIS#custom-nsis-script).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"7zip-bin": "^2.0.4",
2626
"archiver": "^1.3.0",
2727
"asar-electron-builder": "^0.13.5",
28-
"aws-sdk": "^2.12.0",
28+
"aws-sdk": "^2.13.0",
2929
"bluebird-lst-c": "^1.0.6",
3030
"chalk": "^1.1.3",
3131
"chromium-pickle-js": "^0.2.0",

packages/electron-builder/src/options/winOptions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ export interface NsisOptions {
114114
*/
115115
readonly installerHeader?: string | null
116116

117+
/*
118+
*boring installer only.* `MUI_WELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
119+
*/
120+
readonly installerSidebar?: string | null
121+
122+
/*
123+
*boring installer only.* `MUI_UNWELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `installerSidebar` option or `build/uninstallerSidebar.bmp` or `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
124+
*/
125+
readonly uninstallerSidebar?: string | null
126+
117127
/*
118128
*one-click installer only.* The path to header icon (above the progress bar), relative to the project directory. Defaults to `build/installerHeaderIcon.ico` or application icon.
119129
*/

packages/electron-builder/src/targets/nsis.ts

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ import { copyFile } from "electron-builder-util/out/fs"
1515
import { computeDownloadUrl, getPublishConfigs, getPublishConfigsForUpdateInfo } from "../publish/PublishManager"
1616
import { getSignVendorPath } from "../windowsCodeSign"
1717

18-
const NSIS_VERSION = "3.0.1.7"
19-
//noinspection SpellCheckingInspection
20-
const NSIS_SHA2 = "0e797a7099283bf9caf97ee677e1d7986278c27b39916a501480978af039817c"
21-
22-
//noinspection SpellCheckingInspection
2318
const ELECTRON_BUILDER_NS_UUID = "50e065bc-3134-11e6-9bab-38c9862bdaf3"
2419

25-
const nsisPathPromise = getBinFromBintray("nsis", NSIS_VERSION, NSIS_SHA2)
20+
const nsisPathPromise = getBinFromBintray("nsis", "3.0.1.8", "d9429cc33d06198b48b939e51f48fc95b3b7ccd5584dd9fe3f3f4eacce9d8275")
21+
const nsisResourcePathPromise = getBinFromBintray("nsis-resources", "3.0.0", "cde0e77b249e29d74250bf006aa355d3e02b32226e1c6431fb48facae41d8a7e")
2622

2723
const USE_NSIS_BUILT_IN_COMPRESSOR = false
2824

@@ -156,7 +152,7 @@ export default class NsisTarget extends Target {
156152
OutFile: `"${installerPath}"`,
157153
VIProductVersion: appInfo.versionInWeirdWindowsForm,
158154
VIAddVersionKey: this.computeVersionKey(),
159-
Unicode: this.isUnicodeEnabled(),
155+
Unicode: this.isUnicodeEnabled,
160156
}
161157

162158
if (packager.config.compression === "store") {
@@ -182,7 +178,7 @@ export default class NsisTarget extends Target {
182178
packager.dispatchArtifactCreated(installerPath, this, `${packager.appInfo.name}-${this.isWebInstaller ? "Web-" : ""}Setup-${version}.exe`)
183179
}
184180

185-
private isUnicodeEnabled() {
181+
private get isUnicodeEnabled() {
186182
return this.options.unicode == null ? true : this.options.unicode
187183
}
188184

@@ -236,16 +232,34 @@ export default class NsisTarget extends Target {
236232
const packager = this.packager
237233
const options = this.options
238234

239-
const installerHeader = oneClick ? null : await packager.getResource(options.installerHeader, "installerHeader.bmp")
240-
if (installerHeader != null) {
241-
defines.MUI_HEADERIMAGE = null
242-
defines.MUI_HEADERIMAGE_RIGHT = null
243-
defines.MUI_HEADERIMAGE_BITMAP = installerHeader
235+
if (oneClick) {
236+
defines.ONE_CLICK = null
237+
238+
if (options.runAfterFinish !== false) {
239+
defines.RUN_AFTER_FINISH = null
240+
}
241+
242+
const installerHeaderIcon = await packager.getResource(options.installerHeaderIcon, "installerHeaderIcon.ico")
243+
if (installerHeaderIcon != null) {
244+
defines.HEADER_ICO = installerHeaderIcon
245+
}
244246
}
247+
else {
248+
const installerHeader = await
249+
packager.getResource(options.installerHeader, "installerHeader.bmp")
250+
if (installerHeader != null) {
251+
defines.MUI_HEADERIMAGE = null
252+
defines.MUI_HEADERIMAGE_RIGHT = null
253+
defines.MUI_HEADERIMAGE_BITMAP = installerHeader
254+
}
255+
256+
const bitmap = (await packager.getResource(options.installerSidebar, "installerSidebar.bmp")) || "${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp"
257+
defines.MUI_WELCOMEFINISHPAGE_BITMAP = bitmap
258+
defines.MUI_UNWELCOMEFINISHPAGE_BITMAP = (await packager.getResource(options.uninstallerSidebar, "uninstallerSidebar.bmp")) || bitmap
245259

246-
const installerHeaderIcon = oneClick ? await packager.getResource(options.installerHeaderIcon, "installerHeaderIcon.ico") : null
247-
if (installerHeaderIcon != null) {
248-
defines.HEADER_ICO = installerHeaderIcon
260+
if (options.allowElevation !== false) {
261+
defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null
262+
}
249263
}
250264

251265
if (options.perMachine === true) {
@@ -256,15 +270,6 @@ export default class NsisTarget extends Target {
256270
defines.INSTALL_MODE_PER_ALL_USERS_REQUIRED = null
257271
}
258272

259-
if (oneClick) {
260-
if (options.runAfterFinish !== false) {
261-
defines.RUN_AFTER_FINISH = null
262-
}
263-
}
264-
else if (options.allowElevation !== false) {
265-
defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null
266-
}
267-
268273
if (options.allowToChangeInstallationDirectory) {
269274
if (oneClick) {
270275
throw new Error("allowToChangeInstallationDirectory makes sense only for boring installer (please set oneClick to false)")
@@ -280,10 +285,6 @@ export default class NsisTarget extends Target {
280285
defines.COMPRESSION_METHOD = options.useZip ? "zip" : "7z"
281286
}
282287

283-
if (oneClick) {
284-
defines.ONE_CLICK = null
285-
}
286-
287288
if (options.menuCategory != null) {
288289
const menu = sanitizeFileName(options.menuCategory === true ? packager.appInfo.companyName : <string>options.menuCategory)
289290
if (!isEmptyOrSpaces(menu)) {
@@ -293,7 +294,7 @@ export default class NsisTarget extends Target {
293294

294295
use(await packager.getResource(options.license, "license.rtf", "license.txt"), it => defines.LICENSE_FILE = it)
295296

296-
if (options.multiLanguageInstaller == null ? this.isUnicodeEnabled() : options.multiLanguageInstaller) {
297+
if (options.multiLanguageInstaller == null ? this.isUnicodeEnabled : options.multiLanguageInstaller) {
297298
defines.MULTI_LANGUAGE_INSTALLER = null
298299
}
299300

@@ -331,11 +332,17 @@ export default class NsisTarget extends Target {
331332
const binDir = process.platform === "darwin" ? "mac" : (process.platform === "win32" ? "Bin" : "linux")
332333
const nsisPath = await nsisPathPromise
333334

335+
let scriptHeader = `!addincludedir "${path.win32.join(__dirname, "..", "..", "templates", "nsis", "include")}"\n`
336+
const pluginArch = this.isUnicodeEnabled ? "x86-unicode" : "x86-ansi"
337+
scriptHeader += `!addplugindir /${pluginArch} "${path.join(await nsisResourcePathPromise, "plugins", pluginArch)}"\n`
338+
334339
let script = originalScript
335340
const packager = this.packager
336341
const customInclude = await packager.getResource(this.options.include, "installer.nsh")
337342
if (customInclude != null) {
338-
script = `!addincludedir "${packager.buildResourcesDir}"\n!addplugindir "${packager.buildResourcesDir}"\n\n!include "${customInclude}"\n\n${script}`
343+
scriptHeader += `!addincludedir "${packager.buildResourcesDir}"\n`
344+
scriptHeader += `!addplugindir /${pluginArch} "${path.join(packager.buildResourcesDir, pluginArch)}"\n`
345+
script = `\n!include "${customInclude}"\n\n${script}`
339346
}
340347

341348
const fileAssociations = packager.fileAssociations
@@ -378,6 +385,8 @@ export default class NsisTarget extends Target {
378385
}
379386
}
380387

388+
script = scriptHeader + script
389+
381390
if (debug.enabled) {
382391
process.stdout.write("\n\nNSIS script:\n\n" + script + "\n\n---\nEnd of NSIS script.\n\n")
383392
}

0 commit comments

Comments
 (0)