-
Notifications
You must be signed in to change notification settings - Fork 337
Add output option for wrangler publish #1507
Add output option for wrangler publish #1507
Conversation
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.
If the main difference being messages go to stderr instead of stdout and the json output I think maybe using lazy_static in terminal::message
to have a static variable that would change all message
functions to go to stderr instead of stdout would be better than having to pass a mutable reference into every function especially if we plan on adding this to other commands since this
reference would basically have to passed everywhere. Thoughts? @EverlastingBugstopper @ashleymichal
Also looks like the lint CI failed, you can fix that by running cargo fmt
and cargo clippy
. Cool that you're starting work on Wrangler :)
Agreed, this should all be handled with the message framework, and if there are things we print that don't use that framework they should be migrated |
Thanks for the feedback. It seems like I'll need to set a global variable |
7a9742e
to
0f869bc
Compare
It doesn't really need to be global, just a local static variable in *Sent this right before your updates I'll take a look |
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.
Just a few small things but other than that looks good to me! I'm assuming you'll be adding the url
part after this.
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.
few things here and there but this is looking good 😄
src/terminal/message.rs
Outdated
println!("{}", msg); | ||
match OUTPUT_TYPE.get() { | ||
Some(OutputType::Json) => { | ||
eprintln!("{}", msg); |
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.
are these backwards? i think json should go to stdout and human readable should be stderr, no?
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.
json should go to stdout and human readable should be stderr, no?
Yes- IFF json output flag is given. I made the assumption messages are for human readable output. It made sense to me to make a json type here. I'm a rust novice so let me know if there is a better way.
wrangler build | publish --output json
Wrangler supports structured output for core commands build
and publish
. JSON
string goes to stdout, stderr displays user output.
js
nat@cf:~/examplejs$wrangler build
💁 JavaScript project found. Skipping unnecessary build!
nat@cf:~/examplejs$wrangler build --output json
{"success":true,"name":"examplejs"}
nat@davidson:~/examplejs$ ../wrangler/target/debug/wrangler publish --output json `returns no output, need to fix.
Webpack build
and publish
nat@davidson:~/demo-site$ ../wrangler/target/debug/wrangler build --output json
{"success":true,"name":"demo-site"}
nat@davidson:~/demo-site$ ../wrangler/target/debug/wrangler publish --output json
{"success":true,"name":"demo-site","urls":["https://demo-site.nats.workers.dev"]}
Next steps: extend to other worker types
acd4c98
to
29750f5
Compare
Spoke with @ashleymichal about this. Implementation plan is as follows:
|
closing for #1538 |
wrangler build | publish --output json
Wrangler supports structured output for core commands
build
andpublish
.JSON
string goes to stdout, stderr displays user output.js
^ No output. Confused why that is happening as the logic to create structured output in the publish path should be the same regardless of project type.
Webpack
build
andpublish
I'm unfamiliar with assert_cmd and will ramp up on that to make some solid tests.