fix: correctly link Wally server packages

This commit is contained in:
daimond113 2024-11-16 10:40:37 +01:00
parent 4965d172be
commit be46042b51
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
15 changed files with 49 additions and 84 deletions

View file

@ -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
- Correctly link Wally server packages by @daimond113
## [0.5.0-rc.8] - 2024-11-12 ## [0.5.0-rc.8] - 2024-11-12
### Added ### Added
- Add `--index` flag to `publish` command to publish to a specific index by @daimond113 - Add `--index` flag to `publish` command to publish to a specific index by @daimond113

View file

@ -4,7 +4,6 @@ use clap::Args;
use pesde::{ use pesde::{
linking::generator::generate_bin_linking_module, linking::generator::generate_bin_linking_module,
names::{PackageName, PackageNames}, names::{PackageName, PackageNames},
source::traits::PackageRef,
Project, PACKAGES_CONTAINER_NAME, Project, PACKAGES_CONTAINER_NAME,
}; };
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
@ -87,7 +86,7 @@ impl RunCommand {
.await? .await?
.target .target
.kind() .kind()
.packages_folder(&node.node.pkg_ref.target_kind()); .packages_folder(version_id.target());
let container_folder = node.node.container_folder( let container_folder = node.node.container_folder(
&project &project
.package_dir() .package_dir()

View file

@ -72,7 +72,7 @@ impl Project {
let container_folder = node.container_folder( let container_folder = node.container_folder(
&package_dir &package_dir
.join(manifest_target_kind.packages_folder(&node.pkg_ref.target_kind())) .join(manifest_target_kind.packages_folder(version_id.target()))
.join(PACKAGES_CONTAINER_NAME), .join(PACKAGES_CONTAINER_NAME),
&name, &name,
version_id.version(), version_id.version(),

View file

@ -51,12 +51,7 @@ impl Project {
let container_folder = node.node.container_folder( let container_folder = node.node.container_folder(
&self &self
.package_dir() .package_dir()
.join( .join(manifest.target.kind().packages_folder(version_id.target()))
manifest
.target
.kind()
.packages_folder(&node.node.pkg_ref.target_kind()),
)
.join(PACKAGES_CONTAINER_NAME), .join(PACKAGES_CONTAINER_NAME),
name, name,
version_id.version(), version_id.version(),
@ -130,12 +125,8 @@ impl Project {
for (version_id, node) in versions { for (version_id, node) in versions {
let (node_container_folder, node_packages_folder) = { let (node_container_folder, node_packages_folder) = {
let base_folder = create_and_canonicalize( let base_folder = create_and_canonicalize(
self.package_dir().join( self.package_dir()
manifest .join(manifest.target.kind().packages_folder(version_id.target())),
.target
.kind()
.packages_folder(&node.node.pkg_ref.target_kind()),
),
) )
.await?; .await?;
let packages_container_folder = base_folder.join(PACKAGES_CONTAINER_NAME); let packages_container_folder = base_folder.join(PACKAGES_CONTAINER_NAME);
@ -214,10 +205,9 @@ impl Project {
let base_folder = create_and_canonicalize( let base_folder = create_and_canonicalize(
self.package_dir().join( self.package_dir().join(
node.node version_id
.pkg_ref .target()
.target_kind() .packages_folder(dependency_version_id.target()),
.packages_folder(&dependency_node.node.pkg_ref.target_kind()),
), ),
) )
.await?; .await?;
@ -230,8 +220,10 @@ impl Project {
); );
let linker_folder = create_and_canonicalize( let linker_folder = create_and_canonicalize(
node_container_folder node_container_folder.join(
.join(node.node.base_folder(dependency_node.target.kind())), node.node
.base_folder(version_id, dependency_node.target.kind()),
),
) )
.await?; .await?;

View file

@ -37,9 +37,9 @@ pub struct DependencyGraphNode {
} }
impl DependencyGraphNode { impl DependencyGraphNode {
pub(crate) fn base_folder(&self, project_target: TargetKind) -> String { pub(crate) fn base_folder(&self, version_id: &VersionId, project_target: TargetKind) -> String {
if self.pkg_ref.use_new_structure() { if self.pkg_ref.use_new_structure() {
self.pkg_ref.target_kind().packages_folder(&project_target) version_id.target().packages_folder(&project_target)
} else { } else {
"..".to_string() "..".to_string()
} }

View file

@ -1,7 +1,4 @@
use crate::{ use crate::{lockfile::DownloadedGraph, Project, MANIFEST_FILE_NAME, PACKAGES_CONTAINER_NAME};
lockfile::DownloadedGraph, source::traits::PackageRef, Project, MANIFEST_FILE_NAME,
PACKAGES_CONTAINER_NAME,
};
use fs_err::tokio as fs; use fs_err::tokio as fs;
use git2::{ApplyLocation, Diff, DiffFormat, DiffLineType, Repository, Signature}; use git2::{ApplyLocation, Diff, DiffFormat, DiffLineType, Repository, Signature};
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
@ -110,12 +107,7 @@ impl Project {
let container_folder = node.node.container_folder( let container_folder = node.node.container_folder(
&self &self
.package_dir() .package_dir()
.join( .join(manifest.target.kind().packages_folder(version_id.target()))
manifest
.target
.kind()
.packages_folder(&node.node.pkg_ref.target_kind()),
)
.join(PACKAGES_CONTAINER_NAME), .join(PACKAGES_CONTAINER_NAME),
&name, &name,
version_id.version(), version_id.version(),

View file

@ -328,7 +328,7 @@ impl Project {
.chain(std::iter::once(alias.to_string())) .chain(std::iter::once(alias.to_string()))
.collect(), .collect(),
overridden.is_some(), overridden.is_some(),
pkg_ref.target_kind(), *target_version_id.target(),
)); ));
} }
} }

View file

@ -272,8 +272,15 @@ impl PackageSource for GitPackageSource {
) )
})?; })?;
let name = PackageNames::Wally(manifest.package.name); let name = PackageNames::Wally(manifest.package.name);
let version_id = let version_id = VersionId(
VersionId(manifest.package.version, TargetKind::Roblox); manifest.package.version,
match manifest.package.realm {
crate::source::wally::manifest::Realm::Server => {
TargetKind::RobloxServer
}
_ => TargetKind::Roblox,
},
);
(name, version_id, dependencies) (name, version_id, dependencies)
} }
@ -300,7 +307,6 @@ impl PackageSource for GitPackageSource {
} }
}; };
let target = *version_id.target();
let new_structure = matches!(name, PackageNames::Pesde(_)); let new_structure = matches!(name, PackageNames::Pesde(_));
Ok(( Ok((
@ -310,7 +316,6 @@ impl PackageSource for GitPackageSource {
GitPackageRef { GitPackageRef {
repo: self.repo_url.clone(), repo: self.repo_url.clone(),
tree_id: tree.id.to_string(), tree_id: tree.id.to_string(),
target,
new_structure, new_structure,
dependencies, dependencies,
}, },
@ -333,10 +338,9 @@ impl PackageSource for GitPackageSource {
match fs::read_to_string(&index_file).await { match fs::read_to_string(&index_file).await {
Ok(s) => { Ok(s) => {
log::debug!( log::debug!(
"using cached index file for package {}#{} {}", "using cached index file for package {}#{}",
pkg_ref.repo, pkg_ref.repo,
pkg_ref.tree_id, pkg_ref.tree_id
pkg_ref.target
); );
let fs = toml::from_str::<PackageFS>(&s).map_err(|e| { let fs = toml::from_str::<PackageFS>(&s).map_err(|e| {

View file

@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use crate::{ use crate::{
manifest::{target::TargetKind, DependencyType}, manifest::DependencyType,
source::{git::GitPackageSource, DependencySpecifiers, PackageRef, PackageSources}, source::{git::GitPackageSource, DependencySpecifiers, PackageRef, PackageSources},
}; };
@ -22,8 +22,6 @@ pub struct GitPackageRef {
pub dependencies: BTreeMap<String, (DependencySpecifiers, DependencyType)>, pub dependencies: BTreeMap<String, (DependencySpecifiers, DependencyType)>,
/// Whether this package uses the new structure /// Whether this package uses the new structure
pub new_structure: bool, pub new_structure: bool,
/// The target of the package
pub target: TargetKind,
} }
impl PackageRef for GitPackageRef { impl PackageRef for GitPackageRef {
fn dependencies(&self) -> &BTreeMap<String, (DependencySpecifiers, DependencyType)> { fn dependencies(&self) -> &BTreeMap<String, (DependencySpecifiers, DependencyType)> {
@ -34,10 +32,6 @@ impl PackageRef for GitPackageRef {
self.new_structure self.new_structure
} }
fn target_kind(&self) -> TargetKind {
self.target
}
fn source(&self) -> PackageSources { fn source(&self) -> PackageSources {
PackageSources::Git(GitPackageSource::new(self.repo.clone())) PackageSources::Git(GitPackageSource::new(self.repo.clone()))
} }

View file

@ -4,10 +4,7 @@ use semver::Version;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
manifest::{ manifest::{target::Target, DependencyType},
target::{Target, TargetKind},
DependencyType,
},
names::PackageName, names::PackageName,
source::{pesde::PesdePackageSource, DependencySpecifiers, PackageRef, PackageSources}, source::{pesde::PesdePackageSource, DependencySpecifiers, PackageRef, PackageSources},
}; };
@ -40,10 +37,6 @@ impl PackageRef for PesdePackageRef {
true true
} }
fn target_kind(&self) -> TargetKind {
self.target.kind()
}
fn source(&self) -> PackageSources { fn source(&self) -> PackageSources {
PackageSources::Pesde(PesdePackageSource::new(self.index_url.clone())) PackageSources::Pesde(PesdePackageSource::new(self.index_url.clone()))
} }

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
manifest::{target::TargetKind, DependencyType}, manifest::DependencyType,
source::{pesde, specifiers::DependencySpecifiers, traits::PackageRef, PackageSources}, source::{pesde, specifiers::DependencySpecifiers, traits::PackageRef, PackageSources},
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -53,16 +53,6 @@ impl PackageRef for PackageRefs {
} }
} }
fn target_kind(&self) -> TargetKind {
match self {
PackageRefs::Pesde(pkg_ref) => pkg_ref.target_kind(),
#[cfg(feature = "wally-compat")]
PackageRefs::Wally(pkg_ref) => pkg_ref.target_kind(),
PackageRefs::Git(pkg_ref) => pkg_ref.target_kind(),
PackageRefs::Workspace(pkg_ref) => pkg_ref.target_kind(),
}
}
fn source(&self) -> PackageSources { fn source(&self) -> PackageSources {
match self { match self {
PackageRefs::Pesde(pkg_ref) => pkg_ref.source(), PackageRefs::Pesde(pkg_ref) => pkg_ref.source(),

View file

@ -22,8 +22,6 @@ pub trait PackageRef: Debug {
fn dependencies(&self) -> &BTreeMap<String, (DependencySpecifiers, DependencyType)>; fn dependencies(&self) -> &BTreeMap<String, (DependencySpecifiers, DependencyType)>;
/// Whether to use the new structure (`packages` folders inside the package's content folder) or the old structure (Wally-style, with linker files in the parent of the folder containing the package's contents) /// Whether to use the new structure (`packages` folders inside the package's content folder) or the old structure (Wally-style, with linker files in the parent of the folder containing the package's contents)
fn use_new_structure(&self) -> bool; fn use_new_structure(&self) -> bool;
/// The target of this package
fn target_kind(&self) -> TargetKind;
/// The source of this package /// The source of this package
fn source(&self) -> PackageSources; fn source(&self) -> PackageSources;
} }

View file

@ -6,7 +6,11 @@ use crate::{
git_index::{read_file, root_tree, GitBasedSource}, git_index::{read_file, root_tree, GitBasedSource},
traits::PackageSource, traits::PackageSource,
version_id::VersionId, version_id::VersionId,
wally::{compat_util::get_target, manifest::WallyManifest, pkg_ref::WallyPackageRef}, wally::{
compat_util::get_target,
manifest::{Realm, WallyManifest},
pkg_ref::WallyPackageRef,
},
IGNORED_DIRS, IGNORED_FILES, IGNORED_DIRS, IGNORED_FILES,
}, },
util::hash, util::hash,
@ -125,7 +129,13 @@ impl PackageSource for WallyPackageSource {
.filter(|manifest| specifier.version.matches(&manifest.package.version)) .filter(|manifest| specifier.version.matches(&manifest.package.version))
.map(|manifest| { .map(|manifest| {
Ok(( Ok((
VersionId(manifest.package.version.clone(), TargetKind::Roblox), VersionId(
manifest.package.version.clone(),
match manifest.package.realm {
Realm::Server => TargetKind::RobloxServer,
_ => TargetKind::Roblox,
},
),
WallyPackageRef { WallyPackageRef {
name: specifier.name.clone(), name: specifier.name.clone(),
index_url: self.repo_url.clone(), index_url: self.repo_url.clone(),

View file

@ -4,7 +4,7 @@ use semver::Version;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
manifest::{target::TargetKind, DependencyType}, manifest::DependencyType,
names::wally::WallyPackageName, names::wally::WallyPackageName,
source::{wally::WallyPackageSource, DependencySpecifiers, PackageRef, PackageSources}, source::{wally::WallyPackageSource, DependencySpecifiers, PackageRef, PackageSources},
}; };
@ -36,10 +36,6 @@ impl PackageRef for WallyPackageRef {
false false
} }
fn target_kind(&self) -> TargetKind {
TargetKind::Roblox
}
fn source(&self) -> PackageSources { fn source(&self) -> PackageSources {
PackageSources::Wally(WallyPackageSource::new(self.index_url.clone())) PackageSources::Wally(WallyPackageSource::new(self.index_url.clone()))
} }

View file

@ -3,10 +3,7 @@ use serde::{Deserialize, Serialize};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use crate::{ use crate::{
manifest::{ manifest::{target::Target, DependencyType},
target::{Target, TargetKind},
DependencyType,
},
source::{workspace::WorkspacePackageSource, DependencySpecifiers, PackageRef, PackageSources}, source::{workspace::WorkspacePackageSource, DependencySpecifiers, PackageRef, PackageSources},
}; };
@ -30,10 +27,6 @@ impl PackageRef for WorkspacePackageRef {
true true
} }
fn target_kind(&self) -> TargetKind {
self.target.kind()
}
fn source(&self) -> PackageSources { fn source(&self) -> PackageSources {
PackageSources::Workspace(WorkspacePackageSource) PackageSources::Workspace(WorkspacePackageSource)
} }