You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mongodb-runner

Package Overview
Dependencies
Maintainers
44
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-runner - npm Package Compare versions

Comparing version

to
5.5.1

dist/runner-helpers.d.ts

73

dist/cli.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -10,7 +33,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const path_1 = __importDefault(require("path"));
const fs_1 = require("fs");
const mongodb_1 = require("mongodb");
const child_process_1 = require("child_process");
const debug_1 = __importDefault(require("debug"));
const events_1 = require("events");
const utilities = __importStar(require("./index"));
(async function () {

@@ -77,2 +99,3 @@ const defaultRunnerDir = path_1.default.join(os_1.default.homedir(), '.mongodb', 'runner2');

.command('stop', 'Stop a MongoDB instance')
.command('prune', 'Clean up metadata for any dead MongoDB instances')
.command('ls', 'List currently running MongoDB instances')

@@ -87,15 +110,4 @@ .command('exec', 'Run a process with a MongoDB instance (as MONGODB_URI env var)')

async function start() {
const id = argv.id || new mongodb_1.BSON.UUID().toHexString();
if (!/^[a-zA-Z0-9_-]+$/.test(id)) {
throw new Error(`ID '${id}' contains non-alphanumeric characters`);
}
await fs_1.promises.mkdir(argv.runnerDir, { recursive: true });
const cluster = await mongocluster_1.MongoCluster.start({
...argv,
args,
});
const serialized = await cluster.serialize();
const { connectionString } = cluster;
await fs_1.promises.writeFile(path_1.default.join(argv.runnerDir, `m-${id}.json`), JSON.stringify({ id, serialized, connectionString }));
console.log(`Server started and running at ${connectionString}`);
const { cluster, id } = await utilities.start(argv);
console.log(`Server started and running at ${cluster.connectionString}`);
console.log('Run the following command to stop the instance:');

@@ -108,15 +120,2 @@ console.log(`${argv.$0} stop --id=${id}` +

}
async function* instances() {
for await (const { name } of await fs_1.promises.opendir(argv.runnerDir)) {
if (name.startsWith('m-') && name.endsWith('.json')) {
try {
const filepath = path_1.default.join(argv.runnerDir, name);
const stored = JSON.parse(await fs_1.promises.readFile(filepath, 'utf8'));
yield { ...stored, filepath };
}
catch {
}
}
}
}
async function stop() {

@@ -126,18 +125,12 @@ if (!argv.id && !argv.all) {

}
const toStop = [];
for await (const instance of instances()) {
if (instance.id === argv.id || argv.all)
toStop.push(instance);
}
await Promise.all(toStop.map(async ({ id, filepath, serialized, connectionString }) => {
await (await mongocluster_1.MongoCluster.deserialize(serialized)).close();
await fs_1.promises.rm(filepath);
console.log(`Stopped cluster '${id}' (was running at '${connectionString}')`);
}));
await utilities.stop(argv);
}
async function ls() {
for await (const { id, connectionString } of instances()) {
for await (const { id, connectionString } of utilities.instances(argv)) {
console.log(`${id}: ${connectionString}`);
}
}
async function prune() {
await utilities.prune(argv);
}
async function exec() {

@@ -179,3 +172,3 @@ let mongodArgs;

}
await ({ start, stop, exec, ls }[command] ?? unknown)();
await ({ start, stop, exec, ls, prune }[command] ?? unknown)();
})().catch((err) => {

@@ -182,0 +175,0 @@ process.nextTick(() => {

export { MongoServer, MongoServerOptions } from './mongoserver';
export { MongoCluster, MongoClusterOptions } from './mongocluster';
export type { ConnectionString } from 'mongodb-connection-string-url';
export { prune, start, stop, instances } from './runner-helpers';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MongoCluster = exports.MongoServer = void 0;
exports.instances = exports.stop = exports.start = exports.prune = exports.MongoCluster = exports.MongoServer = void 0;
var mongoserver_1 = require("./mongoserver");

@@ -8,2 +8,7 @@ Object.defineProperty(exports, "MongoServer", { enumerable: true, get: function () { return mongoserver_1.MongoServer; } });

Object.defineProperty(exports, "MongoCluster", { enumerable: true, get: function () { return mongocluster_1.MongoCluster; } });
var runner_helpers_1 = require("./runner-helpers");
Object.defineProperty(exports, "prune", { enumerable: true, get: function () { return runner_helpers_1.prune; } });
Object.defineProperty(exports, "start", { enumerable: true, get: function () { return runner_helpers_1.start; } });
Object.defineProperty(exports, "stop", { enumerable: true, get: function () { return runner_helpers_1.stop; } });
Object.defineProperty(exports, "instances", { enumerable: true, get: function () { return runner_helpers_1.instances; } });
//# sourceMappingURL=index.js.map
import type { MongoServerOptions } from './mongoserver';
import { ConnectionString } from 'mongodb-connection-string-url';
import type { DownloadOptions } from '@mongodb-js/mongodb-downloader';
import type { MongoClientOptions } from 'mongodb';
import { MongoClient } from 'mongodb';

@@ -29,3 +30,3 @@ export interface MongoClusterOptions extends Pick<MongoServerOptions, 'logDir' | 'tmpDir' | 'args' | 'binDir' | 'docker'> {

close(): Promise<void>;
withClient<Fn extends (client: MongoClient) => any>(fn: Fn): Promise<ReturnType<Fn>>;
withClient<Fn extends (client: MongoClient) => any>(fn: Fn, clientOptions?: MongoClientOptions): Promise<ReturnType<Fn>>;
ref(): void;

@@ -32,0 +33,0 @@ unref(): void;

@@ -166,4 +166,4 @@ "use strict";

}
async withClient(fn) {
const client = await mongodb_1.MongoClient.connect(this.connectionString);
async withClient(fn, clientOptions = {}) {
const client = await mongodb_1.MongoClient.connect(this.connectionString, clientOptions);
try {

@@ -170,0 +170,0 @@ return await fn(client);

@@ -6,2 +6,3 @@ import createDebug from 'debug';

export declare const range: (n: number) => number[];
export declare function parallelForEach<T>(iterable: AsyncIterable<T>, fn: (arg0: T) => Promise<void> | void): Promise<PromiseSettledResult<void>[]>;
//# sourceMappingURL=util.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.range = exports.sleep = exports.uuid = exports.debug = void 0;
exports.parallelForEach = exports.range = exports.sleep = exports.uuid = exports.debug = void 0;
const mongodb_1 = require("mongodb");

@@ -17,2 +17,10 @@ const debug_1 = __importDefault(require("debug"));

exports.range = range;
async function parallelForEach(iterable, fn) {
const result = [];
for await (const item of iterable) {
result.push(fn(item));
}
return await Promise.allSettled(result);
}
exports.parallelForEach = parallelForEach;
//# sourceMappingURL=util.js.map

@@ -16,3 +16,3 @@ {

"homepage": "https://github.com/mongodb-js/devtools-shared",
"version": "5.4.6",
"version": "5.5.1",
"repository": {

@@ -54,5 +54,6 @@ "type": "git",

"dependencies": {
"@mongodb-js/mongodb-downloader": "^0.2.9",
"@mongodb-js/mongodb-downloader": "^0.2.10",
"@mongodb-js/saslprep": "^1.1.3",
"debug": "^4.3.4",
"mongodb": "^5.6.0",
"mongodb": "^6.3.0",
"mongodb-connection-string-url": "^3.0.0",

@@ -63,3 +64,3 @@ "yargs": "^17.7.2"

"@mongodb-js/eslint-config-devtools": "0.9.10",
"@mongodb-js/mocha-config-devtools": "^1.0.2",
"@mongodb-js/mocha-config-devtools": "^1.0.3",
"@mongodb-js/prettier-config-devtools": "^1.0.1",

@@ -83,3 +84,3 @@ "@mongodb-js/tsconfig-devtools": "^1.0.1",

},
"gitHead": "e55cd86d06a1258bfb6da599fb00496b5acc3146"
"gitHead": "4d31c361281e576f54bced21cb5dc1523523052d"
}

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet