From 251b51b79f6e4096c34eda0f34501d4e62f1d47c Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Fri, 1 Mar 2024 13:55:55 -0800 Subject: [PATCH] new: Support proto v0.31. (#30) --- CHANGELOG.md | 14 + Cargo.lock | 398 ++++++++++-------- Cargo.toml | 16 +- README.md | 11 +- crates/common/src/commands.rs | 56 --- crates/common/src/config.rs | 2 +- crates/common/src/lib.rs | 1 - crates/node-depman/Cargo.toml | 3 +- crates/node-depman/src/proto.rs | 217 +++++++--- crates/node-depman/tests/globals_test.rs | 21 - crates/node-depman/tests/hooks_test.rs | 337 ++++++++++++--- ...ims_test__npm__creates_global_shims-2.snap | 14 - ...ims_test__npm__creates_global_shims-3.snap | 14 - ...ap => shims_test__npm__creates_shims.snap} | 0 ...ms_test__pnpm__creates_global_shims-2.snap | 14 - ...p => shims_test__pnpm__creates_shims.snap} | 0 ...ms_test__yarn__creates_global_shims-2.snap | 14 - ...p => shims_test__yarn__creates_shims.snap} | 0 crates/node-depman/tests/versions_test.rs | 6 +- crates/node/Cargo.toml | 2 +- crates/node/src/proto.rs | 39 +- crates/node/tests/globals_test.rs | 3 - ...ms.snap => shims_test__creates_shims.snap} | 0 crates/node/tests/versions_test.rs | 4 +- rust-toolchain.toml | 2 +- 25 files changed, 709 insertions(+), 479 deletions(-) delete mode 100644 crates/common/src/commands.rs delete mode 100644 crates/node-depman/tests/globals_test.rs delete mode 100644 crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-2.snap delete mode 100644 crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-3.snap rename crates/node-depman/tests/snapshots/{shims_test__npm__creates_global_shims.snap => shims_test__npm__creates_shims.snap} (100%) delete mode 100644 crates/node-depman/tests/snapshots/shims_test__pnpm__creates_global_shims-2.snap rename crates/node-depman/tests/snapshots/{shims_test__pnpm__creates_global_shims.snap => shims_test__pnpm__creates_shims.snap} (100%) delete mode 100644 crates/node-depman/tests/snapshots/shims_test__yarn__creates_global_shims-2.snap rename crates/node-depman/tests/snapshots/{shims_test__yarn__creates_global_shims.snap => shims_test__yarn__creates_shims.snap} (100%) delete mode 100644 crates/node/tests/globals_test.rs rename crates/node/tests/snapshots/{shims_test__creates_global_shims.snap => shims_test__creates_shims.snap} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9d7dc4..73cd461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.10.0 + +#### 💥 Breaking + +- Removed `install_global`, use `npm/pnpm/yarn` instead. +- Removed `uninstall_global`, use `npm/pnpm/yarn` instead. +- Removed the `intercept-globals` config setting. + +#### 🚀 Updates + +- Added a new `shared-globals-dir` setting, which injects args/env vars into npm/pnpm/yarn commands when they attemp to install global packages. +- Updated to support proto v0.31 release. +- Updated dependencies. + ## 0.9.1 #### 🚀 Updates diff --git a/Cargo.lock b/Cargo.lock index 804f516..ce309a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,9 +67,9 @@ checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "arbitrary" @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", @@ -212,9 +212,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cached" -version = "0.48.1" +version = "0.49.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355face540df58778b96814c48abb3c2ed67c4878a8087ab1819c1fedeec505f" +checksum = "f251fd1e72720ca07bf5d8e310f54a193fd053479a1f6342c6663ee4fa01cf96" dependencies = [ "ahash", "cached_proc_macro", @@ -227,9 +227,9 @@ dependencies = [ [[package]] name = "cached_proc_macro" -version = "0.19.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d52f526f7cbc875b296856ca8c964a9f6290556922c303a8a3883e3c676e6a1" +checksum = "ad9f16c0d84de31a2ab7fdf5f7783c14631f7075cf464eb3bb43119f61c9cb2a" dependencies = [ "darling 0.14.4", "proc-macro2", @@ -650,12 +650,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" dependencies = [ - "darling_core 0.20.3", - "darling_macro 0.20.3", + "darling_core 0.20.8", + "darling_macro 0.20.8", ] [[package]] @@ -674,9 +674,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" dependencies = [ "fnv", "ident_case", @@ -699,11 +699,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ - "darling_core 0.20.3", + "darling_core 0.20.8", "quote", "syn 2.0.48", ] @@ -859,9 +859,9 @@ dependencies = [ [[package]] name = "extism" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5472dcd9d979ac3a094f1712dea48936a4ef7c35600184f89464c145c2e7dd1c" +checksum = "7360c0823a0e303eb0b5bdb1125a5dae0867a77bfc533bd7e306b5989a53aab6" dependencies = [ "anyhow", "cbindgen", @@ -872,7 +872,7 @@ dependencies = [ "serde", "serde_json", "sha2", - "toml 0.8.8", + "toml 0.8.10", "tracing", "tracing-subscriber", "ureq", @@ -884,24 +884,38 @@ dependencies = [ [[package]] name = "extism-convert" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b5889f52d54f53d540f4661af6122cb6443449a0c9111d5458383352aa2dda" +checksum = "8e78a2317936c20806cb60fa98c15dcc5ccf43458e4cbddad3c6cce17a05b31c" dependencies = [ "anyhow", "base64", "bytemuck", + "extism-convert-macros", "prost", "rmp-serde", "serde", "serde_json", ] +[[package]] +name = "extism-convert-macros" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d190cc0c058346b7750868de96dab17e047e7588ec91691a29b6db4eafd51a7e" +dependencies = [ + "manyhow", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "extism-manifest" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e977dc7c7b75e819b184f35a67c4922e5b2a5424fbdc5c4188e74991b9c9e199" +checksum = "a08af46dc0633e0874e6c1a66ac1226bf2fad6fa67568538238af8b316569d06" dependencies = [ "base64", "serde", @@ -910,9 +924,9 @@ dependencies = [ [[package]] name = "extism-pdk" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ac12d16e778ccf351f39a45efb65c0bbdb45bc9928c557507e808efafa51cf" +checksum = "1f9a87d636d30b75e697642dd4f6cff2054db5a7a5d69d6601041a76265bb681" dependencies = [ "anyhow", "base64", @@ -925,9 +939,9 @@ dependencies = [ [[package]] name = "extism-pdk-derive" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a79239414de9041626020530854cef77027a28d92bf542c7854e271101e9aa" +checksum = "d83995c2023720a0fd5ef2a349c89c1670efb37a979228b0218705f5ddb50d4b" dependencies = [ "proc-macro2", "quote", @@ -1137,9 +1151,9 @@ dependencies = [ [[package]] name = "garde" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237d668ccb63fd96dff6a81c5f37b7d984872f9584794dc1d1a62472d2c7b57" +checksum = "d5fa8fb3ffe035745c6194540b2064b2fe275f32367fbb4eb026024b7921e2e5" dependencies = [ "compact_str", "garde_derive", @@ -1150,9 +1164,9 @@ dependencies = [ [[package]] name = "garde_derive" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a42efb40be9de1926cfd15881ff08adb7a70c6cedacced425537c8b1f96ac4f" +checksum = "9cf62650515830c41553b72bd49ec20fb120226f9277c7f2847f071cf998325b" dependencies = [ "proc-macro2", "quote", @@ -1188,7 +1202,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" dependencies = [ "fallible-iterator", - "indexmap 2.1.0", + "indexmap 2.2.3", "stable_deref_trait", ] @@ -1430,9 +1444,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.2", @@ -1494,22 +1508,11 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix 0.38.28", - "windows-sys 0.48.0", -] - [[package]] name = "is_ci" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" [[package]] name = "itertools" @@ -1574,10 +1577,10 @@ dependencies = [ ] [[package]] -name = "json_comments" -version = "0.2.2" +name = "json-strip-comments" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbbfed4e59ba9750e15ba154fdfd9329cee16ff3df539c2666b70f58cc32105" +checksum = "c3d129799327c8f80861e467c59b825ba24c277dba6ad0d71a141dc98f9e04ee" [[package]] name = "lazy_static" @@ -1651,6 +1654,29 @@ dependencies = [ "libc", ] +[[package]] +name = "manyhow" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cd8783b626890c6e8124a894135b3bebca18af66a00f8e246dc378084d56e8" +dependencies = [ + "manyhow-macros", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "manyhow-macros" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532aa12d5846b38a524b3acd99fb74dc8a5f193b33e65dac142ef92bd60f9416" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + [[package]] name = "matchers" version = "0.1.0" @@ -1692,21 +1718,20 @@ dependencies = [ [[package]] name = "miette" -version = "5.10.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" +checksum = "baed61d13cc3723ee6dbed730a82bfacedc60a85d81da2d77e9c3e8ebc0b504a" dependencies = [ "miette-derive", - "once_cell", "thiserror", "unicode-width", ] [[package]] name = "miette-derive" -version = "5.10.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" +checksum = "f301c3f54f98abc6c212ee722f5e5c62e472a334415840669e356f04850051ec" dependencies = [ "proc-macro2", "quote", @@ -1772,11 +1797,12 @@ dependencies = [ [[package]] name = "node_depman_plugin" -version = "0.9.1" +version = "0.10.0" dependencies = [ "extism-pdk", "node_common", "proto_pdk", + "proto_pdk_api", "proto_pdk_test_utils", "regex", "serde", @@ -1787,7 +1813,7 @@ dependencies = [ [[package]] name = "node_plugin" -version = "0.9.1" +version = "0.10.0" dependencies = [ "extism-pdk", "node_common", @@ -1852,7 +1878,7 @@ checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "crc32fast", "hashbrown 0.14.2", - "indexmap 2.1.0", + "indexmap 2.2.3", "memchr", ] @@ -1864,9 +1890,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "once_map" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f2d1d09016ea926b4a8c89938674322fca80bc139d605b21a574c0ce1000a19" +checksum = "0087372f82622a51024ad20d38a6901ba83d09de1e23ef15a621e4404dadbb7a" dependencies = [ "ahash", "hashbrown 0.14.2", @@ -1894,9 +1920,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" [[package]] name = "parking_lot" @@ -1968,14 +1994,13 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" -version = "3.0.4" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dfc28575c2e3f19cb3c73b93af36460ae898d426eba6fc15b9bd2a5220758a0" +checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" dependencies = [ "anstyle", "difflib", "float-cmp", - "itertools 0.11.0", "normalize-line-endings", "predicates-core", "regex", @@ -2007,11 +2032,31 @@ dependencies = [ "yansi", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.0", +] + +[[package]] +name = "proc-macro-utils" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f59e109e2f795a5070e69578c4dc101068139f74616778025ae1011d4cd41a8" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -2041,13 +2086,13 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.29.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276b59495e6c7a4d7df813ddac9d6c21eb392c0d00f36c10e0988df00bebd11a" +checksum = "9901b14a4c9681199ae9a22e04374d14c03fc3c30608d64f844a14a2f44506ff" dependencies = [ "cached", "human-sort", - "indexmap 2.1.0", + "indexmap 2.2.3", "miette", "minisign-verify", "once_cell", @@ -2055,6 +2100,7 @@ dependencies = [ "proto_shim", "regex", "reqwest", + "rustc-hash", "schematic", "semver", "serde", @@ -2075,22 +2121,24 @@ dependencies = [ [[package]] name = "proto_pdk" -version = "0.15.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf90105b373875a194fda4b02e1a6f7be3d043976f27d6e85704070ed1cd7ca" +checksum = "9d8f8400299da97f4addc90447ef5a1251272d88dcc2d8173ea15d849cd343e6" dependencies = [ "extism-pdk", "proto_pdk_api", + "rustc-hash", "serde", "warpgate_pdk", ] [[package]] name = "proto_pdk_api" -version = "0.15.1" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c4edbb65667fa05ad5a83c281c369bfd4243f66d08e1b8db8107753121eb81" +checksum = "9d6cbed3545b6d4a1650ea5ca618342ad8f1054c42d8200028a4d48e5dd83531" dependencies = [ + "rustc-hash", "semver", "serde", "serde_json", @@ -2102,9 +2150,9 @@ dependencies = [ [[package]] name = "proto_pdk_test_utils" -version = "0.17.2" +version = "0.19.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6117b549659d6c0425a932493918f8d5982d642757544c0bae619903cbe40f2" +checksum = "bdea1655c095642442b94e2f6a5a39c9458b728f5c3109df8b3360ee79dc8bd8" dependencies = [ "extism", "proto_core", @@ -2116,9 +2164,9 @@ dependencies = [ [[package]] name = "proto_shim" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9818ce0d6c81e911ef60f047b9e8befdab59a2aebda8fee7c54da8a7556ba0bc" +checksum = "2065b1e7c1bf5d1d590052f0e8457280a84584840abfcb0a52de96ecadd1897a" dependencies = [ "command-group", "dirs 5.0.1", @@ -2288,15 +2336,15 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "relative-path" -version = "1.9.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" +checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "base64", "bytes", @@ -2321,6 +2369,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-rustls", @@ -2495,12 +2544,12 @@ dependencies = [ [[package]] name = "schematic" -version = "0.13.5" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b264774063bdc7a16fe1158426b5a29604478d1c64da0b73cba396505329116" +checksum = "709e1f0b0a3db267a98da09c89a7818e307cc8daea841e1079eb5f5a02591d54" dependencies = [ "garde", - "indexmap 2.1.0", + "indexmap 2.2.3", "miette", "schematic_macros", "schematic_types", @@ -2508,18 +2557,18 @@ dependencies = [ "serde_path_to_error", "starbase_styles", "thiserror", - "toml 0.8.8", + "toml 0.8.10", "tracing", ] [[package]] name = "schematic_macros" -version = "0.13.4" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5362f20a1e2346fb9a7878261b27c8e1adf7872bf4201b7c018dfd3cd88e26a7" +checksum = "31af7347544d97d00870a5865d2077dac07c069a5290c26215ddd1138b302590" dependencies = [ "convert_case", - "darling 0.20.3", + "darling 0.20.8", "proc-macro2", "quote", "syn 2.0.48", @@ -2527,13 +2576,13 @@ dependencies = [ [[package]] name = "schematic_types" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c90769caea1c16e71c756f7afe77a35620d61f77d3db4b834d246203f4ea44b" +checksum = "8f3adfbe1c90a6a9643433e490ef1605c6a99f93be37e4c83fe5149fca9698c6" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.3", "serde_json", - "toml 0.8.8", + "toml 0.8.10", ] [[package]] @@ -2577,27 +2626,27 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", @@ -2606,9 +2655,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -2627,9 +2676,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -2782,9 +2831,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "starbase_archive" -version = "0.2.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a0d1c404d4e987597b018bee76fb8e79937f3b2ab0cf5963ce043031092694" +checksum = "a99a24e91bf823d46d04d520fb87c02ab0c3cac75bfdcf3c7671505681fd9f29" dependencies = [ "flate2", "miette", @@ -2801,9 +2850,9 @@ dependencies = [ [[package]] name = "starbase_events" -version = "0.2.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455a107aab23fa941399ed716e42776ac8e200f5f92706b7ce59b08949aaf153" +checksum = "b98298edb3a2630bf96c6d422f91c617abda687e8a564f36fb4bc38cecbb7155" dependencies = [ "async-trait", "miette", @@ -2813,11 +2862,11 @@ dependencies = [ [[package]] name = "starbase_macros" -version = "0.2.7" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70da3be1ac772cd1cf5b71a725988b64829da92664b8fc362be765462c28638c" +checksum = "fb40eb09c82a8ddffa48a13d53bec72300b5626cb17f216d1fb4cf1b8a14f118" dependencies = [ - "darling 0.20.3", + "darling 0.20.8", "proc-macro2", "quote", "syn 2.0.48", @@ -2825,9 +2874,9 @@ dependencies = [ [[package]] name = "starbase_sandbox" -version = "0.1.13" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74dc9bd92b3587c63cad2db7cb23c79b0d1d1a25b314990880a7a932f6f31e87" +checksum = "46c13185a91009f058c1649eb9692957e3e78398d98a89ed5fc9c3e24844e9c7" dependencies = [ "assert_cmd", "assert_fs", @@ -2841,9 +2890,9 @@ dependencies = [ [[package]] name = "starbase_styles" -version = "0.1.18" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aadf4bb3f99ac3782017aa75123781dd64de38b543469c6b9e96ca9f29fc4868" +checksum = "0e06fa37c027e48ef341787d8c3d26cfbe8507aa4e2e8c61fcba82fe931bb598" dependencies = [ "dirs 5.0.1", "owo-colors", @@ -2852,23 +2901,22 @@ dependencies = [ [[package]] name = "starbase_utils" -version = "0.3.11" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9af464d976956393070880234f8d9f3509f04555266174abfd9b11386cdce4bc" +checksum = "f23570a8fa500ad7ccb3bbfed7d9dc759b657ed536fb9b10eec729ad9de1b60e" dependencies = [ "dirs 5.0.1", "fs4", - "json_comments", + "json-strip-comments", "miette", "once_cell", - "regex", "relative-path", "serde", "serde_json", "starbase_styles", "thiserror", "tokio", - "toml 0.8.8", + "toml 0.8.10", "tracing", "wax", ] @@ -2887,11 +2935,10 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "supports-color" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89" +checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" dependencies = [ - "is-terminal", "is_ci", ] @@ -2917,6 +2964,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "system-configuration" version = "0.5.1" @@ -2956,9 +3009,9 @@ dependencies = [ [[package]] name = "system_env" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dbaf08f70781cb6543bb0cce3d6b63a50cce05f4b071db833d78426f072ef7b" +checksum = "9cc6e061f286e270fa78c10406c3146455906149b684ae2dc15a3a758da16fda" dependencies = [ "schematic", "serde", @@ -2978,16 +3031,6 @@ dependencies = [ "xattr", ] -[[package]] -name = "tardar" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900c942f83b6a8b9998cc8f74ad3ffa24b7ff3c4279ea1c1c52d95dced9f3516" -dependencies = [ - "miette", - "vec1", -] - [[package]] name = "target-lexicon" version = "0.12.13" @@ -3015,18 +3058,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -3060,9 +3103,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -3123,14 +3166,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.22.6", ] [[package]] @@ -3148,11 +3191,22 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.3", + "toml_datetime", + "winnow 0.5.15", +] + +[[package]] +name = "toml_edit" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1b5fd4128cc8d3e0cb74d4ed9a9cc7c7284becd4df68f5f940e1ad123606f6" +dependencies = [ + "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.2", ] [[package]] @@ -3264,9 +3318,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -3322,12 +3376,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vec1" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bda7c41ca331fe9a1c278a9e7ee055f4be7f5eb1c2b72f079b4ff8b5fce9d5c" - [[package]] name = "version_check" version = "0.9.4" @@ -3336,9 +3384,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "version_spec" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28f9327e7b3c0554ec9291491b8e16bf693d35ea18ba4173efbcf2e76078c91f" +checksum = "a81a98a1dd2c4d6f994f4e217029fcc64f3811769ed8e8b9edaabb0cd0c31f3d" dependencies = [ "human-sort", "regex", @@ -3377,9 +3425,9 @@ dependencies = [ [[package]] name = "warpgate" -version = "0.10.2" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3226aa23973b00283aa7955385a902ea1c4f60b0a5d43533bcc937f6eebd0a07" +checksum = "b945ab3247376a2117ae4a0a33a5956d0e5522df8e17a456a4a46efa314eefc4" dependencies = [ "extism", "miette", @@ -3387,6 +3435,7 @@ dependencies = [ "once_map", "regex", "reqwest", + "rustc-hash", "schematic", "serde", "serde_json", @@ -3402,22 +3451,24 @@ dependencies = [ [[package]] name = "warpgate_api" -version = "0.3.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17eca79a6da0046450f09d55829eb53284e727d3d539f076c19754e81db6d236" +checksum = "0dd67684d947815a66886af056713e392c48bd8f4f5fa4c22c4a7f38f85eb2ca" dependencies = [ "anyhow", + "rustc-hash", "schematic", "serde", "serde_json", "system_env", + "thiserror", ] [[package]] name = "warpgate_pdk" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e54d60b8fe7d4d20f74cea816ee5d761c3bedd796bc00a87c19828b85802b5e" +checksum = "14dc35a3ada370c65a41dffd5b685dd758253d537762e1d2e047264bec8cba5e" dependencies = [ "extism-pdk", "serde", @@ -3554,7 +3605,7 @@ version = "0.118.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.3", "semver", ] @@ -3581,7 +3632,7 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "indexmap 2.1.0", + "indexmap 2.2.3", "libc", "log", "object", @@ -3707,7 +3758,7 @@ dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap 2.1.0", + "indexmap 2.2.3", "log", "object", "serde", @@ -3796,7 +3847,7 @@ dependencies = [ "cc", "cfg-if", "encoding_rs", - "indexmap 2.1.0", + "indexmap 2.2.3", "libc", "log", "mach", @@ -3900,7 +3951,7 @@ checksum = "f328b2d4a690270324756e886ed5be3a4da4c00be0eea48253f4595ad068062b" dependencies = [ "anyhow", "heck", - "indexmap 2.1.0", + "indexmap 2.2.3", "wit-parser", ] @@ -3948,11 +3999,9 @@ checksum = "8d12a78aa0bab22d2f26ed1a96df7ab58e8a93506a3e20adb47c51a93b4e1357" dependencies = [ "const_format", "itertools 0.11.0", - "miette", "nom", "pori", "regex", - "tardar", "thiserror", "walkdir", ] @@ -4281,6 +4330,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -4309,7 +4367,7 @@ checksum = "15df6b7b28ce94b8be39d8df5cb21a08a4f3b9f33b631aedb4aa5776f785ead3" dependencies = [ "anyhow", "id-arena", - "indexmap 2.1.0", + "indexmap 2.2.3", "log", "semver", "serde", diff --git a/Cargo.toml b/Cargo.toml index a84ec77..0979abd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,18 +3,18 @@ resolver = "2" members = ["crates/*"] [workspace.dependencies] -extism-pdk = { version = "1.0.0" } -proto_pdk = { version = "0.15.1" } #, path = "../../proto/crates/pdk" } -proto_pdk_api = { version = "0.15.1" } #, path = "../../proto/crates/pdk-api" } -proto_pdk_test_utils = { version = "0.17.2" } #, path = "../../proto/crates/pdk-test-utils" } +extism-pdk = { version = "1.1.0" } +proto_pdk = { version = "0.17.2" } #, path = "../../proto/crates/pdk" } +proto_pdk_api = { version = "0.17.1" } #, path = "../../proto/crates/pdk-api" } +proto_pdk_test_utils = { version = "0.19.3" } #, path = "../../proto/crates/pdk-test-utils" } regex = { version = "1.10.3", default-features = false, features = [ "std", "unicode", ] } -serde = "1.0.195" -serde_json = "1.0.111" -starbase_sandbox = "0.1.13" -tokio = { version = "1.35.1", features = ["full"] } +serde = "1.0.197" +serde_json = "1.0.114" +starbase_sandbox = "0.4.0" +tokio = { version = "1.36.0", features = ["full"] } [profile.release] codegen-units = 1 diff --git a/README.md b/README.md index 53ba0a6..f9872e9 100644 --- a/README.md +++ b/README.md @@ -22,23 +22,30 @@ npm|pnpm|yarn = "source:https://github.com/moonrepo/node-plugin/releases/downloa All plugins can be configured with a `.prototools` file. - `bundled-npm` (bool) - When `node` is installed, also install `npm` with the version of npm that came bundled with Node.js. Defaults to `false`. -- `intercept-globals` (bool) - When npm, pnpm, or yarn attempt to install a global package, intercept the call and fail with an error message encouraging the use of `proto install-global` instead. Defaults to `false`. +- `shared-globals-dir` (bool) - EXPERIMENTAL: Global npm, pnpm, or yarn packages are installed to a shared location: `~/.proto/tools/node/globals`. Defaults to `false`. ```toml [tools.node] bundled-npm = true +shared-globals-dir = true ``` ## Hooks ### Post-install -After installation and `bundled-npm = true`, the version of npm that came bundled with Node.js will also be installed. This functionality can be skipped by passing `--no-bundled-npm` during installation. +After installation and `bundled-npm` is enabled, the version of npm that came bundled with Node.js will also be installed. This functionality can be skipped by passing `--no-bundled-npm` during installation. ```shell proto install node -- --no-bundled-npm ``` +### Pre-run + +Before a npm/pnpm/yarn command is ran and `shared-globals-dir` is enabled, this hook will modify the arguments or environment variables of the command when installing a global package. + +npm and yarn will set the `PREFIX` environment variable, while pnpm will set `--global-dir` and `--global-bin-dir` arguments. + ## Contributing Build the plugins: diff --git a/crates/common/src/commands.rs b/crates/common/src/commands.rs deleted file mode 100644 index 8bd1f2f..0000000 --- a/crates/common/src/commands.rs +++ /dev/null @@ -1,56 +0,0 @@ -use proto_pdk_api::{ExecCommandInput, HostEnvironment, VirtualPath}; - -pub fn get_global_prefix(env: &HostEnvironment, globals_dir: &VirtualPath) -> String { - let prefix = globals_dir.real_path().to_string_lossy().to_string(); - - // On Windows, globals will be installed into the prefix as-is, - // so binaries will exist in the root of the prefix. - if env.os.is_windows() { - return prefix; - } - - // On Unix, globals are nested within a /bin directory, and since our - // fixed globals dir ends in /bin, we must remove it and set the prefix - // to the parent directory. This way everything resolves correctly. - prefix.replace("/bin", "") -} - -pub fn install_global(dependency: &str, globals_prefix: String) -> ExecCommandInput { - let mut cmd = ExecCommandInput::inherit( - "npm", - [ - "install", - dependency, - "--global", - "--loglevel", - "warn", - "--no-audit", - "--no-update-notifier", - "--prefix", - &globals_prefix, - ], - ); - - cmd.env.insert("PROTO_INSTALL_GLOBAL".into(), "true".into()); - - cmd -} - -pub fn uninstall_global(dependency: &str, globals_prefix: String) -> ExecCommandInput { - let mut cmd = ExecCommandInput::inherit( - "npm", - [ - "uninstall", - dependency, - "--global", - "--loglevel", - "warn", - "--prefix", - &globals_prefix, - ], - ); - - cmd.env.insert("PROTO_INSTALL_GLOBAL".into(), "true".into()); - - cmd -} diff --git a/crates/common/src/config.rs b/crates/common/src/config.rs index 6b79779..a3d6a77 100644 --- a/crates/common/src/config.rs +++ b/crates/common/src/config.rs @@ -2,5 +2,5 @@ #[serde(default, deny_unknown_fields, rename_all = "kebab-case")] pub struct PluginConfig { pub bundled_npm: bool, - pub intercept_globals: bool, + pub shared_globals_dir: bool, } diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 8c158cf..f6e730d 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -1,4 +1,3 @@ -pub mod commands; mod config; mod node_dist; mod package_json; diff --git a/crates/node-depman/Cargo.toml b/crates/node-depman/Cargo.toml index 4bdaeff..8ab83fa 100644 --- a/crates/node-depman/Cargo.toml +++ b/crates/node-depman/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node_depman_plugin" -version = "0.9.1" +version = "0.10.0" edition = "2021" license = "MIT" publish = false @@ -16,6 +16,7 @@ regex = { workspace = true } serde = { workspace = true } [dev-dependencies] +proto_pdk_api = { workspace = true } proto_pdk_test_utils = { workspace = true } serde_json = { workspace = true } starbase_sandbox = { workspace = true } diff --git a/crates/node-depman/src/proto.rs b/crates/node-depman/src/proto.rs index 36b8b03..eaad5ea 100644 --- a/crates/node-depman/src/proto.rs +++ b/crates/node-depman/src/proto.rs @@ -1,10 +1,7 @@ use crate::npm_registry::parse_registry_response; use crate::package_manager::PackageManager; use extism_pdk::*; -use node_common::{ - commands::{self, get_global_prefix}, - NodeDistVersion, PackageJson, PluginConfig, -}; +use node_common::{NodeDistVersion, PackageJson, PluginConfig}; use proto_pdk::*; use std::collections::HashMap; @@ -273,15 +270,20 @@ pub fn download_prebuilt( pub fn locate_executables( Json(_): Json, ) -> FnResult> { + let env = get_host_environment()?; let manager = PackageManager::detect()?; let mut secondary = HashMap::default(); let mut primary; + // These are the directories that contain the executable binaries, + // NOT where the packages/node modules are stored. Some package managers + // have separate folders for the 2 processes, and then create symlinks. + let mut globals_lookup_dirs = vec!["$PREFIX/bin".into()]; + // We don't link binaries for package managers for the following reasons: // 1 - We can't link JS files because they aren't executable. // 2 - We can't link the bash/cmd wrappers, as they expect the files to exist // relative from the node install directory, which they do not. - match &manager { PackageManager::Npm => { primary = ExecutableConfig::with_parent("bin/npm-cli.js", "node"); @@ -299,6 +301,11 @@ pub fn locate_executables( node_gyp.no_bin = true; secondary.insert("node-gyp".into(), node_gyp); + + // https://docs.npmjs.com/cli/v9/configuring-npm/folders#prefix-configuration + // https://github.com/npm/cli/blob/latest/lib/npm.js + // https://github.com/npm/cli/blob/latest/workspaces/config/lib/index.js#L339 + globals_lookup_dirs.push("$TOOL_DIR/bin".into()); } PackageManager::Pnpm => { primary = ExecutableConfig::with_parent("bin/pnpm.cjs", "node"); @@ -313,6 +320,19 @@ pub fn locate_executables( ..ExecutableConfig::default() }, ); + + // https://pnpm.io/npmrc#global-dir + // https://github.com/pnpm/pnpm/blob/main/config/config/src/index.ts#L350 + // https://github.com/pnpm/pnpm/blob/main/config/config/src/dirs.ts#L40 + globals_lookup_dirs.push("$PNPM_HOME".into()); + + if env.os == HostOS::Windows { + globals_lookup_dirs.push("$LOCALAPPDATA\\pnpm".into()); + } else if env.os == HostOS::MacOS { + globals_lookup_dirs.push("$HOME/Library/pnpm".into()); + } else { + globals_lookup_dirs.push("$HOME/.local/share/pnpm".into()); + } } PackageManager::Yarn => { primary = ExecutableConfig::with_parent("bin/yarn.js", "node"); @@ -320,11 +340,26 @@ pub fn locate_executables( // yarnpkg secondary.insert("yarnpkg".into(), primary.clone()); + + // https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/global.js#L84 + if env.os == HostOS::Windows { + globals_lookup_dirs.push("$LOCALAPPDATA\\Yarn\\bin".into()); + globals_lookup_dirs.push("$HOME\\.yarn\\bin".into()); + } else { + globals_lookup_dirs.push("$HOME/.yarn/bin".into()); + } } }; + let config = get_tool_config::()?; + + if config.shared_globals_dir { + globals_lookup_dirs.clear(); + globals_lookup_dirs.push("$PROTO_HOME/tools/node/globals/bin".into()); + } + Ok(Json(LocateExecutablesOutput { - globals_lookup_dirs: vec!["$PROTO_HOME/tools/node/globals/bin".into()], + globals_lookup_dirs, primary: Some(primary), secondary, ..LocateExecutablesOutput::default() @@ -332,79 +367,125 @@ pub fn locate_executables( } #[plugin_fn] -pub fn install_global( - Json(input): Json, -) -> FnResult> { - let env = get_host_environment()?; - - let result = exec_command!( - input, - commands::install_global( - &input.dependency, - get_global_prefix(&env, &input.globals_dir), - ) - ); - - Ok(Json(InstallGlobalOutput::from_exec_command(result))) -} - -#[plugin_fn] -pub fn uninstall_global( - Json(input): Json, -) -> FnResult> { - let env = get_host_environment()?; +pub fn pre_run(Json(input): Json) -> FnResult> { + let mut result = RunHookResult::default(); - let result = exec_command!( - input, - commands::uninstall_global( - &input.dependency, - get_global_prefix(&env, &input.globals_dir), - ) - ); - - Ok(Json(UninstallGlobalOutput::from_exec_command(result))) -} + let Some(globals_dir) = &input.globals_dir else { + return Ok(Json(result)); + }; -#[plugin_fn] -pub fn pre_run(Json(input): Json) -> FnResult<()> { let args = &input.passthrough_args; let config = get_tool_config::()?; - if args.len() < 3 || !config.intercept_globals || host_env!("PROTO_INSTALL_GLOBAL").is_some() { - return Ok(()); + if args.len() < 3 || !config.shared_globals_dir { + return Ok(Json(result)); } + let env = get_host_environment()?; let manager = PackageManager::detect()?; - let mut is_install_command = false; - let mut is_global = false; - - // npm install -g - // pnpm add -g - if manager == PackageManager::Npm || manager == PackageManager::Pnpm { - is_install_command = args[0] == "install" || args[0] == "i" || args[0] == "add"; - - for arg in args { - if arg == "--global" || arg == "-g" || arg == "--location=global" { - is_global = true; - break; + + // Includes trailing /bin folder + let globals_bin_dir = globals_dir + .real_path() + .unwrap() + .to_string_lossy() + .to_string(); + // Parent directory, doesn't include /bin folder + let globals_root_dir = globals_dir + .real_path() + .unwrap() + .parent() + .unwrap() + .to_string_lossy() + .to_string(); + + match manager { + // npm install|add|etc -g + PackageManager::Npm => { + let aliases = vec![ + // install + "add", + "i", + "in", + "ins", + "inst", + "insta", + "instal", + "install", + "isnt", + "isnta", + "isntal", + "isntall", + // uninstall + "r", + "remove", + "rm", + "un", + "uninstall", + "unlink", + ]; + + if aliases.iter().any(|alias| *alias == args[0]) + && args + .iter() + .any(|arg| arg == "--global" || arg == "-g" || arg == "--location=global") + && args.iter().all(|arg| arg != "--prefix") + { + result + .env + .get_or_insert(HashMap::default()) + // Unix will create a /bin directory when installing into the root, + // while Windows installs directly into the /bin directory. + .insert( + "PREFIX".into(), + if env.os == HostOS::Windows { + globals_bin_dir + } else { + globals_root_dir + }, + ); } } - } - // yarn global add - if manager == PackageManager::Yarn { - is_global = args[0] == "global"; - is_install_command = args[1] == "add"; - } + // pnpm add|update|etc -g + PackageManager::Pnpm => { + let aliases = [ + "add", "update", "remove", "list", "outdated", "why", "root", "bin", + ]; + + if aliases.iter().any(|alias| *alias == args[0]) + && args.iter().any(|arg| arg == "--global" || arg == "-g") + && args + .iter() + .all(|arg| arg != "--global-dir" && arg != "--global-bin-dir") + { + // These arguments aren't ideal, but pnpm doesn't support + // environment variables from what I've seen... + let new_args = result.args.get_or_insert(vec![]); + new_args.push("--global-dir".into()); + new_args.push(globals_root_dir); + new_args.push("--global-bin-dir".into()); + new_args.push(globals_bin_dir); + } + } - if is_install_command && is_global { - return Err(plugin_err!( - "Global binaries must be installed with proto install-global {}!\nLearn more: {}\n\nOpt-out of this functionality with {}.", - manager.to_string(), - "https://github.com/moonrepo/node-plugin#configuration", - "tools.node.intercept-globals = false", - )); - } + // yarn global add|remove|etc + PackageManager::Yarn => { + let aliases = ["add", "bin", "list", "remove", "upgrade"]; + + if args[0] == "global" + && aliases.iter().any(|alias| *alias == args[1]) + && args.iter().all(|arg| arg != "--prefix") + { + result + .env + .get_or_insert(HashMap::default()) + // Both Unix and Windows will create a /bin directory, + // when installing into the root. + .insert("PREFIX".into(), globals_root_dir); + } + } + }; - Ok(()) + Ok(Json(result)) } diff --git a/crates/node-depman/tests/globals_test.rs b/crates/node-depman/tests/globals_test.rs deleted file mode 100644 index 61b9924..0000000 --- a/crates/node-depman/tests/globals_test.rs +++ /dev/null @@ -1,21 +0,0 @@ -// These work locally but fail in CI... hard to debug! - -use proto_pdk_test_utils::*; - -mod npm { - use super::*; - - generate_globals_test!("npm-test", "prettier"); -} - -// mod pnpm { -// use super::*; - -// generate_globals_test!("pnpm-test", "prettier"); -// } - -// mod yarn { -// use super::*; - -// generate_globals_test!("yarn-test", "prettier"); -// } diff --git a/crates/node-depman/tests/hooks_test.rs b/crates/node-depman/tests/hooks_test.rs index 0ef3c19..01a7031 100644 --- a/crates/node-depman/tests/hooks_test.rs +++ b/crates/node-depman/tests/hooks_test.rs @@ -1,84 +1,152 @@ -// Importing proto_pdk crashes Windows because it contains WASM code -#[cfg(not(windows))] -mod hooks { - use proto_pdk::{RunHook, ToolContext}; - use proto_pdk_test_utils::*; - use starbase_sandbox::create_empty_sandbox; - use std::collections::HashMap; - use std::env; +use proto_pdk_api::RunHook; +use proto_pdk_test_utils::*; +use starbase_sandbox::create_empty_sandbox; +use std::collections::HashMap; +use std::path::PathBuf; + +mod pre_run { + use super::*; + + fn create_globals_dir() -> VirtualPath { + VirtualPath::WithReal { + path: PathBuf::from("/proto/tools/node/globals/bin"), + virtual_prefix: PathBuf::from("/proto"), + real_prefix: PathBuf::from("/.proto"), + } + } mod npm { use super::*; #[test] - fn does_nothing_if_no_args() { + fn does_nothing_if_not_configured() { let sandbox = create_empty_sandbox(); let plugin = create_plugin("npm-test", sandbox.path()); - plugin.pre_run(RunHook::default()); + let result = plugin.pre_run(RunHook::default()); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); } #[test] - fn skips_when_env_var_set() { + fn does_nothing_if_disabled() { let sandbox = create_empty_sandbox(); - let plugin = create_plugin("npm-test", sandbox.path()); + let plugin = create_plugin_with_config( + "npm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":false}"#.to_owned(), + )]), + ); - env::set_var("PROTO_INSTALL_GLOBAL", "1"); + let result = plugin.pre_run(RunHook::default()); - plugin.pre_run(RunHook { - passthrough_args: vec!["install".into(), "-g".into(), "typescript".into()], - context: ToolContext::default(), + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn does_nothing_if_enabled_but_no_args() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin_with_config( + "npm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); + + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + ..RunHook::default() }); - env::remove_var("PROTO_INSTALL_GLOBAL"); + assert_eq!(result.args, None); + assert_eq!(result.env, None); } #[test] - fn can_bypass_with_user_config() { + fn does_nothing_if_a_prefix_was_provided() { let sandbox = create_empty_sandbox(); let plugin = create_plugin_with_config( "npm-test", sandbox.path(), HashMap::from_iter([( "proto_tool_config".into(), - r#"{"intercept-globals":false}"#.to_owned(), + r#"{"shared-globals-dir":true}"#.to_owned(), )]), ); - plugin.pre_run(RunHook { - passthrough_args: vec!["install".into(), "-g".into(), "typescript".into()], + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec![ + "install".into(), + "-g".into(), + "typescript".into(), + "--prefix".into(), + "/some/thing".into(), + ], ..RunHook::default() }); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); } #[test] - #[should_panic(expected = "Global binaries must be installed")] - fn errors_if_installing_global() { + fn adds_env_var() { let sandbox = create_empty_sandbox(); let plugin = create_plugin_with_config( "npm-test", sandbox.path(), HashMap::from_iter([( "proto_tool_config".into(), - r#"{"intercept-globals":true}"#.to_owned(), + r#"{"shared-globals-dir":true}"#.to_owned(), )]), ); - plugin.pre_run(RunHook { + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), passthrough_args: vec!["install".into(), "-g".into(), "typescript".into()], ..RunHook::default() }); + + assert_eq!(result.args, None); + assert_eq!( + result.env, + Some(HashMap::from_iter([( + "PREFIX".into(), + if cfg!(windows) { + "/.proto/tools/node/globals/bin".into() + } else { + "/.proto/tools/node/globals".into() + } + )])) + ); } #[test] - fn doesnt_error_for_other_commands() { + fn adds_env_var_with_aliases() { let sandbox = create_empty_sandbox(); - let plugin = create_plugin("npm-test", sandbox.path()); + let plugin = create_plugin_with_config( + "npm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); - plugin.pre_run(RunHook { - passthrough_args: vec!["info".into(), "--json".into(), "typescript".into()], + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec!["add".into(), "--global".into(), "typescript".into()], ..RunHook::default() }); + + assert!(result.env.is_some()); } } @@ -86,33 +154,132 @@ mod hooks { use super::*; #[test] - #[should_panic(expected = "Global binaries must be installed")] - fn errors_if_installing_global() { + fn does_nothing_if_not_configured() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin("pnpm-test", sandbox.path()); + + let result = plugin.pre_run(RunHook::default()); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn does_nothing_if_disabled() { let sandbox = create_empty_sandbox(); let plugin = create_plugin_with_config( "pnpm-test", sandbox.path(), HashMap::from_iter([( "proto_tool_config".into(), - r#"{"intercept-globals":true}"#.to_owned(), + r#"{"shared-globals-dir":false}"#.to_owned(), )]), ); - plugin.pre_run(RunHook { - passthrough_args: vec!["add".into(), "--global".into(), "typescript".into()], + let result = plugin.pre_run(RunHook::default()); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn does_nothing_if_enabled_but_no_args() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin_with_config( + "pnpm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); + + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), ..RunHook::default() }); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); } #[test] - fn doesnt_error_for_other_commands() { + fn does_nothing_if_a_dir_was_provided() { let sandbox = create_empty_sandbox(); - let plugin = create_plugin("pnpm-test", sandbox.path()); + let plugin = create_plugin_with_config( + "pnpm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); - plugin.pre_run(RunHook { - passthrough_args: vec!["info".into(), "--json".into(), "typescript".into()], + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec![ + "add".into(), + "-g".into(), + "typescript".into(), + "--global-dir".into(), + "/some/thing".into(), + ], ..RunHook::default() }); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn adds_args() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin_with_config( + "pnpm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); + + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec!["add".into(), "-g".into(), "typescript".into()], + ..RunHook::default() + }); + + assert_eq!( + result.args.as_ref().unwrap().iter().collect::>(), + vec![ + "--global-dir", + "/.proto/tools/node/globals", + "--global-bin-dir", + "/.proto/tools/node/globals/bin" + ] + ); + assert_eq!(result.env, None); + } + + #[test] + fn adds_args_with_aliases() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin_with_config( + "pnpm-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); + + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec!["remove".into(), "--global".into(), "typescript".into()], + ..RunHook::default() + }); + + assert!(result.args.is_some()); } } @@ -120,33 +287,109 @@ mod hooks { use super::*; #[test] - #[should_panic(expected = "Global binaries must be installed")] - fn errors_if_installing_global() { + fn does_nothing_if_not_configured() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin("yarn-test", sandbox.path()); + + let result = plugin.pre_run(RunHook::default()); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn does_nothing_if_disabled() { let sandbox = create_empty_sandbox(); let plugin = create_plugin_with_config( "yarn-test", sandbox.path(), HashMap::from_iter([( "proto_tool_config".into(), - r#"{"intercept-globals":true}"#.to_owned(), + r#"{"shared-globals-dir":false}"#.to_owned(), )]), ); - plugin.pre_run(RunHook { - passthrough_args: vec!["global".into(), "add".into(), "typescript".into()], + let result = plugin.pre_run(RunHook::default()); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn does_nothing_if_enabled_but_no_args() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin_with_config( + "yarn-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); + + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), ..RunHook::default() }); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); } #[test] - fn doesnt_error_for_other_commands() { + fn does_nothing_if_a_prefix_was_provided() { let sandbox = create_empty_sandbox(); - let plugin = create_plugin("yarn-test", sandbox.path()); + let plugin = create_plugin_with_config( + "yarn-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); - plugin.pre_run(RunHook { - passthrough_args: vec!["info".into(), "--json".into(), "typescript".into()], + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec![ + "global".into(), + "add".into(), + "typescript".into(), + "--prefix".into(), + "/some/thing".into(), + ], ..RunHook::default() }); + + assert_eq!(result.args, None); + assert_eq!(result.env, None); + } + + #[test] + fn adds_env_var() { + let sandbox = create_empty_sandbox(); + let plugin = create_plugin_with_config( + "yarn-test", + sandbox.path(), + HashMap::from_iter([( + "proto_tool_config".into(), + r#"{"shared-globals-dir":true}"#.to_owned(), + )]), + ); + + let result = plugin.pre_run(RunHook { + globals_dir: Some(create_globals_dir()), + passthrough_args: vec!["global".into(), "add".into(), "typescript".into()], + ..RunHook::default() + }); + + assert_eq!(result.args, None); + assert_eq!( + result.env, + Some(HashMap::from_iter([( + "PREFIX".into(), + "/.proto/tools/node/globals".into() + )])) + ); } } } diff --git a/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-2.snap b/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-2.snap deleted file mode 100644 index 5ee69c5..0000000 --- a/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-2.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/node-depman/tests/shims_test.rs -expression: "std::fs::read_to_string(sandbox.path().join(\".proto/shims\").join(if cfg!(windows)\n {\n format!(\"{}.cmd\", \"npx\")\n } else { \"npx\".to_string() })).unwrap()" ---- -#!/usr/bin/env bash -set -e - -if [ -n "$PROTO_DEBUG" ]; then - set -x - echo "Running with npm-test.sh shim" -fi - -exec proto run npm-test --alt "npx" -- "$@" - diff --git a/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-3.snap b/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-3.snap deleted file mode 100644 index 0714ee1..0000000 --- a/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims-3.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/node-depman/tests/shims_test.rs -expression: "std::fs::read_to_string(sandbox.path().join(\".proto/shims\").join(if cfg!(windows)\n {\n format!(\"{}.cmd\", \"node-gyp\")\n } else { \"node-gyp\".to_string() })).unwrap()" ---- -#!/usr/bin/env bash -set -e - -if [ -n "$PROTO_DEBUG" ]; then - set -x - echo "Running with npm-test.sh shim" -fi - -exec proto run npm-test --alt "node-gyp" -- "$@" - diff --git a/crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims.snap b/crates/node-depman/tests/snapshots/shims_test__npm__creates_shims.snap similarity index 100% rename from crates/node-depman/tests/snapshots/shims_test__npm__creates_global_shims.snap rename to crates/node-depman/tests/snapshots/shims_test__npm__creates_shims.snap diff --git a/crates/node-depman/tests/snapshots/shims_test__pnpm__creates_global_shims-2.snap b/crates/node-depman/tests/snapshots/shims_test__pnpm__creates_global_shims-2.snap deleted file mode 100644 index 04eca6b..0000000 --- a/crates/node-depman/tests/snapshots/shims_test__pnpm__creates_global_shims-2.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/node-depman/tests/shims_test.rs -expression: "std::fs::read_to_string(sandbox.path().join(\".proto/shims\").join(if cfg!(windows)\n {\n format!(\"{}.cmd\", \"pnpx\")\n } else { \"pnpx\".to_string() })).unwrap()" ---- -#!/usr/bin/env bash -set -e - -if [ -n "$PROTO_DEBUG" ]; then - set -x - echo "Running with pnpm-test.sh shim" -fi - -exec proto run pnpm-test -- dlx "$@" - diff --git a/crates/node-depman/tests/snapshots/shims_test__pnpm__creates_global_shims.snap b/crates/node-depman/tests/snapshots/shims_test__pnpm__creates_shims.snap similarity index 100% rename from crates/node-depman/tests/snapshots/shims_test__pnpm__creates_global_shims.snap rename to crates/node-depman/tests/snapshots/shims_test__pnpm__creates_shims.snap diff --git a/crates/node-depman/tests/snapshots/shims_test__yarn__creates_global_shims-2.snap b/crates/node-depman/tests/snapshots/shims_test__yarn__creates_global_shims-2.snap deleted file mode 100644 index 1362fbe..0000000 --- a/crates/node-depman/tests/snapshots/shims_test__yarn__creates_global_shims-2.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/node-depman/tests/shims_test.rs -expression: "std::fs::read_to_string(sandbox.path().join(\".proto/shims\").join(if cfg!(windows)\n {\n format!(\"{}.cmd\", \"yarnpkg\")\n } else { \"yarnpkg\".to_string() })).unwrap()" ---- -#!/usr/bin/env bash -set -e - -if [ -n "$PROTO_DEBUG" ]; then - set -x - echo "Running with yarn-test.sh shim" -fi - -exec proto run yarn-test --alt "yarnpkg" -- "$@" - diff --git a/crates/node-depman/tests/snapshots/shims_test__yarn__creates_global_shims.snap b/crates/node-depman/tests/snapshots/shims_test__yarn__creates_shims.snap similarity index 100% rename from crates/node-depman/tests/snapshots/shims_test__yarn__creates_global_shims.snap rename to crates/node-depman/tests/snapshots/shims_test__yarn__creates_shims.snap diff --git a/crates/node-depman/tests/versions_test.rs b/crates/node-depman/tests/versions_test.rs index e931c47..dd5b027 100644 --- a/crates/node-depman/tests/versions_test.rs +++ b/crates/node-depman/tests/versions_test.rs @@ -109,7 +109,7 @@ mod pnpm { use super::*; generate_resolve_versions_tests!("pnpm-test", { - "7" => "7.33.6", + "7" => "7.33.7", "8.1" => "8.1.1", "dev" => "6.23.7-202112041634", }); @@ -199,8 +199,8 @@ mod yarn { generate_resolve_versions_tests!("yarn-test", { "1" => "1.22.21", "2" => "2.4.3", - "3" => "3.7.0", - "berry" => "4.0.2", + "3" => "3.8.0", + "berry" => "4.1.0", }); #[test] diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index 9080126..53c973f 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node_plugin" -version = "0.9.1" +version = "0.10.0" edition = "2021" license = "MIT" publish = false diff --git a/crates/node/src/proto.rs b/crates/node/src/proto.rs index de89dac..f2cf13f 100644 --- a/crates/node/src/proto.rs +++ b/crates/node/src/proto.rs @@ -1,8 +1,5 @@ use extism_pdk::*; -use node_common::{ - commands::{self, get_global_prefix}, - NodeDistLTS, NodeDistVersion, PackageJson, PluginConfig, -}; +use node_common::{NodeDistLTS, NodeDistVersion, PackageJson, PluginConfig}; use proto_pdk::*; #[host_fn] @@ -226,40 +223,6 @@ pub fn locate_executables( })) } -#[plugin_fn] -pub fn install_global( - Json(input): Json, -) -> FnResult> { - let env = get_host_environment()?; - - let result = exec_command!( - input, - commands::install_global( - &input.dependency, - get_global_prefix(&env, &input.globals_dir), - ) - ); - - Ok(Json(InstallGlobalOutput::from_exec_command(result))) -} - -#[plugin_fn] -pub fn uninstall_global( - Json(input): Json, -) -> FnResult> { - let env = get_host_environment()?; - - let result = exec_command!( - input, - commands::uninstall_global( - &input.dependency, - get_global_prefix(&env, &input.globals_dir), - ) - ); - - Ok(Json(UninstallGlobalOutput::from_exec_command(result))) -} - #[plugin_fn] pub fn post_install(Json(input): Json) -> FnResult<()> { let config = get_tool_config::()?; diff --git a/crates/node/tests/globals_test.rs b/crates/node/tests/globals_test.rs deleted file mode 100644 index 88898a0..0000000 --- a/crates/node/tests/globals_test.rs +++ /dev/null @@ -1,3 +0,0 @@ -use proto_pdk_test_utils::*; - -generate_globals_test!("node-test", "prettier"); diff --git a/crates/node/tests/snapshots/shims_test__creates_global_shims.snap b/crates/node/tests/snapshots/shims_test__creates_shims.snap similarity index 100% rename from crates/node/tests/snapshots/shims_test__creates_global_shims.snap rename to crates/node/tests/snapshots/shims_test__creates_shims.snap diff --git a/crates/node/tests/versions_test.rs b/crates/node/tests/versions_test.rs index 622c1ea..44bfedf 100644 --- a/crates/node/tests/versions_test.rs +++ b/crates/node/tests/versions_test.rs @@ -6,8 +6,8 @@ generate_resolve_versions_tests!("node-test", { "10.1" => "10.1.0", "lts-gallium" => "16.20.2", "lts/fermium" => "14.21.3", - "stable" => "20.11.0", - "node" => "21.6.1", + "stable" => "20.11.1", + "node" => "21.6.2", }); #[test] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 93c4cba..51b24ee 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] profile = "default" -channel = "1.75.0" +channel = "1.76.0"