44} from '@mongodb-js/connection-info' ;
55import type { MongoClusterOptions } from 'mongodb-runner' ;
66import yargs from 'yargs' ;
7- import type { Argv } from 'yargs' ;
7+ import type { Argv , CamelCase } from 'yargs' ;
88import { hideBin } from 'yargs/helpers' ;
99import Debug from 'debug' ;
1010import fs from 'fs' ;
@@ -106,15 +106,17 @@ function buildDesktopArgs(yargs: Argv) {
106106 * make sure that the tests in mms are also updated to account for that
107107 */
108108const atlasCloudExternalArgs = [
109- 'test-atlas-cloud-external' ,
110109 'atlas-cloud-external-url' ,
111110 'atlas-cloud-external-project-id' ,
112111 'atlas-cloud-external-cookies-file' ,
113112 'atlas-cloud-external-default-connections-file' ,
114113] as const ;
115114
115+ type AtlasCloudExternalArgs =
116+ | typeof atlasCloudExternalArgs [ number ]
117+ | CamelCase < typeof atlasCloudExternalArgs [ number ] > ;
118+
116119const atlasCloudSandboxArgs = [
117- 'test-atlas-cloud-sandbox' ,
118120 'atlas-cloud-sandbox-cloud-config' ,
119121 'atlas-cloud-sandbox-username' ,
120122 'atlas-cloud-sandbox-password' ,
@@ -123,6 +125,10 @@ const atlasCloudSandboxArgs = [
123125 'atlas-cloud-sandbox-default-connections' ,
124126] as const ;
125127
128+ type AtlasCloudSandboxArgs =
129+ | typeof atlasCloudSandboxArgs [ number ]
130+ | CamelCase < typeof atlasCloudSandboxArgs [ number ] > ;
131+
126132let testEnv : 'desktop' | 'web' | undefined ;
127133
128134function buildWebArgs ( yargs : Argv ) {
@@ -191,13 +197,9 @@ function buildWebArgs(yargs: Argv) {
191197 description :
192198 'Stringified JSON with connections that are expected to be available in the Atlas project' ,
193199 } )
194- . implies (
195- Object . fromEntries (
196- atlasCloudSandboxArgs . map ( ( arg ) => {
197- return [ arg , atlasCloudSandboxArgs ] ;
198- } )
199- )
200- )
200+ . implies ( {
201+ 'test-atlas-cloud-sandbox' : atlasCloudSandboxArgs ,
202+ } )
201203 . option ( 'test-atlas-cloud-external' , {
202204 type : 'boolean' ,
203205 description :
@@ -221,13 +223,9 @@ function buildWebArgs(yargs: Argv) {
221223 description :
222224 'File with JSON array of connections (following ConnectionInfo schema) that are expected to be available in the Atlas project' ,
223225 } )
224- . implies (
225- Object . fromEntries (
226- atlasCloudExternalArgs . map ( ( arg ) => {
227- return [ arg , atlasCloudExternalArgs ] ;
228- } )
229- )
230- )
226+ . implies ( {
227+ 'test-atlas-cloud-external' : atlasCloudExternalArgs ,
228+ } )
231229 . conflicts ( {
232230 'test-atlas-cloud-external' : 'test-atlas-cloud-sandbox' ,
233231 'test-atlas-cloud-sandbox' : 'test-atlas-cloud-external' ,
@@ -310,42 +308,23 @@ export function assertTestingWeb(ctx = context): asserts ctx is WebParsedArgs {
310308export function isTestingAtlasCloudExternal (
311309 ctx = context
312310) : ctx is WebParsedArgs & {
313- [ K in
314- | 'testAtlasCloudExternal'
315- | 'atlasCloudExternalUrl'
316- | 'atlasCloudExternalProjectId'
317- | 'atlasCloudExternalCookiesFile'
318- | 'atlasCloudExternalDefaultConnectionsFile' ] : NonNullable <
319- WebParsedArgs [ K ]
320- > ;
311+ [ K in AtlasCloudExternalArgs ] : NonNullable < WebParsedArgs [ K ] > ;
321312} {
322313 return isTestingWeb ( ctx ) && ! ! ctx . testAtlasCloudExternal ;
323314}
324315
325316export function isTestingAtlasCloudSandbox (
326317 ctx = context
327318) : ctx is WebParsedArgs & {
328- [ K in
329- | 'testAtlasCloudSandbox'
330- | 'atlasCloudSandboxUsername'
331- | 'atlasCloudSandboxPassword'
332- | 'atlasCloudSandboxDbuserUsername'
333- | 'atlasCloudSandboxDbuserPassword'
334- | 'atlasCloudSandboxDefaultConnections' ] : NonNullable < WebParsedArgs [ K ] > ;
319+ [ K in AtlasCloudSandboxArgs ] : NonNullable < WebParsedArgs [ K ] > ;
335320} {
336321 return isTestingWeb ( ctx ) && ! ! ctx . testAtlasCloudSandbox ;
337322}
338323
339324export function assertTestingAtlasCloudSandbox (
340325 ctx = context
341326) : asserts ctx is WebParsedArgs & {
342- [ K in
343- | 'testAtlasCloudSandbox'
344- | 'atlasCloudSandboxUsername'
345- | 'atlasCloudSandboxPassword'
346- | 'atlasCloudSandboxDbuserUsername'
347- | 'atlasCloudSandboxDbuserPassword'
348- | 'atlasCloudSandboxDefaultConnections' ] : NonNullable < WebParsedArgs [ K ] > ;
327+ [ K in AtlasCloudSandboxArgs ] : NonNullable < WebParsedArgs [ K ] > ;
349328} {
350329 if ( ! isTestingAtlasCloudSandbox ( ctx ) ) {
351330 throw new Error ( `Expected tested runtime to be web w/ Atlas Cloud account` ) ;
0 commit comments