convex-js icon indicating copy to clipboard operation
convex-js copied to clipboard

Allow Convex CLI to save CONVEX_DEPLOYMENT on init to a custom .env file

Open quaia-ai opened this issue 6 months ago • 0 comments

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

  1. convex dev --env-file .env.dev Image saved 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}`,
    );

quaia-ai avatar May 23 '25 18:05 quaia-ai