From fd84b7e41b172d9865724642d006627882860f8a Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 19 Nov 2024 11:50:22 -0800 Subject: [PATCH 1/6] Add deprecations. --- CHANGELOG.md | 7 +++++++ crates/pdk-api/src/api/mod.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8c39dd5..8f2137b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ - [Rust](https://github.com/moonrepo/tools/blob/master/tools/rust/CHANGELOG.md) - [Schema (TOML, JSON, YAML)](https://github.com/moonrepo/tools/blob/master/tools/internal-schema/CHANGELOG.md) +## Unreleased + +#### 🚀 Updates + +- WASM API + - Added `ToolMetadataOutput.deprecations`. + ## 0.42.1 #### 🚀 Updates diff --git a/crates/pdk-api/src/api/mod.rs b/crates/pdk-api/src/api/mod.rs index 92b7ec7c..50acd501 100644 --- a/crates/pdk-api/src/api/mod.rs +++ b/crates/pdk-api/src/api/mod.rs @@ -77,6 +77,11 @@ api_struct!( #[serde(default, skip_serializing_if = "Option::is_none")] pub default_version: Option, + /// List of deprecation messages that will be displayed to users + /// of this plugin. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub deprecations: Vec, + /// Controls aspects of the tool inventory. #[serde(default)] pub inventory: ToolInventoryMetadata, From 9e11186d6b1ac030db033b7a5bb4590932c429d1 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 19 Nov 2024 11:50:51 -0800 Subject: [PATCH 2/6] chore: Release --- Cargo.lock | 4 ++-- crates/cli/Cargo.toml | 2 +- crates/codegen/Cargo.toml | 2 +- crates/core/Cargo.toml | 2 +- crates/pdk-api/Cargo.toml | 2 +- crates/pdk-test-utils/Cargo.toml | 2 +- crates/pdk/Cargo.toml | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70fbc0cf..66dfff07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2531,7 +2531,7 @@ dependencies = [ [[package]] name = "proto_pdk" -version = "0.25.2" +version = "0.25.3" dependencies = [ "extism-pdk", "proto_pdk_api", @@ -2542,7 +2542,7 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.24.2" +version = "0.24.3" dependencies = [ "proto_pdk_api", "rustc-hash 2.0.0", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 1c1c5529..0dad03ca 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -34,7 +34,7 @@ path = "src/main_shim.rs" [dependencies] proto_core = { version = "0.43.5", path = "../core", features = ["clap"] } proto_installer = { version = "0.7.1", path = "../installer" } -proto_pdk_api = { version = "0.24.2", path = "../pdk-api" } +proto_pdk_api = { version = "0.24.3", path = "../pdk-api" } proto_shim = { version = "0.5.0", path = "../shim" } system_env = { version = "0.6.1", path = "../system-env" } anyhow = { workspace = true } diff --git a/crates/codegen/Cargo.toml b/crates/codegen/Cargo.toml index d31ce2a8..ba7b025b 100644 --- a/crates/codegen/Cargo.toml +++ b/crates/codegen/Cargo.toml @@ -10,7 +10,7 @@ dist = false [dependencies] proto_core = { version = "0.43.5", path = "../core" } -proto_pdk_api = { version = "0.24.2", path = "../pdk-api", features = [ +proto_pdk_api = { version = "0.24.3", path = "../pdk-api", features = [ "schematic", ] } schematic = { workspace = true, features = [ diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index d5693343..097030e8 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -8,7 +8,7 @@ homepage = "https://moonrepo.dev/proto" repository = "https://github.com/moonrepo/proto" [dependencies] -proto_pdk_api = { version = "0.24.2", path = "../pdk-api", features = [ +proto_pdk_api = { version = "0.24.3", path = "../pdk-api", features = [ "schematic", ] } proto_shim = { version = "0.5.0", path = "../shim" } diff --git a/crates/pdk-api/Cargo.toml b/crates/pdk-api/Cargo.toml index 4936f41d..f8d3fd2b 100644 --- a/crates/pdk-api/Cargo.toml +++ b/crates/pdk-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "proto_pdk_api" -version = "0.24.2" +version = "0.24.3" edition = "2021" license = "MIT" description = "Core APIs for creating proto WASM plugins." diff --git a/crates/pdk-test-utils/Cargo.toml b/crates/pdk-test-utils/Cargo.toml index 0f5b9b04..a30e6af1 100644 --- a/crates/pdk-test-utils/Cargo.toml +++ b/crates/pdk-test-utils/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/moonrepo/proto" [dependencies] proto_core = { version = "0.43.5", path = "../core" } -proto_pdk_api = { version = "0.24.2", path = "../pdk-api" } +proto_pdk_api = { version = "0.24.3", path = "../pdk-api" } warpgate = { version = "0.19.0", path = "../warpgate" } # extism = { workspace = true } serde = { workspace = true } diff --git a/crates/pdk/Cargo.toml b/crates/pdk/Cargo.toml index 3c121182..4bc28df4 100644 --- a/crates/pdk/Cargo.toml +++ b/crates/pdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "proto_pdk" -version = "0.25.2" +version = "0.25.3" edition = "2021" license = "MIT" description = "A plugin development kit for creating proto WASM plugins." @@ -8,7 +8,7 @@ homepage = "https://moonrepo.dev/proto" repository = "https://github.com/moonrepo/proto" [dependencies] -proto_pdk_api = { version = "0.24.2", path = "../pdk-api" } +proto_pdk_api = { version = "0.24.3", path = "../pdk-api" } warpgate_pdk = { version = "0.8.1", path = "../warpgate-pdk" } extism-pdk = { workspace = true } rustc-hash = { workspace = true } From 14d399a9df559b6a5d93394220d376438a9ba381 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 19 Nov 2024 12:24:38 -0800 Subject: [PATCH 3/6] Bump schema. --- CHANGELOG.md | 6 ++++++ crates/cli/src/commands/plugin/add.rs | 17 ++++++++++++++++- crates/cli/src/commands/plugin/info.rs | 13 ++++++++++++- crates/core/src/proto_config.rs | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f2137b0..715530cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,15 @@ #### 🚀 Updates +- When adding or viewing a plugin, we now display any deprecation messages from the plugin to the user. - WASM API - Added `ToolMetadataOutput.deprecations`. +#### 🧩 Plugins + +- Updated `schema_tool` to v0.16.1. + - Brought back `platform.*.bin-path` to support legacy plugin configs. + ## 0.42.1 #### 🚀 Updates diff --git a/crates/cli/src/commands/plugin/add.rs b/crates/cli/src/commands/plugin/add.rs index c26775f7..b1856b1f 100644 --- a/crates/cli/src/commands/plugin/add.rs +++ b/crates/cli/src/commands/plugin/add.rs @@ -3,7 +3,8 @@ use crate::session::ProtoSession; use clap::Args; use proto_core::{Id, PluginLocator, ProtoConfig}; use starbase::AppResult; -use starbase_styles::color; +use starbase_styles::color::{self, apply_style_tags}; +use tracing::warn; #[derive(Args, Clone, Debug)] pub struct AddPluginArgs { @@ -34,6 +35,20 @@ pub async fn add(session: ProtoSession, args: AddPluginArgs) -> AppResult { }, )?; + // Load the tool and verify it works + let tool = session.load_tool(&args.id).await?; + + if !tool.metadata.deprecations.is_empty() { + let mut output = String::from("Deprecation notices from the plugin:\n"); + + for msg in &tool.metadata.deprecations { + output.push_str(&apply_style_tags(msg)); + output.push('\n'); + } + + warn!("{output}"); + } + println!( "Added plugin {} to config {}", color::id(&args.id), diff --git a/crates/cli/src/commands/plugin/info.rs b/crates/cli/src/commands/plugin/info.rs index b3d403ec..b78bf904 100644 --- a/crates/cli/src/commands/plugin/info.rs +++ b/crates/cli/src/commands/plugin/info.rs @@ -8,7 +8,7 @@ use proto_core::{ use proto_pdk_api::ToolMetadataOutput; use serde::Serialize; use starbase::AppResult; -use starbase_styles::color; +use starbase_styles::color::{self, apply_style_tags}; use starbase_utils::json; use std::path::PathBuf; @@ -88,6 +88,17 @@ pub async fn info(session: ProtoSession, args: InfoPluginArgs) -> AppResult { p.locator(locator); } + if !tool.metadata.deprecations.is_empty() { + p.entry_list( + "Deprecations", + tool.metadata + .deprecations + .iter() + .map(|msg| apply_style_tags(msg)), + None, + ); + } + Ok(()) })?; diff --git a/crates/core/src/proto_config.rs b/crates/core/src/proto_config.rs index a3cff8a1..cf2b6cea 100644 --- a/crates/core/src/proto_config.rs +++ b/crates/core/src/proto_config.rs @@ -362,7 +362,7 @@ impl ProtoConfig { self.plugins.insert( Id::raw(SCHEMA_PLUGIN_KEY), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/schema_tool-v0.16.0/schema_tool.wasm".into() + url: "https://github.com/moonrepo/tools/releases/download/schema_tool-v0.16.1/schema_tool.wasm".into() })) ); } From 4a759235d098065afd85f5c1c4395022ed72407e Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 19 Nov 2024 12:38:41 -0800 Subject: [PATCH 4/6] Improve output. --- crates/cli/src/commands/plugin/add.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/cli/src/commands/plugin/add.rs b/crates/cli/src/commands/plugin/add.rs index b1856b1f..f707e63c 100644 --- a/crates/cli/src/commands/plugin/add.rs +++ b/crates/cli/src/commands/plugin/add.rs @@ -1,10 +1,9 @@ use crate::helpers::{map_pin_type, PinOption}; use crate::session::ProtoSession; use clap::Args; -use proto_core::{Id, PluginLocator, ProtoConfig}; +use proto_core::{load_tool_from_locator, Id, PluginLocator, ProtoConfig}; use starbase::AppResult; use starbase_styles::color::{self, apply_style_tags}; -use tracing::warn; #[derive(Args, Clone, Debug)] pub struct AddPluginArgs { @@ -35,18 +34,23 @@ pub async fn add(session: ProtoSession, args: AddPluginArgs) -> AppResult { }, )?; - // Load the tool and verify it works - let tool = session.load_tool(&args.id).await?; + // Load the tool and verify it works. We can't load the tool with the + // session as the config has already been cached, and doesn't reflect + // the recent addition! + let tool = load_tool_from_locator(&args.id, &session.env, &args.plugin).await?; if !tool.metadata.deprecations.is_empty() { - let mut output = String::from("Deprecation notices from the plugin:\n"); + let mut output = color::caution("Deprecation notices from the plugin:\n"); for msg in &tool.metadata.deprecations { + output.push_str(" "); + output.push_str(&color::muted("-")); + output.push_str(" "); output.push_str(&apply_style_tags(msg)); output.push('\n'); } - warn!("{output}"); + println!("{output}"); } println!( From ef8318bf0d1dd6626a9dad0781740e72eeaa6fab Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 19 Nov 2024 12:41:29 -0800 Subject: [PATCH 5/6] Fix lints. --- crates/cli/src/commands/plugin/add.rs | 2 +- crates/cli/src/commands/plugin/info.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/commands/plugin/add.rs b/crates/cli/src/commands/plugin/add.rs index f707e63c..f4baec3b 100644 --- a/crates/cli/src/commands/plugin/add.rs +++ b/crates/cli/src/commands/plugin/add.rs @@ -45,7 +45,7 @@ pub async fn add(session: ProtoSession, args: AddPluginArgs) -> AppResult { for msg in &tool.metadata.deprecations { output.push_str(" "); output.push_str(&color::muted("-")); - output.push_str(" "); + output.push(' '); output.push_str(&apply_style_tags(msg)); output.push('\n'); } diff --git a/crates/cli/src/commands/plugin/info.rs b/crates/cli/src/commands/plugin/info.rs index b78bf904..39ea33e0 100644 --- a/crates/cli/src/commands/plugin/info.rs +++ b/crates/cli/src/commands/plugin/info.rs @@ -94,7 +94,7 @@ pub async fn info(session: ProtoSession, args: InfoPluginArgs) -> AppResult { tool.metadata .deprecations .iter() - .map(|msg| apply_style_tags(msg)), + .map(apply_style_tags), None, ); } From 8a5f3c93f07d6dd7c194d326cc24b01be65e224e Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 19 Nov 2024 12:56:54 -0800 Subject: [PATCH 6/6] Dont run in tests. --- crates/cli/src/commands/plugin/add.rs | 32 +++++++++++++++----------- crates/cli/src/commands/plugin/info.rs | 5 +--- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/crates/cli/src/commands/plugin/add.rs b/crates/cli/src/commands/plugin/add.rs index f4baec3b..5a076b97 100644 --- a/crates/cli/src/commands/plugin/add.rs +++ b/crates/cli/src/commands/plugin/add.rs @@ -1,9 +1,9 @@ use crate::helpers::{map_pin_type, PinOption}; use crate::session::ProtoSession; use clap::Args; -use proto_core::{load_tool_from_locator, Id, PluginLocator, ProtoConfig}; +use proto_core::{Id, PluginLocator, ProtoConfig}; use starbase::AppResult; -use starbase_styles::color::{self, apply_style_tags}; +use starbase_styles::color; #[derive(Args, Clone, Debug)] pub struct AddPluginArgs { @@ -37,20 +37,26 @@ pub async fn add(session: ProtoSession, args: AddPluginArgs) -> AppResult { // Load the tool and verify it works. We can't load the tool with the // session as the config has already been cached, and doesn't reflect // the recent addition! - let tool = load_tool_from_locator(&args.id, &session.env, &args.plugin).await?; + #[cfg(not(debug_assertions))] + { + use proto_core::load_tool_from_locator; + use starbase_styles::color::apply_style_tags; - if !tool.metadata.deprecations.is_empty() { - let mut output = color::caution("Deprecation notices from the plugin:\n"); + let tool = load_tool_from_locator(&args.id, &session.env, &args.plugin).await?; - for msg in &tool.metadata.deprecations { - output.push_str(" "); - output.push_str(&color::muted("-")); - output.push(' '); - output.push_str(&apply_style_tags(msg)); - output.push('\n'); - } + if !tool.metadata.deprecations.is_empty() { + let mut output = color::caution("Deprecation notices from the plugin:\n"); + + for msg in &tool.metadata.deprecations { + output.push_str(" "); + output.push_str(&color::muted("-")); + output.push(' '); + output.push_str(&apply_style_tags(msg)); + output.push('\n'); + } - println!("{output}"); + println!("{output}"); + } } println!( diff --git a/crates/cli/src/commands/plugin/info.rs b/crates/cli/src/commands/plugin/info.rs index 39ea33e0..ee04af89 100644 --- a/crates/cli/src/commands/plugin/info.rs +++ b/crates/cli/src/commands/plugin/info.rs @@ -91,10 +91,7 @@ pub async fn info(session: ProtoSession, args: InfoPluginArgs) -> AppResult { if !tool.metadata.deprecations.is_empty() { p.entry_list( "Deprecations", - tool.metadata - .deprecations - .iter() - .map(apply_style_tags), + tool.metadata.deprecations.iter().map(apply_style_tags), None, ); }