Skip to content

Commit 80fe3ee

Browse files
authored
Support proto v0.42 (#4)
1 parent 8c5648e commit 80fe3ee

8 files changed

Lines changed: 603 additions & 594 deletions

File tree

Cargo.lock

Lines changed: 568 additions & 580 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "zig_tool"
3-
version = "0.6.0"
3+
version = "0.7.0"
44
edition = "2021"
55
license = "MIT"
66
publish = false
@@ -9,14 +9,14 @@ publish = false
99
crate-type = ['cdylib']
1010

1111
[dependencies]
12-
extism-pdk = "1.2.1"
13-
proto_pdk = "0.23.0"
14-
serde = "1.0.208"
12+
extism-pdk = "1.3.0"
13+
proto_pdk = "0.25.2"
14+
serde = "1.0.214"
1515

1616
[dev-dependencies]
17-
proto_pdk_test_utils = "0.27.0"
18-
starbase_sandbox = "0.7.2"
19-
tokio = { version = "1.39.3", features = ["full"] }
17+
proto_pdk_test_utils = "0.30.3"
18+
starbase_sandbox = "0.7.4"
19+
tokio = { version = "1.41.0", features = ["full"] }
2020

2121
[features]
2222
default = ["wasm"]

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
profile = "default"
3-
channel = "1.80.0"
3+
channel = "1.82.0"

src/proto.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
use crate::zig_dist::ZigDist;
22
use extism_pdk::*;
33
use proto_pdk::*;
4+
use std::collections::HashMap;
45

56
static NAME: &str = "Zig";
6-
static BIN: &str = "zig";
77

88
#[plugin_fn]
99
pub fn register_tool(Json(_): Json<ToolMetadataInput>) -> FnResult<Json<ToolMetadataOutput>> {
1010
Ok(Json(ToolMetadataOutput {
1111
name: NAME.into(),
1212
type_of: PluginType::Language,
13-
plugin_version: Some(env!("CARGO_PKG_VERSION").into()),
13+
minimum_proto_version: Some(Version::new(0, 42, 0)),
14+
plugin_version: Version::parse(env!("CARGO_PKG_VERSION")).ok(),
1415
..ToolMetadataOutput::default()
1516
}))
1617
}
@@ -85,7 +86,10 @@ pub fn locate_executables(
8586
let env = get_host_environment()?;
8687

8788
Ok(Json(LocateExecutablesOutput {
88-
primary: Some(ExecutableConfig::new(env.os.get_file_name(BIN, "exe"))),
89+
exes: HashMap::from_iter([(
90+
"zig".into(),
91+
ExecutableConfig::new_primary(env.os.get_exe_name("zig")),
92+
)]),
8993
..LocateExecutablesOutput::default()
9094
}))
9195
}

tests/download_test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ async fn locates_unix_bin() {
306306
},
307307
})
308308
.await
309-
.primary
309+
.exes
310+
.get("zig")
310311
.unwrap()
311312
.exe_path,
312313
Some("zig".into())
@@ -331,7 +332,8 @@ async fn locates_windows_bin() {
331332
},
332333
})
333334
.await
334-
.primary
335+
.exes
336+
.get("zig")
335337
.unwrap()
336338
.exe_path,
337339
Some("zig.exe".into())

tests/metadata_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ async fn registers_metadata() {
88
let metadata = plugin.register_tool(ToolMetadataInput::default()).await;
99

1010
assert_eq!(metadata.name, "Zig");
11-
assert_eq!(metadata.plugin_version.unwrap(), env!("CARGO_PKG_VERSION"));
11+
assert_eq!(
12+
metadata.plugin_version.unwrap().to_string(),
13+
env!("CARGO_PKG_VERSION")
14+
);
1215
}

tests/shims_test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use proto_pdk_test_utils::*;
2+
3+
#[cfg(not(windows))]
4+
generate_shims_test!("zig-test", ["zig"]);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
source: tests/shims_test.rs
3+
expression: "std :: fs ::\nread_to_string(sandbox.path().join(\".proto/shims/registry.json\")).unwrap()"
4+
snapshot_kind: text
5+
---
6+
{
7+
"zig": {}
8+
}

0 commit comments

Comments
 (0)