-
Notifications
You must be signed in to change notification settings - Fork 946
[wrangler] Add --json flag to r2 bucket info command #9530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wrangler] Add --json flag to r2 bucket info command #9530
Conversation
🦋 Changeset detectedLatest commit: 9ec5cf8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
Hello. Since I'm who issued #9433, I'm very happy about this. Although it would be very preferable if it was possible to remove the banner line when using |
Thanks so much for the feedback, @frankichiro — totally agree with you. I'll go ahead and update the PR to suppress the banner when --json is used, so the output is clean and parseable. |
Made the requested changes to suppress the banner when --json is used. Let me know if there's anything else I should address — happy to iterate further. Thanks again for the guidance! |
Just wanted to follow up on this! Let me know if there’s anything else needed from my side to move this forward — happy to make any changes if required. Thanks again for your time! |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks so much for the contribution - sorry this was missed for a while, looks like our github automations went wonky and it wasn't added to our queue 😅
Just a couple of small things, but on the whole looks good.
Would you also be able to add a changeset? https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/CONTRIBUTING.md#changesets
And if you're up to it, would you also be able to create a PR to the docs to add it to the wrangler command documentation? https://developers.cloudflare.com/workers/wrangler/commands/#r2-bucket-info
Let me know if you have any questions about this :)
also, it looks like you have some linting issues. you can run |
4cc8e51
to
c7ddab9
Compare
Thanks a lot for the detailed review, -Used behaviour: { showBanner: false } instead of editing the banner file Let me know if i made a mistake anywhere. |
Just a quick note: I ended up cleaning up the commit history because the original one had some unrelated files accidentally committed. To keep things clean and focused, I created a fresh branch from main, reapplied only the relevant changes, and force-pushed — which unfortunately removed previous commit-level context. But I’ve addressed all the feedback again in this clean version. Once you’ve had a chance to review this updated commit, I’ll go ahead and create a follow-up PR to update the Wrangler documentation for the r2 bucket info command as well. Let me know if anything else is needed! |
@Akshit222 thanks for this, this is looking pretty good! Would you be able to restore the PR template and fill out the relevant checkboxes, so we can get this merged? |
Thanks for the feedback! I'll update the PR template and checkboxes shortly. |
I've updated the PR description with the template and filled out the checkboxes as requested. Also, please let me know if any of the failing checks need action on my side — happy to fix if required. |
c7ddab9
to
1dec4af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. I expect that there will be a bunch of snapshot failures that need updating now that the help text for these commands will have changed.
pnpm test:ci -F wrangler -- -u
there are a bunch of linting errors which would mostly be solved by simplifying the test as suggested. |
Please open a draft docs-PR before merging and reference it in the PR description. It can then be reviewed and merged after this had been released. |
Wow, this really required much more work than I imagined it would. Thanks @Akshit222 for seeing it through, I really appreciate your efforts for making this work. |
Thanks a lot for the thoughtful feedback and guidance |
Thanks for the detailed review! I've made the following changes based on your feedback: Snapshot concerns: I'm not using Jest snapshots in these tests, so there's no need to update any. The existing test setup avoids snapshot-based output assertions — but let me know if I misunderstood and you were referring to something else. Mock reset: You were right — we already call vi.resetAllMocks() by default, so that part was redundant. I've cleaned it up. JSON parse block simplification: Simplified the --json test as suggested. It now directly asserts on the parsed output rather than wrapping the parse in a try-catch. Linting issues: These were mostly resolved by the above simplification and cleanup — no lint errors now. I checked after running pnpm check:lint. logger.json() integration: Updated the bucket.ts implementation to use logger.json() for consistency with other commands when the --json flag is used. I'll send a follow-up PR to add the relevant docs to docs/content/en/r2 as discussed soon. Let me know if there’s anything else to tweak! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Akshit222 for bearing with us. Looks good now.
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
5c81d4d
to
da1b52a
Compare
Congratulations @Akshit222, the maintainer of this repository has issued you a holobyte! Here it is: https://holopin.io/holobyte/cmduai1z6006807l5zii5jc3t This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
Fixes #9433
What
Adds a
--json
flag to thewrangler r2 bucket info
command, returning the bucket info in clean JSON format.Why
The current output is not machine-readable.
Adding this flag makes the output usable in scripts and consistent with D1 commands that already support
--json
.How
--json
flag tor2 bucket info
--json
is passed--json
is usedpnpm fix
Test Plan
pnpm exec vitest run packages/wrangler/src/__tests__/r2/bucket.test.ts
passed--json
is passedExample
With
--json
:Without
--json
:r2 bucket info
command cloudflare-docs#24120