From 4ecf83838a269c8febe5705526e81e9a1c8ac4b3 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 15 Nov 2024 10:38:12 -0800 Subject: [PATCH 01/12] new: Add `--on-init` to `proto activate`. (#654) --- CHANGELOG.md | 6 ++++ Cargo.lock | 4 +-- Cargo.toml | 2 +- crates/cli/src/commands/activate.rs | 9 ++++- ...t__activate__empty_output_if_no_tools.snap | 8 ++--- ...e_test__activate__passes_args_through.snap | 5 ++- ...test__activate__supports_json_exports.snap | 33 ++++++++++--------- ...e_test__activate__supports_many_tools.snap | 2 +- ...ate_test__activate__supports_one_tool.snap | 6 ++-- 9 files changed, 45 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b721d03..2bc5c5957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ - [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 + +- Added `--on-init` option to `proto activate`, which will trigger the activation hook immediately in the shell, instead of waiting for a directory/prompt change to occur. + ## 0.42.2 #### 🚀 Updates diff --git a/Cargo.lock b/Cargo.lock index 68e8c8f38..f2fe1dff4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3372,9 +3372,9 @@ dependencies = [ [[package]] name = "starbase_shell" -version = "0.5.10" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb4ddfe965972d15e1b12fd0650c5bcfa0219b0c20bce763b66ffd88b75e6733" +checksum = "64b465ae225b09ac539963cd85448fff7520e82320ff2a120f648990fb064229" dependencies = [ "miette", "regex", diff --git a/Cargo.toml b/Cargo.toml index 5775eea48..5e9a524a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ starbase_archive = { version = "0.8.9", features = [ ] } starbase_events = { version = "0.6.3" } starbase_sandbox = { version = "0.7.6" } -starbase_shell = { version = "0.5.10", features = ["miette"] } +starbase_shell = { version = "0.6.1", features = ["miette"] } starbase_styles = { version = "0.4.5" } starbase_utils = { version = "0.8.12", default-features = false, features = [ "json", diff --git a/crates/cli/src/commands/activate.rs b/crates/cli/src/commands/activate.rs index 390bf9be2..02c02e602 100644 --- a/crates/cli/src/commands/activate.rs +++ b/crates/cli/src/commands/activate.rs @@ -63,6 +63,9 @@ pub struct ActivateArgs { #[arg(long, help = "Don't include ~/.proto/shims in path lookup")] no_shim: bool, + + #[arg(long, help = "Run activate hook on initialization and export")] + on_init: bool, } #[tracing::instrument(skip_all)] @@ -213,10 +216,14 @@ fn print_activation_hook( "{}", shell_type.build().format_hook(Hook::OnChangeDir { command, - prefix: "proto".into(), + function: "_proto_activate_hook".into(), })? ); + if args.on_init { + println!("\n_proto_activate_hook"); + } + Ok(None) } diff --git a/crates/cli/tests/snapshots/activate_test__activate__empty_output_if_no_tools.snap b/crates/cli/tests/snapshots/activate_test__activate__empty_output_if_no_tools.snap index 1ac8495b1..d5df824a7 100644 --- a/crates/cli/tests/snapshots/activate_test__activate__empty_output_if_no_tools.snap +++ b/crates/cli/tests/snapshots/activate_test__activate__empty_output_if_no_tools.snap @@ -4,7 +4,7 @@ expression: "get_activate_output(&assert, &sandbox)" --- export __ORIG_PATH="$PATH" -_proto_hook() { +_proto_activate_hook() { local previous_exit_status=$?; trap '' SIGINT; output=$(proto activate bash --export) @@ -15,10 +15,10 @@ _proto_hook() { return $previous_exit_status; }; -if [[ ";${PROMPT_COMMAND[*]:-};" != *";_proto_hook;"* ]]; then +if [[ ";${PROMPT_COMMAND[*]:-};" != *";_proto_activate_hook;"* ]]; then if [[ "$(declare -p PROMPT_COMMAND 2>&1)" == "declare -a"* ]]; then - PROMPT_COMMAND=(_proto_hook "${PROMPT_COMMAND[@]}") + PROMPT_COMMAND=(_proto_activate_hook "${PROMPT_COMMAND[@]}") else - PROMPT_COMMAND="_proto_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}" + PROMPT_COMMAND="_proto_activate_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}" fi fi diff --git a/crates/cli/tests/snapshots/activate_test__activate__passes_args_through.snap b/crates/cli/tests/snapshots/activate_test__activate__passes_args_through.snap index b3be618a1..bbf305ed7 100644 --- a/crates/cli/tests/snapshots/activate_test__activate__passes_args_through.snap +++ b/crates/cli/tests/snapshots/activate_test__activate__passes_args_through.snap @@ -2,13 +2,12 @@ source: crates/cli/tests/activate_test.rs expression: "get_activate_output(&assert, &sandbox)" --- -# proto hook set-env __ORIG_PATH $E:PATH -fn _proto_hook { +fn _proto_activate_hook { eval (proto activate elvish --config-mode upwards-global --no-bin --no-shim --export); } set @edit:before-readline = $@edit:before-readline { - _proto_hook + _proto_activate_hook } diff --git a/crates/cli/tests/snapshots/activate_test__activate__supports_json_exports.snap b/crates/cli/tests/snapshots/activate_test__activate__supports_json_exports.snap index 8c7bfc549..48edecfcc 100644 --- a/crates/cli/tests/snapshots/activate_test__activate__supports_json_exports.snap +++ b/crates/cli/tests/snapshots/activate_test__activate__supports_json_exports.snap @@ -2,29 +2,32 @@ source: crates/cli/tests/activate_test.rs expression: "get_activate_output(&assert, &sandbox)" --- -# proto hook $env.__ORIG_PATH = $env.PATH -$env.config = ( $env.config | upsert hooks.env_change.PWD { |config| - let list = ($config | get -i hooks.env_change.PWD) | default [] - - $list | append { |before, after| - let data = proto activate nu --config-mode upwards-global --json | from json +def _proto_activate_hook [] { + let data = proto activate nu --config-mode upwards-global --json | from json - $data | get env | items { |k, v| - if $v == null { + $data | get env | items { |k, v| + if $v == null { hide_env $k - } else { + } else { load-env { ($k): $v } - } } + } - let path_list = $env.__ORIG_PATH | split row (char esep) + let path_list = $env.__ORIG_PATH | split row (char esep) - $data | get paths | reverse | each { |p| - let path_list = ($path_list | prepend $p) - } + $data | get paths | reverse | each { |p| + let path_list = ($path_list | prepend $p) + } + + $env.PATH = ($path_list | uniq) +} - $env.PATH = ($path_list | uniq) +$env.config = ($env.config | upsert hooks.env_change.PWD { |config| + let list = ($config | get -i hooks.env_change.PWD) | default [] + + $list | append { |before, after| + _proto_activate_hook } }) diff --git a/crates/cli/tests/snapshots/activate_test__activate__supports_many_tools.snap b/crates/cli/tests/snapshots/activate_test__activate__supports_many_tools.snap index f20c30e53..008bfccb0 100644 --- a/crates/cli/tests/snapshots/activate_test__activate__supports_many_tools.snap +++ b/crates/cli/tests/snapshots/activate_test__activate__supports_many_tools.snap @@ -4,6 +4,6 @@ expression: "get_activate_output(&assert, &sandbox)" --- set -gx __ORIG_PATH $PATH -function _proto_hook --on-variable PWD; +function _proto_activate_hook --on-variable PWD; proto activate fish --export | source end; diff --git a/crates/cli/tests/snapshots/activate_test__activate__supports_one_tool.snap b/crates/cli/tests/snapshots/activate_test__activate__supports_one_tool.snap index 7972fa864..c46a3aa21 100644 --- a/crates/cli/tests/snapshots/activate_test__activate__supports_one_tool.snap +++ b/crates/cli/tests/snapshots/activate_test__activate__supports_one_tool.snap @@ -4,7 +4,7 @@ expression: "get_activate_output(&assert, &sandbox)" --- export __ORIG_PATH="$PATH" -_proto_hook() { +_proto_activate_hook() { trap '' SIGINT output=$(proto activate zsh --export) if [ -n "$output" ]; then @@ -14,6 +14,6 @@ _proto_hook() { } typeset -ag chpwd_functions -if (( ! ${chpwd_functions[(I)_proto_hook]} )); then - chpwd_functions=(_proto_hook $chpwd_functions) +if (( ! ${chpwd_functions[(I)_proto_activate_hook]} )); then + chpwd_functions=(_proto_activate_hook $chpwd_functions) fi From c613cabb06f90371ed942effc9a4915c73a819d6 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 25 Nov 2024 17:30:41 -0800 Subject: [PATCH 02/12] deps(wasmtime): Update to v26. (#657) --- CHANGELOG.md | 8 + Cargo.lock | 752 ++++++++++++++++++++-------------------- Cargo.toml | 26 +- crates/cli/Cargo.toml | 14 +- crates/cli/src/shell.rs | 10 +- crates/core/Cargo.toml | 2 +- 6 files changed, 412 insertions(+), 400 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc5c5957..6adb761c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,14 @@ - Added `--on-init` option to `proto activate`, which will trigger the activation hook immediately in the shell, instead of waiting for a directory/prompt change to occur. +#### 🐞 Fixes + +- Fixed the order of shell profiles/configs when applicable. + +#### ⚙️ Internal + +- Updated wasmtime to v26 (from v23). + ## 0.42.2 #### 🚀 Updates diff --git a/Cargo.lock b/Cargo.lock index f2fe1dff4..6a8805152 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,22 +2,13 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli 0.28.1", -] - [[package]] name = "addr2line" version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ - "gimli 0.31.1", + "gimli", ] [[package]] @@ -70,9 +61,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -85,9 +76,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8365de52b16c035ff4fcafe0092ba9390540e3e352870ac09933bebcaa2c8c56" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" @@ -119,15 +110,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" dependencies = [ "derive_arbitrary", ] @@ -192,7 +183,7 @@ version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ - "addr2line 0.24.2", + "addr2line", "cfg-if", "libc", "miniz_oxide", @@ -250,12 +241,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "serde", ] @@ -267,9 +258,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" [[package]] name = "byteorder" @@ -306,9 +297,9 @@ dependencies = [ [[package]] name = "cap-fs-ext" -version = "3.3.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712695628f77a28acd7c9135b9f05f9c1563f8eb91b317f63876bac550032403" +checksum = "e16619ada836f12897a72011fe99b03f0025b87a8dbbea4f3c9f89b458a23bf3" dependencies = [ "cap-primitives", "cap-std", @@ -318,9 +309,9 @@ dependencies = [ [[package]] name = "cap-primitives" -version = "3.3.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff5bcbaf57897c8f14098cc9ad48a78052930a9948119eea01b80ca224070fa6" +checksum = "82fa6c3f9773feab88d844aa50035a33fb6e7e7426105d2f4bb7aadc42a5f89a" dependencies = [ "ambient-authority", "fs-set-times", @@ -335,9 +326,9 @@ dependencies = [ [[package]] name = "cap-rand" -version = "3.3.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c780812948b31f362c3bab82d23b902529c26705d0e094888bc7fdb9656908" +checksum = "53774d49369892b70184f8312e50c1b87edccb376691de4485b0ff554b27c36c" dependencies = [ "ambient-authority", "rand", @@ -345,9 +336,9 @@ dependencies = [ [[package]] name = "cap-std" -version = "3.3.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6cf1a22e6eab501e025a9953532b1e95efb8a18d6364bf8a4a7547b30c49186" +checksum = "7f71b70818556b4fe2a10c7c30baac3f5f45e973f49fc2673d7c75c39d0baf5b" dependencies = [ "cap-primitives", "io-extras", @@ -357,9 +348,9 @@ dependencies = [ [[package]] name = "cap-time-ext" -version = "3.3.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1547a95cd071db92382c649260bcc6721879ef5d1f0f442af33bff75003dd7" +checksum = "69dd48afa2363f746c93f961c211f6f099fb594a3446b8097bc5f79db51b6816" dependencies = [ "ambient-authority", "cap-primitives", @@ -398,9 +389,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -435,9 +426,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -445,9 +436,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -457,9 +448,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.36" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86bc73de94bc81e52f3bebec71bc4463e9748f7a59166663e32044669577b0e2" +checksum = "d9647a559c112175f17cf724dc72d3645680a883c58481332779192b0d8e7a01" dependencies = [ "clap", ] @@ -488,9 +479,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "clean-path" @@ -512,14 +503,14 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comfy-table" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" +checksum = "24f165e7b643266ea80cb858aed492ad9280e3e05ce24d4a99d7d7b889b6a4d9" dependencies = [ "crossterm", "strum", "strum_macros", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] @@ -554,7 +545,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] @@ -597,6 +588,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -614,27 +615,27 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a41b85213deedf877555a7878ca9fb680ccba8183611c4bb8030ed281b2ad83" +checksum = "540b193ff98b825a1f250a75b3118911af918a734154c69d80bcfcf91e7e9522" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "690d8ae6c73748e5ce3d8fe59034dceadb8823e6c8994ba324141c5eae909b0e" +checksum = "c7cb269598b9557ab942d687d3c1086d77c4b50dcf35813f3a65ba306fd42279" dependencies = [ "serde", "serde_derive", @@ -642,9 +643,9 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce027a7b16f8b86f60ff6819615273635186d607a0c225ee6ac340d7d18f978" +checksum = "46566d7c83a8bff4150748d66020f4c7224091952aa4b4df1ec4959c39d937a1" dependencies = [ "bumpalo", "cranelift-bforest", @@ -654,44 +655,44 @@ dependencies = [ "cranelift-control", "cranelift-entity", "cranelift-isle", - "gimli 0.28.1", + "gimli", "hashbrown 0.14.5", "log", "regalloc2", - "rustc-hash 1.1.0", + "rustc-hash", "smallvec", "target-lexicon", ] [[package]] name = "cranelift-codegen-meta" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0a2d2ab65e6cbf91f81781d8da65ec2005510f18300eff21a99526ed6785863" +checksum = "2df8a86a34236cc75a8a6a271973da779c2aeb36c43b6e14da474cf931317082" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efcff860573cf3db9ae98fbd949240d78b319df686cc306872e7fab60e9c84d7" +checksum = "cf75340b6a57b7c7c1b74f10d3d90883ee6d43a554be8131a4046c2ebcf5eb65" [[package]] name = "cranelift-control" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d70e5b75c2d5541ef80a99966ccd97aaa54d2a6af19ea31759a28538e1685a" +checksum = "2e84495bc5d23d86aad8c86f8ade4af765b94882af60d60e271d3153942f1978" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d21d3089714278920030321829090d9482c91e5ff2339f2f697f8425bffdcba3" +checksum = "963c17147b80df351965e57c04d20dbedc85bcaf44c3436780a59a3f1ff1b1c2" dependencies = [ "cranelift-bitset", "serde", @@ -700,9 +701,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7308482930f2a2fad4fe25a06054f6f9a4ee1ab97264308c661b037cb60001a3" +checksum = "727f02acbc4b4cb2ba38a6637101d579db50190df1dd05168c68e762851a3dd5" dependencies = [ "cranelift-codegen", "log", @@ -712,37 +713,21 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c59e259dab0e6958dabcc536b30845574f027ba6e5000498cdaf7e7ed2d30" +checksum = "32b00cc2e03c748f2531eea01c871f502b909d30295fdcad43aec7bf5c5b4667" [[package]] name = "cranelift-native" -version = "0.110.3" +version = "0.113.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77ac3dfb61ef3159998105116acdfeaec75e4296c43ee2dcc4ea39838c0080e" +checksum = "bbeaf978dc7c1a2de8bbb9162510ed218eb156697bc45590b8fbdd69bb08e8de" dependencies = [ "cranelift-codegen", "libc", "target-lexicon", ] -[[package]] -name = "cranelift-wasm" -version = "0.110.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d883f1b8d3d1dab4797407117bc8a1824f4a1fe86654aee2ee3205613f77d3e" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "itertools 0.12.1", - "log", - "smallvec", - "wasmparser 0.212.0", - "wasmtime-types", -] - [[package]] name = "crc32fast" version = "1.4.2" @@ -779,14 +764,14 @@ checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" -version = "0.27.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ "bitflags", "crossterm_winapi", - "libc", "parking_lot", + "rustix", "winapi", ] @@ -855,9 +840,9 @@ dependencies = [ [[package]] name = "derive_arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", @@ -873,7 +858,7 @@ dependencies = [ "console", "shell-words", "tempfile", - "thiserror", + "thiserror 1.0.69", "zeroize", ] @@ -1035,9 +1020,9 @@ dependencies = [ [[package]] name = "extism" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3da59fba4da905210ef7c4c2a9f784717de54afbfb3f07414de5b0b15d5ecc8" +checksum = "4b7dbc26280a335a1cb5547f99a6459b58d72568bf760306633a16c02826e88f" dependencies = [ "anyhow", "cbindgen", @@ -1061,9 +1046,9 @@ dependencies = [ [[package]] name = "extism-convert" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b6253fe1e378abdd0fd9fd01b53aa8757c6827cd3c48794b417e542d088d0e" +checksum = "70a62907d60afa3fc0dfc273833fcb5bb68771f771ce137da1dab7916d856ce9" dependencies = [ "anyhow", "base64 0.22.1", @@ -1077,9 +1062,9 @@ dependencies = [ [[package]] name = "extism-convert-macros" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7022773c485da2122413c2edbf50b7dee135b6577cc5ac42dccc307e347ac5d6" +checksum = "8cd75ee443312a8cd7a402e29fb369c1a2b72f532fd7cdaf34f3023e5d8963d5" dependencies = [ "manyhow", "proc-macro-crate", @@ -1090,9 +1075,9 @@ dependencies = [ [[package]] name = "extism-manifest" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca9129d54add3090148a17444879256b4ec3fd7c4269d2780cd70050232edda" +checksum = "8203adde7bb7a632122e387564314c804793773e9a701fd8cbb6b2c5940a6640" dependencies = [ "base64 0.22.1", "serde", @@ -1133,9 +1118,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fd-lock" @@ -1162,9 +1147,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -1346,27 +1331,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "glob" version = "0.3.1" @@ -1382,7 +1363,7 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -1399,9 +1380,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", @@ -1416,15 +1397,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.14.5" @@ -1437,9 +1409,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "foldhash", ] @@ -1510,9 +1482,9 @@ checksum = "140a09c9305e6d5e557e2ed7cbc68e05765a7d4213975b87cb04920689cc6219" [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", @@ -1539,7 +1511,7 @@ dependencies = [ "hyper", "hyper-util", "rustls", - "rustls-native-certs 0.8.0", + "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", "tokio-rustls", @@ -1749,7 +1721,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -1762,22 +1734,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "serde", ] [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", "unicode-segmentation", - "unicode-width", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -1792,20 +1764,11 @@ dependencies = [ "similar", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "io-extras" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9f046b9af244f13b3bd939f55d16830ac3a201e8a9ba9661bfcb03e2be72b9b" +checksum = "7d45fd7584f9b67ac37bc041212d06bfac0700b36456b05890d36a3b626260eb" dependencies = [ "io-lifetimes", "windows-sys 0.52.0", @@ -1864,9 +1827,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "ittapi" @@ -1929,9 +1892,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "fcb4d3d38eab6c5239a362fa8bae48c03baf980a6e7079f063942d563ef3533e" [[package]] name = "libm" @@ -1964,9 +1927,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -2088,8 +2051,8 @@ dependencies = [ "supports-unicode", "terminal_size", "textwrap", - "thiserror", - "unicode-width", + "thiserror 1.0.69", + "unicode-width 0.1.14", ] [[package]] @@ -2210,7 +2173,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "crc32fast", - "hashbrown 0.15.0", + "hashbrown 0.15.2", "indexmap", "memchr", ] @@ -2309,9 +2272,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "postcard" @@ -2396,9 +2359,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -2451,7 +2414,7 @@ dependencies = [ "regex", "reqwest", "rust_json", - "rustc-hash 2.0.0", + "rustc-hash", "semver", "serde", "shared_child", @@ -2462,7 +2425,7 @@ dependencies = [ "starbase_styles", "starbase_utils", "system_env", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", "wasi-common", @@ -2495,7 +2458,7 @@ dependencies = [ "proto_shim", "regex", "reqwest", - "rustc-hash 2.0.0", + "rustc-hash", "schematic", "semver", "serde", @@ -2506,7 +2469,7 @@ dependencies = [ "starbase_sandbox", "starbase_styles", "starbase_utils", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", "url", @@ -2525,7 +2488,7 @@ dependencies = [ "starbase_styles", "starbase_utils", "system_env", - "thiserror", + "thiserror 2.0.3", "tracing", ] @@ -2535,7 +2498,7 @@ version = "0.25.3" dependencies = [ "extism-pdk", "proto_pdk_api", - "rustc-hash 2.0.0", + "rustc-hash", "serde", "warpgate_pdk", ] @@ -2545,13 +2508,13 @@ name = "proto_pdk_api" version = "0.24.3" dependencies = [ "proto_pdk_api", - "rustc-hash 2.0.0", + "rustc-hash", "schematic", "semver", "serde", "serde_json", "system_env", - "thiserror", + "thiserror 2.0.3", "version_spec", "warpgate_api", ] @@ -2578,53 +2541,67 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" dependencies = [ "cc", ] +[[package]] +name = "pulley-interpreter" +version = "26.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df33e7f8a43ccc7f93b330fef4baf271764674926f3f4d40f4a196d54de8af26" +dependencies = [ + "cranelift-bitset", + "log", + "sptr", +] + [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", - "rustc-hash 2.0.0", + "rustc-hash", "rustls", "socket2", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand", "ring", - "rustc-hash 2.0.0", + "rustc-hash", "rustls", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] name = "quinn-udp" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e346e016eacfff12233c243718197ca12f148c84e1e84268a896699b41c71780" +checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" dependencies = [ "cfg_aliases", "libc", @@ -2710,18 +2687,18 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "regalloc2" -version = "0.9.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +checksum = "12908dbeb234370af84d0579b9f68258a0f67e201412dd9a2814e6f45b2fc0f0" dependencies = [ - "hashbrown 0.13.2", + "hashbrown 0.14.5", "log", - "rustc-hash 1.1.0", + "rustc-hash", "slice-group-by", "smallvec", ] @@ -2734,7 +2711,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -2749,9 +2726,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -2797,7 +2774,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", - "rustls-native-certs 0.8.0", + "rustls-native-certs 0.8.1", "rustls-pemfile", "rustls-pki-types", "serde", @@ -2866,12 +2843,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "rustc-hash" version = "2.0.0" @@ -2880,9 +2851,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags", "errno", @@ -2895,9 +2866,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" dependencies = [ "log", "once_cell", @@ -2918,20 +2889,19 @@ dependencies = [ "rustls-pemfile", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 2.11.1", ] [[package]] name = "rustls-native-certs" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.0.1", ] [[package]] @@ -2948,6 +2918,9 @@ name = "rustls-pki-types" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -2983,18 +2956,18 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.4" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" +checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" dependencies = [ "sdd", ] [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -3012,9 +2985,9 @@ dependencies = [ [[package]] name = "schematic" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9803bd9e6cccb1cc9cec6943f34ba93aa6cf7b6f183ee20a43457934dbc2b686" +checksum = "b13cc48a6f0f9cdb16cfa88f7a104e1e77483b03e154b0de40c68af41462d0db" dependencies = [ "garde", "indexmap", @@ -3027,16 +3000,16 @@ dependencies = [ "serde_json", "serde_path_to_error", "starbase_styles", - "thiserror", + "thiserror 1.0.69", "toml", "tracing", ] [[package]] name = "schematic_macros" -version = "0.17.3" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "641ca4c08e2735689cbc88901b755a806cbdb328a5dbddcd9176ec6de2ce59b0" +checksum = "5336c468775c5083eaa2958608f68937c491686a079d108e246345f370623f9a" dependencies = [ "convert_case", "darling", @@ -3047,9 +3020,9 @@ dependencies = [ [[package]] name = "schematic_types" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baae6c4555fd2a9cad6b1675fde90c8c3eff3772a1053b251d6ff0d547852e1f" +checksum = "768ff9d8765442119bfb73b7808607f76f75fb2987932637d43b144d6ad5e3fe" dependencies = [ "indexmap", "semver", @@ -3078,7 +3051,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +dependencies = [ + "bitflags", + "core-foundation 0.10.0", "core-foundation-sys", "libc", "security-framework-sys", @@ -3086,9 +3072,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -3125,9 +3111,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap", "itoa", @@ -3321,9 +3307,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "starbase" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b55189276998800e553d329ab7218e1a81688661901268a0cad0b774d6d70d" +checksum = "472e15cb7da9f3348555a671fe61e58fc901ecdfc45972fe304a2f367e2eb424" dependencies = [ "async-trait", "chrono", @@ -3337,18 +3323,18 @@ dependencies = [ [[package]] name = "starbase_archive" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddcd0a8668af71ac7aaec90d5c75237d48f7cfc2b68f0ca06cafc683e2ab584c" +checksum = "2b4c102781eddb9417186f40eb49ef6e1b3dade352bbffe405e95c3427c6170b" dependencies = [ "binstall-tar", "bzip2", "flate2", "miette", - "rustc-hash 2.0.0", + "rustc-hash", "starbase_styles", "starbase_utils", - "thiserror", + "thiserror 2.0.3", "tracing", "xz2", "zip", @@ -3357,9 +3343,9 @@ dependencies = [ [[package]] name = "starbase_sandbox" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00380c6d481a26cd65866100980aabc75b6ad3425ea7fe5b741fdf3ada9d7674" +checksum = "eea28a45557a5974e6995a36bf34cb56bda35cbfc0d9536089c83e9c0d2414c1" dependencies = [ "assert_cmd", "assert_fs", @@ -3372,22 +3358,22 @@ dependencies = [ [[package]] name = "starbase_shell" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b465ae225b09ac539963cd85448fff7520e82320ff2a120f648990fb064229" +checksum = "8c92e59e9cb8234c7d07f8260b7196c0d0cd29f4b31cfad8180bc3bcfe0c2619" dependencies = [ "miette", "regex", "sysinfo", - "thiserror", + "thiserror 2.0.3", "tracing", ] [[package]] name = "starbase_styles" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "358d0e98dc524ef2b838e9e70367c899d5ef8629f4efb44add57d92da6e75a8f" +checksum = "b1664b29d64bf37a14a0f50ae4c1568eb712c7eb28fb489aabac81c36e5558c1" dependencies = [ "dirs 5.0.1", "miette", @@ -3397,9 +3383,9 @@ dependencies = [ [[package]] name = "starbase_utils" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92724184aae5faf89b2ded8ac247e24cb0720f3eb5ec163509fb6994cdfa6f9d" +checksum = "fb5d48b4190c4e94d9f6e8dc3487228500f78d5920655d357b1a5c086a995c28" dependencies = [ "dirs 5.0.1", "fs4", @@ -3411,7 +3397,7 @@ dependencies = [ "serde_json", "serde_yaml", "starbase_styles", - "thiserror", + "thiserror 2.0.3", "tokio", "toml", "tracing", @@ -3479,9 +3465,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -3490,9 +3476,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -3528,7 +3514,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys", ] @@ -3566,7 +3552,7 @@ dependencies = [ "serde", "serde_json", "shell-words", - "thiserror", + "thiserror 2.0.3", ] [[package]] @@ -3577,9 +3563,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -3621,7 +3607,7 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -3630,7 +3616,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -3644,6 +3639,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thread_local" version = "1.1.8" @@ -3809,9 +3815,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -3866,9 +3872,9 @@ checksum = "10103c57044730945224467c09f71a4db0071c123a0648cc3e818913bde6b561" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-linebreak" @@ -3888,6 +3894,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -3925,9 +3937,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -3983,7 +3995,7 @@ dependencies = [ "schematic", "semver", "serde", - "thiserror", + "thiserror 2.0.3", ] [[package]] @@ -4033,7 +4045,7 @@ dependencies = [ "starbase_styles", "starbase_utils", "system_env", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", "ureq", @@ -4045,12 +4057,12 @@ name = "warpgate_api" version = "0.10.1" dependencies = [ "anyhow", - "rustc-hash 2.0.0", + "rustc-hash", "schematic", "serde", "serde_json", "system_env", - "thiserror", + "thiserror 2.0.3", ] [[package]] @@ -4070,9 +4082,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-common" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ddca85a537113179aae69f1faf916401113acb66e4b52b86483344bc5ae43fa" +checksum = "165a969c7b4ac223150e2819df36d58b8f24b06320dc314503f90300e5e18bc1" dependencies = [ "anyhow", "bitflags", @@ -4087,11 +4099,11 @@ dependencies = [ "once_cell", "rustix", "system-interface", - "thiserror", + "thiserror 1.0.69", "tracing", "wasmtime", "wiggle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4163,21 +4175,21 @@ checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-encoder" -version = "0.212.0" +version = "0.218.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501940df4418b8929eb6d52f1aade1fdd15a5b86c92453cb696e3c906bd3fc33" +checksum = "22b896fa8ceb71091ace9bcb81e853f54043183a1c9667cf93422c40252ffa0a" dependencies = [ "leb128", ] [[package]] name = "wasm-encoder" -version = "0.219.1" +version = "0.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54" +checksum = "ebf48234b389415b226a4daef6562933d38c7b28a8b8f64c5c4130dad1561ab7" dependencies = [ "leb128", - "wasmparser 0.219.1", + "wasmparser 0.220.0", ] [[package]] @@ -4195,9 +4207,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.212.0" +version = "0.218.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d28bc49ba1e5c5b61ffa7a2eace10820443c4b7d1c0b144109261d14570fdf8" +checksum = "b09e46c7fceceaa72b2dd1a8a137ea7fd8f93dfaa69806010a709918e496c5dc" dependencies = [ "ahash", "bitflags", @@ -4209,9 +4221,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.219.1" +version = "0.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5" +checksum = "e246c2772ce3ebc83f89a2d4487ac5794cad6c309b2071818a88c7db7c36d87b" dependencies = [ "bitflags", "indexmap", @@ -4219,22 +4231,22 @@ dependencies = [ [[package]] name = "wasmprinter" -version = "0.212.0" +version = "0.218.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfac65326cc561112af88c3028f6dfdb140acff67ede33a8e86be2dc6b8956f7" +checksum = "0ace089155491837b75f474bf47c99073246d1b737393fe722d6dee311595ddc" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.212.0", + "wasmparser 0.218.0", ] [[package]] name = "wasmtime" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe501caefeb9f7b15360bdd7e47ad96e20223846f1c7db485ae5820ba5acc3d2" +checksum = "51e762e163fd305770c6c341df3290f0cabb3c264e7952943018e9a1ced8d917" dependencies = [ - "addr2line 0.21.0", + "addr2line", "anyhow", "async-trait", "bitflags", @@ -4243,7 +4255,7 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "gimli 0.28.1", + "gimli", "hashbrown 0.14.5", "indexmap", "ittapi", @@ -4257,6 +4269,7 @@ dependencies = [ "paste", "postcard", "psm", + "pulley-interpreter", "rayon", "rustix", "semver", @@ -4266,8 +4279,8 @@ dependencies = [ "smallvec", "sptr", "target-lexicon", - "wasm-encoder 0.212.0", - "wasmparser 0.212.0", + "wasm-encoder 0.218.0", + "wasmparser 0.218.0", "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", @@ -4281,23 +4294,23 @@ dependencies = [ "wasmtime-versioned-export-macros", "wasmtime-winch", "wat", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "wasmtime-asm-macros" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904a057d74bfa0ad9369a3fd99231d81ba0345f059d03c9148c3bb2abbf310f" +checksum = "63caa7aebb546374e26257a1900fb93579171e7c02514cde26805b9ece3ef812" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dff4d467d6b5bd0d137f5426f45178222e40b59e49ab3a7361420262b9f00df" +checksum = "c7192f71e3afe32e858729454d9d90d6e927bd92427d688a9507d8220bddb256" dependencies = [ "anyhow", "base64 0.21.7", @@ -4309,15 +4322,15 @@ dependencies = [ "serde_derive", "sha2", "toml", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a96185dab1c14ffb986ff2b3a2185d15acf2b801ca7895aa35ee80328e2ce38" +checksum = "d61a4b5ce2ad9c15655e830f0eac0c38b8def30c74ecac71f452d3901e491b68" dependencies = [ "anyhow", "proc-macro2", @@ -4330,15 +4343,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a40200d42a8985edadb4007a0ed320756cbe28065b83e0027e39524c1b1b22" +checksum = "35e87a1212270dbb84a49af13d82594e00a92769d6952b0ea7fc4366c949f6ad" [[package]] name = "wasmtime-cranelift" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b099ef9b7808fa8d18cad32243e78e9c07a4a8aacfa913d88dc08704b1643c49" +checksum = "7cb40dddf38c6a5eefd5ce7c1baf43b00fe44eada11a319fab22e993a960262f" dependencies = [ "anyhow", "cfg-if", @@ -4347,28 +4360,29 @@ dependencies = [ "cranelift-entity", "cranelift-frontend", "cranelift-native", - "cranelift-wasm", - "gimli 0.28.1", + "gimli", + "itertools 0.12.1", "log", "object", + "smallvec", "target-lexicon", - "thiserror", - "wasmparser 0.212.0", + "thiserror 1.0.69", + "wasmparser 0.218.0", "wasmtime-environ", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-environ" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f1765f6ca1a166927bee13ad4aed7bf18269f34c0cd7d6d523889a0b52e6ee" +checksum = "8613075e89e94a48c05862243c2b718eef1b9c337f51493ebf951e149a10fa19" dependencies = [ "anyhow", "cpp_demangle", "cranelift-bitset", "cranelift-entity", - "gimli 0.28.1", + "gimli", "indexmap", "log", "object", @@ -4377,19 +4391,19 @@ dependencies = [ "semver", "serde", "serde_derive", + "smallvec", "target-lexicon", - "wasm-encoder 0.212.0", - "wasmparser 0.212.0", + "wasm-encoder 0.218.0", + "wasmparser 0.218.0", "wasmprinter", "wasmtime-component-util", - "wasmtime-types", ] [[package]] name = "wasmtime-fiber" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "047be22a9ebe0343e583edf52b89b60a87e37bec1bc71dc127d3c7fb287c4471" +checksum = "77acabfbcd89a4d47ad117fb31e340c824e2f49597105402c3127457b6230995" dependencies = [ "anyhow", "cc", @@ -4397,14 +4411,14 @@ dependencies = [ "rustix", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "wasmtime-jit-debug" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2383b29fd973222293b5ff562f81a67c7e558b669685ca13f8cb80d04ea24b2d" +checksum = "f02a0118d471de665565ed200bc56673eaa10cc8e223dfe2cef5d50ed0d9d143" dependencies = [ "object", "once_cell", @@ -4414,41 +4428,27 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1a826e4ccd0803b2f7463289cad104f40d09d06bc8acf1a614230a47b4d96f" +checksum = "da47fba49af72581bc0dc67c8faaf5ee550e6f106e285122a184a675193701a5" dependencies = [ "anyhow", "cfg-if", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "wasmtime-slab" -version = "23.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92a137c17c992eb5eaacfa0f0590353471e49dbb4bdbdf9cf7536d66109e63a" - -[[package]] -name = "wasmtime-types" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6072ac3267866d99ca726b6a4f157df9b733aac8082e902d527368f07c303ba" -dependencies = [ - "anyhow", - "cranelift-entity", - "serde", - "serde_derive", - "smallvec", - "wasmparser 0.212.0", -] +checksum = "770e10cdefb15f2b6304152978e115bd062753c1ebe7221c0b6b104fa0419ff6" [[package]] name = "wasmtime-versioned-export-macros" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bde986038b819bc43a21fef0610aeb47aabfe3ea09ca3533a7b81023b84ec6" +checksum = "db8efb877c9e5e67239d4553bb44dd2a34ae5cfb728f3cf2c5e64439c6ca6ee7" dependencies = [ "proc-macro2", "quote", @@ -4457,16 +4457,16 @@ dependencies = [ [[package]] name = "wasmtime-winch" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beb1abdc26ddf1d7c819ea0fcbfccb0808410549d28bb3154c9bdb7d11fbcc58" +checksum = "4f7a267367382ceec3e7f7ace63a63b83d86f4a680846743dead644e10f08150" dependencies = [ "anyhow", "cranelift-codegen", - "gimli 0.28.1", + "gimli", "object", "target-lexicon", - "wasmparser 0.212.0", + "wasmparser 0.218.0", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -4474,12 +4474,12 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f88e49a9b81746ec0cede5505e40a4012c92cb5054cd7ef4300dc57c36f26b1" +checksum = "4bef2a726fd8d1ee9b0144655e16c492dc32eb4c7c9f7e3309fcffe637870933" dependencies = [ "anyhow", - "heck 0.4.1", + "heck 0.5.0", "indexmap", "wit-parser", ] @@ -4495,24 +4495,24 @@ dependencies = [ [[package]] name = "wast" -version = "219.0.1" +version = "220.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f79a9d9df79986a68689a6b40bcc8d5d40d807487b235bebc2ac69a242b54a1" +checksum = "4e708c8de08751fd66e70961a32bae9d71901f14a70871e181cb8461a3bb3165" dependencies = [ "bumpalo", "leb128", "memchr", - "unicode-width", - "wasm-encoder 0.219.1", + "unicode-width 0.2.0", + "wasm-encoder 0.220.0", ] [[package]] name = "wat" -version = "1.219.1" +version = "1.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bc3cf014fb336883a411cd662f987abf6a1d2a27f2f0008616a0070bbf6bd0d" +checksum = "de4f1d7d59614ba690541360102b995c4eb1b9ed373701d5102cc1a968b1c5a3" dependencies = [ - "wast 219.0.1", + "wast 220.0.0", ] [[package]] @@ -4526,7 +4526,7 @@ dependencies = [ "nom", "pori", "regex", - "thiserror", + "thiserror 1.0.69", "walkdir", ] @@ -4540,25 +4540,35 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] [[package]] name = "wiggle" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "522bdb5756a42b3e01e9e3097f0d8a2a6b00ffdea50c6aa1a301497813c81cf8" +checksum = "b0f25588cf5ea16f56c1af13244486d50c5a2cf67cc0c4e990c665944d741546" dependencies = [ "anyhow", "async-trait", "bitflags", - "thiserror", + "thiserror 1.0.69", "tracing", "wasmtime", "wiggle-macro", @@ -4567,12 +4577,12 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8979d5490e31efec2beb6c8f58435acceedae52cda9c755456005c0b370ca343" +checksum = "28ff23bed568b335dac6a324b8b167318a0c60555199445fcc89745a5eb42452" dependencies = [ "anyhow", - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "shellexpand", @@ -4582,9 +4592,9 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "23.0.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f8feabe94ce6f07d62669d1acf469e0d3249f786562b4263dff3537a4e77ae" +checksum = "7f13be83541aa0b033ac5ec8a8b59c9a8d8b32305845b8466dd066e722cb0004" dependencies = [ "proc-macro2", "quote", @@ -4625,17 +4635,17 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.21.3" +version = "26.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a666bf2cdb838e68b9b8370d7ebf8806b87ccc0d89a634bfc9ed8ffca1f19591" +checksum = "07ab957fc71a36c63834b9b51cc2e087c4260d5ff810a5309ab99f7fbeb19567" dependencies = [ "anyhow", "cranelift-codegen", - "gimli 0.28.1", + "gimli", "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.212.0", + "wasmparser 0.218.0", "wasmtime-cranelift", "wasmtime-environ", ] @@ -4911,9 +4921,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.212.0" +version = "0.218.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceeb0424aa8679f3fcf2d6e3cfa381f3d6fa6179976a2c05a6249dd2bb426716" +checksum = "0d3d1066ab761b115f97fef2b191090faabcb0f37b555b758d3caf42d4ed9e55" dependencies = [ "anyhow", "id-arena", @@ -4924,7 +4934,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.212.0", + "wasmparser 0.218.0", ] [[package]] @@ -4935,7 +4945,7 @@ checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" dependencies = [ "anyhow", "log", - "thiserror", + "thiserror 1.0.69", "wast 35.0.2", ] @@ -4979,9 +4989,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -4991,9 +5001,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", @@ -5024,18 +5034,18 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", @@ -5073,9 +5083,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" +checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" dependencies = [ "arbitrary", "crc32fast", @@ -5084,7 +5094,7 @@ dependencies = [ "flate2", "indexmap", "memchr", - "thiserror", + "thiserror 2.0.3", "zopfli", ] diff --git a/Cargo.toml b/Cargo.toml index 5e9a524a7..85dc3fd8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,10 @@ members = ["crates/*"] default-members = ["crates/cli"] [workspace.dependencies] -anyhow = "1.0.91" +anyhow = "1.0.93" async-trait = "0.1.83" -clap = "4.5.20" -clap_complete = "4.5.36" +clap = "4.5.21" +clap_complete = "4.5.38" dirs = "5.0.1" extism = ">=1.6.0" # Lower for consumers extism-pdk = "1.3.0" @@ -22,15 +22,15 @@ reqwest = { version = "0.12.9", default-features = false, features = [ "macos-system-configuration", ] } rustc-hash = "2.0.0" -scc = "2.2.4" -schematic = { version = "0.17.5", default-features = false } +scc = "2.2.5" +schematic = { version = "0.17.6", default-features = false } semver = { version = "1.0.23", features = ["serde"] } serde = { version = "1.0.214", features = ["derive"] } -serde_json = "1.0.132" +serde_json = "1.0.133" sha2 = "0.10.8" shell-words = "1.1.0" -starbase = { version = "0.9.4" } -starbase_archive = { version = "0.8.9", features = [ +starbase = { version = "0.9.5" } +starbase_archive = { version = "0.8.10", features = [ "gz", "miette", "tar-bz2", @@ -41,16 +41,16 @@ starbase_archive = { version = "0.8.9", features = [ "zip-deflate", ] } starbase_events = { version = "0.6.3" } -starbase_sandbox = { version = "0.7.6" } -starbase_shell = { version = "0.6.1", features = ["miette"] } -starbase_styles = { version = "0.4.5" } -starbase_utils = { version = "0.8.12", default-features = false, features = [ +starbase_sandbox = { version = "0.7.7" } +starbase_shell = { version = "0.6.3", features = ["miette"] } +starbase_styles = { version = "0.4.6" } +starbase_utils = { version = "0.8.13", default-features = false, features = [ "json", "miette", "net", "toml", ] } -thiserror = "1.0.65" +thiserror = "2.0.3" tokio = { version = "1.41.0", features = ["full", "tracing"] } tracing = "0.1.40" uuid = { version = "1.11.0", features = ["v4"] } diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index d59106a5b..c6d9554b3 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -43,11 +43,11 @@ chrono = "0.4.38" clap = { workspace = true, features = ["derive", "env"] } clap_complete = { workspace = true } clap_complete_nushell = "4.5.4" -comfy-table = "7.1.1" +comfy-table = "7.1.3" dialoguer = "0.11.0" dirs = { workspace = true } indexmap = { workspace = true } -indicatif = { version = "0.17.8", features = ["improved_unicode"] } +indicatif = { version = "0.17.9", features = ["improved_unicode"] } miette = { workspace = true } regex = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls-native-roots"] } @@ -67,11 +67,11 @@ rust_json = "0.1.5" sigpipe = "0.1.3" # For extism/wastime -extism = "1.8.0" -regalloc2 = "=0.9.3" -wasmtime = "~23.0.3" -wasi-common = "~23.0.3" -wiggle = "~23.0.3" +extism = "1.9.0" +regalloc2 = "=0.10.2" +wasmtime = "~26.0.1" +wasi-common = "~26.0.1" +wiggle = "~26.0.1" [dev-dependencies] starbase_sandbox = { workspace = true } diff --git a/crates/cli/src/shell.rs b/crates/cli/src/shell.rs index 36ebc974b..83957f27a 100644 --- a/crates/cli/src/shell.rs +++ b/crates/cli/src/shell.rs @@ -27,10 +27,7 @@ pub fn find_profiles(shell: &BoxedShell, home_dir: &Path) -> miette::Result miette::Result { - let profiles = find_profiles(shell, home_dir)?; - - // Check in reverse order as the most common profile is always last in the list - for profile in profiles.into_iter().rev() { + for profile in find_profiles(shell, home_dir)? { if profile.exists() { return Ok(profile); } @@ -124,10 +121,7 @@ pub fn prompt_for_shell_profile( home_dir: &Path, ) -> miette::Result> { let theme = create_theme(); - - let mut profiles = find_profiles(shell, home_dir)?; - profiles.reverse(); - + let profiles = find_profiles(shell, home_dir)?; let mut items = profiles.iter().map(color::path).collect::>(); items.push("Other".to_owned()); items.push("None".to_owned()); diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index a2025fdad..7c24991f8 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -45,7 +45,7 @@ starbase_styles = { workspace = true } starbase_utils = { workspace = true, features = ["fs-lock", "yaml"] } thiserror = { workspace = true } tracing = { workspace = true } -url = { version = "2.5.2", features = ["serde"] } +url = { version = "2.5.4", features = ["serde"] } uuid = { workspace = true } [dev-dependencies] From b8bf3afd52b53d64688e92ae733e2446342db0d8 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 25 Nov 2024 18:08:18 -0800 Subject: [PATCH 03/12] internal: Use `compact_str` where applicable. (#658) --- CHANGELOG.md | 1 + Cargo.lock | 19 +++++++++++- Cargo.toml | 3 ++ crates/cli/src/commands/alias.rs | 2 +- crates/core/src/error.rs | 4 +-- crates/core/src/proto_config.rs | 2 +- crates/core/src/version_resolver.rs | 13 +++++--- crates/version-spec/Cargo.toml | 1 + crates/version-spec/src/resolved_spec.rs | 5 +-- crates/version-spec/src/unresolved_spec.rs | 7 +++-- .../version-spec/tests/resolved_spec_test.rs | 9 +++--- .../tests/unresolved_spec_test.rs | 15 ++++----- crates/warpgate/Cargo.toml | 1 + crates/warpgate/src/error.rs | 16 +++++----- crates/warpgate/src/id.rs | 31 ++++++++++--------- 15 files changed, 80 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6adb761c3..d04ed017c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ #### ⚙️ Internal +- Updated identifiers, versions, and locators to use [compact strings](https://crates.io/crates/compact_str). - Updated wasmtime to v26 (from v23). ## 0.42.2 diff --git a/Cargo.lock b/Cargo.lock index 6a8805152..252956059 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,6 +536,21 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "compact_str" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6050c3a16ddab2e412160b31f2c871015704239bca62f72f6e5f0be631d3f644" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "serde", + "static_assertions", +] + [[package]] name = "console" version = "0.15.8" @@ -1295,7 +1310,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a3233677ea1554a48235d81bb59d2a41654969a8e29a1316c48105fd1701693" dependencies = [ - "compact_str", + "compact_str 0.7.1", "garde_derive", "once_cell", "regex", @@ -3990,6 +4005,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" name = "version_spec" version = "0.7.0" dependencies = [ + "compact_str 0.8.0", "human-sort", "regex", "schematic", @@ -4030,6 +4046,7 @@ dependencies = [ name = "warpgate" version = "0.19.0" dependencies = [ + "compact_str 0.8.0", "extism", "miette", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 85dc3fd8e..52fc17bfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,9 @@ anyhow = "1.0.93" async-trait = "0.1.83" clap = "4.5.21" clap_complete = "4.5.38" +compact_str = { version = "0.8.0", default-features = false, features = [ + "serde", +] } dirs = "5.0.1" extism = ">=1.6.0" # Lower for consumers extism-pdk = "1.3.0" diff --git a/crates/cli/src/commands/alias.rs b/crates/cli/src/commands/alias.rs index 88397a314..372be505a 100644 --- a/crates/cli/src/commands/alias.rs +++ b/crates/cli/src/commands/alias.rs @@ -27,7 +27,7 @@ pub struct AliasArgs { #[tracing::instrument(skip_all)] pub async fn alias(session: ProtoSession, args: AliasArgs) -> AppResult { if let UnresolvedVersionSpec::Alias(inner_alias) = &args.spec { - if &args.alias == inner_alias { + if args.alias == inner_alias { return Err(ProtoCliError::NoMatchingAliasToVersion.into()); } } diff --git a/crates/core/src/error.rs b/crates/core/src/error.rs index 15664709e..e1a4e2749 100644 --- a/crates/core/src/error.rs +++ b/crates/core/src/error.rs @@ -56,7 +56,7 @@ pub enum ProtoError { #[diagnostic(code(proto::minimum_version_requirement))] #[error( "Unable to use the {tool} plugin with identifier {}, as it requires a minimum proto version of {}, but found {} instead.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .expected.style(Style::Hash), .actual.style(Style::Hash) )] @@ -119,7 +119,7 @@ pub enum ProtoError { #[diagnostic(code(proto::tool::unknown))] #[error( "Unable to proceed, {} is not a built-in tool and has not been configured with {} in a {} file.\n\nLearn more about plugins: {}\nSearch community plugins: {}", - .id.style(Style::Id), + .id.to_string().style(Style::Id), "[plugins]".style(Style::Property), PROTO_CONFIG_NAME.style(Style::File), "https://moonrepo.dev/docs/proto/plugins".style(Style::Url), diff --git a/crates/core/src/proto_config.rs b/crates/core/src/proto_config.rs index cf2b6cea0..87d46762e 100644 --- a/crates/core/src/proto_config.rs +++ b/crates/core/src/proto_config.rs @@ -432,7 +432,7 @@ impl ProtoConfig { if config .versions .as_ref() - .is_some_and(|versions| versions.contains_key(field)) + .is_some_and(|versions| versions.contains_key(field.as_str())) { continue; } diff --git a/crates/core/src/version_resolver.rs b/crates/core/src/version_resolver.rs index 7e3c1a1a7..c3b1b3468 100644 --- a/crates/core/src/version_resolver.rs +++ b/crates/core/src/version_resolver.rs @@ -115,28 +115,31 @@ pub fn resolve_version( return Some(VersionSpec::Canary); } UnresolvedVersionSpec::Alias(alias) => { - trace!(alias, "Found an alias, resolving further"); + trace!(alias = alias.as_str(), "Found an alias, resolving further"); let mut alias_value = None; if let Some(config) = config { - alias_value = config.aliases.get(alias); + alias_value = config.aliases.get(alias.as_str()); } if alias_value.is_none() { - alias_value = aliases.get(alias); + alias_value = aliases.get(alias.as_str()); } if let Some(value) = alias_value { trace!( - alias, + alias = alias.as_str(), candidate = value.to_string(), "Alias exists with a potential candidate" ); return resolve_version(value, versions, aliases, manifest, config); } else { - trace!(alias, "Alias does not exist, trying others"); + trace!( + alias = alias.as_str(), + "Alias does not exist, trying others" + ); } } UnresolvedVersionSpec::Req(req) => { diff --git a/crates/version-spec/Cargo.toml b/crates/version-spec/Cargo.toml index 2dbbf91d7..d7375c2c1 100644 --- a/crates/version-spec/Cargo.toml +++ b/crates/version-spec/Cargo.toml @@ -8,6 +8,7 @@ homepage = "https://moonrepo.dev/proto" repository = "https://github.com/moonrepo/proto" [dependencies] +compact_str = { workspace = true } human-sort = { workspace = true } regex = { workspace = true } schematic = { workspace = true, optional = true, features = ["schema"] } diff --git a/crates/version-spec/src/resolved_spec.rs b/crates/version-spec/src/resolved_spec.rs index d0579c5b5..c56fe866c 100644 --- a/crates/version-spec/src/resolved_spec.rs +++ b/crates/version-spec/src/resolved_spec.rs @@ -3,6 +3,7 @@ use crate::spec_error::SpecError; use crate::{clean_version_string, is_alias_name, is_calver, UnresolvedVersionSpec}; use crate::{is_semver, version_types::*}; +use compact_str::CompactString; use semver::Version; use serde::{Deserialize, Serialize}; use std::fmt; @@ -15,7 +16,7 @@ pub enum VersionSpec { /// A special canary target. Canary, /// An alias that is used as a map to a version. - Alias(String), + Alias(CompactString), /// A fully-qualified calendar version. Calendar(CalVer), /// A fully-qualified semantic version. @@ -108,7 +109,7 @@ impl FromStr for VersionSpec { let value = clean_version_string(value); if is_alias_name(&value) { - return Ok(VersionSpec::Alias(value)); + return Ok(VersionSpec::Alias(CompactString::new(value))); } if is_calver(&value) { diff --git a/crates/version-spec/src/unresolved_spec.rs b/crates/version-spec/src/unresolved_spec.rs index 5db5404dd..ba0de3f72 100644 --- a/crates/version-spec/src/unresolved_spec.rs +++ b/crates/version-spec/src/unresolved_spec.rs @@ -4,6 +4,7 @@ use crate::spec_error::SpecError; use crate::unresolved_parser::*; use crate::version_types::*; use crate::{clean_version_req_string, clean_version_string, is_alias_name, VersionSpec}; +use compact_str::CompactString; use semver::VersionReq; use serde::{Deserialize, Serialize}; use std::fmt::{Debug, Display}; @@ -17,7 +18,7 @@ pub enum UnresolvedVersionSpec { /// A special canary target. Canary, /// An alias that is used as a map to a version. - Alias(String), + Alias(CompactString), /// A partial version, requirement, or range (`^`, `~`, etc). Req(VersionReq), /// A list of requirements to match any against (joined by `||`). @@ -78,7 +79,7 @@ impl UnresolvedVersionSpec { pub fn to_resolved_spec(&self) -> VersionSpec { match self { Self::Canary => VersionSpec::Canary, - Self::Alias(alias) => VersionSpec::Alias(alias.to_owned()), + Self::Alias(alias) => VersionSpec::Alias(CompactString::new(alias)), Self::Calendar(version) => VersionSpec::Calendar(version.to_owned()), Self::Semantic(version) => VersionSpec::Semantic(version.to_owned()), _ => VersionSpec::default(), @@ -116,7 +117,7 @@ impl FromStr for UnresolvedVersionSpec { let value = clean_version_string(value); if is_alias_name(&value) { - return Ok(UnresolvedVersionSpec::Alias(value)); + return Ok(UnresolvedVersionSpec::Alias(CompactString::new(value))); } let value = clean_version_req_string(&value); diff --git a/crates/version-spec/tests/resolved_spec_test.rs b/crates/version-spec/tests/resolved_spec_test.rs index 4fd678dd0..71763cebf 100644 --- a/crates/version-spec/tests/resolved_spec_test.rs +++ b/crates/version-spec/tests/resolved_spec_test.rs @@ -1,3 +1,4 @@ +use compact_str::CompactString; use semver::Version; use version_spec::{CalVer, SemVer, VersionSpec}; @@ -13,19 +14,19 @@ mod resolved_spec { fn aliases() { assert_eq!( VersionSpec::parse("latest").unwrap(), - VersionSpec::Alias("latest".to_owned()) + VersionSpec::Alias(CompactString::new("latest")) ); assert_eq!( VersionSpec::parse("stable").unwrap(), - VersionSpec::Alias("stable".to_owned()) + VersionSpec::Alias(CompactString::new("stable")) ); assert_eq!( VersionSpec::parse("legacy-2023").unwrap(), - VersionSpec::Alias("legacy-2023".to_owned()) + VersionSpec::Alias(CompactString::new("legacy-2023")) ); assert_eq!( VersionSpec::parse("future/202x").unwrap(), - VersionSpec::Alias("future/202x".to_owned()) + VersionSpec::Alias(CompactString::new("future/202x")) ); } diff --git a/crates/version-spec/tests/unresolved_spec_test.rs b/crates/version-spec/tests/unresolved_spec_test.rs index ceb0d85f8..fb13c8c8a 100644 --- a/crates/version-spec/tests/unresolved_spec_test.rs +++ b/crates/version-spec/tests/unresolved_spec_test.rs @@ -1,3 +1,4 @@ +use compact_str::CompactString; use semver::{Version, VersionReq}; use version_spec::{CalVer, SemVer, UnresolvedVersionSpec}; @@ -16,19 +17,19 @@ mod unresolved_spec { fn aliases() { assert_eq!( UnresolvedVersionSpec::parse("latest").unwrap(), - UnresolvedVersionSpec::Alias("latest".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("latest")) ); assert_eq!( UnresolvedVersionSpec::parse("stable").unwrap(), - UnresolvedVersionSpec::Alias("stable".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("stable")) ); assert_eq!( UnresolvedVersionSpec::parse("legacy-2023").unwrap(), - UnresolvedVersionSpec::Alias("legacy-2023".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("legacy-2023")) ); assert_eq!( UnresolvedVersionSpec::parse("future/202x").unwrap(), - UnresolvedVersionSpec::Alias("future/202x".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("future/202x")) ); } @@ -171,15 +172,15 @@ mod unresolved_spec { fn parses_alias() { assert_eq!( UnresolvedVersionSpec::parse("stable").unwrap(), - UnresolvedVersionSpec::Alias("stable".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("stable")) ); assert_eq!( UnresolvedVersionSpec::parse("latest").unwrap(), - UnresolvedVersionSpec::Alias("latest".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("latest")) ); assert_eq!( UnresolvedVersionSpec::parse("lts-2014").unwrap(), - UnresolvedVersionSpec::Alias("lts-2014".to_owned()) + UnresolvedVersionSpec::Alias(CompactString::new("lts-2014")) ); } diff --git a/crates/warpgate/Cargo.toml b/crates/warpgate/Cargo.toml index 5b46d20f3..ad6b24e34 100644 --- a/crates/warpgate/Cargo.toml +++ b/crates/warpgate/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/moonrepo/proto" [dependencies] system_env = { version = "0.6.1", path = "../system-env" } warpgate_api = { version = "0.10.1", path = "../warpgate-api" } +compact_str = { workspace = true } extism = { workspace = true, features = ["http"] } miette = { workspace = true } once_cell = { workspace = true } diff --git a/crates/warpgate/src/error.rs b/crates/warpgate/src/error.rs index bba4c6989..bcab60bfe 100644 --- a/crates/warpgate/src/error.rs +++ b/crates/warpgate/src/error.rs @@ -32,7 +32,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::source::file_missing))] #[error( "Cannot load {} plugin, source file {} does not exist.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .path.style(Style::Path), )] SourceFileMissing { id: Id, path: PathBuf }, @@ -40,7 +40,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::github::asset_missing))] #[error( "Cannot download {} plugin from GitHub ({}), no tag found, matched, or provided.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .repo_slug.style(Style::Id), )] GitHubTagMissing { id: Id, repo_slug: String }, @@ -48,7 +48,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::github::asset_missing))] #[error( "Cannot download {} plugin from GitHub ({}), no applicable asset found for release {}.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .repo_slug.style(Style::Id), .tag, )] @@ -59,7 +59,7 @@ pub enum WarpgateError { }, #[diagnostic(code(plugin::create::failed))] - #[error("Failed to load and create {} plugin: {error}", .id.style(Style::Id))] + #[error("Failed to load and create {} plugin: {error}", .id.to_string().style(Style::Id))] PluginCreateFailed { id: Id, #[source] @@ -69,7 +69,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::call_func::failed))] #[error( "Failed to call {} plugin function {}:\n{error}", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .func.style(Style::Property), )] PluginCallFailed { id: Id, func: String, error: String }, @@ -87,7 +87,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::call_func::format_input))] #[error( "Failed to format input for {} plugin function {} call.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .func.style(Style::Property), )] FormatInputFailed { @@ -100,7 +100,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::call_func::parse_output))] #[error( "Failed to parse output of {} plugin function {} call.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), .func.style(Style::Property), )] ParseOutputFailed { @@ -146,7 +146,7 @@ pub enum WarpgateError { #[diagnostic(code(plugin::incompatible_runtime))] #[error( "The loaded {} plugin is incompatible with the current runtime.\nFor plugin consumers, try upgrading to a newer plugin version.\nFor plugin authors, upgrade to the latest runtime and release a new version.", - .id.style(Style::Id), + .id.to_string().style(Style::Id), )] IncompatibleRuntime { id: Id }, } diff --git a/crates/warpgate/src/id.rs b/crates/warpgate/src/id.rs index f0279ade9..1c46f90d9 100644 --- a/crates/warpgate/src/id.rs +++ b/crates/warpgate/src/id.rs @@ -1,4 +1,5 @@ use crate::error::WarpgateError; +use compact_str::CompactString; use regex::Regex; use serde::{de, Deserialize, Deserializer, Serialize}; use std::sync::LazyLock; @@ -9,7 +10,7 @@ pub static ID_PATTERN: LazyLock = /// An identifier for plugins. #[derive(Clone, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -pub struct Id(String); +pub struct Id(CompactString); impl Id { pub fn new>(id: S) -> Result { @@ -23,7 +24,7 @@ impl Id { } pub fn raw>(id: S) -> Id { - Id(id.as_ref().to_owned()) + Id(CompactString::new(id)) } pub fn as_str(&self) -> &str { @@ -57,11 +58,11 @@ impl AsRef for Id { } } -impl AsRef for Id { - fn as_ref(&self) -> &String { - &self.0 - } -} +// impl AsRef for Id { +// fn as_ref(&self) -> &String { +// &self.0 +// } +// } impl AsRef for Id { fn as_ref(&self) -> &Id { @@ -70,7 +71,7 @@ impl AsRef for Id { } impl Deref for Id { - type Target = String; + type Target = str; fn deref(&self) -> &Self::Target { &self.0 @@ -85,23 +86,23 @@ impl PartialEq for Id { impl PartialEq<&str> for Id { fn eq(&self, other: &&str) -> bool { - &self.0 == other + self.0 == other } } impl PartialEq for Id { fn eq(&self, other: &String) -> bool { - &self.0 == other + self.0 == other } } // Allows strings to be used for collection keys -impl Borrow for Id { - fn borrow(&self) -> &String { - &self.0 - } -} +// impl Borrow for Id { +// fn borrow(&self) -> &String { +// &self.0 +// } +// } impl Borrow for Id { fn borrow(&self) -> &str { From 9f02fc02cf754a86d296ed458cc644fab2a3b376 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 26 Nov 2024 16:09:11 -0800 Subject: [PATCH 04/12] new: Support loading `.env` files. (#659) --- CHANGELOG.md | 5 + Cargo.lock | 7 + crates/core/Cargo.toml | 19 +- crates/core/src/error.rs | 24 ++ crates/core/src/proto_config.rs | 136 ++++++++++- crates/core/tests/proto_config_test.rs | 319 +++++++++++++++++++++++++ package/src/api-types.ts | 9 + registry/data/third-party.json | 2 +- 8 files changed, 498 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d04ed017c..6d5195e0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ #### 🚀 Updates - Added `--on-init` option to `proto activate`, which will trigger the activation hook immediately in the shell, instead of waiting for a directory/prompt change to occur. +- Added support for loading `.env` files through the special `env.file` and `tools.*.env.file` settings. + ```toml + [env] + file = ".env" + ``` #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index 252956059..7ba850fa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -978,6 +978,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "dyn-clone" version = "1.0.17" @@ -2465,6 +2471,7 @@ version = "0.43.6" dependencies = [ "clap", "convert_case", + "dotenvy", "indexmap", "miette", "minisign-verify", diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 7c24991f8..4c10cde85 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -9,17 +9,18 @@ repository = "https://github.com/moonrepo/proto" [dependencies] proto_pdk_api = { version = "0.24.3", path = "../pdk-api", features = [ - "schematic", + "schematic", ] } proto_shim = { version = "0.5.0", path = "../shim" } version_spec = { version = "0.7.0", path = "../version-spec", features = [ - "schematic", + "schematic", ] } warpgate = { version = "0.19.0", path = "../warpgate", features = [ - "schematic", + "schematic", ] } clap = { workspace = true, optional = true } convert_case = "0.6.0" +dotenvy = "0.15.7" indexmap = { workspace = true } miette = { workspace = true } minisign-verify = "0.2.2" @@ -28,12 +29,12 @@ regex = { workspace = true } reqwest = { workspace = true } rustc-hash = { workspace = true } schematic = { workspace = true, features = [ - "config", - "env", - "toml", - "type_indexmap", - "type_url", - "validate", + "config", + "env", + "toml", + "type_indexmap", + "type_url", + "validate", ] } semver = { workspace = true } serde = { workspace = true } diff --git a/crates/core/src/error.rs b/crates/core/src/error.rs index e1a4e2749..f1ea3d24a 100644 --- a/crates/core/src/error.rs +++ b/crates/core/src/error.rs @@ -181,4 +181,28 @@ pub enum ProtoError { #[source] error: Box, }, + + #[diagnostic(code(proto::env::missing_file))] + #[error( + "The .env file {} does not exist. This was configured as {} in the config {}.", + .path.style(Style::Path), + .config.style(Style::File), + .config_path.style(Style::Path), + )] + MissingEnvFile { + path: PathBuf, + config: String, + config_path: PathBuf, + }, + + #[diagnostic(code(proto::env::parse_failed))] + #[error( + "Failed to parse .env file {}.", + .path.style(Style::Path), + )] + EnvFileParseFailed { + path: PathBuf, + #[source] + error: Box, + }, } diff --git a/crates/core/src/proto_config.rs b/crates/core/src/proto_config.rs index 87d46762e..5dac34c42 100644 --- a/crates/core/src/proto_config.rs +++ b/crates/core/src/proto_config.rs @@ -1,3 +1,4 @@ +use crate::error::ProtoError; use crate::helpers::ENV_VAR_SUB; use indexmap::IndexMap; use once_cell::sync::OnceCell; @@ -9,10 +10,12 @@ use schematic::{ }; use serde::{Deserialize, Serialize}; use starbase_styles::color; +use starbase_utils::fs::FsError; use starbase_utils::json::JsonValue; use starbase_utils::toml::TomlValue; use starbase_utils::{fs, toml}; use std::collections::BTreeMap; +use std::ffi::OsStr; use std::fmt::Debug; use std::hash::Hash; use std::path::{Path, PathBuf}; @@ -24,6 +27,7 @@ use warpgate::{HttpOptions, Id, PluginLocator, UrlLocator}; pub const PROTO_CONFIG_NAME: &str = ".prototools"; pub const SCHEMA_PLUGIN_KEY: &str = "internal-schema"; pub const PROTO_PLUGIN_KEY: &str = "proto"; +pub const ENV_FILE_KEY: &str = "file"; fn merge_tools( mut prev: BTreeMap, @@ -131,6 +135,12 @@ derive_enum!( } ); +#[derive(Clone, Debug, PartialEq)] +pub struct EnvFile { + pub path: PathBuf, + pub weight: usize, +} + #[derive(Clone, Config, Debug, PartialEq, Serialize)] #[serde(untagged)] pub enum EnvVar { @@ -174,6 +184,10 @@ pub struct ProtoToolConfig { #[setting(merge = merge_fxhashmap)] #[serde(flatten, skip_serializing_if = "FxHashMap::is_empty")] pub config: FxHashMap, + + #[setting(exclude, merge = merge::append_vec)] + #[serde(skip)] + _env_files: Vec, } #[derive(Clone, Config, Debug, Serialize)] @@ -240,6 +254,10 @@ pub struct ProtoConfig { #[setting(merge = merge_fxhashmap)] #[serde(flatten, skip_serializing)] pub unknown: FxHashMap, + + #[setting(exclude, merge = merge::append_vec)] + #[serde(skip)] + _env_files: Vec, } impl ProtoConfig { @@ -402,7 +420,6 @@ impl ProtoConfig { debug!(file = ?path, "Loading {}", PROTO_CONFIG_NAME); - let config_path = path.to_string_lossy(); let config_content = if with_lock { fs::read_file_with_lock(path)? } else { @@ -415,7 +432,7 @@ impl ProtoConfig { config.validate(&(), true).map_err(|error| match error { ConfigError::Validator { error, .. } => ConfigError::Validator { - location: config_path.to_string(), + location: path.to_string_lossy().to_string(), error, help: Some(color::muted_light("https://moonrepo.dev/docs/proto/config")), }, @@ -454,7 +471,7 @@ impl ProtoConfig { if !error.errors.is_empty() { return Err(ConfigError::Validator { - location: config_path.to_string(), + location: path.to_string_lossy().to_string(), error: Box::new(error), help: Some(color::muted_light("https://moonrepo.dev/docs/proto/config")), } @@ -463,20 +480,22 @@ impl ProtoConfig { } // Update file paths to be absolute - let make_absolute = |file: &PathBuf| { + fn make_absolute>(file: T, current_path: &Path) -> PathBuf { + let file = PathBuf::from(file.as_ref()); + if file.is_absolute() { - file.to_owned() - } else if let Some(dir) = path.parent() { + file + } else if let Some(dir) = current_path.parent() { dir.join(file) } else { PathBuf::from("/").join(file) } - }; + } if let Some(plugins) = &mut config.plugins { for locator in plugins.values_mut() { if let PluginLocator::File(ref mut inner) = locator { - inner.path = Some(make_absolute(&inner.get_unresolved_path())); + inner.path = Some(make_absolute(inner.get_unresolved_path(), path)); } } } @@ -484,11 +503,49 @@ impl ProtoConfig { if let Some(settings) = &mut config.settings { if let Some(http) = &mut settings.http { if let Some(root_cert) = &mut http.root_cert { - *root_cert = make_absolute(root_cert); + *root_cert = make_absolute(&root_cert, path); + } + } + } + + let push_env_file = |env_map: Option<&mut IndexMap>, + file_list: &mut Option>, + extra_weight: usize| + -> miette::Result<()> { + if let Some(map) = env_map { + if let Some(PartialEnvVar::Value(env_file)) = map.get(ENV_FILE_KEY) { + let list = file_list.get_or_insert(vec![]); + let env_file_path = make_absolute(env_file, path); + + if !env_file_path.exists() { + return Err(ProtoError::MissingEnvFile { + path: env_file_path, + config: env_file.to_owned(), + config_path: path.to_path_buf(), + } + .into()); + } + + list.push(EnvFile { + path: env_file_path, + weight: (path.to_str().map_or(0, |p| p.len()) * 10) + extra_weight, + }); } + + map.shift_remove(ENV_FILE_KEY); + } + + Ok(()) + }; + + if let Some(tools) = &mut config.tools { + for tool in tools.values_mut() { + push_env_file(tool.env.as_mut(), &mut tool._env_files, 5)?; } } + push_env_file(config.env.as_mut(), &mut config._env_files, 0)?; + Ok(config) } @@ -521,25 +578,49 @@ impl ProtoConfig { Self::save_to(dir, config) } + pub fn get_env_files(&self, filter_id: Option<&Id>) -> Vec<&PathBuf> { + let mut paths: Vec<&EnvFile> = self._env_files.iter().collect(); + + if let Some(id) = filter_id { + if let Some(tool_config) = self.tools.get(id) { + paths.extend(&tool_config._env_files); + } + } + + // Sort by weight so that we persist the order of env files + // when layers across directories exist! + paths.sort_by(|a, d| a.weight.cmp(&d.weight)); + + // Then only return the paths + paths.into_iter().map(|file| &file.path).collect() + } + // We don't use a `BTreeMap` for env vars, so that variable interpolation // and order of declaration can work correctly! pub fn get_env_vars( &self, filter_id: Option<&Id>, ) -> miette::Result>> { + let env_files = self.get_env_files(filter_id); + let mut base_vars = IndexMap::new(); - base_vars.extend(self.env.iter()); + base_vars.extend(self.load_env_files(&env_files)?); + base_vars.extend(self.env.clone()); if let Some(id) = filter_id { if let Some(tool_config) = self.tools.get(id) { - base_vars.extend(tool_config.env.iter()) + base_vars.extend(tool_config.env.clone()) } } let mut vars = IndexMap::>::new(); for (key, value) in base_vars { - let key_exists = std::env::var(key).is_ok_and(|v| !v.is_empty()); + if key == ENV_FILE_KEY { + continue; + } + + let key_exists = std::env::var(&key).is_ok_and(|v| !v.is_empty()); let value = value.to_value(); // Don't override parent inherited vars @@ -564,7 +645,36 @@ impl ProtoConfig { .to_string() }); - vars.insert(key.to_owned(), value); + vars.insert(key, value); + } + + Ok(vars) + } + + pub fn load_env_files(&self, paths: &[&PathBuf]) -> miette::Result> { + let mut vars = IndexMap::default(); + + let map_error = |error: dotenvy::Error, path: &Path| -> miette::Report { + match error { + dotenvy::Error::Io(inner) => FsError::Read { + path: path.to_path_buf(), + error: Box::new(inner), + } + .into(), + other => ProtoError::EnvFileParseFailed { + path: path.to_path_buf(), + error: Box::new(other), + } + .into(), + } + }; + + for path in paths { + for item in dotenvy::from_path_iter(path).map_err(|error| map_error(error, path))? { + let (key, value) = item.map_err(|error| map_error(error, path))?; + + vars.insert(key, EnvVar::Value(value)); + } } Ok(vars) diff --git a/crates/core/tests/proto_config_test.rs b/crates/core/tests/proto_config_test.rs index 97bbcae28..93399465e 100644 --- a/crates/core/tests/proto_config_test.rs +++ b/crates/core/tests/proto_config_test.rs @@ -135,6 +135,37 @@ BAZ_QUX = "abc" }); } + #[test] + fn can_set_env_file() { + let sandbox = create_empty_sandbox(); + sandbox.create_file(".env", ""); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +KEY = "value" +"#, + ); + + let config = ProtoConfig::load_from(sandbox.path(), false).unwrap(); + + assert_eq!(config.env.unwrap(), { + let mut map = IndexMap::::default(); + map.insert("KEY".into(), PartialEnvVar::Value("value".into())); + map + }); + assert_eq!( + config + ._env_files + .unwrap() + .into_iter() + .map(|file| file.path) + .collect::>(), + vec![sandbox.path().join(".env")] + ); + } + #[test] fn can_set_plugins() { let sandbox = create_empty_sandbox(); @@ -307,6 +338,230 @@ foo = "file://./test.toml" ); } + mod envs { + use super::*; + + #[test] + #[should_panic(expected = "does not exist")] + fn errors_if_file_missing() { + let sandbox = create_empty_sandbox(); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +"#, + ); + + ProtoConfigManager::load(sandbox.path(), None, None) + .unwrap() + .get_merged_config() + .unwrap(); + } + + #[test] + #[should_panic(expected = "Failed to parse .env file")] + fn errors_if_parse_fails() { + let sandbox = create_empty_sandbox(); + sandbox.create_file( + ".env", + r#" +.KEY={invalid} +"#, + ); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +"#, + ); + + ProtoConfigManager::load(sandbox.path(), None, None) + .unwrap() + .get_merged_config() + .unwrap() + .get_env_vars(None) + .unwrap(); + } + + #[test] + fn merges_vars_and_files() { + let sandbox = create_empty_sandbox(); + sandbox.create_file( + ".env", + r#" +KEY1 = "file1" +KEY3 = "file3" +"#, + ); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +KEY1 = "value1" +KEY2 = "value2" +"#, + ); + + let config = ProtoConfigManager::load(sandbox.path(), None, None) + .unwrap() + .get_merged_config() + .unwrap() + .to_owned(); + + assert_eq!(config.get_env_vars(None).unwrap(), { + let mut map = IndexMap::>::default(); + map.insert("KEY1".into(), Some("value1".into())); + map.insert("KEY2".into(), Some("value2".into())); + map.insert("KEY3".into(), Some("file3".into())); + map + }); + } + + #[test] + fn child_file_overwrites_parent() { + let sandbox = create_empty_sandbox(); + sandbox.create_file( + ".env", + r#" +KEY = "parent" +"#, + ); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +"#, + ); + sandbox.create_file( + "child/.env", + r#" +KEY = "child" +"#, + ); + sandbox.create_file( + "child/.prototools", + r#" +[env] +file = ".env" +"#, + ); + + let config = ProtoConfigManager::load(sandbox.path().join("child"), None, None) + .unwrap() + .get_merged_config() + .unwrap() + .to_owned(); + + assert_eq!(config.get_env_vars(None).unwrap(), { + let mut map = IndexMap::>::default(); + map.insert("KEY".into(), Some("child".into())); + map + }); + } + + #[test] + fn files_can_substitute_from_self() { + let sandbox = create_empty_sandbox(); + sandbox.create_file( + ".env", + r#" +OTHER = "abc" +KEY = "other=${OTHER}" +"#, + ); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +"#, + ); + + let config = ProtoConfigManager::load(sandbox.path(), None, None) + .unwrap() + .get_merged_config() + .unwrap() + .to_owned(); + + assert_eq!(config.get_env_vars(None).unwrap(), { + let mut map = IndexMap::>::default(); + map.insert("OTHER".into(), Some("abc".into())); + map.insert("KEY".into(), Some("other=abc".into())); + map + }); + } + + // #[test] + // fn files_can_substitute_from_process() { + // let sandbox = create_empty_sandbox(); + // sandbox.create_file( + // ".env", + // r#" + // KEY = "process=${PROCESS_KEY}" + // "#, + // ); + // sandbox.create_file( + // ".prototools", + // r#" + // [env] + // file = ".env" + // "#, + // ); + + // env::set_var("PROCESS_KEY", "abc"); + + // let config = ProtoConfigManager::load(sandbox.path(), None, None) + // .unwrap() + // .get_merged_config() + // .unwrap() + // .to_owned(); + + // env::remove_var("PROCESS_KEY"); + + // assert_eq!(config.get_env_vars(None).unwrap(), { + // let mut map = IndexMap::>::default(); + // map.insert("KEY".into(), Some("process=abc".into())); + // map + // }); + // } + + #[test] + fn vars_can_substitute_from_files() { + let sandbox = create_empty_sandbox(); + sandbox.create_file( + ".env", + r#" +FILE=file +"#, + ); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" +KEY = "from=${FILE}" +"#, + ); + + let config = ProtoConfigManager::load(sandbox.path(), None, None) + .unwrap() + .get_merged_config() + .unwrap() + .to_owned(); + + assert_eq!(config.get_env_vars(None).unwrap(), { + let mut map = IndexMap::>::default(); + map.insert("FILE".into(), Some("file".into())); + map.insert("KEY".into(), Some("from=file".into())); + map + }); + } + } + mod builtins { use super::*; use proto_core::BuiltinPlugins; @@ -579,6 +834,70 @@ NODE_PATH = false map }); } + + #[test] + fn gathers_env_files() { + let sandbox = create_empty_sandbox(); + sandbox.create_file("a/b/.env.b", ""); + sandbox.create_file("a/b/.env.tool-b", ""); + sandbox.create_file( + "a/b/.prototools", + r#" +[env] +file = ".env.b" + +[tools.node.env] +file = ".env.tool-b" +"#, + ); + sandbox.create_file("a/.env.a", ""); + sandbox.create_file("a/.env.tool-a", ""); + sandbox.create_file( + "a/.prototools", + r#" +[env] +file = ".env.a" + +[tools.node.env] +file = ".env.tool-a" +"#, + ); + sandbox.create_file(".env", ""); + sandbox.create_file(".env.tool", ""); + sandbox.create_file( + ".prototools", + r#" +[env] +file = ".env" + +[tools.node.env] +file = ".env.tool" +"#, + ); + + let config = ProtoConfigManager::load(sandbox.path().join("a/b"), None, None) + .unwrap() + .get_merged_config() + .unwrap() + .to_owned(); + + assert_eq!(config.env, IndexMap::::default()); + assert_eq!( + config + .get_env_files(Some(&Id::raw("node"))) + .into_iter() + .cloned() + .collect::>(), + vec![ + sandbox.path().join(".env"), + sandbox.path().join(".env.tool"), + sandbox.path().join("a/.env.a"), + sandbox.path().join("a/.env.tool-a"), + sandbox.path().join("a/b/.env.b"), + sandbox.path().join("a/b/.env.tool-b"), + ] + ); + } } } diff --git a/package/src/api-types.ts b/package/src/api-types.ts index 7cd43d680..d782bc7db 100644 --- a/package/src/api-types.ts +++ b/package/src/api-types.ts @@ -107,8 +107,15 @@ export interface ToolMetadataOutput { configSchema?: unknown | null; /** Default alias or version to use as a fallback. */ defaultVersion?: UnresolvedVersionSpec | null; + /** + * List of deprecation messages that will be displayed to users + * of this plugin. + */ + deprecations?: string[]; /** Controls aspects of the tool inventory. */ inventory?: ToolInventoryMetadata; + /** Minimum version of proto required to execute this plugin. */ + minimumProtoVersion?: string | null; /** Human readable name of the tool. */ name: string; /** Version of the plugin. */ @@ -140,6 +147,8 @@ export interface ParseVersionFileInput { content: string; /** Name of file that's being parsed. */ file: string; + /** Virtual path to the file being parsed. */ + path: VirtualPath; } /** Output returned by the `parse_version_file` function. */ diff --git a/registry/data/third-party.json b/registry/data/third-party.json index c69aab36e..99074e16e 100644 --- a/registry/data/third-party.json +++ b/registry/data/third-party.json @@ -64,7 +64,7 @@ "name": "atlas", "description": "manage your database schema as code.", "author": "crashdump", - "homepageUrl": "https://atlasgo.io", + "homepageUrl": "https://atlasgo.io/", "repositoryUrl": "https://github.com/crashdump/proto-tools", "bins": [ "atlas" From 263218855cdc099f441fe14c3ef4fad8bfb0cdde Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Thu, 28 Nov 2024 16:12:26 -0800 Subject: [PATCH 05/12] build: Upgrade to Rust v1.83. (#661) --- CHANGELOG.md | 1 + crates/cli/src/commands/outdated.rs | 2 +- crates/cli/src/commands/status.rs | 2 +- crates/cli/src/main_shim.rs | 1 + crates/cli/src/printer.rs | 6 +++--- rust-toolchain.toml | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5195e0d..7834b5826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Updated identifiers, versions, and locators to use [compact strings](https://crates.io/crates/compact_str). - Updated wasmtime to v26 (from v23). +- Updated Rust to v1.83. ## 0.42.2 diff --git a/crates/cli/src/commands/outdated.rs b/crates/cli/src/commands/outdated.rs index 683105cb4..a5df6c48a 100644 --- a/crates/cli/src/commands/outdated.rs +++ b/crates/cli/src/commands/outdated.rs @@ -72,7 +72,7 @@ pub async fn outdated(session: ProtoSession, args: OutdatedArgs) -> AppResult { for file in manager.files.iter().rev() { if !file.exists || !env.config_mode.includes_global() && file.global - || env.config_mode.only_local() && !file.path.parent().is_some_and(|p| p == env.cwd) + || env.config_mode.only_local() && file.path.parent().is_none_or(|p| p != env.cwd) { continue; } diff --git a/crates/cli/src/commands/status.rs b/crates/cli/src/commands/status.rs index a86b94ad4..3d2367b6a 100644 --- a/crates/cli/src/commands/status.rs +++ b/crates/cli/src/commands/status.rs @@ -42,7 +42,7 @@ fn find_versions_in_configs( if !file.exists || !env.config_mode.includes_global() && file.global || env.config_mode.only_local() - && !file.path.parent().is_some_and(|p| p == session.env.cwd) + && file.path.parent().is_none_or(|p| p != session.env.cwd) { continue; } diff --git a/crates/cli/src/main_shim.rs b/crates/cli/src/main_shim.rs index aef390aed..69b659fdd 100644 --- a/crates/cli/src/main_shim.rs +++ b/crates/cli/src/main_shim.rs @@ -15,6 +15,7 @@ static mut DEBUG: Option = None; // We don't want to pull the entire `tracing` or `log` crates // into this binary, as we want it to be super lean. So we have // this very rudimentary logging system. +#[allow(static_mut_refs)] fn debug(op: impl FnOnce() -> String) { unsafe { if DEBUG.is_none() { diff --git a/crates/cli/src/printer.rs b/crates/cli/src/printer.rs index 90402a199..64a8b9e85 100644 --- a/crates/cli/src/printer.rs +++ b/crates/cli/src/printer.rs @@ -7,10 +7,10 @@ pub struct Printer<'std> { depth: u8, } -unsafe impl<'std> Send for Printer<'std> {} -unsafe impl<'std> Sync for Printer<'std> {} +unsafe impl Send for Printer<'_> {} +unsafe impl Sync for Printer<'_> {} -impl<'std> Printer<'std> { +impl Printer<'_> { pub fn new() -> Self { let stdout = std::io::stdout(); let buffer = BufWriter::new(stdout.lock()); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1a07338aa..80f03dfe1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.82.0" +channel = "1.83.0" From 294d0200d4984f3787534b91ff7fb7197658e584 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 29 Nov 2024 22:32:05 -0800 Subject: [PATCH 06/12] new: Abort upgrade if proto is currently running. (#663) --- CHANGELOG.md | 1 + Cargo.lock | 7 +++--- crates/cli/Cargo.toml | 17 ++++++++------ crates/cli/src/commands/upgrade.rs | 36 ++++++++++++++++++++++++++++++ crates/cli/src/error.rs | 4 ++++ 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7834b5826..fbb3af130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ [env] file = ".env" ``` +- Updated `proto upgrade` to error if there's another process of proto currently running. #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index 7ba850fa1..184ac1488 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -2445,6 +2445,7 @@ dependencies = [ "starbase_shell", "starbase_styles", "starbase_utils", + "sysinfo", "system_env", "thiserror 2.0.3", "tokio", @@ -3518,9 +3519,9 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.32.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ae3f4f7d64646c46c4cae4e3f01d1c5d255c7406fdd7c7f999a94e488791" +checksum = "4c33cd241af0f2e9e3b5c32163b873b29956890b5342e6745b917ce9d490f4af" dependencies = [ "core-foundation-sys", "libc", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index c6d9554b3..d1432d4c6 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -7,11 +7,11 @@ description = "A multi-language version manager, a unified toolchain." homepage = "https://moonrepo.dev/proto" repository = "https://github.com/moonrepo/proto" keywords = [ - "language", - "installer", - "version-manager", - "dependency-manager", - "package-manager", + "language", + "installer", + "version-manager", + "dependency-manager", + "package-manager", ] categories = ["development-tools"] readme = "../../README.md" @@ -19,8 +19,8 @@ default-run = "proto" [package.metadata.release] pre-release-replacements = [ - { file = "../../version", search = "^(.+)$", replace = "{{version}}" }, - { file = "../../CHANGELOG.md", search = "Unreleased", replace = "{{version}}" }, + { file = "../../version", search = "^(.+)$", replace = "{{version}}" }, + { file = "../../CHANGELOG.md", search = "Unreleased", replace = "{{version}}" }, ] [[bin]] @@ -58,6 +58,9 @@ starbase = { workspace = true } starbase_shell = { workspace = true } starbase_styles = { workspace = true } starbase_utils = { workspace = true } +sysinfo = { version = "0.32.1", default-features = false, features = [ + "system", +] } thiserror = { workspace = true } tokio = { workspace = true } tracing = { workspace = true } diff --git a/crates/cli/src/commands/upgrade.rs b/crates/cli/src/commands/upgrade.rs index 87f2a7576..ae3ad5002 100644 --- a/crates/cli/src/commands/upgrade.rs +++ b/crates/cli/src/commands/upgrade.rs @@ -40,6 +40,10 @@ pub async fn upgrade(session: ProtoSession, args: UpgradeArgs) -> AppResult { return Err(ProtoCliError::UpgradeRequiresInternet.into()); } + if let Some(pid) = is_running() { + return Err(ProtoCliError::CannotUpgradeProtoRunning { pid: pid.as_u32() }.into()); + } + let latest = fetch_latest_version().await?; let current_version = Version::parse(&session.cli_version).unwrap(); @@ -170,3 +174,35 @@ pub async fn upgrade(session: ProtoSession, args: UpgradeArgs) -> AppResult { } .into()) } + +#[cfg(not(debug_assertions))] +fn is_running() -> Option { + debug!("Checking if proto is currently running in a separate process"); + + let system = sysinfo::System::new_all(); + let self_pid = std::process::id(); + + for process in system.processes_by_name("proto".as_ref()) { + if process.pid().as_u32() == self_pid { + continue; + } + + let name = process.name(); + + if name == "proto" + || name == "proto-shim" + || name == "proto.exe" + || name == "proto-shim.exe" + { + return Some(process.pid()); + } + } + + None +} + +// Don't check in tests! +#[cfg(debug_assertions)] +fn is_running() -> Option { + None +} diff --git a/crates/cli/src/error.rs b/crates/cli/src/error.rs index dd6e91ebe..7e150eee4 100644 --- a/crates/cli/src/error.rs +++ b/crates/cli/src/error.rs @@ -50,6 +50,10 @@ pub enum ProtoCliError { #[error("Upgrading proto requires an internet connection!")] UpgradeRequiresInternet, + #[diagnostic(code(proto::cli::running_process))] + #[error("Unable to upgrade as an instance of proto is currently running with the process ID {}. Please stop this process then try again.", .pid.to_string().style(Style::Symbol))] + CannotUpgradeProtoRunning { pid: u32 }, + #[diagnostic(code(proto::cli::unknown_migration))] #[error("Unknown migration operation {}.", .op.style(Style::Symbol))] UnknownMigration { op: String }, From 6b252dc666620771299079215098ea477db7cf8c Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 29 Nov 2024 23:43:37 -0800 Subject: [PATCH 07/12] new: Add netrc support and request caching. (#662) --- CHANGELOG.md | 5 +- Cargo.lock | 433 +++++++++++++++++++++++++++++-- Cargo.toml | 6 + crates/core/src/flow/install.rs | 4 +- crates/core/src/proto.rs | 5 +- crates/warpgate/Cargo.toml | 4 + crates/warpgate/src/client.rs | 145 ++++++++++- crates/warpgate/src/endpoints.rs | 15 +- crates/warpgate/src/error.rs | 4 + crates/warpgate/src/helpers.rs | 7 +- crates/warpgate/src/host.rs | 189 ++++++++------ crates/warpgate/src/loader.rs | 6 +- 12 files changed, 704 insertions(+), 119 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbb3af130..9fca00660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,12 +14,15 @@ #### 🚀 Updates -- Added `--on-init` option to `proto activate`, which will trigger the activation hook immediately in the shell, instead of waiting for a directory/prompt change to occur. +- Added an `--on-init` option to `proto activate`, which will trigger the activation hook immediately in the shell, instead of waiting for a directory/prompt change to occur. + - If you were manually executing `_proto_hook` before, this will now fail. Please remove! - Added support for loading `.env` files through the special `env.file` and `tools.*.env.file` settings. ```toml [env] file = ".env" ``` +- Added support for `~/.netrc` configuration to all HTTP requests. +- Improved implementation of HTTP request/response caching. Now takes into account [HTTP cache semantics](https://github.com/kornelski/rusty-http-cache-semantics). - Updated `proto upgrade` to error if there's another process of proto currently running. #### 🐞 Fixes diff --git a/Cargo.lock b/Cargo.lock index 184ac1488..549cb9208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,6 +213,15 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "binstall-tar" version = "0.4.42" @@ -295,6 +304,33 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "cacache" +version = "13.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5063741c7b2e260bbede781cf4679632dd90e2718e99f7715e46824b65670b" +dependencies = [ + "digest", + "either", + "futures", + "hex", + "libc", + "memmap2", + "miette 5.10.0", + "reflink-copy", + "serde", + "serde_derive", + "serde_json", + "sha1", + "sha2", + "ssri", + "tempfile", + "thiserror 1.0.69", + "tokio", + "tokio-stream", + "walkdir", +] + [[package]] name = "cap-fs-ext" version = "3.4.1" @@ -853,6 +889,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive_arbitrary" version = "1.4.1" @@ -1227,6 +1272,21 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.31" @@ -1234,6 +1294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -1242,6 +1303,17 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.31" @@ -1277,6 +1349,7 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -1455,6 +1528,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "http" version = "1.1.0" @@ -1489,12 +1568,73 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-cache" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b65cd1687caf2c7fff496741a2f264c26f54e6d6cec03dac8f276fa4e5430e" +dependencies = [ + "async-trait", + "bincode", + "cacache", + "http", + "http-cache-semantics", + "httpdate", + "serde", + "url", +] + +[[package]] +name = "http-cache-reqwest" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735586904a5ce0c13877c57cb4eb8195eb7c11ec1ffd64d4db053fb8559ca62e" +dependencies = [ + "anyhow", + "async-trait", + "http", + "http-cache", + "http-cache-semantics", + "reqwest", + "reqwest-middleware 0.4.0", + "serde", + "url", +] + +[[package]] +name = "http-cache-semantics" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92baf25cf0b8c9246baecf3a444546360a97b569168fdf92563ee6a47829920c" +dependencies = [ + "http", + "http-serde", + "serde", + "time", +] + +[[package]] +name = "http-serde" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f056c8559e3757392c8d091e796416e4649d8e49e88b8d76df6c002f05027fd" +dependencies = [ + "http", + "serde", +] + [[package]] name = "httparse" version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + [[package]] name = "human-sort" version = "0.2.2" @@ -1537,6 +1677,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots", ] [[package]] @@ -2056,6 +2197,27 @@ dependencies = [ "rustix", ] +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "miette" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +dependencies = [ + "miette-derive 5.10.0", + "once_cell", + "thiserror 1.0.69", + "unicode-width 0.1.14", +] + [[package]] name = "miette" version = "7.2.0" @@ -2065,7 +2227,7 @@ dependencies = [ "backtrace", "backtrace-ext", "cfg-if", - "miette-derive", + "miette-derive 7.2.0", "owo-colors", "supports-color", "supports-hyperlinks", @@ -2076,6 +2238,17 @@ dependencies = [ "unicode-width 0.1.14", ] +[[package]] +name = "miette-derive" +version = "5.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "miette-derive" version = "7.2.0" @@ -2172,6 +2345,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.19" @@ -2217,6 +2396,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" +dependencies = [ + "memchr", +] + [[package]] name = "overload" version = "0.1.1" @@ -2309,6 +2497,12 @@ dependencies = [ "serde", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -2426,7 +2620,7 @@ dependencies = [ "extism", "indexmap", "indicatif", - "miette", + "miette 7.2.0", "proto_core", "proto_installer", "proto_pdk_api", @@ -2474,7 +2668,7 @@ dependencies = [ "convert_case", "dotenvy", "indexmap", - "miette", + "miette 7.2.0", "minisign-verify", "once_cell", "proto_pdk_api", @@ -2505,7 +2699,7 @@ dependencies = [ name = "proto_installer" version = "0.7.1" dependencies = [ - "miette", + "miette 7.2.0", "reqwest", "starbase_archive", "starbase_styles", @@ -2713,6 +2907,17 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "reflink-copy" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17400ed684c3a0615932f00c271ae3eea13e47056a1455821995122348ab6438" +dependencies = [ + "cfg-if", + "rustix", + "windows 0.58.0", +] + [[package]] name = "regalloc2" version = "0.10.2" @@ -2814,9 +3019,50 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", + "webpki-roots", "windows-registry", ] +[[package]] +name = "reqwest-middleware" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04" +dependencies = [ + "anyhow", + "async-trait", + "http", + "reqwest", + "serde", + "thiserror 1.0.69", + "tower-service", +] + +[[package]] +name = "reqwest-middleware" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1ccd3b55e711f91a9885a2fa6fbbb2e39db1776420b062efc058c6410f7e5e3" +dependencies = [ + "anyhow", + "async-trait", + "http", + "reqwest", + "serde", + "thiserror 1.0.69", + "tower-service", +] + +[[package]] +name = "reqwest-netrc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3000378f31e2aff16946083125d5e317f89bd12ca8160ef4cff21c445c2376f" +dependencies = [ + "reqwest-middleware 0.3.3", + "rust-netrc", +] + [[package]] name = "ring" version = "0.17.8" @@ -2854,6 +3100,16 @@ dependencies = [ "serde", ] +[[package]] +name = "rust-netrc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e98097f62769f92dbf95fb51f71c0a68ec18a4ee2e70e0d3e4f47ac005d63e9" +dependencies = [ + "shellexpand 3.1.0", + "thiserror 1.0.69", +] + [[package]] name = "rust_json" version = "0.1.5" @@ -3015,7 +3271,7 @@ dependencies = [ "garde", "indexmap", "markdown", - "miette", + "miette 7.2.0", "schemars", "schematic_macros", "schematic_types", @@ -3189,6 +3445,28 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.8" @@ -3234,6 +3512,17 @@ dependencies = [ "dirs 4.0.0", ] +[[package]] +name = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "bstr", + "dirs 5.0.1", + "os_str_bytes", +] + [[package]] name = "shlex" version = "1.3.0" @@ -3322,6 +3611,23 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" +[[package]] +name = "ssri" +version = "9.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7a2b3c2bc9693bcb40870c4e9b5bf0d79f9cb46273321bf855ec513e919082" +dependencies = [ + "base64 0.21.7", + "digest", + "hex", + "miette 5.10.0", + "serde", + "sha-1", + "sha2", + "thiserror 1.0.69", + "xxhash-rust", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3336,7 +3642,7 @@ checksum = "472e15cb7da9f3348555a671fe61e58fc901ecdfc45972fe304a2f367e2eb424" dependencies = [ "async-trait", "chrono", - "miette", + "miette 7.2.0", "starbase_styles", "tokio", "tracing", @@ -3353,7 +3659,7 @@ dependencies = [ "binstall-tar", "bzip2", "flate2", - "miette", + "miette 7.2.0", "rustc-hash", "starbase_styles", "starbase_utils", @@ -3385,7 +3691,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c92e59e9cb8234c7d07f8260b7196c0d0cd29f4b31cfad8180bc3bcfe0c2619" dependencies = [ - "miette", + "miette 7.2.0", "regex", "sysinfo", "thiserror 2.0.3", @@ -3399,7 +3705,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1664b29d64bf37a14a0f50ae4c1568eb712c7eb28fb489aabac81c36e5558c1" dependencies = [ "dirs 5.0.1", - "miette", + "miette 7.2.0", "owo-colors", "supports-color", ] @@ -3413,7 +3719,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "json-strip-comments", - "miette", + "miette 7.2.0", "regex", "reqwest", "serde", @@ -3527,7 +3833,7 @@ dependencies = [ "libc", "memchr", "ntapi", - "windows", + "windows 0.57.0", ] [[package]] @@ -3683,6 +3989,37 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -3749,6 +4086,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -4056,10 +4404,14 @@ version = "0.19.0" dependencies = [ "compact_str 0.8.0", "extism", - "miette", + "http-cache-reqwest", + "miette 7.2.0", "once_cell", "regex", "reqwest", + "reqwest-middleware 0.4.0", + "reqwest-netrc", + "rust-netrc", "scc", "schematic", "serde", @@ -4610,7 +4962,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "shellexpand", + "shellexpand 2.1.2", "syn", "witx", ] @@ -4685,6 +5037,16 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -4700,12 +5062,25 @@ version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" dependencies = [ - "windows-implement", - "windows-interface", + "windows-implement 0.57.0", + "windows-interface 0.57.0", "windows-result 0.1.2", "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +dependencies = [ + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings", + "windows-targets 0.52.6", +] + [[package]] name = "windows-implement" version = "0.57.0" @@ -4717,6 +5092,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-implement" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-interface" version = "0.57.0" @@ -4728,6 +5114,17 @@ dependencies = [ "syn", ] +[[package]] +name = "windows-interface" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-registry" version = "0.2.0" @@ -4997,6 +5394,12 @@ dependencies = [ "rustix", ] +[[package]] +name = "xxhash-rust" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" + [[package]] name = "xz2" version = "0.1.7" diff --git a/Cargo.toml b/Cargo.toml index 52fc17bfd..aba79adc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ compact_str = { version = "0.8.0", default-features = false, features = [ dirs = "5.0.1" extism = ">=1.6.0" # Lower for consumers extism-pdk = "1.3.0" +http-cache-reqwest = "0.15.0" human-sort = "0.2.2" indexmap = "2.6.0" miette = "7.2.0" @@ -24,6 +25,11 @@ reqwest = { version = "0.12.9", default-features = false, features = [ "http2", "macos-system-configuration", ] } +reqwest-middleware = { version = "0.4.0", default-features = false, features = [ + "charset", + "http2", +] } +reqwest-netrc = "0.1.2" rustc-hash = "2.0.0" scc = "2.2.5" schematic = { version = "0.17.6", default-features = false } diff --git a/crates/core/src/flow/install.rs b/crates/core/src/flow/install.rs index b9b2b019f..9fb6a87fa 100644 --- a/crates/core/src/flow/install.rs +++ b/crates/core/src/flow/install.rs @@ -253,7 +253,7 @@ impl Tool { &download_url, &download_file, DownloadOptions { - client: Some(client), + client: Some(client.to_inner()), on_chunk: options.on_download_chunk.take(), }, ) @@ -276,7 +276,7 @@ impl Tool { &checksum_url, &checksum_file, DownloadOptions { - client: Some(client), + client: Some(client.to_inner()), on_chunk: None, }, ) diff --git a/crates/core/src/proto.rs b/crates/core/src/proto.rs index 357721423..5c257052a 100644 --- a/crates/core/src/proto.rs +++ b/crates/core/src/proto.rs @@ -79,8 +79,11 @@ impl ProtoEnvironment { let config = self.load_config()?; self.plugin_loader.get_or_try_init(|| { + let mut options = config.settings.http.clone(); + options.cache_dir = Some(self.store.cache_dir.join("requests")); + let mut loader = PluginLoader::new(&self.store.plugins_dir, &self.store.temp_dir); - loader.set_client_options(&config.settings.http); + loader.set_client_options(&options); loader.set_offline_checker(is_offline); Ok(loader) diff --git a/crates/warpgate/Cargo.toml b/crates/warpgate/Cargo.toml index ad6b24e34..8ee3b0406 100644 --- a/crates/warpgate/Cargo.toml +++ b/crates/warpgate/Cargo.toml @@ -11,10 +11,14 @@ system_env = { version = "0.6.1", path = "../system-env" } warpgate_api = { version = "0.10.1", path = "../warpgate-api" } compact_str = { workspace = true } extism = { workspace = true, features = ["http"] } +http-cache-reqwest = { workspace = true } miette = { workspace = true } once_cell = { workspace = true } regex = { workspace = true } reqwest = { workspace = true, features = ["json", "rustls-tls-native-roots"] } +reqwest-middleware = { workspace = true, features = ["json", "rustls-tls"] } +reqwest-netrc = { workspace = true } +rust-netrc = "0.1.2" schematic = { workspace = true, optional = true, features = ["schema"] } scc = { workspace = true } serde = { workspace = true } diff --git a/crates/warpgate/src/client.rs b/crates/warpgate/src/client.rs index ba7cae0fe..88c865f75 100644 --- a/crates/warpgate/src/client.rs +++ b/crates/warpgate/src/client.rs @@ -1,9 +1,50 @@ +use crate::error::WarpgateError; +use core::ops::Deref; use miette::IntoDiagnostic; +use netrc::Netrc; +use reqwest::Client; +use reqwest_middleware::{ClientBuilder, ClientWithMiddleware, RequestBuilder, RequestInitialiser}; use serde::{Deserialize, Serialize}; use starbase_utils::fs; use std::path::PathBuf; use tracing::{debug, trace, warn}; +// `ClientWithMiddleware` doesn't allow access to their inner `Client`, +// so we unfortunately need to keep a reference to both. +// https://github.com/TrueLayer/reqwest-middleware/issues/203 +#[derive(Default)] +pub struct HttpClient { + client: Client, + middleware: ClientWithMiddleware, +} + +impl HttpClient { + pub fn to_inner(&self) -> &Client { + &self.client + } + + pub fn map_error(url: String, error: reqwest_middleware::Error) -> WarpgateError { + match error { + reqwest_middleware::Error::Middleware(inner) => WarpgateError::HttpMiddleware { + error: format!("{}", inner), + url, + }, + reqwest_middleware::Error::Reqwest(inner) => WarpgateError::Http { + error: Box::new(inner), + url, + }, + } + } +} + +impl Deref for HttpClient { + type Target = ClientWithMiddleware; + + fn deref(&self) -> &Self::Target { + &self.middleware + } +} + /// Configures the HTTPS client used for making requests. #[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)] #[serde(default, rename_all = "kebab-case")] @@ -12,6 +53,9 @@ pub struct HttpOptions { /// Allow invalid certificates. This is dangerous and should only be used as a last resort! pub allow_invalid_certs: bool, + /// Absolute path to a directory in which to cache GET and HEAD requests. + pub cache_dir: Option, + /// A list of proxy URLs that all requests should pass through. URLs that start with /// `http:` will handle insecure requests, while `https:` will handle secure requests. pub proxies: Vec, @@ -24,23 +68,23 @@ pub struct HttpOptions { } /// Create an HTTP/HTTPS client that'll be used for downloading files. -pub fn create_http_client() -> miette::Result { +pub fn create_http_client() -> miette::Result { create_http_client_with_options(&HttpOptions::default()) } /// Create an HTTP/HTTPS client with the provided options, that'll be /// used for downloading files. -pub fn create_http_client_with_options(options: &HttpOptions) -> miette::Result { +pub fn create_http_client_with_options(options: &HttpOptions) -> miette::Result { debug!("Creating HTTP client"); - let mut client = reqwest::Client::builder() + let mut client_builder = reqwest::Client::builder() .user_agent(format!("warpgate@{}", env!("CARGO_PKG_VERSION"))) .use_rustls_tls(); if options.allow_invalid_certs { trace!("Allowing invalid certificates (I hope you know what you're doing!)"); - client = client.danger_accept_invalid_certs(true); + client_builder = client_builder.danger_accept_invalid_certs(true); } if let Some(root_cert) = &options.root_cert { @@ -48,13 +92,13 @@ pub fn create_http_client_with_options(options: &HttpOptions) -> miette::Result< match root_cert.extension().and_then(|ext| ext.to_str()) { Some("der") => { - client = client.add_root_certificate( + client_builder = client_builder.add_root_certificate( reqwest::Certificate::from_der(&fs::read_file_bytes(root_cert)?) .into_diagnostic()?, ) } Some("pem") => { - client = client.add_root_certificate( + client_builder = client_builder.add_root_certificate( reqwest::Certificate::from_pem(&fs::read_file_bytes(root_cert)?) .into_diagnostic()?, ) @@ -85,7 +129,7 @@ pub fn create_http_client_with_options(options: &HttpOptions) -> miette::Result< trace!(proxies = ?insecure_proxies, "Adding insecure proxies to client"); for proxy in insecure_proxies { - client = client.proxy(reqwest::Proxy::http(proxy).into_diagnostic()?); + client_builder = client_builder.proxy(reqwest::Proxy::http(proxy).into_diagnostic()?); } } @@ -93,13 +137,94 @@ pub fn create_http_client_with_options(options: &HttpOptions) -> miette::Result< trace!(proxies = ?secure_proxies, "Adding secure proxies to client"); for proxy in secure_proxies { - client = client.proxy(reqwest::Proxy::https(proxy).into_diagnostic()?); + client_builder = client_builder.proxy(reqwest::Proxy::https(proxy).into_diagnostic()?); } } - let client = client.build().into_diagnostic()?; + let client = client_builder.build().into_diagnostic()?; + + trace!("Applying middleware to client"); + + let mut middleware_builder = ClientBuilder::new(client.clone()); + + if let Ok(netrc) = NetrcMiddleware::new() { + trace!("Adding .netrc support"); + + middleware_builder = middleware_builder.with_init(netrc); + } + + if let Some(cache_dir) = &options.cache_dir { + use http_cache_reqwest::{ + CACacheManager, Cache, CacheMode, CacheOptions, HttpCache, HttpCacheOptions, + }; + + trace!("Adding GET and HEAD request caching"); + + middleware_builder = middleware_builder.with(Cache(HttpCache { + manager: CACacheManager { + path: cache_dir.to_owned(), + }, + mode: CacheMode::Default, + options: HttpCacheOptions { + // https://github.com/kornelski/rusty-http-cache-semantics + cache_options: Some(CacheOptions { + cache_heuristic: 0.025, + ..Default::default() + }), + ..Default::default() + }, + })); + } + + let middleware = middleware_builder.build(); debug!("Created HTTP client"); - Ok(client) + Ok(HttpClient { client, middleware }) +} + +// TODO: Temporary until this lands +// https://github.com/gribouille/netrc/issues/9 +pub struct NetrcMiddleware { + nrc: Netrc, +} + +impl NetrcMiddleware { + pub fn new() -> netrc::Result { + Netrc::new().map(|nrc| NetrcMiddleware { nrc }) + } +} + +impl RequestInitialiser for NetrcMiddleware { + fn init(&self, req: RequestBuilder) -> RequestBuilder { + match req.try_clone() { + Some(nr) => req + .try_clone() + .unwrap() + .build() + .ok() + .and_then(|r| { + r.url() + .host_str() + .and_then(|host| { + self.nrc + .hosts + .get(host) + .or_else(|| self.nrc.hosts.get("default")) + }) + .map(|auth| { + nr.basic_auth( + &auth.login, + if auth.password.is_empty() { + None + } else { + Some(&auth.password) + }, + ) + }) + }) + .unwrap_or(req), + None => req, + } + } } diff --git a/crates/warpgate/src/endpoints.rs b/crates/warpgate/src/endpoints.rs index c10cf00d1..cb90c0f97 100644 --- a/crates/warpgate/src/endpoints.rs +++ b/crates/warpgate/src/endpoints.rs @@ -1,3 +1,4 @@ +use crate::client::HttpClient; use crate::error::WarpgateError; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; @@ -27,7 +28,7 @@ pub struct GitHubApiRelease { } pub async fn send_github_request( - client: &reqwest::Client, + client: &HttpClient, url: &str, ) -> miette::Result { let mut request = client.get(url).query(&[("per_page", "100")]); @@ -36,13 +37,15 @@ pub async fn send_github_request( request = request.bearer_auth(auth_token); } - let handle_error = |error: reqwest::Error| WarpgateError::Http { + let response = request + .send() + .await + .map_err(|error| HttpClient::map_error(url.to_owned(), error))?; + + let data: T = response.json().await.map_err(|error| WarpgateError::Http { error: Box::new(error), url: url.to_owned(), - }; - - let response = request.send().await.map_err(handle_error)?; - let data: T = response.json().await.map_err(handle_error)?; + })?; Ok(data) } diff --git a/crates/warpgate/src/error.rs b/crates/warpgate/src/error.rs index bcab60bfe..2cb35ac6b 100644 --- a/crates/warpgate/src/error.rs +++ b/crates/warpgate/src/error.rs @@ -18,6 +18,10 @@ pub enum WarpgateError { error: Box, }, + #[diagnostic(code(plugin::http))] + #[error("Failed to make HTTP request for {}: {}", .url.style(Style::Url), .error.style(Style::MutedLight))] + HttpMiddleware { url: String, error: String }, + #[diagnostic(code(plugin::offline))] #[error("{message} An internet connection is required to request {}.", .url.style(Style::Url))] InternetConnectionRequired { message: String, url: String }, diff --git a/crates/warpgate/src/helpers.rs b/crates/warpgate/src/helpers.rs index a8242d36b..843982099 100644 --- a/crates/warpgate/src/helpers.rs +++ b/crates/warpgate/src/helpers.rs @@ -1,3 +1,4 @@ +use crate::client::HttpClient; use crate::error::WarpgateError; use sha2::{Digest, Sha256}; use starbase_archive::{is_supported_archive_extension, Archiver}; @@ -28,9 +29,11 @@ pub fn determine_cache_extension(value: &str) -> Option<&str> { pub async fn download_from_url_to_file( source_url: &str, temp_file: &Path, - client: &reqwest::Client, + client: &HttpClient, ) -> miette::Result<()> { - if let Err(error) = net::download_from_url_with_client(source_url, temp_file, client).await { + if let Err(error) = + net::download_from_url_with_client(source_url, temp_file, client.to_inner()).await + { return Err(match error { NetError::UrlNotFound { url } => WarpgateError::DownloadNotFound { url }.into(), _ => error.into(), diff --git a/crates/warpgate/src/host.rs b/crates/warpgate/src/host.rs index 9f1934833..b887b8bf7 100644 --- a/crates/warpgate/src/host.rs +++ b/crates/warpgate/src/host.rs @@ -1,7 +1,9 @@ +use crate::client::HttpClient; use crate::error::WarpgateError; -use crate::{create_cache_key, determine_cache_extension, helpers}; +// use crate::helpers::{self, create_cache_key, determine_cache_extension}; +use crate::helpers; use extism::{CurrentPlugin, Error, Function, UserData, Val, ValType}; -use reqwest::header; +// use reqwest::header; use starbase_styles::color::{self, apply_style_tags}; use starbase_utils::env::paths; use starbase_utils::fs; @@ -9,7 +11,7 @@ use std::collections::BTreeMap; use std::env; use std::path::PathBuf; use std::sync::Arc; -use std::time::{Duration, SystemTime}; +// use std::time::{Duration, SystemTime}; use system_env::{create_process_command, find_command_on_path}; use tokio::runtime::Handle; use tracing::{instrument, trace}; @@ -21,7 +23,7 @@ use warpgate_api::{ #[derive(Clone, Default)] pub struct HostData { pub cache_dir: PathBuf, - pub http_client: Arc, + pub http_client: Arc, pub virtual_paths: BTreeMap, pub working_dir: PathBuf, } @@ -262,87 +264,116 @@ fn send_request( let data = user_data.get()?; let data = data.lock().unwrap(); - let cache_key = create_cache_key(&input.url, None); - let cache_path = data.cache_dir.join("requests").join(format!( - "{cache_key}{}", - determine_cache_extension(&input.url).unwrap_or_default() - )); - - // Data to collect - let mut ok = true; - let mut status = 200; - let body; - - // Read from the cache if available and not stale - if cache_path.exists() - && fs::is_stale( - &cache_path, - false, - Duration::from_secs(60 * 60 * 12), // 12 hours - SystemTime::now(), - )? - .is_none() - { - trace!( - plugin = &uuid, - cache = ?cache_path, - "Reusing request from local cache" - ); - - body = fs::read_file_bytes(cache_path)?; - } - // Otherwise send the request and get the response - else { - trace!( - plugin = &uuid, - url = &input.url, - "Sending request from host machine" - ); + // let cache_key = create_cache_key(&input.url, None); + // let cache_path = data.cache_dir.join("requests").join(format!( + // "{cache_key}{}", + // determine_cache_extension(&input.url).unwrap_or_default() + // )); + + // // Data to collect + // let mut ok = true; + // let mut status = 200; + // let body; + + // // Read from the cache if available and not stale + // if cache_path.exists() + // && fs::is_stale( + // &cache_path, + // false, + // Duration::from_secs(60 * 60 * 12), // 12 hours + // SystemTime::now(), + // )? + // .is_none() + // { + // trace!( + // plugin = &uuid, + // cache = ?cache_path, + // "Reusing request from local cache" + // ); + + // body = fs::read_file_bytes(cache_path)?; + // } + // // Otherwise send the request and get the response + // else { + // trace!( + // plugin = &uuid, + // url = &input.url, + // "Sending request from host machine" + // ); + + // let response = Handle::current().block_on(async { + // let mut client = data.http_client.get(&input.url); + + // if let Some(timeout) = plugin.time_remaining() { + // client = client.timeout(timeout); + // } + + // client + // .send() + // .await + // .map_err(|error| HttpClient::map_error(input.url.clone(), error)) + // })?; + + // ok = response.status().is_success(); + // status = response.status().as_u16(); + + // let should_cache = response + // .headers() + // .get(header::CONTENT_TYPE) + // .and_then(|header| header.to_str().ok()) + // .map_or(false, |header| { + // header == "application/json" + // || header == "application/toml" + // || header == "application/yaml" + // || header.starts_with("text/") + // }); + + // let bytes = Handle::current().block_on(async { + // response.bytes().await.map_err(|error| WarpgateError::Http { + // url: input.url.clone(), + // error: Box::new(error), + // }) + // })?; + + // body = Vec::from(bytes); + + // // Don't cache all requests, only those that are text based! + // if should_cache { + // fs::write_file(&cache_path, &body)?; + // } + // }; - let response = Handle::current().block_on(async { - let mut client = data.http_client.get(&input.url); + trace!( + plugin = &uuid, + url = &input.url, + "Sending request from host machine" + ); - if let Some(timeout) = plugin.time_remaining() { - client = client.timeout(timeout); - } + let response = Handle::current().block_on(async { + let mut client = data.http_client.get(&input.url); - client.send().await.map_err(|error| WarpgateError::Http { - url: input.url.clone(), - error: Box::new(error), - }) - })?; - - ok = response.status().is_success(); - status = response.status().as_u16(); - - let should_cache = response - .headers() - .get(header::CONTENT_TYPE) - .and_then(|header| header.to_str().ok()) - .map_or(false, |header| { - header == "application/json" - || header == "application/toml" - || header == "application/yaml" - || header.starts_with("text/") - }); - - let bytes = Handle::current().block_on(async { - response.bytes().await.map_err(|error| WarpgateError::Http { - url: input.url.clone(), - error: Box::new(error), - }) - })?; - - body = Vec::from(bytes); - - // Don't cache all requests, only those that are text based! - if should_cache { - fs::write_file(&cache_path, &body)?; + if let Some(timeout) = plugin.time_remaining() { + client = client.timeout(timeout); } - }; + + client + .send() + .await + .map_err(|error| HttpClient::map_error(input.url.clone(), error)) + })?; + + let ok = response.status().is_success(); + let status = response.status().as_u16(); + + let bytes = Handle::current().block_on(async { + response.bytes().await.map_err(|error| WarpgateError::Http { + url: input.url.clone(), + error: Box::new(error), + }) + })?; // Create and return our intermediate shapes - let memory = plugin.memory_new(body)?; + let memory = plugin.memory_new(Vec::from(bytes))?; let output = SendRequestOutput { body: Vec::new(), diff --git a/crates/warpgate/src/loader.rs b/crates/warpgate/src/loader.rs index a0d6a5bb1..63bd9fd1d 100644 --- a/crates/warpgate/src/loader.rs +++ b/crates/warpgate/src/loader.rs @@ -1,4 +1,4 @@ -use crate::client::{create_http_client_with_options, HttpOptions}; +use crate::client::{create_http_client_with_options, HttpClient, HttpOptions}; use crate::endpoints::*; use crate::error::WarpgateError; use crate::helpers::{ @@ -23,7 +23,7 @@ pub type OfflineChecker = Arc bool>; #[derive(Clone)] pub struct PluginLoader { /// Instance of our HTTP client. - http_client: OnceCell>, + http_client: OnceCell>, /// Options to pass to the HTTP client. http_options: HttpOptions, @@ -59,7 +59,7 @@ impl PluginLoader { } /// Return the HTTP client, or create it if it does not exist. - pub fn get_client(&self) -> miette::Result<&Arc> { + pub fn get_client(&self) -> miette::Result<&Arc> { self.http_client .get_or_try_init(|| create_http_client_with_options(&self.http_options).map(Arc::new)) } From 3ae1e5e81da8446f13fdeaa7b7716d6fe45427fe Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Sat, 30 Nov 2024 17:29:07 -0800 Subject: [PATCH 08/12] fix: Fix `proto setup` issues. (#667) --- CHANGELOG.md | 2 ++ Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/cli/src/commands/setup.rs | 9 ++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fca00660..671959942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,10 +24,12 @@ - Added support for `~/.netrc` configuration to all HTTP requests. - Improved implementation of HTTP request/response caching. Now takes into account [HTTP cache semantics](https://github.com/kornelski/rusty-http-cache-semantics). - Updated `proto upgrade` to error if there's another process of proto currently running. +- Updated `proto setup` to default to a fallback shell if none could be detected, instead of erroring. #### 🐞 Fixes - Fixed the order of shell profiles/configs when applicable. +- Updated `proto setup` to inherit `PROTO_HOME` if already set, instead of defaulting to `$HOME/.proto`. #### ⚙️ Internal diff --git a/Cargo.lock b/Cargo.lock index 549cb9208..d34d32cbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3687,9 +3687,9 @@ dependencies = [ [[package]] name = "starbase_shell" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c92e59e9cb8234c7d07f8260b7196c0d0cd29f4b31cfad8180bc3bcfe0c2619" +checksum = "0e5fab2d4fa242f3e4453718ad21b05e5f3126681437e5b1e04b14833de966b7" dependencies = [ "miette 7.2.0", "regex", diff --git a/Cargo.toml b/Cargo.toml index aba79adc1..04dfb9bd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ starbase_archive = { version = "0.8.10", features = [ ] } starbase_events = { version = "0.6.3" } starbase_sandbox = { version = "0.7.7" } -starbase_shell = { version = "0.6.3", features = ["miette"] } +starbase_shell = { version = "0.6.4", features = ["miette"] } starbase_styles = { version = "0.4.6" } starbase_utils = { version = "0.8.13", default-features = false, features = [ "json", diff --git a/crates/cli/src/commands/setup.rs b/crates/cli/src/commands/setup.rs index 5119b75cf..ad8bf798f 100644 --- a/crates/cli/src/commands/setup.rs +++ b/crates/cli/src/commands/setup.rs @@ -6,7 +6,7 @@ use crate::shell::{ use clap::Args; use proto_shim::get_exe_file_name; use starbase::AppResult; -use starbase_shell::{BoxedShell, ShellError, ShellType}; +use starbase_shell::{BoxedShell, ShellType}; use starbase_styles::color; use std::env; use std::io::stdout; @@ -70,7 +70,7 @@ pub async fn setup(session: ProtoSession, args: SetupArgs) -> AppResult { prompt_for_shell()? } else { - return Err(ShellError::CouldNotDetectShell.into()); + ShellType::default() } } }; @@ -83,7 +83,10 @@ pub async fn setup(session: ProtoSession, args: SetupArgs) -> AppResult { &shell, "proto", vec![ - Export::Var("PROTO_HOME".into(), "$HOME/.proto".into()), + Export::Var( + "PROTO_HOME".into(), + env::var("PROTO_HOME").unwrap_or_else(|_| "$HOME/.proto".into()), + ), Export::Path(vec!["$PROTO_HOME/shims".into(), "$PROTO_HOME/bin".into()]), ], ); From 3032208e067c21b40083bc10f7225150a5a0f2a3 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Sun, 1 Dec 2024 11:36:26 -0800 Subject: [PATCH 09/12] fix: Fix Python bin linking. (#665) --- CHANGELOG.md | 5 ++ Cargo.lock | 109 ++++++++++++------------- Cargo.toml | 8 +- crates/cli/Cargo.toml | 3 +- crates/core/src/proto_config.rs | 2 +- crates/core/tests/proto_config_test.rs | 2 +- crates/warpgate/Cargo.toml | 2 +- 7 files changed, 65 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 671959942..4f8d5ea91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,11 @@ - Fixed the order of shell profiles/configs when applicable. - Updated `proto setup` to inherit `PROTO_HOME` if already set, instead of defaulting to `$HOME/.proto`. +#### 🧩 Plugins + +- Updated `python_tool` to v0.12.1. + - Fixed an issue where our bin linking would point to an invalid executable path. + #### ⚙️ Internal - Updated identifiers, versions, and locators to use [compact strings](https://crates.io/crates/compact_str). diff --git a/Cargo.lock b/Cargo.lock index d34d32cbd..146a40959 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1086,9 +1086,9 @@ dependencies = [ [[package]] name = "extism" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7dbc26280a335a1cb5547f99a6459b58d72568bf760306633a16c02826e88f" +checksum = "f03e2cac5668dead4088aa9da25c9985f1a1b72edd3e31b201d2c044647b56f2" dependencies = [ "anyhow", "cbindgen", @@ -1112,9 +1112,9 @@ dependencies = [ [[package]] name = "extism-convert" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a62907d60afa3fc0dfc273833fcb5bb68771f771ce137da1dab7916d856ce9" +checksum = "a33423cbb1226c483f47a9cad883ee804caf45d8b0d2e5c03cd33d9e43ca5561" dependencies = [ "anyhow", "base64 0.22.1", @@ -1128,9 +1128,9 @@ dependencies = [ [[package]] name = "extism-convert-macros" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd75ee443312a8cd7a402e29fb369c1a2b72f532fd7cdaf34f3023e5d8963d5" +checksum = "8bb132f6e20aab7e8eb3715e26ff8893c611abba73242e00771d740a0fbcb384" dependencies = [ "manyhow", "proc-macro-crate", @@ -1141,9 +1141,9 @@ dependencies = [ [[package]] name = "extism-manifest" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8203adde7bb7a632122e387564314c804793773e9a701fd8cbb6b2c5940a6640" +checksum = "6d9c8b50558af0a75ce08b8ef90a37fb018d99cc99a5f7365c33ba008afdbfb4" dependencies = [ "base64 0.22.1", "serde", @@ -2089,9 +2089,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.4" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" [[package]] name = "lock_api" @@ -2220,14 +2220,14 @@ dependencies = [ [[package]] name = "miette" -version = "7.2.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" +checksum = "317f146e2eb7021892722af37cf1b971f0a70c8406f487e24952667616192c64" dependencies = [ "backtrace", "backtrace-ext", "cfg-if", - "miette-derive 7.2.0", + "miette-derive 7.4.0", "owo-colors", "supports-color", "supports-hyperlinks", @@ -2251,9 +2251,9 @@ dependencies = [ [[package]] name = "miette-derive" -version = "7.2.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" dependencies = [ "proc-macro2", "quote", @@ -2620,12 +2620,11 @@ dependencies = [ "extism", "indexmap", "indicatif", - "miette 7.2.0", + "miette 7.4.0", "proto_core", "proto_installer", "proto_pdk_api", "proto_shim", - "regalloc2", "regex", "reqwest", "rust_json", @@ -2668,7 +2667,7 @@ dependencies = [ "convert_case", "dotenvy", "indexmap", - "miette 7.2.0", + "miette 7.4.0", "minisign-verify", "once_cell", "proto_pdk_api", @@ -2699,7 +2698,7 @@ dependencies = [ name = "proto_installer" version = "0.7.1" dependencies = [ - "miette 7.2.0", + "miette 7.4.0", "reqwest", "starbase_archive", "starbase_styles", @@ -3124,9 +3123,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustix" @@ -3145,9 +3144,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.18" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9cc1d47e243d655ace55ed38201c19ae02c148ae56412ab8750e8f0166ab7f" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -3264,14 +3263,14 @@ dependencies = [ [[package]] name = "schematic" -version = "0.17.6" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13cc48a6f0f9cdb16cfa88f7a104e1e77483b03e154b0de40c68af41462d0db" +checksum = "8ef9a634be1649ec5f5516e39eb78d2e84fcf5eef3792acae353d8ade6a7b391" dependencies = [ "garde", "indexmap", "markdown", - "miette 7.2.0", + "miette 7.4.0", "schemars", "schematic_macros", "schematic_types", @@ -3279,16 +3278,16 @@ dependencies = [ "serde_json", "serde_path_to_error", "starbase_styles", - "thiserror 1.0.69", + "thiserror 2.0.3", "toml", "tracing", ] [[package]] name = "schematic_macros" -version = "0.17.4" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5336c468775c5083eaa2958608f68937c491686a079d108e246345f370623f9a" +checksum = "26d2d4005b3b6482801d60ba093c550d25382401e0c4d1c3fbba80eb07e28626" dependencies = [ "convert_case", "darling", @@ -3299,9 +3298,9 @@ dependencies = [ [[package]] name = "schematic_types" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "768ff9d8765442119bfb73b7808607f76f75fb2987932637d43b144d6ad5e3fe" +checksum = "f320deb050277c5bcc79213b01d749f8a847a63713e76d5748fdad654f47ed52" dependencies = [ "indexmap", "semver", @@ -3583,12 +3582,6 @@ dependencies = [ "serde", ] -[[package]] -name = "smawk" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" - [[package]] name = "socket2" version = "0.5.7" @@ -3642,7 +3635,7 @@ checksum = "472e15cb7da9f3348555a671fe61e58fc901ecdfc45972fe304a2f367e2eb424" dependencies = [ "async-trait", "chrono", - "miette 7.2.0", + "miette 7.4.0", "starbase_styles", "tokio", "tracing", @@ -3659,7 +3652,7 @@ dependencies = [ "binstall-tar", "bzip2", "flate2", - "miette 7.2.0", + "miette 7.4.0", "rustc-hash", "starbase_styles", "starbase_utils", @@ -3691,7 +3684,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e5fab2d4fa242f3e4453718ad21b05e5f3126681437e5b1e04b14833de966b7" dependencies = [ - "miette 7.2.0", + "miette 7.4.0", "regex", "sysinfo", "thiserror 2.0.3", @@ -3705,7 +3698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1664b29d64bf37a14a0f50ae4c1568eb712c7eb28fb489aabac81c36e5558c1" dependencies = [ "dirs 5.0.1", - "miette 7.2.0", + "miette 7.4.0", "owo-colors", "supports-color", ] @@ -3719,7 +3712,7 @@ dependencies = [ "dirs 5.0.1", "fs4", "json-strip-comments", - "miette 7.2.0", + "miette 7.4.0", "regex", "reqwest", "serde", @@ -3914,12 +3907,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -3934,7 +3927,6 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ - "smawk", "unicode-linebreak", "unicode-width 0.1.14", ] @@ -4152,9 +4144,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -4164,9 +4156,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -4291,12 +4283,13 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.10.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" +checksum = "b30e6f97efe1fa43535ee241ee76967d3ff6ff3953ebb430d8d55c5393029e7b" dependencies = [ "base64 0.22.1", "flate2", + "litemap", "log", "once_cell", "rustls", @@ -4304,6 +4297,8 @@ dependencies = [ "rustls-pki-types", "url", "webpki-roots", + "yoke", + "zerofrom", ] [[package]] @@ -4405,7 +4400,7 @@ dependencies = [ "compact_str 0.8.0", "extism", "http-cache-reqwest", - "miette 7.2.0", + "miette 7.4.0", "once_cell", "regex", "reqwest", @@ -5417,9 +5412,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yoke" -version = "0.7.5" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" dependencies = [ "serde", "stable_deref_trait", @@ -5462,9 +5457,9 @@ dependencies = [ [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" dependencies = [ "zerofrom-derive", ] diff --git a/Cargo.toml b/Cargo.toml index 04dfb9bd7..f9d094110 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ extism-pdk = "1.3.0" http-cache-reqwest = "0.15.0" human-sort = "0.2.2" indexmap = "2.6.0" -miette = "7.2.0" +miette = "7.4.0" once_cell = "1.20.2" regex = { version = "1.11.1", default-features = false, features = ["std"] } reqwest = { version = "0.12.9", default-features = false, features = [ @@ -30,9 +30,9 @@ reqwest-middleware = { version = "0.4.0", default-features = false, features = [ "http2", ] } reqwest-netrc = "0.1.2" -rustc-hash = "2.0.0" +rustc-hash = "2.1.0" scc = "2.2.5" -schematic = { version = "0.17.6", default-features = false } +schematic = { version = "0.17.7", default-features = false } semver = { version = "1.0.23", features = ["serde"] } serde = { version = "1.0.214", features = ["derive"] } serde_json = "1.0.133" @@ -61,7 +61,7 @@ starbase_utils = { version = "0.8.13", default-features = false, features = [ ] } thiserror = "2.0.3" tokio = { version = "1.41.0", features = ["full", "tracing"] } -tracing = "0.1.40" +tracing = "0.1.41" uuid = { version = "1.11.0", features = ["v4"] } [profile.dist] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index d1432d4c6..35b7c4c65 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -70,8 +70,7 @@ rust_json = "0.1.5" sigpipe = "0.1.3" # For extism/wastime -extism = "1.9.0" -regalloc2 = "=0.10.2" +extism = "1.9.1" wasmtime = "~26.0.1" wasi-common = "~26.0.1" wiggle = "~26.0.1" diff --git a/crates/core/src/proto_config.rs b/crates/core/src/proto_config.rs index 5dac34c42..11f60dd31 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("python"), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/python_tool-v0.12.0/python_tool.wasm".into() + url: "https://github.com/moonrepo/tools/releases/download/python_tool-v0.12.1/python_tool.wasm".into() })) ); } diff --git a/crates/core/tests/proto_config_test.rs b/crates/core/tests/proto_config_test.rs index 93399465e..d0295207c 100644 --- a/crates/core/tests/proto_config_test.rs +++ b/crates/core/tests/proto_config_test.rs @@ -342,7 +342,7 @@ foo = "file://./test.toml" use super::*; #[test] - #[should_panic(expected = "does not exist")] + #[should_panic(expected = "not exist")] fn errors_if_file_missing() { let sandbox = create_empty_sandbox(); sandbox.create_file( diff --git a/crates/warpgate/Cargo.toml b/crates/warpgate/Cargo.toml index 8ee3b0406..f2f9603a9 100644 --- a/crates/warpgate/Cargo.toml +++ b/crates/warpgate/Cargo.toml @@ -32,7 +32,7 @@ tokio = { workspace = true } tracing = { workspace = true } # Enabling certs for extism! -ureq = { version = "2.10.1", features = ["native-certs"] } +ureq = { version = "2.11.0", features = ["native-certs"] } [dev-dependencies] starbase_sandbox = { workspace = true } From 685619346e4d13c492c1682a2f1efe69466fc3f2 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Mon, 2 Dec 2024 12:24:25 -0800 Subject: [PATCH 10/12] new: Allow tools to require other tools. (#666) --- CHANGELOG.md | 8 ++ Cargo.lock | 4 +- crates/cli/Cargo.toml | 2 +- crates/cli/src/commands/bin.rs | 4 +- crates/cli/src/commands/clean.rs | 3 +- crates/cli/src/commands/install.rs | 127 ++++++++++++++++----- crates/cli/src/commands/plugin/info.rs | 8 ++ crates/cli/src/error.rs | 27 +++-- crates/cli/src/helpers.rs | 21 ++-- crates/cli/src/main.rs | 1 + crates/cli/src/session.rs | 7 ++ crates/cli/src/systems.rs | 3 +- crates/cli/src/utils/install_graph.rs | 88 ++++++++++++++ crates/cli/src/utils/mod.rs | 1 + crates/cli/tests/bin_test.rs | 34 +++--- crates/cli/tests/install_all_test.rs | 43 +++++++ crates/cli/tests/install_uninstall_test.rs | 38 +++++- crates/codegen/Cargo.toml | 2 +- crates/core/Cargo.toml | 2 +- crates/core/src/proto_config.rs | 4 +- crates/pdk-api/Cargo.toml | 2 +- crates/pdk-api/src/api/mod.rs | 4 + crates/pdk-test-utils/Cargo.toml | 2 +- crates/pdk/Cargo.toml | 4 +- 24 files changed, 353 insertions(+), 86 deletions(-) create mode 100644 crates/cli/src/utils/install_graph.rs create mode 100644 crates/cli/src/utils/mod.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f8d5ea91..4cea0a5cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ #### 🚀 Updates +- Added a system that allows plugins to require other plugins to be installed, before they will install. - Added an `--on-init` option to `proto activate`, which will trigger the activation hook immediately in the shell, instead of waiting for a directory/prompt change to occur. - If you were manually executing `_proto_hook` before, this will now fail. Please remove! - Added support for loading `.env` files through the special `env.file` and `tools.*.env.file` settings. @@ -23,8 +24,11 @@ ``` - Added support for `~/.netrc` configuration to all HTTP requests. - Improved implementation of HTTP request/response caching. Now takes into account [HTTP cache semantics](https://github.com/kornelski/rusty-http-cache-semantics). +- Updated `proto install` to multi-install tools in topological order. - Updated `proto upgrade` to error if there's another process of proto currently running. - Updated `proto setup` to default to a fallback shell if none could be detected, instead of erroring. +- WASM API + - Added `ToolMetadataOutput.requires`, allowing the plugin to require other plugins. For example, npm requires node. #### 🐞 Fixes @@ -33,8 +37,12 @@ #### 🧩 Plugins +- Updated `node_depman_tool` to v0.14.1. + - Added `node` as a required plugin. - Updated `python_tool` to v0.12.1. - Fixed an issue where our bin linking would point to an invalid executable path. +- Updated `schema_tool` to v0.16.2. + - Added `metadata.requires`, for defining plugin requirements. #### ⚙️ Internal diff --git a/Cargo.lock b/Cargo.lock index 146a40959..eb8591ffb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2710,7 +2710,7 @@ dependencies = [ [[package]] name = "proto_pdk" -version = "0.25.3" +version = "0.25.4" dependencies = [ "extism-pdk", "proto_pdk_api", @@ -2721,7 +2721,7 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.24.3" +version = "0.24.4" dependencies = [ "proto_pdk_api", "rustc-hash", diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 35b7c4c65..4d4825891 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.6", path = "../core", features = ["clap"] } proto_installer = { version = "0.7.1", path = "../installer" } -proto_pdk_api = { version = "0.24.3", path = "../pdk-api" } +proto_pdk_api = { version = "0.24.4", 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/cli/src/commands/bin.rs b/crates/cli/src/commands/bin.rs index 57f9c5663..28b034f34 100644 --- a/crates/cli/src/commands/bin.rs +++ b/crates/cli/src/commands/bin.rs @@ -1,6 +1,6 @@ use crate::session::ProtoSession; use clap::Args; -use proto_core::{detect_version, Id, UnresolvedVersionSpec}; +use proto_core::{detect_version, Id, UnresolvedVersionSpec, PROTO_PLUGIN_KEY}; use proto_shim::{get_exe_file_name, locate_proto_exe}; use starbase::AppResult; @@ -21,7 +21,7 @@ pub struct BinArgs { #[tracing::instrument(skip_all)] pub async fn bin(session: ProtoSession, args: BinArgs) -> AppResult { - if args.id == "proto" { + if args.id == PROTO_PLUGIN_KEY { println!( "{}", locate_proto_exe("proto") diff --git a/crates/cli/src/commands/clean.rs b/crates/cli/src/commands/clean.rs index 3c807b93e..6ede55695 100644 --- a/crates/cli/src/commands/clean.rs +++ b/crates/cli/src/commands/clean.rs @@ -3,6 +3,7 @@ use crate::session::ProtoSession; use clap::Args; use dialoguer::Confirm; use miette::IntoDiagnostic; +use proto_core::PROTO_PLUGIN_KEY; use proto_core::{Id, ProtoError, Tool, VersionSpec}; use proto_shim::get_exe_file_name; use rustc_hash::FxHashSet; @@ -201,7 +202,7 @@ pub async fn clean_proto(session: &ProtoSession, days: u64) -> miette::Result