Skip to content

Conversation

@penalosa
Copy link
Contributor

@penalosa penalosa commented Aug 20, 2025

Fixes #9730

When running a resource creation command (like wrangler kv namespace create NAME), Wrangler will now offer to update your config file for you. Some notes:

  • This does not work for preview KV namespaces, as we don't know the right main KV ID to use
  • This does work for environments, and will update the relevant resource field in the given environment (i.e. --env test)
  • Wrangler will prompt with 3 options: Yes, Yes but change the binding name (which will then present a second dialog to choose the binding name), or No
  • This will not work in non-interactive contexts like CI
  • This will not work when running Wrangler in a context that can't find a config file
  • Updating the config file only works for jsonc format

  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this doesn't need additional documentation
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: new feature

@changeset-bot
Copy link

changeset-bot bot commented Aug 20, 2025

🦋 Changeset detected

Latest commit: ae956e3

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

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Major
@cloudflare/vitest-pool-workers Patch

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 20, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10414

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10414

miniflare

npm i https://pkg.pr.new/miniflare@10414

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10414

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10414

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10414

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10414

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10414

wrangler

npm i https://pkg.pr.new/wrangler@10414

commit: ae956e3

@penalosa penalosa changed the title Penalosa/update config Update config after creation commands Aug 20, 2025
Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 😄 I just left a few small comments

Possibly I would also suggest two additional tests:

  • a test with a toml file testing that the promp is not being presented
  • a test showing that the promp and modification also works as intended with jsonc files with comments (although this might be a bit redundant since already tested for experimental_patchConfig? 🤔 )

]
}"
}
? Would you like Wrangler to add it on your behalf?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry... this is completely completely unrelated, but probably as a followup, I think it's be nicer to use an emoji for the question mark (like❔ for example), what do you think? 🙂

@penalosa
Copy link
Contributor Author

The TOML case is tested here:

, howing no prompts & no config updates. I could add an additional test for a file with comments, but as you say I think it might be a bit redundant given experimental_patchConfig() is already tested with that case.

@dario-piotrowicz
Copy link
Member

The TOML case is tested here:

Sorry, somehow I missed that! 🤦 🙇

I could add an additional test for a file with comments, but as you say I think it might be a bit redundant given experimental_patchConfig() is already tested with that case.

I don't have a strong opinion on it either, if you think it's unnecessary I'm ok avoiding it 🙂👍

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 😄

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Aug 21, 2025
@penalosa penalosa merged commit e81c2cf into main Aug 22, 2025
53 of 56 checks passed
@penalosa penalosa deleted the penalosa/update-config branch August 22, 2025 11:30
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Feature Request: Automatically update the .jsonc Wrangler configuration file when a resource is created

3 participants