Socket
Socket
Sign inDemoInstall

mongodb-memory-server

Package Overview
Dependencies
Maintainers
1
Versions
345
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-memory-server - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

22

lib/MongoMemoryServer.js

@@ -14,3 +14,3 @@ 'use strict';

var generateDbName = function () {
var _ref = _asyncToGenerator(_regenerator2.default.mark(function _callee(dbName) {
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(dbName) {
return _regenerator2.default.wrap(function _callee$(_context) {

@@ -36,3 +36,3 @@ while (1) {

var generateConnectionString = function () {
var _ref2 = _asyncToGenerator(_regenerator2.default.mark(function _callee2(port, dbName) {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(port, dbName) {
return _regenerator2.default.wrap(function _callee2$(_context2) {

@@ -115,3 +115,3 @@ while (1) {

value: function () {
var _ref3 = _asyncToGenerator(_regenerator2.default.mark(function _callee3() {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
var _this2 = this;

@@ -167,3 +167,3 @@

value: function () {
var _ref4 = _asyncToGenerator(_regenerator2.default.mark(function _callee4() {
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
var data, tmpDir, instOpts, instance;

@@ -247,3 +247,3 @@ return _regenerator2.default.wrap(function _callee4$(_context4) {

value: function () {
var _ref5 = _asyncToGenerator(_regenerator2.default.mark(function _callee5() {
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
var _ref6, instance, port, tmpDir;

@@ -296,3 +296,3 @@

value: function () {
var _ref7 = _asyncToGenerator(_regenerator2.default.mark(function _callee6() {
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
return _regenerator2.default.wrap(function _callee6$(_context6) {

@@ -329,3 +329,3 @@ while (1) {

value: function () {
var _ref8 = _asyncToGenerator(_regenerator2.default.mark(function _callee7() {
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee7() {
var otherDbName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;

@@ -389,3 +389,3 @@

value: function () {
var _ref10 = _asyncToGenerator(_regenerator2.default.mark(function _callee8() {
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee8() {
var otherDbName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;

@@ -415,3 +415,3 @@ return _regenerator2.default.wrap(function _callee8$(_context8) {

value: function () {
var _ref11 = _asyncToGenerator(_regenerator2.default.mark(function _callee9() {
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee9() {
var _ref12, port;

@@ -448,3 +448,3 @@

value: function () {
var _ref13 = _asyncToGenerator(_regenerator2.default.mark(function _callee10() {
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee10() {
var _ref14, dbPath;

@@ -481,3 +481,3 @@

value: function () {
var _ref15 = _asyncToGenerator(_regenerator2.default.mark(function _callee11() {
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee11() {
var _ref16, dbName;

@@ -484,0 +484,0 @@

@@ -47,3 +47,3 @@ 'use strict';

value: function () {
var _ref = _asyncToGenerator(_regenerator2.default.mark(function _callee() {
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -50,0 +50,0 @@

@@ -18,2 +18,6 @@ 'use strict';

var _url = require('url');
var _url2 = _interopRequireDefault(_url);
var _path = require('path');

@@ -27,6 +31,2 @@

var _requestPromise = require('request-promise');
var _requestPromise2 = _interopRequireDefault(_requestPromise);
var _md5File = require('md5-file');

@@ -40,2 +40,6 @@

var _httpsProxyAgent = require('https-proxy-agent');
var _httpsProxyAgent2 = _interopRequireDefault(_httpsProxyAgent);
var _decompress = require('decompress');

@@ -90,3 +94,3 @@

value: function () {
var _ref2 = _asyncToGenerator(_regenerator2.default.mark(function _callee() {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var binaryName, mongodPath, mongoDBArchive;

@@ -109,3 +113,3 @@ return _regenerator2.default.wrap(function _callee$(_context) {

_context.next = 6;
return this.download();
return this.startDownload();

@@ -145,6 +149,6 @@ case 6:

}, {
key: 'download',
key: 'startDownload',
value: function () {
var _ref3 = _asyncToGenerator(_regenerator2.default.mark(function _callee2() {
var mbdUrl, url, archName, downloadLocation, tempDownloadLocation, mongoDBArchive, md5Remote, md5Local;
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
var mbdUrl, downloadUrl, mongoDBArchive, mongoDBArchiveMd5;
return _regenerator2.default.wrap(function _callee2$(_context2) {

@@ -167,35 +171,20 @@ while (1) {

case 5:
url = _context2.sent;
downloadUrl = _context2.sent;
_context2.next = 8;
return mbdUrl.getArchiveName();
return this.download(downloadUrl);
case 8:
archName = _context2.sent;
downloadLocation = _path2.default.resolve(this.downloadDir, archName);
mongoDBArchive = _context2.sent;
_context2.next = 11;
return this.download(`${downloadUrl}.md5`);
console.log('Downloading MongoDB:', url);
tempDownloadLocation = _path2.default.resolve(this.downloadDir, `${archName}.downloading`);
case 11:
mongoDBArchiveMd5 = _context2.sent;
_context2.next = 14;
return this.httpDownload(url, downloadLocation, tempDownloadLocation);
return this.checkMd5(mongoDBArchiveMd5, mongoDBArchive);
case 14:
mongoDBArchive = _context2.sent;
_context2.next = 17;
return this.downloadMD5(`${url}.md5`);
case 17:
md5Remote = _context2.sent;
md5Local = _md5File2.default.sync(mongoDBArchive);
if (!(md5Remote !== md5Local)) {
_context2.next = 21;
break;
}
throw new Error('MongoBinaryDownload: md5 check is failed');
case 21:
return _context2.abrupt('return', mongoDBArchive);
case 22:
case 15:
case 'end':

@@ -208,13 +197,13 @@ return _context2.stop();

function download() {
function startDownload() {
return _ref3.apply(this, arguments);
}
return download;
return startDownload;
}()
}, {
key: 'downloadMD5',
key: 'checkMd5',
value: function () {
var _ref4 = _asyncToGenerator(_regenerator2.default.mark(function _callee3(md5url) {
var signatureContent, signature;
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(mongoDBArchiveMd5, mongoDBArchive) {
var signatureContent, md5Remote, md5Local;
return _regenerator2.default.wrap(function _callee3$(_context3) {

@@ -225,12 +214,15 @@ while (1) {

_context3.next = 2;
return (0, _requestPromise2.default)(md5url);
return _fsExtra2.default.readFile(mongoDBArchiveMd5);
case 2:
signatureContent = _context3.sent;
signatureContent = _context3.sent.toString('UTF-8');
md5Remote = signatureContent.match(/(.*?)\s/)[1];
md5Local = _md5File2.default.sync(mongoDBArchive);
this.debug(`getDownloadMD5Hash content: ${signatureContent}`);
signature = signatureContent.match(/(.*?)\s/)[1];
if (!(md5Remote !== md5Local)) {
_context3.next = 7;
break;
}
this.debug(`getDownloadMD5Hash extracted signature: ${signature}`);
return _context3.abrupt('return', signature);
throw new Error('MongoBinaryDownload: md5 check is failed');

@@ -245,13 +237,13 @@ case 7:

function downloadMD5(_x) {
function checkMd5(_x, _x2) {
return _ref4.apply(this, arguments);
}
return downloadMD5;
return checkMd5;
}()
}, {
key: 'extract',
key: 'download',
value: function () {
var _ref5 = _asyncToGenerator(_regenerator2.default.mark(function _callee4(mongoDBArchive) {
var binaryName, extractDir, filter;
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(downloadUrl) {
var proxy, urlObject, downloadOptions, filename, downloadLocation, tempDownloadLocation, downloadedFile;
return _regenerator2.default.wrap(function _callee4$(_context4) {

@@ -261,2 +253,55 @@ while (1) {

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;
urlObject = _url2.default.parse(downloadUrl);
downloadOptions = {
hostname: urlObject.hostname,
port: urlObject.port || 443,
path: urlObject.path,
method: 'GET',
agent: proxy ? new _httpsProxyAgent2.default(proxy) : undefined
};
filename = (urlObject.pathname || '').split('/').pop();
if (filename) {
_context4.next = 6;
break;
}
throw new Error(`MongoBinaryDownload: missing filename for url ${downloadUrl}`);
case 6:
downloadLocation = _path2.default.resolve(this.downloadDir, filename);
tempDownloadLocation = _path2.default.resolve(this.downloadDir, `${filename}.downloading`);
console.log(`Downloading${proxy ? ` via proxy ${proxy}` : ''}:`, downloadUrl);
_context4.next = 11;
return this.httpDownload(downloadOptions, downloadLocation, tempDownloadLocation);
case 11:
downloadedFile = _context4.sent;
return _context4.abrupt('return', downloadedFile);
case 13:
case 'end':
return _context4.stop();
}
}
}, _callee4, this);
}));
function download(_x3) {
return _ref5.apply(this, arguments);
}
return download;
}()
}, {
key: 'extract',
value: function () {
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(mongoDBArchive) {
var binaryName, extractDir, filter;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
binaryName = this.platform === 'win32' ? 'mongod.exe' : 'mongod';

@@ -266,3 +311,3 @@ extractDir = _path2.default.resolve(this.downloadDir, this.version);

this.debug(`extract(): ${extractDir}`);
_context4.next = 5;
_context5.next = 5;
return _fsExtra2.default.ensureDir(extractDir);

@@ -285,3 +330,3 @@

_context4.next = 9;
_context5.next = 9;
return (0, _decompress2.default)(mongoDBArchive, extractDir, {

@@ -299,3 +344,3 @@ // extract only `bin/mongod` file

if (this.locationExists(_path2.default.resolve(this.downloadDir, this.version, binaryName))) {
_context4.next = 11;
_context5.next = 11;
break;

@@ -307,14 +352,14 @@ }

case 11:
return _context4.abrupt('return', extractDir);
return _context5.abrupt('return', extractDir);
case 12:
case 'end':
return _context4.stop();
return _context5.stop();
}
}
}, _callee4, this);
}, _callee5, this);
}));
function extract(_x2) {
return _ref5.apply(this, arguments);
function extract(_x4) {
return _ref6.apply(this, arguments);
}

@@ -327,10 +372,10 @@

value: function () {
var _ref6 = _asyncToGenerator(_regenerator2.default.mark(function _callee5(httpOptions, downloadLocation, tempDownloadLocation) {
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6(httpOptions, downloadLocation, tempDownloadLocation) {
var _this = this;
return _regenerator2.default.wrap(function _callee5$(_context5) {
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context6.prev = _context6.next) {
case 0:
return _context5.abrupt('return', new Promise(function (resolve, reject) {
return _context6.abrupt('return', new Promise(function (resolve, reject) {
var fileStream = _fsExtra2.default.createWriteStream(tempDownloadLocation);

@@ -366,10 +411,10 @@

case 'end':
return _context5.stop();
return _context6.stop();
}
}
}, _callee5, this);
}, _callee6, this);
}));
function httpDownload(_x3, _x4, _x5) {
return _ref6.apply(this, arguments);
function httpDownload(_x5, _x6, _x7) {
return _ref7.apply(this, arguments);
}

@@ -376,0 +421,0 @@

@@ -26,4 +26,2 @@ 'use strict';

var DOWNLOAD_URI = 'https://fastdl.mongodb.org';
var MongoBinaryDownloadUrl = function () {

@@ -47,3 +45,3 @@ function MongoBinaryDownloadUrl(_ref) {

value: function () {
var _ref2 = _asyncToGenerator(_regenerator2.default.mark(function _callee() {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var archive;

@@ -59,3 +57,3 @@ return _regenerator2.default.wrap(function _callee$(_context) {

archive = _context.sent;
return _context.abrupt('return', `${DOWNLOAD_URI}/${this.platform}/${archive}`);
return _context.abrupt('return', `https://fastdl.mongodb.org/${this.platform}/${archive}`);

@@ -79,3 +77,3 @@ case 4:

value: function () {
var _ref3 = _asyncToGenerator(_regenerator2.default.mark(function _callee2() {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
return _regenerator2.default.wrap(function _callee2$(_context2) {

@@ -118,3 +116,3 @@ while (1) {

value: function () {
var _ref4 = _asyncToGenerator(_regenerator2.default.mark(function _callee3() {
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
var name;

@@ -152,3 +150,3 @@ return _regenerator2.default.wrap(function _callee3$(_context3) {

value: function () {
var _ref5 = _asyncToGenerator(_regenerator2.default.mark(function _callee4() {
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
var name;

@@ -188,3 +186,3 @@ return _regenerator2.default.wrap(function _callee4$(_context4) {

value: function () {
var _ref6 = _asyncToGenerator(_regenerator2.default.mark(function _callee5() {
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
var name, osString;

@@ -246,3 +244,3 @@ return _regenerator2.default.wrap(function _callee5$(_context5) {

value: function () {
var _ref7 = _asyncToGenerator(_regenerator2.default.mark(function _callee6() {
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
return _regenerator2.default.wrap(function _callee6$(_context6) {

@@ -249,0 +247,0 @@ while (1) {

@@ -82,3 +82,3 @@ 'use strict';

value: function () {
var _ref = _asyncToGenerator(_regenerator2.default.mark(function _callee() {
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
var _this = this;

@@ -134,3 +134,3 @@

value: function () {
var _ref2 = _asyncToGenerator(_regenerator2.default.mark(function _callee2() {
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
var _this2 = this;

@@ -137,0 +137,0 @@

{
"name": "mongodb-memory-server",
"version": "1.8.0",
"version": "1.9.0",
"description": "In-memory MongoDB Server. Designed with testing in mind, the server will allow you to connect your favourite ODM or client library to the MongoDB Server and run integration tests isolated from each other.",

@@ -36,15 +36,15 @@ "main": "lib/index.js",

"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint": "^5.0.1",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.48.0",
"eslint-plugin-flowtype": "^2.49.3",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-prettier": "^2.6.0",
"flow-bin": "^0.73.0",
"flow-bin": "^0.75.0",
"jest": "^23.1.0",
"mongodb": "3.1.0-beta4",
"mongodb": "3.1.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.13.3",
"prettier": "^1.13.5",
"rimraf": "^2.6.2",
"semantic-release": "^15.5.0"
"semantic-release": "^15.5.2"
},

@@ -58,7 +58,6 @@ "dependencies": {

"getos": "^3.1.0",
"https-proxy-agent": "^2.2.1",
"lockfile": "^1.0.4",
"md5-file": "^4.0.0",
"mkdirp": "^0.5.1",
"request": "^2.87.0",
"request-promise": "^4.2.2",
"tmp": "^0.0.33",

@@ -65,0 +64,0 @@ "uuid": "^3.2.1"

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