Skip to content

Commit

Permalink
feat: remove OriginalFilename, add LegalTrademarks, add ProductVersio…
Browse files Browse the repository at this point in the history
…n for NSIS

Closes #655
  • Loading branch information
develar committed Aug 9, 2016
1 parent 50d27bf commit 6a906ac
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 128 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For a production app you need to sign your application, see [Where to buy code s
```json
"build": {
"appId": "your.id",
"app-category-type": "your.app.category.type",
"category": "your.app.category.type",
"win": {
"iconUrl": "(windows-only) https link to icon"
}
Expand Down
3 changes: 2 additions & 1 deletion docs/Multi Platform Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Use [brew](http://brew.sh) to install required packages.

### To build app for Windows on MacOS:
```
brew install Caskroom/cask/xquartz wine mono
brew install wine --with-win64 --without-x11 --devel
brew install mono
```

### To build app for Linux on MacOS:
Expand Down
8 changes: 5 additions & 3 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ Here documented only `electron-builder` specific options:
| Name | Description
| --- | ---
| appId | <a name="BuildMetadata-appId"></a><p>The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows.</p> <p>For windows only NSIS target supports it. Squirrel.Windows is not fixed yet.</p> <p>Defaults to <code>com.electron.${name}</code>. It is strongly recommended that an explicit ID be set.</p>
| app-category-type | <a name="BuildMetadata-app-category-type"></a><p>*macOS-only.* The application category type, as shown in the Finder via *View -&gt; Arrange by Application Category* when viewing the Applications directory.</p> <p>For example, <code>app-category-type=public.app-category.developer-tools</code> will set the application category to *Developer Tools*.</p> <p>Valid values are listed in [Apple’s documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).</p>
| asar | <a name="BuildMetadata-asar"></a><p>Whether to package the application’s source code into an archive, using [Electron’s archive format](https://github.com/electron/asar). Defaults to <code>true</code>. Reasons why you may want to disable this feature are described in [an application packaging tutorial in Electron’s documentation](http://electron.atom.io/docs/latest/tutorial/application-packaging/#limitations-on-node-api/).</p> <p>Or you can pass object of any asar options.</p> <p>electron-builder detects node modules that must be unpacked automatically, you don’t need to explicitly set <code>asar.unpackDir</code> - please file issue if this doesn’t work.</p>
| category | <a name="BuildMetadata-category"></a><p>*macOS-only.* The application category type, as shown in the Finder via *View -&gt; Arrange by Application Category* when viewing the Applications directory.</p> <p>For example, <code>&quot;category&quot;: &quot;public.app-category.developer-tools&quot;</code> will set the application category to *Developer Tools*.</p> <p>Valid values are listed in [Apple’s documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).</p>
| copyright | <a name="BuildMetadata-copyright"></a>The human-readable copyright line for the app. Defaults to `Copyright © year author`.
| asar | <a name="BuildMetadata-asar"></a><p>Whether to package the application’s source code into an archive, using [Electron’s archive format](https://github.com/electron/asar). Defaults to <code>true</code>. Reasons why you may want to disable this feature are described in [an application packaging tutorial in Electron’s documentation](http://electron.atom.io/docs/latest/tutorial/application-packaging/#limitations-on-node-api/).</p> <p>Or you can pass object of any asar options.</p> <p>Node modules, that must be unpacked, will be detected automatically, you don’t need to explicitly set <code>asar.unpackDir</code> - please file issue if this doesn’t work.</p>
| productName | <a name="BuildMetadata-productName"></a>See [AppMetadata.productName](#AppMetadata-productName).
| files | <a name="BuildMetadata-files"></a><p>A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the [app directory](#MetadataDirectories-app), which specifies which files to include when copying files to create the package.</p> <p>See [File Patterns](#multiple-glob-patterns).</p>
| extraResources | <a name="BuildMetadata-extraResources"></a><p>A [glob patterns](https://www.npmjs.com/package/glob#glob-primer) relative to the project directory, when specified, copy the file or directory with matching names directly into the app’s resources directory (<code>Contents/Resources</code> for MacOS, <code>resources</code> for Linux/Windows).</p> <p>Glob rules the same as for [files](#multiple-glob-patterns).</p>
| extraFiles | <a name="BuildMetadata-extraFiles"></a>The same as [extraResources](#BuildMetadata-extraResources) but copy into the app's content directory (`Contents` for MacOS, root directory for Linux/Windows).
| fileAssociations | <a name="BuildMetadata-fileAssociations"></a>File associations. See [.build.fileAssociations](#FileAssociation).
| mac | <a name="BuildMetadata-mac"></a>See [.build.mac](#MacOptions).
| dmg | <a name="BuildMetadata-dmg"></a>See [.build.dmg](#DmgOptions).
| mas | <a name="BuildMetadata-mas"></a>See [.build.mas](#MasBuildOptions).
Expand All @@ -66,7 +68,6 @@ Here documented only `electron-builder` specific options:
| compression | <a name="BuildMetadata-compression"></a>The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
| afterPack | <a name="BuildMetadata-afterPack"></a>*programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned.
| npmRebuild | <a name="BuildMetadata-npmRebuild"></a>Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`.
| fileAssociations | <a name="BuildMetadata-fileAssociations"></a>File associations. (NSIS only for now).

<a name="MacOptions"></a>
### `.build.mac`
Expand Down Expand Up @@ -119,6 +120,7 @@ Windows specific build options.
| remoteToken | <a name="WinBuildOptions-remoteToken"></a>*Squirrel.Windows-only.* Authentication token for remote updates
| signingHashAlgorithms | <a name="WinBuildOptions-signingHashAlgorithms"></a>Array of signing algorithms used. Defaults to `['sha1', 'sha256']`
| icon | <a name="WinBuildOptions-icon"></a>The path to application icon. Defaults to `build/icon.ico` (consider using this convention instead of complicating your configuration).
| legalTrademarks | <a name="WinBuildOptions-legalTrademarks"></a>The trademarks and registered trademarks.

<a name="NsisOptions"></a>
### `.build.nsis`
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint": "tslint 'src/**/*.ts' 'test/src/**/*.ts'",
"pretest": "npm run compile && npm run lint",
"test": "node ./test/out/helpers/runTests.js",
"semantic-release": "semantic-release pre && cd nsis-auto-updater && npm install --production && cd .. && npm publish && semantic-release post",
"semantic-release": "semantic-release pre && cd nsis-auto-updater && npm install --production && npm prune && cd .. && npm publish && semantic-release post",
"//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)",
"update-wiki": "git subtree split -b wiki --prefix docs/ && git push -f wiki wiki:master",
"whitespace": "whitespace 'src/**/*.ts'",
Expand Down Expand Up @@ -69,7 +69,7 @@
"debug": "^2.2.0",
"electron-download": "^2.1.2",
"electron-osx-sign": "^0.4.0-beta4",
"electron-winstaller-fixed": "~3.1.0",
"electron-winstaller-fixed": "~4.0.0",
"extract-zip": "^1.5.0",
"fs-extra-p": "^1.0.6",
"hosted-git-info": "^2.1.5",
Expand All @@ -84,7 +84,6 @@
"pretty-ms": "^2.1.0",
"progress": "^1.1.8",
"progress-stream": "^1.2.0",
"rcedit": "^0.5.1",
"sanitize-filename": "^1.6.0",
"semver": "^5.3.0",
"source-map-support": "^0.4.2",
Expand All @@ -110,7 +109,7 @@
"@types/progress": "^1.1.27",
"@types/semver": "^5.3.28",
"@types/source-map-support": "^0.2.27",
"ava-tf": "^0.15.4",
"ava-tf": "^0.16.0",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
Expand Down
27 changes: 16 additions & 11 deletions src/appInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ const __awaiter = require("./util/awaiter")

export class AppInfo {
readonly description = smarten(this.metadata.description!)

// windows-only
versionString = {
CompanyName: this.companyName,
FileDescription: this.description,
ProductName: this.productName,
InternalName: this.productName,
LegalCopyright: this.copyright,
}

readonly version: string
readonly buildNumber: string
readonly buildVersion: string
Expand Down Expand Up @@ -69,12 +59,27 @@ export class AppInfo {
return this.metadata.name
}

get category() {
const metadata = this.devMetadata.build
const old = (<any>metadata)["app-category-type"]
if (old != null) {
warn('"app-category-type" is deprecated — please use "category" instead')
}
return metadata.category || old
}

get productName(): string {
return getProductName(this.metadata, this.devMetadata)
}

get copyright(): string {
const copyright = (<any>this.devMetadata.build)["app-copyright"]
const metadata = this.devMetadata.build
const old = (<any>metadata)["app-copyright"]
if (old != null) {
warn('"app-copyright" is deprecated — please use "copyright" instead')
}

const copyright = metadata.copyright || old
if (copyright != null) {
return copyright
}
Expand Down
2 changes: 1 addition & 1 deletion src/errorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const buildIsMissed = `Please specify 'build' configuration in the develo
build: {
"appId": "your.id",
"app-category-type": "your.app.category.type"
"category": "your.app.category.type"
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/linuxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FpmTarget from "./targets/fpm"
import { createCommonTarget, DEFAULT_TARGET } from "./targets/targetFactory"
import { LinuxTargetHelper } from "./targets/LinuxTargetHelper"
import AppImageTarget from "./targets/appImage"
import { rename } from "fs-extra-p"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./util/awaiter")
Expand Down Expand Up @@ -65,6 +66,10 @@ export class LinuxPackager extends PlatformPackager<LinuxBuildOptions> {
postAsyncTasks.push(this.packageInDistributableFormat(outDir, appOutDir, arch, targets))
}

protected postInitApp(appOutDir: string): Promise<any> {
return rename(path.join(appOutDir, "electron"), path.join(appOutDir, this.appInfo.productFilename))
}

protected async packageInDistributableFormat(outDir: string, appOutDir: string, arch: Arch, targets: Array<Target>): Promise<any> {
// todo fix fpm - if run in parallel, get strange tar errors
for (let t of targets) {
Expand Down
31 changes: 20 additions & 11 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,27 @@ export interface BuildMetadata {
*/
readonly appId?: string | null

// deprecated
readonly "app-bundle-id"?: string | null

/*
*macOS-only.* The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.
For example, `app-category-type=public.app-category.developer-tools` will set the application category to *Developer Tools*.
For example, `"category": "public.app-category.developer-tools"` will set the application category to *Developer Tools*.
Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).
*/
readonly "app-category-type"?: string | null
readonly category?: string | null

/*
The human-readable copyright line for the app. Defaults to `Copyright © year author`.
*/
readonly copyright?: string | null

/*
Whether to package the application's source code into an archive, using [Electron's archive format](https://github.com/electron/asar). Defaults to `true`.
Reasons why you may want to disable this feature are described in [an application packaging tutorial in Electron's documentation](http://electron.atom.io/docs/latest/tutorial/application-packaging/#limitations-on-node-api/).
Or you can pass object of any asar options.
electron-builder detects node modules that must be unpacked automatically, you don't need to explicitly set `asar.unpackDir` - please file issue if this doesn't work.
Node modules, that must be unpacked, will be detected automatically, you don't need to explicitly set `asar.unpackDir` - please file issue if this doesn't work.
*/
readonly asar?: AsarOptions | boolean | null

Expand Down Expand Up @@ -142,6 +144,11 @@ export interface BuildMetadata {
*/
readonly extraFiles?: Array<string> | string | null

/*
File associations. See [.build.fileAssociations](#FileAssociation).
*/
readonly fileAssociations?: Array<FileAssociation> | FileAssociation

/*
See [.build.mac](#MacOptions).
*/
Expand Down Expand Up @@ -194,10 +201,8 @@ export interface BuildMetadata {

readonly icon?: string | null

/*
File associations. (NSIS only for now).
*/
readonly fileAssociations?: Array<FileAssociation> | FileAssociation
// deprecated
readonly "app-bundle-id"?: string | null
}

export interface AfterPackContext {
Expand Down Expand Up @@ -335,14 +340,18 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions {
Array of signing algorithms used. Defaults to `['sha1', 'sha256']`
*/
readonly signingHashAlgorithms?: Array<string> | null
readonly signcodePath?: string | null

/*
The path to application icon. Defaults to `build/icon.ico` (consider using this convention instead of complicating your configuration).
*/
readonly icon?: string | null

readonly fileAssociations?: Array<FileAssociation> | FileAssociation

/*
The trademarks and registered trademarks.
*/
readonly legalTrademarks?: string | null
}

/*
Expand Down
20 changes: 4 additions & 16 deletions src/packager/dirPackager.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Promise as BluebirdPromise } from "bluebird"
import { emptyDir, rename } from "fs-extra-p"
import { emptyDir } from "fs-extra-p"
import { warn } from "../util/log"
import { AppInfo } from "../appInfo"
import * as path from "path"

const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("electron-download"))
const extract: any = BluebirdPromise.promisify(require("extract-zip"))
Expand All @@ -12,7 +11,6 @@ const __awaiter = require("../util/awaiter")

export interface ElectronPackagerOptions {
"extend-info"?: string
"app-category-type"?: string

protocols?: any

Expand All @@ -25,13 +23,6 @@ export interface ElectronPackagerOptions {
ignore?: any
}

const supportedPlatforms: any = {
// Maps to module ID for each platform (lazy-required if used)
darwin: "./mac",
mas: "./mac", // map to darwin
win32: "./win32"
}

function createDownloadOpts(opts: any, platform: string, arch: string, electronVersion: string) {
const downloadOpts = Object.assign({
cache: opts.cache,
Expand All @@ -58,13 +49,10 @@ export async function pack(opts: ElectronPackagerOptions, out: string, platform:
]))[0]
await extract(zipPath, {dir: out})

if (platform === "linux") {
await BluebirdPromise.all([
initializeApp(),
rename(path.join(out, "electron"), path.join(out, opts.appInfo.productFilename))
])
if (platform === "darwin" || platform === "mas") {
await(<any>require("./mac")).createApp(opts, out, initializeApp)
}
else {
await (<any>require(supportedPlatforms[platform])).createApp(opts, out, initializeApp)
await initializeApp()
}
}
28 changes: 8 additions & 20 deletions src/packager/mac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { rename, readFile, writeFile, copy } from "fs-extra-p"
import * as path from "path"
import { parse as parsePlist, build as buildPlist } from "plist"
import { Promise as BluebirdPromise } from "bluebird"
import { use } from "../util/util"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("../util/awaiter")
Expand Down Expand Up @@ -52,15 +53,9 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
Object.assign(appPlist, parsePlist(fileContents[4]))
}

// Now set fields based on explicit options

const appBundleIdentifier = filterCFBundleIdentifier(appInfo.id)
const helperBundleIdentifier = filterCFBundleIdentifier(opts["helper-bundle-id"] || `${appBundleIdentifier}.helper`)

const buildVersion = appInfo.buildVersion
const appCategoryType = opts["app-category-type"]
const humanReadableCopyright = appInfo.copyright

appPlist.CFBundleDisplayName = appInfo.productName
appPlist.CFBundleIdentifier = appBundleIdentifier
appPlist.CFBundleName = appInfo.productName
Expand All @@ -78,13 +73,11 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
helperNPPlist.CFBundleName = `${appInfo.productName} Helper NP`
helperNPPlist.CFBundleExecutable = `${appFilename} Helper NP`

if (appInfo.version != null) {
appPlist.CFBundleShortVersionString = appPlist.CFBundleVersion = appInfo.version
}

if (buildVersion != null) {
appPlist.CFBundleVersion = buildVersion
}
use(appInfo.version, it => {
appPlist.CFBundleShortVersionString = it
appPlist.CFBundleVersion = it
})
use(appInfo.buildVersion, it => appPlist.CFBundleVersion = it)

if (opts.protocols && opts.protocols.length) {
appPlist.CFBundleURLTypes = opts.protocols.map(function (protocol: any) {
Expand All @@ -95,13 +88,8 @@ export async function createApp(opts: ElectronPackagerOptions, appOutDir: string
})
}

if (appCategoryType) {
appPlist.LSApplicationCategoryType = appCategoryType
}

if (humanReadableCopyright) {
appPlist.NSHumanReadableCopyright = humanReadableCopyright
}
use(appInfo.category, it => appPlist.LSApplicationCategoryType = it)
use(appInfo.copyright, it => appPlist.NSHumanReadableCopyright = it)

const promises: Array<BluebirdPromise<any | n>> = [
writeFile(appPlistFilename, buildPlist(appPlist)),
Expand Down
23 changes: 0 additions & 23 deletions src/packager/win32.ts

This file was deleted.

Loading

0 comments on commit 6a906ac

Please sign in to comment.