Skip to content

Commit

Permalink
deps: Update plugins. (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Mar 1, 2024
1 parent 7a98dde commit 8b353cd
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 47 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ In preparation for an official v1 release, improved stability, and overall devel

- Fixed an issue where empty version strings were being parsed, causing failures.

#### 🧩 Plugins

- Updated `bun_plugin` to v0.10.
- Updated `deno_plugin` to v0.10.
- Updated `go_plugin` to v0.10.
- Updated `node_plugin` and `node_depman_plugin` to v0.10.
- Removed the `intercept-globals` config setting.
- Added a new `shared-globals-dir` setting, which injects args/env vars into npm/pnpm/yarn commands when they attemp to install global packages.
- Updated `python_plugin` to v0.8.
- Updated `rust_plugin` to v0.9.
- Updated `schema_plugin` (TOML) to v0.9.
- Removed `globals` and `shims` settings.
- Added a `platform.*.archs` setting, to limit what architectures are supported for that OS.
- Added a `packages` setting for managing global packages. Supports `globals_lookup_dirs` and `globals_prefix` sub-settings.

## 0.30.2

#### 🧩 Plugins
Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ name = "proto-shim"
path = "src/main_shim.rs"

[dependencies]
proto_core = { version = "0.31.1", path = "../core" }
proto_core = { version = "0.31.2", path = "../core" }
proto_installer = { version = "0.2.2", path = "../installer" }
proto_pdk_api = { version = "0.17.0", path = "../pdk-api" }
proto_pdk_api = { version = "0.17.2", path = "../pdk-api" }
proto_shim = { version = "0.2.7", path = "../shim" }
system_env = { version = "0.2.2", path = "../system-env" }
anyhow = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions crates/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,15 @@ pub async fn run(args: ArgsRef<RunArgs>, proto: ResourceRef<ProtoResource>) -> S

// Run before hook
let hook_result = if tool.plugin.has_func("pre_run") {
let globals_dir = tool.get_globals_bin_dir();
let globals_prefix = tool.get_globals_prefix();

tool.plugin.call_func_with(
"pre_run",
RunHook {
context: tool.create_context(),
globals_dir: globals_dir.map(|dir| tool.to_virtual_path(dir)),
globals_prefix: globals_prefix.map(|p| p.to_owned()),
passthrough_args: args.passthrough.clone(),
},
)?
Expand Down
6 changes: 3 additions & 3 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
name = "proto_core"
version = "0.31.1"
version = "0.31.2"
edition = "2021"
license = "MIT"
description = "Core proto APIs."
homepage = "https://moonrepo.dev/proto"
repository = "https://github.com/moonrepo/proto"

[dependencies]
proto_pdk_api = { version = "0.17.0", path = "../pdk-api" }
proto_pdk_api = { version = "0.17.2", path = "../pdk-api" }
proto_shim = { version = "0.2.7", path = "../shim" }
system_env = { version = "0.2.2", path = "../system-env", features = [
"schematic",
] }
version_spec = { version = "0.2.1", path = "../version-spec", features = [
"schematic",
] }
warpgate = { version = "0.11.2", path = "../warpgate", features = [
warpgate = { version = "0.11.3", path = "../warpgate", features = [
"schematic",
] }
cached = { workspace = true }
Expand Down
16 changes: 8 additions & 8 deletions crates/core/src/proto_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw("bun"),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.9.0/bun_plugin.wasm".into()
url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.10.0/bun_plugin.wasm".into()
}
);
}
Expand All @@ -185,7 +185,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw("deno"),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/deno-plugin/releases/download/v0.9.1/deno_plugin.wasm".into()
url: "https://github.com/moonrepo/deno-plugin/releases/download/v0.10.0/deno_plugin.wasm".into()
}
);
}
Expand All @@ -194,7 +194,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw("go"),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/go-plugin/releases/download/v0.9.0/go_plugin.wasm".into()
url: "https://github.com/moonrepo/go-plugin/releases/download/v0.10.0/go_plugin.wasm".into()
}
);
}
Expand All @@ -203,7 +203,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw("node"),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/node-plugin/releases/download/v0.9.1/node_plugin.wasm".into()
url: "https://github.com/moonrepo/node-plugin/releases/download/v0.10.0/node_plugin.wasm".into()
}
);
}
Expand All @@ -213,7 +213,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw(depman),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/node-plugin/releases/download/v0.9.1/node_depman_plugin.wasm".into()
url: "https://github.com/moonrepo/node-plugin/releases/download/v0.10.0/node_depman_plugin.wasm".into()
}
);
}
Expand All @@ -223,7 +223,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw("python"),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/python-plugin/releases/download/v0.7.0/python_plugin.wasm".into()
url: "https://github.com/moonrepo/python-plugin/releases/download/v0.8.0/python_plugin.wasm".into()
}
);
}
Expand All @@ -232,7 +232,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw("rust"),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/rust-plugin/releases/download/v0.8.1/rust_plugin.wasm".into()
url: "https://github.com/moonrepo/rust-plugin/releases/download/v0.9.0/rust_plugin.wasm".into()
}
);
}
Expand All @@ -241,7 +241,7 @@ impl ProtoConfig {
self.plugins.insert(
Id::raw(SCHEMA_PLUGIN_KEY),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/schema-plugin/releases/download/v0.9.1/schema_plugin.wasm".into()
url: "https://github.com/moonrepo/schema-plugin/releases/download/v0.10.0/schema_plugin.wasm".into()
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/pdk-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "proto_pdk_api"
version = "0.17.0"
version = "0.17.2"
edition = "2021"
license = "MIT"
description = "Core APIs for creating proto WASM plugins."
Expand All @@ -10,7 +10,7 @@ repository = "https://github.com/moonrepo/proto"
[dependencies]
system_env = { version = "0.2.2", path = "../system-env" }
version_spec = { version = "0.2.1", path = "../version-spec" }
warpgate_api = { version = "0.4.2", path = "../warpgate-api" }
warpgate_api = { version = "0.4.3", path = "../warpgate-api" }
rustc-hash = { workspace = true }
semver = { workspace = true, features = ["serde"] }
serde = { workspace = true }
Expand Down
6 changes: 6 additions & 0 deletions crates/pdk-api/src/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ api_struct!(
/// Current tool context.
pub context: ToolContext,

/// Path to the global packages directory for the tool, if found.
pub globals_dir: Option<VirtualPath>,

/// A prefix applied to the file names of globally installed packages.
pub globals_prefix: Option<String>,

/// Arguments passed after `--` that was directly passed to the tool's binary.
pub passthrough_args: Vec<String>,
}
Expand Down
8 changes: 4 additions & 4 deletions crates/pdk-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "proto_pdk_test_utils"
version = "0.19.1"
version = "0.19.6"
edition = "2021"
license = "MIT"
description = "Utilities for testing proto WASM plugins."
homepage = "https://moonrepo.dev/proto"
repository = "https://github.com/moonrepo/proto"

[dependencies]
proto_core = { version = "0.31.1", path = "../core" }
proto_pdk_api = { version = "0.17.0", path = "../pdk-api" }
warpgate = { version = "0.11.2", path = "../warpgate" }
proto_core = { version = "0.31.2", path = "../core" }
proto_pdk_api = { version = "0.17.2", path = "../pdk-api" }
warpgate = { version = "0.11.3", path = "../warpgate" }
extism = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
64 changes: 57 additions & 7 deletions crates/pdk-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ pub use proto_pdk_api::*;
pub use warpgate::Wasm;
pub use wrapper::WasmTestWrapper;

use proto_core::inject_proto_manifest_config;
use proto_core::{get_home_dir, inject_proto_manifest_config};
use serde::Serialize;
use std::collections::HashMap;
use std::fs;
use std::env;
use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::{Path, PathBuf};
use warpgate::{inject_default_manifest_config, test_utils};

pub fn find_wasm_file(sandbox: &Path) -> PathBuf {
let wasm_file = test_utils::find_wasm_file();

// Folders must exists for WASM to compile correctly!
// Folders must exist for WASM to compile correctly!
fs::create_dir_all(sandbox.join(".home")).unwrap();
fs::create_dir_all(sandbox.join(".proto")).unwrap();

Expand All @@ -35,14 +37,40 @@ pub fn create_plugin_with_config(
let id = Id::new(id).unwrap();
let proto = ProtoEnvironment::new_testing(sandbox);

let mut manifest =
Tool::create_plugin_manifest(&proto, Wasm::file(find_wasm_file(sandbox))).unwrap();
let wasm_file = find_wasm_file(sandbox);
let mut log_file = wasm_file.clone();
log_file.set_extension("log");

let mut manifest = Tool::create_plugin_manifest(&proto, Wasm::file(wasm_file)).unwrap();

inject_default_manifest_config(&id, &proto.home, &mut manifest).unwrap();
inject_proto_manifest_config(&id, &proto, &mut manifest).unwrap();

manifest.config.extend(config);

let test_config = map_config_test_environment(sandbox);
manifest.config.insert(test_config.0, test_config.1);

// Remove the file otherwise it keeps growing
if log_file.exists() {
let _ = fs::remove_file(&log_file);
}

// TODO redo
if env::var("CI").is_err() {
let _ = extism::set_log_callback(
move |line| {
let mut file = OpenOptions::new()
.create(true)
.append(true)
.open(&log_file)
.unwrap();

file.write_all(line.as_bytes()).unwrap();
},
"debug",
);
}

WasmTestWrapper {
tool: Tool::load_from_manifest(Id::new(id).unwrap(), proto, manifest).unwrap(),
}
Expand Down Expand Up @@ -86,12 +114,34 @@ pub fn create_config_entry<T: Serialize>(key: &str, value: T) -> (String, String
}

pub fn map_config_environment(os: HostOS, arch: HostArch) -> (String, String) {
map_config_environment_with_home(os, arch, get_home_dir().unwrap())
}

pub fn map_config_environment_with_home(
os: HostOS,
arch: HostArch,
home_dir: impl AsRef<Path>,
) -> (String, String) {
create_config_entry(
"host_environment",
HostEnvironment {
arch,
os,
..HostEnvironment::default()
home_dir: VirtualPath::WithReal {
path: PathBuf::from("/userhome"),
virtual_prefix: PathBuf::from("/userhome"),
real_prefix: home_dir.as_ref().to_path_buf(),
},
},
)
}

pub fn map_config_test_environment(sandbox: impl AsRef<Path>) -> (String, String) {
create_config_entry(
"test_environment",
TestEnvironment {
ci: env::var("CI").is_ok(),
sandbox: sandbox.as_ref().to_path_buf(),
},
)
}
Expand Down
7 changes: 2 additions & 5 deletions crates/pdk-test-utils/src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ impl WasmTestWrapper {
.unwrap();
}

pub fn pre_run(&self, mut input: RunHook) {
pub fn pre_run(&self, mut input: RunHook) -> RunHookResult {
input.context = self.prepare_context(input.context);

self.tool
.plugin
.call_func_without_output("pre_run", input)
.unwrap();
self.tool.plugin.call_func_with("pre_run", input).unwrap()
}

pub fn post_install(&self, mut input: InstallHook) {
Expand Down
6 changes: 3 additions & 3 deletions crates/pdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "proto_pdk"
version = "0.17.1"
version = "0.17.3"
edition = "2021"
license = "MIT"
description = "A plugin development kit for creating proto WASM plugins."
homepage = "https://moonrepo.dev/proto"
repository = "https://github.com/moonrepo/proto"

[dependencies]
proto_pdk_api = { version = "0.17.0", path = "../pdk-api" }
warpgate_pdk = { version = "0.2.1", path = "../warpgate-pdk" }
proto_pdk_api = { version = "0.17.2", path = "../pdk-api" }
warpgate_pdk = { version = "0.2.2", path = "../warpgate-pdk" }
extism-pdk = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true }
Loading

0 comments on commit 8b353cd

Please sign in to comment.