From e0d7974cbf0294524f47dbef62c9eb8398d2ecf0 Mon Sep 17 00:00:00 2001 From: develar Date: Sun, 4 Jun 2017 12:03:48 +0200 Subject: [PATCH] feat: asar integrity: add externalAllowed option --- .travis.yml | 2 +- packages/asar-integrity/src/asarIntegrity.ts | 4 ++-- packages/electron-builder-core/src/core.ts | 3 ++- packages/electron-builder/src/platformPackager.ts | 4 ++-- yarn.lock | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66e84dc6d38..f2db614e1ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ matrix: env: TEST_FILES=BuildTest,extraMetadataTest,globTest,filesTest,ignoreTest,linux.* NODE_VERSION=6 PUBLISH_TO_NPM=true - os: osx - env: TEST_FILES=windows.*,mac.* NODE_VERSION=7 + env: TEST_FILES=windows.*,mac.* NODE_VERSION=8 - os: osx env: TEST_FILES=mac.* NODE_VERSION=6 diff --git a/packages/asar-integrity/src/asarIntegrity.ts b/packages/asar-integrity/src/asarIntegrity.ts index 068d95e61bf..256fa89e9a3 100644 --- a/packages/asar-integrity/src/asarIntegrity.ts +++ b/packages/asar-integrity/src/asarIntegrity.ts @@ -10,14 +10,14 @@ export interface AsarIntegrityOptions { * * @default false */ - readonly externalAllowed: Boolean + readonly externalAllowed?: Boolean } export interface AsarIntegrity extends AsarIntegrityOptions { checksums: { [key: string]: string; } } -export async function computeData(resourcesPath: string, options?: AsarIntegrityOptions): Promise { +export async function computeData(resourcesPath: string, options?: AsarIntegrityOptions | null): Promise { // sort to produce constant result const names = (await readdir(resourcesPath)).filter(it => it.endsWith(".asar")).sort() const checksums = await BluebirdPromise.map(names, it => hashFile(path.join(resourcesPath, it), "sha512", "base64")) diff --git a/packages/electron-builder-core/src/core.ts b/packages/electron-builder-core/src/core.ts index c65dba57129..824341db02f 100644 --- a/packages/electron-builder-core/src/core.ts +++ b/packages/electron-builder-core/src/core.ts @@ -1,3 +1,4 @@ +import { AsarIntegrityOptions } from "asar-integrity" import { Publish } from "electron-builder-http/out/publishOptions" export enum Arch { @@ -160,7 +161,7 @@ export interface FilePattern { filter?: Array | string } -export interface AsarOptions { +export interface AsarOptions extends AsarIntegrityOptions { smartUnpack?: boolean ordering?: string | null diff --git a/packages/electron-builder/src/platformPackager.ts b/packages/electron-builder/src/platformPackager.ts index c83000d4ef5..0db04b0794b 100644 --- a/packages/electron-builder/src/platformPackager.ts +++ b/packages/electron-builder/src/platformPackager.ts @@ -1,3 +1,4 @@ +import { computeData } from "asar-integrity" import BluebirdPromise from "bluebird-lst" import { Arch, AsarOptions, FileAssociation, getArchSuffix, Platform, PlatformSpecificBuildOptions, Target, TargetSpecificOptions } from "electron-builder-core" import { asArray, debug, isEmptyOrSpaces, Lazy, use } from "electron-builder-util" @@ -15,7 +16,6 @@ import { Config } from "./metadata" import { unpackElectron, unpackMuon } from "./packager/dirPackager" import { BuildInfo, PackagerOptions } from "./packagerApi" import { readInstalled } from "./readInstalled" -import { computeData } from "asar-integrity" export abstract class PlatformPackager { readonly packagerOptions: PackagerOptions @@ -209,7 +209,7 @@ export abstract class PlatformPackager await BluebirdPromise.all(promises) if (platformName === "darwin" || platformName === "mas") { - await (require("./packager/mac")).createApp(this, appOutDir, asarOptions == null ? null : await computeData(resourcesPath)) + await (require("./packager/mac")).createApp(this, appOutDir, asarOptions == null ? null : await computeData(resourcesPath, asarOptions.externalAllowed ? {externalAllowed: true} : null)) } await copyFiles(extraResourceMatchers) diff --git a/yarn.lock b/yarn.lock index 62c0b827ea0..6333c571eda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3349,8 +3349,8 @@ typical@^2.4.2, typical@^2.6.0, typical@^2.6.1: resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d" uglify-js@^2.6: - version "2.8.27" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.27.tgz#47787f912b0f242e5b984343be8e35e95f694c9c" + version "2.8.28" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.28.tgz#e335032df9bb20dcb918f164589d5af47f38834a" dependencies: source-map "~0.5.1" yargs "~3.10.0"