redis-memory-server
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -8,9 +8,9 @@ "use strict"; | ||
require("./util/resolve-config"); // import it for the side-effects (globals) | ||
var RedisBinary_1 = __importDefault(require("./util/RedisBinary")); | ||
const RedisBinary_1 = __importDefault(require("./util/RedisBinary")); | ||
exports.RedisBinary = RedisBinary_1.default; | ||
var RedisInstance_1 = __importDefault(require("./util/RedisInstance")); | ||
const RedisInstance_1 = __importDefault(require("./util/RedisInstance")); | ||
exports.RedisInstance = RedisInstance_1.default; | ||
var RedisMemoryServer_1 = __importDefault(require("./RedisMemoryServer")); | ||
const RedisMemoryServer_1 = __importDefault(require("./RedisMemoryServer")); | ||
exports.RedisMemoryServer = RedisMemoryServer_1.default; | ||
exports.default = RedisMemoryServer_1.default; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -41,29 +34,2 @@ if (k2 === undefined) k2 = k; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -73,10 +39,10 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tmp = __importStar(require("tmp")); | ||
var get_port_1 = __importDefault(require("get-port")); | ||
var db_util_1 = require("./util/db_util"); | ||
var RedisInstance_1 = __importDefault(require("./util/RedisInstance")); | ||
var debug_1 = __importDefault(require("debug")); | ||
var log = debug_1.default('RedisMS:RedisMemoryServer'); | ||
const tmp = __importStar(require("tmp")); | ||
const get_port_1 = __importDefault(require("get-port")); | ||
const db_util_1 = require("./util/db_util"); | ||
const RedisInstance_1 = __importDefault(require("./util/RedisInstance")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const log = (0, debug_1.default)('RedisMS:RedisMemoryServer'); | ||
tmp.setGracefulCleanup(); | ||
var RedisMemoryServer = /** @class */ (function () { | ||
class RedisMemoryServer { | ||
/** | ||
@@ -88,6 +54,6 @@ * Create an Redis-Memory-Sever Instance | ||
*/ | ||
function RedisMemoryServer(opts) { | ||
constructor(opts) { | ||
this.runningInstance = null; | ||
this.instanceInfoSync = null; | ||
this.opts = __assign({}, opts); | ||
this.opts = Object.assign({}, opts); | ||
if ((opts === null || opts === void 0 ? void 0 : opts.autoStart) === true) { | ||
@@ -102,19 +68,12 @@ log('Autostarting Redis instance...'); | ||
*/ | ||
RedisMemoryServer.create = function (opts) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var instance; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
instance = new RedisMemoryServer(__assign(__assign({}, opts), { autoStart: false })); | ||
if (!(opts === null || opts === void 0 ? void 0 : opts.autoStart)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, instance.start()]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, instance]; | ||
} | ||
}); | ||
static create(opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// create an instance WITHOUT autoStart so that the user can await it | ||
const instance = new RedisMemoryServer(Object.assign(Object.assign({}, opts), { autoStart: false })); | ||
if (opts === null || opts === void 0 ? void 0 : opts.autoStart) { | ||
yield instance.start(); | ||
} | ||
return instance; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -124,35 +83,32 @@ * Start the in-memory Instance | ||
*/ | ||
RedisMemoryServer.prototype.start = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
log('Called RedisMemoryServer.start() method'); | ||
if (this.runningInstance) { | ||
throw new Error('Redis instance already in status startup/running/error. Use debug for more info.'); | ||
start() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
log('Called RedisMemoryServer.start() method'); | ||
if (this.runningInstance) { | ||
throw new Error('Redis instance already in status startup/running/error. Use debug for more info.'); | ||
} | ||
this.runningInstance = this._startUpInstance() | ||
.catch((err) => { | ||
var _a; | ||
if (err.message === 'redis-server shutting down' || err === 'redis-server shutting down') { | ||
log(`Redis did not start. Trying to start on another port one more time...`); | ||
if ((_a = this.opts.instance) === null || _a === void 0 ? void 0 : _a.port) { | ||
this.opts.instance.port = null; | ||
} | ||
return this._startUpInstance(); | ||
} | ||
this.runningInstance = this._startUpInstance() | ||
.catch(function (err) { | ||
var _a; | ||
if (err.message === 'redis-server shutting down' || err === 'redis-server shutting down') { | ||
log("Redis did not start. Trying to start on another port one more time..."); | ||
if ((_a = _this.opts.instance) === null || _a === void 0 ? void 0 : _a.port) { | ||
_this.opts.instance.port = null; | ||
} | ||
return _this._startUpInstance(); | ||
} | ||
throw err; | ||
}) | ||
.catch(function (err) { | ||
if (!debug_1.default.enabled('RedisMS:RedisMemoryServer')) { | ||
console.warn('Starting the instance failed, please enable debug for more infomation'); | ||
} | ||
throw err; | ||
}); | ||
return [2 /*return*/, this.runningInstance.then(function (data) { | ||
_this.instanceInfoSync = data; | ||
return true; | ||
})]; | ||
throw err; | ||
}) | ||
.catch((err) => { | ||
if (!debug_1.default.enabled('RedisMS:RedisMemoryServer')) { | ||
console.warn('Starting the instance failed, please enable debug for more infomation'); | ||
} | ||
throw err; | ||
}); | ||
return this.runningInstance.then((data) => { | ||
this.instanceInfoSync = data; | ||
return true; | ||
}); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -162,78 +118,60 @@ * Internal Function to start an instance | ||
*/ | ||
RedisMemoryServer.prototype._startUpInstance = function () { | ||
_startUpInstance() { | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var instOpts, data, instance; | ||
var _e; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
case 0: | ||
instOpts = (_a = this.opts.instance) !== null && _a !== void 0 ? _a : {}; | ||
_e = {}; | ||
return [4 /*yield*/, get_port_1.default({ port: (_b = instOpts.port) !== null && _b !== void 0 ? _b : undefined })]; | ||
case 1: | ||
data = (_e.port = _f.sent(), | ||
_e.ip = (_c = instOpts.ip) !== null && _c !== void 0 ? _c : '127.0.0.1', | ||
_e.tmpDir = undefined, | ||
_e); | ||
if (instOpts.port != data.port) { | ||
log("starting with port " + data.port + ", since " + instOpts.port + " was locked:", data.port); | ||
} | ||
log("Starting Redis instance with following options: " + JSON.stringify(data)); | ||
return [4 /*yield*/, RedisInstance_1.default.run({ | ||
instance: { | ||
ip: data.ip, | ||
port: data.port, | ||
args: instOpts.args, | ||
}, | ||
binary: this.opts.binary, | ||
spawn: this.opts.spawn, | ||
})]; | ||
case 2: | ||
instance = _f.sent(); | ||
return [2 /*return*/, __assign(__assign({}, data), { instance: instance, childProcess: (_d = instance.childProcess) !== null && _d !== void 0 ? _d : undefined })]; | ||
} | ||
return __awaiter(this, void 0, void 0, function* () { | ||
/** Shortcut to this.opts.instance */ | ||
const instOpts = (_a = this.opts.instance) !== null && _a !== void 0 ? _a : {}; | ||
const data = { | ||
port: yield (0, get_port_1.default)({ port: (_b = instOpts.port) !== null && _b !== void 0 ? _b : undefined }), | ||
ip: (_c = instOpts.ip) !== null && _c !== void 0 ? _c : '127.0.0.1', | ||
tmpDir: undefined, | ||
}; | ||
if (instOpts.port != data.port) { | ||
log(`starting with port ${data.port}, since ${instOpts.port} was locked:`, data.port); | ||
} | ||
log(`Starting Redis instance with following options: ${JSON.stringify(data)}`); | ||
// Download if not exists redis binaries in ~/.redis-prebuilt | ||
// After that startup Redis instance | ||
const instance = yield RedisInstance_1.default.run({ | ||
instance: { | ||
ip: data.ip, | ||
port: data.port, | ||
args: instOpts.args, | ||
}, | ||
binary: this.opts.binary, | ||
spawn: this.opts.spawn, | ||
}); | ||
return Object.assign(Object.assign({}, data), { instance: instance, childProcess: (_d = instance.childProcess) !== null && _d !== void 0 ? _d : undefined }); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Stop the current In-Memory Instance | ||
*/ | ||
RedisMemoryServer.prototype.stop = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, instance, port, tmpDir; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
log('Called RedisMemoryServer.stop() method'); | ||
// just return "true" if the instance is already running / defined | ||
if (db_util_1.isNullOrUndefined(this.runningInstance)) { | ||
log('Instance is already stopped, returning true'); | ||
return [2 /*return*/, true]; | ||
} | ||
return [4 /*yield*/, this.ensureInstance()]; | ||
case 1: | ||
_a = _b.sent(), instance = _a.instance, port = _a.port, tmpDir = _a.tmpDir; | ||
log("Shutdown Redis server on port " + port + " with pid " + (instance.getPid() || '')); | ||
return [4 /*yield*/, instance.kill()]; | ||
case 2: | ||
_b.sent(); | ||
this.runningInstance = null; | ||
this.instanceInfoSync = null; | ||
if (tmpDir) { | ||
log("Removing tmpDir " + tmpDir.name); | ||
tmpDir.removeCallback(); | ||
} | ||
return [2 /*return*/, true]; | ||
} | ||
}); | ||
stop() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
log('Called RedisMemoryServer.stop() method'); | ||
// just return "true" if the instance is already running / defined | ||
if ((0, db_util_1.isNullOrUndefined)(this.runningInstance)) { | ||
log('Instance is already stopped, returning true'); | ||
return true; | ||
} | ||
const { instance, port, tmpDir } = yield this.ensureInstance(); | ||
log(`Shutdown Redis server on port ${port} with pid ${instance.getPid() || ''}`); | ||
yield instance.kill(); | ||
this.runningInstance = null; | ||
this.instanceInfoSync = null; | ||
if (tmpDir) { | ||
log(`Removing tmpDir ${tmpDir.name}`); | ||
tmpDir.removeCallback(); | ||
} | ||
return true; | ||
}); | ||
}; | ||
} | ||
/** | ||
* Get Information about the currently running instance, if it is not running it returns "false" | ||
*/ | ||
RedisMemoryServer.prototype.getInstanceInfo = function () { | ||
getInstanceInfo() { | ||
var _a; | ||
return (_a = this.instanceInfoSync) !== null && _a !== void 0 ? _a : false; | ||
}; | ||
} | ||
/** | ||
@@ -243,51 +181,35 @@ * Ensure that the instance is running | ||
*/ | ||
RedisMemoryServer.prototype.ensureInstance = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
log('Called RedisMemoryServer.ensureInstance() method'); | ||
if (this.runningInstance) { | ||
return [2 /*return*/, this.runningInstance]; | ||
} | ||
log(' - no running instance, call `start()` command'); | ||
return [4 /*yield*/, this.start()]; | ||
case 1: | ||
_a.sent(); | ||
log(' - `start()` command was succesfully resolved'); | ||
// check again for 1. Typescript-type reasons and 2. if .start failed to throw an error | ||
if (!this.runningInstance) { | ||
throw new Error('Ensure-Instance failed to start an instance!'); | ||
} | ||
return [2 /*return*/, this.runningInstance]; | ||
} | ||
}); | ||
ensureInstance() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
log('Called RedisMemoryServer.ensureInstance() method'); | ||
if (this.runningInstance) { | ||
return this.runningInstance; | ||
} | ||
log(' - no running instance, call `start()` command'); | ||
yield this.start(); | ||
log(' - `start()` command was succesfully resolved'); | ||
// check again for 1. Typescript-type reasons and 2. if .start failed to throw an error | ||
if (!this.runningInstance) { | ||
throw new Error('Ensure-Instance failed to start an instance!'); | ||
} | ||
return this.runningInstance; | ||
}); | ||
}; | ||
} | ||
/** | ||
* Get a redis host | ||
*/ | ||
RedisMemoryServer.prototype.getHost = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.getIp()]; | ||
}); | ||
getHost() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.getIp(); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Get a redis IP | ||
*/ | ||
RedisMemoryServer.prototype.getIp = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var ip; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.ensureInstance()]; | ||
case 1: | ||
ip = (_a.sent()).ip; | ||
return [2 /*return*/, ip]; | ||
} | ||
}); | ||
getIp() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { ip } = yield this.ensureInstance(); | ||
return ip; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -297,18 +219,10 @@ * Get the Port of the currently running Instance | ||
*/ | ||
RedisMemoryServer.prototype.getPort = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var port; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.ensureInstance()]; | ||
case 1: | ||
port = (_a.sent()).port; | ||
return [2 /*return*/, port]; | ||
} | ||
}); | ||
getPort() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { port } = yield this.ensureInstance(); | ||
return port; | ||
}); | ||
}; | ||
return RedisMemoryServer; | ||
}()); | ||
} | ||
} | ||
exports.default = RedisMemoryServer; | ||
//# sourceMappingURL=RedisMemoryServer.js.map |
@@ -1,3 +0,3 @@ | ||
export declare type DebugFn = (...args: any[]) => any; | ||
export declare type DebugPropT = boolean; | ||
export type DebugFn = (...args: any[]) => any; | ||
export type DebugPropT = boolean; | ||
export interface DownloadProgressT { | ||
@@ -9,3 +9,3 @@ current: number; | ||
} | ||
export declare type CallbackFn = (...args: any[]) => any; | ||
export type CallbackFn = (...args: any[]) => any; | ||
export { SpawnOptions } from 'child_process'; | ||
@@ -19,4 +19,4 @@ export interface RedisMemoryInstancePropBaseT { | ||
} | ||
export declare type ErrorVoidCallback = (err: any) => void; | ||
export declare type EmptyVoidCallback = () => void; | ||
export type ErrorVoidCallback = (err: any) => void; | ||
export type EmptyVoidCallback = () => void; | ||
//# sourceMappingURL=types.d.ts.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -22,29 +11,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -55,18 +17,16 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.LATEST_VERSION = void 0; | ||
var fs_1 = __importDefault(require("fs")); | ||
var os_1 = __importDefault(require("os")); | ||
var path_1 = __importDefault(require("path")); | ||
var lockfile_1 = __importDefault(require("lockfile")); | ||
var mkdirp_1 = __importDefault(require("mkdirp")); | ||
var find_cache_dir_1 = __importDefault(require("find-cache-dir")); | ||
var child_process_1 = require("child_process"); | ||
var util_1 = require("util"); | ||
var RedisBinaryDownload_1 = __importDefault(require("./RedisBinaryDownload")); | ||
var resolve_config_1 = __importDefault(require("./resolve-config")); | ||
var debug_1 = __importDefault(require("debug")); | ||
var log = debug_1.default('RedisMS:RedisBinary'); | ||
const fs_1 = __importDefault(require("fs")); | ||
const os_1 = __importDefault(require("os")); | ||
const path_1 = __importDefault(require("path")); | ||
const lockfile_1 = __importDefault(require("lockfile")); | ||
const mkdirp_1 = require("mkdirp"); | ||
const find_cache_dir_1 = __importDefault(require("find-cache-dir")); | ||
const child_process_1 = require("child_process"); | ||
const util_1 = require("util"); | ||
const RedisBinaryDownload_1 = __importDefault(require("./RedisBinaryDownload")); | ||
const resolve_config_1 = __importDefault(require("./resolve-config")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const log = (0, debug_1.default)('RedisMS:RedisBinary'); | ||
exports.LATEST_VERSION = 'stable'; | ||
var RedisBinary = /** @class */ (function () { | ||
function RedisBinary() { | ||
} | ||
class RedisBinary { | ||
/** | ||
@@ -77,27 +37,16 @@ * Probe if the provided "systemBinary" is an existing path | ||
*/ | ||
RedisBinary.getSystemPath = function (systemBinary) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var binaryPath, err_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
binaryPath = ''; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, util_1.promisify(fs_1.default.access)(systemBinary)]; | ||
case 2: | ||
_a.sent(); | ||
log("RedisBinary: found system binary path at \"" + systemBinary + "\""); | ||
binaryPath = systemBinary; | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
err_1 = _a.sent(); | ||
log("RedisBinary: can't find system binary at \"" + systemBinary + "\".\n" + (err_1 === null || err_1 === void 0 ? void 0 : err_1.message)); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/, binaryPath]; | ||
} | ||
}); | ||
static getSystemPath(systemBinary) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let binaryPath = ''; | ||
try { | ||
yield (0, util_1.promisify)(fs_1.default.access)(systemBinary); | ||
log(`RedisBinary: found system binary path at "${systemBinary}"`); | ||
binaryPath = systemBinary; | ||
} | ||
catch (err) { | ||
log(`RedisBinary: can't find system binary at "${systemBinary}".\n${err === null || err === void 0 ? void 0 : err.message}`); | ||
} | ||
return binaryPath; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -107,5 +56,5 @@ * Check if specified version already exists in the cache | ||
*/ | ||
RedisBinary.getCachePath = function (version) { | ||
static getCachePath(version) { | ||
return this.cache[version]; | ||
}; | ||
} | ||
/** | ||
@@ -116,63 +65,43 @@ * Probe download path and download the binary | ||
*/ | ||
RedisBinary.getDownloadPath = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var downloadDir, version, lockfile, downloader, _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
downloadDir = options.downloadDir, version = options.version; | ||
// create downloadDir | ||
return [4 /*yield*/, mkdirp_1.default(downloadDir)]; | ||
case 1: | ||
// create downloadDir | ||
_c.sent(); | ||
lockfile = path_1.default.resolve(downloadDir, version + ".lock"); | ||
// wait to get a lock | ||
// downloading of binaries may be quite long procedure | ||
// that's why we are using so big wait/stale periods | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
lockfile_1.default.lock(lockfile, { | ||
wait: 1000 * 120, | ||
pollPeriod: 100, | ||
stale: 1000 * 110, | ||
retries: 3, | ||
retryWait: 100, | ||
}, function (err) { | ||
return err ? reject(err) : resolve(null); | ||
}); | ||
})]; | ||
case 2: | ||
// wait to get a lock | ||
// downloading of binaries may be quite long procedure | ||
// that's why we are using so big wait/stale periods | ||
_c.sent(); | ||
if (!!this.getCachePath(version)) return [3 /*break*/, 4]; | ||
downloader = new RedisBinaryDownload_1.default({ | ||
downloadDir: downloadDir, | ||
version: version, | ||
}); | ||
_a = this.cache; | ||
_b = version; | ||
return [4 /*yield*/, downloader.getRedisServerPath()]; | ||
case 3: | ||
_a[_b] = _c.sent(); | ||
_c.label = 4; | ||
case 4: | ||
// remove lock | ||
return [4 /*yield*/, new Promise(function (res) { | ||
lockfile_1.default.unlock(lockfile, function (err) { | ||
log(err | ||
? "RedisBinary: Error when removing download lock " + err | ||
: "RedisBinary: Download lock removed"); | ||
res(null); // we don't care if it was successful or not | ||
}); | ||
})]; | ||
case 5: | ||
// remove lock | ||
_c.sent(); | ||
return [2 /*return*/, this.getCachePath(version)]; | ||
} | ||
static getDownloadPath(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { downloadDir, version } = options; | ||
// create downloadDir | ||
yield (0, mkdirp_1.mkdirp)(downloadDir); | ||
/** Lockfile path */ | ||
const lockfile = path_1.default.resolve(downloadDir, `${version}.lock`); | ||
// wait to get a lock | ||
// downloading of binaries may be quite long procedure | ||
// that's why we are using so big wait/stale periods | ||
yield new Promise((resolve, reject) => { | ||
lockfile_1.default.lock(lockfile, { | ||
wait: 1000 * 120, | ||
pollPeriod: 100, | ||
stale: 1000 * 110, | ||
retries: 3, | ||
retryWait: 100, | ||
}, (err) => { | ||
return err ? reject(err) : resolve(null); | ||
}); | ||
}); | ||
// check cache if it got already added to the cache | ||
if (!this.getCachePath(version)) { | ||
const downloader = new RedisBinaryDownload_1.default({ | ||
downloadDir, | ||
version, | ||
}); | ||
this.cache[version] = yield downloader.getRedisServerPath(); | ||
} | ||
// remove lock | ||
yield new Promise((res) => { | ||
lockfile_1.default.unlock(lockfile, (err) => { | ||
log(err | ||
? `RedisBinary: Error when removing download lock ${err}` | ||
: `RedisBinary: Download lock removed`); | ||
res(null); // we don't care if it was successful or not | ||
}); | ||
}); | ||
return this.getCachePath(version); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -184,72 +113,61 @@ * Probe all supported paths for an binary and return the binary path | ||
*/ | ||
RedisBinary.getPath = function (opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var legacyDLDir, nodeModulesDLDir, defaultOptions, options, binaryPath, binaryVersion; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
legacyDLDir = path_1.default.resolve(os_1.default.homedir(), '.cache/redis-binaries'); | ||
nodeModulesDLDir = process.cwd(); | ||
while (nodeModulesDLDir.endsWith("node_modules" + path_1.default.sep + "redis-memory-server")) { | ||
nodeModulesDLDir = path_1.default.resolve(nodeModulesDLDir, '..', '..'); | ||
} | ||
defaultOptions = { | ||
downloadDir: resolve_config_1.default('DOWNLOAD_DIR') || | ||
(fs_1.default.existsSync(legacyDLDir) | ||
? legacyDLDir | ||
: path_1.default.resolve(find_cache_dir_1.default({ | ||
name: 'redis-memory-server', | ||
cwd: nodeModulesDLDir, | ||
}) || '', 'redis-binaries')), | ||
version: resolve_config_1.default('VERSION') || exports.LATEST_VERSION, | ||
systemBinary: resolve_config_1.default('SYSTEM_BINARY'), | ||
}; | ||
options = __assign(__assign({}, defaultOptions), opts); | ||
log("RedisBinary options:", JSON.stringify(options, null, 2)); | ||
binaryPath = ''; | ||
if (!options.systemBinary) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.getSystemPath(options.systemBinary)]; | ||
case 1: | ||
binaryPath = _a.sent(); | ||
if (binaryPath) { | ||
if (binaryPath.indexOf(' ') >= 0) { | ||
binaryPath = "\"" + binaryPath + "\""; | ||
} | ||
binaryVersion = child_process_1.execSync(binaryPath + " --version") | ||
.toString() | ||
.split('\n')[0] | ||
.split(' ')[2]; | ||
if (options.version !== exports.LATEST_VERSION && options.version !== binaryVersion) { | ||
// we will log the version number of the system binary and the version requested so the user can see the difference | ||
log('RedisMemoryServer: Possible version conflict\n' + | ||
(" SystemBinary version: " + binaryVersion + "\n") + | ||
(" Requested version: " + options.version + "\n\n") + | ||
' Using SystemBinary!'); | ||
} | ||
} | ||
_a.label = 2; | ||
case 2: | ||
if (!binaryPath) { | ||
binaryPath = this.getCachePath(options.version); | ||
} | ||
if (!!binaryPath) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.getDownloadPath(options)]; | ||
case 3: | ||
binaryPath = _a.sent(); | ||
_a.label = 4; | ||
case 4: | ||
if (!binaryPath) { | ||
throw new Error("RedisBinary.getPath: could not find an valid binary path! (Got: \"" + binaryPath + "\")"); | ||
} | ||
log("RedisBinary: redis-server binary path: \"" + binaryPath + "\""); | ||
return [2 /*return*/, binaryPath]; | ||
static getPath(opts = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const legacyDLDir = path_1.default.resolve(os_1.default.homedir(), '.cache/redis-binaries'); | ||
// if we're in postinstall script, npm will set the cwd too deep | ||
let nodeModulesDLDir = process.cwd(); | ||
while (nodeModulesDLDir.endsWith(`node_modules${path_1.default.sep}redis-memory-server`)) { | ||
nodeModulesDLDir = path_1.default.resolve(nodeModulesDLDir, '..', '..'); | ||
} | ||
// "||" is still used here, because it should default if the value is false-y (like an empty string) | ||
const defaultOptions = { | ||
downloadDir: (0, resolve_config_1.default)('DOWNLOAD_DIR') || | ||
(fs_1.default.existsSync(legacyDLDir) | ||
? legacyDLDir | ||
: path_1.default.resolve((0, find_cache_dir_1.default)({ | ||
name: 'redis-memory-server', | ||
cwd: nodeModulesDLDir, | ||
}) || '', 'redis-binaries')), | ||
version: (0, resolve_config_1.default)('VERSION') || exports.LATEST_VERSION, | ||
systemBinary: (0, resolve_config_1.default)('SYSTEM_BINARY'), | ||
}; | ||
/** Provided Options combined with the Default Options */ | ||
const options = Object.assign(Object.assign({}, defaultOptions), opts); | ||
log(`RedisBinary options:`, JSON.stringify(options, null, 2)); | ||
let binaryPath = ''; | ||
if (options.systemBinary) { | ||
binaryPath = yield this.getSystemPath(options.systemBinary); | ||
if (binaryPath) { | ||
if (binaryPath.indexOf(' ') >= 0) { | ||
binaryPath = `"${binaryPath}"`; | ||
} | ||
const binaryVersion = (0, child_process_1.execSync)(`${binaryPath} --version`) | ||
.toString() | ||
.split('\n')[0] | ||
.split(' ')[2]; | ||
if (options.version !== exports.LATEST_VERSION && options.version !== binaryVersion) { | ||
// we will log the version number of the system binary and the version requested so the user can see the difference | ||
log('RedisMemoryServer: Possible version conflict\n' + | ||
` SystemBinary version: ${binaryVersion}\n` + | ||
` Requested version: ${options.version}\n\n` + | ||
' Using SystemBinary!'); | ||
} | ||
} | ||
}); | ||
} | ||
if (!binaryPath) { | ||
binaryPath = this.getCachePath(options.version); | ||
} | ||
if (!binaryPath) { | ||
binaryPath = yield this.getDownloadPath(options); | ||
} | ||
if (!binaryPath) { | ||
throw new Error(`RedisBinary.getPath: could not find an valid binary path! (Got: "${binaryPath}")`); | ||
} | ||
log(`RedisBinary: redis-server binary path: "${binaryPath}"`); | ||
return binaryPath; | ||
}); | ||
}; | ||
RedisBinary.cache = {}; | ||
return RedisBinary; | ||
}()); | ||
} | ||
} | ||
RedisBinary.cache = {}; | ||
exports.default = RedisBinary; | ||
//# sourceMappingURL=RedisBinary.js.map |
@@ -15,3 +15,3 @@ import { DownloadProgressT } from '../types'; | ||
rejectUnauthorized?: boolean; | ||
agent: HttpsProxyAgent | undefined; | ||
agent: HttpsProxyAgent<string> | undefined; | ||
} | ||
@@ -18,0 +18,0 @@ /** |
@@ -11,29 +11,2 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -43,24 +16,23 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var url_1 = __importDefault(require("url")); | ||
var path_1 = __importDefault(require("path")); | ||
var fs_1 = __importDefault(require("fs")); | ||
var rimraf_1 = __importDefault(require("rimraf")); | ||
var http_1 = __importDefault(require("http")); | ||
var https_1 = __importDefault(require("https")); | ||
var tar_1 = __importDefault(require("tar")); | ||
var extract_zip_1 = __importDefault(require("extract-zip")); | ||
var RedisBinaryDownloadUrl_1 = __importDefault(require("./RedisBinaryDownloadUrl")); | ||
var RedisBinary_1 = require("./RedisBinary"); | ||
var https_proxy_agent_1 = require("https-proxy-agent"); | ||
var child_process_1 = require("child_process"); | ||
var util_1 = require("util"); | ||
const url_1 = __importDefault(require("url")); | ||
const path_1 = __importDefault(require("path")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const rimraf_1 = require("rimraf"); | ||
const http_1 = __importDefault(require("http")); | ||
const https_1 = __importDefault(require("https")); | ||
const tar_1 = __importDefault(require("tar")); | ||
const extract_zip_1 = __importDefault(require("extract-zip")); | ||
const RedisBinaryDownloadUrl_1 = __importDefault(require("./RedisBinaryDownloadUrl")); | ||
const RedisBinary_1 = require("./RedisBinary"); | ||
const https_proxy_agent_1 = require("https-proxy-agent"); | ||
const child_process_1 = require("child_process"); | ||
const util_1 = require("util"); | ||
require("./resolve-config"); | ||
var debug_1 = __importDefault(require("debug")); | ||
var log = debug_1.default('RedisMS:RedisBinaryDownload'); | ||
const debug_1 = __importDefault(require("debug")); | ||
const log = (0, debug_1.default)('RedisMS:RedisBinaryDownload'); | ||
/** | ||
* Download and extract the "redis-server" binary | ||
*/ | ||
var RedisBinaryDownload = /** @class */ (function () { | ||
function RedisBinaryDownload(_a) { | ||
var downloadDir = _a.downloadDir, version = _a.version; | ||
class RedisBinaryDownload { | ||
constructor({ downloadDir, version }) { | ||
this.version = version !== null && version !== void 0 ? version : RedisBinary_1.LATEST_VERSION; | ||
@@ -79,42 +51,24 @@ this.downloadDir = path_1.default.resolve(downloadDir || 'redis-download'); | ||
*/ | ||
RedisBinaryDownload.prototype.getRedisServerPath = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var binaryName, redisServerPath, redisArchive, extractDir; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
binaryName = process.platform === 'win32' ? 'redis-server.exe' : 'redis-server'; | ||
redisServerPath = path_1.default.resolve(this.downloadDir, this.version, binaryName); | ||
return [4 /*yield*/, this.locationExists(redisServerPath)]; | ||
case 1: | ||
if (_a.sent()) { | ||
return [2 /*return*/, redisServerPath]; | ||
} | ||
return [4 /*yield*/, this.startDownload()]; | ||
case 2: | ||
redisArchive = _a.sent(); | ||
return [4 /*yield*/, this.extract(redisArchive)]; | ||
case 3: | ||
extractDir = _a.sent(); | ||
if (!(process.platform === 'win32')) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.makeInstallWin32(extractDir)]; | ||
case 4: | ||
_a.sent(); | ||
return [3 /*break*/, 7]; | ||
case 5: return [4 /*yield*/, this.makeInstall(extractDir)]; | ||
case 6: | ||
_a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
fs_1.default.unlinkSync(redisArchive); | ||
return [4 /*yield*/, this.locationExists(redisServerPath)]; | ||
case 8: | ||
if (_a.sent()) { | ||
return [2 /*return*/, redisServerPath]; | ||
} | ||
throw new Error("Cannot find downloaded redis-server binary by path " + redisServerPath); | ||
} | ||
}); | ||
getRedisServerPath() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const binaryName = process.platform === 'win32' ? 'redis-server.exe' : 'redis-server'; | ||
const redisServerPath = path_1.default.resolve(this.downloadDir, this.version, binaryName); | ||
if (yield this.locationExists(redisServerPath)) { | ||
return redisServerPath; | ||
} | ||
const redisArchive = yield this.startDownload(); | ||
const extractDir = yield this.extract(redisArchive); | ||
if (process.platform === 'win32') { | ||
yield this.makeInstallWin32(extractDir); | ||
} | ||
else { | ||
yield this.makeInstall(extractDir); | ||
} | ||
fs_1.default.unlinkSync(redisArchive); | ||
if (yield this.locationExists(redisServerPath)) { | ||
return redisServerPath; | ||
} | ||
throw new Error(`Cannot find downloaded redis-server binary by path ${redisServerPath}`); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -124,22 +78,14 @@ * Download the Redis Archive | ||
*/ | ||
RedisBinaryDownload.prototype.startDownload = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var mbdUrl, downloadUrl; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
mbdUrl = new RedisBinaryDownloadUrl_1.default({ | ||
version: this.version, | ||
}); | ||
if (!fs_1.default.existsSync(this.downloadDir)) { | ||
fs_1.default.mkdirSync(this.downloadDir); | ||
} | ||
return [4 /*yield*/, mbdUrl.getDownloadUrl()]; | ||
case 1: | ||
downloadUrl = _a.sent(); | ||
return [2 /*return*/, this.download(downloadUrl)]; | ||
} | ||
startDownload() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const mbdUrl = new RedisBinaryDownloadUrl_1.default({ | ||
version: this.version, | ||
}); | ||
if (!fs_1.default.existsSync(this.downloadDir)) { | ||
fs_1.default.mkdirSync(this.downloadDir); | ||
} | ||
const downloadUrl = yield mbdUrl.getDownloadUrl(); | ||
return this.download(downloadUrl); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -149,52 +95,42 @@ * Download file from downloadUrl | ||
*/ | ||
RedisBinaryDownload.prototype.download = function (downloadUrl) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var proxy, strictSsl, urlObject, downloadOptions, filename, downloadLocation, tempDownloadLocation, downloadedFile; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
proxy = process.env['yarn_https-proxy'] || | ||
process.env.yarn_proxy || | ||
process.env['npm_config_https-proxy'] || | ||
process.env.npm_config_proxy || | ||
process.env.https_proxy || | ||
process.env.http_proxy || | ||
process.env.HTTPS_PROXY || | ||
process.env.HTTP_PROXY; | ||
strictSsl = process.env.npm_config_strict_ssl === 'true'; | ||
urlObject = url_1.default.parse(downloadUrl); | ||
if (!urlObject.hostname || !urlObject.path) { | ||
throw new Error("Provided incorrect download url: " + downloadUrl); | ||
} | ||
downloadOptions = { | ||
hostname: urlObject.hostname, | ||
port: urlObject.port || '443', | ||
path: urlObject.path, | ||
protocol: urlObject.protocol || 'https:', | ||
method: 'GET', | ||
rejectUnauthorized: strictSsl, | ||
agent: proxy ? new https_proxy_agent_1.HttpsProxyAgent(proxy) : undefined, | ||
}; | ||
filename = (urlObject.pathname || '').split('/').pop(); | ||
if (!filename) { | ||
throw new Error("RedisBinaryDownload: missing filename for url " + downloadUrl); | ||
} | ||
downloadLocation = path_1.default.resolve(this.downloadDir, filename); | ||
tempDownloadLocation = path_1.default.resolve(this.downloadDir, filename + ".downloading"); | ||
log("Downloading" + (proxy ? " via proxy " + proxy : '') + ": \"" + downloadUrl + "\""); | ||
return [4 /*yield*/, this.locationExists(downloadLocation)]; | ||
case 1: | ||
if (_a.sent()) { | ||
log('Already downloaded archive found, skipping download'); | ||
return [2 /*return*/, downloadLocation]; | ||
} | ||
this._downloadingUrl = downloadUrl; | ||
return [4 /*yield*/, this.httpDownload(downloadOptions, downloadLocation, tempDownloadLocation)]; | ||
case 2: | ||
downloadedFile = _a.sent(); | ||
return [2 /*return*/, downloadedFile]; | ||
} | ||
}); | ||
download(downloadUrl) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const proxy = process.env['yarn_https-proxy'] || | ||
process.env.yarn_proxy || | ||
process.env['npm_config_https-proxy'] || | ||
process.env.npm_config_proxy || | ||
process.env.https_proxy || | ||
process.env.http_proxy || | ||
process.env.HTTPS_PROXY || | ||
process.env.HTTP_PROXY; | ||
const strictSsl = process.env.npm_config_strict_ssl === 'true'; | ||
const urlObject = url_1.default.parse(downloadUrl); | ||
if (!urlObject.hostname || !urlObject.path) { | ||
throw new Error(`Provided incorrect download url: ${downloadUrl}`); | ||
} | ||
const downloadOptions = { | ||
hostname: urlObject.hostname, | ||
port: urlObject.port || '443', | ||
path: urlObject.path, | ||
protocol: urlObject.protocol || 'https:', | ||
method: 'GET', | ||
rejectUnauthorized: strictSsl, | ||
agent: proxy ? new https_proxy_agent_1.HttpsProxyAgent(proxy) : undefined, | ||
}; | ||
const filename = (urlObject.pathname || '').split('/').pop(); | ||
if (!filename) { | ||
throw new Error(`RedisBinaryDownload: missing filename for url ${downloadUrl}`); | ||
} | ||
const downloadLocation = path_1.default.resolve(this.downloadDir, filename); | ||
const tempDownloadLocation = path_1.default.resolve(this.downloadDir, `${filename}.downloading`); | ||
log(`Downloading${proxy ? ` via proxy ${proxy}` : ''}: "${downloadUrl}"`); | ||
if (yield this.locationExists(downloadLocation)) { | ||
log('Already downloaded archive found, skipping download'); | ||
return downloadLocation; | ||
} | ||
this._downloadingUrl = downloadUrl; | ||
const downloadedFile = yield this.httpDownload(downloadOptions, downloadLocation, tempDownloadLocation); | ||
return downloadedFile; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -205,31 +141,22 @@ * Extract given Archive | ||
*/ | ||
RedisBinaryDownload.prototype.extract = function (redisArchive) { | ||
extract(redisArchive) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var extractDir; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
extractDir = path_1.default.resolve(this.downloadDir, this.version, 'extracted'); | ||
log("extract(): " + extractDir); | ||
if (!fs_1.default.existsSync(extractDir)) { | ||
fs_1.default.mkdirSync(extractDir, { recursive: true }); | ||
} | ||
if (!redisArchive.endsWith('.zip')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.extractZip(redisArchive, extractDir)]; | ||
case 1: | ||
_b.sent(); | ||
return [3 /*break*/, 5]; | ||
case 2: | ||
if (!redisArchive.endsWith('.tar.gz')) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.extractTarGz(redisArchive, extractDir)]; | ||
case 3: | ||
_b.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: throw new Error("RedisBinaryDownload: unsupported archive " + redisArchive + " (downloaded from " + ((_a = this._downloadingUrl) !== null && _a !== void 0 ? _a : 'unkown') + "). Broken archive from Redis Provider?"); | ||
case 5: return [2 /*return*/, extractDir]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const extractDir = path_1.default.resolve(this.downloadDir, this.version, 'extracted'); | ||
log(`extract(): ${extractDir}`); | ||
if (!fs_1.default.existsSync(extractDir)) { | ||
fs_1.default.mkdirSync(extractDir, { recursive: true }); | ||
} | ||
if (redisArchive.endsWith('.zip')) { | ||
yield this.extractZip(redisArchive, extractDir); | ||
} | ||
else if (redisArchive.endsWith('.tar.gz')) { | ||
yield this.extractTarGz(redisArchive, extractDir); | ||
} | ||
else { | ||
throw new Error(`RedisBinaryDownload: unsupported archive ${redisArchive} (downloaded from ${(_a = this._downloadingUrl) !== null && _a !== void 0 ? _a : 'unkown'}). Broken archive from Redis Provider?`); | ||
} | ||
return extractDir; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -240,18 +167,11 @@ * Extract a .tar.gz archive | ||
*/ | ||
RedisBinaryDownload.prototype.extractTarGz = function (redisArchive, extractDir) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, tar_1.default.extract({ | ||
file: redisArchive, | ||
cwd: extractDir, | ||
strip: 1, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
extractTarGz(redisArchive, extractDir) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield tar_1.default.extract({ | ||
file: redisArchive, | ||
cwd: extractDir, | ||
strip: 1, | ||
}); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -262,14 +182,7 @@ * Extract a .zip archive | ||
*/ | ||
RedisBinaryDownload.prototype.extractZip = function (redisArchive, extractDir) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, extract_zip_1.default(redisArchive, { dir: extractDir })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
extractZip(redisArchive, extractDir) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield (0, extract_zip_1.default)(redisArchive, { dir: extractDir }); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -281,65 +194,53 @@ * Downlaod given httpOptions to tempDownloadLocation, then move it to downloadLocation | ||
*/ | ||
RedisBinaryDownload.prototype.httpDownload = function (httpOptions, downloadLocation, tempDownloadLocation) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var fileStream = fs_1.default.createWriteStream(tempDownloadLocation); | ||
log("trying to download " + httpOptions.protocol + "//" + httpOptions.hostname + httpOptions.path); | ||
(httpOptions.protocol === 'https:' ? https_1.default : http_1.default) | ||
.get(httpOptions, function (response) { | ||
// "as any" because otherwise the "agent" wouldnt match | ||
if (response.statusCode != 200) { | ||
if (response.statusCode === 404) { | ||
reject(new Error('Status Code is 404\n' + | ||
"This means that the requested version doesn't exist\n" + | ||
(" Used Url: \"" + httpOptions.protocol + "//" + httpOptions.hostname + httpOptions.path + "\"\n") + | ||
"Try to use different version 'new RedisMemoryServer({ binary: { version: 'X.Y.Z' } })'\n")); | ||
return; | ||
} | ||
reject(new Error('Status Code isnt 200!')); | ||
return; | ||
} | ||
if (typeof response.headers['content-length'] != 'string') { | ||
reject(new Error('Response header "content-length" is empty!')); | ||
return; | ||
} | ||
_this.dlProgress.current = 0; | ||
_this.dlProgress.length = parseInt(response.headers['content-length'], 10); | ||
_this.dlProgress.totalMb = Math.round((_this.dlProgress.length / 1048576) * 10) / 10; | ||
response.pipe(fileStream); | ||
fileStream.on('finish', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var downloadUrl; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (this.dlProgress.current < this.dlProgress.length) { | ||
downloadUrl = this._downloadingUrl || | ||
httpOptions.protocol + "//" + httpOptions.hostname + "/" + httpOptions.path; | ||
reject(new Error("Too small (" + this.dlProgress.current + " bytes) redis-server binary downloaded from " + downloadUrl)); | ||
return [2 /*return*/]; | ||
} | ||
fileStream.close(); | ||
return [4 /*yield*/, util_1.promisify(fs_1.default.rename)(tempDownloadLocation, downloadLocation)]; | ||
case 1: | ||
_a.sent(); | ||
log("moved " + tempDownloadLocation + " to " + downloadLocation); | ||
resolve(downloadLocation); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
response.on('data', function (chunk) { | ||
_this.printDownloadProgress(chunk); | ||
}); | ||
}) | ||
.on('error', function (e) { | ||
// log it without having debug enabled | ||
console.error("Couldnt download " + httpOptions.path + "!", e.message); | ||
reject(e); | ||
}); | ||
})]; | ||
httpDownload(httpOptions, downloadLocation, tempDownloadLocation) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
const fileStream = fs_1.default.createWriteStream(tempDownloadLocation); | ||
log(`trying to download ${httpOptions.protocol}//${httpOptions.hostname}${httpOptions.path}`); | ||
(httpOptions.protocol === 'https:' ? https_1.default : http_1.default) | ||
.get(httpOptions, (response) => { | ||
// "as any" because otherwise the "agent" wouldnt match | ||
if (response.statusCode != 200) { | ||
if (response.statusCode === 404) { | ||
reject(new Error('Status Code is 404\n' + | ||
"This means that the requested version doesn't exist\n" + | ||
` Used Url: "${httpOptions.protocol}//${httpOptions.hostname}${httpOptions.path}"\n` + | ||
"Try to use different version 'new RedisMemoryServer({ binary: { version: 'X.Y.Z' } })'\n")); | ||
return; | ||
} | ||
reject(new Error('Status Code isnt 200!')); | ||
return; | ||
} | ||
if (typeof response.headers['content-length'] != 'string') { | ||
reject(new Error('Response header "content-length" is empty!')); | ||
return; | ||
} | ||
this.dlProgress.current = 0; | ||
this.dlProgress.length = parseInt(response.headers['content-length'], 10); | ||
this.dlProgress.totalMb = Math.round((this.dlProgress.length / 1048576) * 10) / 10; | ||
response.pipe(fileStream); | ||
fileStream.on('finish', () => __awaiter(this, void 0, void 0, function* () { | ||
if (this.dlProgress.current < this.dlProgress.length) { | ||
const downloadUrl = this._downloadingUrl || | ||
`${httpOptions.protocol}//${httpOptions.hostname}/${httpOptions.path}`; | ||
reject(new Error(`Too small (${this.dlProgress.current} bytes) redis-server binary downloaded from ${downloadUrl}`)); | ||
return; | ||
} | ||
fileStream.close(); | ||
yield (0, util_1.promisify)(fs_1.default.rename)(tempDownloadLocation, downloadLocation); | ||
log(`moved ${tempDownloadLocation} to ${downloadLocation}`); | ||
resolve(downloadLocation); | ||
})); | ||
response.on('data', (chunk) => { | ||
this.printDownloadProgress(chunk); | ||
}); | ||
}) | ||
.on('error', (e) => { | ||
// log it without having debug enabled | ||
console.error(`Couldnt download ${httpOptions.path}!`, e.message); | ||
reject(e); | ||
}); | ||
}); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -349,5 +250,5 @@ * Print the Download Progress to STDOUT | ||
*/ | ||
RedisBinaryDownload.prototype.printDownloadProgress = function (chunk) { | ||
printDownloadProgress(chunk) { | ||
this.dlProgress.current += chunk.length; | ||
var now = Date.now(); | ||
const now = Date.now(); | ||
if (now - this.dlProgress.lastPrintedAt < 2000) { | ||
@@ -357,6 +258,6 @@ return; | ||
this.dlProgress.lastPrintedAt = now; | ||
var percentComplete = Math.round(((100.0 * this.dlProgress.current) / this.dlProgress.length) * 10) / 10; | ||
var mbComplete = Math.round((this.dlProgress.current / 1048576) * 10) / 10; | ||
var crReturn = '\r'; | ||
var message = "Downloading Redis " + this.version + ": " + percentComplete + " % (" + mbComplete + "mb / " + this.dlProgress.totalMb + "mb)" + crReturn; | ||
const percentComplete = Math.round(((100.0 * this.dlProgress.current) / this.dlProgress.length) * 10) / 10; | ||
const mbComplete = Math.round((this.dlProgress.current / 1048576) * 10) / 10; | ||
const crReturn = '\r'; | ||
const message = `Downloading Redis ${this.version}: ${percentComplete} % (${mbComplete}mb / ${this.dlProgress.totalMb}mb)${crReturn}`; | ||
if (process.stdout.isTTY) { | ||
@@ -369,3 +270,3 @@ // if TTY overwrite last line over and over until finished | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -376,26 +277,13 @@ * Make and install given extracted directory | ||
*/ | ||
RedisBinaryDownload.prototype.makeInstall = function (extractDir) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var binaryName; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
binaryName = 'redis-server'; | ||
log("makeInstall(): " + extractDir); | ||
return [4 /*yield*/, util_1.promisify(child_process_1.exec)('make', { | ||
cwd: extractDir, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, util_1.promisify(fs_1.default.copyFile)(path_1.default.resolve(extractDir, 'src', binaryName), path_1.default.resolve(extractDir, '..', binaryName))]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, util_1.promisify(rimraf_1.default)(extractDir)]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
makeInstall(extractDir) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const binaryName = 'redis-server'; | ||
log(`makeInstall(): ${extractDir}`); | ||
yield (0, util_1.promisify)(child_process_1.exec)('make', { | ||
cwd: extractDir, | ||
}); | ||
yield (0, util_1.promisify)(fs_1.default.copyFile)(path_1.default.resolve(extractDir, 'src', binaryName), path_1.default.resolve(extractDir, '..', binaryName)); | ||
yield (0, rimraf_1.rimraf)(extractDir); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -406,21 +294,10 @@ * copy binary to parent folder and delete given extracted directory | ||
*/ | ||
RedisBinaryDownload.prototype.makeInstallWin32 = function (extractDir) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var binaryName; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
binaryName = 'redis-server.exe'; | ||
log("makeInstallWin32(): " + extractDir); | ||
return [4 /*yield*/, util_1.promisify(fs_1.default.copyFile)(path_1.default.resolve(extractDir, '.', binaryName), path_1.default.resolve(extractDir, '..', binaryName))]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, util_1.promisify(rimraf_1.default)(extractDir)]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
makeInstallWin32(extractDir) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const binaryName = 'redis-server.exe'; | ||
log(`makeInstallWin32(): ${extractDir}`); | ||
yield (0, util_1.promisify)(fs_1.default.copyFile)(path_1.default.resolve(extractDir, '.', binaryName), path_1.default.resolve(extractDir, '..', binaryName)); | ||
yield (0, rimraf_1.rimraf)(extractDir); | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -431,27 +308,18 @@ * Test if the location given is already used | ||
*/ | ||
RedisBinaryDownload.prototype.locationExists = function (location) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, util_1.promisify(fs_1.default.lstat)(location)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, true]; | ||
case 2: | ||
e_1 = _a.sent(); | ||
if (e_1.code !== 'ENOENT') { | ||
throw e_1; | ||
} | ||
return [2 /*return*/, false]; | ||
case 3: return [2 /*return*/]; | ||
locationExists(location) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield (0, util_1.promisify)(fs_1.default.lstat)(location); | ||
return true; | ||
} | ||
catch (e) { | ||
if (e.code !== 'ENOENT') { | ||
throw e; | ||
} | ||
}); | ||
return false; | ||
} | ||
}); | ||
}; | ||
return RedisBinaryDownload; | ||
}()); | ||
} | ||
} | ||
exports.default = RedisBinaryDownload; | ||
//# sourceMappingURL=RedisBinaryDownload.js.map |
@@ -11,29 +11,2 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -43,12 +16,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var resolve_config_1 = __importDefault(require("./resolve-config")); | ||
var debug_1 = __importDefault(require("debug")); | ||
var RedisBinary_1 = require("./RedisBinary"); | ||
var log = debug_1.default('RedisMS:RedisBinaryDownloadUrl'); | ||
const resolve_config_1 = __importDefault(require("./resolve-config")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const RedisBinary_1 = require("./RedisBinary"); | ||
const log = (0, debug_1.default)('RedisMS:RedisBinaryDownloadUrl'); | ||
/** | ||
* Download URL generator | ||
*/ | ||
var RedisBinaryDownloadUrl = /** @class */ (function () { | ||
function RedisBinaryDownloadUrl(_a) { | ||
var version = _a.version; | ||
class RedisBinaryDownloadUrl { | ||
constructor({ version }) { | ||
this.version = version; | ||
@@ -60,30 +32,22 @@ } | ||
*/ | ||
RedisBinaryDownloadUrl.prototype.getDownloadUrl = function () { | ||
getDownloadUrl() { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var downloadUrl, archive, mirror; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
downloadUrl = resolve_config_1.default('DOWNLOAD_URL'); | ||
if (downloadUrl) { | ||
log("Using \"" + downloadUrl + "\" as the Download-URL"); | ||
return [2 /*return*/, downloadUrl]; | ||
} | ||
if (process.platform === 'win32') { | ||
return [2 /*return*/, 'https://raw.githubusercontent.com/ServiceStack/redis-windows/master/downloads/redis-latest.zip']; | ||
} | ||
return [4 /*yield*/, this.getArchiveName()]; | ||
case 1: | ||
archive = _b.sent(); | ||
log("Using \"" + archive + "\" as the Archive String"); | ||
mirror = (_a = resolve_config_1.default('DOWNLOAD_MIRROR')) !== null && _a !== void 0 ? _a : 'https://download.redis.io'; | ||
log("Using \"" + mirror + "\" as the mirror"); | ||
return [2 /*return*/, this.version === RedisBinary_1.LATEST_VERSION | ||
? mirror + "/" + archive | ||
: mirror + "/releases/" + archive]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const downloadUrl = (0, resolve_config_1.default)('DOWNLOAD_URL'); | ||
if (downloadUrl) { | ||
log(`Using "${downloadUrl}" as the Download-URL`); | ||
return downloadUrl; | ||
} | ||
if (process.platform === 'win32') { | ||
return 'https://raw.githubusercontent.com/ServiceStack/redis-windows/master/downloads/redis-latest.zip'; | ||
} | ||
const archive = yield this.getArchiveName(); | ||
log(`Using "${archive}" as the Archive String`); | ||
const mirror = (_a = (0, resolve_config_1.default)('DOWNLOAD_MIRROR')) !== null && _a !== void 0 ? _a : 'https://download.redis.io'; | ||
log(`Using "${mirror}" as the mirror`); | ||
return this.version === RedisBinary_1.LATEST_VERSION | ||
? `${mirror}/${archive}` | ||
: `${mirror}/releases/${archive}`; | ||
}); | ||
}; | ||
} | ||
/** | ||
@@ -93,15 +57,12 @@ * Get the archive | ||
*/ | ||
RedisBinaryDownloadUrl.prototype.getArchiveName = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
if (process.platform === 'win32') { | ||
return [2 /*return*/, 'redis-latest.zip']; | ||
} | ||
return [2 /*return*/, "redis-" + this.version + ".tar.gz"]; | ||
}); | ||
getArchiveName() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (process.platform === 'win32') { | ||
return 'redis-latest.zip'; | ||
} | ||
return `redis-${this.version}.tar.gz`; | ||
}); | ||
}; | ||
return RedisBinaryDownloadUrl; | ||
}()); | ||
} | ||
} | ||
exports.default = RedisBinaryDownloadUrl; | ||
//# sourceMappingURL=RedisBinaryDownloadUrl.js.map |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { ChildProcess } from 'child_process'; | ||
@@ -3,0 +4,0 @@ import { RedisBinaryOpts } from './RedisBinary'; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -22,29 +11,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -54,21 +16,21 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var cross_spawn_1 = __importDefault(require("cross-spawn")); | ||
var path_1 = __importDefault(require("path")); | ||
var RedisBinary_1 = __importDefault(require("./RedisBinary")); | ||
var debug_1 = __importDefault(require("debug")); | ||
var db_util_1 = require("./db_util"); | ||
var semver_1 = require("semver"); | ||
if (semver_1.lt(process.version, '10.15.0')) { | ||
const cross_spawn_1 = __importDefault(require("cross-spawn")); | ||
const path_1 = __importDefault(require("path")); | ||
const RedisBinary_1 = __importDefault(require("./RedisBinary")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const db_util_1 = require("./db_util"); | ||
const semver_1 = require("semver"); | ||
if ((0, semver_1.lt)(process.version, '10.15.0')) { | ||
console.warn('Using NodeJS below 10.15.0'); | ||
} | ||
var log = debug_1.default('RedisMS:RedisInstance'); | ||
const log = (0, debug_1.default)('RedisMS:RedisInstance'); | ||
/** | ||
* Redis Instance Handler Class | ||
*/ | ||
var RedisInstance = /** @class */ (function () { | ||
function RedisInstance(opts) { | ||
class RedisInstance { | ||
constructor(opts) { | ||
var _a; | ||
this.isInstanceReady = false; | ||
this.instanceReady = function () { }; | ||
this.instanceFailed = function () { }; | ||
this.instanceReady = () => { }; | ||
this.instanceFailed = () => { }; | ||
this.opts = opts; | ||
@@ -85,9 +47,9 @@ this.childProcess = null; | ||
// add instance's port to debug output | ||
var port_1 = (_a = this.opts.instance) === null || _a === void 0 ? void 0 : _a.port; | ||
this.debug = function (msg) { | ||
log("Redis[" + port_1 + "]: " + msg); | ||
const port = (_a = this.opts.instance) === null || _a === void 0 ? void 0 : _a.port; | ||
this.debug = (msg) => { | ||
log(`Redis[${port}]: ${msg}`); | ||
}; | ||
} | ||
else { | ||
this.debug = function () { }; | ||
this.debug = () => { }; | ||
} | ||
@@ -99,17 +61,14 @@ } | ||
*/ | ||
RedisInstance.run = function (opts) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var instance; | ||
return __generator(this, function (_a) { | ||
instance = new this(opts); | ||
return [2 /*return*/, instance.run()]; | ||
}); | ||
static run(opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const instance = new this(opts); | ||
return instance.run(); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Create an array of arguments for the redis-server instance | ||
*/ | ||
RedisInstance.prototype.prepareCommandArgs = function () { | ||
var _a = this.opts.instance, ip = _a.ip, port = _a.port, args = _a.args; | ||
var result = []; | ||
prepareCommandArgs() { | ||
const { ip, port, args } = this.opts.instance; | ||
const result = []; | ||
result.push('--save', ''); // disable RDB snapshotting | ||
@@ -122,42 +81,34 @@ result.push('--appendonly', 'no'); // disable AOF | ||
return result.concat(args !== null && args !== void 0 ? args : []); | ||
}; | ||
} | ||
/** | ||
* Create the redis-server process | ||
*/ | ||
RedisInstance.prototype.run = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var launch, redisBin; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
launch = new Promise(function (resolve, reject) { | ||
_this.instanceReady = function () { | ||
_this.isInstanceReady = true; | ||
_this.debug('RedisInstance: Instance is ready!'); | ||
resolve(__assign({}, _this.childProcess)); | ||
}; | ||
_this.instanceFailed = function (err) { | ||
_this.debug("RedisInstance: Instance has failed: " + err.toString()); | ||
if (_this.killerProcess) { | ||
_this.killerProcess.kill(); | ||
} | ||
reject(err); | ||
}; | ||
}); | ||
return [4 /*yield*/, RedisBinary_1.default.getPath(this.opts.binary)]; | ||
case 1: | ||
redisBin = _a.sent(); | ||
this.childProcess = this._launchRedisServer(redisBin); | ||
this.killerProcess = this._launchKiller(process.pid, this.childProcess.pid); | ||
return [4 /*yield*/, launch]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, this]; | ||
} | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const launch = new Promise((resolve, reject) => { | ||
this.instanceReady = () => { | ||
this.isInstanceReady = true; | ||
this.debug('RedisInstance: Instance is ready!'); | ||
resolve(Object.assign({}, this.childProcess)); | ||
}; | ||
this.instanceFailed = (err) => { | ||
this.debug(`RedisInstance: Instance has failed: ${err.toString()}`); | ||
if (this.killerProcess) { | ||
this.killerProcess.kill(); | ||
} | ||
reject(err); | ||
}; | ||
}); | ||
const redisBin = yield RedisBinary_1.default.getPath(this.opts.binary); | ||
this.childProcess = this._launchRedisServer(redisBin); | ||
if (this.childProcess.pid) { | ||
this.killerProcess = this._launchKiller(process.pid, this.childProcess.pid); | ||
} | ||
yield launch; | ||
return this; | ||
}); | ||
}; | ||
RedisInstance.prototype.kill = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
} | ||
kill() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.debug('Called RedisInstance.kill():'); | ||
/** | ||
@@ -170,75 +121,54 @@ * Function to De-Duplicate Code | ||
function kill_internal(_process, name, debugfn) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var timeoutTime; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!db_util_1.isAlive(_process.pid)) { | ||
debugfn('kill_internal given process PID is not alive anymore'); | ||
return [2 /*return*/]; | ||
} | ||
timeoutTime = 1000 * 10; | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
var timeout = setTimeout(function () { | ||
debugfn('kill_internal timeout triggered, trying SIGKILL'); | ||
if (!debug_1.default.enabled('RedisMS:RedisInstance')) { | ||
console.warn('An Process didnt exit with signal "SIGINT" within 10 seconds, using "SIGKILL"!\n' + | ||
'Enable debug logs for more information'); | ||
} | ||
_process.kill('SIGKILL'); | ||
timeout = setTimeout(function () { | ||
debugfn('kill_internal timeout triggered again, rejecting'); | ||
reject(new Error('Process didnt exit, enable debug for more information.')); | ||
}, timeoutTime); | ||
}, timeoutTime); | ||
_process.once("exit", function (code, signal) { | ||
debugfn("- " + name + ": got exit signal, Code: " + code + ", Signal: " + signal); | ||
clearTimeout(timeout); | ||
resolve(null); | ||
}); | ||
debugfn("- " + name + ": send \"SIGINT\""); | ||
_process.kill('SIGINT'); | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!(0, db_util_1.isAlive)(_process.pid)) { | ||
debugfn('kill_internal given process PID is not alive anymore'); | ||
return; | ||
} | ||
const timeoutTime = 1000 * 10; | ||
yield new Promise((resolve, reject) => { | ||
let timeout = setTimeout(() => { | ||
debugfn('kill_internal timeout triggered, trying SIGKILL'); | ||
if (!debug_1.default.enabled('RedisMS:RedisInstance')) { | ||
console.warn('An Process didnt exit with signal "SIGINT" within 10 seconds, using "SIGKILL"!\n' + | ||
'Enable debug logs for more information'); | ||
} | ||
_process.kill('SIGKILL'); | ||
timeout = setTimeout(() => { | ||
debugfn('kill_internal timeout triggered again, rejecting'); | ||
reject(new Error('Process didnt exit, enable debug for more information.')); | ||
}, timeoutTime); | ||
}, timeoutTime); | ||
_process.once(`exit`, (code, signal) => { | ||
debugfn(`- ${name}: got exit signal, Code: ${code}, Signal: ${signal}`); | ||
clearTimeout(timeout); | ||
resolve(null); | ||
}); | ||
debugfn(`- ${name}: send "SIGINT"`); | ||
_process.kill('SIGINT'); | ||
}); | ||
}); | ||
} | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.debug('Called RedisInstance.kill():'); | ||
if (!!db_util_1.isNullOrUndefined(this.childProcess)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, kill_internal(this.childProcess, 'childProcess', this.debug)]; | ||
case 1: | ||
_a.sent(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
this.debug('- childProcess: nothing to shutdown, skipping.'); | ||
_a.label = 3; | ||
case 3: | ||
if (!!db_util_1.isNullOrUndefined(this.killerProcess)) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, kill_internal(this.killerProcess, 'killerProcess', this.debug)]; | ||
case 4: | ||
_a.sent(); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
this.debug('- killerProcess: nothing to shutdown, skipping.'); | ||
_a.label = 6; | ||
case 6: | ||
this.debug('Instance Finished Shutdown'); | ||
return [2 /*return*/, this]; | ||
} | ||
}); | ||
if (!(0, db_util_1.isNullOrUndefined)(this.childProcess)) { | ||
yield kill_internal(this.childProcess, 'childProcess', this.debug); | ||
} | ||
else { | ||
this.debug('- childProcess: nothing to shutdown, skipping.'); | ||
} | ||
if (!(0, db_util_1.isNullOrUndefined)(this.killerProcess)) { | ||
yield kill_internal(this.killerProcess, 'killerProcess', this.debug); | ||
} | ||
else { | ||
this.debug('- killerProcess: nothing to shutdown, skipping.'); | ||
} | ||
this.debug('Instance Finished Shutdown'); | ||
return this; | ||
}); | ||
}; | ||
} | ||
/** | ||
* Get the PID of the redis-server instance | ||
*/ | ||
RedisInstance.prototype.getPid = function () { | ||
getPid() { | ||
var _a; | ||
return (_a = this.childProcess) === null || _a === void 0 ? void 0 : _a.pid; | ||
}; | ||
} | ||
/** | ||
@@ -248,9 +178,9 @@ * Actually launch redis-server | ||
*/ | ||
RedisInstance.prototype._launchRedisServer = function (redisBin) { | ||
_launchRedisServer(redisBin) { | ||
var _a, _b, _c; | ||
var spawnOpts = (_a = this.opts.spawn) !== null && _a !== void 0 ? _a : {}; | ||
const spawnOpts = (_a = this.opts.spawn) !== null && _a !== void 0 ? _a : {}; | ||
if (!spawnOpts.stdio) { | ||
spawnOpts.stdio = 'pipe'; | ||
} | ||
var childProcess = cross_spawn_1.default(redisBin, this.prepareCommandArgs(), spawnOpts); | ||
const childProcess = (0, cross_spawn_1.default)(redisBin, this.prepareCommandArgs(), spawnOpts); | ||
(_b = childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', this.stderrHandler.bind(this)); | ||
@@ -260,7 +190,7 @@ (_c = childProcess.stdout) === null || _c === void 0 ? void 0 : _c.on('data', this.stdoutHandler.bind(this)); | ||
childProcess.on('error', this.errorHandler.bind(this)); | ||
if (db_util_1.isNullOrUndefined(childProcess.pid)) { | ||
if ((0, db_util_1.isNullOrUndefined)(childProcess.pid)) { | ||
throw new Error('Spawned Redis Instance PID is undefined'); | ||
} | ||
return childProcess; | ||
}; | ||
} | ||
/** | ||
@@ -271,8 +201,7 @@ * Spawn an child to kill the parent and the redis-server instance if both are Dead | ||
*/ | ||
RedisInstance.prototype._launchKiller = function (parentPid, childPid) { | ||
var _this = this; | ||
_launchKiller(parentPid, childPid) { | ||
var _a, _b, _c; | ||
this.debug("Called RedisInstance._launchKiller(parent: " + parentPid + ", child: " + childPid + "):"); | ||
this.debug(`Called RedisInstance._launchKiller(parent: ${parentPid}, child: ${childPid}):`); | ||
// spawn process which kills itself and redis process if current process is dead | ||
var killer = cross_spawn_1.default((_a = process.env['NODE']) !== null && _a !== void 0 ? _a : process.argv[0], // try Environment variable "NODE" before using argv[0] | ||
const killer = (0, cross_spawn_1.default)((_a = process.env['NODE']) !== null && _a !== void 0 ? _a : process.argv[0], // try Environment variable "NODE" before using argv[0] | ||
[ | ||
@@ -283,22 +212,18 @@ path_1.default.resolve(__dirname, '../../scripts/redis_killer.js'), | ||
], { stdio: 'pipe' }); | ||
(_b = killer.stdout) === null || _b === void 0 ? void 0 : _b.on('data', function (data) { | ||
_this.debug("[RedisKiller]: " + data); | ||
(_b = killer.stdout) === null || _b === void 0 ? void 0 : _b.on('data', (data) => { | ||
this.debug(`[RedisKiller]: ${data}`); | ||
}); | ||
(_c = killer.stderr) === null || _c === void 0 ? void 0 : _c.on('data', function (data) { | ||
_this.debug("[RedisKiller]: " + data); | ||
(_c = killer.stderr) === null || _c === void 0 ? void 0 : _c.on('data', (data) => { | ||
this.debug(`[RedisKiller]: ${data}`); | ||
}); | ||
['exit', 'message', 'disconnect', 'error'].forEach(function (type) { | ||
killer.on(type, function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.debug("[RedisKiller]: " + type + " - " + JSON.stringify(args)); | ||
['exit', 'message', 'disconnect', 'error'].forEach((type) => { | ||
killer.on(type, (...args) => { | ||
this.debug(`[RedisKiller]: ${type} - ${JSON.stringify(args)}`); | ||
}); | ||
}); | ||
return killer; | ||
}; | ||
RedisInstance.prototype.errorHandler = function (err) { | ||
} | ||
errorHandler(err) { | ||
this.instanceFailed(err); | ||
}; | ||
} | ||
/** | ||
@@ -308,9 +233,9 @@ * Write the CLOSE event to the debug function | ||
*/ | ||
RedisInstance.prototype.closeHandler = function (code) { | ||
closeHandler(code) { | ||
if (code != 0) { | ||
this.debug('redis-server instance closed with an non-0 code!'); | ||
} | ||
this.debug("CLOSE: " + code); | ||
this.instanceFailed("redis-server instance closed with code \"" + code + "\""); | ||
}; | ||
this.debug(`CLOSE: ${code}`); | ||
this.instanceFailed(`redis-server instance closed with code "${code}"`); | ||
} | ||
/** | ||
@@ -320,5 +245,5 @@ * Write STDERR to debug function | ||
*/ | ||
RedisInstance.prototype.stderrHandler = function (message) { | ||
this.debug("STDERR: " + message.toString()); | ||
}; | ||
stderrHandler(message) { | ||
this.debug(`STDERR: ${message.toString()}`); | ||
} | ||
/** | ||
@@ -328,5 +253,5 @@ * Write STDOUT to debug function AND instanceReady/instanceFailed if inputs match | ||
*/ | ||
RedisInstance.prototype.stdoutHandler = function (message) { | ||
var line = message.toString(); | ||
this.debug("STDOUT: " + line); | ||
stdoutHandler(message) { | ||
const line = message.toString(); | ||
this.debug(`STDOUT: ${line}`); | ||
if (/Ready to accept connections/i.test(line)) { | ||
@@ -336,3 +261,3 @@ this.instanceReady(); | ||
else if (/Address already in use/i.test(line)) { | ||
this.instanceFailed("Port " + this.opts.instance.port + " already in use"); | ||
this.instanceFailed(`Port ${this.opts.instance.port} already in use`); | ||
} | ||
@@ -354,7 +279,6 @@ else if (/redis-server instance already running/i.test(line)) { | ||
} | ||
}; | ||
RedisInstance.childProcessList = []; | ||
return RedisInstance; | ||
}()); | ||
} | ||
} | ||
RedisInstance.childProcessList = []; | ||
exports.default = RedisInstance; | ||
//# sourceMappingURL=RedisInstance.js.map |
@@ -7,10 +7,10 @@ "use strict"; | ||
exports.envToBool = exports.findPackageJson = exports.setDefaultValue = void 0; | ||
var camelcase_1 = __importDefault(require("camelcase")); | ||
var find_package_json_1 = __importDefault(require("find-package-json")); | ||
var debug_1 = __importDefault(require("debug")); | ||
var path_1 = require("path"); | ||
var lodash_defaultsdeep_1 = __importDefault(require("lodash.defaultsdeep")); | ||
var log = debug_1.default('RedisMS:ResolveConfig'); | ||
var ENV_CONFIG_PREFIX = 'REDISMS_'; | ||
var defaultValues = new Map(); | ||
const camelcase_1 = __importDefault(require("camelcase")); | ||
const find_package_json_1 = __importDefault(require("find-package-json")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const path_1 = require("path"); | ||
const lodash_defaultsdeep_1 = __importDefault(require("lodash.defaultsdeep")); | ||
const log = (0, debug_1.default)('RedisMS:ResolveConfig'); | ||
const ENV_CONFIG_PREFIX = 'REDISMS_'; | ||
const defaultValues = new Map(); | ||
/** | ||
@@ -26,3 +26,3 @@ * Set an Default value for an specific key | ||
exports.setDefaultValue = setDefaultValue; | ||
var packageJsonConfig = {}; | ||
let packageJsonConfig = {}; | ||
/** | ||
@@ -33,5 +33,5 @@ * Traverse up the hierarchy and combine all package.json files | ||
function findPackageJson(directory) { | ||
var _packageJsonConfig = {}; | ||
var finderIterator = find_package_json_1.default(directory || process.cwd()); | ||
var foundPackageJson; | ||
const _packageJsonConfig = {}; | ||
const finderIterator = (0, find_package_json_1.default)(directory || process.cwd()); | ||
let foundPackageJson; | ||
while ((foundPackageJson = finderIterator.next())) { | ||
@@ -41,13 +41,12 @@ if (foundPackageJson.done) { | ||
} | ||
var value = foundPackageJson.value, filename = foundPackageJson.filename; | ||
log("Found package.json at \"" + filename + "\""); | ||
var ourConfig = (value === null || value === void 0 ? void 0 : value.redisMemoryServer) || {}; | ||
const { value, filename } = foundPackageJson; | ||
log(`Found package.json at "${filename}"`); | ||
const ourConfig = (value === null || value === void 0 ? void 0 : value.redisMemoryServer) || {}; | ||
// resolve relative paths | ||
for (var _i = 0, _a = ['downloadDir', 'systemBinary']; _i < _a.length; _i++) { | ||
var relativePathProp = _a[_i]; | ||
for (const relativePathProp of ['downloadDir', 'systemBinary']) { | ||
if (ourConfig[relativePathProp]) { | ||
ourConfig[relativePathProp] = path_1.resolve(path_1.dirname(filename), ourConfig[relativePathProp]); | ||
ourConfig[relativePathProp] = (0, path_1.resolve)((0, path_1.dirname)(filename), ourConfig[relativePathProp]); | ||
} | ||
} | ||
lodash_defaultsdeep_1.default(_packageJsonConfig, ourConfig); | ||
(0, lodash_defaultsdeep_1.default)(_packageJsonConfig, ourConfig); | ||
} | ||
@@ -64,3 +63,3 @@ packageJsonConfig = _packageJsonConfig; | ||
var _a, _b; | ||
return ((_b = (_a = process.env["" + ENV_CONFIG_PREFIX + variableName]) !== null && _a !== void 0 ? _a : packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig[camelcase_1.default(variableName)]) !== null && _b !== void 0 ? _b : defaultValues.get(variableName)); | ||
return ((_b = (_a = process.env[`${ENV_CONFIG_PREFIX}${variableName}`]) !== null && _a !== void 0 ? _a : packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig[(0, camelcase_1.default)(variableName)]) !== null && _b !== void 0 ? _b : defaultValues.get(variableName)); | ||
} | ||
@@ -72,4 +71,3 @@ exports.default = resolveConfig; | ||
*/ | ||
function envToBool(env) { | ||
if (env === void 0) { env = ''; } | ||
function envToBool(env = '') { | ||
return ['1', 'on', 'yes', 'true'].indexOf(env.toLowerCase()) !== -1; | ||
@@ -76,0 +74,0 @@ } |
{ | ||
"name": "redis-memory-server", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Redis Server for testing. The server will allow you to connect your favorite client library to the Redis Server and run parallel integration tests isolated from each other.", | ||
@@ -12,3 +12,3 @@ "main": "lib/index", | ||
"engines": { | ||
"node": ">=10.15.0" | ||
"node": ">=16" | ||
}, | ||
@@ -31,34 +31,34 @@ "files": [ | ||
"devDependencies": { | ||
"@commitlint/cli": "11.0.0", | ||
"@commitlint/config-conventional": "11.0.0", | ||
"@commitlint/cli": "^17.6.6", | ||
"@commitlint/config-conventional": "^17.6.6", | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/debug": "^4.1.5", | ||
"@types/find-cache-dir": "^3.2.0", | ||
"@types/find-package-json": "^1.1.1", | ||
"@types/ioredis": "^4.19.3", | ||
"@types/jest": "26.0.14", | ||
"@types/lockfile": "^1.0.1", | ||
"@types/lodash.defaultsdeep": "^4.6.6", | ||
"@types/mkdirp": "^1.0.1", | ||
"@types/node": "^14.11.2", | ||
"@types/rimraf": "^3.0.0", | ||
"@types/semver": "7.3.4", | ||
"@types/tar": "^4.0.4", | ||
"@types/tmp": "^0.2.0", | ||
"@types/uuid": "^8.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.15.0", | ||
"@typescript-eslint/parser": "^4.15.0", | ||
"commitlint": "11.0.0", | ||
"@types/debug": "^4.1.8", | ||
"@types/find-cache-dir": "^3.2.1", | ||
"@types/find-package-json": "^1.2.3", | ||
"@types/ioredis": "^5.0.0", | ||
"@types/jest": "^29.5.2", | ||
"@types/lockfile": "^1.0.2", | ||
"@types/lodash.defaultsdeep": "^4.6.7", | ||
"@types/mkdirp": "^2.0.0", | ||
"@types/node": "^18.11.9", | ||
"@types/rimraf": "^4.0.5", | ||
"@types/semver": "^7.5.0", | ||
"@types/tar": "^6.1.5", | ||
"@types/tmp": "^0.2.3", | ||
"@types/uuid": "^8.3.4", | ||
"@typescript-eslint/eslint-plugin": "^5.61.0", | ||
"@typescript-eslint/parser": "^5.61.0", | ||
"commitlint": "^17.6.6", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "6.12.0", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"husky": "^4.3.0", | ||
"ioredis": "^4.22.0", | ||
"jest": "^26.6.3", | ||
"lint-staged": "10.4.0", | ||
"prettier": "2.1.2", | ||
"standard-version": "^9.3.2", | ||
"ts-jest": "26.4.1", | ||
"typescript": "^4.1.4" | ||
"eslint": "^8.44.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^8.0.3", | ||
"ioredis": "^5.3.2", | ||
"jest": "^29.6.0", | ||
"lint-staged": "^13.2.3", | ||
"prettier": "^2.8.8", | ||
"standard-version": "^9.5.0", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "~5.1.6" | ||
}, | ||
@@ -70,25 +70,19 @@ "lint-staged": { | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS", | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"dependencies": { | ||
"camelcase": "^6.0.0", | ||
"camelcase": "^6.3.0", | ||
"cross-spawn": "^7.0.3", | ||
"debug": "^4.2.0", | ||
"debug": "^4.3.4", | ||
"extract-zip": "^2.0.1", | ||
"find-cache-dir": "^3.3.1", | ||
"find-cache-dir": "^3.3.2", | ||
"find-package-json": "^1.2.0", | ||
"get-port": "^5.1.1", | ||
"https-proxy-agent": "^5.0.0", | ||
"https-proxy-agent": "^7.0.0", | ||
"lockfile": "^1.0.4", | ||
"lodash.defaultsdeep": "^4.6.1", | ||
"mkdirp": "^1.0.4", | ||
"rimraf": "^3.0.2", | ||
"semver": "^7.3.2", | ||
"tar": "^6.1.0", | ||
"mkdirp": "^3.0.1", | ||
"rimraf": "^5.0.1", | ||
"semver": "^7.5.3", | ||
"tar": "^6.1.15", | ||
"tmp": "^0.2.1", | ||
"uuid": "8.3.0" | ||
"uuid": "^8.3.2" | ||
}, | ||
@@ -108,3 +102,4 @@ "scripts": { | ||
"tscheck": "tsc --noEmit" | ||
} | ||
}, | ||
"packageManager": "yarn@3.6.1" | ||
} |
@@ -9,3 +9,3 @@ /* eslint @typescript-eslint/no-var-requires: 0 */ | ||
It helps to skip timeout setup `jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;` | ||
It helps to skip timeout setup `jest.setTimeout(600000);` | ||
when first test run hits Redis binary downloading to the cache. | ||
@@ -12,0 +12,0 @@ */ |
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
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
41
111998
22595
1609
+ Added@isaacs/cliui@8.0.2(transitive)
+ Added@pkgjs/parseargs@0.11.0(transitive)
+ Addedagent-base@7.1.3(transitive)
+ Addedansi-regex@5.0.16.1.0(transitive)
+ Addedansi-styles@4.3.06.2.1(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedeastasianwidth@0.2.0(transitive)
+ Addedemoji-regex@8.0.09.2.2(transitive)
+ Addedforeground-child@3.3.0(transitive)
+ Addedglob@10.4.5(transitive)
+ Addedhttps-proxy-agent@7.0.6(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedjackspeak@3.4.3(transitive)
+ Addedlru-cache@10.4.3(transitive)
+ Addedminimatch@9.0.5(transitive)
+ Addedminipass@7.1.2(transitive)
+ Addedmkdirp@3.0.1(transitive)
+ Addedpackage-json-from-dist@1.0.1(transitive)
+ Addedpath-scurry@1.11.1(transitive)
+ Addedrimraf@5.0.10(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedstring-width@4.2.35.1.2(transitive)
+ Addedstrip-ansi@6.0.17.1.0(transitive)
+ Addeduuid@8.3.2(transitive)
+ Addedwrap-ansi@7.0.08.1.0(transitive)
- Removedagent-base@6.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedhttps-proxy-agent@5.0.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedrimraf@3.0.2(transitive)
- Removeduuid@8.3.0(transitive)
Updatedcamelcase@^6.3.0
Updateddebug@^4.3.4
Updatedfind-cache-dir@^3.3.2
Updatedhttps-proxy-agent@^7.0.0
Updatedmkdirp@^3.0.1
Updatedrimraf@^5.0.1
Updatedsemver@^7.5.3
Updatedtar@^6.1.15
Updateduuid@^8.3.2