mongodb-memory-server-core 8.15.0 → 9.0.0-beta.1
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/lib/MongoMemoryReplSet.d.ts +3 -19
- package/lib/MongoMemoryReplSet.d.ts.map +1 -1
- package/lib/MongoMemoryReplSet.js +283 -294
- package/lib/MongoMemoryReplSet.js.map +1 -1
- package/lib/MongoMemoryServer.d.ts +13 -26
- package/lib/MongoMemoryServer.d.ts.map +1 -1
- package/lib/MongoMemoryServer.js +323 -333
- package/lib/MongoMemoryServer.js.map +1 -1
- package/lib/util/DryMongoBinary.d.ts +1 -1
- package/lib/util/DryMongoBinary.d.ts.map +1 -1
- package/lib/util/DryMongoBinary.js +158 -172
- package/lib/util/DryMongoBinary.js.map +1 -1
- package/lib/util/MongoBinary.js +85 -85
- package/lib/util/MongoBinary.js.map +1 -1
- package/lib/util/MongoBinaryDownload.d.ts +2 -11
- package/lib/util/MongoBinaryDownload.d.ts.map +1 -1
- package/lib/util/MongoBinaryDownload.js +210 -262
- package/lib/util/MongoBinaryDownload.js.map +1 -1
- package/lib/util/MongoBinaryDownloadUrl.d.ts +3 -5
- package/lib/util/MongoBinaryDownloadUrl.d.ts.map +1 -1
- package/lib/util/MongoBinaryDownloadUrl.js +67 -94
- package/lib/util/MongoBinaryDownloadUrl.js.map +1 -1
- package/lib/util/MongoInstance.d.ts +3 -1
- package/lib/util/MongoInstance.d.ts.map +1 -1
- package/lib/util/MongoInstance.js +125 -126
- package/lib/util/MongoInstance.js.map +1 -1
- package/lib/util/errors.d.ts +10 -9
- package/lib/util/errors.d.ts.map +1 -1
- package/lib/util/errors.js +16 -27
- package/lib/util/errors.js.map +1 -1
- package/lib/util/getos/index.d.ts +1 -1
- package/lib/util/getos/index.d.ts.map +1 -1
- package/lib/util/getos/index.js +53 -59
- package/lib/util/getos/index.js.map +1 -1
- package/lib/util/getport/index.d.ts +34 -0
- package/lib/util/getport/index.d.ts.map +1 -0
- package/lib/util/getport/index.js +108 -0
- package/lib/util/getport/index.js.map +1 -0
- package/lib/util/lockfile.d.ts.map +1 -1
- package/lib/util/lockfile.js +155 -169
- package/lib/util/lockfile.js.map +1 -1
- package/lib/util/postinstallHelper.js +15 -18
- package/lib/util/postinstallHelper.js.map +1 -1
- package/lib/util/resolveConfig.d.ts.map +1 -1
- package/lib/util/resolveConfig.js +9 -8
- package/lib/util/resolveConfig.js.map +1 -1
- package/lib/util/utils.d.ts +20 -4
- package/lib/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +135 -118
- package/lib/util/utils.js.map +1 -1
- package/package.json +8 -12
package/lib/util/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAA0B,KAAK,EAAa,MAAM,IAAI,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAQlC,OAAO,EAAE,UAAU,EAA0B,MAAM,QAAQ,CAAC;AAI5D;;GAEG;AACH,UAAU,aAAc,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAEhE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAItD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG3C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM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
|
|
3
|
-
exports.removeDir = exports.createTmpDir = exports.mkdir = 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;
|
|
3
|
+
exports.md5FromFile = exports.md5 = exports.uuidv4 = exports.removeDir = exports.createTmpDir = exports.mkdir = 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 =
|
|
5
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const errors_1 = require("./errors");
|
|
8
8
|
const os_1 = require("os");
|
|
9
|
-
const path =
|
|
9
|
+
const path = tslib_1.__importStar(require("path"));
|
|
10
|
+
const crypto_1 = require("crypto");
|
|
10
11
|
const log = (0, debug_1.default)('MongoMS:utils');
|
|
11
12
|
/**
|
|
12
13
|
* This is here, because NodeJS does not have a FSError type
|
|
@@ -64,7 +65,7 @@ exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
64
65
|
*/
|
|
65
66
|
function assertion(cond, error) {
|
|
66
67
|
if (!cond) {
|
|
67
|
-
throw error
|
|
68
|
+
throw error ?? new errors_1.AssertionFallbackError();
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
exports.assertion = assertion;
|
|
@@ -74,46 +75,44 @@ exports.assertion = assertion;
|
|
|
74
75
|
* @param name the name used in the logs
|
|
75
76
|
* @param mongodPort the port for the mongod process (for easier logging)
|
|
76
77
|
*/
|
|
77
|
-
function killProcess(childprocess, name, mongodPort) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
timeout
|
|
105
|
-
|
|
106
|
-
rej(new Error(`Process "${name}" didnt exit, enable debug for more information.`));
|
|
107
|
-
}, timeoutTime);
|
|
78
|
+
async function killProcess(childprocess, name, mongodPort) {
|
|
79
|
+
function ilog(msg) {
|
|
80
|
+
log(`Mongo[${mongodPort || 'unknown'}] killProcess: ${msg}`);
|
|
81
|
+
}
|
|
82
|
+
// this case can somehow happen, see https://github.com/nodkz/mongodb-memory-server/issues/666
|
|
83
|
+
if (isNullOrUndefined(childprocess)) {
|
|
84
|
+
ilog('childprocess was somehow undefined');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// check if the childProcess (via PID) is still alive (found thanks to https://github.com/nodkz/mongodb-memory-server/issues/411)
|
|
88
|
+
if (!isAlive(childprocess.pid)) {
|
|
89
|
+
ilog("given childProcess's PID was not alive anymore");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Timeout before using SIGKILL
|
|
94
|
+
*/
|
|
95
|
+
const timeoutTime = 1000 * 10;
|
|
96
|
+
await new Promise((res, rej) => {
|
|
97
|
+
let timeout = setTimeout(() => {
|
|
98
|
+
ilog('timeout triggered, trying SIGKILL');
|
|
99
|
+
if (!debug_1.default.enabled('MongoMS:utils')) {
|
|
100
|
+
console.warn('An Process didnt exit with signal "SIGINT" within 10 seconds, using "SIGKILL"!\n' +
|
|
101
|
+
'Enable debug logs for more information');
|
|
102
|
+
}
|
|
103
|
+
childprocess.kill('SIGKILL');
|
|
104
|
+
timeout = setTimeout(() => {
|
|
105
|
+
ilog('timeout triggered again, rejecting');
|
|
106
|
+
rej(new Error(`Process "${name}" didnt exit, enable debug for more information.`));
|
|
108
107
|
}, timeoutTime);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
ilog(`${name}: sending "SIGINT"`);
|
|
115
|
-
childprocess.kill('SIGINT');
|
|
108
|
+
}, timeoutTime);
|
|
109
|
+
childprocess.once(`exit`, (code, signal) => {
|
|
110
|
+
ilog(`${name}: got exit signal, Code: ${code}, Signal: ${signal}`);
|
|
111
|
+
clearTimeout(timeout);
|
|
112
|
+
res();
|
|
116
113
|
});
|
|
114
|
+
ilog(`${name}: sending "SIGINT"`);
|
|
115
|
+
childprocess.kill('SIGINT');
|
|
117
116
|
});
|
|
118
117
|
}
|
|
119
118
|
exports.killProcess = killProcess;
|
|
@@ -139,10 +138,8 @@ exports.isAlive = isAlive;
|
|
|
139
138
|
* Call "process.nextTick" to ensure an function is exectued directly after all code surrounding it
|
|
140
139
|
* 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)
|
|
141
140
|
*/
|
|
142
|
-
function ensureAsync() {
|
|
143
|
-
return (
|
|
144
|
-
return new Promise((res) => process.nextTick(res));
|
|
145
|
-
});
|
|
141
|
+
async function ensureAsync() {
|
|
142
|
+
return new Promise((res) => process.nextTick(res));
|
|
146
143
|
}
|
|
147
144
|
exports.ensureAsync = ensureAsync;
|
|
148
145
|
/**
|
|
@@ -150,7 +147,15 @@ exports.ensureAsync = ensureAsync;
|
|
|
150
147
|
* @param opts Partitial input options
|
|
151
148
|
*/
|
|
152
149
|
function authDefault(opts) {
|
|
153
|
-
return
|
|
150
|
+
return {
|
|
151
|
+
force: false,
|
|
152
|
+
enable: true,
|
|
153
|
+
customRootName: 'mongodb-memory-server-root',
|
|
154
|
+
customRootPwd: 'rootuser',
|
|
155
|
+
extraUsers: [],
|
|
156
|
+
keyfileContent: '0123456789',
|
|
157
|
+
...opts,
|
|
158
|
+
};
|
|
154
159
|
}
|
|
155
160
|
exports.authDefault = authDefault;
|
|
156
161
|
/**
|
|
@@ -159,15 +164,13 @@ exports.authDefault = authDefault;
|
|
|
159
164
|
* @param path The Path to Stat
|
|
160
165
|
* @throws if the error is not "ENOENT" or "EACCES"
|
|
161
166
|
*/
|
|
162
|
-
function statPath(path) {
|
|
163
|
-
return (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
throw err;
|
|
170
|
-
});
|
|
167
|
+
async function statPath(path) {
|
|
168
|
+
return fs_1.promises.stat(path).catch((err) => {
|
|
169
|
+
// catch the error if the directory doesn't exist or permission is denied, without throwing an error
|
|
170
|
+
if (['ENOENT', 'EACCES'].includes(err.code)) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
throw err;
|
|
171
174
|
});
|
|
172
175
|
}
|
|
173
176
|
exports.statPath = statPath;
|
|
@@ -177,10 +180,8 @@ exports.statPath = statPath;
|
|
|
177
180
|
* follows symlinks
|
|
178
181
|
* @param path The Path to check for
|
|
179
182
|
*/
|
|
180
|
-
function pathExists(path) {
|
|
181
|
-
return (
|
|
182
|
-
return !isNullOrUndefined(yield statPath(path));
|
|
183
|
-
});
|
|
183
|
+
async function pathExists(path) {
|
|
184
|
+
return !isNullOrUndefined(await statPath(path));
|
|
184
185
|
}
|
|
185
186
|
exports.pathExists = pathExists;
|
|
186
187
|
/**
|
|
@@ -188,20 +189,18 @@ exports.pathExists = pathExists;
|
|
|
188
189
|
* @param path The Path to read for an release file
|
|
189
190
|
* @param parser An function to parse the output of the file
|
|
190
191
|
*/
|
|
191
|
-
function tryReleaseFile(path, parser) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
throw err;
|
|
200
|
-
}
|
|
201
|
-
log(`tryReleaseFile: "${path}" does not exist`);
|
|
202
|
-
return undefined;
|
|
192
|
+
async function tryReleaseFile(path, parser) {
|
|
193
|
+
try {
|
|
194
|
+
const output = await fs_1.promises.readFile(path);
|
|
195
|
+
return parser(output.toString());
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
if (errorWithCode(err) && !['ENOENT', 'EACCES'].includes(err.code)) {
|
|
199
|
+
throw err;
|
|
203
200
|
}
|
|
204
|
-
|
|
201
|
+
log(`tryReleaseFile: "${path}" does not exist`);
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
205
204
|
}
|
|
206
205
|
exports.tryReleaseFile = tryReleaseFile;
|
|
207
206
|
/**
|
|
@@ -220,23 +219,21 @@ exports.ManagerAdvanced = ManagerAdvanced;
|
|
|
220
219
|
* Check that the Binary has sufficient Permissions to be executed
|
|
221
220
|
* @param path The Path to check
|
|
222
221
|
*/
|
|
223
|
-
function checkBinaryPermissions(path) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
throw new errors_1.BinaryNotFoundError(path);
|
|
235
|
-
}
|
|
222
|
+
async function checkBinaryPermissions(path) {
|
|
223
|
+
try {
|
|
224
|
+
await fs_1.promises.access(path, fs_1.constants.X_OK); // check if the provided path exists and has the execute bit for current user
|
|
225
|
+
}
|
|
226
|
+
catch (err) {
|
|
227
|
+
if (errorWithCode(err)) {
|
|
228
|
+
if (err.code === 'EACCES') {
|
|
229
|
+
throw new errors_1.InsufficientPermissionsError(path);
|
|
230
|
+
}
|
|
231
|
+
if (err.code === 'ENOENT') {
|
|
232
|
+
throw new errors_1.BinaryNotFoundError(path);
|
|
236
233
|
}
|
|
237
|
-
throw err;
|
|
238
234
|
}
|
|
239
|
-
|
|
235
|
+
throw err;
|
|
236
|
+
}
|
|
240
237
|
}
|
|
241
238
|
exports.checkBinaryPermissions = checkBinaryPermissions;
|
|
242
239
|
/**
|
|
@@ -244,10 +241,8 @@ exports.checkBinaryPermissions = checkBinaryPermissions;
|
|
|
244
241
|
* @param path The Path to create
|
|
245
242
|
* @returns Nothing
|
|
246
243
|
*/
|
|
247
|
-
function mkdir(path) {
|
|
248
|
-
|
|
249
|
-
yield fs_1.promises.mkdir(path, { recursive: true });
|
|
250
|
-
});
|
|
244
|
+
async function mkdir(path) {
|
|
245
|
+
await fs_1.promises.mkdir(path, { recursive: true });
|
|
251
246
|
}
|
|
252
247
|
exports.mkdir = mkdir;
|
|
253
248
|
/**
|
|
@@ -256,11 +251,9 @@ exports.mkdir = mkdir;
|
|
|
256
251
|
* @param atPath Optionally set a custom path other than "os.tmpdir"
|
|
257
252
|
* @returns The created Path
|
|
258
253
|
*/
|
|
259
|
-
function createTmpDir(prefix, atPath) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return fs_1.promises.mkdtemp(path.join(tmpPath, prefix));
|
|
263
|
-
});
|
|
254
|
+
async function createTmpDir(prefix, atPath) {
|
|
255
|
+
const tmpPath = atPath ?? (0, os_1.tmpdir)();
|
|
256
|
+
return fs_1.promises.mkdtemp(path.join(tmpPath, prefix));
|
|
264
257
|
}
|
|
265
258
|
exports.createTmpDir = createTmpDir;
|
|
266
259
|
/**
|
|
@@ -268,27 +261,51 @@ exports.createTmpDir = createTmpDir;
|
|
|
268
261
|
* @param dirPath The Directory Path to delete
|
|
269
262
|
* @returns "true" if deleted, otherwise "false"
|
|
270
263
|
*/
|
|
271
|
-
function removeDir(dirPath) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
});
|
|
264
|
+
async function removeDir(dirPath) {
|
|
265
|
+
const stat = await statPath(dirPath);
|
|
266
|
+
if (isNullOrUndefined(stat)) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (!stat.isDirectory()) {
|
|
270
|
+
throw new Error(`Given Path is not a directory! (Path: "${dirPath}")`);
|
|
271
|
+
}
|
|
272
|
+
if ('rm' in fs_1.promises) {
|
|
273
|
+
// only since NodeJS 14
|
|
274
|
+
await fs_1.promises.rm(dirPath, { force: true, recursive: true });
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
// before NodeJS 14
|
|
278
|
+
// needs the bridge via the interface, because we are using @types/node 14, where this if evaluates to a always "true" in typescript's eyes
|
|
279
|
+
await fs_1.promises.rmdir(dirPath, {
|
|
280
|
+
recursive: true,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
292
283
|
}
|
|
293
284
|
exports.removeDir = removeDir;
|
|
285
|
+
/**
|
|
286
|
+
* Helper function to have uuidv4 generation and definition in one place
|
|
287
|
+
* @returns a uuid-v4
|
|
288
|
+
*/
|
|
289
|
+
function uuidv4() {
|
|
290
|
+
return (0, crypto_1.randomUUID)();
|
|
291
|
+
}
|
|
292
|
+
exports.uuidv4 = uuidv4;
|
|
293
|
+
/**
|
|
294
|
+
* Helper function to have md5 generation and definition in one place
|
|
295
|
+
* @param content the content to checksum
|
|
296
|
+
* @returns a md5 of the input
|
|
297
|
+
*/
|
|
298
|
+
function md5(content) {
|
|
299
|
+
return (0, crypto_1.createHash)('md5').update(content).digest('hex');
|
|
300
|
+
}
|
|
301
|
+
exports.md5 = md5;
|
|
302
|
+
/**
|
|
303
|
+
* Helper function to have md5 generation and definition in one place for a file
|
|
304
|
+
* @param file the location of a file to read for a hash
|
|
305
|
+
* @returns a md5 of the input file
|
|
306
|
+
*/
|
|
307
|
+
async function md5FromFile(file) {
|
|
308
|
+
return md5(await fs_1.promises.readFile(file));
|
|
309
|
+
}
|
|
310
|
+
exports.md5FromFile = md5FromFile;
|
|
294
311
|
//# 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,0DAA0B;AAG1B,2BAA8D;AAE9D,qCAIkB;AAClB,2BAA4B;AAC5B,mDAA6B;AAC7B,mCAA4D;AAE5D,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,CA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IAAI,aAAU,EAAE;QACtB,uBAAuB;QACvB,MAAM,aAAU,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KAChE;SAAM;QACL,mBAAmB;QACnB,2IAA2I;QAC3I,MAAO,aAAoB,CAAC,KAAK,CAAC,OAAO,EAAE;YACzC,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;KACJ;AACH,CAAC;AArBD,8BAqBC;AAED;;;GAGG;AACH,SAAgB,MAAM;IACpB,OAAO,IAAA,mBAAU,GAAE,CAAC;AACtB,CAAC;AAFD,wBAEC;AAED;;;;GAIG;AACH,SAAgB,GAAG,CAAC,OAAmB;IACrC,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAFD,kBAEC;AAED;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,OAAO,GAAG,CAAC,MAAM,aAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC;AAFD,kCAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb-memory-server-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-beta.1",
|
|
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",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"directory": "packages/mongodb-memory-server-core"
|
|
11
11
|
},
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
13
|
+
"node": ">=14.20.1"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"lib",
|
|
@@ -36,27 +36,23 @@
|
|
|
36
36
|
"@types/follow-redirects": "^1.14.1",
|
|
37
37
|
"@types/semver": "^7.5.0",
|
|
38
38
|
"@types/tar-stream": "^2.2.2",
|
|
39
|
-
"@types/uuid": "^9.0.2",
|
|
40
39
|
"@types/yauzl": "^2.10.0",
|
|
41
40
|
"@types/yazl": "^2.4.2",
|
|
42
|
-
"rimraf": "^
|
|
41
|
+
"rimraf": "^5.0.1",
|
|
43
42
|
"yazl": "^2.5.1"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"async-mutex": "^0.
|
|
45
|
+
"async-mutex": "^0.4.0",
|
|
47
46
|
"camelcase": "^6.3.0",
|
|
48
47
|
"debug": "^4.3.4",
|
|
49
48
|
"find-cache-dir": "^3.3.2",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"https-proxy-agent": "^5.0.1",
|
|
53
|
-
"md5-file": "^5.0.0",
|
|
54
|
-
"mongodb": "^4.16.0",
|
|
49
|
+
"https-proxy-agent": "^7.0.1",
|
|
50
|
+
"mongodb": "^5.6.0",
|
|
55
51
|
"new-find-package-json": "^2.0.0",
|
|
56
52
|
"semver": "^7.5.4",
|
|
57
|
-
"tar-stream": "^
|
|
53
|
+
"tar-stream": "^3.0.0",
|
|
58
54
|
"tslib": "^2.6.1",
|
|
59
|
-
"
|
|
55
|
+
"follow-redirects": "^1.15.2",
|
|
60
56
|
"yauzl": "^2.10.0"
|
|
61
57
|
},
|
|
62
58
|
"scripts": {
|