@mongosh/cli-repl 2.6.0 → 2.8.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/AUTHORS +1 -0
- package/lib/async-repl.js +11 -9
- package/lib/async-repl.js.map +1 -1
- package/lib/build-info.js +4 -6
- package/lib/build-info.js.map +1 -1
- package/lib/build-info.json +1 -1
- package/lib/cli-repl.d.ts +1 -0
- package/lib/cli-repl.js +64 -72
- package/lib/cli-repl.js.map +1 -1
- package/lib/config-directory.js +7 -9
- package/lib/config-directory.js.map +1 -1
- package/lib/crypt-library-paths.js +8 -10
- package/lib/crypt-library-paths.js.map +1 -1
- package/lib/format-output.js +5 -8
- package/lib/format-output.js.map +1 -1
- package/lib/get-os-info.js +3 -4
- package/lib/get-os-info.js.map +1 -1
- package/lib/line-by-line-input.js +1 -1
- package/lib/line-by-line-input.js.map +1 -1
- package/lib/mongosh-repl.js +80 -69
- package/lib/mongosh-repl.js.map +1 -1
- package/lib/node-repl-fix-completer-side-effects.js +1 -1
- package/lib/node-repl-fix-completer-side-effects.js.map +1 -1
- package/lib/node-repl-fix-history-rewrite-on-error.d.ts +2 -0
- package/lib/node-repl-fix-history-rewrite-on-error.js +79 -0
- package/lib/node-repl-fix-history-rewrite-on-error.js.map +1 -0
- package/lib/repl-paste-support.js +3 -4
- package/lib/repl-paste-support.js.map +1 -1
- package/lib/run.js +14 -13
- package/lib/run.js.map +1 -1
- package/lib/smoke-tests.js +8 -6
- package/lib/smoke-tests.js.map +1 -1
- package/lib/startup-timing.d.ts +1 -0
- package/lib/startup-timing.js +11 -7
- package/lib/startup-timing.js.map +1 -1
- package/lib/tls-certificate-selector.js +4 -5
- package/lib/tls-certificate-selector.js.map +1 -1
- package/lib/update-notification-manager.js +23 -19
- package/lib/update-notification-manager.js.map +1 -1
- package/lib/webpack-self-inspection.js +2 -4
- package/lib/webpack-self-inspection.js.map +1 -1
- package/package.json +29 -29
- package/webpack.config.js +11 -5
package/AUTHORS
CHANGED
|
@@ -28,3 +28,4 @@ mongodb-devtools-bot[bot] <189715634+mongodb-devtools-bot[bot]@users.noreply.git
|
|
|
28
28
|
Ubuntu <ubuntu@ip-10-0-5-160.ec2.internal>
|
|
29
29
|
Ubuntu <ubuntu@ip-10-0-4-95.ec2.internal>
|
|
30
30
|
Davenson Lombard <dlombard@users.noreply.github.com>
|
|
31
|
+
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
|
package/lib/async-repl.js
CHANGED
|
@@ -23,18 +23,16 @@ function disableEvent(emitter, event) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function getPrompt(repl) {
|
|
26
|
-
|
|
27
|
-
return (_b = (_a = repl.getPrompt) === null || _a === void 0 ? void 0 : _a.call(repl)) !== null && _b !== void 0 ? _b : repl._prompt;
|
|
26
|
+
return repl.getPrompt?.() ?? repl._prompt;
|
|
28
27
|
}
|
|
29
28
|
function start(opts) {
|
|
30
|
-
var _a;
|
|
31
29
|
const { Recoverable, start: originalStart } = require('repl');
|
|
32
30
|
const { asyncEval, wrapCallbackError = (err) => err, onAsyncSigint } = opts;
|
|
33
31
|
if (onAsyncSigint) {
|
|
34
32
|
opts.breakEvalOnSigint = true;
|
|
35
33
|
}
|
|
36
|
-
const repl = (
|
|
37
|
-
const originalEval = (0, util_1.promisify)(wrapPauseInput(repl.input, wrapNoSyncDomainError(repl.eval.bind(repl))));
|
|
34
|
+
const repl = (opts.start ?? originalStart)(opts);
|
|
35
|
+
const originalEval = (0, util_1.promisify)(wrapPauseInput(repl.input, wrapNoSyncDomainError(repl.eval.bind(repl), repl)));
|
|
38
36
|
const setRawMode = (mode) => {
|
|
39
37
|
const input = repl.input;
|
|
40
38
|
const wasInRawMode = input.isRaw;
|
|
@@ -57,7 +55,6 @@ function start(opts) {
|
|
|
57
55
|
return callback(new Recoverable(new Error('recoverable because pasting in progress')));
|
|
58
56
|
}
|
|
59
57
|
async function _eval() {
|
|
60
|
-
var _a, _b;
|
|
61
58
|
let previouslyInRawMode;
|
|
62
59
|
if (onAsyncSigint) {
|
|
63
60
|
previouslyInRawMode = setRawMode(false);
|
|
@@ -114,8 +111,8 @@ function start(opts) {
|
|
|
114
111
|
repl.removeListener('SIGINT', sigintListener);
|
|
115
112
|
process.removeListener('SIGINT', sigintListener);
|
|
116
113
|
}
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
replSigint?.restore?.();
|
|
115
|
+
processSigint?.restore?.();
|
|
119
116
|
if (getPrompt(repl) === '') {
|
|
120
117
|
Interface.prototype.setPrompt.call(repl, origPrompt);
|
|
121
118
|
}
|
|
@@ -163,7 +160,7 @@ function start(opts) {
|
|
|
163
160
|
};
|
|
164
161
|
return repl;
|
|
165
162
|
}
|
|
166
|
-
function wrapNoSyncDomainError(fn) {
|
|
163
|
+
function wrapNoSyncDomainError(fn, repl) {
|
|
167
164
|
return (...args) => {
|
|
168
165
|
const { Domain } = require('domain');
|
|
169
166
|
const origEmit = Domain.prototype.emit;
|
|
@@ -174,10 +171,15 @@ function wrapNoSyncDomainError(fn) {
|
|
|
174
171
|
}
|
|
175
172
|
return origEmit.call(this, ev, ...eventArgs);
|
|
176
173
|
};
|
|
174
|
+
const origHandleError = repl._handleError;
|
|
175
|
+
repl._handleError = (err) => {
|
|
176
|
+
throw err;
|
|
177
|
+
};
|
|
177
178
|
try {
|
|
178
179
|
return fn(...args);
|
|
179
180
|
}
|
|
180
181
|
finally {
|
|
182
|
+
repl._handleError = origHandleError;
|
|
181
183
|
Domain.prototype.emit = origEmit;
|
|
182
184
|
}
|
|
183
185
|
};
|
package/lib/async-repl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-repl.js","sourceRoot":"","sources":["../src/async-repl.ts"],"names":[],"mappings":";;;;;;AA2EA,
|
|
1
|
+
{"version":3,"file":"async-repl.js","sourceRoot":"","sources":["../src/async-repl.ts"],"names":[],"mappings":";;;;;;AA2EA,sBAkNC;AAgJD,4DA6BC;A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,EAAE,eAAe,CAAC,CAAC;IAC7D,qCAAqC,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAClE,CAAC"}
|
package/lib/build-info.js
CHANGED
|
@@ -19,10 +19,9 @@ function getSystemArch() {
|
|
|
19
19
|
: process.arch;
|
|
20
20
|
}
|
|
21
21
|
async function getInstallationMethod(info) {
|
|
22
|
-
var _a;
|
|
23
22
|
if (info.distributionKind !== 'compiled') {
|
|
24
23
|
if (process.env.npm_lifecycle_event === 'npx' &&
|
|
25
|
-
|
|
24
|
+
process.env.npm_lifecycle_script?.includes('mongosh'))
|
|
26
25
|
return 'npx';
|
|
27
26
|
if (__filename.match(/\bhomebrew\b/i) &&
|
|
28
27
|
process.execPath.match(/\bhomebrew\b/i))
|
|
@@ -38,14 +37,13 @@ async function getInstallationMethod(info) {
|
|
|
38
37
|
return 'other';
|
|
39
38
|
}
|
|
40
39
|
function baseBuildInfo() {
|
|
41
|
-
var _a;
|
|
42
40
|
const runtimeData = {
|
|
43
41
|
nodeVersion: process.version,
|
|
44
42
|
opensslVersion: process.versions.openssl,
|
|
45
43
|
sharedOpenssl: !!process.config.variables.node_shared_openssl,
|
|
46
44
|
runtimeArch: getSystemArch(),
|
|
47
45
|
runtimePlatform: process.platform,
|
|
48
|
-
runtimeGlibcVersion:
|
|
46
|
+
runtimeGlibcVersion: getGlibcVersion() ?? 'N/A',
|
|
49
47
|
};
|
|
50
48
|
try {
|
|
51
49
|
return {
|
|
@@ -53,7 +51,7 @@ function baseBuildInfo() {
|
|
|
53
51
|
...runtimeData,
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
|
-
catch
|
|
54
|
+
catch {
|
|
57
55
|
const { version } = require('../package.json');
|
|
58
56
|
return {
|
|
59
57
|
version,
|
|
@@ -89,7 +87,7 @@ function getGlibcVersion() {
|
|
|
89
87
|
try {
|
|
90
88
|
return (cachedGlibcVersion = require('glibc-version')());
|
|
91
89
|
}
|
|
92
|
-
catch
|
|
90
|
+
catch {
|
|
93
91
|
return (cachedGlibcVersion = undefined);
|
|
94
92
|
}
|
|
95
93
|
}
|
package/lib/build-info.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-info.js","sourceRoot":"","sources":["../src/build-info.ts"],"names":[],"mappings":";;;;;AAgEA,sCAmCC;AAOD,8BAiBC;AAGD,0CAQC;AAtID,4CAAoB;AACpB,wFAAkF;AAClF,2BAAoC;AAqBpC,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAClC,CAAC,CAAC,YAAE,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAMrB,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC;YACF,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,KAAK;QACT,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,qBAAqB,CAClC,IAA2D
|
|
1
|
+
{"version":3,"file":"build-info.js","sourceRoot":"","sources":["../src/build-info.ts"],"names":[],"mappings":";;;;;AAgEA,sCAmCC;AAOD,8BAiBC;AAGD,0CAQC;AAtID,4CAAoB;AACpB,wFAAkF;AAClF,2BAAoC;AAqBpC,SAAS,aAAa;IACpB,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAClC,CAAC,CAAC,YAAE,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YAMrB,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC;YACF,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,KAAK;QACT,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;AACnB,CAAC;AAED,KAAK,UAAU,qBAAqB,CAClC,IAA2D;IAE3D,IAAI,IAAI,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC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,QAAQ;YAC/B,WAAW,EAAE,SAAS;YACtB,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,IAAI;YAChB,GAAG,WAAW;SACf,CAAC;IACJ,CAAC;AACH,CAAC;AAOM,KAAK,UAAU,SAAS,CAAC,EAC9B,iBAAiB,MAGf,EAAE;IACJ,MAAM,qBAAqB,GAAsB;QAC/C,GAAG,wDAAyB,CAAC,qBAAqB,EAAE;KACrD,CAAC;IAEF,MAAM,SAAS,GAAG,EAAE,GAAG,aAAa,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,qBAAqB,EAAE,EAAE,CAAC;IAC7E,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,aAAa,CAAC;IACjC,CAAC;IACD,OAAO;QACL,kBAAkB,EAAE,MAAM,qBAAqB,CAAC,SAAS,CAAC;QAC1D,GAAG,SAAS;KACb,CAAC;AACJ,CAAC;AAED,IAAI,kBAAkB,GAA8B,IAAI,CAAC;AACzD,SAAgB,eAAe;IAC7B,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACnD,IAAI,kBAAkB,KAAK,IAAI;QAAE,OAAO,kBAAkB,CAAC;IAC3D,IAAI,CAAC;QACH,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
|
package/lib/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"segmentApiKey":"w4oPlEOrASGSSb7oSF6EAVhdTF3JeGP9","version":"2.
|
|
1
|
+
{"segmentApiKey":"w4oPlEOrASGSSb7oSF6EAVhdTF3JeGP9","version":"2.8.1","distributionKind":"packaged","buildArch":"x64","buildPlatform":"linux","buildTarget":"unknown","buildTime":"2026-03-17T00:51:06.880Z","gitVersion":"3da1d8d52afabfc4c6d7dc85ee31476575399c85"}
|
package/lib/cli-repl.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare class CliRepl implements MongoshIOProvider {
|
|
|
64
64
|
updateNotificationManager: UpdateNotificationManager;
|
|
65
65
|
fetchMongoshUpdateUrlRegardlessOfCiEnvironment: boolean;
|
|
66
66
|
cachedGlibcVersion: null | string | undefined;
|
|
67
|
+
exitingForStartupError: boolean;
|
|
67
68
|
private loggingAndTelemetry;
|
|
68
69
|
constructor(options: CliReplOptions);
|
|
69
70
|
getLogPath(): string | undefined;
|
package/lib/cli-repl.js
CHANGED
|
@@ -35,7 +35,6 @@ const format_output_1 = require("./format-output");
|
|
|
35
35
|
const CONNECTING = 'cli-repl.cli-repl.connecting';
|
|
36
36
|
class CliRepl {
|
|
37
37
|
constructor(options) {
|
|
38
|
-
var _a, _b, _c, _d;
|
|
39
38
|
this.globalConfig = null;
|
|
40
39
|
this.toggleableAnalytics = new logging_2.ToggleableAnalytics();
|
|
41
40
|
this.warnedAboutInaccessibleFiles = false;
|
|
@@ -46,12 +45,13 @@ class CliRepl {
|
|
|
46
45
|
};
|
|
47
46
|
this.fetchMongoshUpdateUrlRegardlessOfCiEnvironment = false;
|
|
48
47
|
this.cachedGlibcVersion = null;
|
|
48
|
+
this.exitingForStartupError = false;
|
|
49
49
|
this.getGlibcVersion = build_info_1.getGlibcVersion;
|
|
50
50
|
this.bus = new events_1.EventEmitter();
|
|
51
51
|
this.cliOptions = options.shellCliOptions;
|
|
52
52
|
this.input = options.input;
|
|
53
53
|
this.output = options.output;
|
|
54
|
-
this.promptOutput =
|
|
54
|
+
this.promptOutput = options.promptOutput ?? options.output;
|
|
55
55
|
this.analyticsOptions = options.analyticsOptions;
|
|
56
56
|
this.onExit = options.onExit;
|
|
57
57
|
const id = new bson_1.ObjectId().toHexString();
|
|
@@ -61,7 +61,7 @@ class CliRepl {
|
|
|
61
61
|
enableTelemetry: true,
|
|
62
62
|
};
|
|
63
63
|
this.getCryptLibraryPaths = options.getCryptLibraryPaths;
|
|
64
|
-
this.globalConfigPaths =
|
|
64
|
+
this.globalConfigPaths = options.globalConfigPaths ?? [];
|
|
65
65
|
this.shellHomeDirectory = new config_directory_1.ShellHomeDirectory(options.shellHomePaths);
|
|
66
66
|
this.configDirectory = new config_directory_1.ConfigManager(this.shellHomeDirectory)
|
|
67
67
|
.on('error', (err) => {
|
|
@@ -95,11 +95,11 @@ class CliRepl {
|
|
|
95
95
|
if (jsContext === 'auto' || !jsContext) {
|
|
96
96
|
jsContext = willEnterInteractiveMode ? 'repl' : 'plain-vm';
|
|
97
97
|
}
|
|
98
|
-
const deepInspect =
|
|
98
|
+
const deepInspect = this.cliOptions.deepInspect ?? willEnterInteractiveMode;
|
|
99
99
|
this.mongoshRepl = new mongosh_repl_1.default({
|
|
100
100
|
...options,
|
|
101
101
|
shellCliOptions: { ...this.cliOptions, jsContext, quiet, deepInspect },
|
|
102
|
-
nodeReplOptions:
|
|
102
|
+
nodeReplOptions: options.nodeReplOptions ?? {
|
|
103
103
|
terminal: process.env.MONGOSH_FORCE_TERMINAL ? true : undefined,
|
|
104
104
|
},
|
|
105
105
|
bus: this.bus,
|
|
@@ -108,37 +108,34 @@ class CliRepl {
|
|
|
108
108
|
this.setupOIDCTokenDumpListener();
|
|
109
109
|
}
|
|
110
110
|
getLogPath() {
|
|
111
|
-
|
|
112
|
-
return (_b = (_a = this.logWriter) === null || _a === void 0 ? void 0 : _a.logFilePath) !== null && _b !== void 0 ? _b : undefined;
|
|
111
|
+
return this.logWriter?.logFilePath ?? undefined;
|
|
113
112
|
}
|
|
114
113
|
async getIsContainerizedEnvironment() {
|
|
115
114
|
try {
|
|
116
115
|
await fs_1.promises.stat('/.dockerenv');
|
|
117
116
|
return true;
|
|
118
117
|
}
|
|
119
|
-
catch
|
|
118
|
+
catch {
|
|
120
119
|
try {
|
|
121
120
|
const cgroup = await fs_1.promises.readFile('/proc/self/cgroup', 'utf8');
|
|
122
121
|
return /\b(docker|lxc|kubepods)\b/.test(cgroup);
|
|
123
122
|
}
|
|
124
|
-
catch
|
|
123
|
+
catch {
|
|
125
124
|
return false;
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
get forceDisableTelemetry() {
|
|
130
|
-
|
|
131
|
-
return (((_a = this.globalConfig) === null || _a === void 0 ? void 0 : _a.forceDisableTelemetry) ||
|
|
129
|
+
return (this.globalConfig?.forceDisableTelemetry ||
|
|
132
130
|
(this.isContainerizedEnvironment && !this.mongoshRepl.isInteractive) ||
|
|
133
131
|
!!process.env.MONGOSH_FORCE_DISABLE_TELEMETRY_FOR_TESTING);
|
|
134
132
|
}
|
|
135
133
|
async startLogging() {
|
|
136
|
-
var _a, _b;
|
|
137
134
|
if (!this.loggingAndTelemetry) {
|
|
138
135
|
throw new Error('Logging and telemetry not setup');
|
|
139
136
|
}
|
|
140
137
|
const customLogLocation = await this.getConfig('logLocation');
|
|
141
|
-
|
|
138
|
+
this.logManager ??= new mongodb_log_writer_1.MongoLogManager({
|
|
142
139
|
directory: customLogLocation || this.shellHomeDirectory.localPath('.'),
|
|
143
140
|
prefix: customLogLocation ? 'mongosh_' : undefined,
|
|
144
141
|
retentionDays: await this.getConfig('logRetentionDays'),
|
|
@@ -147,7 +144,7 @@ class CliRepl {
|
|
|
147
144
|
retentionGB: await this.getConfig('logRetentionGB'),
|
|
148
145
|
onerror: (err) => this.bus.emit('mongosh:error', err, 'log'),
|
|
149
146
|
onwarn: (err, path) => this.warnAboutInaccessibleFile(err, path),
|
|
150
|
-
})
|
|
147
|
+
});
|
|
151
148
|
void this.logManager
|
|
152
149
|
.cleanupOldLogFiles()
|
|
153
150
|
.catch((err) => {
|
|
@@ -157,7 +154,7 @@ class CliRepl {
|
|
|
157
154
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.Logging, 'cleaned up log files');
|
|
158
155
|
});
|
|
159
156
|
if (!this.logWriter) {
|
|
160
|
-
|
|
157
|
+
this.logWriter ??= await this.logManager.createLogWriter();
|
|
161
158
|
const { quiet } = CliRepl.getFileAndEvalInfo(this.cliOptions);
|
|
162
159
|
if (!quiet) {
|
|
163
160
|
this.output.write(`Current Mongosh Log ID:\t${this.logWriter.logId}\n`);
|
|
@@ -165,7 +162,7 @@ class CliRepl {
|
|
|
165
162
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.Logging, 'instantiated log writer');
|
|
166
163
|
}
|
|
167
164
|
this.loggingAndTelemetry.attachLogger(this.logWriter);
|
|
168
|
-
this.logWriter.info('MONGOSH', (0, mongodb_log_writer_1.mongoLogId)(
|
|
165
|
+
this.logWriter.info('MONGOSH', (0, mongodb_log_writer_1.mongoLogId)(1_000_000_000), 'log', 'Starting log', {
|
|
169
166
|
execPath: process.execPath,
|
|
170
167
|
envInfo: (0, mongodb_redact_1.redact)(this.getLoggedEnvironmentVariables()),
|
|
171
168
|
...(await (0, build_info_1.buildInfo)()),
|
|
@@ -177,12 +174,12 @@ class CliRepl {
|
|
|
177
174
|
return await this._start(driverUri, driverOptions);
|
|
178
175
|
}
|
|
179
176
|
catch (err) {
|
|
177
|
+
this.exitingForStartupError = true;
|
|
180
178
|
await this.close();
|
|
181
179
|
throw err;
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
182
|
async _start(driverUri, driverOptions) {
|
|
185
|
-
var _a, _b, _c, _d;
|
|
186
183
|
const { version } = require('../package.json');
|
|
187
184
|
await this.verifyNodeVersion();
|
|
188
185
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.REPLInstantiation, 'verified node version');
|
|
@@ -246,7 +243,7 @@ class CliRepl {
|
|
|
246
243
|
await this.setLoggingEnabled(!(await this.getConfig('disableLogging')));
|
|
247
244
|
void this.fetchMongoshUpdateUrl();
|
|
248
245
|
if (driverOptions.autoEncryption) {
|
|
249
|
-
const origExtraOptions =
|
|
246
|
+
const origExtraOptions = driverOptions.autoEncryption.extraOptions ?? {};
|
|
250
247
|
if (origExtraOptions.cryptSharedLibPath) {
|
|
251
248
|
this.cachedCryptLibraryPath = Promise.resolve({
|
|
252
249
|
cryptSharedLibPath: origExtraOptions.cryptSharedLibPath,
|
|
@@ -261,7 +258,7 @@ class CliRepl {
|
|
|
261
258
|
extraOptions,
|
|
262
259
|
};
|
|
263
260
|
}
|
|
264
|
-
if (Object.keys(
|
|
261
|
+
if (Object.keys(driverOptions.autoEncryption ?? {}).join(',') ===
|
|
265
262
|
'extraOptions') {
|
|
266
263
|
delete driverOptions.autoEncryption;
|
|
267
264
|
}
|
|
@@ -273,8 +270,8 @@ class CliRepl {
|
|
|
273
270
|
}
|
|
274
271
|
catch (err) {
|
|
275
272
|
if (typeof err === 'object' &&
|
|
276
|
-
|
|
277
|
-
!
|
|
273
|
+
err?.constructor.name === 'MongoDBOIDCError' &&
|
|
274
|
+
!String(driverOptions.oidc?.allowedFlows)?.includes('device-auth')) {
|
|
278
275
|
err.message +=
|
|
279
276
|
'\nConsider specifying --oidcFlows=auth-code,device-auth if you are running mongosh in an environment without browser access.';
|
|
280
277
|
}
|
|
@@ -337,7 +334,7 @@ class CliRepl {
|
|
|
337
334
|
}
|
|
338
335
|
if (!this.cliOptions.norc) {
|
|
339
336
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.SnippetLoading, 'start load snippets');
|
|
340
|
-
await
|
|
337
|
+
await snippetManager?.loadAllSnippets();
|
|
341
338
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.SnippetLoading, 'done load snippets');
|
|
342
339
|
}
|
|
343
340
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.ResourceFileLoading, 'loading rc files');
|
|
@@ -355,12 +352,11 @@ class CliRepl {
|
|
|
355
352
|
});
|
|
356
353
|
}
|
|
357
354
|
static getFileAndEvalInfo(cliOptions) {
|
|
358
|
-
|
|
359
|
-
const
|
|
360
|
-
const evalScripts = (_b = cliOptions.eval) !== null && _b !== void 0 ? _b : [];
|
|
355
|
+
const commandLineLoadFiles = cliOptions.fileNames ?? [];
|
|
356
|
+
const evalScripts = cliOptions.eval ?? [];
|
|
361
357
|
const willExecuteCommandLineScripts = commandLineLoadFiles.length > 0 || evalScripts.length > 0;
|
|
362
358
|
const willEnterInteractiveMode = !willExecuteCommandLineScripts || !!cliOptions.shell;
|
|
363
|
-
const quiet =
|
|
359
|
+
const quiet = cliOptions.quiet ?? !(cliOptions.verbose ?? willEnterInteractiveMode);
|
|
364
360
|
return {
|
|
365
361
|
commandLineLoadFiles,
|
|
366
362
|
evalScripts,
|
|
@@ -385,12 +381,12 @@ class CliRepl {
|
|
|
385
381
|
}
|
|
386
382
|
}
|
|
387
383
|
async setupAnalytics() {
|
|
388
|
-
var _a, _b, _c;
|
|
389
384
|
if (process.env.IS_MONGOSH_EVERGREEN_CI &&
|
|
390
|
-
!
|
|
385
|
+
!this.analyticsOptions?.alwaysEnable) {
|
|
391
386
|
throw new Error('no analytics setup for the mongosh CI environment');
|
|
392
387
|
}
|
|
393
|
-
const apiKey =
|
|
388
|
+
const apiKey = this.analyticsOptions?.apiKey ??
|
|
389
|
+
(await (0, build_info_1.buildInfo)({ withSegmentApiKey: true })).segmentApiKey;
|
|
394
390
|
if (!apiKey) {
|
|
395
391
|
throw new Error('no analytics API key defined');
|
|
396
392
|
}
|
|
@@ -413,12 +409,11 @@ class CliRepl {
|
|
|
413
409
|
}));
|
|
414
410
|
}
|
|
415
411
|
async setLoggingEnabled(enabled) {
|
|
416
|
-
var _a;
|
|
417
412
|
if (enabled) {
|
|
418
413
|
await this.startLogging();
|
|
419
414
|
}
|
|
420
415
|
else {
|
|
421
|
-
await
|
|
416
|
+
await this.loggingAndTelemetry?.detachLogger();
|
|
422
417
|
}
|
|
423
418
|
}
|
|
424
419
|
setTelemetryEnabled(enabled) {
|
|
@@ -494,7 +489,7 @@ class CliRepl {
|
|
|
494
489
|
await fs_1.promises.stat(mongoshrcPath);
|
|
495
490
|
hasMongoshRc = true;
|
|
496
491
|
}
|
|
497
|
-
catch
|
|
492
|
+
catch {
|
|
498
493
|
}
|
|
499
494
|
if (hasMongoshRc) {
|
|
500
495
|
try {
|
|
@@ -515,7 +510,7 @@ class CliRepl {
|
|
|
515
510
|
await fs_1.promises.stat(legacyPath);
|
|
516
511
|
hasLegacyRc = true;
|
|
517
512
|
}
|
|
518
|
-
catch
|
|
513
|
+
catch {
|
|
519
514
|
}
|
|
520
515
|
if (hasLegacyRc) {
|
|
521
516
|
this.bus.emit('mongosh:mongoshrc-mongorc-warn');
|
|
@@ -529,7 +524,7 @@ class CliRepl {
|
|
|
529
524
|
await fs_1.promises.stat(mongoshrcMisspelledPath);
|
|
530
525
|
hasMisspelledFilename = true;
|
|
531
526
|
}
|
|
532
|
-
catch
|
|
527
|
+
catch {
|
|
533
528
|
}
|
|
534
529
|
if (hasMisspelledFilename) {
|
|
535
530
|
const msg = 'Warning: Found ~/.mongoshrc, but not ~/.mongoshrc.js. Did you forget to add .js?\n';
|
|
@@ -537,7 +532,6 @@ class CliRepl {
|
|
|
537
532
|
}
|
|
538
533
|
}
|
|
539
534
|
async loadGlobalConfigFile() {
|
|
540
|
-
var _a, _b;
|
|
541
535
|
let fileContents = '';
|
|
542
536
|
let filename = '';
|
|
543
537
|
for (filename of this.globalConfigPaths) {
|
|
@@ -546,7 +540,7 @@ class CliRepl {
|
|
|
546
540
|
break;
|
|
547
541
|
}
|
|
548
542
|
catch (err) {
|
|
549
|
-
if (
|
|
543
|
+
if (err?.code !== 'ENOENT') {
|
|
550
544
|
this.bus.emit('mongosh:error', err, 'config');
|
|
551
545
|
}
|
|
552
546
|
}
|
|
@@ -561,7 +555,7 @@ class CliRepl {
|
|
|
561
555
|
config = bson_1.EJSON.parse(fileContents);
|
|
562
556
|
}
|
|
563
557
|
else {
|
|
564
|
-
config =
|
|
558
|
+
config = js_yaml_1.default.load(fileContents)?.mongosh ?? {};
|
|
565
559
|
}
|
|
566
560
|
for (const [key, value] of Object.entries(config)) {
|
|
567
561
|
const validationResult = await types_1.CliUserConfigValidator.validate(key, value);
|
|
@@ -575,7 +569,7 @@ class CliRepl {
|
|
|
575
569
|
}
|
|
576
570
|
catch (err) {
|
|
577
571
|
this.bus.emit('mongosh:error', err, 'config');
|
|
578
|
-
const msg = `Warning: Could not parse global configuration file at ${filename}: ${err
|
|
572
|
+
const msg = `Warning: Could not parse global configuration file at ${filename}: ${err?.message}\n`;
|
|
579
573
|
this.output.write(this.clr(msg, 'mongosh:warning'));
|
|
580
574
|
return {};
|
|
581
575
|
}
|
|
@@ -603,8 +597,9 @@ class CliRepl {
|
|
|
603
597
|
return this.shellHomeDirectory.roamingPath('mongosh_repl_history');
|
|
604
598
|
}
|
|
605
599
|
async getConfig(key) {
|
|
606
|
-
|
|
607
|
-
|
|
600
|
+
return (this.config[key] ??
|
|
601
|
+
this.globalConfig?.[key] ??
|
|
602
|
+
new types_1.CliUserConfig()[key]);
|
|
608
603
|
}
|
|
609
604
|
async setConfig(key, value) {
|
|
610
605
|
if (key === 'forceDisableTelemetry') {
|
|
@@ -662,7 +657,7 @@ class CliRepl {
|
|
|
662
657
|
const warnings = [];
|
|
663
658
|
const RECOMMENDED_GLIBC = '>=2.28.0';
|
|
664
659
|
const RECOMMENDED_OPENSSL = '>=3.0.0';
|
|
665
|
-
const RECOMMENDED_NODEJS = '>=
|
|
660
|
+
const RECOMMENDED_NODEJS = '>=24.0.0';
|
|
666
661
|
const semverRangeCheck = (semverLikeVersion, range) => {
|
|
667
662
|
const semverVersion = semver_1.default.valid(semver_1.default.coerce(semverLikeVersion));
|
|
668
663
|
if (!semverVersion) {
|
|
@@ -680,7 +675,7 @@ class CliRepl {
|
|
|
680
675
|
warnings.push(' - Using mongosh with OpenSSL versions lower than 3.0.0 is deprecated, and support may be removed in a future release.');
|
|
681
676
|
}
|
|
682
677
|
if (!semver_1.default.satisfies(process.version, RECOMMENDED_NODEJS)) {
|
|
683
|
-
warnings.push(' - Using mongosh with Node.js versions lower than
|
|
678
|
+
warnings.push(' - Using mongosh with Node.js versions lower than 24.0.0 is deprecated, and support may be removed in a future release.');
|
|
684
679
|
}
|
|
685
680
|
if (warnings.length) {
|
|
686
681
|
const deprecationWarning = [
|
|
@@ -692,10 +687,9 @@ class CliRepl {
|
|
|
692
687
|
}
|
|
693
688
|
}
|
|
694
689
|
isPasswordMissingURI(cs) {
|
|
695
|
-
var _a;
|
|
696
690
|
return !!(cs.username &&
|
|
697
691
|
!cs.password &&
|
|
698
|
-
['', 'MONGODB-CR', 'PLAIN', 'SCRAM-SHA-1', 'SCRAM-SHA-256'].includes(
|
|
692
|
+
['', 'MONGODB-CR', 'PLAIN', 'SCRAM-SHA-1', 'SCRAM-SHA-256'].includes(cs.searchParams.get('authMechanism') ?? ''));
|
|
699
693
|
}
|
|
700
694
|
async isTlsKeyFilePasswordMissingURI(searchParams) {
|
|
701
695
|
const tlsCertificateKeyFile = searchParams.get('tlsCertificateKeyFile');
|
|
@@ -739,17 +733,16 @@ class CliRepl {
|
|
|
739
733
|
return this.exit(1);
|
|
740
734
|
}
|
|
741
735
|
async close() {
|
|
742
|
-
|
|
743
|
-
return ((_a = this.closingPromise) !== null && _a !== void 0 ? _a : (this.closingPromise = (async () => {
|
|
744
|
-
var _a, _b, _c, _d;
|
|
736
|
+
return (this.closingPromise ??= (async () => {
|
|
745
737
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.REPLInstantiation, 'start closing');
|
|
746
|
-
|
|
738
|
+
await this.mongoshRepl.close();
|
|
739
|
+
this.agent?.destroy();
|
|
747
740
|
if (!this.output.destroyed) {
|
|
748
741
|
if (this.output.writableEnded) {
|
|
749
742
|
try {
|
|
750
743
|
await (0, events_1.once)(this.output, 'close');
|
|
751
744
|
}
|
|
752
|
-
catch
|
|
745
|
+
catch {
|
|
753
746
|
}
|
|
754
747
|
}
|
|
755
748
|
else {
|
|
@@ -760,7 +753,7 @@ class CliRepl {
|
|
|
760
753
|
const analytics = this.toggleableAnalytics;
|
|
761
754
|
let flushError = null;
|
|
762
755
|
let flushDuration = null;
|
|
763
|
-
await
|
|
756
|
+
await this.loggingAndTelemetry?.flush();
|
|
764
757
|
if (analytics) {
|
|
765
758
|
const flushStart = Date.now();
|
|
766
759
|
try {
|
|
@@ -774,17 +767,19 @@ class CliRepl {
|
|
|
774
767
|
flushDuration = Date.now() - flushStart;
|
|
775
768
|
}
|
|
776
769
|
}
|
|
777
|
-
|
|
770
|
+
this.logWriter?.info('MONGOSH', (0, mongodb_log_writer_1.mongoLogId)(1_000_000_045), 'analytics', 'Flushed outstanding data', {
|
|
778
771
|
flushError,
|
|
779
772
|
flushDuration,
|
|
780
773
|
});
|
|
781
|
-
await
|
|
774
|
+
await this.logWriter?.flush();
|
|
782
775
|
(0, startup_timing_1.markTime)(types_1.TimingCategories.Logging, 'flushed log writer');
|
|
783
776
|
this.bus.emit('mongosh:closed');
|
|
784
|
-
})())
|
|
777
|
+
})());
|
|
785
778
|
}
|
|
786
779
|
async exit(code) {
|
|
787
780
|
await this.close();
|
|
781
|
+
if (this.exitingForStartupError)
|
|
782
|
+
return new Promise(() => undefined);
|
|
788
783
|
await this.onExit(code);
|
|
789
784
|
const error = new errors_1.MongoshInternalError('onExit() unexpectedly returned');
|
|
790
785
|
this.bus.emit('mongosh:error', error, 'fatal');
|
|
@@ -801,52 +796,49 @@ class CliRepl {
|
|
|
801
796
|
return this.mongoshRepl.clr(text, style);
|
|
802
797
|
}
|
|
803
798
|
async getCryptLibraryOptions() {
|
|
804
|
-
var _a;
|
|
805
799
|
if (!this.getCryptLibraryPaths) {
|
|
806
800
|
throw new errors_1.MongoshInternalError('This instance of mongosh is not configured for in-use encryption');
|
|
807
801
|
}
|
|
808
|
-
return (
|
|
802
|
+
return (this.cachedCryptLibraryPath ??= this.getCryptLibraryPaths(this.bus));
|
|
809
803
|
}
|
|
810
804
|
bugReportErrorMessageInfo() {
|
|
811
|
-
|
|
812
|
-
return `Please include the log file for this session (${(_a = this.logWriter) === null || _a === void 0 ? void 0 : _a.logFilePath}).`;
|
|
805
|
+
return `Please include the log file for this session (${this.logWriter?.logFilePath}).`;
|
|
813
806
|
}
|
|
814
807
|
getLoggedEnvironmentVariables() {
|
|
815
808
|
const { EDITOR, NODE_OPTIONS, TERM } = process.env;
|
|
816
809
|
return { EDITOR, NODE_OPTIONS, TERM };
|
|
817
810
|
}
|
|
818
811
|
async prepareOIDCOptions(driverUri, driverOptionsIn) {
|
|
819
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
820
|
-
var _j, _k, _l, _m, _o;
|
|
821
812
|
const driverOptions = {
|
|
822
813
|
oidc: {},
|
|
823
814
|
authMechanismProperties: {},
|
|
824
815
|
...driverOptionsIn,
|
|
825
816
|
};
|
|
826
|
-
|
|
827
|
-
|
|
817
|
+
driverOptions.oidc.allowedFlows ??= ['auth-code'];
|
|
818
|
+
driverOptions.oidc.notifyDeviceFlow ??= ({ verificationUrl, userCode }) => {
|
|
828
819
|
this.output.write('\n' +
|
|
829
820
|
`Visit the following URL to complete authentication: ${this.clr(verificationUrl, 'mongosh:uri')}\n` +
|
|
830
821
|
`Enter the following code on that page: ${this.clr(userCode, 'mongosh:uri')}\nWaiting...\n`);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
|
|
822
|
+
};
|
|
823
|
+
driverOptions.proxy ??= this.proxyOptions;
|
|
824
|
+
driverOptions.applyProxyToOIDC ??= true;
|
|
834
825
|
const [redirectURI, trustedEndpoints, browser] = await Promise.all([
|
|
835
826
|
this.getConfig('oidcRedirectURI'),
|
|
836
827
|
this.getConfig('oidcTrustedEndpoints'),
|
|
837
828
|
this.getConfig('browser'),
|
|
838
829
|
]);
|
|
839
830
|
if (redirectURI !== undefined) {
|
|
840
|
-
|
|
831
|
+
driverOptions.oidc.redirectURI ??= redirectURI;
|
|
841
832
|
}
|
|
842
833
|
if (browser !== undefined) {
|
|
843
|
-
|
|
834
|
+
driverOptions.oidc.openBrowser ??=
|
|
835
|
+
browser !== false ? { command: browser } : browser;
|
|
844
836
|
}
|
|
845
837
|
if (trustedEndpoints !== undefined) {
|
|
846
|
-
|
|
838
|
+
driverOptions.authMechanismProperties.ALLOWED_HOSTS ??= trustedEndpoints;
|
|
847
839
|
}
|
|
848
840
|
if (process.env.MONGOSH_OIDC_PARENT_HANDLE) {
|
|
849
|
-
|
|
841
|
+
driverOptions.parentHandle ??= process.env.MONGOSH_OIDC_PARENT_HANDLE;
|
|
850
842
|
}
|
|
851
843
|
return driverOptions;
|
|
852
844
|
}
|
|
@@ -900,7 +892,7 @@ class CliRepl {
|
|
|
900
892
|
try {
|
|
901
893
|
return JSON.parse(Buffer.from(part, 'base64url').toString('utf8'));
|
|
902
894
|
}
|
|
903
|
-
catch
|
|
895
|
+
catch {
|
|
904
896
|
}
|
|
905
897
|
});
|
|
906
898
|
if (redact === 'include-secrets') {
|
|
@@ -921,9 +913,9 @@ class CliRepl {
|
|
|
921
913
|
this.bus.on('mongodb-oidc-plugin:auth-succeeded', ({ tokenType, refreshToken, expiresAt, passIdTokenAsAccessToken, tokens: { accessToken: at, refreshToken: rt, idToken: idt }, }) => {
|
|
922
914
|
const printable = {
|
|
923
915
|
lastServerIdPInfo: lastServerIdPInfo && {
|
|
924
|
-
issuer: lastServerIdPInfo
|
|
925
|
-
clientId: lastServerIdPInfo
|
|
926
|
-
requestScopes: lastServerIdPInfo
|
|
916
|
+
issuer: lastServerIdPInfo?.issuer,
|
|
917
|
+
clientId: lastServerIdPInfo?.clientId,
|
|
918
|
+
requestScopes: lastServerIdPInfo?.requestScopes,
|
|
927
919
|
},
|
|
928
920
|
tokenType,
|
|
929
921
|
refreshToken,
|