Skip to content

Conversation

eduardo-vargas
Copy link

@eduardo-vargas eduardo-vargas commented Oct 10, 2025

This change updates Wrangler's CLI parser to recognize the 'CLOUDFLARE_ENV' environment variable. If the '--env' flag is not specified in a command, Wrangler will now use the value of 'CLOUDFLARE_ENV' to determine the target environment.

This improves user experience in CI/CD pipelines and local development where setting an environment variable is often more convenient than appending a flag to every command. The '--env' flag continues to take precedence if provided.

Key changes include:

  • A yargs middleware was added to 'createCLIParser' in 'index.ts' to inject the value from 'process.env.CLOUDFLARE_ENV'.
  • The logic in 'register-yargs-command.ts' that warns about missing environments has been updated to be aware of 'CLOUDFLARE_ENV', preventing false-positive warnings.
  • Unit tests have been added to 'cli.test.ts' to verify the fallback and override behavior.
  • 'turbo.json' was updated to include 'CLOUDFLARE_ENV' in 'globalEnv' to ensure correct build caching.

Fixes #10928


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because:

This change updates Wrangler's CLI parser to recognize the 'CLOUDFLARE_ENV' environment variable. If the '--env' flag is not specified in a command, Wrangler will now use the value of 'CLOUDFLARE_ENV' to determine the target environment.

This improves user experience in CI/CD pipelines and local development where setting an environment variable is often more convenient than appending a flag to every command. The '--env' flag continues to take precedence if provided.

Key changes include:
- A yargs middleware was added to 'createCLIParser' in 'index.ts' to inject the value from 'process.env.CLOUDFLARE_ENV'.
- The logic in 'register-yargs-command.ts' that warns about missing environments has been updated to be aware of 'CLOUDFLARE_ENV', preventing false-positive warnings.
- Unit tests have been added to 'cli.test.ts' to verify the fallback and override behavior.
- 'turbo.json' was updated to include 'CLOUDFLARE_ENV' in 'globalEnv' to ensure correct build caching.

Fixes cloudflare#10891
@eduardo-vargas eduardo-vargas requested a review from a team as a code owner October 10, 2025 05:03
Copy link

changeset-bot bot commented Oct 10, 2025

🦋 Changeset detected

Latest commit: feaf356

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

wrangler upload doesn't recognize CLOUDFLARE_ENV

1 participant