Skip to content

Commit

Permalink
feat: icon relative or to build resources, or to project
Browse files Browse the repository at this point in the history
Close #1276
  • Loading branch information
develar committed Feb 19, 2017
1 parent 9359357 commit 3f3419a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 25 deletions.
14 changes: 7 additions & 7 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Please see [Windows AppX docs](https://msdn.microsoft.com/en-us/library/windows/
| --- | ---
| background | <a name="DmgOptions-background"></a><p>The path to background image (default: <code>build/background.tiff</code> or <code>build/background.png</code> if exists). The resolution of this file determines the resolution of the installer window. If background is not specified, use <code>window.size</code>. Default locations expected background size to be 540x380.</p> <p>See [DMG with Retina background support](http://stackoverflow.com/a/11204769/1910191).</p>
| backgroundColor | <a name="DmgOptions-backgroundColor"></a>The background color (accepts css colors). Defaults to `#ffffff` (white) if no background image.
| icon | <a name="DmgOptions-icon"></a>The path to DMG icon (volume icon), which will be shown when mounted. Defaults to application icon (`build/icon.icns`).
| icon | <a name="DmgOptions-icon"></a><p>The path to DMG icon (volume icon), which will be shown when mounted, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to the application icon (<code>build/icon.icns</code>).</p>
| iconSize | <a name="DmgOptions-iconSize"></a>The size of all the icons inside the DMG. Defaults to 80.
| iconTextSize | <a name="DmgOptions-iconTextSize"></a>The size of all the icon texts inside the DMG. Defaults to 12.
| title | <a name="DmgOptions-title"></a><p>The title of the produced DMG, which will be shown when mounted (volume name). Defaults to <code>${productName} ${version}</code></p> <p>Macro <code>${productName}</code>, <code>${version}</code> and <code>${name}</code> are supported.</p>
Expand Down Expand Up @@ -143,7 +143,7 @@ On Windows works only if [nsis.perMachine](https://github.com/electron-userland/
| desktop | <a name="LinuxBuildOptions-desktop"></a>The [Desktop file](https://developer.gnome.org/integration-guide/stable/desktop-files.html.en) entries (name to value).
| depends | <a name="LinuxBuildOptions-depends"></a>Package dependencies. Defaults to `["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3"]` for `deb`.
| executableName | <a name="LinuxBuildOptions-executableName"></a><p>The executable name. Defaults to <code>productName</code>.</p> <p>Cannot be specified per target, allowed only in the <code>linux</code>.</p>
| icon | <a name="LinuxBuildOptions-icon"></a><p>The path to icon set directory, relative to <code>build</code> (build resources directory). The icon filename must contain the size (e.g. 32x32.png) of the icon. By default will be generated automatically based on the macOS icns file.</p>
| icon | <a name="LinuxBuildOptions-icon"></a><p>The path to icon set directory, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. The icon filename must contain the size (e.g. 32x32.png) of the icon. By default will be generated automatically based on the macOS icns file.</p>

<a name="MacOptions"></a>
### `mac` macOS Specific Options
Expand Down Expand Up @@ -180,11 +180,11 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
| allowToChangeInstallationDirectory | <a name="NsisOptions-allowToChangeInstallationDirectory"></a>*boring installer only.* Whether to allow user to change installation directory. Defaults to `false`.
| runAfterFinish | <a name="NsisOptions-runAfterFinish"></a>*one-click installer only.* Run application after finish. Defaults to `true`.
| guid | <a name="NsisOptions-guid"></a>See [GUID vs Application Name](https://github.com/electron-userland/electron-builder/wiki/NSIS#guid-vs-application-name).
| installerIcon | <a name="NsisOptions-installerIcon"></a>The path to installer icon. Defaults to `build/installerIcon.ico` or application icon.
| installerHeader | <a name="NsisOptions-installerHeader"></a>*boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp`
| 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`
| 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`
| 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.
| installerIcon | <a name="NsisOptions-installerIcon"></a><p>The path to installer icon, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to <code>build/installerIcon.ico</code> or application icon.</p>
| installerHeader | <a name="NsisOptions-installerHeader"></a><p>*boring installer only.* <code>MUI_HEADERIMAGE</code>, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to <code>build/installerHeader.bmp</code></p>
| installerSidebar | <a name="NsisOptions-installerSidebar"></a><p>*boring installer only.* <code>MUI_WELCOMEFINISHPAGE_BITMAP</code>, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to <code>build/installerSidebar.bmp</code> or <code>${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp</code></p>
| uninstallerSidebar | <a name="NsisOptions-uninstallerSidebar"></a><p>*boring installer only.* <code>MUI_UNWELCOMEFINISHPAGE_BITMAP</code>, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to <code>installerSidebar</code> option or <code>build/uninstallerSidebar.bmp</code> or <code>build/installerSidebar.bmp</code> or <code>${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp</code></p>
| installerHeaderIcon | <a name="NsisOptions-installerHeaderIcon"></a><p>*one-click installer only.* The path to header icon (above the progress bar), relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to <code>build/installerHeaderIcon.ico</code> or application icon.</p>
| 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`.
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/options/linuxOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions {
readonly executableName?: string | null

/**
The path to icon set directory, relative to `build` (build resources directory). The icon filename must contain the size (e.g. 32x32.png) of the icon.
The path to icon set directory, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. The icon filename must contain the size (e.g. 32x32.png) of the icon.
By default will be generated automatically based on the macOS icns file.
*/
readonly icon?: string
Expand Down
5 changes: 3 additions & 2 deletions packages/electron-builder/src/options/macOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlatformSpecificBuildOptions } from "../metadata"
import { TargetSpecificOptions } from "electron-builder-core"
import { PlatformSpecificBuildOptions } from "../metadata"

export type MacOsTargetName = "default" | "dmg" | "mas" | "pkg" | "7z" | "zip" | "tar.xz" | "tar.lz" | "tar.gz" | "tar.bz2" | "dir"

Expand Down Expand Up @@ -109,7 +109,8 @@ export interface DmgOptions extends TargetSpecificOptions {
readonly backgroundColor?: string | null

/**
The path to DMG icon (volume icon), which will be shown when mounted. Defaults to application icon (`build/icon.icns`).
The path to DMG icon (volume icon), which will be shown when mounted, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory.
Defaults to the application icon (`build/icon.icns`).
*/
readonly icon?: string | null

Expand Down
15 changes: 10 additions & 5 deletions packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,32 @@ export interface NsisOptions {
readonly guid?: string | null

/**
The path to installer icon. Defaults to `build/installerIcon.ico` or application icon.
The path to installer icon, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory.
Defaults to `build/installerIcon.ico` or application icon.
*/
readonly installerIcon?: string | null

/**
*boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp`
*boring installer only.* `MUI_HEADERIMAGE`, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory.
Defaults to `build/installerHeader.bmp`
*/
readonly installerHeader?: string | null

/**
*boring installer only.* `MUI_WELCOMEFINISHPAGE_BITMAP`, relative to the project directory. Defaults to `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
*boring installer only.* `MUI_WELCOMEFINISHPAGE_BITMAP`, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory.
Defaults to `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
*/
readonly installerSidebar?: string | null

/**
*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`
*boring installer only.* `MUI_UNWELCOMEFINISHPAGE_BITMAP`, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory.
Defaults to `installerSidebar` option or `build/uninstallerSidebar.bmp` or `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp`
*/
readonly uninstallerSidebar?: string | null

/**
*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.
*one-click installer only.* The path to header icon (above the progress bar), relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory.
Defaults to `build/installerHeaderIcon.ico` or application icon.
*/
readonly installerHeaderIcon?: string | null

Expand Down
18 changes: 13 additions & 5 deletions packages/electron-builder/src/targets/LinuxTargetHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { debug, exec, isEmptyOrSpaces } from "electron-builder-util"
import { statOrNull } from "electron-builder-util/out/fs"
import { ensureDir, outputFile, readdir } from "fs-extra-p"
import * as path from "path"
import { LinuxPackager } from "../linuxPackager"
Expand All @@ -18,8 +19,15 @@ export class LinuxTargetHelper {

// must be name without spaces and other special characters, but not product name used
private async computeDesktopIcons(): Promise<Array<Array<string>>> {
if (this.packager.platformSpecificBuildOptions.icon != null) {
const iconDir = path.resolve(this.packager.buildResourcesDir, this.packager.platformSpecificBuildOptions.icon)
const packager = this.packager
let customIconSetDir = packager.platformSpecificBuildOptions.icon
if (customIconSetDir != null) {
let iconDir = path.resolve(packager.buildResourcesDir, customIconSetDir)
const stat = await statOrNull(iconDir)
if (stat == null || !stat.isDirectory()) {
iconDir = path.resolve(packager.projectDir, customIconSetDir)
}

try {
return await this.iconsFromDir(iconDir)
}
Expand All @@ -36,12 +44,12 @@ export class LinuxTargetHelper {
}
}

const resourceList = await this.packager.resourceList
const resourceList = await packager.resourceList
if (resourceList.includes("icons")) {
return await this.iconsFromDir(path.join(this.packager.buildResourcesDir, "icons"))
return await this.iconsFromDir(path.join(packager.buildResourcesDir, "icons"))
}
else {
const iconDir = await this.packager.getTempFile("linux.iconset")
const iconDir = await packager.getTempFile("linux.iconset")
ensureDir(iconDir)
return await this.createFromIcns(iconDir)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class DmgTarget extends Target {
}
else {
const volumeIcon = `${volumePath}/.VolumeIcon.icns`
promises.push(copy(path.resolve(packager.projectDir, specification.icon), volumeIcon))
promises.push(copy((await packager.getResource(specification.icon))!, volumeIcon))
env.volumeIcon = volumeIcon
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ async@^1.4.0, async@^1.4.2, async@^1.5.0:
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

async@^2.0.0, async@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/async/-/async-2.1.4.tgz#2d2160c7788032e4dd6cbe2502f1f9a2c8f6cde4"
version "2.1.5"
resolved "https://registry.yarnpkg.com/async/-/async-2.1.5.tgz#e587c68580994ac67fc56ff86d3ac56bdbe810bc"
dependencies:
lodash "^4.14.0"

Expand Down Expand Up @@ -2785,8 +2785,8 @@ right-align@^0.1.1:
align-text "^0.1.1"

rimraf@^2.4.3, rimraf@^2.4.4:
version "2.5.4"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
version "2.6.0"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.0.tgz#89b8a0fe432b9ff9ec9a925a00b6cdb3a91bbada"
dependencies:
glob "^7.0.5"

Expand Down

0 comments on commit 3f3419a

Please sign in to comment.