diff --git a/Cargo.lock b/Cargo.lock index 98a7ef9d5..59accbaca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4016,22 +4016,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wapm-toml" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "994ef26447f3158955d2e3fca96021d1f1c47b830e2053569177673dca1447a9" -dependencies = [ - "anyhow", - "semver 1.0.14", - "serde", - "serde_cbor", - "serde_json", - "serde_yaml", - "thiserror", - "toml", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -4348,7 +4332,6 @@ dependencies = [ "unix_mode", "url", "walkdir", - "wapm-toml", "wasmer", "wasmer-cache", "wasmer-compiler", @@ -4358,6 +4341,7 @@ dependencies = [ "wasmer-emscripten", "wasmer-object", "wasmer-registry", + "wasmer-toml", "wasmer-types", "wasmer-vfs", "wasmer-vm", @@ -4596,11 +4580,27 @@ dependencies = [ "tokio", "toml", "url", - "wapm-toml", + "wasmer-toml", "webc", "whoami", ] +[[package]] +name = "wasmer-toml" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d0f664e5dfad0339727ad2f4f8a7d982b4c120d87b800380e306c0dc038a49" +dependencies = [ + "anyhow", + "semver 1.0.14", + "serde", + "serde_cbor", + "serde_json", + "serde_yaml", + "thiserror", + "toml", +] + [[package]] name = "wasmer-types" version = "3.1.0" diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 6a8274381..0062558e3 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -63,7 +63,7 @@ dirs = { version = "4.0" } serde_json = { version = "1.0" } target-lexicon = { version = "0.12", features = ["std"] } prettytable-rs = "0.9.0" -wapm-toml = "0.4.0" +wasmer-toml = "0.5.0" walkdir = "2.3.2" regex = "1.6.0" toml = "0.5.9" diff --git a/lib/cli/src/commands/init.rs b/lib/cli/src/commands/init.rs index c837885bb..363cfc7b2 100644 --- a/lib/cli/src/commands/init.rs +++ b/lib/cli/src/commands/init.rs @@ -146,7 +146,10 @@ impl Init { } /// Writes the metadata to a wasmer.toml file - fn write_wasmer_toml(path: &PathBuf, toml: &wapm_toml::Manifest) -> Result<(), anyhow::Error> { + fn write_wasmer_toml( + path: &PathBuf, + toml: &wasmer_toml::Manifest, + ) -> Result<(), anyhow::Error> { let toml_string = toml::to_string_pretty(&toml)? .replace( "[dependencies]", @@ -221,15 +224,15 @@ impl Init { } fn get_command( - modules: &[wapm_toml::Module], + modules: &[wasmer_toml::Module], bin_or_lib: BinOrLib, - ) -> Option> { + ) -> Option> { match bin_or_lib { BinOrLib::Bin => Some( modules .iter() .map(|m| { - wapm_toml::Command::V1(wapm_toml::CommandV1 { + wasmer_toml::Command::V1(wasmer_toml::CommandV1 { name: m.name.clone(), module: m.name.clone(), main_args: None, @@ -291,12 +294,12 @@ impl Init { let is_wit = e.path().extension().and_then(|s| s.to_str()) == Some(".wit"); let is_wai = e.path().extension().and_then(|s| s.to_str()) == Some(".wai"); if is_wit { - Some(wapm_toml::Bindings::Wit(wapm_toml::WitBindings { + Some(wasmer_toml::Bindings::Wit(wasmer_toml::WitBindings { wit_exports: e.path().to_path_buf(), wit_bindgen: semver::Version::parse("0.1.0").unwrap(), })) } else if is_wai { - Some(wapm_toml::Bindings::Wai(wapm_toml::WaiBindings { + Some(wasmer_toml::Bindings::Wai(wasmer_toml::WaiBindings { exports: None, imports: vec![e.path().to_path_buf()], wai_version: semver::Version::parse("0.2.0").unwrap(), @@ -320,12 +323,12 @@ impl Init { } enum GetBindingsResult { - OneBinding(wapm_toml::Bindings), - MultiBindings(Vec), + OneBinding(wasmer_toml::Bindings), + MultiBindings(Vec), } impl GetBindingsResult { - fn first_binding(&self) -> Option { + fn first_binding(&self) -> Option { match self { Self::OneBinding(s) => Some(s.clone()), Self::MultiBindings(s) => s.get(0).cloned(), @@ -346,7 +349,7 @@ fn construct_manifest( template: Option<&Template>, include_fs: &[String], quiet: bool, -) -> wapm_toml::Manifest { +) -> wasmer_toml::Manifest { if let Some(ct) = cargo_toml.as_ref() { let msg = format!( "NOTE: Initializing wasmer.toml file with metadata from Cargo.toml{NEWLINE} -> {}", @@ -381,17 +384,17 @@ fn construct_manifest( .and_then(|t| t.description.clone()) .unwrap_or_else(|| format!("Description for package {package_name}")); - let default_abi = wapm_toml::Abi::Wasi; + let default_abi = wasmer_toml::Abi::Wasi; let bindings = Init::get_bindings(target_file, bin_or_lib); if let Some(GetBindingsResult::MultiBindings(m)) = bindings.as_ref() { let found = m .iter() .map(|m| match m { - wapm_toml::Bindings::Wit(wb) => { + wasmer_toml::Bindings::Wit(wb) => { format!("found: {}", serde_json::to_string(wb).unwrap_or_default()) } - wapm_toml::Bindings::Wai(wb) => { + wasmer_toml::Bindings::Wai(wb) => { format!("found: {}", serde_json::to_string(wb).unwrap_or_default()) } }) @@ -412,7 +415,7 @@ fn construct_manifest( log::warn!("{msg}"); } - let modules = vec![wapm_toml::Module { + let modules = vec![wasmer_toml::Module { name: package_name.to_string(), source: cargo_toml .as_ref() @@ -443,8 +446,8 @@ fn construct_manifest( }), }]; - wapm_toml::Manifest { - package: wapm_toml::Package { + wasmer_toml::Manifest { + package: wasmer_toml::Package { name: if let Some(s) = namespace { format!("{s}/{package_name}") } else { diff --git a/lib/cli/src/commands/publish.rs b/lib/cli/src/commands/publish.rs index 09ec31502..36a5d74ce 100644 --- a/lib/cli/src/commands/publish.rs +++ b/lib/cli/src/commands/publish.rs @@ -74,7 +74,7 @@ impl Publish { let manifest = std::fs::read_to_string(&manifest_path_buf) .map_err(|e| anyhow::anyhow!("could not find manifest: {e}")) .with_context(|| anyhow::anyhow!("{}", manifest_path_buf.display()))?; - let mut manifest = wapm_toml::Manifest::parse(&manifest)?; + let mut manifest = wasmer_toml::Manifest::parse(&manifest)?; manifest.base_directory_path = cwd.clone(); if let Some(package_name) = self.package_name.as_ref() { @@ -158,7 +158,7 @@ impl Publish { fn construct_tar_gz( builder: &mut tar::Builder>, - manifest: &wapm_toml::Manifest, + manifest: &wasmer_toml::Manifest, cwd: &Path, ) -> Result<(Option, Option), anyhow::Error> { let package = &manifest.package; @@ -523,7 +523,7 @@ mod validate { use wasmer_wasm_interface::{validate, Interface}; pub fn validate_directory( - manifest: &wapm_toml::Manifest, + manifest: &wasmer_toml::Manifest, registry: &str, pkg_path: PathBuf, ) -> anyhow::Result<()> { @@ -606,7 +606,7 @@ mod validate { } fn validate_bindings( - bindings: &wapm_toml::Bindings, + bindings: &wasmer_toml::Bindings, base_directory_path: &Path, ) -> Result<(), ValidationError> { // Note: checking for referenced files will make sure they all exist. @@ -624,7 +624,7 @@ mod validate { #[error("Failed to read file {file}; {error}")] MiscCannotRead { file: String, error: String }, #[error(transparent)] - Imports(#[from] wapm_toml::ImportsError), + Imports(#[from] wasmer_toml::ImportsError), } // legacy function, validates wasm. TODO: clean up diff --git a/lib/registry/Cargo.toml b/lib/registry/Cargo.toml index 2750c9e54..af96584af 100644 --- a/lib/registry/Cargo.toml +++ b/lib/registry/Cargo.toml @@ -20,7 +20,7 @@ serde_json = "1.0.85" url = "2.3.1" thiserror = "1.0.37" toml = "0.5.9" -wapm-toml = "0.4.0" +wasmer-toml = "0.5.0" tar = "0.4.38" flate2 = "1.0.24" semver = "1.0.14" diff --git a/lib/registry/src/lib.rs b/lib/registry/src/lib.rs index 9d8518dd0..c126b0d28 100644 --- a/lib/registry/src/lib.rs +++ b/lib/registry/src/lib.rs @@ -126,7 +126,7 @@ impl LocalPackage { } /// Reads the wasmer.toml fron $PATH with wapm.toml as a fallback - pub fn read_toml(base_path: &Path) -> Result { + pub fn read_toml(base_path: &Path) -> Result { let wasmer_toml = std::fs::read_to_string(base_path.join(PACKAGE_TOML_FILE_NAME)) .or_else(|_| std::fs::read_to_string(base_path.join(PACKAGE_TOML_FALLBACK_NAME))) .map_err(|_| { @@ -135,7 +135,7 @@ impl LocalPackage { base_path.display() ) })?; - let wasmer_toml = toml::from_str::(&wasmer_toml) + let wasmer_toml = toml::from_str::(&wasmer_toml) .map_err(|e| format!("Could not parse toml for {:?}: {e}", base_path.display()))?; Ok(wasmer_toml) } @@ -159,7 +159,7 @@ impl LocalPackage { pub fn get_executable_file_from_path( package_dir: &Path, command: Option<&str>, -) -> Result<(wapm_toml::Manifest, PathBuf), anyhow::Error> { +) -> Result<(wasmer_toml::Manifest, PathBuf), anyhow::Error> { let wasmer_toml = LocalPackage::read_toml(package_dir).map_err(|e| anyhow::anyhow!("{e}"))?; let name = wasmer_toml.package.name.clone(); @@ -406,7 +406,7 @@ pub fn query_package_from_registry( QueryPackageError::ErrorSendingQuery(format!("no package version for {name:?}")) })?; - let manifest = toml::from_str::(&v.manifest).map_err(|e| { + let manifest = toml::from_str::(&v.manifest).map_err(|e| { QueryPackageError::ErrorSendingQuery(format!("Invalid manifest for crate {name:?}: {e}")) })?; diff --git a/lib/registry/src/publish.rs b/lib/registry/src/publish.rs index 6c67405ec..6988586bb 100644 --- a/lib/registry/src/publish.rs +++ b/lib/registry/src/publish.rs @@ -26,7 +26,7 @@ pub enum SignArchiveResult { pub fn try_chunked_uploading( registry: Option, token: Option, - package: &wapm_toml::Package, + package: &wasmer_toml::Package, manifest_string: &String, license_file: &Option, readme: &Option,