Socket
Socket
Sign inDemoInstall

builder-util

Package Overview
Dependencies
Maintainers
1
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

builder-util - npm Package Compare versions

Comparing version 4.2.5 to 5.0.0

2

out/binDownload.d.ts

@@ -1,3 +0,3 @@

export declare function getBinFromBintray(name: string, version: string, sha2: string): Promise<string>;
export declare function getBinFromGithub(name: string, version: string, checksum: string): Promise<string>;
export declare function getBin(name: string, dirName: string, url: string, checksum: string): Promise<string>;
export declare function download(url: string, output: string, checksum?: string | null): Promise<void>;

@@ -13,8 +13,2 @@ "use strict";

var _bluebirdLst2;
function _load_bluebirdLst2() {
return _bluebirdLst2 = _interopRequireDefault(require("bluebird-lst"));
}
// we cache in the global location - in the home dir, not in the node_modules/.cache (https://www.npmjs.com/package/find-cache-dir) because

@@ -40,30 +34,7 @@ // * don't need to find node_modules

yield (0, (_fsExtraP || _load_fsExtraP()).emptyDir)(tempUnpackDir);
const options = {
skipDirCreation: true,
cancellationToken: new (_builderUtilRuntime || _load_builderUtilRuntime()).CancellationToken()
};
if (checksum.length === 64 && !checksum.includes("+") && !checksum.includes("Z") && !checksum.includes("=")) {
options.sha2 = checksum;
} else {
options.sha512 = checksum;
}
for (let attemptNumber = 1; attemptNumber < 4; attemptNumber++) {
try {
yield (_nodeHttpExecutor || _load_nodeHttpExecutor()).httpExecutor.download(url, archiveName, options);
} catch (e) {
if (attemptNumber >= 3) {
throw e;
}
(_util || _load_util()).log.warn(Object.assign({}, logFlags, { attempt: attemptNumber }), `cannot download: ${e}`);
yield new (_bluebirdLst2 || _load_bluebirdLst2()).default(function (resolve, reject) {
setTimeout(function () {
return (_nodeHttpExecutor || _load_nodeHttpExecutor()).httpExecutor.download(url, archiveName, options).then(resolve).catch(reject);
}, 1000 * attemptNumber);
});
}
}
yield download(url, archiveName, checksum);
yield (0, (_util || _load_util()).spawn)((_zipBin || _load_zipBin()).path7za, (0, (_util || _load_util()).debug7zArgs)("x").concat(archiveName, `-o${tempUnpackDir}`), {
cwd: cachePath
});
yield (_bluebirdLst2 || _load_bluebirdLst2()).default.all([(0, (_fsExtraP || _load_fsExtraP()).rename)(tempUnpackDir, dirPath).catch(function (e) {
yield Promise.all([(0, (_fsExtraP || _load_fsExtraP()).rename)(tempUnpackDir, dirPath).catch(function (e) {
return (_util || _load_util()).log.debug(Object.assign({}, logFlags, { tempUnpackDir, e }), `cannot move downloaded into final location (another process downloaded faster?)`);

@@ -82,5 +53,5 @@ }), (0, (_fsExtraP || _load_fsExtraP()).unlink)(archiveName)]);

exports.getBinFromBintray = getBinFromBintray;
exports.getBinFromGithub = getBinFromGithub;
exports.getBin = getBin;
exports.download = download;

@@ -93,6 +64,6 @@ var _zipBin;

var _builderUtilRuntime;
var _appBuilderBin;
function _load_builderUtilRuntime() {
return _builderUtilRuntime = require("builder-util-runtime");
function _load_appBuilderBin() {
return _appBuilderBin = require("app-builder-bin");
}

@@ -120,8 +91,2 @@

var _nodeHttpExecutor;
function _load_nodeHttpExecutor() {
return _nodeHttpExecutor = require("./nodeHttpExecutor");
}
var _util;

@@ -135,9 +100,3 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const versionToPromise = new Map();
function getBinFromBintray(name, version, sha2) {
const dirName = `${name}-${version}`;
return getBin(name, dirName, `https://dl.bintray.com/electron-userland/bin/${dirName}.7z`, sha2);
}
function getBinFromGithub(name, version, checksum) {

@@ -150,3 +109,3 @@ const dirName = `${name}-${version}`;

// if rejected, we will try to download again
if (promise != null && !promise.isRejected()) {
if (promise != null) {
return promise;

@@ -157,2 +116,9 @@ }

return promise;
}
function download(url, output, checksum) {
const args = ["download", "--url", url, "--output", output];
if (checksum != null) {
args.push("--sha512", checksum);
}
return (0, (_util || _load_util()).spawn)((_appBuilderBin || _load_appBuilderBin()).appBuilderPath, args);
}
/// <reference types="node" />
import { DownloadOptions, HttpExecutor } from "builder-util-runtime";
import { HttpExecutor, DownloadOptions } from "builder-util-runtime";
import { ClientRequest } from "http";
export declare class NodeHttpExecutor extends HttpExecutor<ClientRequest> {
private httpsAgentPromise;
download(url: string, destination: string, options?: DownloadOptions): Promise<string>;
download(url: string, destination: string, options: DownloadOptions): Promise<string>;
doRequest(options: any, callback: (response: any) => void): any;
}
export declare const httpExecutor: NodeHttpExecutor;

@@ -8,64 +8,2 @@ "use strict";

var _bluebirdLst;
function _load_bluebirdLst() {
return _bluebirdLst = require("bluebird-lst");
}
// only https proxy
let proxyFromNpm = (() => {
var _ref = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
let data = "";
try {
data = yield (0, (_fsExtraP || _load_fsExtraP()).readFile)(_path.join((0, (_os || _load_os()).homedir)(), ".npmrc"), "utf-8");
} catch (ignored) {
return null;
}
if (!data) {
return null;
}
try {
const config = (0, (_ini || _load_ini()).parse)(data);
return config["https-proxy"] || config.proxy;
} catch (e) {
// used in nsis auto-updater, do not use .util.warn here
console.warn(e);
return null;
}
});
return function proxyFromNpm() {
return _ref.apply(this, arguments);
};
})();
// only https url
let createAgent = (() => {
var _ref2 = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
let proxyString = process.env.npm_config_https_proxy || process.env.HTTPS_PROXY || process.env.https_proxy || process.env.npm_config_proxy;
if (!proxyString) {
proxyString = yield proxyFromNpm();
if (!proxyString) {
return null;
}
}
const proxy = (0, (_url || _load_url()).parse)(proxyString);
const proxyProtocol = proxy.protocol === "https:" ? "Https" : "Http";
return require("tunnel-agent")[`httpsOver${proxyProtocol}`]({
proxy: {
port: proxy.port || (proxyProtocol === "Https" ? 443 : 80),
host: proxy.hostname,
proxyAuth: proxy.auth
}
});
});
return function createAgent() {
return _ref2.apply(this, arguments);
};
})();
//# sourceMappingURL=nodeHttpExecutor.js.map
var _builderUtilRuntime;

@@ -77,6 +15,6 @@

var _fsExtraP;
var _binDownload;
function _load_fsExtraP() {
return _fsExtraP = require("fs-extra-p");
function _load_binDownload() {
return _binDownload = require("./binDownload");
}

@@ -96,54 +34,9 @@

var _ini;
function _load_ini() {
return _ini = require("ini");
}
var _os;
function _load_os() {
return _os = require("os");
}
var _path = _interopRequireWildcard(require("path"));
var _url;
function _load_url() {
return _url = require("url");
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
class NodeHttpExecutor extends (_builderUtilRuntime || _load_builderUtilRuntime()).HttpExecutor {
constructor() {
super(...arguments);
this.httpsAgentPromise = null;
// used only in tests of electron-updater
download(url, destination, options) {
return (0, (_binDownload || _load_binDownload()).download)(url, destination, options == null ? null : options.sha512).then(() => destination);
}
download(url, destination, options = { cancellationToken: new (_builderUtilRuntime || _load_builderUtilRuntime()).CancellationToken() }) {
var _this = this;
return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
if (!options.skipDirCreation) {
yield (0, (_fsExtraP || _load_fsExtraP()).ensureDir)(_path.dirname(destination));
}
if (_this.httpsAgentPromise == null) {
_this.httpsAgentPromise = createAgent();
}
const agent = yield _this.httpsAgentPromise;
return yield options.cancellationToken.createPromise(function (resolve, reject, onCancel) {
_this.doDownload((0, (_builderUtilRuntime || _load_builderUtilRuntime()).configureRequestOptionsFromUrl)(url, {
headers: options.headers || undefined,
agent
}), destination, 0, options, function (error) {
if (error == null) {
resolve(destination);
} else {
reject(error);
}
}, onCancel);
});
})();
}
doRequest(options, callback) {

@@ -154,2 +47,3 @@ return (options.protocol === "http:" ? (_http || _load_http()).request : (_https || _load_https()).request)(options, callback);

exports.NodeHttpExecutor = NodeHttpExecutor;
const httpExecutor = exports.httpExecutor = new NodeHttpExecutor();
const httpExecutor = exports.httpExecutor = new NodeHttpExecutor();
//# sourceMappingURL=nodeHttpExecutor.js.map
{
"name": "builder-util",
"version": "4.2.5",
"version": "5.0.0",
"main": "out/util.js",

@@ -14,2 +14,3 @@ "author": "Vladimir Krivosheev",

"dependencies": {
"app-builder-bin": "1.0.5",
"temp-file": "^3.1.1",

@@ -24,5 +25,3 @@ "fs-extra-p": "^4.5.0",

"source-map-support": "^0.5.3",
"7zip-bin": "~3.0.0",
"ini": "^1.3.5",
"tunnel-agent": "^0.6.0",
"7zip-bin": "~3.1.0",
"semver": "^5.5.0",

@@ -29,0 +28,0 @@ "lazy-val": "^1.0.3",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc