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

fix: cleans up d1 list output for json #2622

Merged
merged 5 commits into from
Jan 25, 2023
Merged

fix: cleans up d1 list output for json #2622

merged 5 commits into from
Jan 25, 2023

Conversation

rozenmd
Copy link
Contributor

@rozenmd rozenmd commented Jan 25, 2023

This PR hides the warning messages, and just returns clean json when running wrangler d1 list --json

Before:

rozenmd@cflaptop test % npx wrangler d1 list
--------------------
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
🚧 Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
🚧 To give feedback, visit https://discord.gg/cloudflaredev
--------------------

┌──────────────────────────────┬─────────────────┐
│ uuid                         │ name            │
├──────────────────────────────┼─────────────────┤
│ xxxxxx-xxxx-xxxx-xxxx-xxxxxx │ test            │
├──────────────────────────────┼─────────────────┤
│ xxxxxx-xxxx-xxxx-xxxx-xxxxxx │ test2           │
├──────────────────────────────┼─────────────────┤
│ xxxxxx-xxxx-xxxx-xxxx-xxxxxx │ test3           │
└──────────────────────────────┴─────────────────┘

After:

rozenmd@cflaptop test % npx wrangler d1 list --json
[
  {
    "uuid": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
    "name": "test"
  },
  {
    "uuid": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
    "name": "test2"
  },
  {
    "uuid": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
    "name": "test3"
  },
]

Closes #2323

@rozenmd rozenmd self-assigned this Jan 25, 2023
@rozenmd rozenmd requested a review from a team as a code owner January 25, 2023 13:45
@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2023

🦋 Changeset detected

Latest commit: 44e85d1

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

This PR includes changesets to release 1 package
Name Type
wrangler 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

@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #2622 (44e85d1) into main (416babf) will increase coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2622   +/-   ##
=======================================
  Coverage   73.19%   73.20%           
=======================================
  Files         159      159           
  Lines        9847     9850    +3     
  Branches     2622     2624    +2     
=======================================
+ Hits         7208     7211    +3     
  Misses       2639     2639           
Impacted Files Coverage Δ
packages/wrangler/src/d1/list.tsx 26.66% <0.00%> (-2.97%) ⬇️
packages/wrangler/src/git-client.ts 81.25% <0.00%> (+4.16%) ⬆️
...ackages/wrangler/src/__tests__/helpers/mock-bin.ts 100.00% <0.00%> (+5.26%) ⬆️

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

It's looking good, looks like moving some stuff around and JSON option feature too.

The blocking comment is in regards to the beta warning message.

if (json) {
logger.log(JSON.stringify(dbs, null, 2));
} else {
logger.log(d1BetaWarning);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this beta warning be moved above the if statement?

Copy link
Contributor

Choose a reason for hiding this comment

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

The point of the pull is to have a json parseable output - by having the warning, you lose that ability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My idea was to not print the warning since it might pollute stdout

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I see the use case you may be referring to in regards of maybe piping the stdout to say a .json file or something and this messaging would break that.

packages/wrangler/src/d1/list.tsx Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Jan 25, 2023

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/runs/4007970845/npm-package-wrangler-2622

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/runs/4007970845/npm-package-wrangler-2622 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/runs/4007970845/npm-package-cloudflare-pages-shared-2622

@rozenmd rozenmd requested a review from JacobMGEvans January 25, 2023 16:24
Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

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

Appreciate the clarification of the use case. We want to be considerate of the messaging as part of the Wrangler Public API, I think you make a good point that the messaging is strongly prominent in other parts of d1 usage

if (json) {
logger.log(JSON.stringify(dbs, null, 2));
} else {
logger.log(d1BetaWarning);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I see the use case you may be referring to in regards of maybe piping the stdout to say a .json file or something and this messaging would break that.

@rozenmd
Copy link
Contributor Author

rozenmd commented Jan 25, 2023

Apologies @JacobMGEvans, I should've linked the GitHub issue: #2323

@rozenmd rozenmd merged commit 9778b33 into main Jan 25, 2023
@rozenmd rozenmd deleted the rozenmd/d1-json-output branch January 25, 2023 18:05
@github-actions github-actions bot mentioned this pull request Jan 25, 2023
@JacobMGEvans
Copy link
Contributor

Apologies @JacobMGEvans, I should've linked the GitHub issue: #2323

Looks like you did in the PR description! That's a miss on my part 😅

@rozenmd
Copy link
Contributor Author

rozenmd commented Jan 25, 2023

Added it after your last comment lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Add --json argument to print json
3 participants