mongodb-memory-server-core 7.4.0-beta.7 → 7.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/lib/MongoMemoryReplSet.d.ts.map +1 -1
- package/lib/MongoMemoryReplSet.js +36 -36
- package/lib/MongoMemoryReplSet.js.map +1 -1
- package/lib/MongoMemoryServer.js +39 -39
- package/lib/MongoMemoryServer.js.map +1 -1
- package/lib/util/DryMongoBinary.d.ts.map +1 -1
- package/lib/util/DryMongoBinary.js +34 -34
- package/lib/util/DryMongoBinary.js.map +1 -1
- package/lib/util/MongoBinary.js +20 -20
- package/lib/util/MongoBinary.js.map +1 -1
- package/lib/util/MongoBinaryDownload.d.ts +1 -0
- package/lib/util/MongoBinaryDownload.d.ts.map +1 -1
- package/lib/util/MongoBinaryDownload.js +39 -38
- package/lib/util/MongoBinaryDownload.js.map +1 -1
- package/lib/util/MongoBinaryDownloadUrl.js +14 -14
- package/lib/util/MongoBinaryDownloadUrl.js.map +1 -1
- package/lib/util/MongoInstance.js +25 -25
- package/lib/util/MongoInstance.js.map +1 -1
- package/lib/util/errors.d.ts +10 -0
- package/lib/util/errors.d.ts.map +1 -1
- package/lib/util/errors.js +19 -2
- package/lib/util/errors.js.map +1 -1
- package/lib/util/getos/index.js +13 -13
- package/lib/util/getos/index.js.map +1 -1
- package/lib/util/lockfile.js +17 -17
- package/lib/util/lockfile.js.map +1 -1
- package/lib/util/postinstallHelper.js +7 -7
- package/lib/util/postinstallHelper.js.map +1 -1
- package/lib/util/resolveConfig.js +11 -11
- package/lib/util/resolveConfig.js.map +1 -1
- package/lib/util/utils.d.ts +13 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +27 -16
- package/lib/util/utils.js.map +1 -1
- package/package.json +3 -3
package/lib/util/utils.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkBinaryPermissions = exports.ManagerAdvanced = exports.ManagerBase = exports.tryReleaseFile = exports.pathExists = exports.statPath = exports.authDefault = exports.ensureAsync = exports.isAlive = exports.killProcess = exports.assertion = exports.isNullOrUndefined = exports.uriTemplate = exports.getHost = exports.generateDbName = void 0;
|
|
3
|
+
exports.checkBinaryPermissions = exports.ManagerAdvanced = exports.ManagerBase = exports.tryReleaseFile = exports.pathExists = exports.statPath = exports.authDefault = exports.ensureAsync = exports.isAlive = exports.killProcess = exports.assertion = exports.isNullOrUndefined = exports.uriTemplate = exports.getHost = exports.generateDbName = exports.errorWithCode = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
5
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const errors_1 = require("./errors");
|
|
8
|
-
const log = debug_1.default('MongoMS:utils');
|
|
8
|
+
const log = (0, debug_1.default)('MongoMS:utils');
|
|
9
|
+
/**
|
|
10
|
+
* This is here, because NodeJS does not have a FSError type
|
|
11
|
+
* @param err Value to check agains
|
|
12
|
+
* @returns `true` if it is a error with code, `false` if not
|
|
13
|
+
*/
|
|
14
|
+
function errorWithCode(err) {
|
|
15
|
+
return err instanceof Error && 'code' in err;
|
|
16
|
+
}
|
|
17
|
+
exports.errorWithCode = errorWithCode;
|
|
9
18
|
/**
|
|
10
19
|
* Return input or default database
|
|
11
20
|
* @param {string} dbName
|
|
@@ -53,7 +62,7 @@ exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
53
62
|
*/
|
|
54
63
|
function assertion(cond, error) {
|
|
55
64
|
if (!cond) {
|
|
56
|
-
throw error !== null && error !== void 0 ? error : new
|
|
65
|
+
throw error !== null && error !== void 0 ? error : new errors_1.AssertionFallbackError();
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
68
|
exports.assertion = assertion;
|
|
@@ -64,7 +73,7 @@ exports.assertion = assertion;
|
|
|
64
73
|
* @param mongodPort the port for the mongod process (for easier logging)
|
|
65
74
|
*/
|
|
66
75
|
function killProcess(childprocess, name, mongodPort) {
|
|
67
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
68
77
|
function ilog(msg) {
|
|
69
78
|
log(`Mongo[${mongodPort || 'unknown'}] killProcess: ${msg}`);
|
|
70
79
|
}
|
|
@@ -124,7 +133,7 @@ exports.isAlive = isAlive;
|
|
|
124
133
|
* look at the following link to get to know on why this needed: https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#process-nexttick (read full documentation)
|
|
125
134
|
*/
|
|
126
135
|
function ensureAsync() {
|
|
127
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
128
137
|
return new Promise((res) => process.nextTick(res));
|
|
129
138
|
});
|
|
130
139
|
}
|
|
@@ -144,7 +153,7 @@ exports.authDefault = authDefault;
|
|
|
144
153
|
* @throws if the error is not "ENOENT" or "EACCES"
|
|
145
154
|
*/
|
|
146
155
|
function statPath(path) {
|
|
147
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
148
157
|
return fs_1.promises.stat(path).catch((err) => {
|
|
149
158
|
// catch the error if the directory doesn't exist or permission is denied, without throwing an error
|
|
150
159
|
if (['ENOENT', 'EACCES'].includes(err.code)) {
|
|
@@ -162,7 +171,7 @@ exports.statPath = statPath;
|
|
|
162
171
|
* @param path The Path to check for
|
|
163
172
|
*/
|
|
164
173
|
function pathExists(path) {
|
|
165
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
166
175
|
return !isNullOrUndefined(yield statPath(path));
|
|
167
176
|
});
|
|
168
177
|
}
|
|
@@ -173,13 +182,13 @@ exports.pathExists = pathExists;
|
|
|
173
182
|
* @param parser An function to parse the output of the file
|
|
174
183
|
*/
|
|
175
184
|
function tryReleaseFile(path, parser) {
|
|
176
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
177
186
|
try {
|
|
178
187
|
const output = yield fs_1.promises.readFile(path);
|
|
179
188
|
return parser(output.toString());
|
|
180
189
|
}
|
|
181
190
|
catch (err) {
|
|
182
|
-
if (!['ENOENT', 'EACCES'].includes(err.code)) {
|
|
191
|
+
if (errorWithCode(err) && !['ENOENT', 'EACCES'].includes(err.code)) {
|
|
183
192
|
throw err;
|
|
184
193
|
}
|
|
185
194
|
log(`tryReleaseFile: "${path}" does not exist`);
|
|
@@ -205,16 +214,18 @@ exports.ManagerAdvanced = ManagerAdvanced;
|
|
|
205
214
|
* @param path The Path to check
|
|
206
215
|
*/
|
|
207
216
|
function checkBinaryPermissions(path) {
|
|
208
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
209
218
|
try {
|
|
210
219
|
yield fs_1.promises.access(path, fs_1.constants.X_OK); // check if the provided path exists and has the execute bit for current user
|
|
211
220
|
}
|
|
212
221
|
catch (err) {
|
|
213
|
-
if ((err
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
222
|
+
if (errorWithCode(err)) {
|
|
223
|
+
if (err.code === 'EACCES') {
|
|
224
|
+
throw new errors_1.InsufficientPermissionsError(path);
|
|
225
|
+
}
|
|
226
|
+
if (err.code === 'ENOENT') {
|
|
227
|
+
throw new errors_1.BinaryNotFoundError(path);
|
|
228
|
+
}
|
|
218
229
|
}
|
|
219
230
|
throw err;
|
|
220
231
|
}
|
package/lib/util/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":";;;;AAAA,+DAA0B;AAG1B,2BAA8D;AAE9D,qCAIkB;AAElB,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,eAAe,CAAC,CAAC;AASnC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,OAAO,GAAG,YAAY,KAAK,IAAI,MAAM,IAAI,GAAG,CAAC;AAC/C,CAAC;AAFD,sCAEC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,MAAe;IAC5C,8FAA8F;IAC9F,sFAAsF;IACtF,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC;AAJD,wCAIC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,GAAW;IACjC,gGAAgG;IAChG,OAAO,GAAG,CAAC,OAAO,CAAC,yCAAyC,EAAE,EAAE,CAAC,CAAC;AACpE,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CACzB,IAAY,EACZ,IAAwB,EACxB,MAAc,EACd,KAAgB;IAEhB,MAAM,KAAK,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAElE,OAAO,aAAa,KAAK,IAAI,MAAM,EAAE,GAAG,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACnG,CAAC;AATD,kCASC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,GAAY;IAC5C,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC;AA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AAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,MAAM,IAAI,qCAA4B,CAAC,IAAI,CAAC,CAAC;iBAC9C;gBACD,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,MAAM,IAAI,4BAAmB,CAAC,IAAI,CAAC,CAAC;iBACrC;aACF;YAED,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CAAA;AAfD,wDAeC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-memory-server-core",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.2",
|
|
4
4
|
"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.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@types/tmp": "^0.2.0",
|
|
46
|
-
"async-mutex": "^0.3.
|
|
46
|
+
"async-mutex": "^0.3.2",
|
|
47
47
|
"camelcase": "^6.1.0",
|
|
48
48
|
"debug": "^4.2.0",
|
|
49
|
-
"find-cache-dir": "^3.3.
|
|
49
|
+
"find-cache-dir": "^3.3.2",
|
|
50
50
|
"get-port": "^5.1.1",
|
|
51
51
|
"https-proxy-agent": "^5.0.0",
|
|
52
52
|
"md5-file": "^5.0.0",
|