diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3a3cc949fed..32e8a94f487 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -77,7 +77,7 @@ jobs: # Required for "global bins" tests - uses: moonrepo/setup-toolchain@v0 if: ${{ runner.os == 'Linux' }} - - run: proto install bun 1.0.0 + - run: proto install bun 1.0.0 --pin if: ${{ runner.os == 'Linux' }} - uses: mozilla-actions/sccache-action@v0.0.3 - name: Run tests diff --git a/Cargo.lock b/Cargo.lock index 72b924e68e3..152764bee42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -761,9 +761,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.8" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -771,9 +771,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -788,7 +788,7 @@ version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bffe91f06a11b4b9420f62103854e90867812cd5d01557f853c5ee8e791b12ae" dependencies = [ - "clap 4.4.8", + "clap 4.4.11", ] [[package]] @@ -2963,7 +2963,7 @@ dependencies = [ name = "moon_action_context" version = "0.1.0" dependencies = [ - "clap 4.4.8", + "clap 4.4.11", "moon_common", "moon_target", "rustc-hash", @@ -3207,7 +3207,7 @@ version = "1.17.4" dependencies = [ "bytes", "ci_env", - "clap 4.4.8", + "clap 4.4.11", "clap_complete", "clap_lex 0.6.0", "console", @@ -4235,9 +4235,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "once_map" @@ -4655,9 +4655,9 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.23.7" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978135450f0fa16ec42a159fdcf01b92b65611a5b87ff484461cba1fd32993e7" +checksum = "b898d9381330a511bfc08e112507b57a6f03b4fa25b5269c1eb4ea14e5a33004" dependencies = [ "cached", "extism", @@ -4668,6 +4668,7 @@ dependencies = [ "proto_pdk_api", "regex", "reqwest", + "schematic", "semver", "serde", "serde_json", @@ -4687,9 +4688,9 @@ dependencies = [ [[package]] name = "proto_pdk_api" -version = "0.10.4" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde8df4fbd8eeea007157df37376c24bf1cde6bffb3638aeefa95583911b15a5" +checksum = "72325283c00030c565ff067fab5bee7ce22c3c345aea6f5b48ffb28d60234f58" dependencies = [ "anyhow", "semver", @@ -5098,6 +5099,7 @@ dependencies = [ "serde_yaml 0.9.27", "starbase_styles", "thiserror", + "toml 0.8.8", "tracing", ] @@ -5121,8 +5123,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c38cdd0968bde35f7e093600c90e0306da6af5ffd1b3cb175dbfde1146debcf2" dependencies = [ "semver", - "version_spec", - "warpgate", + "serde_json", + "toml 0.8.8", ] [[package]] @@ -5715,10 +5717,11 @@ dependencies = [ [[package]] name = "system_env" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d56db17c73df41a4b8a42dacbc63dd56ae5fcf936c4807aca9ade566be0abc4" +checksum = "ca213bddf34f26c2d4d76ef0a6e7f0d29d11c3246d514dc78723b8e457f9f3f9" dependencies = [ + "schematic", "serde", "serde_json", "shell-words", @@ -6383,9 +6386,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58fe91d841bc04822c9801002db4ea904b9e4b8e6bbad25127b46eff8dc516b" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", ] @@ -6422,12 +6425,13 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "version_spec" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a874b9ff438ee535ce27c6099a76f23483b475e5942b85fd97d4a6806abaa3f3" +checksum = "f3aaaf40ae0d800122ce8ef646ddd08ea02a42a141b249e08496e10ae3eb4440" dependencies = [ "human-sort", "regex", + "schematic", "semver", "serde", ] @@ -6475,9 +6479,9 @@ dependencies = [ [[package]] name = "warpgate" -version = "0.5.15" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aedafb67d3791893d2e7c62f9d08a9bf95b4ae78f9d8c610e56ee57b6a12f57" +checksum = "8a7753f1234515fcfb16f532527e6d4c3bf20a9745b89ca6d450f7ae9b04fbdd" dependencies = [ "extism", "miette", @@ -6485,6 +6489,7 @@ dependencies = [ "once_map", "regex", "reqwest", + "schematic", "serde", "serde_json", "sha2", @@ -6498,10 +6503,11 @@ dependencies = [ [[package]] name = "warpgate_api" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a4834d752d83450aab41986e1b9a08d069bbe09a83fe016532de19d0a87e24e" +checksum = "5fe2fae4f5a428c7c697e057909240e376abdd45577beec6d4bd9798b451f20c" dependencies = [ + "schematic", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index dbb7490bf32..6076d118394 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,17 +29,17 @@ cached = "0.46.1" chrono = { version = "0.4.31", features = ["serde"] } cd_env = "0.1.2" ci_env = "0.2.1" -clap = { version = "4.4.8", features = ["derive", "env", "wrap_help"] } +clap = { version = "4.4.11", features = ["derive", "env", "wrap_help"] } clap_complete = "4.4.4" console = "0.15.7" miette = "5.10.0" -once_cell = "1.18.0" -once_map = "0.4.11" +once_cell = "1.19.0" +once_map = "0.4.13" pathdiff = "0.2.1" petgraph = { version = "0.6.4", default-features = false, features = [ "serde-1", ] } -proto_core = "0.23.7" +proto_core = "0.24.2" relative-path = { version = "1.9.0", features = ["serde"] } regex = "1.10.2" reqwest = { version = "0.11.22", default-features = false, features = [ @@ -54,11 +54,9 @@ schematic = { version = "0.12.10", default-features = false, features = [ "url", "yaml", "type_semver", - "type_version_spec", - "type_warpgate", ] } semver = "1.0.20" -serde = { version = "1.0.192", features = ["derive", "rc"] } +serde = { version = "1.0.193", features = ["derive", "rc"] } serde_json = "1.0.108" serde_yaml = "0.9.27" starbase = "0.2.10" @@ -75,7 +73,7 @@ starbase_utils = { version = "0.3.11", default-features = false, features = [ "toml", "yaml", ] } -system_env = "0.1.6" +system_env = "0.1.8" tera = { version = "1.19.1", features = ["preserve_order"] } thiserror = "1.0.50" tokio = { version = "1.34.0", default-features = false, features = [ @@ -89,5 +87,5 @@ tokio = { version = "1.34.0", default-features = false, features = [ ] } tokio-util = "0.7.10" tracing = "0.1.40" -url = "2.4.1" -uuid = { version = "1.6.0", features = ["v4"] } +url = "2.5.0" +uuid = { version = "1.6.1", features = ["v4"] } diff --git a/crates/core/tool/src/lib.rs b/crates/core/tool/src/lib.rs index 2eca5ee1577..7fdc34e75b7 100644 --- a/crates/core/tool/src/lib.rs +++ b/crates/core/tool/src/lib.rs @@ -8,8 +8,7 @@ pub use manager::*; pub use tool::*; use proto_core::{ - inject_default_manifest_config, Id, PluginLocator, ProtoEnvironment, Tool as ProtoTool, - UserConfig, Wasm, + inject_default_manifest_config, Id, PluginLocator, ProtoEnvironment, Tool as ProtoTool, Wasm, }; use std::env; use std::path::Path; @@ -49,9 +48,7 @@ pub async fn load_tool_plugin( Wasm::file(proto.get_plugin_loader().load_plugin(id, locator).await?), )?; - let user_config = UserConfig::load()?; - - inject_default_manifest_config(id, proto, &user_config, &mut manifest)?; + inject_default_manifest_config(id, proto, &mut manifest)?; ProtoTool::load_from_manifest(id, proto, manifest) } diff --git a/nextgen/app-components/src/resources.rs b/nextgen/app-components/src/resources.rs index a5183b2fbcd..b0eb2926d40 100644 --- a/nextgen/app-components/src/resources.rs +++ b/nextgen/app-components/src/resources.rs @@ -1,5 +1,5 @@ use moon_config::{InheritedTasksManager, ToolchainConfig, WorkspaceConfig}; -use proto_core::ToolsConfig; +use proto_core::ProtoConfig; use semver::Version; use starbase::Resource; use std::path::PathBuf; @@ -29,7 +29,7 @@ pub struct Tasks { #[derive(Debug, Resource)] pub struct Toolchain { pub config: ToolchainConfig, - pub proto: ToolsConfig, + pub proto_config: ProtoConfig, pub proto_home: PathBuf, } diff --git a/nextgen/app/src/systems/startup.rs b/nextgen/app/src/systems/startup.rs index 4f79346b908..2d4ba9dd236 100644 --- a/nextgen/app/src/systems/startup.rs +++ b/nextgen/app/src/systems/startup.rs @@ -4,7 +4,7 @@ use crate::app_error::AppError; use moon_app_components::{AppInfo, Tasks, Toolchain, WorkingDir, Workspace, WorkspaceRoot}; use moon_common::consts; use moon_config::{InheritedTasksManager, ToolchainConfig, WorkspaceConfig}; -use proto_core::{get_proto_home, ToolsConfig, TOOLS_CONFIG_NAME}; +use proto_core::{get_proto_home, ProtoConfig, PROTO_CONFIG_NAME}; use semver::Version; use starbase::system; use starbase_styles::color; @@ -121,7 +121,7 @@ pub fn load_toolchain_config(workspace_root: StateRef, resources: consts::CONFIG_TOOLCHAIN_FILENAME ); let config_path = workspace_root.join(&config_name); - let proto_path = workspace_root.join(TOOLS_CONFIG_NAME); + let proto_path = workspace_root.join(PROTO_CONFIG_NAME); debug!( file = ?config_path, @@ -132,24 +132,24 @@ pub fn load_toolchain_config(workspace_root: StateRef, resources: if proto_path.exists() { debug!( "Found a {} file in the root, loading into the toolchain", - color::file(TOOLS_CONFIG_NAME) + color::file(PROTO_CONFIG_NAME) ); } - let mut proto_tools = ToolsConfig::load_from(workspace_root)?; - proto_tools.inherit_builtin_plugins(); + // TODO + let proto_config = ProtoConfig::default(); let config = if config_path.exists() { debug!("Config file does not exist, using defaults"); ToolchainConfig::default() } else { - ToolchainConfig::load(workspace_root, &config_path, &proto_tools)? + ToolchainConfig::load(workspace_root, &config_path, &proto_config)? }; resources.set(Toolchain { config, - proto: proto_tools, + proto_config, proto_home: get_proto_home()?, }); } diff --git a/nextgen/config/src/lib.rs b/nextgen/config/src/lib.rs index 7c90c1ecfd3..e7f67615fa2 100644 --- a/nextgen/config/src/lib.rs +++ b/nextgen/config/src/lib.rs @@ -19,7 +19,7 @@ pub use language_platform::*; pub use portable_path::*; pub use project::*; pub use project_config::*; -pub use proto_core::{ToolsConfig, UnresolvedVersionSpec, Version, VersionReq, VersionSpec}; +pub use proto_core::{ProtoConfig, UnresolvedVersionSpec, Version, VersionReq, VersionSpec}; pub use schematic::{Config, ConfigEnum, ConfigError, PartialConfig}; pub use shapes::*; pub use template::*; diff --git a/nextgen/config/src/toolchain/mod.rs b/nextgen/config/src/toolchain/mod.rs index b83c458a2a3..4d51f68b0bc 100644 --- a/nextgen/config/src/toolchain/mod.rs +++ b/nextgen/config/src/toolchain/mod.rs @@ -15,8 +15,8 @@ pub use typescript_config::*; #[macro_export] macro_rules! inherit_tool { ($config:ident, $tool:ident, $key:expr, $method:ident) => { - pub fn $method(&mut self, proto_tools: &ToolsConfig) -> miette::Result<()> { - if let Some(version) = proto_tools.tools.get($key) { + pub fn $method(&mut self, proto_config: &ProtoConfig) -> miette::Result<()> { + if let Some(version) = proto_config.versions.get($key) { let config = self.$tool.get_or_insert_with($config::default); if config.version.is_none() { @@ -26,10 +26,7 @@ macro_rules! inherit_tool { if let Some(config) = &mut self.$tool { if config.plugin.is_none() { - config.plugin = proto_tools.plugins.get($key).cloned(); - // config.plugin = Some(PluginLocator::SourceUrl { - // url: $plugin.into(), - // }); + config.plugin = proto_config.plugins.get($key).cloned(); } } @@ -41,15 +38,15 @@ macro_rules! inherit_tool { #[macro_export] macro_rules! inherit_tool_required { ($config:ident, $tool:ident, $key:expr, $method:ident) => { - pub fn $method(&mut self, proto_tools: &ToolsConfig) -> miette::Result<()> { - if let Some(version) = proto_tools.tools.get($key) { + pub fn $method(&mut self, proto_config: &ProtoConfig) -> miette::Result<()> { + if let Some(version) = proto_config.versions.get($key) { if self.$tool.version.is_none() { self.$tool.version = Some(version.to_owned()); } } if self.$tool.plugin.is_none() { - self.$tool.plugin = proto_tools.plugins.get($key).cloned(); + self.$tool.plugin = proto_config.plugins.get($key).cloned(); } Ok(()) @@ -60,15 +57,15 @@ macro_rules! inherit_tool_required { #[macro_export] macro_rules! inherit_tool_without_version { ($config:ident, $tool:ident, $key:expr, $method:ident) => { - pub fn $method(&mut self, proto_tools: &ToolsConfig) -> miette::Result<()> { - if self.$tool.is_none() && proto_tools.tools.get($key).is_some() { + pub fn $method(&mut self, proto_config: &ProtoConfig) -> miette::Result<()> { + if self.$tool.is_none() && proto_config.versions.get($key).is_some() { self.$tool = Some($config::default()); } // Not used yet! // if let Some(config) = self.$tool.as_mut() { // if config.plugin.is_none() { - // config.plugin = proto_tools.plugins.get($key).cloned(); + // config.plugin = proto_config.plugins.get($key).cloned(); // } // } diff --git a/nextgen/config/src/toolchain/node_config.rs b/nextgen/config/src/toolchain/node_config.rs index 0e491cf896a..f10aafe2302 100644 --- a/nextgen/config/src/toolchain/node_config.rs +++ b/nextgen/config/src/toolchain/node_config.rs @@ -1,6 +1,6 @@ use crate::{inherit_tool, inherit_tool_required}; use moon_common::color; -use proto_core::{PluginLocator, ToolsConfig, UnresolvedVersionSpec}; +use proto_core::{PluginLocator, ProtoConfig, UnresolvedVersionSpec}; use schematic::{derive_enum, Config, ConfigEnum}; use tracing::debug; @@ -163,31 +163,31 @@ impl NodeConfig { inherit_tool!(YarnConfig, yarn, "yarn", inherit_proto_yarn); - pub fn inherit_proto(&mut self, proto_tools: &ToolsConfig) -> miette::Result<()> { + pub fn inherit_proto(&mut self, proto_config: &ProtoConfig) -> miette::Result<()> { match &self.package_manager { NodePackageManager::Bun => { if self.bun.is_none() { self.bun = Some(BunpmConfig::default()); } - self.inherit_proto_bun(proto_tools)?; + self.inherit_proto_bun(proto_config)?; } NodePackageManager::Npm => { - self.inherit_proto_npm(proto_tools)?; + self.inherit_proto_npm(proto_config)?; } NodePackageManager::Pnpm => { if self.pnpm.is_none() { self.pnpm = Some(PnpmConfig::default()); } - self.inherit_proto_pnpm(proto_tools)?; + self.inherit_proto_pnpm(proto_config)?; } NodePackageManager::Yarn => { if self.yarn.is_none() { self.yarn = Some(YarnConfig::default()); } - self.inherit_proto_yarn(proto_tools)?; + self.inherit_proto_yarn(proto_config)?; } }; diff --git a/nextgen/config/src/toolchain_config.rs b/nextgen/config/src/toolchain_config.rs index b8b4cf9188c..5f5ee5970d1 100644 --- a/nextgen/config/src/toolchain_config.rs +++ b/nextgen/config/src/toolchain_config.rs @@ -5,7 +5,7 @@ use crate::toolchain::*; use crate::validate::check_yml_extension; use crate::{inherit_tool, inherit_tool_without_version}; use moon_common::consts; -use proto_core::ToolsConfig; +use proto_core::ProtoConfig; use schematic::{validate, Config, ConfigLoader}; use std::path::Path; @@ -75,15 +75,15 @@ impl ToolchainConfig { tools } - pub fn inherit_proto(&mut self, proto_tools: &ToolsConfig) -> miette::Result<()> { - self.inherit_proto_bun(proto_tools)?; - self.inherit_proto_deno(proto_tools)?; - self.inherit_proto_node(proto_tools)?; - self.inherit_proto_rust(proto_tools)?; - self.inherit_proto_typescript(proto_tools)?; + pub fn inherit_proto(&mut self, proto_config: &ProtoConfig) -> miette::Result<()> { + self.inherit_proto_bun(proto_config)?; + self.inherit_proto_deno(proto_config)?; + self.inherit_proto_node(proto_config)?; + self.inherit_proto_rust(proto_config)?; + self.inherit_proto_typescript(proto_config)?; if let Some(node_config) = &mut self.node { - node_config.inherit_proto(proto_tools)?; + node_config.inherit_proto(proto_config)?; } Ok(()) @@ -92,21 +92,21 @@ impl ToolchainConfig { pub fn load, P: AsRef>( workspace_root: R, path: P, - proto_tools: &ToolsConfig, + proto_config: &ProtoConfig, ) -> miette::Result { let mut result = ConfigLoader::::new() .set_root(workspace_root) .file_optional(check_yml_extension(path.as_ref()))? .load()?; - result.config.inherit_proto(proto_tools)?; + result.config.inherit_proto(proto_config)?; Ok(result.config) } pub fn load_from>( workspace_root: R, - proto_tools: &ToolsConfig, + proto_config: &ProtoConfig, ) -> miette::Result { let workspace_root = workspace_root.as_ref(); @@ -115,7 +115,7 @@ impl ToolchainConfig { workspace_root .join(consts::CONFIG_DIRNAME) .join(consts::CONFIG_TOOLCHAIN_FILENAME), - proto_tools, + proto_config, ) } } diff --git a/nextgen/config/tests/toolchain_config_test.rs b/nextgen/config/tests/toolchain_config_test.rs index d061a57e670..8361847bc70 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, NodeVersionFormat, ToolchainConfig}; -use proto_core::{Id, PluginLocator, ToolsConfig, UnresolvedVersionSpec}; +use proto_core::{Id, PluginLocator, ProtoConfig, UnresolvedVersionSpec}; use starbase_sandbox::create_sandbox; use std::env; use utils::*; @@ -17,14 +17,14 @@ mod toolchain_config { )] fn error_unknown_field() { test_load_config(FILENAME, "unknown: 123", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); } #[test] fn loads_defaults() { let config = test_load_config(FILENAME, "{}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.deno.is_none()); @@ -40,7 +40,7 @@ mod toolchain_config { fn recursive_merges() { let sandbox = create_sandbox("extends/toolchain"); let config = test_config(sandbox.path().join("base-2.yml"), |path| { - ToolchainConfig::load(sandbox.path(), path, &ToolsConfig::default()) + ToolchainConfig::load(sandbox.path(), path, &ProtoConfig::default()) }); let node = config.node.unwrap(); @@ -65,7 +65,7 @@ mod toolchain_config { fn recursive_merges_typescript() { let sandbox = create_sandbox("extends/toolchain"); let config = test_config(sandbox.path().join("typescript-2.yml"), |path| { - ToolchainConfig::load(sandbox.path(), path, &ToolsConfig::default()) + ToolchainConfig::load(sandbox.path(), path, &ProtoConfig::default()) }); let typescript = config.typescript.unwrap(); @@ -82,7 +82,7 @@ mod toolchain_config { // #[test] // fn uses_defaults() { // let config = test_load_config(FILENAME, "bun: {}", |path| { - // ToolchainConfig::load_from(path, &ToolsConfig::default()) + // ToolchainConfig::load_from(path, &ProtoConfig::default()) // }); // let cfg = config.bun.unwrap(); @@ -93,8 +93,8 @@ mod toolchain_config { #[test] fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("bun"), UnresolvedVersionSpec::parse("1.0.0").unwrap(), ); @@ -112,7 +112,7 @@ mod toolchain_config { #[test] fn inherits_plugin_locator() { let config = test_load_config(FILENAME, "bun: {}", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -121,7 +121,7 @@ mod toolchain_config { assert_eq!( config.bun.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.5.0/bun_plugin.wasm".into() + url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.6.0/bun_plugin.wasm".into() } ); } @@ -135,8 +135,8 @@ bun: version: 1.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("bun"), UnresolvedVersionSpec::parse("2.0.0").unwrap(), ); @@ -163,8 +163,8 @@ bun: version: 3.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("bun"), UnresolvedVersionSpec::parse("2.0.0").unwrap(), ); @@ -188,7 +188,7 @@ bun: #[test] fn uses_defaults() { let config = test_load_config(FILENAME, "deno: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); let cfg = config.deno.unwrap(); @@ -206,7 +206,7 @@ deno: depsFile: dependencies.ts lockfile: true ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.deno.unwrap(); @@ -227,7 +227,7 @@ deno: name: 'fs' force: true ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.deno.unwrap(); @@ -249,8 +249,8 @@ deno: #[test] fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("deno"), UnresolvedVersionSpec::parse("1.30.0").unwrap(), ); @@ -269,7 +269,7 @@ deno: #[test] fn uses_defaults() { let config = test_load_config(FILENAME, "node: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); let cfg = config.node.unwrap(); @@ -287,7 +287,7 @@ node: dedupeOnLockfileChange: false inferTasksFromScripts: true ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.node.unwrap(); @@ -299,8 +299,8 @@ node: #[test] fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("node"), UnresolvedVersionSpec::parse("18.0.0").unwrap(), ); @@ -318,7 +318,7 @@ node: #[test] fn inherits_plugin_locator() { let config = test_load_config(FILENAME, "node: {}", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -327,7 +327,7 @@ node: assert_eq!( config.node.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/node-plugin/releases/download/v0.5.3/node_plugin.wasm".into() + url: "https://github.com/moonrepo/node-plugin/releases/download/v0.6.1/node_plugin.wasm".into() } ); } @@ -341,8 +341,8 @@ node: version: 20.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("node"), UnresolvedVersionSpec::parse("18.0.0").unwrap(), ); @@ -369,8 +369,8 @@ node: version: 20.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("node"), UnresolvedVersionSpec::parse("18.0.0").unwrap(), ); @@ -400,8 +400,8 @@ node: version: 9.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("npm"), UnresolvedVersionSpec::parse("8.0.0").unwrap(), ); @@ -419,7 +419,7 @@ node: #[test] fn inherits_plugin_locator() { let config = test_load_config(FILENAME, "node:\n npm: {}", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -428,7 +428,7 @@ node: assert_eq!( config.node.unwrap().npm.plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/node-plugin/releases/download/v0.5.3/node_depman_plugin.wasm".into() + url: "https://github.com/moonrepo/node-plugin/releases/download/v0.6.1/node_depman_plugin.wasm".into() } ); } @@ -445,8 +445,8 @@ node: version: 9.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("npm"), UnresolvedVersionSpec::parse("8.0.0").unwrap(), ); @@ -472,7 +472,7 @@ node: packageManager: npm dependencyVersionFormat: workspace ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.node.unwrap(); @@ -487,13 +487,13 @@ node: #[test] fn enables_when_defined() { let config = test_load_config(FILENAME, "node: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.node.unwrap().pnpm.is_none()); let config = test_load_config(FILENAME, "node:\n pnpm: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.node.unwrap().pnpm.is_some()); @@ -509,7 +509,7 @@ node: pnpm: {} ", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -519,7 +519,7 @@ node: assert_eq!( config.node.unwrap().pnpm.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/node-plugin/releases/download/v0.5.3/node_depman_plugin.wasm".into() + url: "https://github.com/moonrepo/node-plugin/releases/download/v0.6.1/node_depman_plugin.wasm".into() } ); } @@ -533,7 +533,7 @@ node: packageManager: pnpm ", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -543,7 +543,7 @@ node: assert_eq!( config.node.unwrap().pnpm.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/node-plugin/releases/download/v0.5.3/node_depman_plugin.wasm".into() + url: "https://github.com/moonrepo/node-plugin/releases/download/v0.6.1/node_depman_plugin.wasm".into() } ); } @@ -558,8 +558,8 @@ node: version: 9.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("pnpm"), UnresolvedVersionSpec::parse("8.0.0").unwrap(), ); @@ -586,8 +586,8 @@ node: version: 9.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("pnpm"), UnresolvedVersionSpec::parse("8.0.0").unwrap(), ); @@ -611,13 +611,13 @@ node: #[test] fn enables_when_defined() { let config = test_load_config(FILENAME, "node: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.node.unwrap().yarn.is_none()); let config = test_load_config(FILENAME, "node:\n yarn: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.node.unwrap().yarn.is_some()); @@ -633,7 +633,7 @@ node: yarn: {} ", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -643,7 +643,7 @@ node: assert_eq!( config.node.unwrap().yarn.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/node-plugin/releases/download/v0.5.3/node_depman_plugin.wasm".into() + url: "https://github.com/moonrepo/node-plugin/releases/download/v0.6.1/node_depman_plugin.wasm".into() } ); } @@ -657,7 +657,7 @@ node: packageManager: yarn ", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -667,7 +667,7 @@ node: assert_eq!( config.node.unwrap().yarn.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/node-plugin/releases/download/v0.5.3/node_depman_plugin.wasm".into() + url: "https://github.com/moonrepo/node-plugin/releases/download/v0.6.1/node_depman_plugin.wasm".into() } ); } @@ -682,8 +682,8 @@ node: version: 9.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("yarn"), UnresolvedVersionSpec::parse("8.0.0").unwrap(), ); @@ -710,8 +710,8 @@ node: version: 9.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("yarn"), UnresolvedVersionSpec::parse("8.0.0").unwrap(), ); @@ -735,13 +735,13 @@ node: #[test] fn enables_when_defined() { let config = test_load_config(FILENAME, "node: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.node.unwrap().bun.is_none()); let config = test_load_config(FILENAME, "node:\n bun: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); assert!(config.node.unwrap().bun.is_some()); @@ -757,7 +757,7 @@ node: bun: {} ", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -767,7 +767,7 @@ node: assert_eq!( config.node.unwrap().bun.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.5.0/bun_plugin.wasm".into() + url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.6.0/bun_plugin.wasm".into() } ); } @@ -781,7 +781,7 @@ node: packageManager: bun ", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -791,7 +791,7 @@ node: assert_eq!( config.node.unwrap().bun.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.5.0/bun_plugin.wasm".into() + url: "https://github.com/moonrepo/bun-plugin/releases/download/v0.6.0/bun_plugin.wasm".into() } ); } @@ -806,8 +806,8 @@ node: version: 1.0.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("bun"), UnresolvedVersionSpec::parse("0.0.1").unwrap(), ); @@ -834,8 +834,8 @@ node: version: 0.0.1 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("bun"), UnresolvedVersionSpec::parse("0.1.0").unwrap(), ); @@ -861,7 +861,7 @@ node: packageManager: bun dependencyVersionFormat: workspace-tilde ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.node.unwrap(); @@ -877,7 +877,7 @@ node: #[test] fn uses_defaults() { let config = test_load_config(FILENAME, "rust: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); let cfg = config.rust.unwrap(); @@ -895,7 +895,7 @@ rust: bins: [cargo-make] syncToolchainConfig: true ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.rust.unwrap(); @@ -918,7 +918,7 @@ rust: local: true syncToolchainConfig: true ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.rust.unwrap(); @@ -945,8 +945,8 @@ rust: #[test] fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("rust"), UnresolvedVersionSpec::parse("1.69.0").unwrap(), ); @@ -964,7 +964,7 @@ rust: #[test] fn inherits_plugin_locator() { let config = test_load_config(FILENAME, "rust: {}", |path| { - let mut tools = ToolsConfig::default(); + let mut tools = ProtoConfig::default(); tools.inherit_builtin_plugins(); ToolchainConfig::load_from(path, &tools) @@ -973,7 +973,7 @@ rust: assert_eq!( config.rust.unwrap().plugin.unwrap(), PluginLocator::SourceUrl { - url: "https://github.com/moonrepo/rust-plugin/releases/download/v0.4.0/rust_plugin.wasm".into() + url: "https://github.com/moonrepo/rust-plugin/releases/download/v0.5.0/rust_plugin.wasm".into() } ); } @@ -987,8 +987,8 @@ rust: version: 1.60.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("rust"), UnresolvedVersionSpec::parse("1.69.0").unwrap(), ); @@ -1015,8 +1015,8 @@ rust: version: 1.60.0 ", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("rust"), UnresolvedVersionSpec::parse("1.65.0").unwrap(), ); @@ -1040,7 +1040,7 @@ rust: #[test] fn uses_defaults() { let config = test_load_config(FILENAME, "typescript: {}", |path| { - ToolchainConfig::load_from(path, &ToolsConfig::default()) + ToolchainConfig::load_from(path, &ProtoConfig::default()) }); let cfg = config.typescript.unwrap(); @@ -1058,7 +1058,7 @@ typescript: projectConfigFileName: tsconf.json syncProjectReferences: false ", - |path| ToolchainConfig::load_from(path, &ToolsConfig::default()), + |path| ToolchainConfig::load_from(path, &ProtoConfig::default()), ); let cfg = config.typescript.unwrap(); @@ -1070,8 +1070,8 @@ typescript: #[test] fn enables_via_proto() { let config = test_load_config(FILENAME, "{}", |path| { - let mut proto = ToolsConfig::default(); - proto.tools.insert( + let mut proto = ProtoConfig::default(); + proto.versions.insert( Id::raw("typescript"), UnresolvedVersionSpec::parse("5.0.0").unwrap(), ); diff --git a/nextgen/test-utils/src/platform_manager.rs b/nextgen/test-utils/src/platform_manager.rs index 2bf953ef01b..8fa8d86b5f5 100644 --- a/nextgen/test-utils/src/platform_manager.rs +++ b/nextgen/test-utils/src/platform_manager.rs @@ -1,5 +1,5 @@ use moon_bun_platform::BunPlatform; -use moon_config::{PlatformType, ToolchainConfig, ToolsConfig}; +use moon_config::{PlatformType, ProtoConfig, ToolchainConfig}; use moon_node_platform::NodePlatform; use moon_platform::PlatformManager; use moon_rust_platform::RustPlatform; @@ -10,7 +10,7 @@ use std::sync::Arc; pub async fn generate_platform_manager_from_sandbox(root: &Path) -> PlatformManager { let proto = Arc::new(ProtoEnvironment::new_testing(root)); - let config = ToolchainConfig::load_from(root, &ToolsConfig::default()).unwrap(); + let config = ToolchainConfig::load_from(root, &ProtoConfig::default()).unwrap(); let mut manager = PlatformManager::default(); if let Some(bun_config) = &config.bun { diff --git a/nextgen/test-utils/src/project_graph.rs b/nextgen/test-utils/src/project_graph.rs index 5fd4cad59e6..8b553da3783 100644 --- a/nextgen/test-utils/src/project_graph.rs +++ b/nextgen/test-utils/src/project_graph.rs @@ -1,6 +1,6 @@ use moon_config::{ InheritedTasksEntry, InheritedTasksManager, NodeConfig, PartialInheritedTasksConfig, - PartialTaskConfig, ToolchainConfig, ToolsConfig, WorkspaceConfig, WorkspaceProjects, + PartialTaskConfig, ProtoConfig, ToolchainConfig, WorkspaceConfig, WorkspaceProjects, WorkspaceProjectsConfig, }; use moon_project_graph::{ @@ -24,10 +24,10 @@ pub struct ProjectGraphContainer { impl ProjectGraphContainer { pub fn new(root: &Path) -> Self { - let proto = ToolsConfig::default(); + let proto_config = ProtoConfig::default(); let mut graph = Self { inherited_tasks: InheritedTasksManager::load_from(root).unwrap(), - toolchain_config: ToolchainConfig::load_from(root, &proto).unwrap(), + toolchain_config: ToolchainConfig::load_from(root, &proto_config).unwrap(), workspace_root: root.to_path_buf(), ..Default::default() }; diff --git a/nextgen/workspace/src/workspace.rs b/nextgen/workspace/src/workspace.rs index 8ddac2ea638..9fd675b1e6a 100644 --- a/nextgen/workspace/src/workspace.rs +++ b/nextgen/workspace/src/workspace.rs @@ -5,7 +5,7 @@ use moon_common::consts; use moon_config::{InheritedTasksManager, ToolchainConfig, WorkspaceConfig}; use moon_hash::HashEngine; use moon_vcs::{BoxedVcs, Git}; -use proto_core::{ProtoEnvironment, ToolsConfig, Version}; +use proto_core::{ProtoConfig, ProtoEnvironment, Version}; use starbase::Resource; use starbase_styles::color; use starbase_utils::{dirs, fs}; @@ -82,7 +82,7 @@ fn load_tasks_config(root_dir: &Path) -> miette::Result { // .moon/toolchain.yml fn load_toolchain_config( root_dir: &Path, - proto_tools: &ToolsConfig, + proto_config: &ProtoConfig, ) -> miette::Result { let config_name = format!( "{}/{}", @@ -101,7 +101,7 @@ fn load_toolchain_config( return Ok(ToolchainConfig::default()); } - ToolchainConfig::load_from(root_dir, proto_tools) + ToolchainConfig::load_from(root_dir, proto_config) } // .moon/workspace.yml @@ -140,9 +140,6 @@ pub struct Workspace { /// The plugin loader. pub proto_env: Arc, - /// Proto tools loaded from ".prototools". - pub proto_tools: Arc, - /// The root of the workspace that contains the ".moon" config folder. pub root: PathBuf, @@ -176,13 +173,14 @@ impl Workspace { ); // Load proto tools - let proto_env = ProtoEnvironment::new()?; - let mut proto_tools = ToolsConfig::load_from(&root_dir)?; - proto_tools.inherit_builtin_plugins(); + let mut proto_env = ProtoEnvironment::new()?; + proto_env.cwd = working_dir.to_path_buf(); + + let proto_config = proto_env.load_config()?; // Load configs let config = load_workspace_config(&root_dir)?; - let toolchain_config = load_toolchain_config(&root_dir, &proto_tools)?; + let toolchain_config = load_toolchain_config(&root_dir, proto_config)?; let tasks_config = load_tasks_config(&root_dir)?; if let Some(constraint) = &config.version_constraint { @@ -213,7 +211,6 @@ impl Workspace { config: Arc::new(config), hash_engine: Arc::new(hash_engine), proto_env: Arc::new(proto_env), - proto_tools: Arc::new(proto_tools), root: root_dir, session: None, tasks_config: Arc::new(tasks_config), diff --git a/nextgen/workspace/tests/workspace_test.rs b/nextgen/workspace/tests/workspace_test.rs index 5b8964493a4..5d6f7e128e0 100644 --- a/nextgen/workspace/tests/workspace_test.rs +++ b/nextgen/workspace/tests/workspace_test.rs @@ -16,13 +16,14 @@ npm = "9.0.0" ); let workspace = Workspace::load_from(sandbox.path()).unwrap(); + let proto_config = workspace.proto_env.load_config().unwrap(); assert_eq!( - workspace.proto_tools.tools.get("node").unwrap().to_string(), + proto_config.versions.get("node").unwrap().to_string(), "18.0.0" ); assert_eq!( - workspace.proto_tools.tools.get("npm").unwrap().to_string(), + proto_config.versions.get("npm").unwrap().to_string(), "9.0.0" ); } diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 851c889c293..b00e97aae16 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -23,7 +23,8 @@ #### ⚙️ Internal -- Improved string allocation and performance for queries, task tokens, and process command. +- Improved string allocation and performance for queries, task tokens, and process commands. +- Updated proto to v0.24. ## 1.17.4