Skip to content

Commit

Permalink
feat(deprecated): Warn when resolving npm packages marked as `depreca…
Browse files Browse the repository at this point in the history
…ted` (#184)

Fixes: #157
  • Loading branch information
amitdahan committed Feb 28, 2023
1 parent b227eb3 commit 45a953b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/node-maintainer/Cargo.toml
Expand Up @@ -15,6 +15,7 @@ oro-common = { version = "=0.2.2", path = "../oro-common" }
oro-package-spec = { version = "=0.2.2", path = "../oro-package-spec" }

async-std = { workspace = true }
colored = { workspace = true }
futures = { workspace = true }
kdl = { workspace = true }
miette = { workspace = true }
Expand Down
26 changes: 24 additions & 2 deletions crates/node-maintainer/src/maintainer.rs
Expand Up @@ -6,11 +6,12 @@ use std::sync::atomic::{self, AtomicUsize};
#[cfg(not(target_arch = "wasm32"))]
use async_std::fs;
use async_std::sync::{Arc, Mutex};
use colored::*;
use futures::{StreamExt, TryFutureExt, TryStreamExt};
#[cfg(not(target_arch = "wasm32"))]
use indicatif::{ProgressBar, ProgressStyle};
use nassun::{Nassun, NassunOpts, Package, PackageSpec};
use oro_common::CorgiManifest;
use oro_common::{CorgiManifest, CorgiVersionMetadata};
use petgraph::stable_graph::NodeIndex;
use petgraph::visit::EdgeRef;
use petgraph::Direction;
Expand Down Expand Up @@ -459,7 +460,28 @@ impl NodeMaintainer {

if let Some(deps) = deps {
in_flight -= deps.len();
let manifest = package.corgi_metadata().await?.manifest;

let CorgiVersionMetadata {
manifest,
deprecated,
..
} = &package.corgi_metadata().await?;

if let Some(deprecated) = deprecated {
pb.suspend(|| {
tracing::warn!(
"{} {}@{}: {}",
"deprecated".magenta(),
manifest.name.as_ref().unwrap(),
manifest
.version
.as_ref()
.map(|v| v.to_string())
.unwrap_or_else(|| "unknown".into()),
deprecated
);
});
}

for dep in deps {
if let Some(child_idx) =
Expand Down
3 changes: 3 additions & 0 deletions crates/oro-common/src/packument.rs
Expand Up @@ -74,6 +74,8 @@ pub struct CorgiVersionMetadata {
pub has_shrinkwrap: Option<bool>,
#[serde(flatten)]
pub manifest: CorgiManifest,
#[serde(skip_serializing_if = "Option::is_none")]
pub deprecated: Option<String>,
}

/// A manifest for an individual package version.
Expand Down Expand Up @@ -111,6 +113,7 @@ impl From<VersionMetadata> for CorgiVersionMetadata {
dist: value.dist.into(),
has_shrinkwrap: value.has_shrinkwrap,
manifest: value.manifest.into(),
deprecated: value.deprecated,
}
}
}
Expand Down

0 comments on commit 45a953b

Please sign in to comment.