Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

builder-util

Package Overview
Dependencies
Maintainers
1
Versions
258
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 3.5.0 to 4.0.0

21

out/binDownload.js

@@ -27,13 +27,13 @@ "use strict";

const dirPath = _path.join(cachePath, dirName);
const logFlags = { path: dirPath };
const dirStat = yield (0, (_fs || _load_fs()).statOrNull)(dirPath);
//noinspection ES6MissingAwait
if (dirStat != null && dirStat.isDirectory()) {
debug(`Found existing ${name} ${dirPath}`);
(_util || _load_util()).log.debug(logFlags, `found existing`);
return dirPath;
}
(0, (_log || _load_log()).log)(`Downloading ${dirName}, please wait`);
(_util || _load_util()).log.info(Object.assign({}, logFlags, { url }), `downloading`);
// 7z cannot be extracted from the input stream, temp file is required
const tempUnpackDir = _path.join(cachePath, (0, (_tempFile || _load_tempFile()).getTempName)());
const archiveName = `${tempUnpackDir}.7z`;
debug(`Download ${name} from ${url} to ${archiveName}`);
// 7z doesn't create out dir, so, we don't create dir in parallel to download - dir creation will create parent dirs for archive file also

@@ -57,3 +57,3 @@ yield (0, (_fsExtraP || _load_fsExtraP()).emptyDir)(tempUnpackDir);

}
(0, (_log || _load_log()).warn)(`Cannot download ${name}, attempt #${attemptNumber}: ${e}`);
(_util || _load_util()).log.warn(Object.assign({}, logFlags, { attempt: attemptNumber }), `cannot download: ${e}`);
yield new (_bluebirdLst2 || _load_bluebirdLst2()).default(function (resolve, reject) {

@@ -70,5 +70,5 @@ setTimeout(function () {

yield (_bluebirdLst2 || _load_bluebirdLst2()).default.all([(0, (_fsExtraP || _load_fsExtraP()).rename)(tempUnpackDir, dirPath).catch(function (e) {
console.warn(`Cannot move downloaded ${name} into final location (another process downloaded faster?): ${e}`);
return (_util || _load_util()).log.debug(Object.assign({}, logFlags, { tempUnpackDir, e }), `cannot move downloaded into final location (another process downloaded faster?)`);
}), (0, (_fsExtraP || _load_fsExtraP()).unlink)(archiveName)]);
debug(`${name}} downloaded to ${dirPath}`);
(_util || _load_util()).log.debug(logFlags, `downloaded`);
return dirPath;

@@ -100,4 +100,2 @@ });

var _debug2 = _interopRequireDefault(require("debug"));
var _fsExtraP;

@@ -123,8 +121,2 @@

var _log;
function _load_log() {
return _log = require("./log");
}
var _nodeHttpExecutor;

@@ -146,3 +138,2 @@

const debug = (0, _debug2.default)("electron-builder:binDownload");
const versionToPromise = new Map();

@@ -149,0 +140,0 @@ function getBinFromBintray(name, version, sha2) {

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

var _log;
function _load_log() {
return _log = require("./log");
}
var _promise;

@@ -152,8 +158,2 @@

var _util;
function _load_util() {
return _util = require("./util");
}
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; } }

@@ -190,5 +190,5 @@

if (originalModeNumber !== stats.mode) {
if ((_util || _load_util()).debug.enabled) {
if ((_log || _load_log()).log.isDebugEnabled) {
const oldMode = new (_statMode || _load_statMode()).default({ mode: originalModeNumber });
(0, (_util || _load_util()).debug)(`${dest} permissions fixed from ${oldMode.toOctal()} (${oldMode.toString()}) to ${mode.toOctal()} (${mode.toString()})`);
(_log || _load_log()).log.debug({ file: dest, oldMode, mode }, "permissions fixed from");
}

@@ -200,3 +200,3 @@ // https://helgeklein.com/blog/2009/05/hard-links-and-permissions-acls/

isUseHardLink = false;
(0, (_util || _load_util()).debug)(`${dest} will be copied, but not linked, because file permissions need to be fixed`);
(_log || _load_log()).log.debug({ dest }, "copied, but not linked, because file permissions need to be fixed");
}

@@ -209,4 +209,4 @@ }

const isLog = exDevErrorHandler == null ? true : exDevErrorHandler();
if (isLog && (_util || _load_util()).debug.enabled) {
(0, (_util || _load_util()).debug)(`Cannot copy using hard link: ${e.message}`);
if (isLog && (_log || _load_log()).log.isDebugEnabled) {
(_log || _load_log()).log.debug({ error: e.message }, "cannot copy using hard link");
}

@@ -287,4 +287,4 @@ return doCopyFile(src, dest, stats);

const fileCopier = new FileCopier(options.isUseHardLink, options.transformer);
if ((_util || _load_util()).debug.enabled) {
(0, (_util || _load_util()).debug)(`Copying ${src} to ${destination}${fileCopier.isUseHardLink ? " using hard links" : ""}`);
if ((_log || _load_log()).log.isDebugEnabled) {
(_log || _load_log()).log.debug({ src, destination }, `copying${fileCopier.isUseHardLink ? " using hard links" : ""}`);
}

@@ -291,0 +291,0 @@ const createdSourceDirs = new Set();

@@ -1,5 +0,27 @@

import BluebirdPromise from "bluebird-lst";
/// <reference types="node" />
/// <reference types="debug" />
import _debug from "debug";
import WritableStream = NodeJS.WritableStream;
export declare const debug: _debug.IDebugger;
export interface Fields {
[index: string]: any;
}
export declare function setPrinter(value: ((message: string) => void) | null): void;
export declare function warn(message: string): void;
export declare function log(message: string): void;
export declare function task(title: string, promise: BluebirdPromise<any> | Promise<any>): BluebirdPromise<any>;
export declare type LogLevel = "info" | "warn" | "debug" | "notice" | "error";
export declare const PADDING = 3;
export declare class Logger {
protected readonly stream: WritableStream;
constructor(stream: WritableStream);
messageTransformer: ((message: string, level: LogLevel) => string);
filePath(file: string): string;
readonly isDebugEnabled: boolean;
info(messageOrFields: Fields | null | string, message?: string): void;
notice(messageOrFields: Fields | null | string, message?: string): void;
warn(messageOrFields: Fields | null | string, message?: string): void;
debug(fields: Fields | null, message: string): void;
private doLog(message, messageOrFields, level);
private _doLog(message, fields, level);
static createMessage(message: string, fields: Fields | null, level: LogLevel, color: (it: string) => string): string;
log(message: string): void;
}
export declare const log: Logger;

@@ -6,6 +6,4 @@ "use strict";

});
exports.log = exports.Logger = exports.PADDING = exports.debug = undefined;
exports.setPrinter = setPrinter;
exports.warn = warn;
exports.log = log;
exports.task = task;

@@ -18,21 +16,68 @@ var _chalk;

var _nodeEmoji;
var _debug2 = _interopRequireDefault(require("debug"));
function _load_nodeEmoji() {
return _nodeEmoji = require("node-emoji");
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
let printer = null;
const debug = exports.debug = (0, _debug2.default)("electron-builder");
function setPrinter(value) {
printer = value;
}
const PADDING = exports.PADDING = 3;
class Logger {
constructor(stream) {
this.stream = stream;
this.messageTransformer = it => it;
}
warn(message) {
this.log((_chalk || _load_chalk()).default.yellow(`Warning: ${message}`));
filePath(file) {
const cwd = process.cwd();
return file.startsWith(cwd) ? file.substring(cwd.length + 1) : file;
}
// noinspection JSMethodCanBeStatic
get isDebugEnabled() {
return debug.enabled;
}
info(messageOrFields, message) {
this.doLog(message, messageOrFields, "info");
}
notice(messageOrFields, message) {
this.doLog(message, messageOrFields, "notice");
}
warn(messageOrFields, message) {
this.doLog(message, messageOrFields, "warn");
}
debug(fields, message) {
if (debug.enabled) {
this._doLog(message, fields, "debug");
}
}
doLog(message, messageOrFields, level) {
if (message === undefined) {
this._doLog(messageOrFields, null, level);
} else {
this._doLog(message, messageOrFields, level);
}
}
_doLog(message, fields, level) {
const levelIndicator = "•";
const color = LEVEL_TO_COLOR[level];
this.stream.write(`${" ".repeat(PADDING)}${color(levelIndicator)} `);
this.stream.write(Logger.createMessage(this.messageTransformer(message, level), fields, level, color));
this.stream.write("\n");
}
static createMessage(message, fields, level, color) {
let text = message;
const fieldPadding = " ".repeat(Math.max(0, 16 - message.length));
text += fieldPadding;
if (fields != null) {
for (const name of Object.keys(fields)) {
let fieldValue = fields[name];
if (fieldValue != null && typeof fieldValue === "string" && fieldValue.includes("\n")) {
fieldValue = ("\n" + fieldValue).replace(/\n/g, `\n${" ".repeat(PADDING)}${fieldPadding}`);
}
text += ` ${color(name)}=${Array.isArray(fieldValue) ? JSON.stringify(fieldValue) : fieldValue}`;
}
}
return text;
}
log(message) {

@@ -45,26 +90,11 @@ if (printer == null) {

}
task(title, _promise) {
const promise = _promise;
this.log(title);
return promise;
}
}
class TtyLogger extends Logger {
constructor(stream) {
super(stream);
}
warn(message) {
this.log(`${(0, (_nodeEmoji || _load_nodeEmoji()).get)("warning")} ${(_chalk || _load_chalk()).default.yellow(message)}`);
}
}
const logger = process.stdout.isTTY ? new TtyLogger(process.stdout) : new Logger(process.stdout);
function warn(message) {
logger.warn(message);
}
function log(message) {
logger.log(message);
}
function task(title, promise) {
return logger.task(title, promise);
}
exports.Logger = Logger;
const LEVEL_TO_COLOR = {
info: (_chalk || _load_chalk()).default.blue,
notice: (_chalk || _load_chalk()).default.yellow,
warn: (_chalk || _load_chalk()).default.yellow,
debug: (_chalk || _load_chalk()).default.gray
};
const log = exports.log = new Logger(process.stdout);
//# sourceMappingURL=log.js.map

@@ -90,3 +90,3 @@ "use strict";

}
(0, (_util || _load_util()).debug)(`macOS version: ${matches[1]}`);
(_util || _load_util()).log.debug({ version: matches[1] }, "macOS version");
return clean(matches[1]);

@@ -93,0 +93,0 @@ }));

@@ -9,3 +9,3 @@ /// <reference types="debug" />

export { TmpDir } from "temp-file";
export { log, warn, task } from "./log";
export { log, debug } from "./log";
export { isMacOsSierra, isCanSignDmg } from "./macosVersion";

@@ -19,3 +19,2 @@ export { execWine, prepareWindowsExecutableArgs } from "./wine";

export { asArray } from "builder-util-runtime";
export declare const debug: _debug.IDebugger;
export declare const debug7z: _debug.IDebugger;

@@ -22,0 +21,0 @@ export declare function serializeToYaml(object: object): string;

@@ -6,3 +6,3 @@ "use strict";

});
exports.debug7z = exports.debug = exports.asArray = exports.copyFile = exports.hashFile = exports.DebugLogger = exports.AsyncTaskManager = exports.archFromString = exports.getArchSuffix = exports.toLinuxArchString = exports.Arch = exports.prepareWindowsExecutableArgs = exports.execWine = exports.isCanSignDmg = exports.isMacOsSierra = exports.task = exports.warn = exports.log = exports.TmpDir = exports.safeStringifyJson = undefined;
exports.debug7z = exports.asArray = exports.copyFile = exports.hashFile = exports.DebugLogger = exports.AsyncTaskManager = exports.archFromString = exports.getArchSuffix = exports.toLinuxArchString = exports.Arch = exports.prepareWindowsExecutableArgs = exports.execWine = exports.isCanSignDmg = exports.isMacOsSierra = exports.debug = exports.log = exports.TmpDir = exports.safeStringifyJson = undefined;

@@ -47,14 +47,8 @@ var _builderUtilRuntime;

});
Object.defineProperty(exports, "warn", {
Object.defineProperty(exports, "debug", {
enumerable: true,
get: function () {
return (_log || _load_log()).warn;
return (_log || _load_log()).debug;
}
});
Object.defineProperty(exports, "task", {
enumerable: true,
get: function () {
return (_log || _load_log()).task;
}
});

@@ -252,3 +246,2 @@ var _macosVersion;

const debug = exports.debug = (0, _debug2.default)("electron-builder");
const debug7z = exports.debug7z = (0, _debug2.default)("electron-builder:7z");

@@ -281,4 +274,4 @@ function serializeToYaml(object) {

function exec(file, args, options, isLogOutIfDebug = true) {
if (debug.enabled) {
debug(`Executing ${file} ${args == null ? "" : removePassword(args.join(" "))}`);
if ((_log || _load_log()).debug.enabled) {
(_log || _load_log()).log.debug({ file, args: args == null ? "" : removePassword(args.join(" ")) }, "executing");
if (options != null && options.env != null) {

@@ -291,6 +284,6 @@ const diffEnv = Object.assign({}, options.env);

}
debug(`env: ${(0, (_builderUtilRuntime || _load_builderUtilRuntime()).safeStringifyJson)(diffEnv)}`);
(0, (_log || _load_log()).debug)(`env: ${(0, (_builderUtilRuntime || _load_builderUtilRuntime()).safeStringifyJson)(diffEnv)}`);
}
if (options != null && options.cwd != null) {
debug(`cwd: ${options.cwd}`);
(_log || _load_log()).log.debug(null, `cwd: ${options.cwd}`);
}

@@ -301,8 +294,8 @@ }

if (error == null) {
if (isLogOutIfDebug && debug.enabled) {
if (isLogOutIfDebug && (_log || _load_log()).debug.enabled) {
if (stderr.length !== 0) {
debug(file.endsWith("wine") ? removeWineSpam(stderr.toString()) : stderr);
(0, (_log || _load_log()).debug)(file.endsWith("wine") ? removeWineSpam(stderr.toString()) : stderr);
}
if (stdout.length !== 0) {
debug(stdout);
(0, (_log || _load_log()).debug)(stdout);
}

@@ -338,3 +331,3 @@ }

options.env = getProcessEnv(options.env);
const isDebugEnabled = extraOptions == null || extraOptions.isDebugEnabled == null ? debug.enabled : extraOptions.isDebugEnabled;
const isDebugEnabled = extraOptions == null || extraOptions.isDebugEnabled == null ? (_log || _load_log()).debug.enabled : extraOptions.isDebugEnabled;
if (options.stdio == null) {

@@ -345,7 +338,7 @@ // do not ignore stdout/stderr if not debug, because in this case we will read into buffer and print on error

// use general debug.enabled to log spawn, because it doesn't produce a lot of output (the only line), but important in any case
if (debug.enabled) {
if ((_log || _load_log()).debug.enabled) {
const argsString = args.join(" ");
debug(`Spawning ${command} ${command === "docker" ? argsString : removePassword(argsString)}`);
(_log || _load_log()).log.debug({ command, args: command === "docker" ? argsString : removePassword(argsString) }, "spawning");
if (options != null && options.cwd != null) {
debug(`cwd: ${options.cwd}`);
(0, (_log || _load_log()).debug)({ cwd: options.cwd }, "");
}

@@ -387,3 +380,3 @@ }

let out = "";
if (!debug.enabled && childProcess.stdout != null) {
if (!(_log || _load_log()).debug.enabled && childProcess.stdout != null) {
childProcess.stdout.on("data", data => {

@@ -400,4 +393,4 @@ out += data;

childProcess.once(event, code => {
if (code === 0 && debug.enabled) {
debug(`${_path.basename(command)} (${childProcess.pid}) exited with exit code 0`);
if (code === 0 && (_log || _load_log()).debug.enabled) {
(_log || _load_log()).log.debug({ command: _path.basename(command), pid: childProcess.pid }, "exited with exit code 0");
}

@@ -404,0 +397,0 @@ if (code === 0) {

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

var _zipBin;
function _load_zipBin() {
return _zipBin = require("7zip-bin");
}
var _lazyVal;

@@ -66,2 +72,8 @@

var _os;
function _load_os() {
return _os = _interopRequireWildcard(require("os"));
}
var _path = _interopRequireWildcard(require("path"));

@@ -99,14 +111,2 @@

var _zipBin;
function _load_zipBin() {
return _zipBin = require("7zip-bin");
}
var _os;
function _load_os() {
return _os = _interopRequireWildcard(require("os"));
}
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; } }

@@ -117,3 +117,3 @@

if (isUseSystemWine) {
(0, (_util || _load_util()).debug)("Using system wine is forced");
(_util || _load_util()).log.debug(null, "using system wine is forced");
} else if (process.platform === "darwin") {

@@ -120,0 +120,0 @@ // assume that on travis latest version is used

{
"name": "builder-util",
"version": "3.5.0",
"version": "4.0.0",
"main": "out/util.js",

@@ -21,4 +21,3 @@ "author": "Vladimir Krivosheev",

"debug": "^3.1.0",
"node-emoji": "^1.8.1",
"builder-util-runtime": "^3.5.0",
"builder-util-runtime": "^4.0.0",
"source-map-support": "^0.5.0",

@@ -25,0 +24,0 @@ "7zip-bin": "^2.3.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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