Skip to content

Commit

Permalink
fix(nsis): EULA
Browse files Browse the repository at this point in the history
Closes #829
  • Loading branch information
develar committed Oct 18, 2016
1 parent 6f20e8d commit a0e7131
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 25 deletions.
19 changes: 19 additions & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/electron-builder.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/ArtifactPublisherTest.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
| 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.
| 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).
| 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).
| license | <a name="NsisOptions-license"></a>The path to EULA license file. Defaults to `build/license.rtf` or `build/license.txt`.
| language | <a name="NsisOptions-language"></a>* [LCID Dec](https://msdn.microsoft.com/en-au/goglobal/bb964664.aspx), defaults to `1033`(`English - United States`).
| warningsAsErrors | <a name="NsisOptions-warningsAsErrors"></a><p>Defaults to <code>false</code>.</p> <p>If <code>warningsAsErrors</code> is <code>true</code> (default): NSIS will treat warnings as errors.</p> <p>If <code>warningsAsErrors</code> is <code>false</code>: NSIS will allow warnings.</p>

Expand Down
2 changes: 1 addition & 1 deletion nsis-auto-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"fs-extra-p": "^1.1.10",
"ini": "^1.3.4",
"semver": "^5.3.0",
"source-map-support": "^0.4.4",
"source-map-support": "^0.4.5",
"tunnel-agent": "^0.4.3"
},
"typings": "./out/electron-auto-updater.d.ts"
Expand Down
6 changes: 3 additions & 3 deletions nsis-auto-updater/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ semver@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"

source-map-support:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.4.tgz#0df5765a05a560c91bc8f8641cf79f2affc0322e"
source-map-support@^0.4.5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.5.tgz#4438df4219e1b3c7feb674614b4c67f9722db1e4"
dependencies:
source-map "^0.5.3"

Expand Down
5 changes: 5 additions & 0 deletions src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ export interface NsisOptions {
*/
readonly script?: string | null

/*
The path to EULA license file. Defaults to `build/license.rtf` or `build/license.txt`.
*/
readonly license?: string | null

/*
* [LCID Dec](https://msdn.microsoft.com/en-au/goglobal/bb964664.aspx), defaults to `1033`(`English - United States`).
*/
Expand Down
16 changes: 8 additions & 8 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,18 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
return asArray(this.devMetadata.build.fileAssociations).concat(asArray(this.platformSpecificBuildOptions.fileAssociations))
}

async getResource(custom: string | n, name: string): Promise<string | null> {
let result = custom
if (result === undefined) {
async getResource(custom: string | n, ...names: Array<string>): Promise<string | null> {
if (custom === undefined) {
const resourceList = await this.resourceList
if (resourceList.includes(name)) {
return path.join(this.buildResourcesDir, name)
for (let name of names) {
if (resourceList.includes(name)) {
return path.join(this.buildResourcesDir, name)
}
}
}
else {
return path.resolve(this.projectDir, result)
else if (!isEmptyOrSpaces(custom)) {
return path.resolve(this.projectDir, custom)
}

return null
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ export default class NsisTarget extends TargetEx {
return
}

const licenseFile = await this.packager.getResource(this.options.license, "license.rtf", "license.txt")
if (licenseFile != null) {
defines.LICENSE_FILE = licenseFile
}

const customScriptPath = await this.packager.getResource(this.options.script, "installer.nsi")
const script = await readFile(customScriptPath || path.join(this.nsisTemplatesDir, "installer.nsi"), "utf8")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!include "nsProcess.nsh"

# http://nsis.sourceforge.net/Allow_only_one_installer_instance
!macro ALLOW_ONLY_ONE_INSTALLER_INSTACE
!macro ALLOW_ONLY_ONE_INSTALLER_INSTANCE
BringToFront
!define /ifndef SYSTYPE_PTR p ; NSIS v3.0+
System::Call 'kernel32::CreateMutex(${SYSTYPE_PTR}0, i1, t"${APP_GUID}")?e'
Expand Down
5 changes: 5 additions & 0 deletions templates/nsis/boringInstaller.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "StartApp"

!ifdef LICENSE_FILE
!insertmacro MUI_PAGE_LICENSE "${LICENSE_FILE}"
!endif

!ifndef INSTALL_MODE_PER_ALL_USERS
!insertmacro PAGE_INSTALL_MODE
Function GuiInit
Expand All @@ -20,6 +24,7 @@

!define MUI_CUSTOMFUNCTION_GUIINIT GuiInit
!endif

!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!else
Expand Down
6 changes: 3 additions & 3 deletions templates/nsis/installer.nsi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!include "common.nsh"
!include "MUI2.nsh"
!include "multiUser.nsh"
!include "allowOnlyOneInstallerInstace.nsh"
!include "allowOnlyOneInstallerInstance.nsh"

!ifdef INSTALL_MODE_PER_ALL_USERS
!ifdef BUILD_UNINSTALLER
Expand Down Expand Up @@ -41,10 +41,10 @@ Function .onInit
!insertmacro initMultiUser

!ifdef ONE_CLICK
!insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTACE
!insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTANCE
!else
${IfNot} ${UAC_IsInnerInstance}
!insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTACE
!insertmacro ALLOW_ONLY_ONE_INSTALLER_INSTANCE
${EndIf}
!endif

Expand Down
4 changes: 4 additions & 0 deletions templates/nsis/oneClick.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
!endif
!endif

!ifdef LICENSE_FILE
!insertmacro MUI_PAGE_LICENSE "${LICENSE_FILE}"
!endif

!insertmacro MUI_PAGE_INSTFILES
!ifdef BUILD_UNINSTALLER
!insertmacro MUI_UNPAGE_INSTFILES
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hi!
9 changes: 7 additions & 2 deletions test/src/nsisTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test.ifDevOrLinuxCi("perMachine, no run after finish", app({
}, {
projectDirCreated: projectDir => {
let headerIconPath = path.join(projectDir, "build", "foo.ico")
return copy(getTestAsset("headerIcon.ico"), headerIconPath)
return BluebirdPromise.all([copy(getTestAsset("headerIcon.ico"), headerIconPath), copy(getTestAsset("license.txt"), path.join(projectDir, "build", "license.txt"))])
},
packed: context => {
return doTest(context.outDir, false)
Expand Down Expand Up @@ -134,7 +134,12 @@ test.ifNotCiOsx("boring", app({
},
}
}
}, {signed: true}))
}, {
signed: true,
projectDirCreated: projectDir => {
return copy(getTestAsset("license.txt"), path.join(projectDir, "build", "license.txt"))
},
}))

test.ifNotCiOsx("boring, only perMachine", app({
targets: nsisTarget,
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2480,8 +2480,8 @@ map-stream@~0.1.0:
resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194"

markdown-it@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.0.0.tgz#e66255497a0e409e816fbc67807975f4f26f6f82"
version "8.0.1"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.0.1.tgz#ff60e2103d17896cb6c57407baa9766f916495cb"
dependencies:
argparse "^1.0.7"
entities "~1.1.1"
Expand Down Expand Up @@ -3436,9 +3436,9 @@ sort-keys@^1.1.1:
dependencies:
is-plain-obj "^1.0.0"

source-map-support@^0.4.2, source-map-support@^0.4.3, source-map-support@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.4.tgz#0df5765a05a560c91bc8f8641cf79f2affc0322e"
source-map-support@^0.4.2, source-map-support@^0.4.3, source-map-support@^0.4.4, source-map-support@^0.4.5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.5.tgz#4438df4219e1b3c7feb674614b4c67f9722db1e4"
dependencies:
source-map "^0.5.3"

Expand Down

0 comments on commit a0e7131

Please sign in to comment.