Skip to content

Commit

Permalink
fix(electron-updater): update sign verification error
Browse files Browse the repository at this point in the history
Close #1641
  • Loading branch information
develar committed Jun 12, 2017
1 parent 8e957c8 commit e713bbe
Show file tree
Hide file tree
Showing 18 changed files with 599 additions and 289 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- ssh [email protected] git-lfs-authenticate $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git download
- git lfs pull
- mkdir -p $CIRCLE_TEST_REPORTS/reports
- docker run --rm --env-file ./test/docker-env.list -v ${PWD}:/project -v ~/.electron:/root/.electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/electron-builder:wine /bin/bash -c "node ./test/vendor/yarn.js --link-duplicates --pure-lockfile && node ./test/vendor/yarn.js test" && mv -f test/test-report.xml $CIRCLE_TEST_REPORTS/reports/test-report.xml
- docker run --rm --env-file ./test/docker-env.list -v ${PWD}:/project -v ~/.cache/electron:/root/.cache/electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/electron-builder:wine /bin/bash -c "node ./test/vendor/yarn.js --link-duplicates --pure-lockfile && node ./test/vendor/yarn.js test" && mv -f test/test-report.xml $CIRCLE_TEST_REPORTS/reports/test-report.xml

test:
override:
Expand Down
87 changes: 87 additions & 0 deletions packages/electron-builder-http/src/rfc2253Parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
export function parseDn(seq: string): Map<string, string> {
let quoted = false
let key: string | null = null
let token = ""
let nextNonSpace = 0

seq = seq.trim()
const result = new Map<string, string>()
for (let i = 0; i <= seq.length; i++) {
if (i === seq.length) {
if (key !== null) {
result.set(key, token)
}
break
}

const ch = seq[i]
if (quoted) {
if (ch === '"') {
quoted = false
continue
}
}
else {
if (ch === '"') {
quoted = true
continue
}

if (ch === "\\") {
i++
const ord = parseInt(seq.slice(i, i + 2), 16)
if (Number.isNaN(ord)) {
token += seq[i]
}
else {
i++
token += String.fromCharCode(ord)
}
continue
}

if (key === null && ch === "=") {
key = token
token = ""
continue
}

if (ch === "," || ch === ";" || ch === "+") {
if (key !== null) {
result.set(key, token)
}
key = null
token = ""
continue
}
}

if (ch === " " && !quoted) {
if (token.length === 0) {
continue
}

if (i > nextNonSpace) {
let j = i
while (seq[j] === " ") {
j++
}
nextNonSpace = j
}

if (nextNonSpace >= seq.length
|| seq[nextNonSpace] === ","
|| seq[nextNonSpace] === ";"
|| (key === null && seq[nextNonSpace] === "=")
|| (key !== null && seq[nextNonSpace] === "+")
) {
i = nextNonSpace - 1
continue
}
}

token += ch
}

return result
}
2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"certs/root_certs.keychain"
],
"bin": {
"build": "./out/cli/build-cli.js",
"build": "./out/cli/cliOptions.js",
"install-app-deps": "./out/cli/install-app-deps.js",
"node-gyp-rebuild": "./out/cli/node-gyp-rebuild.js"
},
Expand Down
131 changes: 130 additions & 1 deletion packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import BluebirdPromise from "bluebird-lst"
import { cyan, dim, green, reset, underline } from "chalk"
import { Arch, archFromString, DIR_TARGET, Platform } from "electron-builder-core"
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
import { addValue, isEmptyOrSpaces } from "electron-builder-util"
import { warn } from "electron-builder-util/out/log"
import { executeFinally } from "electron-builder-util/out/promise"
import { executeFinally, printErrorAndExit } from "electron-builder-util/out/promise"
import { PublishOptions } from "electron-publish"
import { readJson } from "fs-extra-p"
import isCi from "is-ci"
import * as path from "path"
import updateNotifier from "update-notifier"
import { normalizePlatforms, Packager } from "./packager"
import { PackagerOptions } from "./packagerApi"
import { PublishManager } from "./publish/PublishManager"
Expand Down Expand Up @@ -212,4 +217,128 @@ export async function build(rawOptions?: CliOptions): Promise<Array<string>> {
return publishManager.awaitTasks()
}
})
}

/** @private */
export function configureBuildCommand(yargs: yargs.Yargs): yargs.Yargs {
const publishGroup = "Publishing:"
const buildGroup = "Building:"
const deprecated = "Deprecated:"

return yargs
.option("mac", {
group: buildGroup,
alias: ["m", "o", "macos"],
describe: `Build for macOS, accepts target list (see ${underline("https://goo.gl/HAnnq8")}).`,
type: "array",
})
.option("linux", {
group: buildGroup,
alias: "l",
describe: `Build for Linux, accepts target list (see ${underline("https://goo.gl/O80IL2")})`,
type: "array",
})
.option("win", {
group: buildGroup,
alias: ["w", "windows"],
describe: `Build for Windows, accepts target list (see ${underline("https://goo.gl/dL4i8i")})`,
type: "array",
})
.option("x64", {
group: buildGroup,
describe: "Build for x64",
type: "boolean",
})
.option("ia32", {
group: buildGroup,
describe: "Build for ia32",
type: "boolean",
})
.option("armv7l", {
group: buildGroup,
describe: "Build for armv7l",
type: "boolean",
})
.option("dir", {
group: buildGroup,
describe: "Build unpacked dir. Useful to test.",
type: "boolean",
})
.option("publish", {
group: publishGroup,
alias: "p",
describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`,
choices: ["onTag", "onTagOrDraft", "always", "never"],
})
.option("draft", {
group: publishGroup,
describe: "Create a draft (unpublished) release",
type: "boolean",
default: undefined,
})
.option("prerelease", {
group: publishGroup,
describe: "Identify the release as a prerelease",
type: "boolean",
default: undefined,
})
.option("platform", {
group: deprecated,
describe: "The target platform (preferred to use --mac, --win or --linux)",
choices: ["mac", "win", "linux", "darwin", "win32", "all"],
})
.option("arch", {
group: deprecated,
describe: "The target arch (preferred to use --x64 or --ia32)",
choices: ["ia32", "x64", "all"],
})
.option("extraMetadata", {
alias: ["em"],
group: buildGroup,
describe: "Inject properties to package.json (asar only)",
})
.option("prepackaged", {
alias: ["pd"],
group: buildGroup,
describe: "The path to prepackaged app (to pack in a distributable format)",
})
.option("projectDir", {
alias: ["project"],
group: buildGroup,
describe: "The path to project directory. Defaults to current working directory.",
})
.option("config", {
alias: ["c"],
group: buildGroup,
describe: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`), see " + underline("https://goo.gl/YFRJOM"),
})
.group(["help", "version"], "Other:")
.example("build -mwl", "build for macOS, Windows and Linux")
.example("build --linux deb tar.xz", "build deb and tar.xz for Linux")
.example("build --win --ia32", "build for Windows ia32")
.example("build --em.foo=bar", "set package.json property `foo` to `bar`")
.example("build --config.nsis.unicode=false", "configure unicode options for NSIS")
}

/** @private */
export function buildCommandHandler(args: CliOptions) {
if (!isCi && process.env.NO_UPDATE_NOTIFIER == null) {
readJson(path.join(__dirname, "..", "..", "package.json"))
.then(it => {
if (it.version === "0.0.0-semantic-release") {
return
}

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("npm i electron-builder --save-dev")} to update`
})
}
})
.catch(e => warn(`Cannot check updates: ${e}`))
}

build(args)
.catch(printErrorAndExit)
}
30 changes: 0 additions & 30 deletions packages/electron-builder/src/cli/build-cli.ts

This file was deleted.

Loading

0 comments on commit e713bbe

Please sign in to comment.