fix(wrangler): hide multi-env warning when env is set via CLOUDFLARE_ENV#13827
fix(wrangler): hide multi-env warning when env is set via CLOUDFLARE_ENV#13827greyvugrin wants to merge 30 commits intocloudflare:mainfrom
Conversation
…env warning message
…nstead of duplicating conditions
🦋 Changeset detectedLatest commit: 4dd4a0b 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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
| const availableEnvs = Object.keys(rawConfig.env ?? {}); | ||
| if (availableEnvs.length > 0) { | ||
| // The targetEnvironment will contain the resolved result of the env flag and the env var, if passed | ||
| if (config.targetEnvironment === undefined) { |
There was a problem hiding this comment.
Is this quite right?
If we are processing a redirected config, then this value is the one environment used when generating the redirected config. It's purpose is so that we can ensure that any --env or CLOUDFLARE_ENV (i.e. the current selected environment) matches the original target.
So this code might work where there is no redirected config, which I think is the case for all the tests above. But will fail otherwise...
There was a problem hiding this comment.
Ah gotcha, yep I see the issue. Added a test to cover that case (it failed) and then updated the code to fix it.
Added a helper to detect if it's a redirected config to not duplicate the logic there.
Also, added tests for the expected --env="" behavior to ensure that's preserved moving forward.
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
…d multi-env warning message" This reverts commit 74fe39f.
…env warning message
…nstead of duplicating conditions
…d multi-env warning message" This reverts commit 74fe39f.
3ae1d5e to
26e6134
Compare
…m:greyvugrin/workers-sdk into fix-workers-deploy-warning-cloudflare-env
Changes:
CLOUDFLARE_ENV)targetEnvironmentCLOUDFLARE_ENVExample of failures prior to adjusting the source code:

Photo by Sierra NiCole Narvaeth on Unsplash