Deno: Progress bars for "Downloading" messages

Created on 12 Dec 2018  路  6Comments  路  Source: denoland/deno

Should be completely in Rust.
This looks like a good library to use: https://github.com/mitsuhiko/indicatif

Starting points is here:
https://github.com/denoland/deno/blob/a8c3b448049912ead5ba025fee9568dcc0786573/src/deno_dir.rs#L152

(After #975 the "Compiling" messages can also be added to the progress bar. It will move the compilation step into Rust. Currently "Compiling" is printed from JS.)

Most helpful comment

@ry I've been watching this project for several months and I really want to be involved. Can I try this issue?

All 6 comments

@ry I've been watching this project for several months and I really want to be involved. Can I try this issue?

Async module loading has now landed. It should be quite approachable now to do proper progress bars.

Waiting for denoland/deno_third_party#32 to resolve this

@ry moving discussion here to keep it in one place


@bartlomieju I'd rather there be a "ProgressBar" object (which should wrap whichever progress bar crate we're using) which can be added to ThreadSafeState. Then you'd have something like ProgressBar::start(action: String) and ProgressBar::end(action: String) ? Not sure about that exact API, but some functionality like that.

_Originally posted by @ry in https://github.com/denoland/deno/issues/2057#issuecomment-487308674_



@bartlomieju I like how ninja does its progress - which is very simple - it looks like

[4/34] STAMP obj/cli/msg_rs.stamp

maybe we can just do that manually in a few lines of code.

_Originally posted by @ry in https://github.com/denoland/deno/pull/2229#issuecomment-487383232_


Taking both comments into consideration:

  • When deno starts we don't know which files are cached so we don't know how many files will be downloaded. That means we need to store and update number of files to download and already downloaded as new imports are being "discovered".

Then when file is being downloaded around here:
https://github.com/denoland/deno/blob/a4551c853e25a08ea479c5b75f60dc4109eee72f/cli/deno_dir.rs#L560-L570
number of files to download should be incremented, and message displayed:

[{no_finished_downloads}/{no_downloads}] DOWNLOAD {filename}
[0/1] DOWNLOAD https://deno.land/std/prettier/main.ts
[0/4] DOWNLOAD https://deno.land/std/prettier/prettier.ts
[1/4] DOWNLOAD https://deno.land/std/prettier/prettier.ts
...

Lastly around here:
https://github.com/denoland/deno/blob/a4551c853e25a08ea479c5b75f60dc4109eee72f/cli/deno_dir.rs#L648-L650
number of files downloaded should be incremented.

I guess it makes most sense to store those numbers in Metrics. The same thing applies for compiled files.

Done in #2309

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ry picture ry  路  3Comments

sh7dm picture sh7dm  路  3Comments

CruxCv picture CruxCv  路  3Comments

JosephAkayesi picture JosephAkayesi  路  3Comments

kitsonk picture kitsonk  路  3Comments