diff --git a/.gitignore b/.gitignore index 3c58539..e9868cc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ Cargo.lock **/*.rs.bk *.pdb publish +*.swp diff --git a/Cargo.lock b/Cargo.lock index 3e12d94..4745589 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -775,6 +775,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "dialoguer" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" +dependencies = [ + "console", + "shell-words", + "tempfile", + "thiserror", + "zeroize", +] + [[package]] name = "diff" version = "0.1.13" @@ -1428,7 +1441,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -1656,9 +1669,9 @@ dependencies = [ [[package]] name = "keyring" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be8bc4c6b6e9d85ecdad090fcf342a9216f53d747a537cc05e3452fd650ca46" +checksum = "363387f0019d714aa60cc30ab4fe501a747f4c08fc58f069dd14be971bd495a0" dependencies = [ "byteorder", "lazy_static 1.4.0", @@ -1854,18 +1867,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "miette" -version = "5.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" -dependencies = [ - "miette-derive 5.10.0", - "once_cell", - "thiserror", - "unicode-width", -] - [[package]] name = "miette" version = "7.2.0" @@ -1875,7 +1876,7 @@ dependencies = [ "backtrace", "backtrace-ext", "cfg-if", - "miette-derive 7.2.0", + "miette-derive", "owo-colors", "serde 1.0.197", "supports-color 3.0.0", @@ -1887,17 +1888,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "miette-derive" -version = "5.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.57", -] - [[package]] name = "miette-derive" version = "7.2.0" @@ -2544,12 +2534,12 @@ dependencies = [ [[package]] name = "prost-reflect" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057237efdb71cf4b3f9396302a3d6599a92fa94063ba537b66130980ea9909f3" +checksum = "6f5eec97d5d34bdd17ad2db2219aabf46b054c6c41bd5529767c9ce55be5898f" dependencies = [ - "logos 0.13.0", - "miette 5.10.0", + "logos 0.14.0", + "miette", "once_cell", "prost", "prost-types", @@ -2566,12 +2556,12 @@ dependencies = [ [[package]] name = "protox" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00bb76c5f6221de491fe2c8f39b106330bbd9762c6511119c07940e10eb9ff11" +checksum = "a29b3c5596eb23a849deba860b53ffd468199d9ad5fe4402a7d55379e16aa2d2" dependencies = [ "bytes", - "miette 5.10.0", + "miette", "prost", "prost-reflect", "prost-types", @@ -2581,12 +2571,12 @@ dependencies = [ [[package]] name = "protox-parse" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4581f441c58863525a3e6bec7b8de98188cf75239a56c725a3e7288450a33f" +checksum = "033b939d76d358f7c32120c86c71f515bae45e64f2bde455200356557276276c" dependencies = [ "logos 0.13.0", - "miette 5.10.0", + "miette", "prost-types", "thiserror", ] @@ -3174,6 +3164,12 @@ dependencies = [ "lazy_static 1.4.0", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3850,7 +3846,7 @@ dependencies = [ "indexmap 2.2.6", "indicatif", "log", - "miette 7.2.0", + "miette", "owo-colors", "pretty_env_logger", "semver", @@ -3899,7 +3895,7 @@ dependencies = [ "indexmap 2.2.6", "log", "logos 0.14.0", - "miette 7.2.0", + "miette", "owo-colors", "pretty_assertions", "pretty_env_logger", @@ -3925,9 +3921,8 @@ dependencies = [ "futures", "indexmap 2.2.6", "log", - "miette 7.2.0", + "miette", "pretty_assertions", - "secrecy", "semver", "tempdir", "thiserror", @@ -3937,7 +3932,6 @@ dependencies = [ "wac-parser", "wac-types", "warg-client", - "warg-credentials", "warg-crypto", "warg-protocol", "warg-server", @@ -3987,9 +3981,9 @@ dependencies = [ [[package]] name = "warg-api" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bf1e22e1e396b98a2181219b06d1a49a3478c1b9d87a29cd9cd819d714e6c3" +checksum = "b08e86feb745fa5a4e9b3ed8c53ca7353ce474c9164573e7963c65eab0e20998" dependencies = [ "indexmap 2.2.6", "itertools 0.12.1", @@ -4002,19 +3996,21 @@ dependencies = [ [[package]] name = "warg-client" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56cfaf9781ca2d084468bbdd8bbc1e35947bb2a19f8d3940d899852f6dd78aa" +checksum = "ecb95cdddbc52c73e774d6d555412bb8060156f1ac666df733c18bdeb923c22c" dependencies = [ "anyhow", "async-recursion", "async-trait", "bytes", "clap", + "dialoguer", "dirs", "futures-util", "indexmap 2.2.6", "itertools 0.12.1", + "keyring", "libc", "normpath", "once_cell", @@ -4044,25 +4040,11 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "warg-credentials" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626224ba1a00965282b669d2611654fd6292a15396ed8c850ce91684678fe19f" -dependencies = [ - "anyhow", - "indexmap 2.2.6", - "keyring", - "secrecy", - "warg-client", - "warg-crypto", -] - [[package]] name = "warg-crypto" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a8c47e96a7f1903931b34db9a1f0d22bcb3761a203ee6861db686daaedcb4b" +checksum = "79344c8bd2cf133533ce6352b6491fbb343e374a8c09527073adda5015c89c92" dependencies = [ "anyhow", "base64", @@ -4081,9 +4063,9 @@ dependencies = [ [[package]] name = "warg-protobuf" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed0e698efd0fab8bb747efd452156a65149eb389f7fe2a6b6b3ced4e25ab24" +checksum = "975e38d2ddba1d26f46713d75cccecf3769ebaae7d14b0dcb830d207867c50bf" dependencies = [ "anyhow", "pbjson", @@ -4100,9 +4082,9 @@ dependencies = [ [[package]] name = "warg-protocol" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69be98a2e9e0aeace7cbd62184b11462d259c5e391e6208d59506c9a2d33571c" +checksum = "fb997bf019742f796123539e9c9031d3ec8ed973950a0534e1f6af508e27e4f1" dependencies = [ "anyhow", "base64", @@ -4123,9 +4105,9 @@ dependencies = [ [[package]] name = "warg-server" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07f15457ced83df5c2298f225fc83b6700e93c7bf320a2e4ef01114c0b34d7ce" +checksum = "a8ada7d9f5ec554959501509b60229da52f5bd0e535b6b83eef2ca4f7f47d127" dependencies = [ "anyhow", "axum", @@ -4154,9 +4136,9 @@ dependencies = [ [[package]] name = "warg-transparency" -version = "0.4.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d272b3002b9e5f6f636817089ba091e1ba7b85858e72529f96e24bc9827f530" +checksum = "f04b4573fd7c7ebee61f5b4645b464e7dcd656386d0ca4c77b37533ad1bb98d9" dependencies = [ "anyhow", "indexmap 2.2.6", diff --git a/Cargo.toml b/Cargo.toml index cafdad1..6d9185d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,10 +40,10 @@ semver = { workspace = true } indicatif = { workspace = true, optional = true } [features] -default = ["wit"] +default = ["wit", "registry"] wat = ["wac-resolver/wat"] wit = ["wac-resolver/wit"] -registry = ["wac-resolver/registry", "indicatif"] +registry = ["wac-resolver/registry", "dep:indicatif"] [workspace.dependencies] wac-parser = { path = "crates/wac-parser", version = "0.1.0", default-features = false } @@ -71,12 +71,10 @@ wat = "1.202.0" logos = "0.14.0" miette = "7.2.0" thiserror = "1.0.58" -warg-client = "0.4.1" -warg-protocol = "0.4.1" -warg-crypto = "0.4.1" -warg-server = "0.4.1" -warg-credentials = "0.4.1" -secrecy = "0.8.0" +warg-client = "0.6.0" +warg-protocol = "0.6.0" +warg-crypto = "0.6.0" +warg-server = "0.6.0" futures = "0.3.30" indicatif = "0.17.8" pretty_assertions = "1.4.0" diff --git a/README.md b/README.md index 24952b6..01a73e1 100644 --- a/README.md +++ b/README.md @@ -84,12 +84,6 @@ For a full description of the `wac` language see [the language guide](LANGUAGE.m cargo install wac-cli ``` -To enable support Warg component registries, specify the `registry` feature: - -``` -cargo install wac-cli --features registry -``` - ## Usage The `wac` CLI tool has three commands: diff --git a/crates/wac-resolver/Cargo.toml b/crates/wac-resolver/Cargo.toml index 7ff8349..8aa8a38 100644 --- a/crates/wac-resolver/Cargo.toml +++ b/crates/wac-resolver/Cargo.toml @@ -24,8 +24,6 @@ miette = { workspace = true } warg-client = { workspace = true, optional = true } warg-protocol = { workspace = true, optional = true } warg-crypto = { workspace = true, optional = true } -warg-credentials = { workspace = true, optional = true } -secrecy = { workspace = true, optional = true } tokio = { workspace = true, optional = true } futures = { workspace = true, optional = true } @@ -40,5 +38,5 @@ tempdir = "0.3.7" [features] default = ["registry"] wat = ["dep:wat"] -wit = ["wit-parser"] -registry = ["warg-client", "warg-protocol", "warg-crypto", "warg-credentials", "secrecy", "tokio", "futures"] +wit = ["dep:wit-parser"] +registry = ["dep:warg-client", "dep:warg-protocol", "dep:warg-crypto", "dep:tokio", "dep:futures"] diff --git a/crates/wac-resolver/src/lib.rs b/crates/wac-resolver/src/lib.rs index 9476351..a22f05c 100644 --- a/crates/wac-resolver/src/lib.rs +++ b/crates/wac-resolver/src/lib.rs @@ -28,6 +28,15 @@ pub enum Error { #[label(primary, "unknown package `{name}`")] span: SourceSpan, }, + /// An invalid package name was encountered. + #[error("invalid package name `{name}`")] + InvalidPackageName { + /// The name of the package. + name: String, + /// The span where the error occurred. + #[label(primary, "invalid package name `{name}`")] + span: SourceSpan, + }, /// An unknown package version was encountered. #[cfg(feature = "registry")] #[error("version {version} of package `{name}` does not exist")] @@ -56,22 +65,22 @@ pub enum Error { #[label(primary, "package `{name}` does not exist")] span: SourceSpan, }, - /// The requested package version has been yanked. + /// The requested package version has been yanked or does not exist. #[cfg(feature = "registry")] - #[error("version {version} of package `{name}` has been yanked")] - PackageVersionYanked { + #[error("version {version} of package `{name}` has been yanked or does not exist")] + PackageVersionYankedOrDoesNotExist { /// The name of the package. name: String, - /// The version of the package that has been yanked. + /// The version of the package. version: semver::Version, /// The span where the error occurred. - #[label(primary, "{version} has been yanked")] + #[label(primary, "{version} has been yanked or does not exist")] span: SourceSpan, }, - /// A package log was empty. + /// A package has no releases. #[cfg(feature = "registry")] - #[error("a release for package `{name}` has not yet been published")] - PackageLogEmpty { + #[error("package `{name}` has no releases")] + PackageNoReleases { /// The name of the package. name: String, /// The span where the error occurred. diff --git a/crates/wac-resolver/src/registry.rs b/crates/wac-resolver/src/registry.rs index 6bb20d8..bd6463f 100644 --- a/crates/wac-resolver/src/registry.rs +++ b/crates/wac-resolver/src/registry.rs @@ -1,18 +1,13 @@ use super::Error; use anyhow::Result; use futures::{stream::FuturesUnordered, StreamExt}; -use indexmap::{IndexMap, IndexSet}; +use indexmap::IndexMap; use miette::SourceSpan; -use secrecy::Secret; -use semver::{Comparator, Op, Version, VersionReq}; +use semver::{Version, VersionReq}; use std::{fs, path::Path, sync::Arc}; use wac_types::BorrowedPackageKey; -use warg_client::{ - storage::{ContentStorage, RegistryStorage}, - Client, ClientError, Config, FileSystemClient, RegistryUrl, -}; -use warg_credentials::keyring::get_auth_token; -use warg_crypto::hash::AnyHash; +use warg_client::{Client, ClientError, Config, FileSystemClient}; +use warg_protocol::registry::PackageName; /// Implemented by progress bars. /// @@ -46,13 +41,8 @@ impl RegistryPackageResolver { /// /// If `url` is `None`, the default URL will be used. pub fn new(url: Option<&str>, bar: Option>) -> Result { - let config = Config::from_default_file()?.unwrap_or_default(); Ok(Self { - client: Arc::new(Client::new_with_config( - url, - &config, - Self::auth_token(&config, url)?, - )?), + client: Arc::new(Client::new_with_default_config(url)?), bar, }) } @@ -66,11 +56,7 @@ impl RegistryPackageResolver { bar: Option>, ) -> Result { Ok(Self { - client: Arc::new(Client::new_with_config( - url, - config, - Self::auth_token(config, url)?, - )?), + client: Arc::new(Client::new_with_config(url, config, None)?), bar, }) } @@ -82,242 +68,120 @@ impl RegistryPackageResolver { &self, keys: &IndexMap, SourceSpan>, ) -> Result, Vec>, Error> { - // Start by fetching any required package logs - self.fetch(keys).await?; - - // All the logs have been updated, now we need to see what content - // is missing from local storage. - let mut packages = IndexMap::new(); - let missing = self.find_missing_content(keys, &mut packages).await?; + // parses into `PackageName` and maps back to `SourceSpan` + let package_names_with_source_span = keys + .iter() + .map(|(key, span)| { + Ok(( + PackageName::new(key.name.to_string()).map_err(|_| { + Error::InvalidPackageName { + name: key.name.to_string(), + span: *span, + } + })?, + (key.version.cloned(), *span), + )) + }) + .collect::, SourceSpan)>, Error>>()?; + + // fetch required package logs and return error if any not found + if let Some(bar) = self.bar.as_ref() { + bar.init(1); + bar.println("Updating", "package logs from the registry"); + } - if !missing.is_empty() { - if let Some(bar) = self.bar.as_ref() { - bar.init(missing.len()); - bar.println("Downloading", "package content from the registry"); + match self + .client + .fetch_packages(package_names_with_source_span.keys()) + .await + { + Ok(_) => {} + Err(ClientError::PackageDoesNotExist { name, .. }) => { + return Err(Error::PackageDoesNotExist { + name: name.to_string(), + span: package_names_with_source_span.get(&name).unwrap().1, + }); } - - let mut tasks = FuturesUnordered::new(); - for (index, hash) in missing.keys().enumerate() { - let client = self.client.clone(); - let hash = hash.clone(); - tasks.push(tokio::spawn(async move { - Ok((index, client.download_content(&hash).await?)) - })); + Err(err) => { + return Err(Error::RegistryUpdateFailure { source: err.into() }); } + } - let count = tasks.len(); - let mut finished = 0; - while let Some(res) = tasks.next().await { - let (index, path) = res - .unwrap() - .map_err(|e| Error::RegistryDownloadFailure { source: e })?; - - let (hash, (version, set)) = missing.get_index(index).unwrap(); - log::debug!("downloaded content `{hash}`"); - - finished += 1; - - if let Some(bar) = self.bar.as_ref() { - bar.inc(1); - let first = set.first().unwrap(); - bar.println( - "Downloaded", - &format!("package `{name}` {version} ({hash})", name = first.name), - ) - } - - let contents = Self::read_contents(&path)?; - for key in set { - packages.insert(*key, contents.clone()); - } - } + if let Some(bar) = self.bar.as_ref() { + bar.inc(1); + bar.finish(); - assert_eq!(finished, count); + // download package content if not in cache + bar.init(keys.len()); + bar.println("Downloading", "package content from the registry"); + } - if let Some(bar) = self.bar.as_ref() { - bar.finish(); - } + let mut tasks = FuturesUnordered::new(); + for (index, (package_name, (version, span))) in + package_names_with_source_span.into_iter().enumerate() + { + let client = self.client.clone(); + tasks.push(tokio::spawn(async move { + Ok(( + index, + if let Some(version) = version { + client + .download_exact(&package_name, &version) + .await + .map_err(|err| match err { + ClientError::PackageVersionDoesNotExist { name, version } => { + Error::PackageVersionYankedOrDoesNotExist { + name: name.to_string(), + version, + span, + } + } + err => Error::RegistryDownloadFailure { source: err.into() }, + })? + } else { + client + .download(&package_name, &VersionReq::STAR) + .await + .map_err(|err| Error::RegistryDownloadFailure { source: err.into() })? + .ok_or_else(|| Error::PackageNoReleases { + name: package_name.to_string(), + span, + })? + }, + )) + })); } - Ok(packages) - } + let mut packages = IndexMap::with_capacity(keys.len()); + let count = tasks.len(); + let mut finished = 0; - async fn fetch<'a>( - &self, - keys: &IndexMap, SourceSpan>, - ) -> Result<(), Error> { - // First check if we already have the packages in client storage. - // If not, we'll fetch the logs from the registry. - let mut fetch = IndexMap::new(); - for (key, span) in keys { - let id = - key.name - .parse() - .map_err(|e: anyhow::Error| Error::PackageResolutionFailure { - name: key.name.to_string(), - span: *span, - source: e, - })?; + while let Some(res) = tasks.next().await { + let (index, download) = res.unwrap()?; - // Load the package from client storage to see if we already - // have a matching version present. - if let Some(info) = self - .client - .registry() - .load_package(self.client.get_warg_registry(), &id) - .await - .map_err(|e| Error::PackageResolutionFailure { - name: key.name.to_string(), - span: *span, - source: e, - })? - { - if let Some(version) = key.version { - let req = VersionReq { - comparators: vec![Comparator { - op: Op::Exact, - major: version.major, - minor: Some(version.minor), - patch: Some(version.patch), - pre: version.pre.clone(), - }], - }; + finished += 1; - // Version already present, no need to fetch the log - if info.state.find_latest_release(&req).is_some() { - log::debug!( - "package log for `{name}` has a release version {version}", - name = key.name - ); - continue; - } - } - } + let (key, _) = keys.get_index(index).unwrap(); - fetch.entry(id).or_insert_with(|| { - log::debug!( - "fetching log for package `{name}` from the registry", - name = key.name - ); - span - }); - } - - // Fetch the logs - if !fetch.is_empty() { if let Some(bar) = self.bar.as_ref() { - bar.init(1); - bar.println("Updating", "package logs from the registry"); + bar.inc(1); + let BorrowedPackageKey { name, .. } = key; + bar.println( + "Downloaded", + &format!("package `{name}` {version}", version = download.version), + ) } - match self.client.upsert(fetch.keys()).await { - Ok(_) => { - if let Some(bar) = self.bar.as_ref() { - bar.inc(1); - bar.finish(); - } - } - Err(ClientError::PackageDoesNotExist { name }) => { - return Err(Error::PackageDoesNotExist { - name: name.to_string(), - span: *fetch[&name], - }) - } - Err(e) => { - return Err(Error::RegistryUpdateFailure { source: e.into() }); - } - } + packages.insert(*key, Self::read_contents(&download.path)?); } - Ok(()) - } - - async fn find_missing_content<'a>( - &self, - keys: &IndexMap, SourceSpan>, - packages: &mut IndexMap, Vec>, - ) -> Result>)>, Error> { - let mut downloads: IndexMap)> = - IndexMap::new(); - for (key, span) in keys { - let id = - key.name - .parse() - .map_err(|e: anyhow::Error| Error::PackageResolutionFailure { - name: key.name.to_string(), - span: *span, - source: e, - })?; + assert_eq!(finished, count); - let info = self - .client - .registry() - .load_package(self.client.get_warg_registry(), &id) - .await - .map_err(|e| Error::PackageResolutionFailure { - name: key.name.to_string(), - span: *span, - source: e, - })? - .expect("package log should be present after fetching"); - - let req = match key.version { - Some(v) => VersionReq { - comparators: vec![Comparator { - op: Op::Exact, - major: v.major, - minor: Some(v.minor), - patch: Some(v.patch), - pre: v.pre.clone(), - }], - }, - None => VersionReq::STAR, - }; - - let release = match info.state.find_latest_release(&req) { - Some(release) if !release.yanked() => release, - Some(release) => { - return Err(Error::PackageVersionYanked { - name: key.name.to_string(), - version: release.version.clone(), - span: *span, - }); - } - None => { - if let Some(version) = key.version { - return Err(Error::UnknownPackageVersion { - name: key.name.to_string(), - version: version.clone(), - span: *span, - }); - } else { - return Err(Error::PackageLogEmpty { - name: key.name.to_string(), - span: *span, - }); - } - } - }; - - let hash = release.content().unwrap(); - if let Some(path) = self.client.content().content_location(hash) { - packages.insert(*key, Self::read_contents(&path)?); - } else { - log::debug!( - "downloading content for version {version} of package `{name}`", - name = key.name, - version = release.version - ); - - downloads - .entry(hash.clone()) - .or_insert_with(|| (release.version.clone(), Default::default())) - .1 - .insert(*key); - } + if let Some(bar) = self.bar.as_ref() { + bar.finish(); } - Ok(downloads) + Ok(packages) } fn read_contents(path: &Path) -> Result, Error> { @@ -326,18 +190,4 @@ impl RegistryPackageResolver { source: e.into(), }) } - - pub fn auth_token(config: &Config, url: Option<&str>) -> Result>> { - if config.keyring_auth { - return if let Some(url) = url { - Ok(get_auth_token(&RegistryUrl::new(url)?)?) - } else if let Some(url) = config.home_url.as_ref() { - Ok(get_auth_token(&RegistryUrl::new(url)?)?) - } else { - Ok(None) - }; - } - - Ok(None) - } } diff --git a/crates/wac-resolver/tests/support/mod.rs b/crates/wac-resolver/tests/support/mod.rs index afe77c5..a3339df 100644 --- a/crates/wac-resolver/tests/support/mod.rs +++ b/crates/wac-resolver/tests/support/mod.rs @@ -149,6 +149,9 @@ pub async fn spawn_server(root: &Path) -> Result<(ServerInstance, warg_client::C namespace_map_path: Some(root.join("namespaces")), keyring_auth: false, keys: Default::default(), + ignore_federation_hints: false, + auto_accept_federation_hints: false, + disable_interactive: true, }; Ok((instance, config)) diff --git a/src/commands/plug.rs b/src/commands/plug.rs index 41198dc..fc3815c 100644 --- a/src/commands/plug.rs +++ b/src/commands/plug.rs @@ -108,7 +108,7 @@ impl PlugCommand { } match &self.output { Some(path) => { - std::fs::write(&path, bytes).context(format!( + std::fs::write(path, bytes).context(format!( "failed to write output file `{path}`", path = path.display() ))?; @@ -143,7 +143,10 @@ fn plug_into_socket( let mut checker = SubtypeChecker::new(&mut cache); for (name, plug_ty) in &graph.types()[graph[plug].ty()].exports { if let Some(socket_ty) = graph.types()[graph[socket].ty()].imports.get(name) { - if let Ok(_) = checker.is_subtype(*plug_ty, graph.types(), *socket_ty, graph.types()) { + if checker + .is_subtype(*plug_ty, graph.types(), *socket_ty, graph.types()) + .is_ok() + { plugs.push(name.clone()); } }