-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #413
- Loading branch information
Showing
19 changed files
with
412 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,67 @@ | ||
#! /usr/bin/env node | ||
|
||
import { PackagerOptions, commonTargets } from "./platformPackager" | ||
import { normalizePlatforms } from "./packager" | ||
import { build } from "./builder" | ||
import { PublishOptions } from "./gitHubPublisher" | ||
// import { commonTargets } from "./platformPackager" | ||
import { build, CliOptions } from "./builder" | ||
import { printErrorAndExit } from "./promise" | ||
import yargs = require("yargs") | ||
import { underline } from "chalk" | ||
import { Platform } from "./metadata" | ||
import yargs = require("yargs") | ||
|
||
//noinspection JSUnusedLocalSymbols | ||
const __awaiter = require("./awaiter") | ||
|
||
interface CliOptions extends PackagerOptions, PublishOptions { | ||
osx?: Array<string> | ||
linux?: Array<string> | ||
win?: Array<string> | ||
|
||
arch?: string | ||
|
||
x64?: boolean | ||
ia32?: boolean | ||
} | ||
|
||
const args = <CliOptions>(yargs | ||
.version() | ||
.option("osx", { | ||
alias: "o", | ||
describe: "Build for OS X", | ||
type: "array", | ||
}) | ||
.option("linux", { | ||
alias: "l", | ||
describe: "Build for Linux", | ||
type: "array", | ||
}) | ||
.option("win", { | ||
alias: ["w", "windows"], | ||
describe: "Build for Windows", | ||
type: "array", | ||
}) | ||
.option("x64", { | ||
describe: "Build for x64", | ||
type: "boolean", | ||
}) | ||
.option("ia32", { | ||
describe: "Build for ia32", | ||
type: "boolean", | ||
}) | ||
.option("target", { | ||
alias: "t", | ||
describe: "Target package types", | ||
choices: commonTargets, | ||
}) | ||
.option("publish", { | ||
alias: "p", | ||
describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`, | ||
choices: ["onTag", "onTagOrDraft", "always", "never"], | ||
}) | ||
.option("platform", { | ||
choices: ["osx", "win", "linux", "darwin", "win32", "all"], | ||
}) | ||
.option("arch", { | ||
choices: ["ia32", "x64", "all"], | ||
}) | ||
.option("npmRebuild", { | ||
describe: "Runs npm rebuild before starting to package the app.", | ||
default: true, | ||
type: "boolean", | ||
}) | ||
.strict() | ||
.help() | ||
.epilog(`Project home: ${underline("https://github.com/electron-userland/electron-builder")}`) | ||
.argv) | ||
|
||
const platforms = normalizePlatforms(args.platform) | ||
if (args.osx != null && !platforms.includes(Platform.OSX)) { | ||
platforms.push(Platform.OSX) | ||
} | ||
if (args.linux != null && !platforms.includes(Platform.LINUX)) { | ||
platforms.push(Platform.LINUX) | ||
} | ||
if (args.win != null && !platforms.includes(Platform.WINDOWS)) { | ||
platforms.push(Platform.WINDOWS) | ||
} | ||
|
||
const archAsProp = args.arch | ||
const archs = archAsProp === "all" ? ["ia32", "x64"] : (archAsProp == null ? [] : [archAsProp]) | ||
|
||
if (args.x64 && !archs.includes("x64")) { | ||
archs.push("x64") | ||
} | ||
if (args.ia32 && !archs.includes("ia32")) { | ||
archs.push("ia32") | ||
export function createYargs(): any { | ||
return yargs | ||
.version() | ||
.option("osx", { | ||
alias: "o", | ||
describe: "Build for OS X", | ||
type: "array", | ||
}) | ||
.option("linux", { | ||
alias: "l", | ||
describe: "Build for Linux", | ||
type: "array", | ||
}) | ||
.option("win", { | ||
alias: ["w", "windows"], | ||
describe: "Build for Windows", | ||
type: "array", | ||
}) | ||
.option("x64", { | ||
describe: "Build for x64", | ||
type: "boolean", | ||
}) | ||
.option("ia32", { | ||
describe: "Build for ia32", | ||
type: "boolean", | ||
}) | ||
// .option("target", { | ||
// alias: "t", | ||
// describe: "Target package types", | ||
// choices: commonTargets, | ||
// }) | ||
.option("publish", { | ||
alias: "p", | ||
describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`, | ||
choices: ["onTag", "onTagOrDraft", "always", "never"], | ||
}) | ||
.option("platform", { | ||
choices: ["osx", "win", "linux", "darwin", "win32", "all"], | ||
}) | ||
.option("arch", { | ||
choices: ["ia32", "x64", "all"], | ||
}) | ||
.option("npmRebuild", { | ||
describe: "Runs npm rebuild before starting to package the app.", | ||
default: true, | ||
type: "boolean", | ||
}) | ||
.strict() | ||
.help() | ||
.epilog(`Project home: ${underline("https://github.com/electron-userland/electron-builder")}`) | ||
} | ||
|
||
build(Object.assign({}, args, { | ||
platform: platforms, | ||
arch: archs, | ||
})) | ||
.catch(printErrorAndExit) | ||
if (!module.parent) { | ||
build(<CliOptions>(createYargs().argv)) | ||
.catch(printErrorAndExit) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { Packager } from "./packager" | ||
export { PackagerOptions, ArtifactCreated, DIR_TARGET } from "./platformPackager" | ||
export { BuildOptions, build, createPublisher } from "./builder" | ||
export { BuildOptions, build, createPublisher, CliOptions, createTargets } from "./builder" | ||
export { PublishOptions, Publisher } from "./gitHubPublisher" | ||
export { AppMetadata, DevMetadata, Platform, getProductName, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions } from "./metadata" | ||
export { AppMetadata, DevMetadata, Platform, Arch, archFromString, getProductName, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions } from "./metadata" |
Oops, something went wrong.