New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-memory-server-core

Package Overview
Dependencies
Maintainers
1
Versions
277
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-memory-server-core - npm Package Compare versions

Comparing version 6.4.0 to 6.4.1

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [6.4.1](https://github.com/nodkz/mongodb-memory-server/compare/v6.4.0...v6.4.1) (2020-03-19)
### Bug Fixes
* **MongoBinaryDownload:** Resolve in extractTarGz ([58faef2](https://github.com/nodkz/mongodb-memory-server/commit/58faef2))
# [6.4.0](https://github.com/nodkz/mongodb-memory-server/compare/v6.3.3...v6.4.0) (2020-03-19)

@@ -8,0 +19,0 @@

32

lib/__tests__/replset-single-restart-test.js

@@ -63,5 +63,5 @@ "use strict";

it('should start multiple times', function () { return __awaiter(void 0, void 0, void 0, function () {
var opts, replSetBefore, replSetAfter;
return __generator(this, function (_a) {
switch (_a.label) {
var opts, replSetBefore, _a, replSetAfter;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:

@@ -82,6 +82,14 @@ opts = {

case 1:
_a.sent();
_b.sent();
// Write real port to config (because 27017 may be busy, we need to get real port)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_a = opts.instanceOpts[0];
return [4 /*yield*/, replSetBefore.servers[0].getPort()];
case 2:
// Write real port to config (because 27017 may be busy, we need to get real port)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
_a.port = _b.sent();
return [4 /*yield*/, replSetBefore.stop()];
case 2:
_a.sent();
case 3:
_b.sent();
/**

@@ -93,3 +101,3 @@ * get-port has a portlocking-feature that keeps ports locked for

return [4 /*yield*/, sleep(30000)];
case 3:
case 4:
/**

@@ -100,10 +108,10 @@ * get-port has a portlocking-feature that keeps ports locked for

*/
_a.sent();
_b.sent();
replSetAfter = new MongoMemoryReplSet_1.default(opts);
return [4 /*yield*/, replSetAfter.waitUntilRunning()];
case 4:
_a.sent();
case 5:
_b.sent();
return [4 /*yield*/, replSetAfter.stop()];
case 5:
_a.sent();
case 6:
_b.sent();
return [2 /*return*/];

@@ -110,0 +118,0 @@ }

@@ -57,2 +57,16 @@ import { DownloadProgressT } from '../types';

/**
* Extract a .tar.gz archive
* @param mongoDBArchive Archive location
* @param extractDir Directory to extract to
* @param filter Method to determine which files to extract
*/
extractTarGz(mongoDBArchive: string, extractDir: string, filter: (file: string) => boolean): Promise<void>;
/**
* Extract a .zip archive
* @param mongoDBArchive Archive location
* @param extractDir Directory to extract to
* @param filter Method to determine which files to extract
*/
extractZip(mongoDBArchive: string, extractDir: string, filter: (file: string) => boolean): Promise<void>;
/**
* Downlaod given httpOptions to tempDownloadLocation, then move it to downloadLocation

@@ -59,0 +73,0 @@ * @param httpOptions The httpOptions directly passed to https.get

"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -55,3 +59,5 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var https_1 = __importDefault(require("https"));
var decompress_1 = __importDefault(require("decompress")); // 💩💩💩 this package does not work with Node@11+Jest+Babel
var zlib_1 = require("zlib");
var tar_stream_1 = __importDefault(require("tar-stream"));
var yauzl_1 = __importDefault(require("yauzl"));
var MongoBinaryDownloadUrl_1 = __importDefault(require("./MongoBinaryDownloadUrl"));

@@ -63,2 +69,3 @@ var MongoBinary_1 = require("./MongoBinary");

var debug_1 = __importDefault(require("debug"));
var dedent_1 = __importDefault(require("dedent"));
var log = debug_1.default('MongoMS:MongoBinaryDownload');

@@ -230,7 +237,7 @@ /**

MongoBinaryDownload.prototype.extract = function (mongoDBArchive) {
var _a;
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var binaryName, extractDir, filter;
return __generator(this, function (_b) {
switch (_b.label) {
return __generator(this, function (_c) {
switch (_c.label) {
case 0:

@@ -245,24 +252,26 @@ binaryName = this.platform === 'win32' ? 'mongod.exe' : 'mongod';

filter = function (file) {
return /bin\/mongod.exe$/.test(file.path) || /.dll$/.test(file.path);
return /bin\/mongod.exe$/.test(file) || /.dll$/.test(file);
};
}
else {
filter = function (file) { return /bin\/mongod$/.test(file.path); };
filter = function (file) { return /bin\/mongod$/.test(file); };
}
return [4 /*yield*/, decompress_1.default(mongoDBArchive, extractDir, {
// extract only `bin/mongod` file
filter: filter,
// extract to root folder
map: function (file) {
file.path = path_1.default.basename(file.path);
return file;
},
})];
if (!/(.tar.gz|.tgz)$/.test(path_1.default.extname(mongoDBArchive))) return [3 /*break*/, 2];
return [4 /*yield*/, this.extractTarGz(mongoDBArchive, extractDir, filter)];
case 1:
_b.sent();
return [4 /*yield*/, this.locationExists(path_1.default.resolve(this.downloadDir, this.version, binaryName))];
_c.sent();
return [3 /*break*/, 5];
case 2:
if (!(_b.sent())) {
throw new Error("MongoBinaryDownload: missing mongod binary in " + mongoDBArchive + " (downloaded from " + (_a = this
._downloadingUrl, (_a !== null && _a !== void 0 ? _a : 'unkown')) + "). Broken archive from MongoDB Provider?");
if (!/.zip$/.test(path_1.default.extname(mongoDBArchive))) return [3 /*break*/, 4];
return [4 /*yield*/, this.extractZip(mongoDBArchive, extractDir, filter)];
case 3:
_c.sent();
return [3 /*break*/, 5];
case 4: throw new Error("MongoBinaryDownload: unsupported archive " + mongoDBArchive + " (downloaded from " + (_a = this
._downloadingUrl, (_a !== null && _a !== void 0 ? _a : 'unkown')) + "). Broken archive from MongoDB Provider?");
case 5: return [4 /*yield*/, this.locationExists(path_1.default.resolve(this.downloadDir, this.version, binaryName))];
case 6:
if (!(_c.sent())) {
throw new Error("MongoBinaryDownload: missing mongod binary in " + mongoDBArchive + " (downloaded from " + (_b = this
._downloadingUrl, (_b !== null && _b !== void 0 ? _b : 'unkown')) + "). Broken archive from MongoDB Provider?");
}

@@ -275,2 +284,74 @@ return [2 /*return*/, extractDir];

/**
* Extract a .tar.gz archive
* @param mongoDBArchive Archive location
* @param extractDir Directory to extract to
* @param filter Method to determine which files to extract
*/
MongoBinaryDownload.prototype.extractTarGz = function (mongoDBArchive, extractDir, filter) {
return __awaiter(this, void 0, void 0, function () {
var extract;
return __generator(this, function (_a) {
extract = tar_stream_1.default.extract();
extract.on('entry', function (header, stream, next) {
if (filter(header.name)) {
stream.pipe(fs_1.default.createWriteStream(path_1.default.resolve(extractDir, path_1.default.basename(header.name)), {
mode: 509,
}));
}
stream.on('end', function () { return next(); });
stream.resume();
});
return [2 /*return*/, new Promise(function (resolve, reject) {
fs_1.default.createReadStream(mongoDBArchive)
.on('error', function (err) {
reject('Unable to open tarball ' + mongoDBArchive + ': ' + err);
})
.pipe(zlib_1.createUnzip())
.on('error', function (err) {
reject('Error during unzip for ' + mongoDBArchive + ': ' + err);
})
.pipe(extract)
.on('error', function (err) {
reject('Error during untar for ' + mongoDBArchive + ': ' + err);
})
.on('finish', function (result) {
resolve(result);
});
})];
});
});
};
/**
* Extract a .zip archive
* @param mongoDBArchive Archive location
* @param extractDir Directory to extract to
* @param filter Method to determine which files to extract
*/
MongoBinaryDownload.prototype.extractZip = function (mongoDBArchive, extractDir, filter) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
yauzl_1.default.open(mongoDBArchive, { lazyEntries: true }, function (e, zipfile) {
if (e || !zipfile)
return reject(e);
zipfile.readEntry();
zipfile.on('end', function () { return resolve(); });
zipfile.on('entry', function (entry) {
if (!filter(entry.fileName))
return zipfile.readEntry();
zipfile.openReadStream(entry, function (e, r) {
if (e || !r)
return reject(e);
r.on('end', function () { return zipfile.readEntry(); });
r.pipe(fs_1.default.createWriteStream(path_1.default.resolve(extractDir, path_1.default.basename(entry.fileName)), {
mode: 509,
}));
});
});
});
})];
});
});
};
/**
* Downlaod given httpOptions to tempDownloadLocation, then move it to downloadLocation

@@ -291,4 +372,3 @@ * @param httpOptions The httpOptions directly passed to https.get

if (response.statusCode === 403) {
reject(new Error("Status Code is 403 (MongoDB's 404)\n" +
'This means that the requested version-platform combination dosnt exist'));
reject(new Error(dedent_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n Status Code is 403 (MongoDB's 404)\n\n This means that the requested version-platform combination dosnt exist\n "], ["\n Status Code is 403 (MongoDB's 404)\\n\n This means that the requested version-platform combination dosnt exist\n "])))));
return;

@@ -354,4 +434,3 @@ }

var crReturn = this.platform === 'win32' ? '\x1b[0G' : '\r';
process.stdout.write("Downloading MongoDB " + this.version + ": " + percentComplete + " % (" + mbComplete + "mb " +
("/ " + this.dlProgress.totalMb + "mb)" + crReturn));
process.stdout.write("Downloading MongoDB " + this.version + ": " + percentComplete + " % (" + mbComplete + "mb / " + this.dlProgress.totalMb + "mb)" + crReturn);
};

@@ -387,2 +466,3 @@ /**

exports.default = MongoBinaryDownload;
var templateObject_1;
//# sourceMappingURL=MongoBinaryDownload.js.map
{
"name": "mongodb-memory-server-core",
"version": "6.4.0",
"version": "6.4.1",
"description": "MongoDB Server for testing (core package, without autodownload). The server will allow you to connect your favourite ODM or client library to the MongoDB Server and run parallel integration tests isolated from each other.",

@@ -36,2 +36,4 @@ "main": "lib/index",

"@types/mongodb": "3.5.2",
"@types/tar-stream": "^2.1.0",
"@types/yauzl": "^2.9.1",
"@typescript-eslint/eslint-plugin": "2.23.0",

@@ -52,3 +54,2 @@ "@typescript-eslint/parser": "2.23.0",

"@types/debug": "^4.1.5",
"@types/decompress": "^4.2.3",
"@types/dedent": "^0.7.0",

@@ -66,3 +67,2 @@ "@types/find-cache-dir": "^3.2.0",

"debug": "^4.1.1",
"decompress": "^4.2.0",
"dedent": "^0.7.0",

@@ -76,4 +76,6 @@ "find-cache-dir": "3.3.1",

"mkdirp": "^1.0.3",
"tar-stream": "^2.1.1",
"tmp": "^0.1.0",
"uuid": "^7.0.2"
"uuid": "^7.0.2",
"yauzl": "^2.10.0"
},

@@ -95,3 +97,3 @@ "optionalDependencies": {

},
"gitHead": "9bd61b9ae98099f63d273a4db4dcbcf62ed4937e"
"gitHead": "6653542a3867689dbbf8b168e1eea5b959b5ce09"
}

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