@rebasepro/cli 0.11.1-canary.gfadf355 → 0.12.0
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/index.es.js
CHANGED
|
@@ -1531,6 +1531,26 @@ async function findAvailablePort(startPort) {
|
|
|
1531
1531
|
while (!await isPortAvailable(port)) port++;
|
|
1532
1532
|
return port;
|
|
1533
1533
|
}
|
|
1534
|
+
/**
|
|
1535
|
+
* The CLI's own version, which is the runtime image tag a scaffolded project
|
|
1536
|
+
* pins. They move together: the CLI, the packages and the runtime image are cut
|
|
1537
|
+
* from one release, so the version that installed the project is the version
|
|
1538
|
+
* whose runtime can boot its bundle.
|
|
1539
|
+
*
|
|
1540
|
+
* Falls back to `latest` only when the CLI cannot read its own manifest — a
|
|
1541
|
+
* floating tag is worse than a pinned one, but better than a compose file that
|
|
1542
|
+
* names a version that was never published.
|
|
1543
|
+
*/
|
|
1544
|
+
function readCliVersion() {
|
|
1545
|
+
try {
|
|
1546
|
+
const manifest = path.resolve(cliRoot, "package.json");
|
|
1547
|
+
if (fs.existsSync(manifest)) {
|
|
1548
|
+
const pkg = JSON.parse(fs.readFileSync(manifest, "utf-8"));
|
|
1549
|
+
if (typeof pkg.version === "string" && pkg.version) return pkg.version;
|
|
1550
|
+
}
|
|
1551
|
+
} catch {}
|
|
1552
|
+
return "latest";
|
|
1553
|
+
}
|
|
1534
1554
|
async function configureEnvFile(targetDirectory, databaseUrl) {
|
|
1535
1555
|
const envExamplePath = path.join(targetDirectory, ".env.example");
|
|
1536
1556
|
const envPath = path.join(targetDirectory, ".env");
|
|
@@ -1542,6 +1562,8 @@ async function configureEnvFile(targetDirectory, databaseUrl) {
|
|
|
1542
1562
|
let envContent = fs.readFileSync(envPath, "utf-8");
|
|
1543
1563
|
envContent = envContent.replace(/^JWT_SECRET=.*$/m, `JWT_SECRET=${jwtSecret}`);
|
|
1544
1564
|
envContent = envContent.replace(/^#\s*REBASE_SERVICE_KEY=.*$/m, `REBASE_SERVICE_KEY=${serviceKey}`);
|
|
1565
|
+
const runtimeVersion = readCliVersion();
|
|
1566
|
+
envContent = /^#?\s*REBASE_VERSION=.*$/m.test(envContent) ? envContent.replace(/^#?\s*REBASE_VERSION=.*$/m, `REBASE_VERSION=${runtimeVersion}`) : `${envContent.trimEnd()}\n\n# The Rebase runtime image tag docker-compose.yml pulls.\n# Change this and restart to upgrade; your project bundle is untouched.\nREBASE_VERSION=${runtimeVersion}\n`;
|
|
1545
1567
|
if (databaseUrl) {
|
|
1546
1568
|
if (/[\r\n]/.test(databaseUrl)) throw new Error("Invalid DATABASE_URL: multiline values are not allowed.");
|
|
1547
1569
|
envContent = envContent.replace(/^DATABASE_URL=.*$/m, `DATABASE_URL=${databaseUrl}\nDATABASE_PASSWORD=${dbPassword}`);
|