File tree Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change 1
1
import path from "path" ;
2
2
import os from "os" ;
3
3
import argv from "yargs-parser" ;
4
- import type { CliOptions } from "@mongosh/arg-parser" ;
5
- import type { ConnectionInfo } from "@mongosh/arg-parser" ;
4
+ import type { CliOptions , ConnectionInfo } from "@mongosh/arg-parser" ;
5
+ import { generateConnectionInfoFromCliArgs } from "@mongosh/arg-parser" ;
6
6
7
7
// From: https://github.com/mongodb-js/mongosh/blob/main/packages/cli-repl/src/arg-parser.ts
8
8
const OPTIONS = {
@@ -286,21 +286,9 @@ export function setupUserConfig({
286
286
userConfig . loggers = commaSeparatedToArray ( userConfig . loggers ) ;
287
287
288
288
if ( userConfig . connectionString && userConfig . connectionSpecifier ) {
289
- delete userConfig . connectionString ;
289
+ const connectionInfo = generateConnectionInfoFromCliArgs ( userConfig ) ;
290
+ userConfig . connectionString = connectionInfo . connectionString ;
290
291
}
291
292
292
293
return userConfig ;
293
294
}
294
-
295
- /**
296
- readConcern: {
297
- level: settings.readConcern,
298
- },
299
- readPreference: settings.readPreference,
300
- writeConcern: {
301
- w: settings.writeConcern,
302
- },
303
- timeoutMS: settings.timeoutMS,
304
- proxy: { useEnvironmentVariableProxies: true },
305
- applyProxyToOIDC: true,
306
- **/
Original file line number Diff line number Diff line change 1
1
export { Server , type ServerOptions } from "./server.js" ;
2
2
export { Telemetry } from "./telemetry/telemetry.js" ;
3
3
export { Session , type SessionOptions } from "./common/session.js" ;
4
- export type { UserConfig , ConnectOptions } from "./common/config.js" ;
4
+ export type { UserConfig } from "./common/config.js" ;
Original file line number Diff line number Diff line change @@ -404,7 +404,10 @@ describe("config", () => {
404
404
defaults : { } ,
405
405
} ) ;
406
406
407
- expect ( actual . connectionString ) . toBe ( undefined ) ;
407
+ // the shell specifies directConnection=true and serverSelectionTimeoutMS=2000 by default
408
+ expect ( actual . connectionString ) . toBe (
409
+ "mongodb://localhost/?directConnection=true&serverSelectionTimeoutMS=2000"
410
+ ) ;
408
411
expect ( actual . connectionSpecifier ) . toBe ( "mongodb://localhost" ) ;
409
412
} ) ;
410
413
} ) ;
You can’t perform that action at this time.
0 commit comments