genbox 1.0.108 → 1.0.109
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/commands/init.js +12 -1
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -1555,12 +1555,23 @@ function generateEnvFile(projectName, detected, envVars, serviceUrlMappings) {
|
|
|
1555
1555
|
content += `\n# Git authentication\n# GIT_TOKEN=ghp_xxxxxxxxxxxx\n`;
|
|
1556
1556
|
}
|
|
1557
1557
|
// Add app-specific sections from existing env files
|
|
1558
|
+
// Convert hardcoded localhost URLs to placeholders so they can be expanded based on profile
|
|
1558
1559
|
const appEnvFiles = findAppEnvFiles(detected.apps, detected._meta.scanned_root);
|
|
1559
1560
|
for (const envFile of appEnvFiles) {
|
|
1560
1561
|
try {
|
|
1561
|
-
|
|
1562
|
+
let fileContent = fs_1.default.readFileSync(envFile.fullPath, 'utf8').trim();
|
|
1562
1563
|
if (fileContent) {
|
|
1564
|
+
// Replace hardcoded localhost URLs with placeholders
|
|
1565
|
+
// This allows the URLs to be expanded to local/staging/production based on profile
|
|
1566
|
+
for (const mapping of serviceUrlMappings) {
|
|
1567
|
+
// Escape special regex characters in the URL
|
|
1568
|
+
const escapedUrl = mapping.localUrl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1569
|
+
// Match the URL with optional quotes around it
|
|
1570
|
+
const urlPattern = new RegExp(`(["']?)${escapedUrl}\\1`, 'g');
|
|
1571
|
+
fileContent = fileContent.replace(urlPattern, `"\${${mapping.varName}}"`);
|
|
1572
|
+
}
|
|
1563
1573
|
content += `\n# === ${envFile.appName} ===\n`;
|
|
1574
|
+
content += `# URLs use placeholders that get expanded based on profile (local vs staging)\n`;
|
|
1564
1575
|
content += fileContent;
|
|
1565
1576
|
content += '\n';
|
|
1566
1577
|
}
|