Skip to content

Commit

Permalink
fix: "status 401: Unauthorized" issue with dl.bintray.com
Browse files Browse the repository at this point in the history
Close #1581
  • Loading branch information
develar committed May 24, 2017
1 parent a2e58c0 commit 52995df
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ajv": "^5.1.3",
"ajv-keywords": "^2.0.0",
"archiver": "^1.3.0",
"aws-sdk": "^2.55.0",
"aws-sdk": "^2.56.0",
"bluebird-lst": "^1.0.2",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.2.0",
Expand Down Expand Up @@ -78,7 +78,6 @@
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
"catharsis": "^0.8.8",
"convert-source-map": "^1.5.0",
"decompress-zip": "^0.3.0",
"depcheck": "^0.6.7",
Expand Down
5 changes: 3 additions & 2 deletions packages/electron-builder-http/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export abstract class HttpExecutor<REQUEST_OPTS, REQUEST> {
protected doDownload(requestOptions: any, destination: string, redirectCount: number, options: DownloadOptions, callback: (error: Error | null) => void, onCancel: (callback: () => void) => void) {
const request = this.doRequest(requestOptions, (response: Electron.IncomingMessage) => {
if (response.statusCode >= 400) {
callback(new Error(`Cannot download "${requestOptions.protocol || "https"}://${requestOptions.hostname}/${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`))
callback(new Error(`Cannot download "${requestOptions.protocol || "https:"}//${requestOptions.hostname}${requestOptions.path}", status ${response.statusCode}: ${response.statusMessage}`))
return
}

Expand Down Expand Up @@ -298,7 +298,8 @@ export function configureRequestOptions(options: RequestOptions, token?: string
headers["Cache-Control"] = "no-cache"
}

if (options.protocol == null) {
// do not specify for node (in any case we use https module)
if (options.protocol == null && process.versions["electron"] != null) {
options.protocol = "https:"
}
return options
Expand Down
5 changes: 5 additions & 0 deletions packages/electron-builder-util/src/binDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export function getBinFromBintray(name: string, version: string, sha2: string):
return getBin(name, dirName, `https://dl.bintray.com/electron-userland/bin/${dirName}.7z`, sha2)
}

export function getBinFromGithub(name: string, version: string, sha2: string): Promise<string> {
const dirName = `${name}-${version}`
return getBin(name, dirName, `https://github.com/electron-userland/electron-builder-binaries/releases/download/${dirName}/${dirName}.7z`, sha2)
}

export function getBin(name: string, dirName: string, url: string, sha2: string): Promise<string> {
let promise = versionToPromise.get(dirName)
// if rejected, we will try to download again
Expand Down
8 changes: 4 additions & 4 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BluebirdPromise from "bluebird-lst"
import _debug from "debug"
import { Arch, Target } from "electron-builder-core"
import { asArray, debug, doSpawn, exec, getPlatformIconFileName, handleProcess, isEmptyOrSpaces, use } from "electron-builder-util"
import { getBinFromBintray } from "electron-builder-util/out/binDownload"
import { getBinFromGithub } from "electron-builder-util/out/binDownload"
import { copyFile } from "electron-builder-util/out/fs"
import { log, subTask, warn } from "electron-builder-util/out/log"
import { asyncAll } from "electron-builder-util/out/promise"
Expand All @@ -24,9 +24,9 @@ const debugLang = _debug("electron-builder:lang")
const ELECTRON_BUILDER_NS_UUID = "50e065bc-3134-11e6-9bab-38c9862bdaf3"

// noinspection SpellCheckingInspection
const nsisPathPromise = getBinFromBintray("nsis", "3.0.1.13", "2921dd404ce9b69679088a6f1409a56dd360da2077fe1019573c0712c9edf057")
const nsisPathPromise = getBinFromGithub("nsis", "3.0.1.13", "2921dd404ce9b69679088a6f1409a56dd360da2077fe1019573c0712c9edf057")
// noinspection SpellCheckingInspection
const nsisResourcePathPromise = getBinFromBintray("nsis-resources", "3.0.0", "cde0e77b249e29d74250bf006aa355d3e02b32226e1c6431fb48facae41d8a7e")
const nsisResourcePathPromise = getBinFromGithub("nsis-resources", "3.0.0", "cde0e77b249e29d74250bf006aa355d3e02b32226e1c6431fb48facae41d8a7e")

const USE_NSIS_BUILT_IN_COMPRESSOR = false

Expand Down Expand Up @@ -344,7 +344,7 @@ export class NsisTarget extends Target {
menu = sanitizeFileName(packager.appInfo.companyName)
}
else {
menu = (<string>options.menuCategory).split(/\/|\\/).map(it => sanitizeFileName(it)).join("\\")
menu = (<string>options.menuCategory).split(/[\/\\]/).map(it => sanitizeFileName(it)).join("\\")
}
if (!isEmptyOrSpaces(menu)) {
defines.MENU_FILENAME = menu
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/windowsCodeSign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from "electron-builder-util"
import { getBinFromBintray } from "electron-builder-util/out/binDownload"
import { getBinFromGithub } from "electron-builder-util/out/binDownload"
import { rename } from "fs-extra-p"
import isCi from "is-ci"
import { release } from "os"
Expand All @@ -10,7 +10,7 @@ const TOOLS_VERSION = "1.7.0"

export function getSignVendorPath() {
//noinspection SpellCheckingInspection
return getBinFromBintray("winCodeSign", TOOLS_VERSION, "a34a60e74d02b81d0303e498f03c70ce0133f908b671f62ec32896db5cd0a716")
return getBinFromGithub("winCodeSign", TOOLS_VERSION, "a34a60e74d02b81d0303e498f03c70ce0133f908b671f62ec32896db5cd0a716")
}

export interface FileCodeSigningInfo {
Expand Down
1 change: 1 addition & 0 deletions test/src/windows/portableTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { app } from "../helpers/packTester"
test.ifAll.ifNotCiMac("portable", app({
targets: Platform.WINDOWS.createTarget(["portable", "nsis"]),
config: {
publish: null,
nsis: {
}
}
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ acorn@^3.0.4, acorn@^3.3.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"

acorn@^4.0.4:
version "4.0.11"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.11.tgz#edcda3bd937e7556410d42ed5860f67399c794c0"
version "4.0.13"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787"

ajv-keywords@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -271,9 +271,9 @@ asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"

aws-sdk@^2.55.0:
version "2.55.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.55.0.tgz#7528f3729ecbc8e5aea42ac89e1ff2537086f7c2"
aws-sdk@^2.56.0:
version "2.56.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.56.0.tgz#a18c3005c7adb1c6edc86b95f2833aedd4f86493"
dependencies:
buffer "5.0.6"
crypto-browserify "1.0.9"
Expand Down Expand Up @@ -688,7 +688,7 @@ caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"

catharsis@^0.8.8, catharsis@~0.8.8:
catharsis@~0.8.8:
version "0.8.8"
resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.8.tgz#693479f43aac549d806bd73e924cd0d944951a06"
dependencies:
Expand Down

0 comments on commit 52995df

Please sign in to comment.