diff --git a/.yarn/versions/27de5510.yml b/.yarn/versions/27de5510.yml new file mode 100644 index 00000000000..1f2a5d9c201 --- /dev/null +++ b/.yarn/versions/27de5510.yml @@ -0,0 +1,9 @@ +releases: + "@moonrepo/cli": patch + "@moonrepo/core-linux-arm64-gnu": patch + "@moonrepo/core-linux-arm64-musl": patch + "@moonrepo/core-linux-x64-gnu": patch + "@moonrepo/core-linux-x64-musl": patch + "@moonrepo/core-macos-arm64": patch + "@moonrepo/core-macos-x64": patch + "@moonrepo/core-windows-x64-msvc": patch diff --git a/Cargo.lock b/Cargo.lock index e5112c3c28c..24bd304222b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -322,7 +322,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -366,7 +366,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -544,28 +544,24 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cached" -version = "0.44.0" +version = "0.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b195e4fbc4b6862bbd065b991a34750399c119797efff72492f28a5864de8700" +checksum = "90eb5776f28a149524d1d8623035760b4454ec881e8cf3838fa8d7e1b11254b3" dependencies = [ - "async-trait", "cached_proc_macro", "cached_proc_macro_types", - "futures", "hashbrown 0.13.2", "instant", "once_cell", "thiserror", - "tokio", ] [[package]] name = "cached_proc_macro" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b48814962d2fd604c50d2b9433c2a41a0ab567779ee2c02f7fba6eca1221f082" +checksum = "7da8245dd5f576a41c3b76247b54c15b0e43139ceeb4f732033e15be7c005176" dependencies = [ - "cached_proc_macro_types", "darling 0.14.4", "proc-macro2", "quote", @@ -720,16 +716,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.28" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" +checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", - "time 0.1.45", "wasm-bindgen", "windows-targets 0.48.0", ] @@ -854,7 +849,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1368,7 +1363,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1390,7 +1385,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1912,7 +1907,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1988,7 +1983,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2009,7 +2004,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -2928,7 +2923,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2988,7 +2983,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.45.0", ] @@ -4415,7 +4410,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -4655,9 +4650,9 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.16.4" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a58df3e529b4c61e437c3f5041c35e4e922eccdea8b54775383d90d09aa3a7" +checksum = "d14fcbce786856785227d02edb778baeed6ecfc68f73367a72302adbee5b0b84" dependencies = [ "cached", "extism", @@ -4673,6 +4668,7 @@ dependencies = [ "serde_json", "sha2", "starbase_archive", + "starbase_events", "starbase_styles", "starbase_utils", "thiserror", @@ -4684,9 +4680,9 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.6.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20f1e58f726b5e8c8c92c567f682bdbb2b44f859a108d852a5bdcc94f8fd3452" +checksum = "33aee2bcc06bc3f8d0033e2c733e0ddaf8e1fcd141e151064ef7f73867e123cd" dependencies = [ "anyhow", "semver", @@ -4698,9 +4694,9 @@ dependencies = [ [[package]] name = "proto_wasm_plugin" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b644d1fe65ce5412cd6599a38ddc685b82a3f71a1b0254f8cded2dec52c11e" +checksum = "a377902a50bcfd6658744b43c416b18088921d6c52db0de2be0e8f7a76ec4aed" dependencies = [ "extism", "proto_pdk_api", @@ -5104,7 +5100,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -5197,7 +5193,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -5300,7 +5296,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -5456,9 +5452,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "starbase" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328b77f92b09f8788a894d063cefd3f7876f0bef776baec6946bdd2e75f24117" +checksum = "399c94c128150ef75e2ee780cc70d5aef92f5b44badc6005ac84bb8b9b6ed4a1" dependencies = [ "async-trait", "chrono", @@ -5478,9 +5474,9 @@ dependencies = [ [[package]] name = "starbase_archive" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bb40d408fb474e6d0092eba4fa977aa40c85885931c62219bb12d512e515e8" +checksum = "f85e565b134761413513c0091ed002ffb31ba448ca9542c4c41ca5968a29a9bb" dependencies = [ "flate2", "miette", @@ -5492,13 +5488,14 @@ dependencies = [ "tracing", "xz2", "zip", + "zstd 0.12.4", ] [[package]] name = "starbase_events" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6913545608418518959d13ac9e05568d0d059f53ab3a24cf3283b7958ee5e732" +checksum = "5f172a2185991dbfb2a3446c47749ade52d66d2aaea724d19bd45607527ebd9d" dependencies = [ "async-trait", "miette", @@ -5508,21 +5505,21 @@ dependencies = [ [[package]] name = "starbase_macros" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd2a77f76022474557803637dbefe72e38fa196564e9a1daf3c695c06b1ee222" +checksum = "63159597180d00c01353e4bf4d4401328a30eb618c0130adf7b9371db4df3d3a" dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] name = "starbase_sandbox" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e03cea8d1fd34d42fc47979aa670e28f276f395c70a6e446b6e68c8136dd2ae2" +checksum = "62ec8301c49429d3da1105475f4e32ce8fa7c8cf1028c4e4535b0c010be2952a" dependencies = [ "assert_cmd", "assert_fs", @@ -5536,9 +5533,9 @@ dependencies = [ [[package]] name = "starbase_styles" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bad293ee0bf20cc69aced802167871210db53994bb6dd4206d9cf48dd7517cd2" +checksum = "251a45da918b41577ab62fb764c9683a0f50fb2b8999a629dbd6c25476a9c411" dependencies = [ "dirs 5.0.1", "miette", @@ -5549,9 +5546,9 @@ dependencies = [ [[package]] name = "starbase_utils" -version = "0.2.21" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09593b70b1d477cd8f6e84c5934e13da13bc788ec9d626822f3edeaaaaaddec5" +checksum = "032493983d1aaa0e6107219e8b17e2b315452f902f0f512c8bd5af6df6704b44" dependencies = [ "dirs 5.0.1", "ec4rs", @@ -5566,6 +5563,7 @@ dependencies = [ "serde_yaml 0.9.25", "starbase_styles", "thiserror", + "tokio", "toml 0.7.6", "tracing", "wax", @@ -5650,9 +5648,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", @@ -5807,7 +5805,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -5830,17 +5828,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.3.20" @@ -5942,7 +5929,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -6048,7 +6035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" dependencies = [ "crossbeam-channel", - "time 0.3.20", + "time", "tracing-subscriber", ] @@ -6394,9 +6381,9 @@ dependencies = [ [[package]] name = "warpgate" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef3766f024730109e7479aab34a33ca7cddba42c867ae282b9722210e17ee0a" +checksum = "37e105ab7fd178b2fc6b59439046418278b478e761549658a41eb48c97a9944a" dependencies = [ "extism", "miette", @@ -6424,12 +6411,6 @@ dependencies = [ "serde", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -6662,7 +6643,7 @@ dependencies = [ "sha2", "toml 0.5.11", "windows-sys 0.48.0", - "zstd", + "zstd 0.11.2+zstd.1.5.2", ] [[package]] @@ -7346,7 +7327,16 @@ version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ - "zstd-safe", + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", ] [[package]] @@ -7359,6 +7349,16 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-sys" version = "2.0.7+zstd.1.5.4" diff --git a/Cargo.toml b/Cargo.toml index b062aeffe6b..b826f5003b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default-members = ["crates/cli"] [workspace.dependencies] async-trait = "0.1.73" -cached = "0.44.0" +cached = "0.45.1" chrono = { version = "0.4.28", features = ["serde"] } ci_env = "0.2.0" clap = { version = "4.4.2", features = ["derive", "env", "wrap_help"] } @@ -38,7 +38,7 @@ pathdiff = "0.2.1" petgraph = { version = "0.6.4", default-features = false, features = [ "serde-1", ] } -proto_core = "0.16.4" +proto_core = "0.17.3" relative-path = { version = "1.9.0", features = ["serde"] } regex = "1.9.5" # We don't use openssl but its required for musl builds @@ -56,14 +56,14 @@ semver = "1.0.18" serde = { version = "1.0.188", features = ["derive", "rc"] } serde_json = "1.0.105" serde_yaml = "0.9.25" -starbase = "0.2.5" -starbase_archive = { version = "0.2.0", default-features = false, features = [ +starbase = "0.2.6" +starbase_archive = { version = "0.2.2", default-features = false, features = [ "tar-gz", ] } -starbase_events = "0.2.0" -starbase_sandbox = "0.1.8" -starbase_styles = { version = "0.1.13", features = ["relative-path"] } -starbase_utils = { version = "0.2.21", default-features = false, features = [ +starbase_events = "0.2.1" +starbase_sandbox = "0.1.10" +starbase_styles = { version = "0.1.15", features = ["relative-path"] } +starbase_utils = { version = "0.3.1", default-features = false, features = [ "editor-config", "glob", "json", diff --git a/crates/core/action-pipeline/src/actions/setup_tool.rs b/crates/core/action-pipeline/src/actions/setup_tool.rs index d48776cf876..e6f9cf0d11f 100644 --- a/crates/core/action-pipeline/src/actions/setup_tool.rs +++ b/crates/core/action-pipeline/src/actions/setup_tool.rs @@ -49,12 +49,7 @@ pub async fn setup_tool( // Install and setup the specific tool + version in the toolchain! let installed_count = PlatformManager::write() .get_mut(runtime)? - .setup_tool( - &context, - runtime, - &mut state.data.last_versions, - &workspace.plugin_loader, - ) + .setup_tool(&context, runtime, &mut state.data.last_versions) .await?; // Update the cache with the timestamp diff --git a/crates/core/moon/src/lib.rs b/crates/core/moon/src/lib.rs index 60885b30906..d25cf79700b 100644 --- a/crates/core/moon/src/lib.rs +++ b/crates/core/moon/src/lib.rs @@ -81,6 +81,7 @@ pub async fn load_workspace_from(path: &Path) -> miette::Result { deno_config, &workspace.toolchain_config.typescript, &workspace.root, + Arc::clone(&workspace.proto_env), )), ); } @@ -92,6 +93,7 @@ pub async fn load_workspace_from(path: &Path) -> miette::Result { node_config, &workspace.toolchain_config.typescript, &workspace.root, + Arc::clone(&workspace.proto_env), )), ); } @@ -99,7 +101,11 @@ pub async fn load_workspace_from(path: &Path) -> miette::Result { if let Some(rust_config) = &workspace.toolchain_config.rust { registry.register( PlatformType::Rust, - Box::new(RustPlatform::new(rust_config, &workspace.root)), + Box::new(RustPlatform::new( + rust_config, + &workspace.root, + Arc::clone(&workspace.proto_env), + )), ); } @@ -115,7 +121,7 @@ pub async fn load_workspace_with_toolchain() -> miette::Result { let workspace = load_workspace().await?; for platform in PlatformManager::write().list_mut() { - platform.setup_toolchain(&workspace.plugin_loader).await?; + platform.setup_toolchain().await?; } Ok(workspace) diff --git a/crates/core/platform/src/platform.rs b/crates/core/platform/src/platform.rs index 403b57f5ce0..cb18d1a5341 100644 --- a/crates/core/platform/src/platform.rs +++ b/crates/core/platform/src/platform.rs @@ -11,7 +11,6 @@ use moon_process::Command; use moon_project::Project; use moon_task::Task; use moon_tool::Tool; -use proto_core::PluginLoader; use rustc_hash::FxHashMap; use std::collections::BTreeMap; use std::path::Path; @@ -86,7 +85,7 @@ pub trait Platform: Send + Sync { /// Setup the top-level tool in the toolchain if applicable. /// This is a one off flow, as most flows will be using the pipeline. - async fn setup_toolchain(&mut self, plugin_loader: &PluginLoader) -> miette::Result<()> { + async fn setup_toolchain(&mut self) -> miette::Result<()> { Ok(()) } @@ -105,7 +104,6 @@ pub trait Platform: Send + Sync { context: &ActionContext, runtime: &Runtime, last_versions: &mut FxHashMap, - plugin_loader: &PluginLoader, ) -> miette::Result { Ok(0) } diff --git a/crates/core/runner/src/runner.rs b/crates/core/runner/src/runner.rs index 82d72dd7a8c..04bde98059a 100644 --- a/crates/core/runner/src/runner.rs +++ b/crates/core/runner/src/runner.rs @@ -329,7 +329,7 @@ impl<'a> Runner<'a> { env_vars.insert("MOON_TARGET".to_owned(), self.task.target.id.to_string()); env_vars.insert( "MOON_TOOLCHAIN_DIR".to_owned(), - path::to_string(&self.workspace.toolchain_root)?, + path::to_string(&self.workspace.proto_env.root)?, ); env_vars.insert( "MOON_WORKSPACE_ROOT".to_owned(), diff --git a/crates/core/tool/src/lib.rs b/crates/core/tool/src/lib.rs index aeef5ec36a1..90b6414654b 100644 --- a/crates/core/tool/src/lib.rs +++ b/crates/core/tool/src/lib.rs @@ -8,8 +8,8 @@ pub use manager::*; pub use tool::*; use proto_core::{ - inject_default_manifest_config, Id, PluginLoader, PluginLocator, ProtoEnvironment, - Tool as ProtoTool, UserConfig, Wasm, + inject_default_manifest_config, Id, PluginLocator, ProtoEnvironment, Tool as ProtoTool, + UserConfig, Wasm, }; use std::env; use std::path::Path; @@ -31,11 +31,10 @@ pub async fn load_tool_plugin( id: &Id, proto: &ProtoEnvironment, locator: &PluginLocator, - loader: &PluginLoader, ) -> miette::Result { let mut manifest = ProtoTool::create_plugin_manifest( proto, - Wasm::file(loader.load_plugin(id, locator).await?), + Wasm::file(proto.get_plugin_loader().load_plugin(id, locator).await?), )?; let user_config = UserConfig::load()?; diff --git a/crates/core/workspace/src/workspace.rs b/crates/core/workspace/src/workspace.rs index 73b6e9e9928..0dd88ba0ab3 100644 --- a/crates/core/workspace/src/workspace.rs +++ b/crates/core/workspace/src/workspace.rs @@ -6,7 +6,7 @@ use moon_config::{InheritedTasksConfig, InheritedTasksManager, ToolchainConfig, use moon_hash::HashEngine; use moon_utils::semver; use moon_vcs::{BoxedVcs, Git}; -use proto_core::{get_proto_home, PluginLoader, ToolsConfig, TOOLS_CONFIG_NAME}; +use proto_core::{ProtoEnvironment, ToolsConfig, TOOLS_CONFIG_NAME}; use starbase::Resource; use starbase_styles::color; use starbase_utils::{dirs, fs, glob}; @@ -149,7 +149,7 @@ pub struct Workspace { pub hash_engine: Arc, /// The plugin loader. - pub plugin_loader: Arc, + pub proto_env: Arc, /// Proto tools loaded from ".prototools". pub proto_tools: Arc, @@ -166,9 +166,6 @@ pub struct Workspace { /// Toolchain configuration loaded from ".moon/toolchain.yml". pub toolchain_config: ToolchainConfig, - /// The root of the toolchain, typically "~/.proto". - pub toolchain_root: PathBuf, - /// Configured version control system. pub vcs: Arc, @@ -190,6 +187,7 @@ impl Workspace { ); // Load proto tools + let proto_env = ProtoEnvironment::new()?; let mut proto_tools = ToolsConfig::load(root_dir.join(TOOLS_CONFIG_NAME))?; proto_tools.inherit_builtin_plugins(); @@ -219,22 +217,16 @@ impl Workspace { &config.vcs.remote_candidates, )?; - let toolchain_root = get_proto_home()?; - let mut plugin_loader = - PluginLoader::new(toolchain_root.join("plugins"), toolchain_root.join("temp")); - plugin_loader.set_seed(env::var("MOON_VERSION").unwrap_or_default().as_str()); - Ok(Workspace { cache_engine: Arc::new(cache_engine), config, hash_engine: Arc::new(hash_engine), - plugin_loader: Arc::new(plugin_loader), + proto_env: Arc::new(proto_env), proto_tools: Arc::new(proto_tools), root: root_dir, session: None, tasks_config: Arc::new(tasks_config), toolchain_config, - toolchain_root, vcs: Arc::new(Box::new(vcs)), working_dir: working_dir.to_owned(), }) diff --git a/crates/deno/platform/src/platform.rs b/crates/deno/platform/src/platform.rs index 463cc58ecc6..0cce5dce90a 100644 --- a/crates/deno/platform/src/platform.rs +++ b/crates/deno/platform/src/platform.rs @@ -19,7 +19,7 @@ use moon_terminal::{print_checkpoint, Checkpoint}; use moon_tool::{Tool, ToolManager}; use moon_typescript_platform::TypeScriptTargetHash; use moon_utils::async_trait; -use proto_core::{hash_file_contents, PluginLoader, ProtoEnvironment}; +use proto_core::{hash_file_contents, ProtoEnvironment}; use rustc_hash::FxHashMap; use std::sync::Arc; use std::{ @@ -32,6 +32,8 @@ const LOG_TARGET: &str = "moon:deno-platform"; pub struct DenoPlatform { config: DenoConfig, + proto_env: Arc, + toolchain: ToolManager, typescript_config: Option, @@ -44,9 +46,11 @@ impl DenoPlatform { config: &DenoConfig, typescript_config: &Option, workspace_root: &Path, + proto_env: Arc, ) -> Self { DenoPlatform { config: config.to_owned(), + proto_env, toolchain: ToolManager::new(Runtime::Deno(Version::new_global())), typescript_config: typescript_config.to_owned(), workspace_root: workspace_root.to_path_buf(), @@ -113,7 +117,7 @@ impl Platform for DenoPlatform { ))) } - async fn setup_toolchain(&mut self, _plugin_loader: &PluginLoader) -> miette::Result<()> { + async fn setup_toolchain(&mut self) -> miette::Result<()> { // let version = match &self.config.version { // Some(v) => Version::new(v), // None => Version::new_global(), @@ -125,7 +129,7 @@ impl Platform for DenoPlatform { if !self.toolchain.has(&version) { self.toolchain.register( &version, - DenoTool::new(&ProtoEnvironment::new()?, &self.config, &version)?, + DenoTool::new(&self.proto_env, &self.config, &version)?, ); } @@ -147,14 +151,13 @@ impl Platform for DenoPlatform { _context: &ActionContext, runtime: &Runtime, last_versions: &mut FxHashMap, - _plugin_loader: &PluginLoader, ) -> miette::Result { let version = runtime.version(); if !self.toolchain.has(&version) { self.toolchain.register( &version, - DenoTool::new(&ProtoEnvironment::new()?, &self.config, &version)?, + DenoTool::new(&self.proto_env, &self.config, &version)?, ); } diff --git a/crates/node/platform/src/platform.rs b/crates/node/platform/src/platform.rs index 1e3246020d7..88ba76a74fa 100644 --- a/crates/node/platform/src/platform.rs +++ b/crates/node/platform/src/platform.rs @@ -19,7 +19,7 @@ use moon_task::Task; use moon_tool::{Tool, ToolManager}; use moon_typescript_platform::TypeScriptTargetHash; use moon_utils::async_trait; -use proto_core::{PluginLoader, ProtoEnvironment}; +use proto_core::ProtoEnvironment; use rustc_hash::FxHashMap; use starbase_styles::color; use starbase_utils::glob::GlobSet; @@ -34,6 +34,8 @@ pub struct NodePlatform { package_names: FxHashMap, + proto_env: Arc, + toolchain: ToolManager, typescript_config: Option, @@ -46,10 +48,12 @@ impl NodePlatform { config: &NodeConfig, typescript_config: &Option, workspace_root: &Path, + proto_env: Arc, ) -> Self { NodePlatform { config: config.to_owned(), package_names: FxHashMap::default(), + proto_env, toolchain: ToolManager::new(Runtime::Node(Version::new_global())), typescript_config: typescript_config.to_owned(), workspace_root: workspace_root.to_path_buf(), @@ -263,7 +267,7 @@ impl Platform for NodePlatform { ))) } - async fn setup_toolchain(&mut self, plugin_loader: &PluginLoader) -> miette::Result<()> { + async fn setup_toolchain(&mut self) -> miette::Result<()> { let version = match &self.config.version { Some(v) => Version::new(v), None => Version::new_global(), @@ -274,13 +278,7 @@ impl Platform for NodePlatform { if !self.toolchain.has(&version) { self.toolchain.register( &version, - NodeTool::new( - &ProtoEnvironment::new()?, - &self.config, - &version, - plugin_loader, - ) - .await?, + NodeTool::new(&self.proto_env, &self.config, &version).await?, ); } @@ -302,20 +300,13 @@ impl Platform for NodePlatform { _context: &ActionContext, runtime: &Runtime, last_versions: &mut FxHashMap, - plugin_loader: &PluginLoader, ) -> miette::Result { let version = runtime.version(); if !self.toolchain.has(&version) { self.toolchain.register( &version, - NodeTool::new( - &ProtoEnvironment::new()?, - &self.config, - &version, - plugin_loader, - ) - .await?, + NodeTool::new(&self.proto_env, &self.config, &version).await?, ); } diff --git a/crates/node/tool/src/node_tool.rs b/crates/node/tool/src/node_tool.rs index 43d24cec5e4..241a8ebc3da 100644 --- a/crates/node/tool/src/node_tool.rs +++ b/crates/node/tool/src/node_tool.rs @@ -10,7 +10,7 @@ use moon_terminal::{print_checkpoint, Checkpoint}; use moon_tool::{ async_trait, get_path_env_var, load_tool_plugin, DependencyManager, Tool, ToolError, }; -use proto_core::{Id, PluginLoader, ProtoEnvironment, Tool as ProtoTool, VersionType}; +use proto_core::{Id, ProtoEnvironment, Tool as ProtoTool, UnresolvedVersionSpec}; use rustc_hash::FxHashMap; use std::path::{Path, PathBuf}; @@ -33,18 +33,12 @@ impl NodeTool { proto: &ProtoEnvironment, config: &NodeConfig, version: &Version, - plugin_loader: &PluginLoader, ) -> miette::Result { let mut node = NodeTool { global: false, config: config.to_owned(), - tool: load_tool_plugin( - &Id::raw("node"), - proto, - config.plugin.as_ref().unwrap(), - plugin_loader, - ) - .await?, + tool: load_tool_plugin(&Id::raw("node"), proto, config.plugin.as_ref().unwrap()) + .await?, npm: None, pnpm: None, yarn: None, @@ -59,13 +53,13 @@ impl NodeTool { match config.package_manager { NodePackageManager::Npm => { - node.npm = Some(NpmTool::new(proto, &config.npm, plugin_loader).await?); + node.npm = Some(NpmTool::new(proto, &config.npm).await?); } NodePackageManager::Pnpm => { - node.pnpm = Some(PnpmTool::new(proto, &config.pnpm, plugin_loader).await?); + node.pnpm = Some(PnpmTool::new(proto, &config.pnpm).await?); } NodePackageManager::Yarn => { - node.yarn = Some(YarnTool::new(proto, &config.yarn, plugin_loader).await?); + node.yarn = Some(YarnTool::new(proto, &config.yarn).await?); } }; @@ -167,7 +161,7 @@ impl Tool for NodeTool { // Don't abort early, as we need to setup package managers below if let Some(version) = &self.config.version { - let version_type = VersionType::parse(version)?; + let version_type = UnresolvedVersionSpec::parse(version)?; if self.tool.is_setup(&version_type).await? { debug!("Node.js has already been setup"); diff --git a/crates/node/tool/src/npm_tool.rs b/crates/node/tool/src/npm_tool.rs index aa3ae55cea2..11560d32c91 100644 --- a/crates/node/tool/src/npm_tool.rs +++ b/crates/node/tool/src/npm_tool.rs @@ -6,7 +6,7 @@ use moon_process::Command; use moon_terminal::{print_checkpoint, Checkpoint}; use moon_tool::{async_trait, get_path_env_var, load_tool_plugin, DependencyManager, Tool}; use moon_utils::is_ci; -use proto_core::{Id, PluginLoader, ProtoEnvironment, Tool as ProtoTool, VersionType}; +use proto_core::{Id, ProtoEnvironment, Tool as ProtoTool, UnresolvedVersionSpec}; use rustc_hash::FxHashMap; use starbase_utils::fs; use std::env; @@ -21,21 +21,11 @@ pub struct NpmTool { } impl NpmTool { - pub async fn new( - proto: &ProtoEnvironment, - config: &NpmConfig, - plugin_loader: &PluginLoader, - ) -> miette::Result { + pub async fn new(proto: &ProtoEnvironment, config: &NpmConfig) -> miette::Result { Ok(NpmTool { global: config.version.is_none(), config: config.to_owned(), - tool: load_tool_plugin( - &Id::raw("npm"), - proto, - config.plugin.as_ref().unwrap(), - plugin_loader, - ) - .await?, + tool: load_tool_plugin(&Id::raw("npm"), proto, config.plugin.as_ref().unwrap()).await?, }) } } @@ -66,7 +56,7 @@ impl Tool for NpmTool { return Ok(count); }; - let version_type = VersionType::parse(&version)?; + let version_type = UnresolvedVersionSpec::parse(&version)?; if self.tool.is_setup(&version_type).await? { self.tool.locate_globals_dir().await?; diff --git a/crates/node/tool/src/pnpm_tool.rs b/crates/node/tool/src/pnpm_tool.rs index b015b71cf21..40d35fe011d 100644 --- a/crates/node/tool/src/pnpm_tool.rs +++ b/crates/node/tool/src/pnpm_tool.rs @@ -6,7 +6,7 @@ use moon_process::Command; use moon_terminal::{print_checkpoint, Checkpoint}; use moon_tool::{async_trait, get_path_env_var, load_tool_plugin, DependencyManager, Tool}; use moon_utils::{is_ci, semver}; -use proto_core::{Id, PluginLoader, ProtoEnvironment, Tool as ProtoTool, VersionType}; +use proto_core::{Id, ProtoEnvironment, Tool as ProtoTool, UnresolvedVersionSpec}; use rustc_hash::FxHashMap; use starbase_utils::fs; use std::env; @@ -24,19 +24,13 @@ impl PnpmTool { pub async fn new( proto: &ProtoEnvironment, config: &Option, - plugin_loader: &PluginLoader, ) -> miette::Result { let config = config.to_owned().unwrap_or_default(); Ok(PnpmTool { global: config.version.is_none(), - tool: load_tool_plugin( - &Id::raw("pnpm"), - proto, - config.plugin.as_ref().unwrap(), - plugin_loader, - ) - .await?, + tool: load_tool_plugin(&Id::raw("pnpm"), proto, config.plugin.as_ref().unwrap()) + .await?, config, }) } @@ -68,7 +62,7 @@ impl Tool for PnpmTool { return Ok(count); }; - let version_type = VersionType::parse(&version)?; + let version_type = UnresolvedVersionSpec::parse(&version)?; if self.tool.is_setup(&version_type).await? { self.tool.locate_globals_dir().await?; diff --git a/crates/node/tool/src/yarn_tool.rs b/crates/node/tool/src/yarn_tool.rs index e979f804c93..0853f0a872a 100644 --- a/crates/node/tool/src/yarn_tool.rs +++ b/crates/node/tool/src/yarn_tool.rs @@ -8,7 +8,7 @@ use moon_tool::{ async_trait, get_path_env_var, load_tool_plugin, DependencyManager, Tool, ToolError, }; use moon_utils::{get_workspace_root, is_ci}; -use proto_core::{Id, PluginLoader, ProtoEnvironment, Tool as ProtoTool, VersionType}; +use proto_core::{Id, ProtoEnvironment, Tool as ProtoTool, UnresolvedVersionSpec}; use rustc_hash::FxHashMap; use starbase_styles::color; use starbase_utils::fs; @@ -27,19 +27,13 @@ impl YarnTool { pub async fn new( proto: &ProtoEnvironment, config: &Option, - plugin_loader: &PluginLoader, ) -> miette::Result { let config = config.to_owned().unwrap_or_default(); Ok(YarnTool { global: config.version.is_none(), - tool: load_tool_plugin( - &Id::raw("yarn"), - proto, - config.plugin.as_ref().unwrap(), - plugin_loader, - ) - .await?, + tool: load_tool_plugin(&Id::raw("yarn"), proto, config.plugin.as_ref().unwrap()) + .await?, config, }) } @@ -116,7 +110,7 @@ impl Tool for YarnTool { return Ok(count); }; - let version_type = VersionType::parse(&version)?; + let version_type = UnresolvedVersionSpec::parse(&version)?; if self.tool.is_setup(&version_type).await? { self.tool.locate_globals_dir().await?; diff --git a/crates/rust/platform/src/rust_platform.rs b/crates/rust/platform/src/rust_platform.rs index b1f16509b68..9979a14b87c 100644 --- a/crates/rust/platform/src/rust_platform.rs +++ b/crates/rust/platform/src/rust_platform.rs @@ -23,7 +23,7 @@ use moon_task::Task; use moon_terminal::{print_checkpoint, Checkpoint}; use moon_tool::{Tool, ToolError, ToolManager}; use moon_utils::async_trait; -use proto_core::{PluginLoader, ProtoEnvironment}; +use proto_core::ProtoEnvironment; use rustc_hash::FxHashMap; use starbase_styles::color; use starbase_utils::{fs, glob::GlobSet}; @@ -38,6 +38,8 @@ const LOG_TARGET: &str = "moon:rust-platform"; pub struct RustPlatform { pub config: RustConfig, + proto_env: Arc, + toolchain: ToolManager, #[allow(dead_code)] @@ -45,9 +47,14 @@ pub struct RustPlatform { } impl RustPlatform { - pub fn new(config: &RustConfig, workspace_root: &Path) -> Self { + pub fn new( + config: &RustConfig, + workspace_root: &Path, + proto_env: Arc, + ) -> Self { RustPlatform { config: config.to_owned(), + proto_env, toolchain: ToolManager::new(Runtime::Rust(Version::new_global())), workspace_root: workspace_root.to_path_buf(), } @@ -158,7 +165,7 @@ impl Platform for RustPlatform { Ok(Some((CARGO.lockfile.to_owned(), CARGO.manifest.to_owned()))) } - async fn setup_toolchain(&mut self, plugin_loader: &PluginLoader) -> miette::Result<()> { + async fn setup_toolchain(&mut self) -> miette::Result<()> { let version = match &self.config.version { Some(v) => Version::new(v), None => Version::new_global(), @@ -169,13 +176,7 @@ impl Platform for RustPlatform { if !self.toolchain.has(&version) { self.toolchain.register( &version, - RustTool::new( - &ProtoEnvironment::new()?, - &self.config, - &version, - plugin_loader, - ) - .await?, + RustTool::new(&self.proto_env, &self.config, &version).await?, ); } @@ -197,20 +198,13 @@ impl Platform for RustPlatform { _context: &ActionContext, runtime: &Runtime, last_versions: &mut FxHashMap, - plugin_loader: &PluginLoader, ) -> miette::Result { let version = runtime.version(); if !self.toolchain.has(&version) { self.toolchain.register( &version, - RustTool::new( - &ProtoEnvironment::new()?, - &self.config, - &version, - plugin_loader, - ) - .await?, + RustTool::new(&self.proto_env, &self.config, &version).await?, ); } diff --git a/crates/rust/platform/tests/rust_platform_test.rs b/crates/rust/platform/tests/rust_platform_test.rs index e4614d052e3..9b814210a52 100644 --- a/crates/rust/platform/tests/rust_platform_test.rs +++ b/crates/rust/platform/tests/rust_platform_test.rs @@ -7,13 +7,19 @@ use moon_rust_platform::RustPlatform; use moon_task::Task; use moon_test_utils::create_sandbox; use moon_utils::string_vec; +use proto_core::ProtoEnvironment; use rustc_hash::FxHashMap; use std::env; use std::fs; use std::path::PathBuf; +use std::sync::Arc; fn create_platform() -> RustPlatform { - RustPlatform::new(&RustConfig::default(), &PathBuf::new()) + RustPlatform::new( + &RustConfig::default(), + &PathBuf::new(), + Arc::new(ProtoEnvironment::new().unwrap()), + ) } fn create_task() -> Task { diff --git a/crates/rust/tool/src/rust_tool.rs b/crates/rust/tool/src/rust_tool.rs index ba5bff04a6f..7854d5aef52 100644 --- a/crates/rust/tool/src/rust_tool.rs +++ b/crates/rust/tool/src/rust_tool.rs @@ -4,7 +4,7 @@ use moon_platform_runtime::Version; use moon_process::Command; use moon_terminal::{print_checkpoint, Checkpoint}; use moon_tool::{async_trait, load_tool_plugin, Tool}; -use proto_core::{Id, PluginLoader, ProtoEnvironment, Tool as ProtoTool, VersionType}; +use proto_core::{Id, ProtoEnvironment, Tool as ProtoTool, UnresolvedVersionSpec}; use rustc_hash::FxHashMap; use std::{ ffi::OsStr, @@ -24,18 +24,12 @@ impl RustTool { proto: &ProtoEnvironment, config: &RustConfig, version: &Version, - plugin_loader: &PluginLoader, ) -> miette::Result { let mut rust = RustTool { config: config.to_owned(), global: false, - tool: load_tool_plugin( - &Id::raw("rust"), - proto, - config.plugin.as_ref().unwrap(), - plugin_loader, - ) - .await?, + tool: load_tool_plugin(&Id::raw("rust"), proto, config.plugin.as_ref().unwrap()) + .await?, }; if version.is_global() { @@ -81,7 +75,7 @@ impl Tool for RustTool { return Ok(installed); }; - let version_type = VersionType::parse(version)?; + let version_type = UnresolvedVersionSpec::parse(version)?; if self.tool.is_setup(&version_type).await? { debug!("Rust has already been setup"); diff --git a/nextgen/config/tests/toolchain_config_test.rs b/nextgen/config/tests/toolchain_config_test.rs index e9e5e7a992e..18c9932a7d5 100644 --- a/nextgen/config/tests/toolchain_config_test.rs +++ b/nextgen/config/tests/toolchain_config_test.rs @@ -1,7 +1,7 @@ mod utils; use moon_config::{BinConfig, BinEntry, NodePackageManager, ToolchainConfig}; -use proto_core::{AliasOrVersion, Id, PluginLocator, ToolsConfig}; +use proto_core::{Id, PluginLocator, ToolsConfig, UnresolvedVersionSpec}; use starbase_sandbox::create_sandbox; use std::env; use utils::*; @@ -138,9 +138,10 @@ deno: fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("deno"), AliasOrVersion::parse("1.30.0").unwrap()); + proto.tools.insert( + Id::raw("deno"), + UnresolvedVersionSpec::parse("1.30.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }); @@ -204,9 +205,10 @@ node: fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("node"), AliasOrVersion::parse("18.0.0").unwrap()); + proto.tools.insert( + Id::raw("node"), + UnresolvedVersionSpec::parse("18.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }); @@ -242,9 +244,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("node"), AliasOrVersion::parse("18.0.0").unwrap()); + proto.tools.insert( + Id::raw("node"), + UnresolvedVersionSpec::parse("18.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -279,9 +282,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("node"), AliasOrVersion::parse("18.0.0").unwrap()); + proto.tools.insert( + Id::raw("node"), + UnresolvedVersionSpec::parse("18.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -306,9 +310,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("npm"), AliasOrVersion::parse("8.0.0").unwrap()); + proto.tools.insert( + Id::raw("npm"), + UnresolvedVersionSpec::parse("8.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -347,9 +352,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("npm"), AliasOrVersion::parse("8.0.0").unwrap()); + proto.tools.insert( + Id::raw("npm"), + UnresolvedVersionSpec::parse("8.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -439,9 +445,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("pnpm"), AliasOrVersion::parse("8.0.0").unwrap()); + proto.tools.insert( + Id::raw("pnpm"), + UnresolvedVersionSpec::parse("8.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -463,9 +470,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("pnpm"), AliasOrVersion::parse("8.0.0").unwrap()); + proto.tools.insert( + Id::raw("pnpm"), + UnresolvedVersionSpec::parse("8.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -558,9 +566,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("yarn"), AliasOrVersion::parse("8.0.0").unwrap()); + proto.tools.insert( + Id::raw("yarn"), + UnresolvedVersionSpec::parse("8.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -582,9 +591,10 @@ node: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("yarn"), AliasOrVersion::parse("8.0.0").unwrap()); + proto.tools.insert( + Id::raw("yarn"), + UnresolvedVersionSpec::parse("8.0.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -675,9 +685,10 @@ rust: fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("rust"), AliasOrVersion::parse("1.69.0").unwrap()); + proto.tools.insert( + Id::raw("rust"), + UnresolvedVersionSpec::parse("1.69.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }); @@ -713,9 +724,10 @@ rust: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("rust"), AliasOrVersion::parse("1.69.0").unwrap()); + proto.tools.insert( + Id::raw("rust"), + UnresolvedVersionSpec::parse("1.69.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -750,9 +762,10 @@ rust: ", |path| { let mut proto = ToolsConfig::default(); - proto - .tools - .insert(Id::raw("rust"), AliasOrVersion::parse("1.65.0").unwrap()); + proto.tools.insert( + Id::raw("rust"), + UnresolvedVersionSpec::parse("1.65.0").unwrap(), + ); ToolchainConfig::load_from(path, &proto) }, @@ -803,7 +816,7 @@ typescript: let mut proto = ToolsConfig::default(); proto.tools.insert( Id::raw("typescript"), - AliasOrVersion::parse("5.0.0").unwrap(), + UnresolvedVersionSpec::parse("5.0.0").unwrap(), ); ToolchainConfig::load_from(path, &proto) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 42878d5aebe..7bebedca97b 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +#### ⚙️ Internal + +- Updated to proto v0.17. + ## 1.13.3 #### 🐞 Fixes diff --git a/website/blog/2023-09-11_proto-v0.17.mdx b/website/blog/2023-09-11_proto-v0.17.mdx new file mode 100644 index 00000000000..3ed7daf206f --- /dev/null +++ b/website/blog/2023-09-11_proto-v0.17.mdx @@ -0,0 +1,84 @@ +--- +slug: proto-v0.17 +title: proto v0.17 - Experimental Python support and canary releases +authors: [milesj] +tags: [proto, plugin, tool, canary, python] +image: ./img/proto/v0.17.png +--- + +This release implements two long requested features, Python language support and canary releases. + + + +## Experimental Python support + +It's been quite a while since we've introduced a new language into proto, and we're excited to +announce the highly requested language, Python! Since Python is now an +[officially supported language](https://github.com/moonrepo/python-plugin), installing Python (and +pip) is as simple as: + +```shell +$ proto install python +``` + +However, we're marking language support as experimental for the time being. We expect our +implementation to work for modern Python versions, but may not work for older versions, especially +Python 2. The reasons for this are as follows: + +- proto will install pre-built binaries from + [indygreg/python-build-standalone](https://github.com/indygreg/python-build-standalone). This is + an unofficial project, and _does not_ support all Python versions. +- If [`python-build`](https://github.com/pyenv/pyenv/blob/master/plugins/python-build/README.md) is + available, we'll attempt to use it to build + install Python. This currently requires `pyenv` to + be installed, and _does not_ work on Windows. +- Furthermore, we only support `cpython` at the moment, and do not support `pypy`, `jython`, or + other Python implementations. It's unknown whether this functionality should be in the core Python + plugin, or another plugin entirely. + +In a future proto version, we want to support a true "build from source" approach for all tools. +Once that functionality has landed, we can properly support Python on all platforms, but until then, +let us know how this works for you! + +## Install canary releases + +A canary release is a mechanism for rolling out new features and changes to a small subset of users, +without it being an official release on an official channel. This allows users to opt-in and test +functionality if they so choose. Canary releases are not meant to be used in production, and may +contain bugs or breaking changes. A canary is similar to a nightly (or weekly) release, depending on +the tool. + +We now support this workflow in proto. To install a canary release, simply use the +[`--canary` flag when installing a tool](/docs/proto/commands/install): + +```shell +$ proto install --canary +``` + +This will install the latest canary release to `~/.proto/tools//canary`, and _only_ the latest +release can be used. Re-installing with `--canary` will overwrite the previous canary installation. + +However, because we [detect a version to run with at runtime](/docs/proto/detection), how should you +actually run canary? The easiest way is to prefix the shim with an environment variable: + +```shell +$ PROTO_BUN_VERSION=canary bun ./index.ts +``` + +Or to explicitly configure the version in [`.prototools`](/docs/proto/config): + +```toml +bun = "canary" +``` + +## Other changes + +View the [official release](https://github.com/moonrepo/proto/releases/tag/v0.17.0) for a full list +of changes. + +- Added colors to command line `--help` menus. +- Updated the following locations to support partial versions and aliases: + - Tool versions in `.prototools`. + - Pinning a default version with `proto install --pin`. + - Setting global version with `proto global`. + - Setting local version with `proto local`. +- Node, npm, pnpm, and yarn will again extract a version from `package.json` engines. diff --git a/website/blog/img/proto/v0.17.png b/website/blog/img/proto/v0.17.png new file mode 100644 index 00000000000..115d1caea37 Binary files /dev/null and b/website/blog/img/proto/v0.17.png differ diff --git a/website/docs/proto/commands/global.mdx b/website/docs/proto/commands/global.mdx index d41d42c6341..86ffce85926 100644 --- a/website/docs/proto/commands/global.mdx +++ b/website/docs/proto/commands/global.mdx @@ -7,7 +7,7 @@ tool, by pinning the version in `~/.proto/tools//manifest.json`. This vers when attempting to [detect a version](../detection). ```shell -$ proto global go 1.20.1 +$ proto global go 1.20 ``` ### Arguments diff --git a/website/docs/proto/commands/install.mdx b/website/docs/proto/commands/install.mdx index b30867b2dcd..a0fb90c9ca7 100644 --- a/website/docs/proto/commands/install.mdx +++ b/website/docs/proto/commands/install.mdx @@ -7,10 +7,12 @@ their archive to `~/.proto/tools/`. If the tool has already been installed exit early. The command is also smart enough to resolve partial versions, so 1, 1.2, and 1.2.3 are all -acceptable. It even supports aliases when applicable, like `latest`, `next`, `beta`, etc. +acceptable. It even supports aliases when applicable, like `latest`, `next`, `beta`, etc. To install +a canary release, use `--canary`. ```shell $ proto install deno 1.31 +$ proto install deno --canary ``` Some tools run [post-install hooks](../tools) that support arbitrary arguments that can be passed @@ -28,4 +30,5 @@ $ proto install go -- --no-gobin ### Options +- `--canary` - Install a canary (next, nightly, etc) version. - `--pin` - Pin the resolved version as the global default. diff --git a/website/docs/proto/commands/local.mdx b/website/docs/proto/commands/local.mdx index aa1dd7b9995..f4b1d41a446 100644 --- a/website/docs/proto/commands/local.mdx +++ b/website/docs/proto/commands/local.mdx @@ -8,7 +8,7 @@ appropriate tool and version. This version will be used when attempting to [detect a version](../detection). ```shell -$ proto local go 1.20.1 +$ proto local go 1.20 ``` > [Learn more about the `.prototools` configuration file!](../config) diff --git a/website/docs/proto/config.mdx b/website/docs/proto/config.mdx index 006817f2e0d..644904152df 100644 --- a/website/docs/proto/config.mdx +++ b/website/docs/proto/config.mdx @@ -16,12 +16,11 @@ proto supports pinning versions of tools on a per-project or per-directory basis and can be created/updated with [`proto local`](./commands/local). This configuration simply maps tools to fully-qualified semantic versions for the current directory. -Partial versions are not supported. ```toml title=".prototools" node = "16.16.0" -npm = "9.0.0" -go = "1.20.0" +npm = "9" +go = "1.20" rust = "1.68.0" ``` diff --git a/website/docs/proto/faq.mdx b/website/docs/proto/faq.mdx index e4b04d39044..642dfd71e82 100644 --- a/website/docs/proto/faq.mdx +++ b/website/docs/proto/faq.mdx @@ -24,28 +24,20 @@ Nah. ### Will you support more languages? -Yes! We'd love to support as many as possible. We're looking into supporting Python, Ruby, and PHP -next. Feel free to create a [plugin](./plugins) in the mean time. - -If you'd like to help, join our Discord community! +Yes! We'd love to support as many as possible, and if you'd like to help, join our Discord +community! Feel free to create a [plugin](./plugins) in the mean time. ### Will you support other kinds of tools? -No, we will only support languages and dependency managers. However, you can create a -[plugin](./plugins) to support other kinds of tools. +No, we will only support languages, dependency managers, and CLIs, which should be enough. However, +you can create a [plugin](./plugins) to support other kinds of tools. ### Will you support "build from source"? In the future we have plans to support building from source. For the time being, proto is built around pre-built archives for easier portability. -### Can I contribute a new language? - -Yes, go for it! We have no official guide on how to do this, but the Rust code is rather straight -forward. Feel free to copy another -[language crate](https://github.com/moonrepo/proto/tree/master/crates). - -### How can I install a global binary for a language? +### How can I install a global package for a language? You can install a global with the [`proto install-global`](./commands/install-global) command. Most languages install a global to a shared location regardless of the language's version (Deno is @@ -61,6 +53,22 @@ also need to manually add these global directories to your `PATH`. However, if you'd prefer to use the native non-proto workflow, you can disable the globals intercept using the [`node-intercept-globals` setting](./config#settings). +### How to run a canary release after installing it? + +Once a tool has been installed with `--canary`, the canary version can be explicitly referenced +using our [version detection rules](./detection). The easiest approach is to prefix the shim with an +environment variable: + +```shell +$ PROTO_BUN_VERSION=canary bun ./index.ts +``` + +Or to explicitly configure the version in [`.prototools`](./config): + +```toml +bun = "canary" +``` + ### OS is unable to find an installed binary, how to resolve? To start, ensure that proto's binaries directory (`~/.proto/bin`) is listed first on `PATH`, and diff --git a/website/docs/proto/index.mdx b/website/docs/proto/index.mdx index cd4dd236c47..c2053d48ce8 100644 --- a/website/docs/proto/index.mdx +++ b/website/docs/proto/index.mdx @@ -74,7 +74,7 @@ the [`proto setup`](./proto/commands/setup) command, or add the path manually. The following tools are [officially supported](./proto/tools) in proto via moonrepo. Additional tools can be supported through [third-party plugins](./proto/plugins). - + ## Supported targets diff --git a/website/docs/proto/install.mdx b/website/docs/proto/install.mdx index 8ac196eaed8..b643501a055 100644 --- a/website/docs/proto/install.mdx +++ b/website/docs/proto/install.mdx @@ -58,5 +58,5 @@ scripts above. ## Uninstalling -To uninstall proto, delete the `~/.proto` directory, and remove any `PROTO_ROOT` references from +To uninstall proto, delete the `~/.proto` directory, and remove any `PROTO_HOME` references from your shell profile. diff --git a/website/docs/proto/toml-plugin.mdx b/website/docs/proto/toml-plugin.mdx index fec9beb5b96..70f754ef39d 100644 --- a/website/docs/proto/toml-plugin.mdx +++ b/website/docs/proto/toml-plugin.mdx @@ -86,7 +86,9 @@ be downloaded and installed into the toolchain. The following settings are avail the `{arch}` token. This is useful if the tool has different terminology. - `checksum-url` - A secure URL to download the checksum file for verification. If the tool does not support checksum verification, this setting can be omitted. +- `checksum-url-canary` - A URL for canary releases. - `download-url` (required) - A secure URL to download the tool/archive. +- `download-url-canary` - A URL for canary releases. The URL settings support `{checksum_file}` and `{download_file}` tokens, which will be replaced with the values from the `[platform]` section. diff --git a/website/docs/proto/tools.mdx b/website/docs/proto/tools.mdx index b963ecb52e3..9fd4a792f90 100644 --- a/website/docs/proto/tools.mdx +++ b/website/docs/proto/tools.mdx @@ -11,33 +11,33 @@ through [plugins](./plugins). -[Bun](https://bun.sh/) (`bun`) is an all-in-one runtime and toolset for JavaScript and TypeScript, -powered by Zig and Webkit. +[Bun](https://bun.sh/) is an all-in-one runtime and toolset for JavaScript and TypeScript, powered +by Zig and Webkit. -#### Global binaries - -- Installs to `~/.bun/bin`. +- **Available binaries** - `bun`, `bunx` +- **Globals directory** - `~/.bun/bin` ## Deno -[Deno](https://deno.land/) (`deno`) is a secure runtime for JavaScript and TypeScript, powered by -Rust and Chrome's V8 engine. - -#### Global binaries - -- Installs to `DENO_INSTALL_ROOT` or `~/.deno/bin`. +[Deno](https://deno.land/) is a secure runtime for JavaScript and TypeScript, powered by Rust and +Chrome's V8 engine. -#### Detection sources - -- A [`.dvmrc`](https://github.com/justjavac/dvm) file. +- **Available binaries** - `deno` +- **Globals directory** - `$DENO_INSTALL_ROOT/bin`, `~/.deno/bin` +- **Detection sources** - [`.dvmrc`](https://github.com/justjavac/dvm) ## Go -[Go](https://go.dev/) (`go`) is a simple, secure, and fast systems language. +[Go](https://go.dev/) is a simple, secure, and fast systems language. + +- **Available binaries** - `go` +- **Globals directory** - `$GOBIN`, `~/go/bin` +- **Detection sources** - [`go.work`](https://go.dev/doc/tutorial/workspaces), + [`go.mod`](https://go.dev/doc/modules/gomod-ref) #### Post-install hook @@ -50,20 +50,16 @@ installation. $ proto install go -- --no-gobin ``` -#### Global binaries - -- Installs to `GOBIN` or `~/go/bin`. - -#### Detection sources - -- Native [`go.work`](https://go.dev/doc/tutorial/workspaces) or - [`go.mod`](https://go.dev/doc/modules/gomod-ref) files. - ## Node.js -[Node.js](https://nodejs.org/) (`node`) is a JavaScript runtime built on Chrome's V8 engine. +[Node.js](https://nodejs.org/) is a JavaScript runtime built on Chrome's V8 engine. + +- **Available binaries** - `node`, `npx` +- **Globals directory** - `~/.proto/tools/node/globals/bin` +- **Detection sources** - [`.nvmrc`](https://github.com/nvm-sh/nvm), + [`.node-version`](https://github.com/nodenv/nodenv), `package.json` engines #### Post-install hook @@ -74,39 +70,29 @@ functionality can be skipped by passing `--no-bundled-npm` during installation. $ proto install node -- --no-bundled-npm ``` -#### Global binaries - -- Installs to `~/.proto/tools/node/globals/bin`. - -#### Detection sources - -- An [`.nvmrc`](https://github.com/nvm-sh/nvm) or - [`.node-version`](https://github.com/nodenv/nodenv) file. - ### npm, pnpm, yarn proto supports all popular Node.js package managers: `npm`, `pnpm`, `yarn`. -#### Global binaries - -- Installs to `~/.proto/tools/node/globals/bin`. -- Internally all package managers [install globals](./commands/install-global) with `npm` into the - location above. +- **Available binaries** - `*`, `node-gyp` +- **Detection sources** - `package.json` engines / package manager -#### Detection sources +### corepack -- The `packageManager` field in `package.json`. +Corepack _is not supported_ by proto, and will never be. Use [`proto use`](./commands/use) instead, +which is a far more poweful alternative. -### node-gyp +## Python (experimental) -The `node-gyp` binary is created alongside the `npm` tool, and cannot be installed manually. + -### corepack +[Python](https://www.python.org/) is a high-level, general-purpose programming language. -Corepack _is not supported_ by proto, and will never be. Use [`proto use`](./commands/use) instead, -which is a far more poweful alternative. +- **Available binaries** - `python`, `pip` +- **Globals directory** - `~/.local/bin` +- **Detection sources** - [`.python-version`](https://github.com/pyenv/pyenv) ## Rust @@ -128,12 +114,6 @@ using Rust in proto: ::: -#### Global binaries - -- Installs to `CARGO_INSTALL_ROOT` or `~/.cargo/bin`. - -#### Detection sources - Since we don't create shims for `cargo`, `rustup`, etc, we can't detect Rust versions at runtime. However, `rustup` supports this as well through the [`rust-toolchain.toml`](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) file. diff --git a/website/docs/proto/wasm-plugin.mdx b/website/docs/proto/wasm-plugin.mdx index fe44b8fb4bc..ac72304b47c 100644 --- a/website/docs/proto/wasm-plugin.mdx +++ b/website/docs/proto/wasm-plugin.mdx @@ -1,6 +1,6 @@ --- -title: WASM plugin (experimental) -sidebar_label: WASM (experimental) +title: WASM plugin +sidebar_label: WASM toc_max_heading_level: 5 --- @@ -161,7 +161,15 @@ The following fields are available on the - `env_vars` - A map of environment variables requested by the [`register_tool`](#registering-metadata) function. - `tool_dir` - A virtual path to the tool's directory for the current version. -- `version` - The current version. If not resolved, will be "latest". +- `version` - The current version or alias. If not resolved, will be "latest". + +:::caution + +The `version` field is either a fully-qualified semantic version (1.2.3), an alias ("latest", +"stable"), or canary ("canary"). Be sure to account for all these variations when implementing +plugin functions! + +::: ## Create a plugin @@ -181,11 +189,15 @@ cargo new plugin --lib cd plugin ``` -And set the lib type to `cdylib`. +And set the lib type to `cdylib`, and other settings. ```toml title="Cargo.toml" [lib] crate-type = ['cdylib'] + +[profile.release] +codegen-units = 1 +lto = true ``` Our Rust plugins are powered by [Extism](https://extism.org/), so lets add their PDK and ours as a @@ -579,7 +591,7 @@ as much as possible with built-in test utilities, and Rust macros for generating To begin, install all necessary development dependencies: ```shell -cargo add --dev proto_core proto_pdk_test_utils starbase_sandbox tokio +cargo add --dev proto_pdk_test_utils starbase_sandbox tokio ``` And as mentioned above, everytime you make a change to the plugin, you'll need to rebuild it with: @@ -631,7 +643,6 @@ plugin ID and a real version to test with. ```rust use proto_pdk_test_utils::*; -use starbase_sandbox::create_empty_sandbox; generate_download_install_tests!("id", "1.2.3"); ``` @@ -730,6 +741,7 @@ Some helpful resources for learning about and building plugins. - [Go](https://github.com/moonrepo/go-plugin) - [Node](https://github.com/moonrepo/node-plugin) - [npm, pnpm, yarn](https://github.com/moonrepo/node-plugin) + - [Python](https://github.com/moonrepo/python-plugin) - [Rust](https://github.com/moonrepo/rust-plugin) - [Schema](https://github.com/moonrepo/schema-plugin) - Plugin development kit diff --git a/website/moon.yml b/website/moon.yml index c24704e48f3..7a5e2cf91b3 100644 --- a/website/moon.yml +++ b/website/moon.yml @@ -14,9 +14,6 @@ tasks: - '^:build' outputs: - 'build' - options: - # https://github.com/facebook/docusaurus/issues/9278 - allowFailure: true start: command: 'docusaurus start' diff --git a/website/src/components/Products/Proto/ToolsGrid.tsx b/website/src/components/Products/Proto/ToolsGrid.tsx index 4fcc1be7ec0..b1323fcbb0b 100644 --- a/website/src/components/Products/Proto/ToolsGrid.tsx +++ b/website/src/components/Products/Proto/ToolsGrid.tsx @@ -1,10 +1,15 @@ import React from 'react'; +import clsx from 'clsx'; import Link from '@docusaurus/Link'; import Text from '@site/src/ui/typography/Text'; -export default function ToolsGrid() { +export interface ToolsGridProps { + cols?: number; +} + +export default function ToolsGrid({ cols = 3 }: ToolsGridProps) { return ( -
+
+
+ + + + + +
+