From 266e686a0f6453bfcf1e02328c78ee752141259b Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 23 Jan 2024 10:11:13 -0800 Subject: [PATCH] new: Support proto v0.29. (#17) --- .github/workflows/ci.yml | 2 - CHANGELOG.md | 7 +++ Cargo.lock | 124 ++++++++++++++++++++++----------------- Cargo.toml | 10 ++-- src/proto.rs | 26 +++++--- src/schema.rs | 1 + 6 files changed, 102 insertions(+), 68 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e1b231..e9d384b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,5 @@ jobs: bins: cargo-nextest cache: false - uses: moonrepo/setup-toolchain@v0 - with: - proto-version: 0.28.0-rc.0 - uses: moonrepo/build-proto-plugin@v0 - run: cargo nextest run --no-default-features diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c28af3..c3148de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.9.0 + +#### 🚀 Updates + +- Updated to support proto v0.29 release. +- Added `globals.bin` setting, for customizing the bin used for installs/uninstalls. + ## 0.8.0 #### 💥 Breaking diff --git a/Cargo.lock b/Cargo.lock index 0b366f5..4509685 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,9 +88,9 @@ checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" [[package]] name = "assert_cmd" -version = "2.0.12" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +checksum = "00ad3f3a942eee60335ab4342358c161ee296829e0d16ff42fc1d6cb07815467" dependencies = [ "anstyle", "bstr", @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "assert_fs" -version = "1.0.13" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f070617a68e5c2ed5d06ee8dd620ee18fb72b99f6c094bed34cf8ab07c875b48" +checksum = "2cd762e110c8ed629b11b6cde59458cc1c71de78ebbcc30099fc8e0403a2a2ec" dependencies = [ "anstyle", "doc-comment", @@ -221,9 +221,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cached" -version = "0.47.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69b0116662497bc24e4b177c90eaf8870e39e2714c3fcfa296327a93f593fc21" +checksum = "355face540df58778b96814c48abb3c2ed67c4878a8087ab1819c1fedeec505f" dependencies = [ "ahash", "cached_proc_macro", @@ -236,9 +236,9 @@ dependencies = [ [[package]] name = "cached_proc_macro" -version = "0.18.1" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c878c71c2821aa2058722038a59a67583a4240524687c6028571c9b395ded61f" +checksum = "9d52f526f7cbc875b296856ca8c964a9f6290556922c303a8a3883e3c676e6a1" dependencies = [ "darling 0.14.4", "proc-macro2", @@ -248,9 +248,9 @@ dependencies = [ [[package]] name = "cached_proc_macro_types" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" +checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cap-fs-ext" @@ -866,9 +866,9 @@ dependencies = [ [[package]] name = "extism" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0929c64560cac1e9c71562ec1611dce2b383354371547d201802ab4abc23387b" +checksum = "5472dcd9d979ac3a094f1712dea48936a4ef7c35600184f89464c145c2e7dd1c" dependencies = [ "anyhow", "cbindgen", @@ -891,9 +891,9 @@ dependencies = [ [[package]] name = "extism-convert" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a01edfb12afa6ce5f4d5205831b0630edb867918aa3d2fc829a9dfbfa75f1" +checksum = "37b5889f52d54f53d540f4661af6122cb6443449a0c9111d5458383352aa2dda" dependencies = [ "anyhow", "base64", @@ -906,9 +906,9 @@ dependencies = [ [[package]] name = "extism-manifest" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb76af5cf0fd656e6dff25069056ef41ce0eb0541cc98c15b90b601a16fcfacc" +checksum = "e977dc7c7b75e819b184f35a67c4922e5b2a5424fbdc5c4188e74991b9c9e199" dependencies = [ "base64", "serde", @@ -1129,9 +1129,9 @@ dependencies = [ [[package]] name = "garde" -version = "0.16.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0bde634ca1248cfcd67a29f7b3798997d328406020f5e19b502b0a0d5e8cae" +checksum = "0237d668ccb63fd96dff6a81c5f37b7d984872f9584794dc1d1a62472d2c7b57" dependencies = [ "compact_str", "garde_derive", @@ -1142,9 +1142,9 @@ dependencies = [ [[package]] name = "garde_derive" -version = "0.16.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feafd106c73dd61d6f10f2fa782cdb6212b3422aee5b953a094818e9575078aa" +checksum = "4a42efb40be9de1926cfd15881ff08adb7a70c6cedacced425537c8b1f96ac4f" dependencies = [ "proc-macro2", "quote", @@ -1211,11 +1211,11 @@ dependencies = [ [[package]] name = "globwalk" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.3", "ignore", "walkdir", ] @@ -2011,13 +2011,13 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.28.2" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29890bd951233870c64d9de86afcd0f0bbb2baddbc74994ef4e92e4205ba7fa9" +checksum = "276b59495e6c7a4d7df813ddac9d6c21eb392c0d00f36c10e0988df00bebd11a" dependencies = [ "cached", - "extism", "human-sort", + "indexmap 2.1.0", "miette", "minisign-verify", "once_cell", @@ -2045,23 +2045,22 @@ dependencies = [ [[package]] name = "proto_pdk" -version = "0.14.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "448c156bf0f7ce1efb0c14fbd4b370c6adb583bce39084f7bea2d70776b9ef4e" +checksum = "caf90105b373875a194fda4b02e1a6f7be3d043976f27d6e85704070ed1cd7ca" dependencies = [ - "anyhow", "extism-pdk", "proto_pdk_api", "serde", + "warpgate_pdk", ] [[package]] name = "proto_pdk_api" -version = "0.14.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68af03a80ca5b9ee65a667a707d997598b9155163ac422af8f0bfd95dbc0a23" +checksum = "54c4edbb65667fa05ad5a83c281c369bfd4243f66d08e1b8db8107753121eb81" dependencies = [ - "anyhow", "semver", "serde", "serde_json", @@ -2073,9 +2072,9 @@ dependencies = [ [[package]] name = "proto_pdk_test_utils" -version = "0.16.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f058f5ecb347d55afe1b8d138deebeedec14972bce13fc023a24f6d0fe71f3d" +checksum = "e6117b549659d6c0425a932493918f8d5982d642757544c0bae619903cbe40f2" dependencies = [ "extism", "proto_core", @@ -2083,6 +2082,7 @@ dependencies = [ "serde", "serde_json", "toml 0.8.8", + "warpgate", ] [[package]] @@ -2209,13 +2209,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.4", "regex-syntax 0.8.2", ] @@ -2236,9 +2236,9 @@ checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" dependencies = [ "aho-corasick", "memchr", @@ -2466,7 +2466,7 @@ dependencies = [ [[package]] name = "schema_plugin" -version = "0.8.0" +version = "0.9.0" dependencies = [ "extism-pdk", "proto_pdk", @@ -2480,9 +2480,9 @@ dependencies = [ [[package]] name = "schematic" -version = "0.13.3" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bd78146e39d7140fb82773d9674f98cd4bec2d603c2a172bdc27e0b99fa4f3" +checksum = "0b264774063bdc7a16fe1158426b5a29604478d1c64da0b73cba396505329116" dependencies = [ "garde", "indexmap 2.1.0", @@ -2499,9 +2499,9 @@ dependencies = [ [[package]] name = "schematic_macros" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee0e84caa20e8a80361420733807ef5abeb15cd7dd3c96fb434d393aab9455b5" +checksum = "5362f20a1e2346fb9a7878261b27c8e1adf7872bf4201b7c018dfd3cd88e26a7" dependencies = [ "convert_case", "darling 0.20.3", @@ -2512,10 +2512,11 @@ dependencies = [ [[package]] name = "schematic_types" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edf50096b67242b37f1ca76b4082e961477f875aec7fd77f5e13a4632368c8ae" +checksum = "1c90769caea1c16e71c756f7afe77a35620d61f77d3db4b834d246203f4ea44b" dependencies = [ + "indexmap 2.1.0", "serde_json", "toml 0.8.8", ] @@ -2784,9 +2785,9 @@ dependencies = [ [[package]] name = "starbase_sandbox" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49d8cc34f93dd97db45ad1a7240bc03e01ee8478af003f8d945e8031585a4f11" +checksum = "74dc9bd92b3587c63cad2db7cb23c79b0d1d1a25b314990880a7a932f6f31e87" dependencies = [ "assert_cmd", "assert_fs", @@ -2800,9 +2801,9 @@ dependencies = [ [[package]] name = "starbase_styles" -version = "0.1.16" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d5d3e494c96659752fd79227acff36f375d6f113cb5460acdfdfe9a5b95a0d" +checksum = "aadf4bb3f99ac3782017aa75123781dd64de38b543469c6b9e96ca9f29fc4868" dependencies = [ "dirs 5.0.1", "owo-colors", @@ -3336,9 +3337,9 @@ dependencies = [ [[package]] name = "warpgate" -version = "0.9.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee5304ae947f6b22a2f1d7f3ca6d6ffbf22c17e76cd58ea1982f3ea912ae1542" +checksum = "3226aa23973b00283aa7955385a902ea1c4f60b0a5d43533bcc937f6eebd0a07" dependencies = [ "extism", "miette", @@ -3353,6 +3354,7 @@ dependencies = [ "starbase_archive", "starbase_styles", "starbase_utils", + "system_env", "thiserror", "tracing", "warpgate_api", @@ -3360,12 +3362,26 @@ dependencies = [ [[package]] name = "warpgate_api" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20a7b09712daf3301122452839647781d6b33e1090aa68cde27f0e70fa33398" +checksum = "17eca79a6da0046450f09d55829eb53284e727d3d539f076c19754e81db6d236" dependencies = [ + "anyhow", "schematic", "serde", + "serde_json", + "system_env", +] + +[[package]] +name = "warpgate_pdk" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e54d60b8fe7d4d20f74cea816ee5d761c3bedd796bc00a87c19828b85802b5e" +dependencies = [ + "extism-pdk", + "serde", + "warpgate_api", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5c762e9..b92e5d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "schema_plugin" -version = "0.8.0" +version = "0.9.0" edition = "2021" license = "MIT" publish = false @@ -10,16 +10,16 @@ crate-type = ['cdylib'] [dependencies] extism-pdk = "1.0.0" -proto_pdk = { version = "0.14.2" } #, path = "../../proto/crates/pdk" } -regex = { version = "1.10.2", default-features = false, features = ["std"] } +proto_pdk = { version = "0.15.1" } #, path = "../../proto/crates/pdk" } +regex = { version = "1.10.3", default-features = false, features = ["std"] } serde = "1.0.195" serde_json = "1.0.111" [dev-dependencies] -proto_pdk_test_utils = { version = "0.16.1", features = [ +proto_pdk_test_utils = { version = "0.17.2", features = [ "schema", ] } #, path = "../../proto/crates/pdk-test-utils" } -starbase_sandbox = "0.1.12" +starbase_sandbox = "0.1.13" tokio = { version = "1.35.1", features = ["full"] } [features] diff --git a/src/proto.rs b/src/proto.rs index d3dcc0c..dc97771 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -6,7 +6,6 @@ use serde_json::Value as JsonValue; #[host_fn] extern "ExtismHost" { - fn host_log(input: Json); fn exec_command(input: Json) -> Json; } @@ -36,7 +35,7 @@ fn get_platform<'schema>( } fn get_bin_path(platform: &PlatformMapper, env: &HostEnvironment) -> Result { - let id = get_tool_id()?; + let id = get_plugin_id()?; Ok(platform .bin_path @@ -152,7 +151,10 @@ pub fn load_versions(Json(_): Json) -> FnResultresolve.git_url or resolve.manifest_url.", + schema.name + )) } #[plugin_fn] @@ -200,7 +202,7 @@ fn interpolate_tokens( pub fn download_prebuilt( Json(input): Json, ) -> FnResult> { - let env = get_proto_environment()?; + let env = get_host_environment()?; let schema = get_schema()?; let platform = get_platform(&schema, &env)?; let version = input.context.version.to_string(); @@ -264,7 +266,7 @@ pub fn download_prebuilt( pub fn locate_executables( Json(_): Json, ) -> FnResult> { - let env = get_proto_environment()?; + let env = get_host_environment()?; let schema = get_schema()?; let platform = get_platform(&schema, &env)?; @@ -287,12 +289,17 @@ pub fn install_global( let schema = get_schema()?; if let Some(install_args) = schema.globals.install_args { + let bin = match schema.globals.bin.as_ref() { + Some(name) => name.to_owned(), + None => get_plugin_id()?, + }; + let args = install_args .into_iter() .map(|arg| arg.replace("{dependency}", &input.dependency)) .collect::>(); - let result = exec_command!(inherit, get_tool_id()?, args); + let result = exec_command!(inherit, bin, args); return Ok(Json(InstallGlobalOutput::from_exec_command(result))); } @@ -307,12 +314,17 @@ pub fn uninstall_global( let schema = get_schema()?; if let Some(uninstall_args) = schema.globals.uninstall_args { + let bin = match schema.globals.bin.as_ref() { + Some(name) => name.to_owned(), + None => get_plugin_id()?, + }; + let args = uninstall_args .into_iter() .map(|arg| arg.replace("{dependency}", &input.dependency)) .collect::>(); - let result = exec_command!(inherit, get_tool_id()?, args); + let result = exec_command!(inherit, bin, args); return Ok(Json(UninstallGlobalOutput::from_exec_command(result))); } diff --git a/src/schema.rs b/src/schema.rs index 6ffdd5e..f815a82 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -32,6 +32,7 @@ pub struct InstallSchema { #[derive(Debug, Default, Deserialize)] #[serde(default, rename_all = "kebab-case")] pub struct GlobalsSchema { + pub bin: Option, pub install_args: Option>, pub lookup_dirs: Vec, pub package_prefix: Option,