diff --git a/CHANGELOG.md b/CHANGELOG.md index d35682515..ad704ec2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ - [Rust](https://github.com/moonrepo/rust-plugin/blob/master/CHANGELOG.md) - [TOML schema](https://github.com/moonrepo/schema-plugin/blob/master/CHANGELOG.md) +## Unreleased + +#### Updates + +- Added support to plugins to ignore certain paths when detecting a version. +- WASM API + - Added `DetectVersionOutput.ignore` field. + ## 0.22.2 #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index 40f3b24b4..e6ec4c74b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,9 +455,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -465,9 +465,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -481,7 +481,7 @@ version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" dependencies = [ - "clap 4.4.7", + "clap 4.4.8", ] [[package]] @@ -1844,9 +1844,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "link-cplusplus" @@ -2061,14 +2061,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.6" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", - "log", "wasi", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2304,7 +2303,7 @@ name = "proto_cli" version = "0.22.2" dependencies = [ "chrono", - "clap 4.4.7", + "clap 4.4.8", "clap_complete", "convert_case", "dialoguer", @@ -3023,9 +3022,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -3446,9 +3445,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -3458,7 +3457,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.5", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -3466,9 +3465,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d137a16bf..2c0cbf172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ default-members = ["crates/cli"] [workspace.dependencies] cached = "0.46.1" -clap = "4.4.7" +clap = "4.4.8" clap_complete = "4.4.4" convert_case = "0.6.0" extism = { version = "0.5.4" } @@ -39,7 +39,7 @@ starbase_utils = { version = "0.3.7", default-features = false, features = [ "toml", ] } thiserror = "1.0.50" -tokio = { version = "1.33.0", features = ["full", "tracing"] } +tokio = { version = "1.34.0", features = ["full", "tracing"] } tracing = "0.1.40" # Config for 'cargo dist' diff --git a/crates/core/src/tool.rs b/crates/core/src/tool.rs index 6495493dd..a4298ffaa 100644 --- a/crates/core/src/tool.rs +++ b/crates/core/src/tool.rs @@ -546,14 +546,17 @@ impl Tool { return Ok(None); } - // TODO move this into plugins - if current_dir.to_string_lossy().contains("node_modules") { - return Ok(None); - } - let has_parser = self.plugin.has_func("parse_version_file"); let result: DetectVersionOutput = self.plugin.cache_func("detect_version_files")?; + if !result.ignore.is_empty() { + if let Some(dir) = current_dir.to_str() { + if result.ignore.iter().any(|ignore| dir.contains(ignore)) { + return Ok(None); + } + } + } + trace!( tool = self.id.as_str(), dir = ?current_dir, @@ -593,6 +596,7 @@ impl Tool { debug!( tool = self.id.as_str(), file = ?file_path, + version = version.to_string(), "Detected a version" ); diff --git a/crates/pdk-api/src/api.rs b/crates/pdk-api/src/api.rs index d378550b9..ebe6afa1d 100644 --- a/crates/pdk-api/src/api.rs +++ b/crates/pdk-api/src/api.rs @@ -8,6 +8,14 @@ use warpgate_api::VirtualPath; pub use semver::{Version, VersionReq}; +fn is_empty_map(value: &HashMap) -> bool { + value.is_empty() +} + +fn is_empty_vec(value: &[T]) -> bool { + value.is_empty() +} + fn is_false(value: &bool) -> bool { !(*value) } @@ -103,6 +111,7 @@ json_struct!( /// Names of commands that will self-upgrade the tool, /// and should be blocked from happening. + #[serde(skip_serializing_if = "is_empty_vec")] pub self_upgrade_commands: Vec, /// Type of the tool. @@ -117,7 +126,12 @@ json_struct!( /// Output returned by the `detect_version_files` function. pub struct DetectVersionOutput { /// List of files that should be checked for version information. + #[serde(skip_serializing_if = "is_empty_vec")] pub files: Vec, + + /// List of path patterns to ignore when traversing directories. + #[serde(skip_serializing_if = "is_empty_vec")] + pub ignore: Vec, } ); @@ -241,10 +255,12 @@ json_struct!( /// List of instructions to execute to build the tool, after system /// dependencies have been installed. + #[serde(skip_serializing_if = "is_empty_vec")] pub instructions: Vec, /// List of system dependencies that are required for building from source. /// If a dependency does not exist, it will be installed. + #[serde(skip_serializing_if = "is_empty_vec")] pub system_dependencies: Vec, } ); @@ -401,6 +417,7 @@ json_struct!( pub struct LocateExecutablesOutput { /// List of directory paths to find the globals installation directory. /// Each path supports environment variable expansion. + #[serde(skip_serializing_if = "is_empty_vec")] pub globals_lookup_dirs: Vec, /// A string that all global binaries are prefixed with, and will be removed @@ -415,6 +432,7 @@ json_struct!( /// Configures secondary/additional executables to create. /// The map key is the name of the shim/binary file. + #[serde(skip_serializing_if = "is_empty_map")] pub secondary: HashMap, } ); @@ -525,9 +543,11 @@ json_struct!( pub latest: Option, /// Mapping of aliases (channels, etc) to a version. + #[serde(skip_serializing_if = "is_empty_map")] pub aliases: HashMap, /// List of available production versions to install. + #[serde(skip_serializing_if = "is_empty_vec")] pub versions: Vec, } ); diff --git a/plugins/Cargo.lock b/plugins/Cargo.lock index ee41331be..3eb730784 100644 --- a/plugins/Cargo.lock +++ b/plugins/Cargo.lock @@ -238,9 +238,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cached" -version = "0.46.0" +version = "0.46.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cead8ece0da6b744b2ad8ef9c58a4cdc7ef2921e60a6ddfb9eaaa86839b5fc5" +checksum = "c7c8c50262271cdf5abc979a5f76515c234e764fa025d1ba4862c0f0bcda0e95" dependencies = [ "ahash", "cached_proc_macro", @@ -253,9 +253,9 @@ dependencies = [ [[package]] name = "cached_proc_macro" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8245dd5f576a41c3b76247b54c15b0e43139ceeb4f732033e15be7c005176" +checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f" dependencies = [ "darling 0.14.4", "proc-macro2", @@ -2016,7 +2016,7 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.21.2" +version = "0.22.5" dependencies = [ "cached", "extism", @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "proto_pdk" -version = "0.9.0" +version = "0.10.2" dependencies = [ "anyhow", "extism-pdk", @@ -2055,7 +2055,7 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.9.0" +version = "0.10.3" dependencies = [ "anyhow", "semver", @@ -2069,7 +2069,7 @@ dependencies = [ [[package]] name = "proto_pdk_test_utils" -version = "0.9.1" +version = "0.10.2" dependencies = [ "extism", "proto_core", @@ -2498,9 +2498,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] @@ -2517,9 +2517,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.190" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", @@ -2834,7 +2834,7 @@ dependencies = [ [[package]] name = "system_env" -version = "0.1.2" +version = "0.1.4" dependencies = [ "serde", "serde_json", @@ -3256,10 +3256,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "version_spec" -version = "0.1.3" +version = "0.1.5" dependencies = [ "human-sort", - "once_cell", "regex", "semver", "serde", @@ -3295,7 +3294,7 @@ dependencies = [ [[package]] name = "warpgate" -version = "0.5.13" +version = "0.5.14" dependencies = [ "extism", "miette", @@ -3316,7 +3315,7 @@ dependencies = [ [[package]] name = "warpgate_api" -version = "0.1.4" +version = "0.1.5" dependencies = [ "serde", ] diff --git a/plugins/wasm-test/src/lib.rs b/plugins/wasm-test/src/lib.rs index edcb8652f..1ff810175 100644 --- a/plugins/wasm-test/src/lib.rs +++ b/plugins/wasm-test/src/lib.rs @@ -39,6 +39,7 @@ pub fn register_tool(_: ()) -> FnResult> { pub fn detect_version_files(_: ()) -> FnResult> { Ok(Json(DetectVersionOutput { files: vec![".proto-wasm-version".into(), ".protowasmrc".into()], + ignore: vec!["node_modules".into()], })) }