diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a542b7b6506..d9030f93b48 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -90,7 +90,7 @@ jobs: with: auto-install: true cache: ${{ runner.os == 'Linux' }} - proto-version: '0.44.2' # Keep in sync + proto-version: '0.44.4' # Keep in sync - uses: mozilla-actions/sccache-action@v0.0.5 if: ${{ vars.ENABLE_SCCACHE == 'true' }} - name: Checking coverage status diff --git a/.yarn/versions/ddd51f72.yml b/.yarn/versions/ddd51f72.yml new file mode 100644 index 00000000000..1f2a5d9c201 --- /dev/null +++ b/.yarn/versions/ddd51f72.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/CHANGELOG.md b/CHANGELOG.md index a0f2e3e0034..8961dc6261f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## Unreleased + +#### 🐞 Fixes + +- Fixed `NO_COLOR` and `FORCE_COLOR` being unexpectedly set in some situations. +- Fixed an issue where a custom project `language` would no longer inherit global tasks of the same + name. + +#### ⚙️ Internal + +- Updated proto to [v0.44.4](https://github.com/moonrepo/proto/releases/tag/v0.44.4) (from 0.44.2). + ## 1.31.0 #### 💥 Breaking diff --git a/Cargo.lock b/Cargo.lock index 50700b4d763..25adf76d766 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -392,9 +392,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.84" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", @@ -911,9 +911,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd" dependencies = [ "clap_builder", "clap_derive", @@ -921,9 +921,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd" dependencies = [ "anstream", "anstyle", @@ -934,9 +934,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2e663e3e3bed2d32d065a8404024dad306e699a04263ec59919529f803aee9" +checksum = "942dc5991a34d8cf58937ec33201856feba9cbceeeab5adf04116ec7c763bff1" dependencies = [ "clap", ] @@ -953,9 +953,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -1003,19 +1003,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" -[[package]] -name = "compact_str" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" -dependencies = [ - "castaway", - "cfg-if", - "itoa", - "ryu", - "static_assertions", -] - [[package]] name = "compact_str" version = "0.8.1" @@ -1945,11 +1932,11 @@ dependencies = [ [[package]] name = "garde" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a3233677ea1554a48235d81bb59d2a41654969a8e29a1316c48105fd1701693" +checksum = "1dbf10452e3dbf51033a5035a05762b2653c43bf84d46e96f15bc93beedd426d" dependencies = [ - "compact_str 0.7.1", + "compact_str", "garde_derive", "once_cell", "regex", @@ -1959,9 +1946,9 @@ dependencies = [ [[package]] name = "garde_derive" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8796f322e43105351a7ec35148807b32b5b6058a539656dafe4a5b456d5ca41f" +checksum = "ccfdbc9c39fad7991686e229c55cf71565eafe73dcb2cf38ddf1d4aa3ca7e176" dependencies = [ "proc-macro2", "quote", @@ -3604,7 +3591,7 @@ dependencies = [ name = "moon_common" version = "0.0.10" dependencies = [ - "compact_str 0.8.1", + "compact_str", "dirs 5.0.1", "miette 7.4.0", "regex", @@ -4309,7 +4296,7 @@ dependencies = [ name = "moon_target" version = "0.0.9" dependencies = [ - "compact_str 0.8.1", + "compact_str", "miette 7.4.0", "moon_common", "once_cell", @@ -5325,9 +5312,9 @@ dependencies = [ [[package]] name = "proto_core" -version = "0.44.2" +version = "0.44.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de994f1232e79a59d2ff8ef420573cf958c60f0019d60bd631b8a49efb94ce0" +checksum = "16652b7f710c617b5caaa38d41cc8ebc8ea9f5472471e614eab365dcc221de69" dependencies = [ "convert_case", "dotenvy", @@ -5951,9 +5938,9 @@ dependencies = [ [[package]] name = "schematic" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef9a634be1649ec5f5516e39eb78d2e84fcf5eef3792acae353d8ade6a7b391" +checksum = "bc902ccf410e32f7d1fdcad8080729def0cd5e696fb70ca7468bfcd02ff4fe80" dependencies = [ "garde", "indexmap 2.7.0", @@ -5976,9 +5963,9 @@ dependencies = [ [[package]] name = "schematic_macros" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d2d4005b3b6482801d60ba093c550d25382401e0c4d1c3fbba80eb07e28626" +checksum = "55f638e083cb574cc60a6f15a9eecc45bb4ace4bbbeda0e904298788f04e9453" dependencies = [ "convert_case", "darling", @@ -6069,9 +6056,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "indexmap 2.7.0", "itoa", @@ -6460,9 +6447,9 @@ dependencies = [ [[package]] name = "starbase_shell" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41e10113494061625fcc45aa99ff3ef6817fc7f221f327fd52ccbf2161db7070" +checksum = "d4a1e16cb1a23e18cb58c0e4793a786a6b3a459bef6f689333ee7a65a379d6b4" dependencies = [ "regex", "sysinfo", @@ -7402,7 +7389,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acae98122dbacf133351b898ae29916c0faa263279e1ee7ab418b02e38aaaecf" dependencies = [ - "compact_str 0.8.1", + "compact_str", "human-sort", "regex", "schematic", @@ -7446,7 +7433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f735385fd761d474fef2af2b4bfaaf5c2ab7c7765e7ea730bee2b1f939a22f67" dependencies = [ "async-trait", - "compact_str 0.8.1", + "compact_str", "extism", "http-cache-reqwest", "miette 7.4.0", diff --git a/Cargo.toml b/Cargo.toml index 9fbb58fe297..b2e8103b436 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,16 +18,16 @@ default-members = ["crates/cli"] [workspace.dependencies] async-recursion = "1.1.1" -async-trait = "0.1.84" +async-trait = "0.1.85" cached = "0.54.0" chrono = { version = "0.4.39", features = ["serde"] } cd_env = "0.2.0" ci_env = "0.3.0" -clap = { version = "4.5.23", default-features = false, features = [ +clap = { version = "4.5.24", default-features = false, features = [ "std", "error-context", ] } -clap_complete = "4.5.40" +clap_complete = "4.5.41" compact_str = { version = "0.8.1", default-features = false, features = [ "serde", ] } @@ -55,7 +55,7 @@ reqwest = { version = "0.12.12", default-features = false, features = [ ] } rustc-hash = "2.1.0" scc = "2.2.5" -schematic = { version = "0.17.7", default-features = false, features = [ +schematic = { version = "0.17.8", default-features = false, features = [ "schema", ] } serial_test = "3.2.0" @@ -71,7 +71,7 @@ starbase_archive = { version = "0.9.0", default-features = false, features = [ ] } starbase_events = "0.6.6" starbase_sandbox = "0.8.0" -starbase_shell = "0.6.9" +starbase_shell = "0.6.10" starbase_styles = { version = "0.4.4", features = ["relative-path"] } starbase_utils = { version = "0.9.1", default-features = false, features = [ "editor-config", @@ -95,7 +95,7 @@ uuid = { version = "1.11.0", features = ["v4"] } # proto/plugin related extism = "=1.9.1" extism-pdk = "1.3.0" -proto_core = "0.44.2" +proto_core = "0.44.3" proto_installer = "0.8.0" system_env = "0.6.1" version_spec = "0.7.1" diff --git a/crates/common/src/consts.rs b/crates/common/src/consts.rs index 2b64c37f2c9..96952bd992e 100644 --- a/crates/common/src/consts.rs +++ b/crates/common/src/consts.rs @@ -6,4 +6,4 @@ pub const BIN_NAME: &str = "moon"; pub const CONFIG_DIRNAME: &str = ".moon"; -pub const PROTO_CLI_VERSION: &str = "0.44.2"; +pub const PROTO_CLI_VERSION: &str = "0.44.4"; diff --git a/crates/config/src/language_platform.rs b/crates/config/src/language_platform.rs index dc49098e509..a4e019b0047 100644 --- a/crates/config/src/language_platform.rs +++ b/crates/config/src/language_platform.rs @@ -35,7 +35,6 @@ impl LanguageType { pub fn get_toolchain_ids(&self) -> Vec { match self { Self::Bash | Self::Batch | Self::Unknown => vec![Id::raw("system")], - Self::TypeScript => vec![Id::raw("typescript"), Id::raw("javascript")], Self::Other(id) => vec![id.to_owned(), Id::raw("system")], other => vec![Id::raw(other.to_string().to_lowercase())], } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 72546f5c8d1..c24eda372d0 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::disallowed_types)] // schematic + #[cfg(feature = "loader")] mod config_cache; mod config_finder; diff --git a/crates/config/tests/toolchain_config_test.rs b/crates/config/tests/toolchain_config_test.rs index e10201002ce..a9c7ae46d56 100644 --- a/crates/config/tests/toolchain_config_test.rs +++ b/crates/config/tests/toolchain_config_test.rs @@ -201,7 +201,7 @@ deno: {{}} assert_eq!( config.bun.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/bun_tool-v0.14.0/bun_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/bun_tool-v0.14.0/bun_tool.wasm".into() })) ); } @@ -404,7 +404,7 @@ deno: assert_eq!( config.deno.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/deno_tool-v0.13.0/deno_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/deno_tool-v0.13.0/deno_tool.wasm".into() })) ); } @@ -531,7 +531,7 @@ node: assert_eq!( config.node.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/node_tool-v0.13.0/node_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/node_tool-v0.13.0/node_tool.wasm".into() })) ); } @@ -635,7 +635,7 @@ node: assert_eq!( config.node.unwrap().npm.plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() })) ); } @@ -727,7 +727,7 @@ node: assert_eq!( config.node.unwrap().pnpm.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() })) ); } @@ -751,7 +751,7 @@ node: assert_eq!( config.node.unwrap().pnpm.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() })) ); } @@ -853,7 +853,7 @@ node: assert_eq!( config.node.unwrap().yarn.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() })) ); } @@ -877,7 +877,7 @@ node: assert_eq!( config.node.unwrap().yarn.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into() })) ); } @@ -979,7 +979,7 @@ node: assert_eq!( config.node.unwrap().bun.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/bun_tool-v0.14.0/bun_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/bun_tool-v0.14.0/bun_tool.wasm".into() })) ); } @@ -1003,7 +1003,7 @@ node: assert_eq!( config.node.unwrap().bun.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/bun_tool-v0.14.0/bun_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/bun_tool-v0.14.0/bun_tool.wasm".into() })) ); } @@ -1168,7 +1168,7 @@ node: assert_eq!( config.python.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/python_tool-v0.12.2/python_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/python_tool-v0.12.2/python_tool.wasm".into() })) ); } @@ -1333,7 +1333,7 @@ rust: assert_eq!( config.rust.unwrap().plugin.unwrap(), PluginLocator::Url(Box::new(UrlLocator { - url: "https://github.com/moonrepo/tools/releases/download/rust_tool-v0.12.0/rust_tool.wasm".into() + url: "https://github.com/moonrepo/plugins/releases/download/rust_tool-v0.12.0/rust_tool.wasm".into() })) ); } diff --git a/crates/project-builder/src/project_builder.rs b/crates/project-builder/src/project_builder.rs index 748d959bb05..3a7489dd1da 100644 --- a/crates/project-builder/src/project_builder.rs +++ b/crates/project-builder/src/project_builder.rs @@ -9,7 +9,9 @@ use moon_file_group::FileGroup; use moon_project::Project; use moon_task::{TargetScope, Task}; use moon_task_builder::{TasksBuilder, TasksBuilderContext}; -use moon_toolchain::detect::{detect_project_language, detect_project_toolchains}; +use moon_toolchain::detect::{ + detect_project_language, detect_project_toolchains, get_project_toolchains, +}; use rustc_hash::FxHashMap; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; @@ -38,7 +40,14 @@ pub struct ProjectBuilder<'app> { root: PathBuf, pub language: LanguageType, - pub toolchains: Vec, + + // Toolchains that will be used as the fallback for tasks. + // These are filtered based on enabled. + pub toolchains_tasks: Vec, + + // Toolchains that will be used for task/config inheritance. + // These are *not* filtered based on enabled. + pub toolchains_config: Vec, } impl<'app> ProjectBuilder<'app> { @@ -63,7 +72,8 @@ impl<'app> ProjectBuilder<'app> { global_config: None, local_config: None, language: LanguageType::Unknown, - toolchains: vec![], + toolchains_tasks: vec![], + toolchains_config: vec![], }) } @@ -79,7 +89,7 @@ impl<'app> ProjectBuilder<'app> { .expect("Local config must be loaded before global config!"); let global_config = tasks_manager.get_inherited_config( - &self.toolchains, + &self.toolchains_config, &local_config.stack, &local_config.type_of, &local_config.tags, @@ -114,28 +124,18 @@ impl<'app> ProjectBuilder<'app> { config.language.clone() }; - // Infer toolchains from language - if self.toolchains.is_empty() { - let mut added = false; - - if let Some(default_id) = &config.toolchain.default { - if self.context.enabled_toolchains.contains(default_id) { - self.toolchains.push(default_id.to_owned()); - added = true; - } - } + // Infer toolchains from the language as it handles the chain correctly: + // For example: node -> javascript, and not just node + if self.toolchains_tasks.is_empty() { + let mut toolchains = vec![]; - // TODO remove in 2.0 #[allow(deprecated)] - if !added && config.platform.is_some() { - if let Some(platform) = &config.platform { - let default_id = platform.get_toolchain_id(); + if let Some(default_id) = &config.toolchain.default { + toolchains.extend(get_project_toolchains(default_id, &self.language)); + } else if let Some(platform) = &config.platform { + let default_id = platform.get_toolchain_id(); - if self.context.enabled_toolchains.contains(&default_id) { - self.toolchains.push(default_id); - added = true; - } - } + toolchains.extend(get_project_toolchains(&default_id, &self.language)); debug!( project_id = self.id.as_str(), @@ -143,21 +143,25 @@ impl<'app> ProjectBuilder<'app> { color::property("platform"), color::property("toolchain.default"), ); - } - - if !added { - self.toolchains = detect_project_toolchains( + } else { + toolchains.extend(detect_project_toolchains( self.context.workspace_root, &self.root, &self.language, - self.context.enabled_toolchains, - ); + )); } + self.toolchains_config.extend(toolchains.clone()); + + self.toolchains_tasks = toolchains + .into_iter() + .filter(|id| self.context.enabled_toolchains.contains(id)) + .collect(); + trace!( project_id = self.id.as_str(), language = ?self.language, - toolchains = ?self.toolchains.iter().map(|tc| tc.as_str()).collect::>(), + toolchains = ?self.toolchains_tasks.iter().map(|tc| tc.as_str()).collect::>(), "Unknown tasks toolchain, inferring from project language", ); } @@ -230,7 +234,12 @@ impl<'app> ProjectBuilder<'app> { language: self.language, root: self.root, source: self.source.to_owned(), - toolchains: self.toolchains, + // Should this be the config one? + toolchains: if self.toolchains_tasks.is_empty() { + vec![Id::raw("system")] + } else { + self.toolchains_tasks + }, ..Project::default() }; @@ -372,7 +381,7 @@ impl<'app> ProjectBuilder<'app> { let mut tasks_builder = TasksBuilder::new( self.id, self.source, - &self.toolchains, + &self.toolchains_tasks, TasksBuilderContext { enabled_toolchains: self.context.enabled_toolchains, monorepo: self.context.monorepo, diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/javascript.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/javascript.yml new file mode 100644 index 00000000000..ccad4eebb08 --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/javascript.yml @@ -0,0 +1,3 @@ +tasks: + global-javascript: + command: global-javascript diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/kotlin.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/kotlin.yml new file mode 100644 index 00000000000..fc3e462108a --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/kotlin.yml @@ -0,0 +1,3 @@ +tasks: + global-kotlin: + command: global-kotlin diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/system.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/system.yml new file mode 100644 index 00000000000..777def8ce1c --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/system.yml @@ -0,0 +1,3 @@ +tasks: + global-system: + command: global-system diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/typescript.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/typescript.yml new file mode 100644 index 00000000000..e36d3a61238 --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/.moon/tasks/typescript.yml @@ -0,0 +1,3 @@ +tasks: + global-typescript: + command: global-typescript diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/bun-with-ts/moon.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/bun-with-ts/moon.yml new file mode 100644 index 00000000000..079daaa12a5 --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/bun-with-ts/moon.yml @@ -0,0 +1,7 @@ +platform: bun +language: typescript + +tasks: + bun: + command: bun + platform: bun diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/bun/moon.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/bun/moon.yml new file mode 100644 index 00000000000..53f850f4647 --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/bun/moon.yml @@ -0,0 +1,6 @@ +platform: bun + +tasks: + bun: + command: bun + platform: bun diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/deno/moon.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/deno/moon.yml new file mode 100644 index 00000000000..6c67c594360 --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/deno/moon.yml @@ -0,0 +1,6 @@ +platform: deno + +tasks: + deno: + command: deno + platform: deno diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/kotlin-app/moon.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/kotlin-app/moon.yml new file mode 100644 index 00000000000..1f26063f815 --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/kotlin-app/moon.yml @@ -0,0 +1,6 @@ +type: application +language: kotlin + +tasks: + kotlin-app: + command: kotlin-app diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/node-library/moon.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/node-library/moon.yml index afefba681fd..13b180c3862 100644 --- a/crates/project-graph/tests/__fixtures__/inheritance/scoped/node-library/moon.yml +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/node-library/moon.yml @@ -1,6 +1,8 @@ -platform: node type: library +toolchain: + default: node + tasks: node-library: command: node-library diff --git a/crates/project-graph/tests/__fixtures__/inheritance/scoped/ruby-tool/moon.yml b/crates/project-graph/tests/__fixtures__/inheritance/scoped/ruby-tool/moon.yml new file mode 100644 index 00000000000..b0b449f06fe --- /dev/null +++ b/crates/project-graph/tests/__fixtures__/inheritance/scoped/ruby-tool/moon.yml @@ -0,0 +1,5 @@ +language: ruby + +tasks: + ruby-tool: + command: ruby-tool diff --git a/crates/project-graph/tests/project_graph_test.rs b/crates/project-graph/tests/project_graph_test.rs index df1a96e5e66..39cb8738a39 100644 --- a/crates/project-graph/tests/project_graph_test.rs +++ b/crates/project-graph/tests/project_graph_test.rs @@ -506,9 +506,25 @@ mod project_graph { assert_eq!( map_ids_from_target(graph.get_project("node").unwrap().task_targets.clone()), - ["global", "global-node", "node"] + ["global", "global-javascript", "global-node", "node"] ); + assert_eq!( + map_ids_from_target( + graph + .get_project("system-library") + .unwrap() + .task_targets + .clone() + ), + ["global", "global-system", "system-library"] + ); + } + + #[tokio::test] + async fn inherits_scoped_tasks_for_tier3_language() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; + assert_eq!( map_ids_from_target( graph @@ -519,21 +535,83 @@ mod project_graph { ), [ "global", + "global-javascript", "global-node", "global-node-library", "node-library" ] ); + } + + #[tokio::test] + async fn inherits_scoped_tasks_for_tier2_language() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; + + assert_eq!( + map_ids_from_target(graph.get_project("ruby-tool").unwrap().task_targets.clone()), + ["global", "ruby-tool"] + ); + } + + #[tokio::test] + async fn inherits_scoped_tasks_for_custom_language() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; assert_eq!( map_ids_from_target( graph - .get_project("system-library") + .get_project("kotlin-app") + .unwrap() + .task_targets + .clone() + ), + ["global", "global-kotlin", "global-system", "kotlin-app"] + ); + } + + #[tokio::test] + async fn inherits_js_tasks_for_bun_toolchain() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; + + assert_eq!( + map_ids_from_target(graph.get_project("bun").unwrap().task_targets.clone()), + ["bun", "global", "global-javascript"] + ); + } + + #[tokio::test] + async fn inherits_js_tasks_for_deno_toolchain() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; + + assert_eq!( + map_ids_from_target(graph.get_project("deno").unwrap().task_targets.clone()), + ["deno", "global", "global-javascript"] + ); + } + + #[tokio::test] + async fn inherits_js_tasks_for_node_toolchain() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; + + assert_eq!( + map_ids_from_target(graph.get_project("node").unwrap().task_targets.clone()), + ["global", "global-javascript", "global-node", "node"] + ); + } + + #[tokio::test] + async fn inherits_ts_tasks_instead_of_js() { + let graph = generate_inheritance_project_graph("inheritance/scoped").await; + + assert_eq!( + map_ids_from_target( + graph + .get_project("bun-with-ts") .unwrap() .task_targets .clone() ), - ["global", "system-library"] + ["bun", "global", "global-typescript"] ); } diff --git a/crates/task-builder/tests/tasks_builder_test.rs b/crates/task-builder/tests/tasks_builder_test.rs index d0a0ae5deec..0a46fa49901 100644 --- a/crates/task-builder/tests/tasks_builder_test.rs +++ b/crates/task-builder/tests/tasks_builder_test.rs @@ -21,12 +21,8 @@ async fn build_tasks_with_config( let id = Id::raw("project"); let source = WorkspaceRelativePathBuf::from(source); let enabled_toolchains = toolchain_config.get_enabled(); - let project_toolchains = detect_project_toolchains( - root, - &root.join(source.as_str()), - &local_config.language, - &enabled_toolchains, - ); + let project_toolchains = + detect_project_toolchains(root, &root.join(source.as_str()), &local_config.language); let mut builder = TasksBuilder::new( &id, @@ -164,55 +160,59 @@ mod tasks_builder { assert!(!test.state.local_only); } - #[tokio::test] - async fn inherits_global_tasks() { - let sandbox = create_sandbox("builder"); - let tasks = build_tasks(sandbox.path(), "local/moon.yml").await; + mod inheritance { + use super::*; - let build = tasks.get("local-build").unwrap(); + #[tokio::test] + async fn inherits_global_tasks() { + let sandbox = create_sandbox("builder"); + let tasks = build_tasks(sandbox.path(), "local/moon.yml").await; - assert_eq!(build.command, "local-build"); - assert_eq!( - build.inputs, - vec![ - InputPath::ProjectFile("abc".into()), - InputPath::WorkspaceGlob(".moon/*.yml".into()), - ] - ); - assert_eq!(build.outputs, vec![OutputPath::ProjectFile("out".into())]); - assert!(!build.state.local_only); + let build = tasks.get("local-build").unwrap(); - let run = tasks.get("local-run").unwrap(); + assert_eq!(build.command, "local-build"); + assert_eq!( + build.inputs, + vec![ + InputPath::ProjectFile("abc".into()), + InputPath::WorkspaceGlob(".moon/*.yml".into()), + ] + ); + assert_eq!(build.outputs, vec![OutputPath::ProjectFile("out".into())]); + assert!(!build.state.local_only); - assert_eq!(run.command, "local-run"); - assert_eq!( - run.inputs, - vec![ - InputPath::ProjectFile("xyz".into()), - InputPath::WorkspaceGlob(".moon/*.yml".into()), - ] - ); - assert_eq!(run.outputs, vec![]); - assert!(run.state.local_only); - } + let run = tasks.get("local-run").unwrap(); - #[tokio::test] - async fn inherits_global_tasks_from_all_scopes() { - let sandbox = create_sandbox("builder"); - let tasks = build_tasks_with_toolchain(sandbox.path(), "scopes/moon.yml").await; + assert_eq!(run.command, "local-run"); + assert_eq!( + run.inputs, + vec![ + InputPath::ProjectFile("xyz".into()), + InputPath::WorkspaceGlob(".moon/*.yml".into()), + ] + ); + assert_eq!(run.outputs, vec![]); + assert!(run.state.local_only); + } - assert_eq!( - tasks.keys().map(|k| k.as_str()).collect::>(), - vec![ - "global-build", - "global-run", - "global-test", - "local", - "node", - "node-application", - "tag" - ] - ); + #[tokio::test] + async fn inherits_global_tasks_from_all_scopes() { + let sandbox = create_sandbox("builder"); + let tasks = build_tasks_with_toolchain(sandbox.path(), "scopes/moon.yml").await; + + assert_eq!( + tasks.keys().map(|k| k.as_str()).collect::>(), + vec![ + "global-build", + "global-run", + "global-test", + "local", + "node", + "node-application", + "tag" + ] + ); + } } mod defaults { diff --git a/crates/toolchain/src/detect/project_toolchain.rs b/crates/toolchain/src/detect/project_toolchain.rs index c9a9e554a36..2f36ba4b18d 100644 --- a/crates/toolchain/src/detect/project_toolchain.rs +++ b/crates/toolchain/src/detect/project_toolchain.rs @@ -1,54 +1,64 @@ use super::languages::{BUN, DENO, NODE}; use super::project_language::has_language_files; use moon_common::Id; -use moon_config::LanguageType; +use moon_config::{LanguageType, PlatformType}; +use std::convert::TryFrom; use std::path::Path; +/// Return a list of toolchains based on the provided ID. +pub fn get_project_toolchains(id: &Id, language: &LanguageType) -> Vec { + let mut toolchains = vec![id.to_owned()]; + + // Since JS has multiple runtimes, we should inherit JS/TS also + if id == "bun" || id == "deno" || id == "node" { + toolchains.push(if matches!(language, LanguageType::TypeScript) { + Id::raw("typescript") + } else { + Id::raw("javascript") + }); + } + // Otherwise check if we're a supported platform, if not, inherit system + else if PlatformType::try_from(id.as_str()).is_err() { + toolchains.push(Id::raw("system")); + } + + toolchains +} + +// Detect the correct toolchains based on the project's language +// and what config files exist in the project root. pub fn detect_project_toolchains( workspace_root: &Path, project_root: &Path, language: &LanguageType, - enabled_toolchains: &[Id], ) -> Vec { let mut toolchains = vec![]; - match language { - LanguageType::JavaScript | LanguageType::TypeScript => { - let runtimes = vec![ - (Id::raw("deno"), DENO), - (Id::raw("bun"), BUN), - (Id::raw("node"), NODE), - ]; - - for (id, files) in runtimes { - // Detect in project first - if has_language_files(project_root, files) { - toolchains.push(id); - break; - } - - // Then in workspace - if has_language_files(workspace_root, files) { - toolchains.push(id); - break; - } + if matches!( + language, + LanguageType::JavaScript | LanguageType::TypeScript + ) { + let runtimes = vec![ + (Id::raw("deno"), DENO), + (Id::raw("bun"), BUN), + (Id::raw("node"), NODE), + ]; + + for (id, files) in runtimes { + // Detect in project first + if has_language_files(project_root, files) { + toolchains.push(id); + break; } - toolchains.extend(language.get_toolchain_ids()); - } - other => { - toolchains.push(Id::raw(other.to_string())); + // Then in workspace + if has_language_files(workspace_root, files) { + toolchains.push(id); + break; + } } - }; - - let mut toolchains = toolchains - .into_iter() - .filter(|id| enabled_toolchains.contains(id)) - .collect::>(); - - if toolchains.is_empty() { - toolchains.push(Id::raw("system")); } + toolchains.extend(language.get_toolchain_ids()); toolchains } diff --git a/legacy/core/tool/src/lib.rs b/legacy/core/tool/src/lib.rs index c9d63b310bf..e0f6cb39656 100644 --- a/legacy/core/tool/src/lib.rs +++ b/legacy/core/tool/src/lib.rs @@ -88,6 +88,7 @@ pub fn get_proto_env_vars() -> FxHashMap { ("PROTO_NO_PROGRESS".into(), "true".into()), // ("PROTO_LOG".into(), "trace".into()), ("PROTO_VERSION".into(), PROTO_CLI_VERSION.into()), + ("STARBASE_FORCE_TTY".into(), "true".into()), ]) } diff --git a/website/blog/2024-07-26_proto-v0.39.mdx b/website/blog/2024-07-26_proto-v0.39.mdx index 2b14771a876..644f50a6f56 100644 --- a/website/blog/2024-07-26_proto-v0.39.mdx +++ b/website/blog/2024-07-26_proto-v0.39.mdx @@ -78,4 +78,4 @@ of changes. (for automated workflows). - Updated `proto status` to display and include versions from ecosystem files (`.nvmrc`, etc). - Updated `github://` plugin locators to support monorepos. Append the project name (that tags are - prefixed with) to the path: `github://moonrepo/tools/node_tool` + prefixed with) to the path: `github://moonrepo/plugins/node_tool` diff --git a/website/docs/proto/commands/activate.mdx b/website/docs/proto/commands/activate.mdx index d9622715774..0fa2eb94ab3 100644 --- a/website/docs/proto/commands/activate.mdx +++ b/website/docs/proto/commands/activate.mdx @@ -119,7 +119,7 @@ use proto-hook.nu Add the following line to the end of your profile (`$PROFILE`). ```shell -Invoke-Expression "$(proto activate pwsh)" +proto activate pwsh | Out-String | Invoke-Expression ``` #### Zsh diff --git a/website/docs/proto/commands/plugin/info.mdx b/website/docs/proto/commands/plugin/info.mdx index 7b4987ef3b6..a9f17e5e2ef 100644 --- a/website/docs/proto/commands/plugin/info.mdx +++ b/website/docs/proto/commands/plugin/info.mdx @@ -18,7 +18,7 @@ Plugin ──────────────────────── Name: Node.js Type: Language Version: 0.13.0 - Source URL: https://github.com/moonrepo/tools/releases/download/node_tool-v0.13.0/node_tool.wasm + Source URL: https://github.com/moonrepo/plugins/releases/download/node_tool-v0.13.0/node_tool.wasm Inventory ────────────────────────────── diff --git a/website/docs/proto/commands/plugin/list.mdx b/website/docs/proto/commands/plugin/list.mdx index d3c5b88a90e..04ec9ee4353 100644 --- a/website/docs/proto/commands/plugin/list.mdx +++ b/website/docs/proto/commands/plugin/list.mdx @@ -20,7 +20,7 @@ $ proto plugin list --versions Bun ──────────────────────────────────── ID: bun - Source URL: https://github.com/moonrepo/tools/releases/download/bun_tool-v0.14.0/bun_tool.wasm + Source URL: https://github.com/moonrepo/plugins/releases/download/bun_tool-v0.14.0/bun_tool.wasm Store directory: /Users/miles/.proto/tools/bun Versions: 1.1.42 - installed 12/25/24, fallback version @@ -28,7 +28,7 @@ Bun ───────────────────────── Deno ─────────────────────────────────── ID: deno - Source URL: https://github.com/moonrepo/tools/releases/download/deno_tool-v0.13.0/deno_tool.wasm + Source URL: https://github.com/moonrepo/plugins/releases/download/deno_tool-v0.13.0/deno_tool.wasm Store directory: /Users/miles/.proto/tools/deno Versions: 1.30.0 - installed 02/01/24, last used 11/28/24 @@ -38,7 +38,7 @@ Deno ───────────────────────── Go ───────────────────────────────────── ID: go - Source URL: https://github.com/moonrepo/tools/releases/download/go_tool-v0.14.0/go_tool.wasm + Source URL: https://github.com/moonrepo/plugins/releases/download/go_tool-v0.14.0/go_tool.wasm Store directory: /Users/miles/.proto/tools/go Versions: 1.18.0 - installed 12/25/24, fallback version diff --git a/website/docs/proto/wasm-plugin.mdx b/website/docs/proto/wasm-plugin.mdx index 95b07604f3d..36711a9d25f 100644 --- a/website/docs/proto/wasm-plugin.mdx +++ b/website/docs/proto/wasm-plugin.mdx @@ -521,7 +521,7 @@ to build and publish your plugin. Some helpful resources for learning about and building plugins. -- [Official proto WASM plugins](https://github.com/moonrepo/tools) +- [Official proto WASM plugins](https://github.com/moonrepo/plugins) - Plugin development kit - [`proto_pdk` docs](https://docs.rs/proto_pdk/) - [`proto_pdk_test_utils` docs](https://docs.rs/proto_pdk_test_utils/)