@@ -8,6 +8,7 @@ import net from "net";
8
8
// Expected arguments: first arg is project ID (5dbf805650b51914727e06c4) or URL (http://localhost:8080/app/lexicon/5dbf805650b51914727e06c4)
9
9
// Second arg is "qa" or "staging" to copy from staging, "live" or "prod" or "production" to copy from production
10
10
// 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
11
12
12
13
// ===== EDIT THIS =====
13
14
@@ -112,12 +113,18 @@ if (process.argv.length < 3) {
112
113
process . exit ( 2 ) ;
113
114
}
114
115
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
+
115
122
let projId ;
116
123
const arg = process . argv [ 2 ] ;
117
124
if ( URL . canParse ( arg ) ) {
118
125
const url = new URL ( arg ) ;
119
126
if ( url . pathname . startsWith ( "/app/lexicon/" ) ) {
120
- projId = url . pathname . substring ( "/app/lexicon/" . length ) ;
127
+ projId = url . pathname . substring ( "/app/lexicon/" . length ) . split ( "/" ) [ 0 ] ;
121
128
} else {
122
129
projId = url . pathname ; // Will probably fail, but worth a try
123
130
}
@@ -209,7 +216,7 @@ console.warn("If that doesn't look right, hit Ctrl+C NOW");
209
216
await portForwardingPromise ;
210
217
console . warn ( "Port forwarding is ready. Setting up remote Mongo connection..." ) ;
211
218
212
- const remoteConnStr = `mongodb://localhost:${ remoteMongoPort } ` ;
219
+ const remoteConnStr = `mongodb://admin: ${ mongoPass } @ localhost:${ remoteMongoPort } ` ;
213
220
remoteConn = await MongoClient . connect ( remoteConnStr ) ;
214
221
215
222
console . warn ( "Remote Mongo connection established. Fetching project record..." ) ;
0 commit comments