diff --git a/crates/app/src/commands/query.rs b/crates/app/src/commands/query.rs index 80695d11c00..d0146ffa83f 100644 --- a/crates/app/src/commands/query.rs +++ b/crates/app/src/commands/query.rs @@ -337,6 +337,7 @@ pub struct QueryTasksArgs { command: Option, #[arg(long, help = "Filter tasks that belong to a platform", help_heading = HEADING_FILTERS)] + #[deprecated(note = "Use `toolchain` instead.")] platform: Option, #[arg(long, help = "Filter tasks that belong to a project", help_heading = HEADING_FILTERS)] @@ -362,6 +363,7 @@ pub async fn tasks(session: CliSession, args: QueryTasksArgs) -> AppResult { json: args.json, command: args.command, query: args.query, + #[allow(deprecated)] platform: args.platform, project: args.project, script: args.script, @@ -422,7 +424,7 @@ pub async fn tasks(session: CliSession, args: QueryTasksArgs) -> AppResult { task_id, task.command, task.type_of, - task.platform, + task.toolchains.join(", "), task.description.as_deref().unwrap_or("...") ))?; } diff --git a/crates/app/src/queries/tasks.rs b/crates/app/src/queries/tasks.rs index 981a1fddf3b..ec8ea71f599 100644 --- a/crates/app/src/queries/tasks.rs +++ b/crates/app/src/queries/tasks.rs @@ -16,6 +16,7 @@ pub struct QueryTasksOptions { // Filters pub id: Option, pub command: Option, + // TODO: Remove in 2.0 pub platform: Option, pub project: Option, pub script: Option, @@ -46,10 +47,14 @@ fn load_with_regex( let platform_regex = convert_to_regex("platform", &options.platform)?; let project_regex = convert_to_regex("project", &options.project)?; let script_regex = convert_to_regex("script", &options.script)?; - let toolchain_regex = convert_to_regex("toolchain", &options.toolchain)?; + let mut toolchain_regex = convert_to_regex("toolchain", &options.toolchain)?; let type_regex = convert_to_regex("type", &options.type_of)?; let mut filtered = vec![]; + if toolchain_regex.is_none() { + toolchain_regex = platform_regex; + } + for task in workspace_graph.get_tasks()? { if let Some(regex) = &id_regex { if !regex.is_match(&task.id) { @@ -75,12 +80,6 @@ fn load_with_regex( } } - if let Some(regex) = &platform_regex { - if !regex.is_match(&task.platform.to_string()) { - continue; - } - } - if let Some(regex) = &toolchain_regex { if !task.toolchains.iter().any(|tc| regex.is_match(&tc)) { continue; diff --git a/crates/query/src/builder.rs b/crates/query/src/builder.rs index b597e2878ce..d3a71b3bd8c 100644 --- a/crates/query/src/builder.rs +++ b/crates/query/src/builder.rs @@ -1,6 +1,6 @@ use crate::parser::{parse_query, AstNode, ComparisonOperator, LogicalOperator}; use crate::query_error::QueryError; -use moon_config::{LanguageType, PlatformType, ProjectType, StackType, TaskType}; +use moon_config::{LanguageType, ProjectType, StackType, TaskType}; use starbase_utils::glob::GlobSet; use std::borrow::Cow; use std::cmp::PartialEq; @@ -21,7 +21,7 @@ pub enum Field<'l> { ProjectType(Vec), Tag(FieldValues<'l>), Task(FieldValues<'l>), - TaskPlatform(Vec), + TaskPlatform(FieldValues<'l>), TaskToolchain(FieldValues<'l>), TaskType(Vec), } @@ -131,9 +131,8 @@ fn build_criteria(ast: Vec>) -> miette::Result> { } "tag" => Field::Tag(value), "task" => Field::Task(value), - "taskPlatform" => Field::TaskPlatform(build_criteria_enum::( - &field, &op, value, - )?), + "taskPlatform" => Field::TaskPlatform(value), + "taskToolchain" => Field::TaskToolchain(value), "taskType" => { Field::TaskType(build_criteria_enum::(&field, &op, value)?) } diff --git a/crates/query/tests/builder_test.rs b/crates/query/tests/builder_test.rs index b11f1bd76c7..721eb0f1c23 100644 --- a/crates/query/tests/builder_test.rs +++ b/crates/query/tests/builder_test.rs @@ -1,4 +1,4 @@ -use moon_config::{LanguageType, PlatformType, ProjectType, StackType, TaskType}; +use moon_config::{LanguageType, ProjectType, StackType, TaskType}; use moon_query::{ build_query, ComparisonOperator, Condition, Criteria, Field, FieldValues, LogicalOperator, }; @@ -626,7 +626,7 @@ mod mql_build { Criteria { op: LogicalOperator::And, conditions: vec![Condition::Field { - field: Field::TaskPlatform(vec![PlatformType::Node]), + field: Field::TaskPlatform(value_list(["node"])), op: ComparisonOperator::Equal, }], input: Some("taskPlatform=node".into()) @@ -641,7 +641,7 @@ mod mql_build { Criteria { op: LogicalOperator::And, conditions: vec![Condition::Field { - field: Field::TaskPlatform(vec![PlatformType::Node, PlatformType::System]), + field: Field::TaskPlatform(value_list(["node", "system"])), op: ComparisonOperator::NotEqual, }], input: Some("taskPlatform!=[node, system]".into()) diff --git a/crates/workspace-graph/src/query_projects.rs b/crates/workspace-graph/src/query_projects.rs index a473366d6f3..e46d7a8862d 100644 --- a/crates/workspace-graph/src/query_projects.rs +++ b/crates/workspace-graph/src/query_projects.rs @@ -115,16 +115,7 @@ impl WorkspaceGraph { Field::Task(ids) => Ok(project.task_targets.iter().any(|target| { condition.matches(ids, &target.task_id).unwrap_or_default() })), - Field::TaskPlatform(platforms) => Ok(self - .tasks - .get_all_for_project(&project.id, false)? - .iter() - .any(|task| { - condition - .matches_enum(platforms, &task.platform) - .unwrap_or_default() - })), - Field::TaskToolchain(ids) => Ok(self + Field::TaskPlatform(ids) | Field::TaskToolchain(ids) => Ok(self .tasks .get_all_for_project(&project.id, false)? .iter() diff --git a/crates/workspace-graph/src/query_tasks.rs b/crates/workspace-graph/src/query_tasks.rs index 53ae4a637ff..7cde93adaf2 100644 --- a/crates/workspace-graph/src/query_tasks.rs +++ b/crates/workspace-graph/src/query_tasks.rs @@ -85,10 +85,7 @@ fn does_task_match_criteria(task: &Task, query: &Criteria) -> miette::Result condition.matches(ids, &task.id), - Field::TaskPlatform(platforms) => { - condition.matches_enum(platforms, &task.platform) - } - Field::TaskToolchain(ids) => { + Field::TaskPlatform(ids) | Field::TaskToolchain(ids) => { let toolchains = task .toolchains .iter()