genbox 1.0.31 → 1.0.32

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.
@@ -621,10 +621,12 @@ exports.initCommand = new commander_1.Command('init')
621
621
  // Environment configuration - do this BEFORE profiles so profiles can reference environments
622
622
  // (skip only in non-interactive mode, always show for --from-scan since environments are required)
623
623
  if (!nonInteractive) {
624
- const envConfig = await setupEnvironments(scan, v4Config, isMultiRepoStructure, existingEnvValues);
625
- if (envConfig) {
626
- v4Config.environments = envConfig;
624
+ const envResult = await setupEnvironments(scan, v4Config, isMultiRepoStructure, existingEnvValues);
625
+ if (envResult.environments) {
626
+ v4Config.environments = envResult.environments;
627
627
  }
628
+ // Add collected database URLs to envVarsToAdd (for .env.genbox)
629
+ Object.assign(envVarsToAdd, envResult.databaseUrls);
628
630
  }
629
631
  // Ask about profiles (skip prompt when using --from-scan)
630
632
  let createProfiles = true;
@@ -1170,6 +1172,7 @@ async function setupGitAuth(gitInfo, projectName) {
1170
1172
  * Setup staging/production environments (v4 format)
1171
1173
  */
1172
1174
  async function setupEnvironments(scan, config, isMultiRepo = false, existingEnvValues = {}) {
1175
+ const databaseUrls = {};
1173
1176
  // First ask which environments they want to configure
1174
1177
  const envChoice = await prompts.select({
1175
1178
  message: 'Which environments do you want to configure?',
@@ -1182,16 +1185,18 @@ async function setupEnvironments(scan, config, isMultiRepo = false, existingEnvV
1182
1185
  default: 'staging',
1183
1186
  });
1184
1187
  if (envChoice === 'skip') {
1185
- return undefined;
1188
+ return { environments: undefined, databaseUrls };
1186
1189
  }
1187
1190
  console.log('');
1188
1191
  console.log(chalk_1.default.blue('=== Environment Setup ==='));
1189
1192
  console.log(chalk_1.default.dim('These URLs will be used when connecting to external services.'));
1190
- console.log(chalk_1.default.dim('Actual secrets go in .env.genbox'));
1193
+ console.log(chalk_1.default.dim('Database URLs are stored in .env.genbox for database copy operations.'));
1191
1194
  const environments = {};
1192
1195
  // Get existing URLs if available
1193
1196
  const existingStagingApiUrl = existingEnvValues['STAGING_API_URL'];
1194
1197
  const existingProductionApiUrl = existingEnvValues['PRODUCTION_API_URL'] || existingEnvValues['PROD_API_URL'];
1198
+ const existingStagingMongoUrl = existingEnvValues['STAGING_MONGODB_URL'];
1199
+ const existingProdMongoUrl = existingEnvValues['PROD_MONGODB_URL'] || existingEnvValues['PRODUCTION_MONGODB_URL'];
1195
1200
  const configureStaging = envChoice === 'staging' || envChoice === 'both';
1196
1201
  const configureProduction = envChoice === 'production' || envChoice === 'both';
1197
1202
  // Configure staging if selected
@@ -1250,6 +1255,36 @@ async function setupEnvironments(scan, config, isMultiRepo = false, existingEnvV
1250
1255
  };
1251
1256
  }
1252
1257
  }
1258
+ // Prompt for staging database URL (for database copy operations)
1259
+ console.log('');
1260
+ console.log(chalk_1.default.dim(' Database URL (for "Copy from staging" database mode):'));
1261
+ console.log(chalk_1.default.dim(' Format: mongodb+srv://user:password@staging.mongodb.net/dbname'));
1262
+ if (existingStagingMongoUrl) {
1263
+ console.log(chalk_1.default.dim(` Found existing value: ${existingStagingMongoUrl.substring(0, 50)}...`));
1264
+ const useExisting = await prompts.confirm({
1265
+ message: ' Use existing staging MongoDB URL?',
1266
+ default: true,
1267
+ });
1268
+ if (useExisting) {
1269
+ databaseUrls['STAGING_MONGODB_URL'] = existingStagingMongoUrl;
1270
+ }
1271
+ else {
1272
+ const mongoUrl = await prompts.input({
1273
+ message: ' Staging MongoDB URL:',
1274
+ });
1275
+ if (mongoUrl) {
1276
+ databaseUrls['STAGING_MONGODB_URL'] = mongoUrl;
1277
+ }
1278
+ }
1279
+ }
1280
+ else {
1281
+ const mongoUrl = await prompts.input({
1282
+ message: ' Staging MongoDB URL (optional, press Enter to skip):',
1283
+ });
1284
+ if (mongoUrl) {
1285
+ databaseUrls['STAGING_MONGODB_URL'] = mongoUrl;
1286
+ }
1287
+ }
1253
1288
  }
1254
1289
  // Configure production if selected
1255
1290
  if (configureProduction) {
@@ -1320,8 +1355,41 @@ async function setupEnvironments(scan, config, isMultiRepo = false, existingEnvV
1320
1355
  };
1321
1356
  }
1322
1357
  }
1358
+ // Prompt for production database URL (for database copy operations)
1359
+ console.log('');
1360
+ console.log(chalk_1.default.dim(' Database URL (for "Copy from production" database mode):'));
1361
+ console.log(chalk_1.default.dim(' Format: mongodb+srv://readonly:password@prod.mongodb.net/dbname'));
1362
+ if (existingProdMongoUrl) {
1363
+ console.log(chalk_1.default.dim(` Found existing value: ${existingProdMongoUrl.substring(0, 50)}...`));
1364
+ const useExisting = await prompts.confirm({
1365
+ message: ' Use existing production MongoDB URL?',
1366
+ default: true,
1367
+ });
1368
+ if (useExisting) {
1369
+ databaseUrls['PROD_MONGODB_URL'] = existingProdMongoUrl;
1370
+ }
1371
+ else {
1372
+ const mongoUrl = await prompts.input({
1373
+ message: ' Production MongoDB URL:',
1374
+ });
1375
+ if (mongoUrl) {
1376
+ databaseUrls['PROD_MONGODB_URL'] = mongoUrl;
1377
+ }
1378
+ }
1379
+ }
1380
+ else {
1381
+ const mongoUrl = await prompts.input({
1382
+ message: ' Production MongoDB URL (optional, press Enter to skip):',
1383
+ });
1384
+ if (mongoUrl) {
1385
+ databaseUrls['PROD_MONGODB_URL'] = mongoUrl;
1386
+ }
1387
+ }
1323
1388
  }
1324
- return Object.keys(environments).length > 0 ? environments : undefined;
1389
+ return {
1390
+ environments: Object.keys(environments).length > 0 ? environments : undefined,
1391
+ databaseUrls,
1392
+ };
1325
1393
  }
1326
1394
  /**
1327
1395
  * Prompt for a single API URL with existing value support
@@ -1378,12 +1446,19 @@ async function setupEnvFile(projectName, config, nonInteractive = false, scan, i
1378
1446
  if (!extraEnvVars['GIT_TOKEN']) {
1379
1447
  segregatedContent += `# GIT_TOKEN=ghp_xxxxxxxxxxxx\n`;
1380
1448
  }
1381
- segregatedContent += `
1382
- # Database URLs (used by profiles with database mode)
1383
- # STAGING_MONGODB_URL=mongodb+srv://user:password@staging.mongodb.net
1384
- # PROD_MONGODB_URL=mongodb+srv://readonly:password@prod.mongodb.net
1385
-
1386
- `;
1449
+ // Add database URL section (only show templates for missing URLs)
1450
+ const hasStagingMongo = !!extraEnvVars['STAGING_MONGODB_URL'];
1451
+ const hasProdMongo = !!extraEnvVars['PROD_MONGODB_URL'];
1452
+ if (!hasStagingMongo || !hasProdMongo) {
1453
+ segregatedContent += `\n# Database URLs (used by profiles with database mode)\n`;
1454
+ if (!hasStagingMongo) {
1455
+ segregatedContent += `# STAGING_MONGODB_URL=mongodb+srv://user:password@staging.mongodb.net\n`;
1456
+ }
1457
+ if (!hasProdMongo) {
1458
+ segregatedContent += `# PROD_MONGODB_URL=mongodb+srv://readonly:password@prod.mongodb.net\n`;
1459
+ }
1460
+ }
1461
+ segregatedContent += '\n';
1387
1462
  // For multi-repo: find env files in app directories
1388
1463
  if (isMultiRepo && scan) {
1389
1464
  const appEnvFiles = findAppEnvFiles(scan.apps, process.cwd());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {