summaryrefslogtreecommitdiff
path: root/cli/npm
diff options
context:
space:
mode:
Diffstat (limited to 'cli/npm')
-rw-r--r--cli/npm/cache.rs18
-rw-r--r--cli/npm/mod.rs9
-rw-r--r--cli/npm/registry.rs21
3 files changed, 29 insertions, 19 deletions
diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs
index e39957a6b..a0082fb29 100644
--- a/cli/npm/cache.rs
+++ b/cli/npm/cache.rs
@@ -11,12 +11,12 @@ use deno_core::anyhow::Context;
use deno_core::error::custom_error;
use deno_core::error::AnyError;
use deno_core::url::Url;
-use deno_runtime::colors;
use deno_runtime::deno_fetch::reqwest;
use crate::deno_dir::DenoDir;
use crate::file_fetcher::CacheSetting;
use crate::fs_util;
+use crate::progress_bar::ProgressBar;
use super::semver::NpmVersion;
use super::tarball::verify_and_extract_tarball;
@@ -173,13 +173,19 @@ impl ReadonlyNpmCache {
pub struct NpmCache {
readonly: ReadonlyNpmCache,
cache_setting: CacheSetting,
+ progress_bar: ProgressBar,
}
impl NpmCache {
- pub fn from_deno_dir(dir: &DenoDir, cache_setting: CacheSetting) -> Self {
+ pub fn from_deno_dir(
+ dir: &DenoDir,
+ cache_setting: CacheSetting,
+ progress_bar: ProgressBar,
+ ) -> Self {
Self {
readonly: ReadonlyNpmCache::from_deno_dir(dir),
cache_setting,
+ progress_bar,
}
}
@@ -211,13 +217,7 @@ impl NpmCache {
);
}
- log::log!(
- log::Level::Info,
- "{} {}",
- colors::green("Download"),
- dist.tarball,
- );
-
+ let _guard = self.progress_bar.update(&dist.tarball);
let response = reqwest::get(&dist.tarball).await?;
if response.status() == 404 {
diff --git a/cli/npm/mod.rs b/cli/npm/mod.rs
index d0a57c5bc..2dd871cff 100644
--- a/cli/npm/mod.rs
+++ b/cli/npm/mod.rs
@@ -31,6 +31,7 @@ use resolution::NpmResolution;
use crate::deno_dir::DenoDir;
use crate::file_fetcher::CacheSetting;
+use crate::progress_bar::ProgressBar;
use self::cache::ReadonlyNpmCache;
use self::resolution::NpmResolutionSnapshot;
@@ -87,13 +88,15 @@ impl GlobalNpmPackageResolver {
cache_setting: CacheSetting,
unstable: bool,
no_npm: bool,
+ progress_bar: ProgressBar,
) -> Self {
Self::from_cache(
- NpmCache::from_deno_dir(dir, cache_setting.clone()),
+ NpmCache::from_deno_dir(dir, cache_setting.clone(), progress_bar.clone()),
reload,
cache_setting,
unstable,
no_npm,
+ progress_bar,
)
}
@@ -103,8 +106,10 @@ impl GlobalNpmPackageResolver {
cache_setting: CacheSetting,
unstable: bool,
no_npm: bool,
+ progress_bar: ProgressBar,
) -> Self {
- let api = NpmRegistryApi::new(cache.clone(), reload, cache_setting);
+ let api =
+ NpmRegistryApi::new(cache.clone(), reload, cache_setting, progress_bar);
let registry_url = api.base_url().to_owned();
let resolution = Arc::new(NpmResolution::new(api));
diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs
index 1fb4b2e0a..f5b8b9fc8 100644
--- a/cli/npm/registry.rs
+++ b/cli/npm/registry.rs
@@ -21,6 +21,7 @@ use serde::Serialize;
use crate::file_fetcher::CacheSetting;
use crate::fs_util;
use crate::http_cache::CACHE_PERM;
+use crate::progress_bar::ProgressBar;
use super::cache::NpmCache;
use super::semver::NpmVersionReq;
@@ -106,6 +107,7 @@ pub struct NpmRegistryApi {
mem_cache: Arc<Mutex<HashMap<String, Option<NpmPackageInfo>>>>,
reload: bool,
cache_setting: CacheSetting,
+ progress_bar: ProgressBar,
}
impl NpmRegistryApi {
@@ -132,8 +134,15 @@ impl NpmRegistryApi {
cache: NpmCache,
reload: bool,
cache_setting: CacheSetting,
+ progress_bar: ProgressBar,
) -> Self {
- Self::from_base(Self::default_url(), cache, reload, cache_setting)
+ Self::from_base(
+ Self::default_url(),
+ cache,
+ reload,
+ cache_setting,
+ progress_bar,
+ )
}
pub fn from_base(
@@ -141,6 +150,7 @@ impl NpmRegistryApi {
cache: NpmCache,
reload: bool,
cache_setting: CacheSetting,
+ progress_bar: ProgressBar,
) -> Self {
Self {
base_url,
@@ -148,6 +158,7 @@ impl NpmRegistryApi {
mem_cache: Default::default(),
reload,
cache_setting,
+ progress_bar,
}
}
@@ -294,13 +305,7 @@ impl NpmRegistryApi {
}
let package_url = self.get_package_url(name);
-
- log::log!(
- log::Level::Info,
- "{} {}",
- colors::green("Download"),
- package_url,
- );
+ let _guard = self.progress_bar.update(package_url.as_str());
let response = match reqwest::get(package_url).await {
Ok(response) => response,