@@ -8,6 +8,7 @@ import net from "net";
88// Expected arguments: first arg is project ID (5dbf805650b51914727e06c4) or URL (http://localhost:8080/app/lexicon/5dbf805650b51914727e06c4)
99// Second arg is "qa" or "staging" to copy from staging, "live" or "prod" or "production" to copy from production
1010// NOTE: You must edit the context names below if they don't match the context names you have (see `kubectl config get-contexts` output)
11+ // A MONGO_PASS env var must be available for the selected environment
1112
1213// ===== EDIT THIS =====
1314
@@ -112,12 +113,18 @@ if (process.argv.length < 3) {
112113 process . exit ( 2 ) ;
113114}
114115
116+ const mongoPass = process . env . MONGO_PASS ;
117+ if ( ! mongoPass ) {
118+ console . warn ( "Please provide a MongoDB password in the MONGO_PASS environment variable" ) ;
119+ process . exit ( 2 ) ;
120+ }
121+
115122let projId ;
116123const arg = process . argv [ 2 ] ;
117124if ( URL . canParse ( arg ) ) {
118125 const url = new URL ( arg ) ;
119126 if ( url . pathname . startsWith ( "/app/lexicon/" ) ) {
120- projId = url . pathname . substring ( "/app/lexicon/" . length ) ;
127+ projId = url . pathname . substring ( "/app/lexicon/" . length ) . split ( "/" ) [ 0 ] ;
121128 } else {
122129 projId = url . pathname ; // Will probably fail, but worth a try
123130 }
@@ -209,7 +216,7 @@ console.warn("If that doesn't look right, hit Ctrl+C NOW");
209216await portForwardingPromise ;
210217console . warn ( "Port forwarding is ready. Setting up remote Mongo connection..." ) ;
211218
212- const remoteConnStr = `mongodb://localhost:${ remoteMongoPort } ` ;
219+ const remoteConnStr = `mongodb://admin: ${ mongoPass } @ localhost:${ remoteMongoPort } ` ;
213220remoteConn = await MongoClient . connect ( remoteConnStr ) ;
214221
215222console . warn ( "Remote Mongo connection established. Fetching project record..." ) ;
0 commit comments