mongodb-memory-server-core 7.4.0-beta.5 → 7.4.0
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 +35 -35
- package/lib/util/DryMongoBinary.js.map +1 -1
- package/lib/util/MongoBinary.d.ts.map +1 -1
- package/lib/util/MongoBinary.js +30 -26
- 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.d.ts.map +1 -1
- package/lib/util/MongoInstance.js +27 -33
- package/lib/util/MongoInstance.js.map +1 -1
- package/lib/util/errors.d.ts +18 -0
- package/lib/util/errors.d.ts.map +1 -1
- package/lib/util/errors.js +34 -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.d.ts +2 -1
- package/lib/util/resolveConfig.d.ts.map +1 -1
- package/lib/util/resolveConfig.js +11 -9
- package/lib/util/resolveConfig.js.map +1 -1
- package/lib/util/utils.d.ts +18 -0
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +43 -10
- package/lib/util/utils.js.map +1 -1
- package/package.json +3 -3
package/lib/util/utils.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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
|
-
const
|
|
7
|
+
const errors_1 = require("./errors");
|
|
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;
|
|
8
18
|
/**
|
|
9
19
|
* Return input or default database
|
|
10
20
|
* @param {string} dbName
|
|
@@ -52,7 +62,7 @@ exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
52
62
|
*/
|
|
53
63
|
function assertion(cond, error) {
|
|
54
64
|
if (!cond) {
|
|
55
|
-
throw error !== null && error !== void 0 ? error : new
|
|
65
|
+
throw error !== null && error !== void 0 ? error : new errors_1.AssertionFallbackError();
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
68
|
exports.assertion = assertion;
|
|
@@ -63,7 +73,7 @@ exports.assertion = assertion;
|
|
|
63
73
|
* @param mongodPort the port for the mongod process (for easier logging)
|
|
64
74
|
*/
|
|
65
75
|
function killProcess(childprocess, name, mongodPort) {
|
|
66
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
67
77
|
function ilog(msg) {
|
|
68
78
|
log(`Mongo[${mongodPort || 'unknown'}] killProcess: ${msg}`);
|
|
69
79
|
}
|
|
@@ -123,7 +133,7 @@ exports.isAlive = isAlive;
|
|
|
123
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)
|
|
124
134
|
*/
|
|
125
135
|
function ensureAsync() {
|
|
126
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
127
137
|
return new Promise((res) => process.nextTick(res));
|
|
128
138
|
});
|
|
129
139
|
}
|
|
@@ -143,7 +153,7 @@ exports.authDefault = authDefault;
|
|
|
143
153
|
* @throws if the error is not "ENOENT" or "EACCES"
|
|
144
154
|
*/
|
|
145
155
|
function statPath(path) {
|
|
146
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
147
157
|
return fs_1.promises.stat(path).catch((err) => {
|
|
148
158
|
// catch the error if the directory doesn't exist or permission is denied, without throwing an error
|
|
149
159
|
if (['ENOENT', 'EACCES'].includes(err.code)) {
|
|
@@ -161,7 +171,7 @@ exports.statPath = statPath;
|
|
|
161
171
|
* @param path The Path to check for
|
|
162
172
|
*/
|
|
163
173
|
function pathExists(path) {
|
|
164
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
165
175
|
return !isNullOrUndefined(yield statPath(path));
|
|
166
176
|
});
|
|
167
177
|
}
|
|
@@ -172,13 +182,13 @@ exports.pathExists = pathExists;
|
|
|
172
182
|
* @param parser An function to parse the output of the file
|
|
173
183
|
*/
|
|
174
184
|
function tryReleaseFile(path, parser) {
|
|
175
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
176
186
|
try {
|
|
177
187
|
const output = yield fs_1.promises.readFile(path);
|
|
178
188
|
return parser(output.toString());
|
|
179
189
|
}
|
|
180
190
|
catch (err) {
|
|
181
|
-
if (!['ENOENT', 'EACCES'].includes(err.code)) {
|
|
191
|
+
if (errorWithCode(err) && !['ENOENT', 'EACCES'].includes(err.code)) {
|
|
182
192
|
throw err;
|
|
183
193
|
}
|
|
184
194
|
log(`tryReleaseFile: "${path}" does not exist`);
|
|
@@ -199,4 +209,27 @@ exports.ManagerBase = ManagerBase;
|
|
|
199
209
|
class ManagerAdvanced extends ManagerBase {
|
|
200
210
|
}
|
|
201
211
|
exports.ManagerAdvanced = ManagerAdvanced;
|
|
212
|
+
/**
|
|
213
|
+
* Check that the Binary has sufficient Permissions to be executed
|
|
214
|
+
* @param path The Path to check
|
|
215
|
+
*/
|
|
216
|
+
function checkBinaryPermissions(path) {
|
|
217
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
|
|
218
|
+
try {
|
|
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
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
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
|
+
}
|
|
229
|
+
}
|
|
230
|
+
throw err;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
exports.checkBinaryPermissions = checkBinaryPermissions;
|
|
202
235
|
//# sourceMappingURL=utils.js.map
|
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,C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B,sBAAsB,CAAC,IAAY;;QACvD,IAAI;YACF,MAAM,aAAU,CAAC,MAAM,CAAC,IAAI,EAAE,cAAS,CAAC,IAAI,CAAC,CAAC,CAAC,6EAA6E;SAC7H;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE;gBACtB,IAAI,GAAG,CAAC,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.0
|
|
3
|
+
"version": "7.4.0",
|
|
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",
|