genbox 1.0.52 ā 1.0.53
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/dist/profile-resolver.js +26 -9
- package/package.json +1 -1
package/dist/profile-resolver.js
CHANGED
|
@@ -321,10 +321,19 @@ class ProfileResolver {
|
|
|
321
321
|
* Resolve database mode
|
|
322
322
|
*/
|
|
323
323
|
async resolveDatabaseMode(config, options, profile) {
|
|
324
|
-
//
|
|
324
|
+
// Load env vars from .env.genbox (where init stores MongoDB URLs)
|
|
325
|
+
const envVars = this.configLoader.loadEnvVars(process.cwd());
|
|
326
|
+
// Helper to get MongoDB URL from .env.genbox
|
|
327
|
+
// Matches what init saves: PROD_MONGODB_URL, STAGING_MONGODB_URL
|
|
325
328
|
const getMongoUrl = (source) => {
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
if (source === 'production') {
|
|
330
|
+
return envVars['PROD_MONGODB_URL'] || envVars['PRODUCTION_MONGODB_URL'];
|
|
331
|
+
}
|
|
332
|
+
else if (source === 'staging') {
|
|
333
|
+
return envVars['STAGING_MONGODB_URL'];
|
|
334
|
+
}
|
|
335
|
+
// Custom environments: {NAME}_MONGODB_URL
|
|
336
|
+
return envVars[`${source.toUpperCase()}_MONGODB_URL`];
|
|
328
337
|
};
|
|
329
338
|
// CLI flag takes precedence
|
|
330
339
|
if (options.db) {
|
|
@@ -374,6 +383,18 @@ class ProfileResolver {
|
|
|
374
383
|
*/
|
|
375
384
|
async selectDatabaseModeInteractive(config) {
|
|
376
385
|
console.log(chalk_1.default.cyan('\nšļø Database Configuration:\n'));
|
|
386
|
+
// Load env vars from .env.genbox (where init stores MongoDB URLs)
|
|
387
|
+
const envVars = this.configLoader.loadEnvVars(process.cwd());
|
|
388
|
+
// Helper to get MongoDB URL from .env.genbox
|
|
389
|
+
const getMongoUrl = (source) => {
|
|
390
|
+
if (source === 'production') {
|
|
391
|
+
return envVars['PROD_MONGODB_URL'] || envVars['PRODUCTION_MONGODB_URL'];
|
|
392
|
+
}
|
|
393
|
+
else if (source === 'staging') {
|
|
394
|
+
return envVars['STAGING_MONGODB_URL'];
|
|
395
|
+
}
|
|
396
|
+
return envVars[`${source.toUpperCase()}_MONGODB_URL`];
|
|
397
|
+
};
|
|
377
398
|
const modeChoices = [
|
|
378
399
|
{ name: 'None (no database)', value: 'none' },
|
|
379
400
|
{ name: 'Fresh (empty database)', value: 'local' },
|
|
@@ -405,18 +426,14 @@ class ProfileResolver {
|
|
|
405
426
|
}
|
|
406
427
|
else if (answer.startsWith('copy-')) {
|
|
407
428
|
const source = answer.replace('copy-', '');
|
|
408
|
-
|
|
409
|
-
const mongoUrl = envConfig?.urls?.mongodb;
|
|
410
|
-
return { mode: 'copy', source, url: mongoUrl };
|
|
429
|
+
return { mode: 'copy', source, url: getMongoUrl(source) };
|
|
411
430
|
}
|
|
412
431
|
else if (answer.startsWith('remote-')) {
|
|
413
432
|
const source = answer.replace('remote-', '');
|
|
414
|
-
const envConfig = config.environments?.[source];
|
|
415
|
-
const mongoUrl = envConfig?.urls?.mongodb;
|
|
416
433
|
return {
|
|
417
434
|
mode: 'remote',
|
|
418
435
|
source,
|
|
419
|
-
url:
|
|
436
|
+
url: getMongoUrl(source),
|
|
420
437
|
};
|
|
421
438
|
}
|
|
422
439
|
return { mode: 'local' };
|