From ee2d4a90a76aecfcc04c941bd480538d238a6a59 Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 24 May 2017 14:11:38 +0200 Subject: [PATCH] fix: "status 401: Unauthorized" issue with dl.bintray.com Close #1581 --- package.json | 3 +-- packages/electron-builder-http/src/httpExecutor.ts | 3 ++- packages/electron-builder-util/src/binDownload.ts | 5 +++++ packages/electron-builder/src/targets/nsis.ts | 6 +++--- packages/electron-builder/src/windowsCodeSign.ts | 4 ++-- yarn.lock | 12 ++++++------ 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index bda1ee3d0e2..317bdace36d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/packages/electron-builder-http/src/httpExecutor.ts b/packages/electron-builder-http/src/httpExecutor.ts index 6f5f26eb683..306e27081da 100644 --- a/packages/electron-builder-http/src/httpExecutor.ts +++ b/packages/electron-builder-http/src/httpExecutor.ts @@ -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 diff --git a/packages/electron-builder-util/src/binDownload.ts b/packages/electron-builder-util/src/binDownload.ts index 70e1d5351c8..9747fa18332 100644 --- a/packages/electron-builder-util/src/binDownload.ts +++ b/packages/electron-builder-util/src/binDownload.ts @@ -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 { + 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 { let promise = versionToPromise.get(dirName) // if rejected, we will try to download again diff --git a/packages/electron-builder/src/targets/nsis.ts b/packages/electron-builder/src/targets/nsis.ts index 58e8a2b08c4..39ed5b8994d 100644 --- a/packages/electron-builder/src/targets/nsis.ts +++ b/packages/electron-builder/src/targets/nsis.ts @@ -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" @@ -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 diff --git a/packages/electron-builder/src/windowsCodeSign.ts b/packages/electron-builder/src/windowsCodeSign.ts index c7b4771d878..fce2d17cb76 100644 --- a/packages/electron-builder/src/windowsCodeSign.ts +++ b/packages/electron-builder/src/windowsCodeSign.ts @@ -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" @@ -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 { diff --git a/yarn.lock b/yarn.lock index e145807fa9d..24915d3f3b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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: