convex-js
convex-js copied to clipboard
Allow Convex CLI to save CONVEX_DEPLOYMENT on init to a custom .env file
Summary
Allow Convex CLI to save CONVEX_DEPLOYMENT on init to a custom .env file.
This would enable a user using a custom env file, e.g. convex dev --env-file .env.dev to have
Use-case
Local Deployments of Convex for Local Development. Reduces friction & usage on dev environment. Dev Environment connection from local via .env.dev.
QOL change and make it easier to manage envs without some weird workaround.
Steps to Reproduce
convex dev --env-file .env.devsaved to .env.local
Expected Behavior
Save to file written through flag --env-file
Actual Behavior
Saved to .env.local
Code Snippet / Affected Code
static saving to .env.local https://github.com/get-convex/convex-js/blob/main/src/cli/lib/init.ts
const envVarWrite = await writeConvexUrlToEnvFile(ctx, options.url);
if (envVarWrite !== null) {
logFinishedStep(
ctx,
`${messageForDeploymentType(options.deploymentType, options.url)} and saved its:\n` +
` name as CONVEX_DEPLOYMENT to .env.local\n` +
` URL as ${envVarWrite.envVar} to ${envVarWrite.envFile}`,
);