Skip to content
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

Implement --json in versions list commands #5412

Merged
merged 4 commits into from Mar 28, 2024
Merged

Conversation

RamIdeas
Copy link
Contributor

@RamIdeas RamIdeas commented Mar 27, 2024

What this PR solves / how to test

Fixes #5408.

This PR adds the --json flag to wrangler deployments list --experimental-versions and wrangler versions list --experimental-versions which will format the output as clean JSON.

This only affects the --experimental-versions flagged implementation of these commands, not the unflagged implementation.

CR: https://jira.cfdata.org/browse/CR-850334

Author has addressed the following

@RamIdeas RamIdeas requested a review from a team as a code owner March 27, 2024 13:46
Copy link

changeset-bot bot commented Mar 27, 2024

🦋 Changeset detected

Latest commit: 3f7f8a1

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

This PR includes changesets to release 2 packages
Name Type
wrangler Minor
@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

@RamIdeas RamIdeas changed the title Implement --json in {versions|deployments} list Implement --json in versions list commands Mar 27, 2024
Copy link
Contributor

github-actions bot commented Mar 27, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-wrangler-5412

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5412/npm-package-wrangler-5412

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-wrangler-5412 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-create-cloudflare-5412 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-cloudflare-kv-asset-handler-5412
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-miniflare-5412
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-cloudflare-pages-shared-5412
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8467123919/npm-package-cloudflare-vitest-pool-workers-5412

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.39.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20240320.0
workerd 1.20240320.1 1.20240320.1
workerd --version 1.20240320.1 2024-03-20

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.31%. Comparing base (0401db9) to head (3f7f8a1).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5412      +/-   ##
==========================================
+ Coverage   72.18%   72.31%   +0.12%     
==========================================
  Files         322      322              
  Lines       16663    16685      +22     
  Branches     4260     4266       +6     
==========================================
+ Hits        12029    12065      +36     
+ Misses       4634     4620      -14     
Files Coverage Δ
...kages/wrangler/src/utils/render-labelled-values.ts 100.00% <100.00%> (ø)
packages/wrangler/src/versions/deployments/list.ts 100.00% <100.00%> (ø)
...ckages/wrangler/src/versions/deployments/status.ts 97.82% <100.00%> (+0.20%) ⬆️
packages/wrangler/src/versions/list.ts 78.78% <100.00%> (+1.36%) ⬆️
packages/wrangler/src/versions/view.ts 100.00% <100.00%> (ø)

... and 10 files with indirect coverage changes

Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

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

Some nits, but mostly LGTM

.changeset/thirty-mayflies-carry.md Outdated Show resolved Hide resolved
@@ -55,6 +62,11 @@ export async function versionsViewHandler(args: VersionsViewArgs) {

const version = await fetchVersion(accountId, workerName, args.versionId);

if (args.json) {
logRaw(JSON.stringify(version, null, 2));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the null, 2? In general, I don't think we should be outputting prettified JSON

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Curious why you think we shouldn't output prettified JSON?

Seems to me like there's no benefit in not prettifying it but if a user needed to debug their usage it would be helpful for it to be slightly more readable

@@ -52,6 +60,12 @@ export async function versionsDeploymentsListHandler(
}

const deployments = await fetchLatestDeployments(accountId, workerName);

if (args.json) {
logRaw(JSON.stringify(deployments, null, 2));
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above

packages/wrangler/src/utils/render-labelled-values.ts Outdated Show resolved Hide resolved
@RamIdeas RamIdeas merged commit 3e5a932 into main Mar 28, 2024
17 checks passed
@RamIdeas RamIdeas deleted the versions-list-json branch March 28, 2024 14:32
@mrbbot mrbbot added the ldw-exempt PRs marked with this label can be included in releases during LDW. label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ldw-exempt PRs marked with this label can be included in releases during LDW.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: --output option for wrangler versions list/view
3 participants