Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Verbose file printouts when using wrangler publish with a Worker Site #790

Merged
merged 10 commits into from
Oct 22, 2019

Conversation

gabbifish
Copy link
Contributor

@gabbifish gabbifish commented Oct 21, 2019

This PR closes #657. It allows Wrangler users running wrangler publish or wrangler preview to see which files are being uploaded to Workers KV:

$ wrangler publish --version
 Using namespace for Workers Site "__blog-workers_sites_assets"
 Preparing to upload updated files...
 Processing ./public/sitemap.xml...
 Processing ./public/page/1/index.html...
 Processing ./public/posts/hahaha.butts/index.html...
 Processing ./public/posts/index.xml...
 ...
 Success
 ⬇️ Installing wasm-pack...
 Built successfully, built project size is 11 KiB.
 Successfully published your script to https://blog.ziggy.workers.dev

@gabbifish gabbifish changed the title Verbose file printouts when using wrangler publish with a Worker Site [WIP] Verbose file printouts when using wrangler publish with a Worker Site Oct 21, 2019
@gabbifish gabbifish changed the title [WIP] Verbose file printouts when using wrangler publish with a Worker Site Verbose file printouts when using wrangler publish with a Worker Site Oct 21, 2019
@@ -36,6 +36,10 @@ pub fn directory_keys_values(
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() {
if print_files {
message::working(&format!("Parsing {}...", path.display()));
Copy link
Member

Choose a reason for hiding this comment

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

Why parsing by the way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we technically don't upload until later :P by then, all the files have been batched into vecs for batched KV bulk uploads, so it's not optimal to print out the files there (we'd be iterating over the files again when we can just print out files in this initial interation).

Copy link
Member

Choose a reason for hiding this comment

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

I see. I would be fine with Processing x .... Parsing the file sounds odd to me, especially if we don't do it at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good! Will replace Parsing with Processing :)

Copy link
Contributor

Choose a reason for hiding this comment

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

We aren't parsing the files so we should change this verb.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about Preparing?

src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

This generally LGTM I have a few nits that I won't block on. This is the output that I had when running wrangler publish after wrangler generate --site && cd worker

$ wrangler publish --print-files
🌀  Using namespace for Workers Site "__worker-workers_sites_assets"
💁  Preparing to upload updated files...
🌀  Processing ./public/favicon.ico...
🌀  Processing ./public/index.html...
🌀  Processing ./public/404.html...
🌀  Processing ./public/img/404-wrangler-ferris.gif...
🌀  Processing ./public/img/200-wrangler-ferris.gif...
✨  Success
✨  Built successfully, built project size is 11 KiB.
✨  Successfully published your script to https://worker.avery.workers.dev

Unrelated to this PR: I think the singular "Success" line should be more descriptive about what exactly was successful. Think we might want to audit the way we communicate success. If others agree I'll open a new issue.

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
@@ -36,6 +36,10 @@ pub fn directory_keys_values(
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() {
if print_files {
message::working(&format!("Processing {}...", path.display()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should "Processing" be "Uploading"? We aren't doing any processing on each file.

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought (personal opinion incoming): I think I'd like to just have each file name on its own line without Processing or the ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh Sven suggested switching to Processing instead of Parsing! I think either is okay... I have no strong opinions on which verb we use. I can get rid of the ellipses easy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah - I feel like it might be redundant to have any verb (not hugely important) but seems like we could get away with each line just being the file name by itself with no frills (maybe even no emoji for easy copy pasting?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about I use the word "preparing"? I guess we are preparing since we are base64 encoding all file contents :)

@gabbifish
Copy link
Contributor Author

@EverlastingBugstopper what did you think about extending this behavior to wrangler preview as well?

@gabbifish gabbifish added regression Something is broken, but works in previous releases status - needs review labels Oct 21, 2019
@gabbifish gabbifish added this to the 1.5.0 milestone Oct 21, 2019
@EverlastingBugstopper
Copy link
Contributor

I think extending to preview is a great idea - it's probably going to be used more often when debugging in preview than when publishing to be honest. I'm still a bit confused what you mean by "true verbose"

@gabbifish
Copy link
Contributor Author

gabbifish commented Oct 21, 2019 via email

@ashleygwilliams
Copy link
Contributor

@gabbifish is there a reason that we can't just make this what verbose would mean for this command? i.e. these are INFO logs? i'm not sure the bepsoke flag is necessary here

i would expected wrangler publish --verbose to print what this does i think

@gabbifish
Copy link
Contributor Author

gabbifish commented Oct 21, 2019 via email

@ashleygwilliams
Copy link
Contributor

can you summarize @xtuc's point (it's late his time so he may be asleep)? im' not sure i understand the difference but it seems useful to understand! (i dont see it in the comment history so i'm not sure where the convo happened- would be good to document here!)

@xtuc
Copy link
Member

xtuc commented Oct 21, 2019

I also don't feel strongly about that. My argument was that --print-files is describing exactly what we are wanting to do here, --verbose will add some noise in the ouput (aka Wrangler debug logs?). It also removes the confusion of the behavior of verbose for the other subcommands.

Also, once if we descided to add a verbose flag it could toggle print-files as well.

@gabbifish
Copy link
Contributor Author

gabbifish commented Oct 21, 2019 via email

@gabbifish
Copy link
Contributor Author

I'm going to revert to using --verbose instead of --print-files. Also extending this functionality to preview.

src/main.rs Outdated
)
.arg(
Arg::with_name("verbose")
.short("v")
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't use a short alias for this flag. It could be in our way when we want to add a flag that starts with the same name and that is more commonly used.

Copy link
Contributor

Choose a reason for hiding this comment

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

agree

Copy link
Contributor

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

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

a few nits, but otherwise looks good to go for me

@@ -36,6 +36,10 @@ pub fn directory_keys_values(
let entry = entry.unwrap();
let path = entry.path();
if path.is_file() {
if print_files {
message::working(&format!("Parsing {}...", path.display()));
Copy link
Contributor

Choose a reason for hiding this comment

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

We aren't parsing the files so we should change this verb.

src/main.rs Outdated
)
.arg(
Arg::with_name("verbose")
.short("v")
Copy link
Contributor

Choose a reason for hiding this comment

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

agree

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

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

this looks great to me!! 🚀

@ashleygwilliams ashleygwilliams merged commit ab3351e into master Oct 22, 2019
@ashleygwilliams ashleygwilliams deleted the gabbi/#657 branch October 22, 2019 18:13
@ashleygwilliams ashleygwilliams added changelog - feature and removed regression Something is broken, but works in previous releases labels Oct 25, 2019
@simplenotezy
Copy link

Is this is 1.11.0 release yet?

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

Successfully merging this pull request may close these issues.

Add --verbose option for wrangler publish
5 participants