fix: do not error on missing deps until full linking
Some checks are pending
Test & Lint / lint (push) Waiting to run

This commit is contained in:
daimond113 2024-12-18 23:34:49 +01:00
parent a6c1108d5b
commit 0f74e2efa3
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
3 changed files with 19 additions and 8 deletions

View file

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Change dependency types for removed peer dependencies by @daimond113 - Change dependency types for removed peer dependencies by @daimond113
- Resolve version to correct tag for `pesde_version` field by @daimond113 - Resolve version to correct tag for `pesde_version` field by @daimond113
- Do not error on missing dependencies until full linking by @daimond113
### Changed ### Changed
- Switch from `log` to `tracing` for logging by @daimond113 - Switch from `log` to `tracing` for logging by @daimond113

View file

@ -11,7 +11,7 @@ use std::{
sync::{Arc, Mutex as StdMutex}, sync::{Arc, Mutex as StdMutex},
}; };
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tracing::instrument; use tracing::{instrument, Instrument};
/// Filters a graph to only include production dependencies, if `prod` is `true` /// Filters a graph to only include production dependencies, if `prod` is `true`
pub fn filter_graph(graph: &DownloadedGraph, prod: bool) -> DownloadedGraph { pub fn filter_graph(graph: &DownloadedGraph, prod: bool) -> DownloadedGraph {
@ -85,6 +85,7 @@ impl Project {
// step 1. download pesde dependencies // step 1. download pesde dependencies
let (mut pesde_rx, pesde_graph) = this let (mut pesde_rx, pesde_graph) = this
.download_graph(&graph, &mut refreshed_sources, &reqwest, prod, write, false) .download_graph(&graph, &mut refreshed_sources, &reqwest, prod, write, false)
.instrument(tracing::debug_span!("download (pesde)"))
.await?; .await?;
while let Some(result) = pesde_rx.recv().await { while let Some(result) = pesde_rx.recv().await {
@ -96,6 +97,7 @@ impl Project {
// step 2. link pesde dependencies. do so without types // step 2. link pesde dependencies. do so without types
if write { if write {
this.link_dependencies(&filter_graph(&pesde_graph, prod), false) this.link_dependencies(&filter_graph(&pesde_graph, prod), false)
.instrument(tracing::debug_span!("link (pesde)"))
.await?; .await?;
} }
@ -110,6 +112,7 @@ impl Project {
// step 3. download wally dependencies // step 3. download wally dependencies
let (mut wally_rx, wally_graph) = this let (mut wally_rx, wally_graph) = this
.download_graph(&graph, &mut refreshed_sources, &reqwest, prod, write, true) .download_graph(&graph, &mut refreshed_sources, &reqwest, prod, write, true)
.instrument(tracing::debug_span!("download (wally)"))
.await?; .await?;
while let Some(result) = wally_rx.recv().await { while let Some(result) = wally_rx.recv().await {
@ -139,6 +142,7 @@ impl Project {
// step 4. link ALL dependencies. do so with types // step 4. link ALL dependencies. do so with types
if write { if write {
this.link_dependencies(&filter_graph(&graph, prod), true) this.link_dependencies(&filter_graph(&graph, prod), true)
.instrument(tracing::debug_span!("link (all)"))
.await?; .await?;
} }

View file

@ -57,7 +57,7 @@ impl Project {
// step 1. link all non-wally packages (and their dependencies) temporarily without types // step 1. link all non-wally packages (and their dependencies) temporarily without types
// we do this separately to allow the required tools for the scripts to be installed // we do this separately to allow the required tools for the scripts to be installed
self.link(graph, &manifest, &Arc::new(Default::default())) self.link(graph, &manifest, &Arc::new(Default::default()), false)
.await?; .await?;
if !with_types { if !with_types {
@ -156,7 +156,8 @@ impl Project {
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();
// step 3. link all packages (and their dependencies), this time with types // step 3. link all packages (and their dependencies), this time with types
self.link(graph, &manifest, &Arc::new(package_types)).await self.link(graph, &manifest, &Arc::new(package_types), true)
.await
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
@ -245,6 +246,7 @@ impl Project {
graph: &DownloadedGraph, graph: &DownloadedGraph,
manifest: &Arc<Manifest>, manifest: &Arc<Manifest>,
package_types: &Arc<HashMap<&PackageNames, HashMap<&VersionId, Vec<String>>>>, package_types: &Arc<HashMap<&PackageNames, HashMap<&VersionId, Vec<String>>>>,
is_complete: bool,
) -> Result<(), errors::LinkingError> { ) -> Result<(), errors::LinkingError> {
try_join_all(graph.iter().flat_map(|(name, versions)| { try_join_all(graph.iter().flat_map(|(name, versions)| {
versions.iter().map(|(version_id, node)| { versions.iter().map(|(version_id, node)| {
@ -299,10 +301,14 @@ impl Project {
.get(dependency_name) .get(dependency_name)
.and_then(|v| v.get(dependency_version_id)) .and_then(|v| v.get(dependency_version_id))
else { else {
return Err(errors::LinkingError::DependencyNotFound( if is_complete {
dependency_name.to_string(), return Err(errors::LinkingError::DependencyNotFound(
dependency_version_id.to_string(), format!("{dependency_name}@{dependency_version_id}"),
)); format!("{name}@{version_id}"),
));
}
continue;
}; };
let base_folder = create_and_canonicalize( let base_folder = create_and_canonicalize(
@ -371,7 +377,7 @@ pub mod errors {
Io(#[from] std::io::Error), Io(#[from] std::io::Error),
/// A dependency was not found /// A dependency was not found
#[error("dependency not found: {0}@{1}")] #[error("dependency `{0}` of `{1}` not found")]
DependencyNotFound(String, String), DependencyNotFound(String, String),
/// The library file was not found /// The library file was not found