Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn when resolving npm packages marked as deprecated #184

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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