diff --git a/Cargo.toml b/Cargo.toml index 9accc69..907821b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,6 @@ bin = [ "tokio/rt", "tokio/rt-multi-thread", "tokio/macros", - "dep:tempfile", ] wally-compat = ["dep:async_zip", "dep:serde_json"] patches = ["dep:git2"] @@ -65,6 +64,7 @@ full_moon = { version = "1.1.2", features = ["luau"] } url = { version = "2.5.4", features = ["serde"] } chrono = { version = "0.4.39", features = ["serde"] } sha2 = "0.10.8" +tempfile = "3.14.0" wax = { version = "0.6.0", default-features = false } fs-err = { version = "3.0.0", features = ["tokio"] } @@ -86,7 +86,6 @@ dirs = { version = "5.0.1", optional = true } tracing-subscriber = { version = "0.3.19", features = ["env-filter"], optional = true } indicatif = { version = "0.17.9", optional = true } inquire = { version = "0.7.5", optional = true } -tempfile = { version = "3.14.0", optional = true } [target.'cfg(target_os = "windows")'.dependencies] winreg = { version = "0.52.0", optional = true } diff --git a/src/cli/install.rs b/src/cli/install.rs index fcd9e22..1c04ddb 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -14,8 +14,8 @@ use anyhow::Context; use colored::Colorize; use fs_err::tokio as fs; use pesde::{ - download_and_link::{filter_graph, DownloadAndLinkHooks, DownloadAndLinkOptions}, - graph::{ConvertableGraph, DependencyGraph, DownloadedGraph}, + download_and_link::{DownloadAndLinkHooks, DownloadAndLinkOptions}, + graph::{DependencyGraph, DownloadedGraph}, lockfile::Lockfile, manifest::{target::TargetKind, DependencyType}, Project, RefreshedSources, LOCKFILE_FILE_NAME, MANIFEST_FILE_NAME, @@ -258,11 +258,17 @@ pub async fn install( bin_folder: bin_dir().await?, }; + #[allow(unused_variables)] let downloaded_graph = project .download_and_link( &graph, DownloadAndLinkOptions::::new(reqwest.clone()) - .reporter(reporter.clone()) + .reporter( + #[cfg(feature = "patches")] + reporter.clone(), + #[cfg(not(feature = "patches"))] + reporter, + ) .hooks(hooks) .refreshed_sources(refreshed_sources) .prod(options.prod) @@ -274,6 +280,8 @@ pub async fn install( #[cfg(feature = "patches")] if options.write { + use pesde::{download_and_link::filter_graph, graph::ConvertableGraph}; + root_progress.reset(); root_progress.set_length(0); root_progress.set_message("patch"); diff --git a/src/cli/mod.rs b/src/cli/mod.rs index f798d88..319b140 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -11,9 +11,7 @@ use pesde::{ }, names::{PackageName, PackageNames}, source::{ - ids::{PackageId, VersionId}, - specifiers::DependencySpecifiers, - workspace::specifier::VersionTypeOrReq, + ids::VersionId, specifiers::DependencySpecifiers, workspace::specifier::VersionTypeOrReq, }, Project, }; @@ -165,7 +163,10 @@ impl, E: Into, N: FromStr, F: Into anyhow::Result { + fn get( + self, + graph: &pesde::graph::DependencyGraph, + ) -> anyhow::Result { let version_id = match self.1 { Some(version) => version, None => { @@ -189,7 +190,7 @@ impl VersionedPackageName { } }; - Ok(PackageId::new(self.0, version_id)) + Ok(pesde::source::ids::PackageId::new(self.0, version_id)) } } diff --git a/src/source/git/mod.rs b/src/source/git/mod.rs index ca69d94..ce47490 100644 --- a/src/source/git/mod.rs +++ b/src/source/git/mod.rs @@ -1,9 +1,6 @@ use crate::{ deser_manifest, - manifest::{ - target::{Target, TargetKind}, - Manifest, - }, + manifest::{target::Target, Manifest}, names::PackageNames, reporters::DownloadProgressReporter, source::{ @@ -12,7 +9,6 @@ use crate::{ git_index::{read_file, GitBasedSource}, specifiers::DependencySpecifiers, traits::{DownloadOptions, GetTargetOptions, PackageRef, RefreshOptions, ResolveOptions}, - wally::compat_util::get_target, PackageSource, ResolveResult, VersionId, IGNORED_DIRS, IGNORED_FILES, }, util::hash, @@ -266,43 +262,43 @@ impl PackageSource for GitPackageSource { #[cfg(feature = "wally-compat")] None => { - match read_file( - &tree, - [crate::source::wally::compat_util::WALLY_MANIFEST_FILE_NAME], - ) - .map_err(|e| { + use crate::{ + manifest::target::TargetKind, + source::wally::{ + compat_util::WALLY_MANIFEST_FILE_NAME, + manifest::{Realm, WallyManifest}, + }, + }; + + match read_file(&tree, [WALLY_MANIFEST_FILE_NAME]).map_err(|e| { errors::ResolveError::ReadManifest(Box::new(self.repo_url.clone()), e) })? { - Some(m) => { - match toml::from_str::(&m) { - Ok(manifest) => { - let dependencies = manifest.all_dependencies().map_err(|e| { - errors::ResolveError::CollectDependencies( - Box::new(self.repo_url.clone()), - e, - ) - })?; - let name = PackageNames::Wally(manifest.package.name); - let version_id = VersionId( - manifest.package.version, - match manifest.package.realm { - crate::source::wally::manifest::Realm::Server => { - TargetKind::RobloxServer - } - _ => TargetKind::Roblox, - }, - ); - - (name, version_id, dependencies) - } - Err(e) => { - return Err(errors::ResolveError::DeserManifest( + Some(m) => match toml::from_str::(&m) { + Ok(manifest) => { + let dependencies = manifest.all_dependencies().map_err(|e| { + errors::ResolveError::CollectDependencies( Box::new(self.repo_url.clone()), e, - )) - } + ) + })?; + let name = PackageNames::Wally(manifest.package.name); + let version_id = VersionId( + manifest.package.version, + match manifest.package.realm { + Realm::Server => TargetKind::RobloxServer, + _ => TargetKind::Roblox, + }, + ); + + (name, version_id, dependencies) } - } + Err(e) => { + return Err(errors::ResolveError::DeserManifest( + Box::new(self.repo_url.clone()), + e, + )) + } + }, None => { return Err(errors::ResolveError::NoManifest(Box::new( self.repo_url.clone(), @@ -509,19 +505,22 @@ impl PackageSource for GitPackageSource { #[instrument(skip_all, level = "debug")] async fn get_target( &self, - _pkg_ref: &Self::Ref, + pkg_ref: &Self::Ref, options: &GetTargetOptions, ) -> Result { - match deser_manifest(&options.path).await { - Ok(manifest) => Ok(manifest.target), + if !pkg_ref.new_structure { #[cfg(feature = "wally-compat")] - Err(crate::errors::ManifestReadError::Io(e)) - if e.kind() == std::io::ErrorKind::NotFound => - { - get_target(options).await.map_err(Into::into) - } - Err(e) => Err(e.into()), + return crate::source::wally::compat_util::get_target(options) + .await + .map_err(Into::into); + #[cfg(not(feature = "wally-compat"))] + panic!("wally-compat feature is not enabled, and package is a wally package"); } + + deser_manifest(&options.path) + .await + .map(|m| m.target) + .map_err(Into::into) } } diff --git a/src/source/pesde/mod.rs b/src/source/pesde/mod.rs index c9a4d46..1c7406d 100644 --- a/src/source/pesde/mod.rs +++ b/src/source/pesde/mod.rs @@ -297,6 +297,7 @@ impl PackageSource for PesdePackageSource { options: &GetTargetOptions, ) -> Result { let GetTargetOptions { id, .. } = options; + #[allow(irrefutable_let_patterns)] let PackageNames::Pesde(name) = id.name() else { panic!("unexpected package name"); }; diff --git a/src/util.rs b/src/util.rs index cb942d9..ffc908e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -50,6 +50,7 @@ pub fn deserialize_gix_url_map<'de, D: Deserializer<'de>>( .collect() } +#[allow(dead_code)] pub fn deserialize_gix_url_vec<'de, D: Deserializer<'de>>( deserializer: D, ) -> Result, D::Error> {