diff --git a/.idea/runConfigurations/osxPackagerTest.xml b/.idea/runConfigurations/osxPackagerTest.xml new file mode 100644 index 00000000000..23e26f659c0 --- /dev/null +++ b/.idea/runConfigurations/osxPackagerTest.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index ade3fe8d1e5..0f7d809977c 100755 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ See [options](./docs/options.md), but consider to follow simple 4-step guide out } ``` And then you can run `npm run pack` or `npm run dist` (to package in a distributable format (e.g. DMG, windows installer, NuGet package)). + Both scripts are the same because If script named `dist` or name has prefix `dist:`, flag `--dist` is implied. 4. Install [required system packages](./docs/multi-platform-build.md). diff --git a/docs/options.md b/docs/options.md index 256d292f989..ad14251de5f 100644 --- a/docs/options.md +++ b/docs/options.md @@ -41,13 +41,11 @@ Here documented only `electron-builder` specific options: | --- | --- | name | The application name. | productName |

As [name](#AppMetadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name}).

- # Development `package.json` | Name | Description | --- | --- -| build | See [build](#BuildMetadata). - +| build | See [BuildMetadata](#BuildMetadata). ## `.build` | Name | Description diff --git a/package.json b/package.json index a968ba5e71d..75d51a016bb 100644 --- a/package.json +++ b/package.json @@ -84,10 +84,10 @@ "pre-commit": "^1.1.2", "semantic-release": "^4.3.5", "should": "^8.3.0", - "ts-babel": "^0.6.3", + "ts-babel": "^0.6.4", "tsconfig-glob": "^0.4.2", "tslint": "next", - "typescript": "^1.9.0-dev.20160323", + "typescript": "^1.9.0-dev.20160325", "validate-commit-msg": "^2.4.1" }, "babel": { diff --git a/src/build-cli.ts b/src/build-cli.ts index d078580b6ff..9d5fec59e02 100644 --- a/src/build-cli.ts +++ b/src/build-cli.ts @@ -20,8 +20,8 @@ const cli = cla(commonArgs.concat( {name: "dist", type: Boolean, alias: "d", description: "Whether to package in a distributable format (e.g. DMG, windows installer, NuGet package)."}, {name: "publish", type: String, alias: "p", description: "Publish artifacts (to GitHub Releases): onTag (on tag push only) or onTagOrDraft (on tag push or if draft release exists)."}, {name: "platform", type: String, multiple: true, description: "darwin, linux, win32 or all. Current platform (" + process.platform + ") by default."}, - {name: "arch", type: String, description: "ia32, x64 or all (by default)."}, - {name: "target", type: String, multiple: true, description: "Installer or package type. For win32: squirrel (default) or nsis (deprecated)."}, + {name: "arch", type: String, description: "ia32, x64 or all. Defaults to architecture you're running on."}, + {name: "target", type: String, multiple: true, description: "Installer or package type."}, {name: "sign", type: String}, {name: "help", alias: "h", type: Boolean, description: "Display this usage guide."} )) diff --git a/src/builder.ts b/src/builder.ts index e685873d6bd..2ddf42b7f6a 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -40,7 +40,7 @@ export async function build(originalOptions?: BuildOptions): Promise { options.dist = true } else if (options.dist === undefined) { - options.dist = lifecycleEvent === "dist" || lifecycleEvent === "build" + options.dist = lifecycleEvent === "dist" || lifecycleEvent === "build" || lifecycleEvent.startsWith("dist:") } let isPublishOptionGuessed = false diff --git a/src/metadata.ts b/src/metadata.ts index ef4f359b69d..22c81c6cef7 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -3,7 +3,7 @@ export interface Metadata { } /** - Application `package.json` + # Application `package.json` */ export interface AppMetadata extends Metadata { readonly version: string @@ -25,7 +25,7 @@ export interface AppMetadata extends Metadata { } /** - Development `package.json` + # Development `package.json` */ export interface DevMetadata extends Metadata { /** @@ -50,7 +50,7 @@ export interface MetadataDirectories { } /** - Development `package.json` `.build` + ## `.build` */ export interface BuildMetadata { readonly "app-bundle-id": string diff --git a/src/packager.ts b/src/packager.ts index a50a674dad3..615fcd66188 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -177,7 +177,12 @@ export class Packager implements BuildInfo { } export function normalizeArchs(platform: string, arch?: string) { - return platform === "darwin" ? ["x64"] : (arch == null || arch === "all" ? ["ia32", "x64"] : [arch]) + if (platform === "darwin") { + return ["x64"] + } + else { + return arch == null ? [process.arch] : (arch === "all" ? ["ia32", "x64"] : [arch]) + } } export function normalizePlatforms(platforms: Array): Array { diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index c2b3aac21c1..2ec17709d15 100755 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -1,5 +1,5 @@ import test from "./helpers/avaEx" -import { assertPack, modifyPackageJson, platform } from "./helpers/packTester" +import { assertPack, modifyPackageJson } from "./helpers/packTester" import { move, outputFile, outputJson } from "fs-extra-p" import { Promise as BluebirdPromise } from "bluebird" import * as path from "path" @@ -9,19 +9,6 @@ import { Platform, PackagerOptions } from "out" //noinspection JSUnusedLocalSymbols const __awaiter = require("out/awaiter") -if (process.env.TRAVIS !== "true") { - // we don't use CircleCI, so, we can safely set this env - process.env.CIRCLE_BUILD_NUM = 42 -} - -test.ifOsx("mac: two-package.json", async () => { - await assertPack("test-app", platform("darwin")) -}) - -test.ifOsx("mac: one-package.json", async () => { - await assertPack("test-app-one", platform("darwin")) -}) - test("custom app dir", async () => { await assertPack("test-app-one", allPlatformsAndCurrentArch(), { tempDirCreated: (projectDir) => { @@ -62,7 +49,6 @@ test("build in the app package.json", t => { test("version from electron-prebuilt dependency", async() => { await assertPack("test-app-one", { platform: [process.platform], - arch: process.arch, dist: false }, { tempDirCreated: projectDir => { @@ -82,9 +68,9 @@ test("copy extra resource", async () => { for (let platform of getPossiblePlatforms()) { const osName = Platform.fromNodePlatform(platform).buildConfigurationKey + //noinspection SpellCheckingInspection await assertPack("test-app", { platform: [platform], - arch: process.arch, // to check NuGet package dist: platform === "win32" }, { @@ -166,8 +152,6 @@ test("copy extra resource", async () => { function allPlatformsAndCurrentArch(): PackagerOptions { return { platform: getPossiblePlatforms(), - // speed up tests, we don't need check every arch - arch: process.arch, } } diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 188ccab9146..e4b79bc1e48 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -19,6 +19,11 @@ const __awaiter = require("out/awaiter") const tmpDirPrefix = "electron-builder-test-" + process.pid + "-" let tmpDirCounter = 0 +if (process.env.TRAVIS !== "true") { + // we don't use CircleCI, so, we can safely set this env + process.env.CIRCLE_BUILD_NUM = 42 +} + interface AssertPackOptions { readonly tempDirCreated?: (projectDir: string) => Promise readonly packed?: (projectDir: string) => Promise @@ -27,7 +32,7 @@ interface AssertPackOptions { export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise { const tempDirCreated = checkOptions == null ? null : checkOptions.tempDirCreated - const useTempDir = tempDirCreated != null || (packagerOptions != null && packagerOptions.target != null) + const useTempDir = tempDirCreated != null || packagerOptions.target != null let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName) // const isDoNotUseTempDir = platform === "darwin" @@ -118,11 +123,11 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions // console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2)) assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName)).deepEqual(expectedContents) - if (packagerOptions == null || packagerOptions.arch === null || packagerOptions.arch === "ia32") { + if (packagerOptions.arch === "all" || packagerOptions.arch === "ia32") { assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName)).deepEqual(expectedContents) } } - else if (platform === "win32" && (packagerOptions == null || packagerOptions.target == null)) { + else if (platform === "win32") { await checkWindowsResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.WINDOWS)) } } @@ -164,7 +169,7 @@ async function checkWindowsResult(packager: Packager, packagerOptions: PackagerO ] } - const archSuffix = packagerOptions != null && packagerOptions.arch === "x64" ? "" : "-ia32" + const archSuffix = (packagerOptions.arch || process.arch) === "x64" ? "" : "-ia32" const expected = archSuffix == "" ? getWinExpected(archSuffix) : getWinExpected(archSuffix).concat(getWinExpected("")) const filenames = artifacts.map(it => path.basename(it.file)) diff --git a/test/src/linuxPackagerTest.ts b/test/src/linuxPackagerTest.ts index 0fcfad93676..1d39818a9cb 100755 --- a/test/src/linuxPackagerTest.ts +++ b/test/src/linuxPackagerTest.ts @@ -13,7 +13,6 @@ test.ifNotWindows("linux", async () => { test.ifNotWindows("linux - icons from ICNS", async () => { await assertPack("test-app-one", { platform: ["linux"], - arch: process.arch, }, {tempDirCreated: (projectDir) => remove(path.join(projectDir, "build", "icons"))}) }) diff --git a/test/src/osxPackagerTest.ts b/test/src/osxPackagerTest.ts new file mode 100644 index 00000000000..5b6e614d52c --- /dev/null +++ b/test/src/osxPackagerTest.ts @@ -0,0 +1,16 @@ +import test from "./helpers/avaEx" +import { assertPack, platform } from "./helpers/packTester" + +//noinspection JSUnusedLocalSymbols +const __awaiter = require("out/awaiter") + +test.ifOsx("mac: two-package.json", () => { + return assertPack("test-app", { + platform: ["darwin"], + arch: "all", + }) +}) + +test.ifOsx("mac: one-package.json", () => { + return assertPack("test-app-one", platform("darwin")) +}) \ No newline at end of file diff --git a/test/tsconfig.json b/test/tsconfig.json index 5c331a7c10a..f93fa2efcdf 100755 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -61,6 +61,7 @@ "src/helpers/packTester.ts", "src/helpers/runTests.ts", "src/linuxPackagerTest.ts", + "src/osxPackagerTest.ts", "src/RepoSlugTest.ts", "src/winPackagerTest.ts" ]