diff --git a/CHANGELOG.md b/CHANGELOG.md index 0539bc0906e..d21a9fe8992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ #### 🚀 Updates +- We are deprecating the concept of a task "platform", as this is required for the next step in supporting WASM based toolchain plugins. Going forward, any reference to platform is now a toolchain. The following changes have been made: + - Deprecated the `platform` task setting, use `toolchain` instead. + - Deprecated the `taskPlatform` query field, use `taskToolchain` instead. + - Removed the top-level `platform` setting from `moon.yml`. The toolchain is now inferred from the top-level `language` setting. - Updated task option `runInCI` to support the values "always" (always run) and "affected" (only run if affected, same as `true`). diff --git a/crates/app/src/commands/project.rs b/crates/app/src/commands/project.rs index 4ae9509e7c5..ee46a44af9d 100644 --- a/crates/app/src/commands/project.rs +++ b/crates/app/src/commands/project.rs @@ -75,14 +75,10 @@ pub async fn project(session: CliSession, args: ProjectArgs) -> AppResult { console.print_entry("Root", color::path(&project.root))?; } - if let Some(toolchain) = &project.toolchain { - console.print_entry("Toolchain", toolchain)?; - } - - if project.platform.is_javascript() { - console.print_entry("Platform", format!("{}", &project.platform))?; - } - + console.print_entry( + "Toolchains", + project.language.get_toolchain_ids().join(", "), + )?; console.print_entry("Language", format!("{}", &project.language))?; console.print_entry("Stack", format!("{}", &project.stack))?; console.print_entry("Type", format!("{}", &project.type_of))?; diff --git a/crates/app/src/commands/task.rs b/crates/app/src/commands/task.rs index 2855b060779..d54a0b11c59 100644 --- a/crates/app/src/commands/task.rs +++ b/crates/app/src/commands/task.rs @@ -44,8 +44,7 @@ pub async fn task(session: CliSession, args: TaskArgs) -> AppResult { console.print_entry("Task", color::id(&args.target.task_id))?; console.print_entry("Project", color::id(&project.id))?; console.print_entry("Toolchains", task.toolchains.join(", "))?; - console.print_entry("Platform", format!("{}", &task.platform))?; - console.print_entry("Type", format!("{}", &task.type_of))?; + console.print_entry("Type", task.type_of.to_string())?; let mut modes = vec![]; diff --git a/crates/config/src/language_platform.rs b/crates/config/src/language_platform.rs index 7544a1319e9..22895f3a024 100644 --- a/crates/config/src/language_platform.rs +++ b/crates/config/src/language_platform.rs @@ -72,6 +72,7 @@ impl Serialize for LanguageType { } } +// TODO: Remove in 2.0 derive_enum!( /// Platforms that each programming language can belong to. #[derive(ConfigEnum, Copy, Default, Hash)] @@ -105,9 +106,9 @@ impl PlatformType { pub fn get_toolchain_ids(&self) -> Vec { match self { - PlatformType::Bun => vec![Id::raw("bun"), Id::raw("javascript")], - PlatformType::Deno => vec![Id::raw("deno"), Id::raw("javascript")], - PlatformType::Node => vec![Id::raw("node"), Id::raw("javascript")], + PlatformType::Bun => vec![Id::raw("bun")], + PlatformType::Deno => vec![Id::raw("deno")], + PlatformType::Node => vec![Id::raw("node")], PlatformType::Python => vec![Id::raw("python")], PlatformType::Rust => vec![Id::raw("rust")], PlatformType::System => vec![Id::raw("system")], diff --git a/crates/config/src/patterns.rs b/crates/config/src/patterns.rs index 3bfbcb970ae..23369252ea6 100644 --- a/crates/config/src/patterns.rs +++ b/crates/config/src/patterns.rs @@ -27,9 +27,9 @@ pattern!(TOKEN_FUNC, "@([a-z]+)\\(([0-9A-Za-z_-]+)\\)"); pattern!(TOKEN_FUNC_DISTINCT, "^@([a-z]+)\\(([0-9A-Za-z_-]+)\\)$"); pattern!( TOKEN_VAR, - "\\$(arch|language|osFamily|os|projectAlias|projectChannel|projectName|projectOwner|projectRoot|projectSource|projectStack|projectType|project|target|taskPlatform|taskType|task|timestamp|datetime|date|time|vcsBranch|vcsRepository|vcsRevision|workingDir|workspaceRoot)" + "\\$(arch|language|osFamily|os|projectAlias|projectChannel|projectName|projectOwner|projectRoot|projectSource|projectStack|projectType|project|target|taskPlatform|taskToolchain|taskToolchains|taskType|task|timestamp|datetime|date|time|vcsBranch|vcsRepository|vcsRevision|workingDir|workspaceRoot)" ); pattern!( TOKEN_VAR_DISTINCT, - "^\\$(arch|language|osFamily|os|projectAlias|projectChannel|projectName|projectOwner|projectRoot|projectSource|projectStack|projectType|project|target|taskPlatform|taskType|task|timestamp|datetime|date|time|vcsBranch|vcsRepository|vcsRevision|workingDir|workspaceRoot)$" + "^\\$(arch|language|osFamily|os|projectAlias|projectChannel|projectName|projectOwner|projectRoot|projectSource|projectStack|projectType|project|target|taskPlatform|taskToolchain|taskToolchains|taskType|task|timestamp|datetime|date|time|vcsBranch|vcsRepository|vcsRevision|workingDir|workspaceRoot)$" ); diff --git a/crates/config/src/project/task_config.rs b/crates/config/src/project/task_config.rs index d3a80f4c84b..ec5eecc20ea 100644 --- a/crates/config/src/project/task_config.rs +++ b/crates/config/src/project/task_config.rs @@ -223,6 +223,7 @@ cacheable!( /// available binaries, lookup paths, and more. When not provided, will /// be automatically detected. #[deprecated(note = "Use `toolchain` instead.")] + // TODO: Remove in 2.0 pub platform: PlatformType, /// The preset to apply for the task. Will inherit default options. diff --git a/crates/config/src/shapes/poly.rs b/crates/config/src/shapes/poly.rs index 4d878e84737..6e0f01f89c1 100644 --- a/crates/config/src/shapes/poly.rs +++ b/crates/config/src/shapes/poly.rs @@ -20,7 +20,7 @@ impl Default for OneOrMany { impl OneOrMany { pub fn is_empty(&self) -> bool { match self { - Self::One(item) => false, + Self::One(_) => false, Self::Many(list) => list.is_empty(), } } diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 3c02924a6a4..0189d9792de 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -44,6 +44,7 @@ cacheable!( pub language: LanguageType, /// Default platform to run tasks against. + // TODO REMOVE #[deprecated] pub platform: PlatformType, @@ -65,9 +66,6 @@ cacheable!( /// Includes internal tasks! pub task_targets: Vec, - /// Default toolchain to run tasks against. - pub toolchain: Option, - /// The type of project. #[serde(rename = "type")] pub type_of: ProjectType, diff --git a/crates/task-builder/src/tasks_builder.rs b/crates/task-builder/src/tasks_builder.rs index dcae870d689..a1ce1b6870e 100644 --- a/crates/task-builder/src/tasks_builder.rs +++ b/crates/task-builder/src/tasks_builder.rs @@ -470,6 +470,7 @@ impl<'proj> TasksBuilder<'proj> { // Backwards compat for when the user has explicitly configured // the deprecated `platform` setting + // TODO: Remove in 2.0 #[allow(deprecated)] if !task.platform.is_unknown() && task.toolchains.is_empty() { task.toolchains = task.platform.get_toolchain_ids(); diff --git a/crates/task-expander/src/token_expander.rs b/crates/task-expander/src/token_expander.rs index 909b459d82b..e0355b80d95 100644 --- a/crates/task-expander/src/token_expander.rs +++ b/crates/task-expander/src/token_expander.rs @@ -585,8 +585,7 @@ impl<'graph> TokenExpander<'graph> { // Task "target" => Cow::Borrowed(task.target.as_str()), "task" => Cow::Borrowed(task.id.as_str()), - "taskPlatform" => Cow::Owned(task.platform.to_string()), - "taskToolchain" => Cow::Borrowed(task.toolchains[0].as_str()), + "taskPlatform" | "taskToolchain" => Cow::Borrowed(task.toolchains[0].as_str()), "taskToolchains" => Cow::Owned(task.toolchains.join(",")), "taskType" => Cow::Owned(task.type_of.to_string()), // Datetime diff --git a/crates/task/src/task.rs b/crates/task/src/task.rs index 7de41ee1b68..7fd535d724c 100644 --- a/crates/task/src/task.rs +++ b/crates/task/src/task.rs @@ -229,11 +229,7 @@ impl Task { /// Return true of the task will run in the system toolchain. pub fn is_system_toolchain(&self) -> bool { - if self.toolchains.is_empty() { - self.platform.is_system() - } else { - self.toolchains.len() == 1 && self.toolchains[0] == "system" - } + self.toolchains.is_empty() || self.toolchains.len() == 1 && self.toolchains[0] == "system" } /// Return true if the task is a "test" type. diff --git a/legacy/bun/platform/src/lib.rs b/legacy/bun/platform/src/lib.rs index 5cdad25d028..617a73140d1 100644 --- a/legacy/bun/platform/src/lib.rs +++ b/legacy/bun/platform/src/lib.rs @@ -5,7 +5,7 @@ mod target_hash; pub use bun_platform::*; use moon_common::Id; -use moon_config::{NodePackageManager, PartialTaskConfig, PlatformType}; +use moon_config::{NodePackageManager, PartialTaskConfig}; use moon_javascript_platform::ScriptParser; use moon_node_lang::PackageJsonCache; use std::collections::BTreeMap; @@ -14,7 +14,7 @@ pub fn infer_tasks_from_scripts( project_id: &str, package_json: &PackageJsonCache, ) -> miette::Result> { - let mut parser = ScriptParser::new(project_id, PlatformType::Bun, NodePackageManager::Bun); + let mut parser = ScriptParser::new(project_id, Id::raw("bun"), NodePackageManager::Bun); parser.infer_scripts(package_json)?; diff --git a/legacy/javascript/platform/src/infer_tasks.rs b/legacy/javascript/platform/src/infer_tasks.rs index acd859d22ff..d45c355153a 100644 --- a/legacy/javascript/platform/src/infer_tasks.rs +++ b/legacy/javascript/platform/src/infer_tasks.rs @@ -1,8 +1,8 @@ use moon_args::split_args; use moon_common::Id; use moon_config::{ - NodePackageManager, OutputPath, PartialTaskArgs, PartialTaskConfig, PartialTaskDependency, - PlatformType, + NodePackageManager, OneOrMany, OutputPath, PartialTaskArgs, PartialTaskConfig, + PartialTaskDependency, }; use moon_node_lang::package_json::{PackageJsonCache, ScriptsMap}; use moon_target::Target; @@ -134,7 +134,7 @@ pub fn create_task( script_name: &str, script: &str, context: TaskContext, - platform: PlatformType, + toolchain: &Id, pm: NodePackageManager, ) -> miette::Result { let is_wrapping = matches!(context, TaskContext::WrapRunScript); @@ -173,7 +173,7 @@ pub fn create_task( } if is_wrapping { - task_config.platform = Some(platform); + task_config.toolchain = Some(OneOrMany::One(toolchain.to_owned())); task_config.command = Some(PartialTaskArgs::List(string_vec![ match pm { NodePackageManager::Bun => "bun", @@ -189,14 +189,7 @@ pub fn create_task( if is_bash_script(command) { args.insert(0, "bash".to_owned()); } else if is_node_script(command) { - args.insert( - 0, - if platform == PlatformType::Bun { - "bun".to_owned() - } else { - "node".to_owned() - }, - ); + args.insert(0, toolchain.as_str().to_owned()); } else { // Already there } @@ -204,11 +197,13 @@ pub fn create_task( args.insert(0, "noop".to_owned()); } - task_config.platform = Some(if is_system_command(&args[0]) || &args[0] == "noop" { - PlatformType::System - } else { - platform - }); + task_config.toolchain = Some(OneOrMany::One( + if is_system_command(&args[0]) || &args[0] == "noop" { + Id::raw("system") + } else { + toolchain.to_owned() + }, + )); task_config.command = Some(if args.len() == 1 { PartialTaskArgs::String(args.remove(0)) } else { @@ -263,12 +258,12 @@ pub struct ScriptParser<'a> { /// Scripts that ran into issues while parsing. unresolved_scripts: ScriptsMap, - platform: PlatformType, + toolchain: Id, pm: NodePackageManager, } impl<'a> ScriptParser<'a> { - pub fn new(project_id: &'a str, platform: PlatformType, pm: NodePackageManager) -> Self { + pub fn new(project_id: &'a str, toolchain: Id, pm: NodePackageManager) -> Self { ScriptParser { life_cycles: ScriptsMap::default(), names_to_ids: FxHashMap::default(), @@ -278,7 +273,7 @@ impl<'a> ScriptParser<'a> { scripts: ScriptsMap::default(), tasks: BTreeMap::new(), unresolved_scripts: ScriptsMap::default(), - platform, + toolchain, pm, } } @@ -307,7 +302,7 @@ impl<'a> ScriptParser<'a> { name, script, TaskContext::WrapRunScript, - self.platform, + &self.toolchain, self.pm, )?, ); @@ -494,7 +489,7 @@ impl<'a> ScriptParser<'a> { name, value, TaskContext::ConvertToTask, - self.platform, + &self.toolchain, self.pm, )?, ); diff --git a/legacy/node/platform/src/lib.rs b/legacy/node/platform/src/lib.rs index 84393b1b6de..093608a4ff2 100644 --- a/legacy/node/platform/src/lib.rs +++ b/legacy/node/platform/src/lib.rs @@ -6,7 +6,7 @@ pub use node_platform::NodePlatform; pub use target_hash::NodeTargetHash; use moon_common::Id; -use moon_config::{NodePackageManager, PartialTaskConfig, PlatformType}; +use moon_config::{NodePackageManager, PartialTaskConfig}; use moon_javascript_platform::ScriptParser; use moon_node_lang::PackageJsonCache; use std::collections::BTreeMap; @@ -16,7 +16,7 @@ pub fn create_tasks_from_scripts( package_json: &mut PackageJsonCache, package_manager: NodePackageManager, ) -> miette::Result> { - let mut parser = ScriptParser::new(project_id, PlatformType::Node, package_manager); + let mut parser = ScriptParser::new(project_id, Id::raw("node"), package_manager); parser.parse_scripts(package_json)?; parser.update_package(package_json)?; @@ -29,7 +29,7 @@ pub fn infer_tasks_from_scripts( package_json: &PackageJsonCache, package_manager: NodePackageManager, ) -> miette::Result> { - let mut parser = ScriptParser::new(project_id, PlatformType::Node, package_manager); + let mut parser = ScriptParser::new(project_id, Id::raw("node"), package_manager); parser.infer_scripts(package_json)?;