diff --git a/package.json b/package.json index 6249a5663e0..ccc06bcf534 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,10 @@ "bugs": "https://github.com/electron-userland/electron-builder/issues", "homepage": "https://github.com/electron-userland/electron-builder", "dependencies": { + "7zip-bin": "^0.0.3", "bluebird": "^3.3.5", "command-line-args": "^2.1.6", + "deep-assign": "^2.0.0", "electron-packager-tf": "^6.0.3-beta.3", "electron-winstaller-fixed": "^2.2.1-beta.0", "fs-extra": "^0.27.0", @@ -69,8 +71,7 @@ "progress-stream": "^1.2.0", "read-package-json": "^2.0.3", "source-map-support": "^0.4.0", - "tmp": "0.0.28", - "7zip-bin": "^0.0.3" + "tmp": "0.0.28" }, "optionalDependencies": { "appdmg": "^0.3.6" diff --git a/src/builder.ts b/src/builder.ts index 1a23fb9b8df..3b87a4bbe63 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -34,7 +34,7 @@ export async function build(originalOptions?: BuildOptions): Promise { cscKeyPassword: process.env.CSC_KEY_PASSWORD, githubToken: process.env.GH_TOKEN || process.env.GH_TEST_TOKEN, }, originalOptions) - + options.platform = normalizePlatforms(originalOptions.platform) const lifecycleEvent = process.env.npm_lifecycle_event diff --git a/src/index.ts b/src/index.ts index cf081f42525..459e4a31fba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export { Packager } from "./packager" export { PackagerOptions, ArtifactCreated } from "./platformPackager" export { BuildOptions, build, createPublisher } from "./builder" +export { PublishOptions, Publisher } from "./gitHubPublisher" export { AppMetadata, DevMetadata, Platform, getProductName, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions } from "./metadata" \ No newline at end of file diff --git a/src/macPackager.ts b/src/macPackager.ts index ecfc64a4079..ec695c82b25 100644 --- a/src/macPackager.ts +++ b/src/macPackager.ts @@ -6,6 +6,7 @@ import { log, spawn } from "./util" import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName, sign } from "./codeSign" import { stat } from "fs-extra-p" import { path7za } from "7zip-bin" +import deepAssign = require("deep-assign") //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") @@ -57,7 +58,7 @@ export default class MacPackager extends PlatformPackager { new BluebirdPromise(async (resolve, reject) => { log("Creating DMG") - const specification: appdmg.Specification = Object.assign({ + const specification: appdmg.Specification = deepAssign({ title: this.appName, icon: path.join(this.buildResourcesDir, "icon.icns"), "icon-size": 80, diff --git a/src/packager.ts b/src/packager.ts index dc2429f93e6..8e1652ad1a1 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -11,6 +11,7 @@ import MacPackager from "./macPackager" import { WinPackager } from "./winPackager" import * as errorMessages from "./errorMessages" import * as util from "util" +import deepAssign = require("deep-assign") //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") @@ -54,7 +55,7 @@ export class Packager implements BuildInfo { const metadataList = await BluebirdPromise.map(Array.from(new Set([devPackageFile, appPackageFile])), readPackageJson) this.metadata = metadataList[metadataList.length - 1] - this.devMetadata = metadataList[0] + this.devMetadata = deepAssign(metadataList[0], this.options.devMetadata) this.checkMetadata(appPackageFile, devPackageFile, platforms) this.electronVersion = await getElectronVersion(this.devMetadata, devPackageFile) diff --git a/src/platformPackager.ts b/src/platformPackager.ts index 21a724c8064..d5e70023f5e 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -8,6 +8,7 @@ import globby = require("globby") import { copy } from "fs-extra-p" import { statOrNull } from "./util" import { Packager } from "./packager" +import deepAssign = require("deep-assign") //noinspection JSUnusedLocalSymbols const __awaiter = require("./awaiter") @@ -34,6 +35,13 @@ export interface PackagerOptions { cscKeyPassword?: string platformPackagerFactory?: (packager: Packager, platform: Platform, cleanupTasks: Array<() => Promise>) => PlatformPackager + + /** + * The same as [development package.json](https://github.com/electron-userland/electron-builder/wiki/Options#development-packagejson). + * + * Development `package.json` will be still read, but options specified in this object will override. + */ + readonly devMetadata?: DevMetadata } export interface BuildInfo extends ProjectMetadataProvider { @@ -105,7 +113,7 @@ export abstract class PlatformPackager checkConflictingOptions(this.devMetadata.build) - const options = Object.assign({ + const options = deepAssign({ dir: this.info.appDir, out: outDir, name: this.appName, diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts index 8c9f248a01e..a568cdc7c02 100755 --- a/test/src/winPackagerTest.ts +++ b/test/src/winPackagerTest.ts @@ -34,16 +34,34 @@ test.ifNotTravis("noMsi as string", t => t.throws(assertPack("test-app-one", pla test("detect install-spinner", () => { let platformPackager: CheckingWinPackager = null let loadingGifPath: string = null + + // todo all PackagerOptions should be optional otherwise it is not possible to pass only several to override dev package.json + const devMetadata: any = { + build: { + win: { + certificatePassword: "pass", + } + } + } return assertPack("test-app-one", { platform: [Platform.WINDOWS], platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingWinPackager(packager, cleanupTasks), + devMetadata: devMetadata }, { tempDirCreated: it => { loadingGifPath = path.join(it, "build", "install-spinner.gif") - return move(path.join(it, "install-spinner.gif"), loadingGifPath) + return BluebirdPromise.all([ + move(path.join(it, "install-spinner.gif"), loadingGifPath), + modifyPackageJson(it, data => { + data.build.win = { + certificateFile: "secretFile", + certificatePassword: "mustBeOverridden", + } + })]) }, packed: () => { assertThat(platformPackager.effectiveDistOptions.loadingGif).equal(loadingGifPath) + assertThat(platformPackager.effectiveDistOptions.certificateFile).equal("secretFile") return BluebirdPromise.resolve(null) }, }) diff --git a/test/tsconfig.json b/test/tsconfig.json index da214150368..23c823b053d 100755 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -29,6 +29,7 @@ "files": [ "../typings/appdmg.d.ts", "../typings/command-line-args.d.ts", + "../typings/deep-assign.d.ts", "../typings/electron-packager.d.ts", "../typings/gh-api.d.ts", "../typings/globby.d.ts", diff --git a/tsconfig.json b/tsconfig.json index c45b09e2656..e78fd7135a3 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -33,6 +33,7 @@ "files": [ "typings/appdmg.d.ts", "typings/command-line-args.d.ts", + "typings/deep-assign.d.ts", "typings/electron-packager.d.ts", "typings/gh-api.d.ts", "typings/globby.d.ts", diff --git a/typings/deep-assign.d.ts b/typings/deep-assign.d.ts new file mode 100644 index 00000000000..8325c9bff04 --- /dev/null +++ b/typings/deep-assign.d.ts @@ -0,0 +1,5 @@ +declare module "deep-assign" { + function deepAssign(target: T, source: U): T & U + + export = deepAssign +} \ No newline at end of file