diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index a4b01e2d88d..58363776b9e 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -31,6 +31,7 @@ postinstall productbuild promisify + psmdcp repos rimraf templating diff --git a/.idea/runConfigurations/BuildTest.xml b/.idea/runConfigurations/BuildTest.xml index 4fc2604c6a4..0af9c0cc35b 100644 --- a/.idea/runConfigurations/BuildTest.xml +++ b/.idea/runConfigurations/BuildTest.xml @@ -1,5 +1,5 @@ - + diff --git a/.idea/runConfigurations/osxPackagerTest.xml b/.idea/runConfigurations/osxPackagerTest.xml index 23e26f659c0..4a823a86878 100644 --- a/.idea/runConfigurations/osxPackagerTest.xml +++ b/.idea/runConfigurations/osxPackagerTest.xml @@ -1,5 +1,5 @@ - + diff --git a/docs/Options.md b/docs/Options.md index fe4bee15ac0..a1befa014e1 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -70,7 +70,7 @@ See all [appdmg options](https://www.npmjs.com/package/appdmg#json-specification | --- | --- | icon | The path to icon, which will be shown when mounted (default: `build/icon.icns`). | background | The path to background (default: `build/background.png`). The resolution of this file determines the resolution of the installer window. -| target | Target package type: list of `default`, `dmg`, `zip`, `mas`. +| target | Target package type: list of `default`, `dmg`, `zip`, `mas`, `7z`. ### `.build.win` diff --git a/package.json b/package.json index 2d87139db41..be0ea4bef41 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "electron-osx-sign-tf": "^0.4.0-beta.0", "electron-packager-tf": "^7.0.2-beta.0", "electron-winstaller-fixed": "~2.4.0-beta.0", - "fs-extra-p": "^0.3.0", + "fs-extra-p": "^0.4.0", "globby": "^4.0.0", "hosted-git-info": "^2.1.4", "image-size": "^0.5.0", diff --git a/src/metadata.ts b/src/metadata.ts index ee65cf6af9e..2eff159fdd7 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -160,7 +160,7 @@ export interface OsXBuildOptions extends PlatformSpecificBuildOptions { readonly background?: string /* - Target package type: list of `default`, `dmg`, `zip`, `mas`. + Target package type: list of `default`, `dmg`, `zip`, `mas`, `7z`. */ readonly target?: Array } diff --git a/src/osxPackager.ts b/src/osxPackager.ts index b495272cb3b..3f070e8f84c 100644 --- a/src/osxPackager.ts +++ b/src/osxPackager.ts @@ -1,4 +1,4 @@ -import { PlatformPackager, BuildInfo } from "./platformPackager" +import { PlatformPackager, BuildInfo, normalizeTargets } from "./platformPackager" import { Platform, OsXBuildOptions } from "./metadata" import * as path from "path" import { Promise as BluebirdPromise } from "bluebird" @@ -14,7 +14,7 @@ const __awaiter = require("./awaiter") export default class OsXPackager extends PlatformPackager { codeSigningInfo: Promise - readonly target: Array + readonly targets: Array constructor(info: BuildInfo, cleanupTasks: Array<() => Promise>) { super(info) @@ -28,41 +28,45 @@ export default class OsXPackager extends PlatformPackager { this.codeSigningInfo = BluebirdPromise.resolve(null) } - let target = this.customBuildOptions == null ? null : this.customBuildOptions.target - if (target != null) { - target = Array.isArray(target) ? target : [target] - target = target.map(it => it.toLowerCase().trim()) - for (let t of target) { - if (t !== "default" && t !== "dmg" && t !== "zip" && t !== "mas") { - throw new Error("Unknown target: " + t) + const targets = normalizeTargets(this.customBuildOptions == null ? null : this.customBuildOptions.target) + if (targets != null) { + for (let target of targets) { + if (target !== "default" && target !== "dmg" && target !== "zip" && target !== "mas" && target !== "7z") { + throw new Error("Unknown target: " + target) } } } - this.target = target == null ? ["default"] : target + this.targets = targets == null ? ["default"] : targets } get platform() { return Platform.OSX } - protected computeAppOutDir(outDir: string, arch: string): string { - return this.target.includes("mas") ? path.join(outDir, `${this.appName}-mas-${arch}`) : super.computeAppOutDir(outDir, arch) - } + async pack(outDir: string, arch: string, postAsyncTasks: Array>): Promise { + const packOptions = this.computePackOptions(outDir, arch) + let nonMasPromise: Promise = null + if (this.targets.length > 1 || this.targets[0] !== "mas") { + const appOutDir = this.computeAppOutDir(outDir, arch) + nonMasPromise = this.doPack(packOptions, outDir, appOutDir, arch) + .then(() => this.sign(appOutDir, false)) + .then(() => postAsyncTasks.push(this.packageInDistributableFormat(outDir, appOutDir, arch))) + } - async doPack(outDir: string, appOutDir: string, arch: string): Promise { - await super.doPack(outDir, appOutDir, arch) - await this.sign(appOutDir, await this.codeSigningInfo) - } + if (this.targets.includes("mas")) { + // osx-sign - disable warning + const appOutDir = path.join(outDir, `${this.appName}-mas-${arch}`) + await this.doPack(Object.assign({}, packOptions, {platform: "mas", "osx-sign": false}), outDir, appOutDir, arch) + await this.sign(appOutDir, true) + } - protected beforePack(options: any): void { - if (this.target.includes("mas")) { - options.platform = "mas" + if (nonMasPromise != null) { + await nonMasPromise } - // disable warning - options["osx-sign"] = false } - private async sign(appOutDir: string, codeSigningInfo: CodeSigningInfo): Promise { + private async sign(appOutDir: string, isMas: boolean): Promise { + let codeSigningInfo = await this.codeSigningInfo if (codeSigningInfo == null) { codeSigningInfo = { name: this.options.sign || process.env.CSC_NAME, @@ -77,7 +81,6 @@ export default class OsXPackager extends PlatformPackager { log("Signing app") - const isMas = this.target.includes("mas") const baseSignOptions: BaseSignOptions = { app: path.join(appOutDir, this.appName + ".app"), platform: isMas ? "mas" : "darwin" @@ -133,10 +136,10 @@ export default class OsXPackager extends PlatformPackager { } packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise { - const artifactPath = path.join(appOutDir, `${this.appName}-${this.metadata.version}.dmg`) const promises: Array> = [] - if (this.target.includes("dmg") || this.target.includes("default")) { + if (this.targets.includes("dmg") || this.targets.includes("default")) { + const artifactPath = path.join(appOutDir, `${this.appName}-${this.metadata.version}.dmg`) promises.push(new BluebirdPromise(async(resolve, reject) => { log("Creating DMG") const dmgOptions = { @@ -164,24 +167,34 @@ export default class OsXPackager extends PlatformPackager { .then(() => this.dispatchArtifactCreated(artifactPath, `${this.metadata.name}-${this.metadata.version}.dmg`))) } - if (this.target.includes("zip") || this.target.includes("default")) { - promises.push(this.zipMacApp(appOutDir) - .then(it => this.dispatchArtifactCreated(it, `${this.metadata.name}-${this.metadata.version}-mac.zip`))) + for (let target of this.targets) { + if (target !== "mas" && target !== "dmg") { + const format = target === "default" ? "zip" : target + log("Creating OS X " + format) + // for default we use mac to be compatible with Squirrel.Mac + const classifier = target === "default" ? "mac" : "osx" + promises.push(this.archiveApp(appOutDir, format, classifier) + .then(it => this.dispatchArtifactCreated(it, `${this.metadata.name}-${this.metadata.version}-${classifier}.${format}`))) + } } - return BluebirdPromise.all(promises) } - private zipMacApp(outDir: string): Promise { - log("Creating ZIP for Squirrel.Mac") - // we use app name here - see https://github.com/electron-userland/electron-builder/pull/204 - const resultPath = `${this.appName}-${this.metadata.version}-mac.zip` - const args = ["a", "-mm=" + (this.devMetadata.build.compression === "store" ? "Copy" : "Deflate"), "-bb" + (debug.enabled ? "3" : "0"), "-bd"] - if (this.devMetadata.build.compression === "maximum") { + private archiveApp(outDir: string, format: string, classifier: string): Promise { + const args = ["a", "-bb" + (debug.enabled ? "3" : "0"), "-bd"] + const compression = this.devMetadata.build.compression + const storeOnly = compression === "store" + if (format === "zip" || storeOnly) { + args.push("-mm=" + (storeOnly ? "Copy" : "Deflate")) + } + if (compression === "maximum") { // http://superuser.com/a/742034 //noinspection SpellCheckingInspection args.push("-mfb=258", "-mpass=15") } + + // we use app name here - see https://github.com/electron-userland/electron-builder/pull/204 + const resultPath = `${this.appName}-${this.metadata.version}-${classifier}.${format}` args.push(resultPath, this.appName + ".app") return spawn(path7za, args, { diff --git a/src/packager.ts b/src/packager.ts index 25ceb57312c..b0aa6fee4de 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -58,6 +58,7 @@ export class Packager implements BuildInfo { const appPackageFile = this.projectDir === this.appDir ? devPackageFile : path.join(this.appDir, "package.json") this.metadata = appPackageFile === devPackageFile ? this.devMetadata : await readPackageJson(appPackageFile) this.checkMetadata(appPackageFile, devPackageFile, platforms) + checkConflictingOptions(this.devMetadata.build) this.electronVersion = await getElectronVersion(this.devMetadata, devPackageFile) @@ -74,11 +75,7 @@ export class Packager implements BuildInfo { for (let arch of normalizeArchs(platform, this.options.arch)) { await this.installAppDependencies(platform, arch) // electron-packager uses productName in the directory name - const appOutDir = await helper.pack(outDir, arch) - if (this.options.dist) { - distTasks.push(helper.packageInDistributableFormat(outDir, appOutDir, arch)) - } - } + await helper.pack(outDir, arch, distTasks)} } return await BluebirdPromise.all(distTasks) @@ -198,3 +195,11 @@ export function normalizePlatforms(platforms: Array): Array

it instanceof Platform ? it : Platform.fromString(it)) } } + +function checkConflictingOptions(options: any) { + for (let name of ["all", "out", "tmpdir", "version", "platform", "dir", "arch"]) { + if (name in options) { + throw new Error(`Option ${name} is ignored, do not specify it.`) + } + } +} \ No newline at end of file diff --git a/src/platformPackager.ts b/src/platformPackager.ts index fa1e30d1b91..32108047c0f 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -10,6 +10,7 @@ import { statOrNull, use } from "./util" import { Packager } from "./packager" import deepAssign = require("deep-assign") import { statFile } from "asar" +import ElectronPackagerOptions = ElectronPackager.ElectronPackagerOptions //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") @@ -106,18 +107,20 @@ export abstract class PlatformPackager }) } - async pack(outDir: string, arch: string): Promise { + pack(outDir: string, arch: string, postAsyncTasks: Array>): Promise { const appOutDir = this.computeAppOutDir(outDir, arch) - await this.doPack(outDir, appOutDir, arch) - await this.copyExtraResources(appOutDir, arch) - return appOutDir + return this.doPack(this.computePackOptions(outDir, arch), outDir, appOutDir, arch, postAsyncTasks) } - protected beforePack(options: any): void { - // to override + protected async doPack(options: ElectronPackagerOptions, outDir: string, appOutDir: string, arch: string, postAsyncTasks: Array> = null) { + await this.packApp(options, appOutDir) + await this.copyExtraResources(appOutDir, arch) + if (postAsyncTasks != null && this.options.dist) { + postAsyncTasks.push(this.packageInDistributableFormat(outDir, appOutDir, arch)) + } } - protected async doPack(outDir: string, appOutDir: string, arch: string): Promise { + protected computePackOptions(outDir: string, arch: string): ElectronPackagerOptions { const version = this.metadata.version let buildVersion = version const buildNumber = this.computeBuildNumber() @@ -125,8 +128,6 @@ export abstract class PlatformPackager buildVersion += "." + buildNumber } - checkConflictingOptions(this.devMetadata.build) - const options = deepAssign({ dir: this.info.appDir, out: outDir, @@ -153,8 +154,10 @@ export abstract class PlatformPackager delete options.linux // this option only for windows-installer delete options.iconUrl + return options + } - this.beforePack(options) + protected async packApp(options: ElectronPackagerOptions, appOutDir: string): Promise { await pack(options) await this.sanityCheckPackage(appOutDir, options.asar) } @@ -186,7 +189,7 @@ export abstract class PlatformPackager return await BluebirdPromise.map(await this.getExtraResources(arch), it => copy(path.join(this.projectDir, it), path.join(resourcesDir, it))) } - abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise + protected abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise protected async computePackageUrl(): Promise { const url = this.metadata.homepage || this.devMetadata.homepage @@ -247,17 +250,18 @@ export abstract class PlatformPackager } } -function checkConflictingOptions(options: any) { - for (let name of ["all", "out", "tmpdir", "version", "platform", "dir", "arch"]) { - if (name in options) { - throw new Error(`Option ${name} is ignored, do not specify it.`) - } - } -} - export interface ArtifactCreated { readonly file: string readonly artifactName?: string readonly platform: Platform +} + +export function normalizeTargets(targets: Array | string): Array { + if (targets == null) { + return null + } + else { + return (Array.isArray(targets) ? targets : [targets]).map(it => it.toLowerCase().trim()) + } } \ No newline at end of file diff --git a/src/winPackager.ts b/src/winPackager.ts index 73c699fe893..aa7736d4c05 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -52,19 +52,19 @@ export class WinPackager extends PlatformPackager { return iconPath } - async pack(outDir: string, arch: string): Promise { + async pack(outDir: string, arch: string, postAsyncTasks: Array>): Promise { // we must check icon before pack because electron-packager uses icon and it leads to cryptic error message "spawn wine ENOENT" await this.iconPath if (!this.options.dist) { - return await super.pack(outDir, arch) + return await super.pack(outDir, arch, postAsyncTasks) } const appOutDir = this.computeAppOutDir(outDir, arch) const installerOut = computeDistOut(outDir, arch) log("Removing %s", installerOut) await BluebirdPromise.all([ - this.doPack(outDir, appOutDir, arch), + this.packApp(this.computePackOptions(outDir, arch), appOutDir), emptyDir(installerOut) ]) @@ -80,11 +80,13 @@ export class WinPackager extends PlatformPackager { }) } - return appOutDir + if (this.options.dist) { + postAsyncTasks.push(this.packageInDistributableFormat(outDir, appOutDir, arch)) + } } - protected async doPack(outDir: string, appOutDir: string, arch: string) { - await super.doPack(outDir, appOutDir, arch) + protected async packApp(options: any, appOutDir: string) { + await super.packApp(options, appOutDir) if (process.platform === "darwin" && this.options.cscLink != null && this.options.cscKeyPassword != null) { const filename = this.appName + ".exe" diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 252af639da6..6564c918176 100755 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -197,7 +197,10 @@ test("invalid platform", (t) => t.throws(assertPack("test-app-one", { function allPlatformsAndCurrentArch(dist: boolean = true): PackagerOptions { return { platform: getPossiblePlatforms(), - dist: dist + dist: dist, + // speed up tests + cscLink: null, + cscInstallerLink: null, } } diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index cf7a058fabb..3692e7fbe66 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -39,7 +39,7 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO const customTmpDir = process.env.TEST_APP_TMP_DIR if (useTempDir) { // non-osx test uses the same dir as osx test, but we cannot share node_modules (because tests executed in parallel) - const dir = customTmpDir == null ? path.join(tmpdir(), tmpDirPrefix + fixtureName + "-" + tmpDirCounter++) : path.resolve(customTmpDir) + const dir = customTmpDir == null ? path.join(tmpdir(), `${tmpDirPrefix}${fixtureName}-${tmpDirCounter++}}`) : path.resolve(customTmpDir) if (customTmpDir != null) { console.log("Custom temp dir used: %s", customTmpDir) } @@ -105,7 +105,7 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions for (let platform of packagerOptions.platform) { if (platform === Platform.OSX) { - await checkOsXResult(packager, checkOptions, artifacts.get(Platform.OSX)) + await checkOsXResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.OSX)) } else if (platform === Platform.LINUX) { await checkLinuxResult(projectDir, packager, packagerOptions) @@ -168,7 +168,7 @@ function parseDebControl(info: string): any { return metadata } -async function checkOsXResult(packager: Packager, checkOptions: AssertPackOptions, artifacts: Array) { +async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array) { const productName = getProductName(packager.metadata, packager.devMetadata) const packedAppDir = path.join(path.dirname(artifacts[0].file), (productName || packager.metadata.name) + ".app") const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8")) @@ -179,8 +179,10 @@ async function checkOsXResult(packager: Packager, checkOptions: AssertPackOption CFBundleVersion: "1.1.0" + "." + (process.env.TRAVIS_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM) }) - const result = await exec("codesign", ["--verify", packedAppDir]) - assertThat(result[0].toString()).not.match(/is not signed at all/) + if (packagerOptions.csaLink != null) { + const result = await exec("codesign", ["--verify", packedAppDir]) + assertThat(result[0].toString()).not.match(/is not signed at all/) + } const actualFiles = artifacts.map(it => path.basename(it.file)).sort() if (checkOptions != null && checkOptions.expectedContents != null) { diff --git a/test/src/osxPackagerTest.ts b/test/src/osxPackagerTest.ts index 63af6045641..cd6f696e3ec 100644 --- a/test/src/osxPackagerTest.ts +++ b/test/src/osxPackagerTest.ts @@ -18,13 +18,13 @@ test.ifOsx("two-package", () => assertPack("test-app", { test.ifOsx("one-package", () => assertPack("test-app-one", platform(Platform.OSX))) -function createTargetTest(target: string, expectedContents: Array) { +function createTargetTest(target: Array, expectedContents: Array) { return () => assertPack("test-app-one", { platform: [Platform.OSX], devMetadata: { build: { osx: { - target: [target] + target: target } } } @@ -34,11 +34,12 @@ function createTargetTest(target: string, expectedContents: Array) { }) } -test.ifOsx("only dmg", createTargetTest("dmg", ["TestApp-1.1.0.dmg"])) -test.ifOsx("only zip", createTargetTest("zip", ["TestApp-1.1.0-mac.zip"])) -test.ifOsx("invalid target", (t: any) => t.throws(createTargetTest("ttt", [])(), "Unknown target: ttt")) +test.ifOsx("only dmg", createTargetTest(["dmg"], ["TestApp-1.1.0.dmg"])) +test.ifOsx("only zip", createTargetTest(["zip"], ["TestApp-1.1.0-osx.zip"])) +test.ifOsx("invalid target", (t: any) => t.throws(createTargetTest(["ttt"], [])(), "Unknown target: ttt")) -test.ifOsx("mas", createTargetTest("mas", ["TestApp-1.1.0.pkg"])) +test.ifOsx("mas", createTargetTest(["mas"], ["TestApp-1.1.0.pkg"])) +test.ifOsx("mas and 7z", createTargetTest(["mas", "7z"], ["TestApp-1.1.0-osx.7z", "TestApp-1.1.0.pkg"])) // test.ifOsx("no background", (t: any) => assertPack("test-app-one", platform(Platform.OSX), { // tempDirCreated: projectDir => deleteFile(path.join(projectDir, "build", "background.png")) @@ -75,12 +76,12 @@ class CheckingOsXPackager extends OsXPackager { super(info, cleanupTasks) } - async pack(outDir: string, arch: string): Promise { + async pack(outDir: string, arch: string): Promise { // skip pack - return this.computeAppOutDir(outDir, arch) + this.effectiveDistOptions = await this.computeEffectiveDistOptions(this.computeAppOutDir(outDir, arch)) } async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise { - this.effectiveDistOptions = await this.computeEffectiveDistOptions(appOutDir) + // skip } } \ No newline at end of file diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts index b264777bbbb..e7c36c8a864 100755 --- a/test/src/winPackagerTest.ts +++ b/test/src/winPackagerTest.ts @@ -78,13 +78,13 @@ class CheckingWinPackager extends WinPackager { super(info, cleanupTasks) } - async pack(outDir: string, arch: string): Promise { + async pack(outDir: string, arch: string): Promise { // skip pack - return this.computeAppOutDir(outDir, arch) + const installerOutDir = computeDistOut(outDir, arch) + this.effectiveDistOptions = await this.computeEffectiveDistOptions(this.computeAppOutDir(outDir, arch), installerOutDir) } async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise { - const installerOutDir = computeDistOut(outDir, arch) - this.effectiveDistOptions = await this.computeEffectiveDistOptions(appOutDir, installerOutDir) + // skip } } \ No newline at end of file diff --git a/tslint.json b/tslint.json index 6dfa3d49b6a..0e88b650ef4 100644 --- a/tslint.json +++ b/tslint.json @@ -67,5 +67,9 @@ }, "no-debugger": true, "no-inferrable-types": true, - "no-shadowed-variable ": true + "no-shadowed-variable": true, + "no-invalid-this": true, + "no-reference": true, + "semicolon": "never", + "prefer-const": "true" } \ No newline at end of file diff --git a/typings/electron-packager.d.ts b/typings/electron-packager.d.ts index b6a167332b9..47bb2ee1a33 100644 --- a/typings/electron-packager.d.ts +++ b/typings/electron-packager.d.ts @@ -1,115 +1,92 @@ -// Type definitions for electron-packager v5.1.0 -// Project: https://github.com/maxogden/electron-packager -// Definitions by: Maxime LUCE -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - declare namespace ElectronPackager { - /** Electron-packager Options. */ - export interface Options { - /** The source directory. */ - dir: string; - /** The application name. */ - name: string; - /** - * Allowed values: linux, win32, darwin, all. Not required if `all` is used. - * Arbitrary combinations of individual platforms are also supported via a comma-delimited string or array of strings. - */ - platform?: string | string[]; - /** Allowed values: ia32, x64, all Not required if `all` is used. */ - arch?: string; - /** Electron version (without the "v"). See https://github.com/atom/electron/releases. */ - version: string; - - /** Shortcut for `--arch=all --platform=all`. */ - all?: boolean; - /** The output directory. */ - out?: string; - /** - * Currently you must look for conversion tools in order to supply an icon in the format required by the platform: - * - OS X: `.icns` - * - Windows: `.ico` - * - * For Linux builds, this option is not required, as the dock/window list icon is set via the icon option in the BrowserWindow contructor. - * Setting the icon in the file manager is not currently supported. - * - * If the file extension is omitted, it is auto-completed to the correct extension based on the platform, - * including when `--platform=all` is in effect. - */ - icon?: string; - - /** The bundle identifier to use in the app plist. */ - "app-bundle-id"?: string; - /** The release version to set for the app. */ - "app-version"?: string; - /** The build version to set for the app (OS X only). */ - "build-version"?: string; - /** The bundle identifier to use in the app helper plist. */ - "helper-bundle-id"?: string; - /** Object hash of application metadata to embed into the executable (Windows only). */ - "version-string"?: VersionString; + /** Electron-packager Options. */ + export interface ElectronPackagerOptions { + /** The source directory. */ + dir: string; + /** The application name. */ + name: string; + /** + * Allowed values: linux, win32, darwin, all. Not required if `all` is used. + * Arbitrary combinations of individual platforms are also supported via a comma-delimited string or array of strings. + */ + platform?: string | string[]; + /** Allowed values: ia32, x64, all Not required if `all` is used. */ + arch?: string; + /** Electron version (without the "v"). See https://github.com/atom/electron/releases. */ + version: string; - /** The directory of cached electron downloads. Defaults to "$HOME/.electron". */ - cache?: string; - /** Do not copy files into App whose filenames regex .match this string. */ - ignore?: RegExp; - /** Runs `npm prune --production` on the app. */ - prune?: boolean; - /** If output directory for a platform already exists, replaces it rather than skipping it. */ - overwrite?: boolean; - /** Packages the source code within your app into an archive. */ - asar?: boolean; - /** Unpacks the files to app.asar.unpacked directory whose filenames regex .match this string. */ - "asar-unpack"?: string; - /** Should contain the identity to be used when running `codesign` (OS X only). */ - sign?: string; - } + /** Shortcut for `--arch=all --platform=all`. */ + all?: boolean; + /** The output directory. */ + out?: string; + /** + * Currently you must look for conversion tools in order to supply an icon in the format required by the platform: + * - OS X: `.icns` + * - Windows: `.ico` + * + * For Linux builds, this option is not required, as the dock/window list icon is set via the icon option in the BrowserWindow contructor. + * Setting the icon in the file manager is not currently supported. + * + * If the file extension is omitted, it is auto-completed to the correct extension based on the platform, + * including when `--platform=all` is in effect. + */ + icon?: string; + /** The bundle identifier to use in the app plist. */ + "app-bundle-id"?: string; + /** The release version to set for the app. */ + "app-version"?: string; + /** The build version to set for the app (OS X only). */ + "build-version"?: string; + /** The bundle identifier to use in the app helper plist. */ + "helper-bundle-id"?: string; /** Object hash of application metadata to embed into the executable (Windows only). */ - export interface VersionString { - CompanyName?: string; - LegalCopyright?: string; - FileDescription?: string; - OriginalFilename?: string; - FileVersion?: string; - ProductVersion?: string; - ProductName?: string; - InternalName?: string; - } + "version-string"?: VersionString; - /** Electron-packager done callback. */ - export interface Callback { - /** - * Callback wich is called when electron-packager is done. - * - * @param err - Contains errors if any. - * @param appPath - Path to the newly created application. - */ - (err: Error, appPath: string): void - } + /** The directory of cached electron downloads. Defaults to "$HOME/.electron". */ + cache?: string; + /** Do not copy files into App whose filenames regex .match this string. */ + ignore?: RegExp; + /** Runs `npm prune --production` on the app. */ + prune?: boolean; + /** If output directory for a platform already exists, replaces it rather than skipping it. */ + overwrite?: boolean; + /** Packages the source code within your app into an archive. */ + asar?: boolean; + /** Unpacks the files to app.asar.unpacked directory whose filenames regex .match this string. */ + "asar-unpack"?: string; + /** Should contain the identity to be used when running `codesign` (OS X only). */ + sign?: string; + } - /** Electron-packager function */ - export interface Packager { - /** - * This will: - * - Find or download the correct release of Electron - * - Use that version of electron to create a app in /-- - * - * You should be able to launch the app on the platform you built for. If not, check your settings and try again. - * - * @param opts - Options to configure packaging. - * @param callback - Callback which is called when packaging is done or an error occured. - */ - (opts: Options, callback: Callback): void; - } -} + /** Object hash of application metadata to embed into the executable (Windows only). */ + export interface VersionString { + CompanyName?: string; + LegalCopyright?: string; + FileDescription?: string; + OriginalFilename?: string; + FileVersion?: string; + ProductVersion?: string; + ProductName?: string; + InternalName?: string; + } -declare module "electron-packager-tf" { - const packager: ElectronPackager.Packager; - export = packager; + export interface Packager { + /** + * This will: + * - Find or download the correct release of Electron + * - Use that version of electron to create a app in /-- + * + * You should be able to launch the app on the platform you built for. If not, check your settings and try again. + * + * @param opts - Options to configure packaging. + * @param callback - Callback which is called when packaging is done or an error occured. + */ + (opts: ElectronPackagerOptions, callback: (err: Error, appPath: string) => void): void; + } } -interface NodeRequireFunction { - (id: "electron-packager"): ElectronPackager.Packager; -} +declare module "electron-packager-tf" { + const packager: ElectronPackager.Packager; + export = packager; +} \ No newline at end of file