Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
new: Support proto v0.20. (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Oct 20, 2023
1 parent 83bf619 commit 148d4ef
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 104 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.4.0

#### 🚀 Updates

- Updated to support proto v0.20 release.

#### ⚙️ Internal

- Updated dependencies.

## 0.3.2

#### 🐞 Fixes
Expand Down
107 changes: 66 additions & 41 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ members = ["crates/*"]

[workspace.dependencies]
extism-pdk = "0.3.4"
proto_pdk = { version = "=0.7.3" } # , path = "../../proto/crates/pdk" }
proto_pdk_api = { version = "=0.7.2" } # , path = "../../proto/crates/pdk-api" }
proto_pdk_test_utils = { version = "=0.7.1" } # , path = "../../proto/crates/pdk-test-utils" }
serde = "1.0.188"
proto_pdk = { version = "0.8.0" } # , path = "../../proto/crates/pdk" }
proto_pdk_api = { version = "0.8.0" } # , path = "../../proto/crates/pdk-api" }
proto_pdk_test_utils = { version = "0.8.2" } # , path = "../../proto/crates/pdk-test-utils" }
serde = "1.0.189"
serde_json = "1.0.107"
starbase_sandbox = "0.1.11"
tokio = "1.33.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/node-depman/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "node_depman_plugin"
version = "0.3.2"
version = "0.4.0"
edition = "2021"
license = "MIT"
publish = false
Expand Down
10 changes: 5 additions & 5 deletions crates/node-depman/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::path::PathBuf;
#[host_fn]
extern "ExtismHost" {
fn exec_command(input: Json<ExecCommandInput>) -> Json<ExecCommandOutput>;
fn get_env_var(key: &str) -> String;
fn host_log(input: Json<HostLogInput>);
}

Expand Down Expand Up @@ -69,7 +70,6 @@ pub fn register_tool(Json(_): Json<ToolMetadataInput>) -> FnResult<Json<ToolMeta
Ok(Json(ToolMetadataOutput {
name: manager.to_string(),
type_of: PluginType::DependencyManager,
env_vars: vec!["PROTO_NODE_VERSION".into(), "PROTO_INSTALL_GLOBAL".into()],
default_version: if manager == PackageManager::Npm {
Some("bundled".into())
} else {
Expand Down Expand Up @@ -163,7 +163,7 @@ pub fn locate_bins(Json(input): Json<LocateBinsInput>) -> FnResult<Json<LocateBi
Ok(Json(LocateBinsOutput {
bin_path: bin_path.map(PathBuf::from),
fallback_last_globals_dir: true,
globals_lookup_dirs: vec!["$PROTO_ROOT/tools/node/globals/bin".into()],
globals_lookup_dirs: vec!["$PROTO_HOME/tools/node/globals/bin".into()],
..LocateBinsOutput::default()
}))
}
Expand Down Expand Up @@ -243,10 +243,10 @@ pub fn resolve_version(
let mut found_version = false;

// Infer from proto's environment variable
if let Some(node_version) = input.context.env_vars.get("PROTO_NODE_VERSION") {
if let Some(node_version) = host_env!("PROTO_NODE_VERSION") {
for node_release in &response {
// Theirs starts with v, ours does not
if &node_release.version[1..] == node_version {
if node_release.version[1..] == node_version {
output.version = node_release.npm.clone();
found_version = true;
break;
Expand Down Expand Up @@ -430,7 +430,7 @@ pub fn pre_run(Json(input): Json<RunHook>) -> FnResult<()> {
let user_config = get_proto_user_config()?;

if args.len() < 3
|| input.context.env_vars.get("PROTO_INSTALL_GLOBAL").is_some()
|| host_env!("PROTO_INSTALL_GLOBAL").is_some()
|| !user_config.node_intercept_globals
{
return Ok(());
Expand Down
Loading

0 comments on commit 148d4ef

Please sign in to comment.