diff --git a/Cargo.lock b/Cargo.lock index 8630cf70..8b60dd86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,6 +564,7 @@ dependencies = [ "semver", "serde 1.0.197", "serde_json", + "serial_test", "shell-escape", "tempfile", "tokio", @@ -753,6 +754,19 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static 1.4.0", + "libc", + "unicode-width", + "windows-sys 0.52.0", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -879,6 +893,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 = "difflib" version = "0.4.0" @@ -984,6 +1011,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.34" @@ -1538,7 +1571,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.10", + "socket2 0.5.6", "tokio", "tower-service", "tracing", @@ -1856,7 +1889,16 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1" dependencies = [ - "logos-derive", + "logos-derive 0.13.0", +] + +[[package]] +name = "logos" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "161971eb88a0da7ae0c333e1063467c5b5727e7fb6b710b8db4814eade3a42e8" +dependencies = [ + "logos-derive 0.14.0", ] [[package]] @@ -1873,13 +1915,37 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "logos-codegen" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e31badd9de5131fdf4921f6473d457e3dd85b11b7f091ceb50e4df7c3eeb12a" +dependencies = [ + "beef", + "fnv", + "lazy_static 1.4.0", + "proc-macro2", + "quote", + "regex-syntax 0.8.3", + "syn 2.0.58", +] + [[package]] name = "logos-derive" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e" dependencies = [ - "logos-codegen", + "logos-codegen 0.13.0", +] + +[[package]] +name = "logos-derive" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c2a69b3eb68d5bd595107c9ee58d7e07fe2bb5e360cc85b0f084dedac80de0a" +dependencies = [ + "logos-codegen 0.14.0", ] [[package]] @@ -1914,21 +1980,21 @@ dependencies = [ [[package]] name = "miette" -version = "5.10.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" dependencies = [ + "cfg-if", "miette-derive", - "once_cell", "thiserror", "unicode-width", ] [[package]] name = "miette-derive" -version = "5.10.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", @@ -2586,11 +2652,11 @@ 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", + "logos 0.14.0", "miette", "once_cell", "prost", @@ -2608,9 +2674,9 @@ 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", @@ -2623,11 +2689,11 @@ 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", + "logos 0.13.0", "miette", "prost-types", "thiserror", @@ -2894,6 +2960,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scc" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc" +dependencies = [ + "sdd", +] + [[package]] name = "schannel" version = "0.1.23" @@ -2909,6 +2984,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sdd" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84345e4c9bd703274a082fb80caaa99b7612be48dfaa1dd9266577ec412309d" + [[package]] name = "sec1" version = "0.7.3" @@ -3127,6 +3208,31 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "serial_test" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +dependencies = [ + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "sha1" version = "0.10.6" @@ -3177,6 +3283,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" +[[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" @@ -3819,9 +3931,8 @@ dependencies = [ [[package]] name = "warg-api" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bf1e22e1e396b98a2181219b06d1a49a3478c1b9d87a29cd9cd819d714e6c3" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "indexmap 2.2.6", "itertools 0.12.1", @@ -3834,15 +3945,15 @@ dependencies = [ [[package]] name = "warg-client" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56cfaf9781ca2d084468bbdd8bbc1e35947bb2a19f8d3940d899852f6dd78aa" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "async-recursion", "async-trait", "bytes", "clap", + "dialoguer", "dirs", "futures-util", "indexmap 2.2.6", @@ -3878,9 +3989,8 @@ dependencies = [ [[package]] name = "warg-credentials" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "626224ba1a00965282b669d2611654fd6292a15396ed8c850ce91684678fe19f" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "indexmap 2.2.6", @@ -3892,9 +4002,8 @@ dependencies = [ [[package]] name = "warg-crypto" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a8c47e96a7f1903931b34db9a1f0d22bcb3761a203ee6861db686daaedcb4b" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "base64", @@ -3913,9 +4022,8 @@ dependencies = [ [[package]] name = "warg-protobuf" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed0e698efd0fab8bb747efd452156a65149eb389f7fe2a6b6b3ced4e25ab24" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "pbjson", @@ -3932,9 +4040,8 @@ dependencies = [ [[package]] name = "warg-protocol" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69be98a2e9e0aeace7cbd62184b11462d259c5e391e6208d59506c9a2d33571c" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "base64", @@ -3955,9 +4062,8 @@ dependencies = [ [[package]] name = "warg-server" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07f15457ced83df5c2298f225fc83b6700e93c7bf320a2e4ef01114c0b34d7ce" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "axum", @@ -3986,9 +4092,8 @@ dependencies = [ [[package]] name = "warg-transparency" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d272b3002b9e5f6f636817089ba091e1ba7b85858e72529f96e24bc9827f530" +version = "0.5.0-dev" +source = "git+https://github.com/calvinrp/bytecodealliance-registry?rev=3eb6368#3eb63685df8f485d84ffefb35216e387ea31eab7" dependencies = [ "anyhow", "indexmap 2.2.6", diff --git a/Cargo.toml b/Cargo.toml index 5604333a..36a651b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,17 +63,18 @@ wat = { workspace = true } warg-server = { workspace = true } tempfile = { workspace = true } wasmprinter = { workspace = true } +serial_test = { workspace = true } [workspace] members = ["crates/core", "crates/wit"] [workspace.dependencies] cargo-component-core = { path = "crates/core", version = "0.11.0" } -warg-protocol = "0.4.1" -warg-crypto = "0.4.1" -warg-client = "0.4.1" -warg-credentials = "0.4.1" -warg-server = "0.4.1" +warg-protocol = { git = "https://github.com/calvinrp/bytecodealliance-registry", rev = "3eb6368" } +warg-crypto = { git = "https://github.com/calvinrp/bytecodealliance-registry", rev = "3eb6368" } +warg-client = { git = "https://github.com/calvinrp/bytecodealliance-registry", rev = "3eb6368" } +warg-credentials = { git = "https://github.com/calvinrp/bytecodealliance-registry", rev = "3eb6368" } +warg-server = { git = "https://github.com/calvinrp/bytecodealliance-registry", rev = "3eb6368" } anyhow = "1.0.82" clap = { version = "4.5.4", features = ["derive"] } toml_edit = { version = "0.22.9", features = ["serde"] } @@ -111,6 +112,7 @@ predicates = "3.1.0" wasmparser = "0.202.0" wat = "1.202.0" wasmprinter = "0.202.0" +serial_test = "3.1.1" [profile.release] panic = "abort" diff --git a/crates/core/src/registry.rs b/crates/core/src/registry.rs index 5879d9bf..a00c37e2 100644 --- a/crates/core/src/registry.rs +++ b/crates/core/src/registry.rs @@ -23,7 +23,7 @@ use std::{ }; use url::Url; use warg_client::{ - storage::{ContentStorage, PackageInfo, RegistryStorage}, + storage::{ContentStorage, PackageInfo}, Config, FileSystemClient, RegistryUrl, StorageLockResult, }; use warg_credentials::keyring::get_auth_token; @@ -591,7 +591,7 @@ impl<'a> DependencyResolver<'a> { let client = registry.client.clone(); futures.push(tokio::spawn(async move { - (index, client.upsert(upserts.iter()).await) + (index, client.fetch_packages(upserts.iter()).await) })) } @@ -877,13 +877,10 @@ impl<'a> Registry<'a> { ) -> Result> { match packages.entry(name) { hash_map::Entry::Occupied(e) => Ok(Some(e.into_mut())), - hash_map::Entry::Vacant(e) => match client - .registry() - .load_package(client.get_warg_registry(), e.key()) - .await? - { - Some(p) => Ok(Some(e.insert(p))), - None => Ok(None), + hash_map::Entry::Vacant(e) => match client.package(e.key()).await { + Ok(p) => Ok(Some(e.insert(p))), + Err(warg_client::ClientError::PackageDoesNotExist { .. }) => Ok(None), + Err(err) => Err(err.into()), }, } } diff --git a/crates/wit/src/lib.rs b/crates/wit/src/lib.rs index 37d1dad8..300052de 100644 --- a/crates/wit/src/lib.rs +++ b/crates/wit/src/lib.rs @@ -328,8 +328,7 @@ async fn publish_wit_package(options: PublishOptions<'_>, terminal: &Terminal) - let bytes = add_registry_metadata(options.config, &bytes)?; let name = options.package.unwrap_or(&name); - let mut client = create_client(options.warg_config, options.url, terminal)?; - client.refresh_namespace(name.namespace()).await?; + let client = create_client(options.warg_config, options.url, terminal)?; let content = client .content() diff --git a/crates/wit/tests/support/mod.rs b/crates/wit/tests/support/mod.rs index 696c2f99..2e54df4c 100644 --- a/crates/wit/tests/support/mod.rs +++ b/crates/wit/tests/support/mod.rs @@ -118,6 +118,9 @@ pub async fn spawn_server(root: &Path) -> Result<(ServerInstance, warg_client::C namespace_map_path: Some(root.join("namespaces")), keys: IndexSet::new(), keyring_auth: false, + ignore_federation_hints: false, + auto_accept_federation_hints: false, + disable_dialoguer: true, }; Ok((instance, config)) diff --git a/src/lib.rs b/src/lib.rs index 9148fe70..ec959619 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1095,8 +1095,7 @@ pub async fn publish(config: &Config, options: &PublishOptions<'_>) -> Result<() return Ok(()); } - let mut client = create_client(config.warg(), options.registry_url, config.terminal())?; - client.refresh_namespace(options.name.namespace()).await?; + let client = create_client(config.warg(), options.registry_url, config.terminal())?; let bytes = fs::read(options.path).with_context(|| { format!( diff --git a/tests/build.rs b/tests/build.rs index 2999b9bd..ed1a6b1c 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -2,6 +2,7 @@ use crate::support::*; use anyhow::{Context, Result}; use assert_cmd::prelude::*; use predicates::{prelude::PredicateBooleanExt, str::contains}; +use serial_test::serial; use std::{fs, process::Command, rc::Rc}; use tempfile::TempDir; use toml_edit::{value, Array, Item, Table}; @@ -9,6 +10,7 @@ use toml_edit::{value, Array, Item, Table}; mod support; #[test] +#[serial] fn it_builds_debug() -> Result<()> { let project = Project::new("foo")?; @@ -28,6 +30,7 @@ fn it_builds_debug() -> Result<()> { } #[test] +#[serial] fn it_builds_a_bin_project_with_snake_case() -> Result<()> { let project = Project::new_bin("hello_world")?; @@ -43,6 +46,7 @@ fn it_builds_a_bin_project_with_snake_case() -> Result<()> { } #[test] +#[serial] fn it_builds_a_bin_project() -> Result<()> { let project = Project::new_bin("foo")?; @@ -58,6 +62,7 @@ fn it_builds_a_bin_project() -> Result<()> { } #[test] +#[serial] fn it_builds_a_workspace() -> Result<()> { let dir = Rc::new(TempDir::new()?); let project = Project { @@ -111,6 +116,7 @@ edition = "2021" } #[test] +#[serial] fn it_supports_wit_keywords() -> Result<()> { let project = Project::new("interface")?; @@ -126,6 +132,7 @@ fn it_supports_wit_keywords() -> Result<()> { } #[test] +#[serial] fn it_adds_a_producers_field() -> Result<()> { let project = Project::new("foo")?; @@ -156,6 +163,7 @@ fn it_adds_a_producers_field() -> Result<()> { } #[test] +#[serial] fn it_builds_wasm32_unknown_unknown() -> Result<()> { let project = Project::new("foo")?; @@ -177,6 +185,7 @@ fn it_builds_wasm32_unknown_unknown() -> Result<()> { } #[test] +#[serial] fn it_regenerates_target_if_wit_changed() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -210,6 +219,7 @@ fn it_regenerates_target_if_wit_changed() -> Result<()> { } #[test] +#[serial] fn it_builds_with_local_wit_deps() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -302,6 +312,7 @@ bindings::export!(Component with_types_in bindings); } #[test] +#[serial] fn empty_world_with_dep_valid() -> Result<()> { let project = Project::new("dep")?; @@ -378,6 +389,7 @@ fn empty_world_with_dep_valid() -> Result<()> { } #[test] +#[serial] fn it_builds_with_resources() -> Result<()> { let project = Project::new("foo")?; @@ -446,6 +458,7 @@ fn it_builds_with_resources() -> Result<()> { } #[test] +#[serial] fn it_builds_resources_with_specified_ownership_model() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -519,6 +532,7 @@ fn it_builds_resources_with_specified_ownership_model() -> Result<()> { } #[test] +#[serial] fn it_builds_with_a_component_dependency() -> Result<()> { let dir = Rc::new(TempDir::new()?); let comp1 = Project::with_dir(dir.clone(), "comp1", "")?; @@ -637,6 +651,7 @@ bindings::export!(Component with_types_in bindings); } #[test] +#[serial] fn it_builds_with_adapter() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -669,6 +684,7 @@ fn it_builds_with_adapter() -> Result<()> { } #[test] +#[serial] fn it_errors_if_adapter_is_not_wasm() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -688,6 +704,7 @@ fn it_errors_if_adapter_is_not_wasm() -> Result<()> { } #[test] +#[serial] fn it_adds_additional_derives() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -760,6 +777,7 @@ bindings::export!(Component with_types_in bindings); } #[test] +#[serial] fn it_builds_with_versioned_wit() -> Result<()> { let project = Project::new("foo")?; @@ -803,6 +821,7 @@ fn it_builds_with_versioned_wit() -> Result<()> { } #[test] +#[serial] fn it_warns_on_proxy_setting_for_command() -> Result<()> { let project = Project::new_bin("foo")?; project.update_manifest(|mut doc| { @@ -824,6 +843,7 @@ fn it_warns_on_proxy_setting_for_command() -> Result<()> { } #[test] +#[serial] fn it_warns_with_proxy_and_adapter_settings() -> Result<()> { let project = Project::new("foo")?; project.update_manifest(|mut doc| { @@ -845,6 +865,7 @@ fn it_warns_with_proxy_and_adapter_settings() -> Result<()> { } #[test] +#[serial] fn it_builds_with_proxy_adapter() -> Result<()> { let dir = Rc::new(TempDir::new()?); let project = Project::with_dir(dir.clone(), "foo", "--proxy")?; @@ -867,6 +888,7 @@ fn it_builds_with_proxy_adapter() -> Result<()> { } #[test] +#[serial] fn it_does_not_generate_bindings_for_cargo_projects() -> Result<()> { let dir = TempDir::new()?; diff --git a/tests/publish.rs b/tests/publish.rs index b8c05645..95309b3f 100644 --- a/tests/publish.rs +++ b/tests/publish.rs @@ -90,7 +90,9 @@ world foo { .cargo_component("publish") .env("CARGO_COMPONENT_PUBLISH_KEY", test_signing_key()) .assert() - .stderr(contains("error: package `test:foo` does not exist")) + .stderr(contains( + "package `test:foo` must be initialized before publishing", + )) .failure(); Ok(()) diff --git a/tests/support/mod.rs b/tests/support/mod.rs index e92d8b74..d8e16362 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -194,6 +194,9 @@ pub async fn spawn_server(root: &Path) -> Result<(ServerInstance, warg_client::C namespace_map_path: Some(root.join("namespaces")), keys: IndexSet::new(), keyring_auth: false, + ignore_federation_hints: false, + auto_accept_federation_hints: false, + disable_dialoguer: true, }; Ok((instance, config))