diff --git a/Cargo.lock b/Cargo.lock index 8850726cec..2896c0e058 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1435,9 +1435,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.39.1" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a91aa99751ebe305a7edad12a3ad751f3b3b9f5ecddbfe4a0459e3cdc8493b6" +checksum = "38fb809500238be2b10eee42944a47b3ac38974e1edbb47f73afcfca7df143bf" dependencies = [ "anyhow", "deno_package_json", diff --git a/Cargo.toml b/Cargo.toml index cf7e2610bb..0dfe7e8bd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,7 @@ deno_ast = { version = "=0.43.3", features = ["transpiling"] } deno_core = { version = "0.321.0" } deno_bench_util = { version = "0.171.0", path = "./bench_util" } -deno_config = { version = "=0.39.1", features = ["workspace", "sync"] } +deno_config = { version = "=0.39.2", features = ["workspace", "sync"] } deno_lockfile = "=0.23.1" deno_media_type = { version = "0.2.0", features = ["module_specifier"] } deno_npm = "=0.25.4" diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 6945065574..3464766728 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -380,6 +380,8 @@ pub struct TaskFlags { pub cwd: Option, pub task: Option, pub is_run: bool, + pub recursive: bool, + pub filter: Option, pub eval: bool, } @@ -3046,13 +3048,27 @@ Evaluate a task from string .help("Specify the directory to run the task in") .value_hint(ValueHint::DirPath), ) + .arg( + Arg::new("recursive") + .long("recursive") + .short('r') + .help("Run the task in all projects in the workspace") + .action(ArgAction::SetTrue), + ) + .arg( + Arg::new("filter") + .long("filter") + .short('f') + .help("Filter members of the workspace by name - should be used with --recursive") + .value_parser(value_parser!(String)), + ) .arg( Arg::new("eval") .long("eval") .help( "Evaluate the passed value as if, it was a task in a configuration file", ).action(ArgAction::SetTrue) - ) + ) .arg(node_modules_dir_arg()) }) } @@ -5212,10 +5228,15 @@ fn task_parse( unstable_args_parse(flags, matches, UnstableArgsConfig::ResolutionAndRuntime); node_modules_arg_parse(flags, matches); + let filter = matches.remove_one::("filter"); + let recursive = matches.get_flag("recursive") || filter.is_some(); + let mut task_flags = TaskFlags { cwd: matches.remove_one::("cwd"), task: None, is_run: false, + recursive, + filter, eval: matches.get_flag("eval"), }; @@ -10418,6 +10439,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), argv: svec!["hello", "world"], @@ -10433,6 +10456,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), ..Flags::default() @@ -10447,6 +10472,56 @@ mod tests { cwd: Some("foo".to_string()), task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, + eval: false, + }), + ..Flags::default() + } + ); + + let r = flags_from_vec(svec!["deno", "task", "--filter", "*", "build"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Task(TaskFlags { + cwd: None, + task: Some("build".to_string()), + is_run: false, + recursive: true, + filter: Some("*".to_string()), + eval: false, + }), + ..Flags::default() + } + ); + + let r = flags_from_vec(svec!["deno", "task", "--recursive", "build"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Task(TaskFlags { + cwd: None, + task: Some("build".to_string()), + is_run: false, + recursive: true, + filter: None, + eval: false, + }), + ..Flags::default() + } + ); + + let r = flags_from_vec(svec!["deno", "task", "-r", "build"]); + assert_eq!( + r.unwrap(), + Flags { + subcommand: DenoSubcommand::Task(TaskFlags { + cwd: None, + task: Some("build".to_string()), + is_run: false, + recursive: true, + filter: None, eval: false, }), ..Flags::default() @@ -10461,6 +10536,8 @@ mod tests { cwd: None, task: Some("echo 1".to_string()), is_run: false, + recursive: false, + filter: None, eval: true, }), ..Flags::default() @@ -10490,6 +10567,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), argv: svec!["--", "hello", "world"], @@ -10508,6 +10587,8 @@ mod tests { cwd: Some("foo".to_string()), task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), argv: svec!["--", "hello", "world"], @@ -10527,6 +10608,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), argv: svec!["--"], @@ -10545,6 +10628,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), argv: svec!["-1", "--test"], @@ -10563,6 +10648,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), argv: svec!["--test"], @@ -10582,6 +10669,8 @@ mod tests { cwd: None, task: Some("build".to_string()), is_run: false, + recursive: false, + filter: None, eval: false, }), log_level: Some(log::Level::Error), @@ -10600,6 +10689,8 @@ mod tests { cwd: None, task: None, is_run: false, + recursive: false, + filter: None, eval: false, }), ..Flags::default() @@ -10617,6 +10708,8 @@ mod tests { cwd: None, task: None, is_run: false, + recursive: false, + filter: None, eval: false, }), config_flag: ConfigFlag::Path("deno.jsonc".to_string()), @@ -10635,6 +10728,8 @@ mod tests { cwd: None, task: None, is_run: false, + recursive: false, + filter: None, eval: false, }), config_flag: ConfigFlag::Path("deno.jsonc".to_string()), diff --git a/cli/main.rs b/cli/main.rs index 017e343178..29f5914bbf 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -243,6 +243,8 @@ async fn run_subcommand(flags: Arc) -> Result { cwd: None, task: Some(run_flags.script.clone()), is_run: true, + recursive: false, + filter: None, eval: false, }; new_flags.subcommand = DenoSubcommand::Task(task_flags.clone()); diff --git a/cli/tools/task.rs b/cli/tools/task.rs index 85145c7af7..b0c290adc0 100644 --- a/cli/tools/task.rs +++ b/cli/tools/task.rs @@ -8,6 +8,7 @@ use std::path::PathBuf; use std::rc::Rc; use std::sync::Arc; +use deno_config::workspace::FolderConfigs; use deno_config::workspace::TaskDefinition; use deno_config::workspace::TaskOrScript; use deno_config::workspace::WorkspaceDirectory; @@ -25,6 +26,7 @@ use deno_path_util::normalize_path; use deno_runtime::deno_node::NodeResolver; use deno_task_shell::ShellCommand; use indexmap::IndexMap; +use regex::Regex; use crate::args::CliOptions; use crate::args::Flags; @@ -35,6 +37,12 @@ use crate::npm::CliNpmResolver; use crate::task_runner; use crate::util::fs::canonicalize_path; +#[derive(Debug)] +struct PackageTaskInfo { + matched_tasks: Vec, + tasks_config: WorkspaceTasksConfig, +} + pub async fn execute_script( flags: Arc, task_flags: TaskFlags, @@ -55,18 +63,145 @@ pub async fn execute_script( v == "1" }) .unwrap_or(false); - let mut tasks_config = start_dir.to_tasks_config()?; - if force_use_pkg_json { - tasks_config = tasks_config.with_only_pkg_json() + + fn arg_to_regex(input: &str) -> Result { + let mut regex_str = regex::escape(input); + regex_str = regex_str.replace("\\*", ".*"); + + Regex::new(®ex_str) } - let Some(task_name) = &task_flags.task else { - print_available_tasks( - &mut std::io::stdout(), - &cli_options.start_dir, - &tasks_config, - )?; - return Ok(0); + let packages_task_configs: Vec = if let Some(filter) = + &task_flags.filter + { + let task_name = task_flags.task.as_ref().unwrap(); + + // Filter based on package name + let package_regex = arg_to_regex(filter)?; + let task_regex = arg_to_regex(task_name)?; + + let mut packages_task_info: Vec = vec![]; + + fn matches_package( + config: &FolderConfigs, + force_use_pkg_json: bool, + regex: &Regex, + ) -> bool { + if !force_use_pkg_json { + if let Some(deno_json) = &config.deno_json { + if let Some(name) = &deno_json.json.name { + if regex.is_match(name) { + return true; + } + } + } + } + + if let Some(package_json) = &config.pkg_json { + if let Some(name) = &package_json.name { + if regex.is_match(name) { + return true; + } + } + } + + false + } + + let workspace = cli_options.workspace(); + for folder in workspace.config_folders() { + if !matches_package(folder.1, force_use_pkg_json, &package_regex) { + continue; + } + + let member_dir = workspace.resolve_member_dir(folder.0); + let mut tasks_config = member_dir.to_tasks_config()?; + if force_use_pkg_json { + tasks_config = tasks_config.with_only_pkg_json(); + } + + // Any of the matched tasks could be a child task of another matched + // one. Therefore we need to filter these out to ensure that every + // task is only run once. + let mut matched: HashSet = HashSet::new(); + let mut visited: HashSet = HashSet::new(); + + fn visit_task( + tasks_config: &WorkspaceTasksConfig, + visited: &mut HashSet, + name: &str, + ) { + if visited.contains(name) { + return; + } + + visited.insert(name.to_string()); + + if let Some((_, TaskOrScript::Task(_, task))) = &tasks_config.task(name) + { + for dep in &task.dependencies { + visit_task(tasks_config, visited, dep); + } + } + } + + // Match tasks in deno.json + for name in tasks_config.task_names() { + if task_regex.is_match(name) && !visited.contains(name) { + matched.insert(name.to_string()); + visit_task(&tasks_config, &mut visited, name); + } + } + + packages_task_info.push(PackageTaskInfo { + matched_tasks: matched + .iter() + .map(|s| s.to_string()) + .collect::>(), + tasks_config, + }); + } + + // Logging every task definition would be too spammy. Pnpm only + // logs a simple message too. + if packages_task_info + .iter() + .all(|config| config.matched_tasks.is_empty()) + { + log::warn!( + "{}", + colors::red(format!( + "No matching task or script '{}' found in selected packages.", + task_name + )) + ); + return Ok(0); + } + + // FIXME: Sort packages topologically + // + + packages_task_info + } else { + let mut tasks_config = start_dir.to_tasks_config()?; + + if force_use_pkg_json { + tasks_config = tasks_config.with_only_pkg_json() + } + + let Some(task_name) = &task_flags.task else { + print_available_tasks( + &mut std::io::stdout(), + &cli_options.start_dir, + &tasks_config, + )?; + return Ok(0); + }; + + vec![PackageTaskInfo { + tasks_config, + matched_tasks: vec![task_name.to_string()], + }] }; let npm_resolver = factory.npm_resolver().await?; @@ -81,7 +216,6 @@ pub async fn execute_script( .unwrap_or_else(|| NonZeroUsize::new(2).unwrap()); let task_runner = TaskRunner { - tasks_config, task_flags: &task_flags, npm_resolver: npm_resolver.as_ref(), node_resolver: node_resolver.as_ref(), @@ -94,7 +228,7 @@ pub async fn execute_script( return task_runner .run_deno_task( &Url::from_directory_path(cli_options.initial_cwd()).unwrap(), - &"".to_string(), + "", &TaskDefinition { command: task_flags.task.as_ref().unwrap().to_string(), dependencies: vec![], @@ -103,7 +237,15 @@ pub async fn execute_script( ) .await; } - task_runner.run_task(task_name).await + + for task_config in &packages_task_configs { + let exit_code = task_runner.run_tasks(task_config).await?; + if exit_code > 0 { + return Ok(exit_code); + } + } + + Ok(0) } struct RunSingleOptions<'a> { @@ -114,7 +256,6 @@ struct RunSingleOptions<'a> { } struct TaskRunner<'a> { - tasks_config: WorkspaceTasksConfig, task_flags: &'a TaskFlags, npm_resolver: &'a dyn CliNpmResolver, node_resolver: &'a NodeResolver, @@ -124,12 +265,16 @@ struct TaskRunner<'a> { } impl<'a> TaskRunner<'a> { - pub async fn run_task( + pub async fn run_tasks( &self, - task_name: &str, + pkg_tasks_config: &PackageTaskInfo, ) -> Result { - match sort_tasks_topo(task_name, &self.tasks_config) { - Ok(sorted) => self.run_tasks_in_parallel(sorted).await, + match sort_tasks_topo(pkg_tasks_config) { + Ok(sorted) => { + self + .run_tasks_in_parallel(&pkg_tasks_config.tasks_config, sorted) + .await + } Err(err) => match err { TaskError::NotFound(name) => { if self.task_flags.is_run { @@ -138,7 +283,7 @@ impl<'a> TaskRunner<'a> { log::error!("Task not found: {}", name); if log::log_enabled!(log::Level::Error) { - self.print_available_tasks()?; + self.print_available_tasks(&pkg_tasks_config.tasks_config)?; } Ok(1) } @@ -150,16 +295,20 @@ impl<'a> TaskRunner<'a> { } } - pub fn print_available_tasks(&self) -> Result<(), std::io::Error> { + pub fn print_available_tasks( + &self, + tasks_config: &WorkspaceTasksConfig, + ) -> Result<(), std::io::Error> { print_available_tasks( &mut std::io::stderr(), &self.cli_options.start_dir, - &self.tasks_config, + tasks_config, ) } async fn run_tasks_in_parallel( &self, + tasks_config: &WorkspaceTasksConfig, task_names: Vec, ) -> Result { struct PendingTasksContext { @@ -181,22 +330,23 @@ impl<'a> TaskRunner<'a> { fn get_next_task<'a>( &mut self, runner: &'a TaskRunner<'a>, + tasks_config: &'a WorkspaceTasksConfig, ) -> Option>> { for name in &self.task_names { if self.completed.contains(name) || self.running.contains(name) { continue; } - let should_run = if let Ok((_, def)) = runner.get_task(name) { - match def { - TaskOrScript::Task(_, def) => def - .dependencies - .iter() - .all(|dep| self.completed.contains(dep)), - TaskOrScript::Script(_, _) => true, - } - } else { - false + let Some((folder_url, task_or_script)) = tasks_config.task(name) + else { + continue; + }; + let should_run = match task_or_script { + TaskOrScript::Task(_, def) => def + .dependencies + .iter() + .all(|dep| self.completed.contains(dep)), + TaskOrScript::Script(_, _) => true, }; if !should_run { @@ -207,10 +357,15 @@ impl<'a> TaskRunner<'a> { let name = name.clone(); return Some( async move { - runner - .run_task_no_dependencies(&name) - .await - .map(|exit_code| (exit_code, name)) + match task_or_script { + TaskOrScript::Task(_, def) => { + runner.run_deno_task(folder_url, &name, def).await + } + TaskOrScript::Script(scripts, _) => { + runner.run_npm_script(folder_url, &name, scripts).await + } + } + .map(|exit_code| (exit_code, name)) } .boxed_local(), ); @@ -229,7 +384,7 @@ impl<'a> TaskRunner<'a> { while context.has_remaining_tasks() { while queue.len() < self.concurrency { - if let Some(task) = context.get_next_task(self) { + if let Some(task) = context.get_next_task(self, tasks_config) { queue.push(task); } else { break; @@ -253,37 +408,10 @@ impl<'a> TaskRunner<'a> { Ok(0) } - fn get_task( - &self, - task_name: &str, - ) -> Result<(&Url, TaskOrScript), TaskError> { - let Some(result) = self.tasks_config.task(task_name) else { - return Err(TaskError::NotFound(task_name.to_string())); - }; - - Ok(result) - } - - async fn run_task_no_dependencies( - &self, - task_name: &String, - ) -> Result { - let (dir_url, task_or_script) = self.get_task(task_name.as_str()).unwrap(); - - match task_or_script { - TaskOrScript::Task(_tasks, definition) => { - self.run_deno_task(dir_url, task_name, definition).await - } - TaskOrScript::Script(scripts, _script) => { - self.run_npm_script(dir_url, task_name, scripts).await - } - } - } - - async fn run_deno_task( + pub async fn run_deno_task( &self, dir_url: &Url, - task_name: &String, + task_name: &str, definition: &TaskDefinition, ) -> Result { let cwd = match &self.task_flags.cwd { @@ -306,10 +434,10 @@ impl<'a> TaskRunner<'a> { .await } - async fn run_npm_script( + pub async fn run_npm_script( &self, dir_url: &Url, - task_name: &String, + task_name: &str, scripts: &IndexMap, ) -> Result { // ensure the npm packages are installed if using a managed resolver @@ -327,7 +455,7 @@ impl<'a> TaskRunner<'a> { // dealing with package.json here and not deno.json let task_names = vec![ format!("pre{}", task_name), - task_name.clone(), + task_name.to_string(), format!("post{}", task_name), ]; let custom_commands = task_runner::resolve_custom_commands( @@ -394,8 +522,7 @@ enum TaskError { } fn sort_tasks_topo( - name: &str, - task_config: &WorkspaceTasksConfig, + pkg_task_config: &PackageTaskInfo, ) -> Result, TaskError> { fn sort_visit<'a>( name: &'a str, @@ -416,12 +543,12 @@ fn sort_tasks_topo( }); } - let Some(def) = tasks_config.task(name) else { + let Some((_, task_or_script)) = tasks_config.task(name) else { return Err(TaskError::NotFound(name.to_string())); }; - if let TaskOrScript::Task(_, actual_def) = def.1 { - for dep in &actual_def.dependencies { + if let TaskOrScript::Task(_, task) = task_or_script { + for dep in &task.dependencies { let mut path = path.clone(); path.push(name); sort_visit(dep, sorted, path, tasks_config)? @@ -435,7 +562,9 @@ fn sort_tasks_topo( let mut sorted: Vec = vec![]; - sort_visit(name, &mut sorted, Vec::new(), task_config)?; + for name in &pkg_task_config.matched_tasks { + sort_visit(name, &mut sorted, Vec::new(), &pkg_task_config.tasks_config)?; + } Ok(sorted) } diff --git a/tests/specs/task/deno_json_lifecycle_script_names/__test__.jsonc b/tests/specs/task/deno_json_lifecycle_script_names/__test__.jsonc new file mode 100644 index 0000000000..d22f77cc2b --- /dev/null +++ b/tests/specs/task/deno_json_lifecycle_script_names/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "task test", + "output": "bin.out", + "exitCode": 0 +} diff --git a/tests/specs/task/deno_json_lifecycle_script_names/bin.out b/tests/specs/task/deno_json_lifecycle_script_names/bin.out new file mode 100644 index 0000000000..ad66595f1e --- /dev/null +++ b/tests/specs/task/deno_json_lifecycle_script_names/bin.out @@ -0,0 +1,2 @@ +Task test echo 'test' +test diff --git a/tests/specs/task/deno_json_lifecycle_script_names/deno.jsonc b/tests/specs/task/deno_json_lifecycle_script_names/deno.jsonc new file mode 100644 index 0000000000..de2f8be880 --- /dev/null +++ b/tests/specs/task/deno_json_lifecycle_script_names/deno.jsonc @@ -0,0 +1,7 @@ +{ + "task": { + // should not execute this one because it's in a deno.json + // and not in the package.json + "pretest": "echo 'should not be in output'" + } +} diff --git a/tests/specs/task/deno_json_lifecycle_script_names/package.json b/tests/specs/task/deno_json_lifecycle_script_names/package.json new file mode 100644 index 0000000000..e66cb27e3d --- /dev/null +++ b/tests/specs/task/deno_json_lifecycle_script_names/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "test": "echo 'test'" + } +} diff --git a/tests/specs/task/filter/__test__.jsonc b/tests/specs/task/filter/__test__.jsonc new file mode 100644 index 0000000000..8baaf04dd4 --- /dev/null +++ b/tests/specs/task/filter/__test__.jsonc @@ -0,0 +1,59 @@ +{ + "tests": { + "npm_all": { + "cwd": "./npm", + "args": "task --filter * dev", + "output": "npm_all.out" + }, + "npm_exact": { + "cwd": "./npm", + "args": "task --filter foo dev", + "output": "npm_exact.out" + }, + "npm_multi": { + "cwd": "./npm_multi", + "args": "task --filter multi-* dev", + "output": "npm_multi.out" + }, + "npm_scoped_exact": { + "cwd": "./npm_scoped", + "args": "task --filter @foo/bar dev", + "output": "npm_scoped_exact.out" + }, + "npm_scoped_multi": { + "cwd": "./npm_scoped", + "args": "task --filter @foo/* dev", + "output": "npm_scoped_multi.out" + }, + "npm_workspace_order": { + "cwd": "./npm_workspace_order", + "args": "task --filter @foo/* dev", + "output": "npm_workspace_order.out" + }, + "deno_all": { + "cwd": "./deno", + "args": "task --filter * dev", + "output": "deno_all.out" + }, + "deno_exact": { + "cwd": "./deno", + "args": "task --filter foo dev", + "output": "deno_exact.out" + }, + "deno_scoped_exact": { + "cwd": "./deno_scoped", + "args": "task --filter @foo/bar dev", + "output": "deno_scoped_exact.out" + }, + "deno_scoped_multi": { + "cwd": "./deno_scoped", + "args": "task --filter @foo/* dev", + "output": "deno_scoped_multi.out" + }, + "deno_workspace_order": { + "cwd": "./deno_workspace_order", + "args": "task --filter @foo/* dev", + "output": "deno_workspace_order.out" + } + } +} diff --git a/tests/specs/task/filter/deno/bar/deno.json b/tests/specs/task/filter/deno/bar/deno.json new file mode 100644 index 0000000000..9bc7d54233 --- /dev/null +++ b/tests/specs/task/filter/deno/bar/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@deno/bar", + "tasks": { + "dev": "echo '@deno/bar'" + }, + "exports": {} +} diff --git a/tests/specs/task/filter/deno/deno.json b/tests/specs/task/filter/deno/deno.json new file mode 100644 index 0000000000..133ab666b4 --- /dev/null +++ b/tests/specs/task/filter/deno/deno.json @@ -0,0 +1,6 @@ +{ + "workspace": [ + "./foo", + "./bar" + ] +} diff --git a/tests/specs/task/filter/deno/foo/deno.json b/tests/specs/task/filter/deno/foo/deno.json new file mode 100644 index 0000000000..6efb2125b7 --- /dev/null +++ b/tests/specs/task/filter/deno/foo/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@deno/foo", + "tasks": { + "dev": "echo '@deno/foo'" + }, + "exports": {} +} diff --git a/tests/specs/task/filter/deno_all.out b/tests/specs/task/filter/deno_all.out new file mode 100644 index 0000000000..c3c3441559 --- /dev/null +++ b/tests/specs/task/filter/deno_all.out @@ -0,0 +1,4 @@ +Task dev echo '@deno/bar' +@deno/bar +Task dev echo '@deno/foo' +@deno/foo diff --git a/tests/specs/task/filter/deno_exact.out b/tests/specs/task/filter/deno_exact.out new file mode 100644 index 0000000000..4bfebd6e92 --- /dev/null +++ b/tests/specs/task/filter/deno_exact.out @@ -0,0 +1,2 @@ +Task dev echo '@deno/foo' +@deno/foo diff --git a/tests/specs/task/filter/deno_multi.out b/tests/specs/task/filter/deno_multi.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/specs/task/filter/deno_scoped/deno.json b/tests/specs/task/filter/deno_scoped/deno.json new file mode 100644 index 0000000000..7a26f9ca68 --- /dev/null +++ b/tests/specs/task/filter/deno_scoped/deno.json @@ -0,0 +1,3 @@ +{ + "workspace": ["./foo_bar", "./foo_baz"] +} diff --git a/tests/specs/task/filter/deno_scoped/foo_bar/deno.json b/tests/specs/task/filter/deno_scoped/foo_bar/deno.json new file mode 100644 index 0000000000..1773d76c26 --- /dev/null +++ b/tests/specs/task/filter/deno_scoped/foo_bar/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "exports": {}, + "tasks": { + "dev": "echo '@foo/bar'" + } +} diff --git a/tests/specs/task/filter/deno_scoped/foo_baz/deno.json b/tests/specs/task/filter/deno_scoped/foo_baz/deno.json new file mode 100644 index 0000000000..f3e59719e5 --- /dev/null +++ b/tests/specs/task/filter/deno_scoped/foo_baz/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/baz", + "exports": {}, + "tasks": { + "dev": "echo '@foo/baz'" + } +} diff --git a/tests/specs/task/filter/deno_scoped_exact.out b/tests/specs/task/filter/deno_scoped_exact.out new file mode 100644 index 0000000000..f7d61e8714 --- /dev/null +++ b/tests/specs/task/filter/deno_scoped_exact.out @@ -0,0 +1,2 @@ +Task dev echo '@foo/bar' +@foo/bar diff --git a/tests/specs/task/filter/deno_scoped_multi.out b/tests/specs/task/filter/deno_scoped_multi.out new file mode 100644 index 0000000000..f4609e94b6 --- /dev/null +++ b/tests/specs/task/filter/deno_scoped_multi.out @@ -0,0 +1,4 @@ +Task dev echo '@foo/bar' +@foo/bar +Task dev echo '@foo/baz' +@foo/baz diff --git a/tests/specs/task/filter/deno_workspace_order.out b/tests/specs/task/filter/deno_workspace_order.out new file mode 100644 index 0000000000..f4609e94b6 --- /dev/null +++ b/tests/specs/task/filter/deno_workspace_order.out @@ -0,0 +1,4 @@ +Task dev echo '@foo/bar' +@foo/bar +Task dev echo '@foo/baz' +@foo/baz diff --git a/tests/specs/task/filter/deno_workspace_order/deno.json b/tests/specs/task/filter/deno_workspace_order/deno.json new file mode 100644 index 0000000000..cd73d72b22 --- /dev/null +++ b/tests/specs/task/filter/deno_workspace_order/deno.json @@ -0,0 +1,6 @@ +{ + "workspace": [ + "./foo_bar", + "./foo_baz" + ] +} diff --git a/tests/specs/task/filter/deno_workspace_order/foo_bar/deno.json b/tests/specs/task/filter/deno_workspace_order/foo_bar/deno.json new file mode 100644 index 0000000000..5be2ceac7f --- /dev/null +++ b/tests/specs/task/filter/deno_workspace_order/foo_bar/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "tasks": { + "dev": "echo '@foo/bar'" + }, + "exports": {} +} diff --git a/tests/specs/task/filter/deno_workspace_order/foo_baz/deno.json b/tests/specs/task/filter/deno_workspace_order/foo_baz/deno.json new file mode 100644 index 0000000000..083cea5bf0 --- /dev/null +++ b/tests/specs/task/filter/deno_workspace_order/foo_baz/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/baz", + "tasks": { + "dev": "echo '@foo/baz'" + }, + "imports": { + "@foo/bar": "jsr:@foo/bar" + }, + "exports": {} +} diff --git a/tests/specs/task/filter/npm/bar/package.json b/tests/specs/task/filter/npm/bar/package.json new file mode 100644 index 0000000000..3723db6f01 --- /dev/null +++ b/tests/specs/task/filter/npm/bar/package.json @@ -0,0 +1,6 @@ +{ + "name": "bar", + "scripts": { + "dev": "echo 'bar'" + } +} diff --git a/tests/specs/task/filter/npm/foo/package.json b/tests/specs/task/filter/npm/foo/package.json new file mode 100644 index 0000000000..86fa20d111 --- /dev/null +++ b/tests/specs/task/filter/npm/foo/package.json @@ -0,0 +1,6 @@ +{ + "name": "foo", + "scripts": { + "dev": "echo 'foo'" + } +} diff --git a/tests/specs/task/filter/npm/package.json b/tests/specs/task/filter/npm/package.json new file mode 100644 index 0000000000..2d70009f2c --- /dev/null +++ b/tests/specs/task/filter/npm/package.json @@ -0,0 +1,3 @@ +{ + "workspaces": ["./foo", "./bar"] +} diff --git a/tests/specs/task/filter/npm_all.out b/tests/specs/task/filter/npm_all.out new file mode 100644 index 0000000000..592d4640cd --- /dev/null +++ b/tests/specs/task/filter/npm_all.out @@ -0,0 +1,4 @@ +Task dev echo 'bar' +bar +Task dev echo 'foo' +foo diff --git a/tests/specs/task/filter/npm_exact.out b/tests/specs/task/filter/npm_exact.out new file mode 100644 index 0000000000..f879b66df8 --- /dev/null +++ b/tests/specs/task/filter/npm_exact.out @@ -0,0 +1,2 @@ +Task dev echo 'foo' +foo diff --git a/tests/specs/task/filter/npm_multi.out b/tests/specs/task/filter/npm_multi.out new file mode 100644 index 0000000000..58898a5965 --- /dev/null +++ b/tests/specs/task/filter/npm_multi.out @@ -0,0 +1,4 @@ +Task dev echo 'multi-a' +multi-a +Task dev echo 'multi-b' +multi-b diff --git a/tests/specs/task/filter/npm_multi/multi-a/package.json b/tests/specs/task/filter/npm_multi/multi-a/package.json new file mode 100644 index 0000000000..348d7273ff --- /dev/null +++ b/tests/specs/task/filter/npm_multi/multi-a/package.json @@ -0,0 +1,6 @@ +{ + "name": "multi-a", + "scripts": { + "dev": "echo 'multi-a'" + } +} diff --git a/tests/specs/task/filter/npm_multi/multi-b/package.json b/tests/specs/task/filter/npm_multi/multi-b/package.json new file mode 100644 index 0000000000..f11006aea4 --- /dev/null +++ b/tests/specs/task/filter/npm_multi/multi-b/package.json @@ -0,0 +1,6 @@ +{ + "name": "multi-b", + "scripts": { + "dev": "echo 'multi-b'" + } +} diff --git a/tests/specs/task/filter/npm_multi/package.json b/tests/specs/task/filter/npm_multi/package.json new file mode 100644 index 0000000000..b6000c0487 --- /dev/null +++ b/tests/specs/task/filter/npm_multi/package.json @@ -0,0 +1,3 @@ +{ + "workspaces": ["./multi-a", "./multi-b"] +} diff --git a/tests/specs/task/filter/npm_scoped/foo_bar/package.json b/tests/specs/task/filter/npm_scoped/foo_bar/package.json new file mode 100644 index 0000000000..0e2c92c8be --- /dev/null +++ b/tests/specs/task/filter/npm_scoped/foo_bar/package.json @@ -0,0 +1,6 @@ +{ + "name": "@foo/bar", + "scripts": { + "dev": "echo '@foo/bar'" + } +} diff --git a/tests/specs/task/filter/npm_scoped/foo_baz/package.json b/tests/specs/task/filter/npm_scoped/foo_baz/package.json new file mode 100644 index 0000000000..77ec9209b1 --- /dev/null +++ b/tests/specs/task/filter/npm_scoped/foo_baz/package.json @@ -0,0 +1,6 @@ +{ + "name": "@foo/baz", + "scripts": { + "dev": "echo '@foo/baz'" + } +} diff --git a/tests/specs/task/filter/npm_scoped/package.json b/tests/specs/task/filter/npm_scoped/package.json new file mode 100644 index 0000000000..d02abfb3f8 --- /dev/null +++ b/tests/specs/task/filter/npm_scoped/package.json @@ -0,0 +1,3 @@ +{ + "workspaces": ["./foo_bar", "./foo_baz"] +} diff --git a/tests/specs/task/filter/npm_scoped_exact.out b/tests/specs/task/filter/npm_scoped_exact.out new file mode 100644 index 0000000000..f7d61e8714 --- /dev/null +++ b/tests/specs/task/filter/npm_scoped_exact.out @@ -0,0 +1,2 @@ +Task dev echo '@foo/bar' +@foo/bar diff --git a/tests/specs/task/filter/npm_scoped_multi.out b/tests/specs/task/filter/npm_scoped_multi.out new file mode 100644 index 0000000000..f4609e94b6 --- /dev/null +++ b/tests/specs/task/filter/npm_scoped_multi.out @@ -0,0 +1,4 @@ +Task dev echo '@foo/bar' +@foo/bar +Task dev echo '@foo/baz' +@foo/baz diff --git a/tests/specs/task/filter/npm_workspace_order.out b/tests/specs/task/filter/npm_workspace_order.out new file mode 100644 index 0000000000..f4609e94b6 --- /dev/null +++ b/tests/specs/task/filter/npm_workspace_order.out @@ -0,0 +1,4 @@ +Task dev echo '@foo/bar' +@foo/bar +Task dev echo '@foo/baz' +@foo/baz diff --git a/tests/specs/task/filter/npm_workspace_order/foo_bar/package.json b/tests/specs/task/filter/npm_workspace_order/foo_bar/package.json new file mode 100644 index 0000000000..0e2c92c8be --- /dev/null +++ b/tests/specs/task/filter/npm_workspace_order/foo_bar/package.json @@ -0,0 +1,6 @@ +{ + "name": "@foo/bar", + "scripts": { + "dev": "echo '@foo/bar'" + } +} diff --git a/tests/specs/task/filter/npm_workspace_order/foo_baz/package.json b/tests/specs/task/filter/npm_workspace_order/foo_baz/package.json new file mode 100644 index 0000000000..79f4b4b793 --- /dev/null +++ b/tests/specs/task/filter/npm_workspace_order/foo_baz/package.json @@ -0,0 +1,9 @@ +{ + "name": "@foo/baz", + "scripts": { + "dev": "echo '@foo/baz'" + }, + "dependencies": { + "@foo/bar": "workspace:*" + } +} diff --git a/tests/specs/task/filter/npm_workspace_order/package.json b/tests/specs/task/filter/npm_workspace_order/package.json new file mode 100644 index 0000000000..d02abfb3f8 --- /dev/null +++ b/tests/specs/task/filter/npm_workspace_order/package.json @@ -0,0 +1,3 @@ +{ + "workspaces": ["./foo_bar", "./foo_baz"] +}