mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-13 11:50:36 +00:00
fix: correctly resolve peer dependencies
This commit is contained in:
parent
e9bb21835c
commit
a067fbd4bd
9 changed files with 29 additions and 22 deletions
|
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Fixed
|
||||||
|
- Fix peer dependencies being resolved incorrectly by @daimond113
|
||||||
|
|
||||||
## [0.5.0-rc.11] - 2024-11-20
|
## [0.5.0-rc.11] - 2024-11-20
|
||||||
### Fixed
|
### Fixed
|
||||||
- Add back mistakenly removed updates check caching by @daimond113
|
- Add back mistakenly removed updates check caching by @daimond113
|
||||||
|
|
|
@ -231,7 +231,7 @@ impl InstallCommand {
|
||||||
(
|
(
|
||||||
n,
|
n,
|
||||||
v.into_iter()
|
v.into_iter()
|
||||||
.filter(|(_, n)| n.node.ty != DependencyType::Dev)
|
.filter(|(_, n)| n.node.resolved_ty != DependencyType::Dev)
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -268,7 +268,7 @@ impl InstallCommand {
|
||||||
.flat_map(|versions| versions.values())
|
.flat_map(|versions| versions.values())
|
||||||
.filter(|node| node.target.bin_path().is_some())
|
.filter(|node| node.target.bin_path().is_some())
|
||||||
.filter_map(|node| node.node.direct.as_ref())
|
.filter_map(|node| node.node.direct.as_ref())
|
||||||
.map(|(alias, _)| alias)
|
.map(|(alias, _, _)| alias)
|
||||||
.filter(|alias| {
|
.filter(|alias| {
|
||||||
if *alias == env!("CARGO_BIN_NAME") {
|
if *alias == env!("CARGO_BIN_NAME") {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl OutdatedCommand {
|
||||||
.map(|(current_version_id, node)| {
|
.map(|(current_version_id, node)| {
|
||||||
let project = project.clone();
|
let project = project.clone();
|
||||||
async move {
|
async move {
|
||||||
let Some((alias, mut specifier)) = node.node.direct else {
|
let Some((alias, mut specifier, _)) = node.node.direct else {
|
||||||
return Ok::<(), anyhow::Error>(());
|
return Ok::<(), anyhow::Error>(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ impl PublishCommand {
|
||||||
.filter_map(|(_, node)| node.node.direct.as_ref().map(|_| node))
|
.filter_map(|(_, node)| node.node.direct.as_ref().map(|_| node))
|
||||||
.any(|node| {
|
.any(|node| {
|
||||||
node.target.build_files().is_none()
|
node.target.build_files().is_none()
|
||||||
&& !matches!(node.node.ty, DependencyType::Dev)
|
&& !matches!(node.node.resolved_ty, DependencyType::Dev)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
anyhow::bail!("roblox packages may not depend on non-roblox packages");
|
anyhow::bail!("roblox packages may not depend on non-roblox packages");
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub async fn up_to_date_lockfile(project: &Project) -> anyhow::Result<Option<Loc
|
||||||
node.node
|
node.node
|
||||||
.direct
|
.direct
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(_, spec)| (spec, node.node.ty))
|
.map(|(_, spec, source_ty)| (spec, source_ty))
|
||||||
})
|
})
|
||||||
.collect::<HashSet<_>>();
|
.collect::<HashSet<_>>();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ pub async fn up_to_date_lockfile(project: &Project) -> anyhow::Result<Option<Loc
|
||||||
.all_dependencies()
|
.all_dependencies()
|
||||||
.context("failed to get all dependencies")?
|
.context("failed to get all dependencies")?
|
||||||
.iter()
|
.iter()
|
||||||
.all(|(_, (spec, ty))| specs.contains(&(spec, *ty)));
|
.all(|(_, (spec, ty))| specs.contains(&(spec, ty)));
|
||||||
|
|
||||||
log::debug!("dependencies are the same: {same_dependencies}");
|
log::debug!("dependencies are the same: {same_dependencies}");
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl Project {
|
||||||
log::debug!("downloaded {name}@{version_id}");
|
log::debug!("downloaded {name}@{version_id}");
|
||||||
|
|
||||||
if write {
|
if write {
|
||||||
if !prod || node.ty != DependencyType::Dev {
|
if !prod || node.resolved_ty != DependencyType::Dev {
|
||||||
match fs.write_to(container_folder, project.cas_dir(), true).await {
|
match fs.write_to(container_folder, project.cas_dir(), true).await {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -137,7 +137,7 @@ impl Project {
|
||||||
version_id.version(),
|
version_id.version(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some((alias, _)) = &node.node.direct.as_ref() {
|
if let Some((alias, _, _)) = &node.node.direct.as_ref() {
|
||||||
if let Some((lib_file, types)) =
|
if let Some((lib_file, types)) =
|
||||||
node.target.lib_path().and_then(|lib_file| {
|
node.target.lib_path().and_then(|lib_file| {
|
||||||
package_types
|
package_types
|
||||||
|
|
|
@ -24,14 +24,14 @@ pub type Graph<Node> = BTreeMap<PackageNames, BTreeMap<VersionId, Node>>;
|
||||||
/// A dependency graph node
|
/// A dependency graph node
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct DependencyGraphNode {
|
pub struct DependencyGraphNode {
|
||||||
/// The alias and specifiers for the dependency, if it is a direct dependency (i.e. used by the current project)
|
/// The alias, specifier, and original (as in the manifest) type for the dependency, if it is a direct dependency (i.e. used by the current project)
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub direct: Option<(String, DependencySpecifiers)>,
|
pub direct: Option<(String, DependencySpecifiers, DependencyType)>,
|
||||||
/// The dependencies of the package
|
/// The dependencies of the package
|
||||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub dependencies: BTreeMap<PackageNames, (VersionId, String)>,
|
pub dependencies: BTreeMap<PackageNames, (VersionId, String)>,
|
||||||
/// The type of the dependency
|
/// The resolved (transformed, for example Peer -> Standard) type of the dependency
|
||||||
pub ty: DependencyType,
|
pub resolved_ty: DependencyType,
|
||||||
/// The package reference
|
/// The package reference
|
||||||
pub pkg_ref: PackageRefs,
|
pub pkg_ref: PackageRefs,
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl Project {
|
||||||
if let Some(previous_graph) = previous_graph {
|
if let Some(previous_graph) = previous_graph {
|
||||||
for (name, versions) in previous_graph {
|
for (name, versions) in previous_graph {
|
||||||
for (version, node) in versions {
|
for (version, node) in versions {
|
||||||
let Some((_, specifier)) = &node.direct else {
|
let Some((_, specifier, source_ty)) = &node.direct else {
|
||||||
// this is not a direct dependency, will be added if it's still being used later
|
// this is not a direct dependency, will be added if it's still being used later
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,8 @@ impl Project {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(alias) = all_specifiers.remove(&(specifier.clone(), node.ty)) else {
|
let Some(alias) = all_specifiers.remove(&(specifier.clone(), *source_ty))
|
||||||
|
else {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"dependency {name}@{version} from old dependency graph is no longer in the manifest",
|
"dependency {name}@{version} from old dependency graph is no longer in the manifest",
|
||||||
);
|
);
|
||||||
|
@ -60,7 +61,7 @@ impl Project {
|
||||||
name.clone(),
|
name.clone(),
|
||||||
version.clone(),
|
version.clone(),
|
||||||
DependencyGraphNode {
|
DependencyGraphNode {
|
||||||
direct: Some((alias.clone(), specifier.clone())),
|
direct: Some((alias.clone(), specifier.clone(), *source_ty)),
|
||||||
..node.clone()
|
..node.clone()
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
@ -218,7 +219,7 @@ impl Project {
|
||||||
)));
|
)));
|
||||||
};
|
};
|
||||||
|
|
||||||
let ty = if depth == 0 && ty == DependencyType::Peer {
|
let resolved_ty = if depth == 0 && ty == DependencyType::Peer {
|
||||||
DependencyType::Standard
|
DependencyType::Standard
|
||||||
} else {
|
} else {
|
||||||
ty
|
ty
|
||||||
|
@ -255,12 +256,14 @@ impl Project {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if already_resolved.ty == DependencyType::Peer && ty == DependencyType::Standard {
|
if already_resolved.resolved_ty == DependencyType::Peer
|
||||||
already_resolved.ty = ty;
|
&& resolved_ty == DependencyType::Standard
|
||||||
|
{
|
||||||
|
already_resolved.resolved_ty = resolved_ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if already_resolved.direct.is_none() && depth == 0 {
|
if already_resolved.direct.is_none() && depth == 0 {
|
||||||
already_resolved.direct = Some((alias.clone(), specifier.clone()));
|
already_resolved.direct = Some((alias.clone(), specifier.clone(), ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -268,13 +271,13 @@ impl Project {
|
||||||
|
|
||||||
let node = DependencyGraphNode {
|
let node = DependencyGraphNode {
|
||||||
direct: if depth == 0 {
|
direct: if depth == 0 {
|
||||||
Some((alias.clone(), specifier.clone()))
|
Some((alias.clone(), specifier.clone(), ty))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
pkg_ref: pkg_ref.clone(),
|
pkg_ref: pkg_ref.clone(),
|
||||||
dependencies: Default::default(),
|
dependencies: Default::default(),
|
||||||
ty,
|
resolved_ty,
|
||||||
};
|
};
|
||||||
insert_node(
|
insert_node(
|
||||||
&mut graph,
|
&mut graph,
|
||||||
|
@ -335,7 +338,7 @@ impl Project {
|
||||||
|
|
||||||
for (name, versions) in &graph {
|
for (name, versions) in &graph {
|
||||||
for (version_id, node) in versions {
|
for (version_id, node) in versions {
|
||||||
if node.ty == DependencyType::Peer {
|
if node.resolved_ty == DependencyType::Peer {
|
||||||
log::warn!("peer dependency {name}@{version_id} was not resolved");
|
log::warn!("peer dependency {name}@{version_id} was not resolved");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue