From 640eb0634750371deeef90a8077ddd6914651f55 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 13 Nov 2023 15:41:39 -0800 Subject: [PATCH] Add is empty check. --- CHANGELOG.md | 7 +++++++ crates/pdk-api/src/api.rs | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d35682515..b50842970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ - [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 + +- WASM API + - Added `DetectVersionOutput.ignore` field. + ## 0.22.2 #### 🐞 Fixes 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, } );