Skip to content

Commit

Permalink
WIP: MSI installer electron-userland#723
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Oct 24, 2017
1 parent 9596448 commit 7182b6b
Show file tree
Hide file tree
Showing 35 changed files with 477 additions and 215 deletions.
3 changes: 3 additions & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,4 @@ We do this open source work in our free time. If you'd like us to invest more ti
## Sponsors

<a href="https://workflowy.com"><img src="https://workflowy.com/media/i/wf-icon-android.png" alt="WorkFlowy" title="WorkFlowy" width="75" height="75"/></a>
<a href="https://tidepool.org"><img src="https://www.electron.build/sponsor-logos/Tidepool_Logo_Light.svg" alt="Tidepool" title="Tidepool" /></a>
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cache:
- '%LOCALAPPDATA%\electron-builder\cache'

environment:
TEST_FILES: ExtraBuildTest,BuildTest,extraMetadataTest,filesTest,globTest,nsisUpdaterTest,oneClickInstallerTest,installerTest,appxTest
TEST_FILES: ExtraBuildTest,BuildTest,extraMetadataTest,filesTest,globTest,nsisUpdaterTest,oneClickInstallerTest,installerTest,appxTest,msiTest

install:
- ps: Install-Product node 8 x64
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"7zip-bin": "^2.2.7",
"archiver": "^2.1.0",
"async-exit-hook": "^2.0.1",
"aws-sdk": "^2.138.0",
"aws-sdk": "^2.139.0",
"bluebird-lst": "^1.0.5",
"chalk": "2.1.0",
"chalk": "^2.3.0",
"chromium-pickle-js": "^0.2.0",
"cuint": "^0.2.2",
"debug": "^3.1.0",
Expand Down Expand Up @@ -72,7 +72,6 @@
},
"devDependencies": {
"@develar/gitbook": "3.2.10",
"@types/chalk": "^0.4.31",
"@types/debug": "^0.0.30",
"@types/ejs": "^2.3.33",
"@types/electron-is-dev": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"is-ci": "^1.0.10",
"stat-mode": "^0.2.2",
"bluebird-lst": "^1.0.5",
"chalk": "2.1.0",
"chalk": "^2.3.0",
"debug": "^3.1.0",
"node-emoji": "^1.8.1",
"builder-util-runtime": "^0.0.0-semantic-release",
Expand Down
6 changes: 3 additions & 3 deletions packages/builder-util/src/log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BluebirdPromise from "bluebird-lst"
import { yellow } from "chalk"
import chalk from "chalk"
import { get as getEmoji } from "node-emoji"
import WritableStream = NodeJS.WritableStream

Expand All @@ -14,7 +14,7 @@ class Logger {
}

warn(message: string): void {
this.log(yellow(`Warning: ${message}`))
this.log(chalk.yellow(`Warning: ${message}`))
}

log(message: string): void {
Expand All @@ -39,7 +39,7 @@ class TtyLogger extends Logger {
}

warn(message: string): void {
this.log(`${getEmoji("warning")} ${yellow(message)}`)
this.log(`${getEmoji("warning")} ${chalk.yellow(message)}`)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/builder-util/src/promise.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { red } from "chalk"
import chalk from "chalk"

export function printErrorAndExit(error: Error) {
console.error(red((error.stack || error).toString()))
console.error(chalk.red((error.stack || error).toString()))
process.exit(-1)
}

Expand Down
8 changes: 4 additions & 4 deletions packages/builder-util/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { safeStringifyJson } from "builder-util-runtime"
import { red, yellow } from "chalk"
import chalk from "chalk"
import { ChildProcess, execFile, spawn as _spawn, SpawnOptions } from "child_process"
import { createHash } from "crypto"
import _debug from "debug"
Expand Down Expand Up @@ -99,18 +99,18 @@ export function exec(file: string, args?: Array<string> | null, options?: ExecOp
resolve(stdout.toString())
}
else {
let message = red(removePassword(`Exit code: ${(error as any).code}. ${error.message}`))
let message = chalk.red(removePassword(`Exit code: ${(error as any).code}. ${error.message}`))
if (stdout.length !== 0) {
if (file.endsWith("wine")) {
stdout = removeWineSpam(stdout.toString())
}
message += `\n${yellow(stdout.toString())}`
message += `\n${chalk.yellow(stdout.toString())}`
}
if (stderr.length !== 0) {
if (file.endsWith("wine")) {
stderr = removeWineSpam(stderr.toString())
}
message += `\n${red(stderr.toString())}`
message += `\n${chalk.red(stderr.toString())}`
}

reject(new Error(message))
Expand Down
15 changes: 12 additions & 3 deletions packages/builder-util/src/wine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const wineExecutable = new Lazy<ToolInfo>(async () => {
let version: string | null = null
let checksum: string | null = null
if (semver.gte(osVersion, "10.13.0")) {
version = "2.0.2-mac-10.13"
version = "2.0.3-mac-10.13"
// noinspection SpellCheckingInspection
checksum = "v6r9RSQBAbfvpVQNrEj48X8Cw1181rEGMRatGxSKY5p+7khzzy/0tOdfHGO8cU+GqYvH43FAKMK8p6vUfCqSSA=="
checksum = "dlEVCf0YKP5IEiOKPNE48Q8NKXbXVdhuaI9hG2oyDEay2c+93PE5qls7XUbIYq4Xi1gRK8fkWeCtzN2oLpVQtg=="
}
else if (semver.gte(osVersion, "10.12.0")) {
version = "2.0.1-mac-10.12"
Expand Down Expand Up @@ -52,7 +52,16 @@ export function execWine(file: string, args: Array<string>, options: ExecOptions
}
else {
return wineExecutable.value
.then(wine => exec(wine.path, [file].concat(args), wine.env == null ? options : {env: wine.env, ...options}))
.then(wine => {
const effectiveOptions = wine.env == null ? options : {...options}
if (wine.env != null) {
effectiveOptions.env = options.env == null ? wine.env : {
...options.env,
...wine.env,
}
}
return exec(wine.path, [file].concat(args), effectiveOptions)
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"7zip-bin": "^2.2.7",
"async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.5",
"chalk": "2.1.0",
"chalk": "^2.3.0",
"chromium-pickle-js": "^0.2.0",
"cuint": "^0.2.2",
"app-package-builder": "0.0.0-semantic-release",
Expand Down
5 changes: 1 addition & 4 deletions packages/electron-builder/src/appInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ export class AppInfo {
if (!isEmptyOrSpaces(this.buildNumber)) {
buildVersion += `.${this.buildNumber}`
}
this.buildVersion = buildVersion
}
else {
this.buildVersion = buildVersion
}
this.buildVersion = buildVersion

this.productName = info.config.productName || info.metadata.productName || info.metadata.name!
this.productFilename = sanitizeFileName(this.productName)
Expand Down
12 changes: 6 additions & 6 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BluebirdPromise from "bluebird-lst"
import { addValue, Arch, archFromString, isEmptyOrSpaces, warn } from "builder-util"
import { CancellationToken } from "builder-util-runtime"
import { executeFinally } from "builder-util/out/promise"
import { underline } from "chalk"
import chalk from "chalk"
import { PublishOptions } from "electron-publish"
import { deepAssign } from "read-config-file/out/deepAssign"
import { Configuration } from "./configuration"
Expand Down Expand Up @@ -304,19 +304,19 @@ export function configureBuildCommand(yargs: yargs.Yargs): yargs.Yargs {
.option("mac", {
group: buildGroup,
alias: ["m", "o", "macos"],
description: `Build for macOS, accepts target list (see ${underline("https://goo.gl/5uHuzj")}).`,
description: `Build for macOS, accepts target list (see ${chalk.underline("https://goo.gl/5uHuzj")}).`,
type: "array",
})
.option("linux", {
group: buildGroup,
alias: "l",
description: `Build for Linux, accepts target list (see ${underline("https://goo.gl/4vwQad")})`,
description: `Build for Linux, accepts target list (see ${chalk.underline("https://goo.gl/4vwQad")})`,
type: "array",
})
.option("win", {
group: buildGroup,
alias: ["w", "windows"],
description: `Build for Windows, accepts target list (see ${underline("https://goo.gl/jYsTEJ")})`,
description: `Build for Windows, accepts target list (see ${chalk.underline("https://goo.gl/jYsTEJ")})`,
type: "array",
})
.option("x64", {
Expand All @@ -342,7 +342,7 @@ export function configureBuildCommand(yargs: yargs.Yargs): yargs.Yargs {
.option("publish", {
group: publishGroup,
alias: "p",
description: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/tSFycD")}`,
description: `Publish artifacts (to GitHub Releases), see ${chalk.underline("https://goo.gl/tSFycD")}`,
choices: ["onTag", "onTagOrDraft", "always", "never", undefined as any],
})
.option("draft", {
Expand Down Expand Up @@ -385,7 +385,7 @@ export function configureBuildCommand(yargs: yargs.Yargs): yargs.Yargs {
.option("config", {
alias: ["c"],
group: buildGroup,
description: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`), see " + underline("https://goo.gl/YFRJOM"),
description: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`), see " + chalk.underline("https://goo.gl/YFRJOM"),
})
.group(["help", "version"], "Other:")
.example("electron-builder -mwl", "build for macOS, Windows and Linux")
Expand Down
6 changes: 3 additions & 3 deletions packages/electron-builder/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { exec, log, warn } from "builder-util"
import { printErrorAndExit } from "builder-util/out/promise"
import { cyan, dim, green, reset, underline } from "chalk"
import chalk from "chalk"
import { readJson } from "fs-extra-p"
import isCi from "is-ci"
import * as path from "path"
Expand Down Expand Up @@ -35,7 +35,7 @@ yargs
yargs => yargs,
wrap(argv => start()))
.help()
.epilog(`See ${underline("https://electron.build")} for more documentation.`)
.epilog(`See ${chalk.underline("https://electron.build")} for more documentation.`)
.strict()
.recommendCommands()
.argv
Expand Down Expand Up @@ -63,7 +63,7 @@ function checkIsOutdated() {
const notifier = updateNotifier({pkg: it})
if (notifier.update != null) {
notifier.notify({
message: `Update available ${dim(notifier.update.current)}${reset(" → ")}${green(notifier.update.latest)} \nRun ${cyan("yarn upgrade electron-builder")} to update`
message: `Update available ${chalk.dim(notifier.update.current)}${chalk.reset(" → ")}${chalk.green(notifier.update.latest)} \nRun ${chalk.cyan("yarn upgrade electron-builder")} to update`
})
}
})
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/cli/create-self-signed-cert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exec, log, spawn, TmpDir } from "builder-util"
import { unlinkIfExists } from "builder-util/out/fs"
import { bold } from "chalk"
import chalk from "chalk"
import { ensureDir } from "fs-extra-p"
import * as path from "path"
import sanitizeFileName from "sanitize-filename"
Expand All @@ -15,7 +15,7 @@ export async function createSelfSignedCert(publisher: string) {
const cer = `${tempPrefix}.cer`
const pvk = `${tempPrefix}.pvk`

log(bold('When asked to enter a password ("Create Private Key Password"), please select "None".'))
log(chalk.bold('When asked to enter a password ("Create Private Key Password"), please select "None".'))

try {
await ensureDir(path.dirname(tempPrefix))
Expand Down
14 changes: 13 additions & 1 deletion packages/electron-builder/src/options/MsiOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ export interface MsiOptions extends TargetSpecificOptions {
*/
readonly oneClick?: boolean

/***
/**
* Install per all users (per-machine).
* @default true
* @private Well, one-click per-user is not easy to write for us, feature hidden for now
*/
readonly perMachine?: boolean

/**
* *one-click installer only.* Whether to run the installed application after finish.
* @default true
*/
readonly runAfterFinish?: boolean

/**
* The [upgrade code](https://msdn.microsoft.com/en-us/library/windows/desktop/aa372375(v=vs.85).aspx). Optional, by default generated using app id.
*/
Expand All @@ -23,4 +30,9 @@ export interface MsiOptions extends TargetSpecificOptions {
* @default true
*/
readonly warningsAsErrors?: boolean

/**
* The name that will be used for all shortcuts. Defaults to the application name.
*/
readonly shortcutName?: string | null
}
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/AppxTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Target } from "../core"
import { getTemplatePath } from "../util/pathManager"
import { getSignVendorPath, isOldWin6 } from "../windowsCodeSign"
import { WinPackager } from "../winPackager"
import { VmManager } from "../parallels"
import { VmManager } from "../vm/vm"
import { createHelperDir } from "./targetUtil"
import { AppXOptions } from "../"

Expand Down
Loading

0 comments on commit 7182b6b

Please sign in to comment.