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 2 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/nassun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ serde_json = { workspace = true }
ssri = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
colored = { workspace = true }
amitdahan marked this conversation as resolved.
Show resolved Hide resolved
url = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
15 changes: 15 additions & 0 deletions crates/nassun/src/resolver.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{fmt::Display, path::PathBuf, sync::Arc};

use colored::*;
use node_semver::{Range as SemVerRange, Version as SemVerVersion};
use oro_common::CorgiPackument;
use oro_package_spec::{GitInfo, PackageSpec, VersionSpec};
Expand Down Expand Up @@ -230,6 +231,20 @@ impl PackageResolver {
versions: packument.versions.keys().map(|k| k.to_string()).collect(),
})
.and_then(|v| {
if let Some(deprecated) = &v.deprecated {
tracing::warn!(
"{} {}@{}: {}",
"deprecated".magenta(),
name,
v.manifest
.version
.as_ref()
.map(|v| v.to_string())
.unwrap_or_else(|| "unknown".into()),
deprecated
);
}
amitdahan marked this conversation as resolved.
Show resolved Hide resolved

Ok(PackageResolution::Npm {
name: name.into(),
version: v
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