From 58d6daf86121edfcb3317dfc37d688bbf4729a42 Mon Sep 17 00:00:00 2001 From: branchseer Date: Mon, 22 Dec 2025 02:38:41 +0800 Subject: [PATCH 01/27] feat: tui --- Cargo.lock | 14 ++ Cargo.toml | 1 + crates/vite_task/src/bin/vite.rs | 13 -- crates/vite_task/src/execute/execute_plan.rs | 107 ++++++++++++ .../src/{execute.rs => execute/mod.rs} | 3 + crates/vite_task/src/execute/reporter.rs | 25 +++ crates/vite_task/src/lib.rs | 4 +- crates/vite_task/src/session.rs | 26 +-- crates/vite_task_bin/Cargo.toml | 24 +++ crates/vite_task_bin/src/main.rs | 90 ++++++++++ crates/vite_task_plan/src/lib.rs | 6 +- crates/vite_task_plan/src/plan.rs | 17 +- crates/vite_task_plan/src/plan_request.rs | 9 +- package.json | 4 +- pnpm-lock.yaml | 163 ++++++++++++++++++ pnpm-workspace.yaml | 4 +- 16 files changed, 471 insertions(+), 39 deletions(-) delete mode 100644 crates/vite_task/src/bin/vite.rs create mode 100644 crates/vite_task/src/execute/execute_plan.rs rename crates/vite_task/src/{execute.rs => execute/mod.rs} (99%) create mode 100644 crates/vite_task/src/execute/reporter.rs create mode 100644 crates/vite_task_bin/Cargo.toml create mode 100644 crates/vite_task_bin/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 58bddf31..a35c4f01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3267,6 +3267,20 @@ dependencies = [ "wax", ] +[[package]] +name = "vite_task_bin" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "clap", + "tokio", + "vite_path", + "vite_str", + "vite_task", + "which", +] + [[package]] name = "vite_task_graph" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 814b4921..a11bcb2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,6 +122,7 @@ vite_glob = { path = "crates/vite_glob" } vite_path = { path = "crates/vite_path" } vite_shell = { path = "crates/vite_shell" } vite_str = { path = "crates/vite_str" } +vite_task = { path = "crates/vite_task" } vite_task_graph = { path = "crates/vite_task_graph" } vite_task_plan = { path = "crates/vite_task_plan" } vite_workspace = { path = "crates/vite_workspace" } diff --git a/crates/vite_task/src/bin/vite.rs b/crates/vite_task/src/bin/vite.rs deleted file mode 100644 index 42acd1ac..00000000 --- a/crates/vite_task/src/bin/vite.rs +++ /dev/null @@ -1,13 +0,0 @@ -use clap::Parser; -use vite_str::Str; -use vite_task::CLIArgs; - -#[derive(Debug, Parser)] -enum CustomTaskSubCommand { - /// oxlint - Lint { args: Vec }, -} - -fn main() { - let _subcommand = CLIArgs::::parse(); -} diff --git a/crates/vite_task/src/execute/execute_plan.rs b/crates/vite_task/src/execute/execute_plan.rs new file mode 100644 index 00000000..e711fb04 --- /dev/null +++ b/crates/vite_task/src/execute/execute_plan.rs @@ -0,0 +1,107 @@ +use core::task; + +use petgraph::{ + algo::{Cycle, toposort}, + graph::DiGraph, +}; +use vite_task_graph::IndexedTaskGraph; +use vite_task_plan::{ + ExecutionItemKind, ExecutionPlan, LeafExecutionKind, TaskExecution, + execution_graph::{ExecutionGraph, ExecutionIx, ExecutionNodeIndex}, +}; + +use super::reporter::Reporter; +use crate::execute::reporter; + +#[derive(Debug, thiserror::Error)] +pub enum ExecuteError { + #[error("Cycle dependencies detected: {0:?}")] + CycleDependencies(Cycle), +} + +struct ExecutionContext<'a> { + indexed_task_graph: Option<&'a IndexedTaskGraph>, + reporter: &'a mut (dyn Reporter + 'a), + last_execution_id: u32, +} + +impl ExecutionContext<'_> { + fn execute_item_kind( + &mut self, + item_kind: &ExecutionItemKind, + task_display: &str, + command: &str, + ) -> Result<(), ExecuteError> { + match item_kind { + ExecutionItemKind::Expanded(graph) => { + // clone for reversing edges and removing nodes + let mut graph: DiGraph<&TaskExecution, (), ExecutionIx> = + graph.map(|_, task_execution| task_execution, |_, ()| ()); + + // To be consistent with the package graph in vite_package_manager and the dependency graph definition in Wikipedia + // https://en.wikipedia.org/wiki/Dependency_graph, we construct the graph with edges from dependents to dependencies + // e.g. A -> B means A depends on B + // + // For execution we need to reverse the edges first before topological sorting, + // so that tasks without dependencies are executed first + graph.reverse(); // Run tasks without dependencies first + + // Always use topological sort to ensure the correct order of execution + // or the task dependencies declaration is meaningless + let node_indices = match toposort(&graph, None) { + Ok(ok) => ok, + Err(err) => return Err(ExecuteError::CycleDependencies(err)), + }; + + let ordered_executions = + node_indices.into_iter().map(|id| graph.remove_node(id).unwrap()); + for task_execution in ordered_executions { + let indexed_task_graph = self.indexed_task_graph.unwrap(); + let task_command = indexed_task_graph.task_graph() + [task_execution.task_node_index] + .resolved_config + .command + .as_str(); + let task_display = + indexed_task_graph.display_task(task_execution.task_node_index); + for (index, item) in task_execution.items.iter().enumerate() { + let item_command = &task_command[item.command_span.clone()]; + + let task_display_str = if task_execution.items.len() > 1 { + vite_str::format!("{} ({})", task_display, index) + } else { + vite_str::format!("{}", task_display) + }; + + for item in &task_execution.items { + self.execute_item_kind(&item.kind, command, &task_display_str)?; + } + } + } + } + ExecutionItemKind::Leaf(leaf_execution_kind) => { + self.execute_leaf(leaf_execution_kind, command)?; + } + } + Ok(()) + } + + fn execute_leaf( + &mut self, + leaf_execution_kind: &LeafExecutionKind, + command: &str, + ) -> Result<(), ExecuteError> { + Ok(()) + } +} + +pub fn execute_plan( + plan: &ExecutionPlan, + indexed_task_graph: Option<&IndexedTaskGraph>, + reporter: &mut (dyn Reporter + '_), + command: &str, +) -> Result<(), ExecuteError> { + let mut execution_context = + ExecutionContext { indexed_task_graph, reporter, last_execution_id: 0 }; + execution_context.execute_item_kind(plan.root_node(), command, command) +} diff --git a/crates/vite_task/src/execute.rs b/crates/vite_task/src/execute/mod.rs similarity index 99% rename from crates/vite_task/src/execute.rs rename to crates/vite_task/src/execute/mod.rs index da950f0f..7ddba633 100644 --- a/crates/vite_task/src/execute.rs +++ b/crates/vite_task/src/execute/mod.rs @@ -1,3 +1,6 @@ +pub mod execute_plan; +pub mod reporter; + use std::{ collections::hash_map::Entry, env::{join_paths, split_paths}, diff --git a/crates/vite_task/src/execute/reporter.rs b/crates/vite_task/src/execute/reporter.rs new file mode 100644 index 00000000..933bc2d6 --- /dev/null +++ b/crates/vite_task/src/execute/reporter.rs @@ -0,0 +1,25 @@ +use std::sync::Arc; + +use vite_path::AbsolutePath; +use vite_str::Str; + +use crate::collections::HashMap; + +pub struct ExecutionDisplay { + command: Str, + cwd: Arc, +} + +pub enum OutputKind { + Stdout, + Stderr, +} + +pub enum ExecutionEvent { + Output { kind: OutputKind, content: Vec }, + Finished { status: Option, cache_status: () }, +} + +pub trait Reporter { + fn new_execution(&mut self, display: ExecutionDisplay); +} diff --git a/crates/vite_task/src/lib.rs b/crates/vite_task/src/lib.rs index 88eb2f20..69d18083 100644 --- a/crates/vite_task/src/lib.rs +++ b/crates/vite_task/src/lib.rs @@ -19,5 +19,7 @@ pub use config::{ResolvedTask, Workspace}; pub use error::Error; pub use execute::{CURRENT_EXECUTION_ID, EXECUTION_SUMMARY_DIR}; pub use schedule::{ExecutionPlan, ExecutionStatus, ExecutionSummary}; -pub use session::{Session, SessionCallbacks}; +pub use session::{Session, SessionCallbacks, TaskSynthesizer}; pub use types::ResolveCommandResult; +pub use vite_task_graph::loader; +pub use vite_task_plan::plan_request; diff --git a/crates/vite_task/src/session.rs b/crates/vite_task/src/session.rs index 207547a5..3b499494 100644 --- a/crates/vite_task/src/session.rs +++ b/crates/vite_task/src/session.rs @@ -1,6 +1,6 @@ use std::{ffi::OsStr, fmt::Debug, sync::Arc}; -use clap::Parser; +use clap::{Parser, Subcommand}; use vite_path::AbsolutePath; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskGraph, TaskGraphLoadError, loader::UserConfigLoader}; @@ -38,8 +38,8 @@ impl TaskGraphLoader for LazyTaskGraph<'_> { } pub struct SessionCallbacks<'a, CustomSubCommand> { - task_synthesizer: &'a mut (dyn TaskSynthesizer + 'a), - user_config_loader: &'a mut (dyn UserConfigLoader + 'a), + pub task_synthesizer: &'a mut (dyn TaskSynthesizer + 'a), + pub user_config_loader: &'a mut (dyn UserConfigLoader + 'a), } #[async_trait::async_trait(?Send)] @@ -87,13 +87,19 @@ impl vite_task_plan::PlanRequestParser args: &[Str], cwd: &Arc, ) -> anyhow::Result> { - if !self.task_synthesizer.should_synthesize_for_program(program) { - return Ok(None); - } - let cli_args = CLIArgs::::try_parse_from( - std::iter::once(program).chain(args.iter().map(Str::as_str)), - )?; - Ok(Some(self.get_plan_request_from_cli_args(cli_args, cwd).await?)) + Ok( + if self.task_synthesizer.should_synthesize_for_program(program) + && let Some(subcommand) = args.first() + && CLIArgs::::has_subcommand(subcommand) + { + let cli_args = CLIArgs::::try_parse_from( + std::iter::once(program).chain(args.iter().map(Str::as_str)), + )?; + Some(self.get_plan_request_from_cli_args(cli_args, cwd).await?) + } else { + None + }, + ) } } diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml new file mode 100644 index 00000000..9b311305 --- /dev/null +++ b/crates/vite_task_bin/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "vite_task_bin" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +license.workspace = true +rust-version.workspace = true + +[[bin]] +name = "vite" +path = "src/main.rs" + +[dependencies] +anyhow = { workspace = true } +async-trait = { workspace = true } +clap = { workspace = true, features = ["derive"] } +tokio = { workspace = true, features = ["full"] } +vite_path = { workspace = true } +vite_str = { workspace = true } +vite_task = { workspace = true } +which = { workspace = true } + +[lints] +workspace = true diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs new file mode 100644 index 00000000..4db59348 --- /dev/null +++ b/crates/vite_task_bin/src/main.rs @@ -0,0 +1,90 @@ +use std::{env::join_paths, ffi::OsStr, path::PathBuf, sync::Arc}; + +use clap::Parser; +use vite_path::{AbsolutePath, current_dir}; +use vite_str::Str; +use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanRequest}; + +/// This is the custom subcommand that synthesizes tasks for vite-task +#[derive(Debug, Parser)] +enum ViteTaskCustomSubCommand { + /// oxlint + Lint { args: Vec }, +} + +#[derive(Debug)] +struct TaskSynthesizer; + +fn find_executable_in_node_modules_bin( + cwd: &AbsolutePath, + executable: &str, +) -> anyhow::Result> { + let mut paths: Vec = vec![]; + let mut current_cwd_parent = cwd; + loop { + let node_modules_bin = current_cwd_parent.join("node_modules").join(".bin"); + paths.push(node_modules_bin.as_path().to_path_buf()); + if let Some(parent) = current_cwd_parent.parent() { + current_cwd_parent = parent; + } else { + break; + } + } + let executable_path = which::which_in(executable, Some(join_paths(paths)?), cwd)?; + Ok(executable_path.into_os_string().into()) +} + +#[async_trait::async_trait(?Send)] +impl vite_task::TaskSynthesizer for TaskSynthesizer { + fn should_synthesize_for_program(&self, program: &str) -> bool { + program == "vite" + } + + async fn synthesize_task( + &mut self, + subcommand: ViteTaskCustomSubCommand, + cwd: &Arc, + ) -> anyhow::Result { + match subcommand { + ViteTaskCustomSubCommand::Lint { args } => Ok(SyntheticPlanRequest { + program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, + args: args.into(), + task_options: Default::default(), + }), + } + } +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + /// This is all the subcommands, including vite-task's own commands (run), + /// vite-task custom commands (lint), and non-task commands (version) + #[derive(Debug, Parser)] + enum Subcommand { + #[clap(flatten)] + Task(CLIArgs), + Version, + } + + // Pass vite-task's own/custom subcommands to vite-task's session. + let task_args = match Subcommand::parse() { + Subcommand::Task(task_args) => task_args, + Subcommand::Version => { + // Non-task subcommands are not handled by vite-task's session. + println!("{}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } + }; + + let mut task_synthesizer = TaskSynthesizer; + let mut config_loader = vite_task::loader::JsonUserConfigLoader::default(); + let mut session = Session::init(SessionCallbacks { + task_synthesizer: &mut task_synthesizer, + user_config_loader: &mut config_loader, + })?; + + let plan = session.plan(task_args).await?; + dbg!(plan); + + Ok(()) +} diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 15aef1c8..4410003a 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -19,7 +19,7 @@ use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; use vite_path::AbsolutePath; use vite_str::Str; -use vite_task_graph::{TaskGraphLoadError, display::TaskDisplay, query::TaskQuery}; +use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, display::TaskDisplay, query::TaskQuery}; use crate::path_env::prepend_path_env; @@ -52,7 +52,7 @@ pub struct SpawnExecution { #[derive(Debug)] pub enum SpawnCommandKind { /// A program with args to be executed directly - Program { program: Str, args: Arc<[Str]> }, + Program { program: Arc, args: Arc<[Str]> }, /// A script to be executed by os shell (sh or cmd) ShellScript(Str), } @@ -61,7 +61,7 @@ pub enum SpawnCommandKind { #[derive(Debug)] pub struct TaskExecution { /// The task this execution corresponds to - pub task_display: TaskDisplay, + pub task_node_index: TaskNodeIndex, /// A task's command is split by `&&` and expanded into multiple execution items. /// diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 4f83a709..ede2894b 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -100,7 +100,7 @@ async fn plan_task_as_execution_node( let spawn_execution = plan_spawn_execution( &and_item.envs, SpawnCommandKind::Program { - program: and_item.program, + program: OsStr::new(&and_item.program).into(), args: and_item.args.into(), }, &task_node.resolved_config.resolved_options, @@ -126,10 +126,7 @@ async fn plan_task_as_execution_node( }); } - Ok(TaskExecution { - task_display: context.indexed_task_graph().display_task(task_node_index), - items, - }) + Ok(TaskExecution { task_node_index, items }) } pub fn plan_synthetic_request( @@ -138,8 +135,14 @@ pub fn plan_synthetic_request( cwd: &Arc, envs: &HashMap, Arc>, ) -> Result { - let resolved_options = ResolvedTaskOptions::resolve(synthetic_plan_request.task_options, &cwd); - plan_spawn_execution(prefix_envs, synthetic_plan_request.command_kind, &resolved_options, envs) + let SyntheticPlanRequest { program, args, task_options } = synthetic_plan_request; + let resolved_options = ResolvedTaskOptions::resolve(task_options, &cwd); + plan_spawn_execution( + prefix_envs, + SpawnCommandKind::Program { program, args }, + &resolved_options, + envs, + ) } fn plan_spawn_execution( diff --git a/crates/vite_task_plan/src/plan_request.rs b/crates/vite_task_plan/src/plan_request.rs index 589dd536..d3318856 100644 --- a/crates/vite_task_plan/src/plan_request.rs +++ b/crates/vite_task_plan/src/plan_request.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{ffi::OsStr, sync::Arc}; use vite_str::Str; use vite_task_graph::{config::user::UserTaskOptions, query::TaskQuery}; @@ -25,8 +25,11 @@ pub struct QueryPlanRequest { /// Synthetic tasks are not defined in the task graph, but are generated on-the-fly. #[derive(Debug)] pub struct SyntheticPlanRequest { - /// The command to execute - pub command_kind: SpawnCommandKind, + /// The program to execute + pub program: Arc, + + /// The arguments to pass to the program + pub args: Arc<[Str]>, /// The task options as if it's defined in `vite.config.*` pub task_options: UserTaskOptions, diff --git a/package.json b/package.json index 26bba7c7..40db9854 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ }, "devDependencies": { "husky": "catalog:", - "lint-staged": "catalog:" + "lint-staged": "catalog:", + "oxlint": "catalog:", + "oxlint-tsgolint": "catalog:" }, "lint-staged": { "*.@(js|ts|tsx|yml|yaml|md|json|html|toml)": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd5b50f6..416ba21c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,12 @@ catalogs: lint-staged: specifier: ^16.2.6 version: 16.2.6 + oxlint: + specifier: ^1.34.0 + version: 1.34.0 + oxlint-tsgolint: + specifier: ^0.10.0 + version: 0.10.0 importers: @@ -23,9 +29,89 @@ importers: lint-staged: specifier: 'catalog:' version: 16.2.6 + oxlint: + specifier: 'catalog:' + version: 1.34.0(oxlint-tsgolint@0.10.0) + oxlint-tsgolint: + specifier: 'catalog:' + version: 0.10.0 packages: + '@oxlint-tsgolint/darwin-arm64@0.10.0': + resolution: {integrity: sha512-mhBF/pjey0UdLL1ocU46Fqta+uJuRfqrLfDpcViRg17BtDiUNd8JY9iN2FOoS2HGSCAgCUjZ0AZkwkHwFs/VTw==} + cpu: [arm64] + os: [darwin] + + '@oxlint-tsgolint/darwin-x64@0.10.0': + resolution: {integrity: sha512-roLi34mw/i1z+NS7luboix55SXyhVv38dNUTcRDkk+0lNPzI9ngrM+1y1N2oBSUmz5o9OZGnfJJ7BSGCw/fFEQ==} + cpu: [x64] + os: [darwin] + + '@oxlint-tsgolint/linux-arm64@0.10.0': + resolution: {integrity: sha512-HL9NThPH1V2F6l9XhwNmhQZUknN4m4yQYEvQFFGfZTYN6cvEEBIiqfF4KvBUg8c0xadMbQlW+Ug7/ybA9Nn+CA==} + cpu: [arm64] + os: [linux] + + '@oxlint-tsgolint/linux-x64@0.10.0': + resolution: {integrity: sha512-Tw8QNq8ab+4+qE5krvJyMA66v6XE3GoiISRD5WmJ7YOxUnu//jSw/bBm7OYf/TNEZyeV0BTR7zXzhT5R+VFWlQ==} + cpu: [x64] + os: [linux] + + '@oxlint-tsgolint/win32-arm64@0.10.0': + resolution: {integrity: sha512-LTogmTRwpwQqVaH1Ama8Wd5/VVZWBSF8v5qTbeT628+1F5Kt1V5eHBvyFh4oN18UCZlgqrh7DqkDhsieXUaC8Q==} + cpu: [arm64] + os: [win32] + + '@oxlint-tsgolint/win32-x64@0.10.0': + resolution: {integrity: sha512-ygqxx8EmNWy9/wCQS5uXq9k/o2EyYNwNxY1ZHNzlmZC/kV06Aemx5OBDafefawBNqH7xTZPfccUrjdiy+QlTrw==} + cpu: [x64] + os: [win32] + + '@oxlint/darwin-arm64@1.34.0': + resolution: {integrity: sha512-euz3Dtp5/UE9axFkQnllOWp3gOwoqaxfZPUUwiW8HBelqhI9PRMVIfQ/akmwl+G5XixQZIgXkXQ5SJxnb1+Qww==} + cpu: [arm64] + os: [darwin] + + '@oxlint/darwin-x64@1.34.0': + resolution: {integrity: sha512-XpmNviE5KOnHkhmQPwJJIBs+mJkr0qItTZBN4dz+O3p9gWN+gCqi3CBP71RiVahZw4qAEQSgY4wro+z0kx+erg==} + cpu: [x64] + os: [darwin] + + '@oxlint/linux-arm64-gnu@1.34.0': + resolution: {integrity: sha512-aCPdoEUGsJGF9y88vDYoaugG4IEGwSBa+usyuAvEVl3vTfuTmE0RDQEC1Z+WnJ3J/cIEpbgKOzS12VwbzFicjg==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxlint/linux-arm64-musl@1.34.0': + resolution: {integrity: sha512-cMo72LQBFmdnVLRKLAHD94ZUBq5Z+aA9Y+RKzkjhCmJuef5ZAfKC24TJD/6c5LxGYzkwwmyySoQAHq5B69i3PQ==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxlint/linux-x64-gnu@1.34.0': + resolution: {integrity: sha512-+9xFhhkqgNIysEh+uHvcba8v4UtL1YzxuyDS2wTLdWrkGvIllCx5WjJItt3K/AhwatciksgNEXSo2Hh4fcQRog==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxlint/linux-x64-musl@1.34.0': + resolution: {integrity: sha512-qa7TL2DfEDdMeSP5UiU5JMs6D2PW7ZJAQ0WZYTgqDV8BlZ6nMkIYVBVIk3QPxIfkyxvfJVbG1RB3PkSWDcfwpA==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxlint/win32-arm64@1.34.0': + resolution: {integrity: sha512-mSJumUveg1S3DiOgvsrVNAGuvenBbbC/zsfT1qhltT+GLhJ7RPBK2I/jz0fTdE+I7M9/as8yc0XJ/eY23y2amA==} + cpu: [arm64] + os: [win32] + + '@oxlint/win32-x64@1.34.0': + resolution: {integrity: sha512-izsDDt5WY4FSISCkPRLUYQD1aRaaEJkPLtEZe3DlioSUdUVAdvVbE+BGllFqR16DWfTTwO/6K4jDeooxQzTMjw==} + cpu: [x64] + os: [win32] + ansi-escapes@7.1.1: resolution: {integrity: sha512-Zhl0ErHcSRUaVfGUeUdDuLgpkEo8KIFjB4Y9uAc46ScOpdDiU1Dbyplh7qWJeJ/ZHpbyMSM26+X3BySgnIz40Q==} engines: {node: '>=18'} @@ -117,6 +203,20 @@ packages: resolution: {integrity: sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==} engines: {node: '>=18'} + oxlint-tsgolint@0.10.0: + resolution: {integrity: sha512-LDDSIu5J/4D4gFUuQQIEQpAC6maNEbMg4nC8JL/+Pe0cUDR86dtVZ09E2x5MwCh8f9yfktoaxt5x6UIVyzrajg==} + hasBin: true + + oxlint@1.34.0: + resolution: {integrity: sha512-Ni0N8wAiKlgaYkI/Yz4VrutfVIZgd2shDtS+loQxyBTwO8YUAnk3+g7OQ1cyI/aatHiFwvFNfV/uvZyHUtyPpA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + oxlint-tsgolint: '>=0.9.2' + peerDependenciesMeta: + oxlint-tsgolint: + optional: true + picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -172,6 +272,48 @@ packages: snapshots: + '@oxlint-tsgolint/darwin-arm64@0.10.0': + optional: true + + '@oxlint-tsgolint/darwin-x64@0.10.0': + optional: true + + '@oxlint-tsgolint/linux-arm64@0.10.0': + optional: true + + '@oxlint-tsgolint/linux-x64@0.10.0': + optional: true + + '@oxlint-tsgolint/win32-arm64@0.10.0': + optional: true + + '@oxlint-tsgolint/win32-x64@0.10.0': + optional: true + + '@oxlint/darwin-arm64@1.34.0': + optional: true + + '@oxlint/darwin-x64@1.34.0': + optional: true + + '@oxlint/linux-arm64-gnu@1.34.0': + optional: true + + '@oxlint/linux-arm64-musl@1.34.0': + optional: true + + '@oxlint/linux-x64-gnu@1.34.0': + optional: true + + '@oxlint/linux-x64-musl@1.34.0': + optional: true + + '@oxlint/win32-arm64@1.34.0': + optional: true + + '@oxlint/win32-x64@1.34.0': + optional: true + ansi-escapes@7.1.1: dependencies: environment: 1.1.0 @@ -257,6 +399,27 @@ snapshots: dependencies: mimic-function: 5.0.1 + oxlint-tsgolint@0.10.0: + optionalDependencies: + '@oxlint-tsgolint/darwin-arm64': 0.10.0 + '@oxlint-tsgolint/darwin-x64': 0.10.0 + '@oxlint-tsgolint/linux-arm64': 0.10.0 + '@oxlint-tsgolint/linux-x64': 0.10.0 + '@oxlint-tsgolint/win32-arm64': 0.10.0 + '@oxlint-tsgolint/win32-x64': 0.10.0 + + oxlint@1.34.0(oxlint-tsgolint@0.10.0): + optionalDependencies: + '@oxlint/darwin-arm64': 1.34.0 + '@oxlint/darwin-x64': 1.34.0 + '@oxlint/linux-arm64-gnu': 1.34.0 + '@oxlint/linux-arm64-musl': 1.34.0 + '@oxlint/linux-x64-gnu': 1.34.0 + '@oxlint/linux-x64-musl': 1.34.0 + '@oxlint/win32-arm64': 1.34.0 + '@oxlint/win32-x64': 1.34.0 + oxlint-tsgolint: 0.10.0 + picomatch@2.3.1: {} pidtree@0.6.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d53a4c96..fd6770f7 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,9 +4,11 @@ packages: catalog: husky: ^9.1.7 lint-staged: ^16.2.6 + oxlint: ^1.34.0 + oxlint-tsgolint: ^0.10.0 catalogMode: prefer minimumReleaseAge: 1440 -minimumReleaseAgeExclude: +minimumReleaseAgeExclude: null From d1997e82fe11c92725862d6a47524fd79ff3a977 Mon Sep 17 00:00:00 2001 From: branchseer Date: Tue, 23 Dec 2025 23:46:01 +0800 Subject: [PATCH 02/27] update --- Cargo.lock | 1 + Cargo.toml | 1 + crates/vite_task/Cargo.toml | 5 +- crates/vite_task/src/execute/cache.rs | 301 +++++++++++++++++++ crates/vite_task/src/execute/event.rs | 68 +++++ crates/vite_task/src/execute/execute_plan.rs | 129 ++++++-- crates/vite_task/src/execute/mod.rs | 3 +- crates/vite_task/src/execute/reporter.rs | 25 -- crates/vite_task/src/session.rs | 28 +- crates/vite_task_plan/src/context.rs | 23 +- crates/vite_task_plan/src/error.rs | 16 + crates/vite_task_plan/src/in_process.rs | 4 + crates/vite_task_plan/src/lib.rs | 27 +- crates/vite_task_plan/src/plan.rs | 66 +++- package.json | 3 +- 15 files changed, 626 insertions(+), 74 deletions(-) create mode 100644 crates/vite_task/src/execute/cache.rs create mode 100644 crates/vite_task/src/execute/event.rs delete mode 100644 crates/vite_task/src/execute/reporter.rs diff --git a/Cargo.lock b/Cargo.lock index a35c4f01..396e2533 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3253,6 +3253,7 @@ dependencies = [ "tempfile", "thiserror 2.0.17", "tokio", + "tokio-stream", "toml", "tracing", "twox-hash", diff --git a/Cargo.toml b/Cargo.toml index a11bcb2e..08bf0085 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,6 +109,7 @@ tempfile = "3.14.0" test-log = { version = "0.2.18", features = ["trace"] } thiserror = "2" tokio = "1.48.0" +tokio-stream = "0.1.17" tokio-util = "0.7.17" toml = "0.9.5" tracing = "0.1.43" diff --git a/crates/vite_task/Cargo.toml b/crates/vite_task/Cargo.toml index 25b22fd0..be70ec5f 100644 --- a/crates/vite_task/Cargo.toml +++ b/crates/vite_task/Cargo.toml @@ -19,7 +19,7 @@ bstr = { workspace = true } clap = { workspace = true, features = ["derive"] } compact_str = { workspace = true, features = ["serde"] } dashmap = { workspace = true } -derive_more = { workspace = true } +derive_more = { workspace = true, features = ["from"] } diff-struct = { workspace = true } fspy = { workspace = true } futures-core = { workspace = true } @@ -36,7 +36,8 @@ shell-escape = { workspace = true } supports-color = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } -tokio = { workspace = true, features = ["rt-multi-thread", "io-std", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread", "io-std", "macros", "sync"] } +tokio-stream = { workspace = true } tracing = { workspace = true } twox-hash = { workspace = true } uuid = { workspace = true, features = ["v4"] } diff --git a/crates/vite_task/src/execute/cache.rs b/crates/vite_task/src/execute/cache.rs new file mode 100644 index 00000000..ae36a723 --- /dev/null +++ b/crates/vite_task/src/execute/cache.rs @@ -0,0 +1,301 @@ +use std::{fmt::Display, io::Write, sync::Arc, time::Duration}; + +// use bincode::config::{Configuration, standard}; +use bincode::{Decode, Encode, decode_from_slice, encode_to_vec}; +use rusqlite::{Connection, OptionalExtension as _, config::DbConfig}; +use serde::{Deserialize, Serialize}; +use tokio::sync::Mutex; +use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf}; +use vite_str::Str; + +use crate::{ + Error, + config::{CommandFingerprint, ResolvedTask, TaskId}, + execute::{ExecutedTask, StdOutput}, + fingerprint::{PostRunFingerprint, PostRunFingerprintMismatch}, + fs::FileSystem, +}; + +/// Command cache value, for validating post-run fingerprint after the command fingerprint is matched, +/// and replaying the std outputs if validated. +#[derive(Debug, Encode, Decode, Serialize)] +pub struct CommandCacheValue { + pub post_run_fingerprint: PostRunFingerprint, + pub std_outputs: Arc<[StdOutput]>, + pub duration: Duration, +} + +impl CommandCacheValue { + pub fn create( + executed_task: ExecutedTask, + fs: &impl FileSystem, + base_dir: &AbsolutePath, + fingerprint_ignores: Option<&[Str]>, + ) -> Result { + let post_run_fingerprint = + PostRunFingerprint::create(&executed_task, fs, base_dir, fingerprint_ignores)?; + Ok(Self { + post_run_fingerprint, + std_outputs: executed_task.std_outputs, + duration: executed_task.duration, + }) + } +} + +#[derive(Debug)] +pub struct TaskCache { + conn: Mutex, +} + +/// Cache key to identify an execution directly from a custom vite-task subcommand. +#[derive(Debug, Encode, Decode, Serialize)] +pub struct DirectExecutionCacheKey { + pub synthesization_cache_key: Arc<[Str]>, + pub plan_cwd: RelativePathBuf, +} + +/// Cache key to identify an execution from a user-defined task. +#[derive(Debug, Encode, Decode, Serialize)] +pub struct UserTaskExecutionCacheKey { + pub synthesization_cache_key: Arc<[Str]>, + pub plan_cwd: RelativePathBuf, +} + +/// Key to identify an execution. +#[derive(Debug, Encode, Decode, Serialize)] +pub enum ExecutionCacheKey { + /// This execution is directly from a custom vite-task subcommand (like `vite lint`). + /// + /// Note that this is only for the case where the subcommand is directly typed in the cli, + /// not from a task script (like `"lint-task": "vite lint"`), which is covered by the `Task` variant. + Direct(DirectExecutionCacheKey), + + /// This execution is from a task script. + UserTask(UserTaskExecutionCacheKey), +} + +const BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard(); + +#[derive(Debug, Serialize, Deserialize, Clone)] +pub enum CacheMiss { + NotFound, + FingerprintMismatch(FingerprintMismatch), +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +pub enum FingerprintMismatch { + /// Found the cache entry of the same task run, but the command fingerprint mismatches + /// this happens when the command itself or an env changes. + CommandFingerprintMismatch(CommandFingerprint), + /// Found the cache entry with the same command fingerprint, but the post-run fingerprint mismatches + PostRunFingerprintMismatch(PostRunFingerprintMismatch), +} + +impl Display for FingerprintMismatch { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::CommandFingerprintMismatch(diff) => { + // TODO: improve the display of command fingerprint diff + write!(f, "Command fingerprint changed: {diff:?}") + } + Self::PostRunFingerprintMismatch(diff) => Display::fmt(diff, f), + } + } +} + +impl TaskCache { + pub fn load_from_path(cache_path: AbsolutePathBuf) -> Result { + let path: &AbsolutePath = cache_path.as_ref(); + tracing::info!("Creating task cache directory at {:?}", path); + std::fs::create_dir_all(path)?; + + let db_path = path.join("cache.db"); + let conn = Connection::open(db_path.as_path())?; + conn.execute_batch("PRAGMA journal_mode=WAL;")?; + loop { + let user_version: u32 = conn.query_one("PRAGMA user_version", (), |row| row.get(0))?; + match user_version { + 0 => { + // fresh new db + conn.execute( + "CREATE TABLE command_cache (key BLOB PRIMARY KEY, value BLOB);", + (), + )?; + conn.execute( + "CREATE TABLE taskrun_to_command (key BLOB PRIMARY KEY, value BLOB);", + (), + )?; + // Bump to version 3 to invalidate cache entries due to a change in the serialized cache key content + // (addition of the `fingerprint_ignores` field). No schema change was made. + conn.execute("PRAGMA user_version = 3", ())?; + } + 1..=2 => { + // old internal db version. reset + conn.set_db_config(DbConfig::SQLITE_DBCONFIG_RESET_DATABASE, true)?; + conn.execute("VACUUM", ())?; + conn.set_db_config(DbConfig::SQLITE_DBCONFIG_RESET_DATABASE, false)?; + } + 3 => break, // current version + 4.. => return Err(Error::UnrecognizedDbVersion(user_version)), + } + } + Ok(Self { conn: Mutex::new(conn) }) + } + + #[tracing::instrument] + pub async fn save(self) -> Result<(), Error> { + // do some cleanup in the future + Ok(()) + } + + pub async fn update( + &self, + resolved_task: &ResolvedTask, + cached_task: CommandCacheValue, + ) -> Result<(), Error> { + let task_run_key: ExecutionCacheKey = todo!(); + let command_fingerprint = &resolved_task.resolved_command.fingerprint; + self.upsert_command_cache(command_fingerprint, &cached_task).await?; + self.upsert_taskrun_to_command(&task_run_key, command_fingerprint).await?; + Ok(()) + } + + /// Tries to get the task cache if the fingerprint matches, otherwise returns why the cache misses + pub async fn try_hit( + &self, + task: &ResolvedTask, + fs: &impl FileSystem, + base_dir: &AbsolutePath, + ) -> Result, Error> { + let task_run_key: ExecutionCacheKey = todo!(); + let command_fingerprint = &task.resolved_command.fingerprint; + // Try to directly find the command cache by command fingerprint first, ignoring the task run key + if let Some(cache_value) = + self.get_command_cache_by_command_fingerprint(command_fingerprint).await? + { + if let Some(post_run_fingerprint_mismatch) = + cache_value.post_run_fingerprint.validate(fs, base_dir)? + { + // Found the command cache with the same command fingerprint, but the post-run fingerprint mismatches + Ok(Err(CacheMiss::FingerprintMismatch( + FingerprintMismatch::PostRunFingerprintMismatch(post_run_fingerprint_mismatch), + ))) + } else { + // Associate the task run key to the command fingerprint if not already, + // so that next time we can find it and report command fingerprint mismatch + self.upsert_taskrun_to_command(&task_run_key, command_fingerprint).await?; + Ok(Ok(cache_value)) + } + } else if let Some(command_fingerprint_in_cache) = + self.get_command_fingerprint_by_task_run_key(&task_run_key).await? + { + // No command cache found with the current command fingerprint, + // but found a command fingerprint associated with the same task run key, + // meaning the command or env has changed since last run + Ok(Err(CacheMiss::FingerprintMismatch( + FingerprintMismatch::CommandFingerprintMismatch(command_fingerprint_in_cache), + ))) + } else { + Ok(Err(CacheMiss::NotFound)) + } + } +} + +// basic database operations +impl TaskCache { + async fn get_key_by_value>( + &self, + table: &str, + key: &K, + ) -> Result, Error> { + let conn = self.conn.lock().await; + let mut select_stmt = + conn.prepare_cached(&format!("SELECT value FROM {table} WHERE key=?"))?; + let key_blob = encode_to_vec(key, BINCODE_CONFIG)?; + let Some(value_blob) = + select_stmt.query_row::, _, _>([key_blob], |row| row.get(0)).optional()? + else { + return Ok(None); + }; + let (value, _) = decode_from_slice::(&value_blob, BINCODE_CONFIG)?; + Ok(Some(value)) + } + + async fn get_command_cache_by_command_fingerprint( + &self, + command_fingerprint: &CommandFingerprint, + ) -> Result, Error> { + self.get_key_by_value("command_cache", command_fingerprint).await + } + + async fn get_command_fingerprint_by_task_run_key( + &self, + task_run_key: &ExecutionCacheKey, + ) -> Result, Error> { + self.get_key_by_value("taskrun_to_command", task_run_key).await + } + + async fn upsert( + &self, + table: &str, + key: &K, + value: &V, + ) -> Result<(), Error> { + let conn = self.conn.lock().await; + let key_blob = encode_to_vec(key, BINCODE_CONFIG)?; + let value_blob = encode_to_vec(value, BINCODE_CONFIG)?; + let mut update_stmt = conn.prepare_cached(&format!( + "INSERT INTO {table} (key, value) VALUES (?1, ?2) ON CONFLICT(key) DO UPDATE SET value=?2" + ))?; + update_stmt.execute([key_blob, value_blob])?; + Ok(()) + } + + async fn upsert_command_cache( + &self, + command_fingerprint: &CommandFingerprint, + cached_task: &CommandCacheValue, + ) -> Result<(), Error> { + self.upsert("command_cache", command_fingerprint, cached_task).await + } + + async fn upsert_taskrun_to_command( + &self, + task_run_key: &ExecutionCacheKey, + command_fingerprint: &CommandFingerprint, + ) -> Result<(), Error> { + self.upsert("taskrun_to_command", task_run_key, command_fingerprint).await + } + + async fn list_table + Serialize, V: Decode<()> + Serialize>( + &self, + table: &str, + out: &mut impl Write, + ) -> Result<(), Error> { + let conn = self.conn.lock().await; + let mut select_stmt = conn.prepare_cached(&format!("SELECT key, value FROM {table}"))?; + let mut rows = select_stmt.query([])?; + while let Some(row) = rows.next()? { + let key_blob: Vec = row.get(0)?; + let value_blob: Vec = row.get(1)?; + let (key, _) = decode_from_slice::(&key_blob, BINCODE_CONFIG)?; + let (value, _) = decode_from_slice::(&value_blob, BINCODE_CONFIG)?; + writeln!( + out, + "{} => {}", + serde_json::to_string_pretty(&key)?, + serde_json::to_string_pretty(&value)? + )?; + } + Ok(()) + } + + pub async fn list(&self, mut out: impl Write) -> Result<(), Error> { + out.write_all(b"------- taskrun_to_command -------\n")?; + self.list_table::("taskrun_to_command", &mut out) + .await?; + out.write_all(b"------- command_cache -------\n")?; + self.list_table::("command_cache", &mut out).await?; + Ok(()) + } +} diff --git a/crates/vite_task/src/execute/event.rs b/crates/vite_task/src/execute/event.rs new file mode 100644 index 00000000..63c41802 --- /dev/null +++ b/crates/vite_task/src/execute/event.rs @@ -0,0 +1,68 @@ +use std::sync::Arc; + +use bstr::BString; +use vite_path::AbsolutePath; +use vite_str::Str; + +use crate::collections::HashMap; + +#[derive(Clone, Debug)] +pub struct TaskInfo { + pub task_display_name: Str, + pub command: Str, + pub plan_cwd: Arc, +} + +#[derive(Debug)] +pub enum OutputKind { + Stdout, + Stderr, +} + +#[derive(Debug)] +pub enum CacheDisabledReason { + InProcessExecution, +} + +#[derive(Debug)] +pub enum CacheStatus { + Disabled(CacheDisabledReason), + Miss, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct ExecutionId(u32); + +impl ExecutionId { + pub(crate) fn zero() -> Self { + Self(0) + } + + pub(crate) fn next(&self) -> Self { + Self(self.0.checked_add(1).expect("ExecutionId overflow")) + } +} + +pub struct ExecutionStartedEvent { + pub execution_id: ExecutionId, + pub display: TaskInfo, +} + +pub struct ExecutionOutputEvent { + pub execution_id: ExecutionId, + pub kind: OutputKind, + pub content: BString, +} + +#[derive(Debug)] +pub struct ExecutionEvent { + pub execution_id: ExecutionId, + pub kind: ExecutionEventKind, +} + +#[derive(Debug)] +pub enum ExecutionEventKind { + Start { task_info: Option }, + Output { kind: OutputKind, content: BString }, + Finish { status: Option, cache_status: CacheStatus }, +} diff --git a/crates/vite_task/src/execute/execute_plan.rs b/crates/vite_task/src/execute/execute_plan.rs index e711fb04..8010606b 100644 --- a/crates/vite_task/src/execute/execute_plan.rs +++ b/crates/vite_task/src/execute/execute_plan.rs @@ -1,17 +1,25 @@ use core::task; +use std::sync::Arc; +use futures_util::FutureExt; use petgraph::{ algo::{Cycle, toposort}, graph::DiGraph, }; use vite_task_graph::IndexedTaskGraph; use vite_task_plan::{ - ExecutionItemKind, ExecutionPlan, LeafExecutionKind, TaskExecution, + ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnCommandKind, SpawnExecution, + TaskExecution, execution_graph::{ExecutionGraph, ExecutionIx, ExecutionNodeIndex}, }; -use super::reporter::Reporter; -use crate::execute::reporter; +use super::{ + cache::{ExecutionCacheKey, TaskCache}, + event::{ + CacheDisabledReason, CacheStatus, ExecutionEvent, ExecutionEventKind, ExecutionId, + ExecutionStartedEvent, OutputKind, TaskInfo, + }, +}; #[derive(Debug, thiserror::Error)] pub enum ExecuteError { @@ -21,16 +29,16 @@ pub enum ExecuteError { struct ExecutionContext<'a> { indexed_task_graph: Option<&'a IndexedTaskGraph>, - reporter: &'a mut (dyn Reporter + 'a), - last_execution_id: u32, + event_handler: &'a mut (dyn FnMut(ExecutionEvent) + 'a), + current_execution_id: ExecutionId, + cache: &'a TaskCache, } impl ExecutionContext<'_> { - fn execute_item_kind( + async fn execute_item_kind( &mut self, item_kind: &ExecutionItemKind, - task_display: &str, - command: &str, + task_info: Option, ) -> Result<(), ExecuteError> { match item_kind { ExecutionItemKind::Expanded(graph) => { @@ -66,42 +74,111 @@ impl ExecutionContext<'_> { indexed_task_graph.display_task(task_execution.task_node_index); for (index, item) in task_execution.items.iter().enumerate() { let item_command = &task_command[item.command_span.clone()]; - - let task_display_str = if task_execution.items.len() > 1 { - vite_str::format!("{} ({})", task_display, index) - } else { - vite_str::format!("{}", task_display) + let task_info = TaskInfo { + task_display_name: if task_execution.items.len() > 1 { + vite_str::format!("{} ({})", task_display, index) + } else { + vite_str::format!("{}", task_display) + }, + command: item_command.into(), }; - - for item in &task_execution.items { - self.execute_item_kind(&item.kind, command, &task_display_str)?; - } + self.execute_item_kind(&item.kind, Some(task_info)).boxed_local().await?; } } } ExecutionItemKind::Leaf(leaf_execution_kind) => { - self.execute_leaf(leaf_execution_kind, command)?; + let execution_id = self.current_execution_id; + self.current_execution_id = self.current_execution_id.next(); + + self.execute_leaf(leaf_execution_kind, task_info, todo!()).await?; } } Ok(()) } - fn execute_leaf( + async fn execute_leaf( &mut self, leaf_execution_kind: &LeafExecutionKind, - command: &str, + task_info: Option, + task_run_cache_key: Option, ) -> Result<(), ExecuteError> { + let execution_id = self.current_execution_id; + self.current_execution_id = self.current_execution_id.next(); + + (self.event_handler)(ExecutionEvent { + execution_id, + kind: ExecutionEventKind::Start { task_info }, + }); + + match leaf_execution_kind { + LeafExecutionKind::InProcess(in_process_execution) => { + let execution_output = in_process_execution.execute().await; + (self.event_handler)(ExecutionEvent { + execution_id, + kind: ExecutionEventKind::Output { + kind: OutputKind::Stdout, + content: execution_output.stdout.into(), + }, + }); + (self.event_handler)(ExecutionEvent { + execution_id, + kind: ExecutionEventKind::Finish { + status: Some(0), + cache_status: CacheStatus::Disabled( + CacheDisabledReason::InProcessExecution, + ), + }, + }); + } + LeafExecutionKind::Spawn(spawn_execution) => { + self.execute_spawn(execution_id, spawn_execution).await?; + } + } Ok(()) } + + async fn execute_spawn( + &mut self, + execution_id: ExecutionId, + spawn_execution: &SpawnExecution, + ) -> Result<(), ExecuteError> { + let mut cmd = match &spawn_execution.command_kind { + SpawnCommandKind::Program { program, args } => { + let mut cmd = fspy::Command::new(&*program); + cmd.args(args.iter().map(|arg| arg.as_str())); + cmd + } + SpawnCommandKind::ShellScript(script) => { + let mut cmd = if cfg!(windows) { + let mut cmd = fspy::Command::new("cmd.exe"); + // https://github.com/nodejs/node/blob/dbd24b165128affb7468ca42f69edaf7e0d85a9a/lib/child_process.js#L633 + cmd.args(["/d", "/s", "/c"]); + cmd + } else { + let mut cmd = fspy::Command::new("sh"); + cmd.args(["-c"]); + cmd + }; + cmd.arg(script); + cmd + } + }; + cmd.envs(spawn_execution.all_envs.iter()).current_dir(&*spawn_execution.cwd); + todo!() + } } -pub fn execute_plan( +pub async fn execute_plan( plan: &ExecutionPlan, indexed_task_graph: Option<&IndexedTaskGraph>, - reporter: &mut (dyn Reporter + '_), - command: &str, + event_handler: &mut (dyn FnMut(ExecutionEvent) + '_), + cache: &TaskCache, ) -> Result<(), ExecuteError> { - let mut execution_context = - ExecutionContext { indexed_task_graph, reporter, last_execution_id: 0 }; - execution_context.execute_item_kind(plan.root_node(), command, command) + let mut execution_context = ExecutionContext { + indexed_task_graph, + event_handler, + current_execution_id: ExecutionId::zero(), + cache, + }; + execution_context.execute_item_kind(plan.root_node(), None).await } diff --git a/crates/vite_task/src/execute/mod.rs b/crates/vite_task/src/execute/mod.rs index 7ddba633..db929ad8 100644 --- a/crates/vite_task/src/execute/mod.rs +++ b/crates/vite_task/src/execute/mod.rs @@ -1,5 +1,6 @@ +pub(crate) mod cache; +pub mod event; pub mod execute_plan; -pub mod reporter; use std::{ collections::hash_map::Entry, diff --git a/crates/vite_task/src/execute/reporter.rs b/crates/vite_task/src/execute/reporter.rs deleted file mode 100644 index 933bc2d6..00000000 --- a/crates/vite_task/src/execute/reporter.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::sync::Arc; - -use vite_path::AbsolutePath; -use vite_str::Str; - -use crate::collections::HashMap; - -pub struct ExecutionDisplay { - command: Str, - cwd: Arc, -} - -pub enum OutputKind { - Stdout, - Stderr, -} - -pub enum ExecutionEvent { - Output { kind: OutputKind, content: Vec }, - Finished { status: Option, cache_status: () }, -} - -pub trait Reporter { - fn new_execution(&mut self, display: ExecutionDisplay); -} diff --git a/crates/vite_task/src/session.rs b/crates/vite_task/src/session.rs index 3b499494..3aff3454 100644 --- a/crates/vite_task/src/session.rs +++ b/crates/vite_task/src/session.rs @@ -1,7 +1,7 @@ use std::{ffi::OsStr, fmt::Debug, sync::Arc}; use clap::{Parser, Subcommand}; -use vite_path::AbsolutePath; +use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskGraph, TaskGraphLoadError, loader::UserConfigLoader}; use vite_task_plan::{ @@ -10,7 +10,7 @@ use vite_task_plan::{ }; use vite_workspace::{WorkspaceRoot, find_workspace_root}; -use crate::{CLIArgs, collections::HashMap}; +use crate::{CLIArgs, TaskCache, collections::HashMap}; #[derive(Debug)] enum LazyTaskGraph<'a> { @@ -116,6 +116,16 @@ pub struct Session<'a, CustomSubCommand> { cwd: Arc, plan_request_parser: PlanRequestParser<'a, CustomSubCommand>, + + cache: TaskCache, +} + +fn get_cache_path_of_workspace(workspace_root: &AbsolutePath) -> AbsolutePathBuf { + if let Ok(env_cache_path) = std::env::var("VITE_CACHE_PATH") { + AbsolutePathBuf::new(env_cache_path.into()).expect("Cache path should be absolute") + } else { + workspace_root.join("node_modules/.vite/task-cache") + } } impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { @@ -134,6 +144,15 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { callbacks: SessionCallbacks<'a, CustomSubCommand>, ) -> anyhow::Result { let (workspace_root, _) = find_workspace_root(&cwd)?; + let cache_path = get_cache_path_of_workspace(&workspace_root.path); + + if !cache_path.as_path().exists() + && let Some(cache_dir) = cache_path.as_path().parent() + { + tracing::info!("Creating task cache directory at {}", cache_dir.display()); + std::fs::create_dir_all(cache_dir)?; + } + let cache = TaskCache::load_from_path(cache_path)?; Ok(Self { workspace_path: Arc::clone(&workspace_root.path), lazy_task_graph: LazyTaskGraph::Uninitialized { @@ -143,9 +162,14 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { envs, cwd, plan_request_parser: PlanRequestParser { task_synthesizer: callbacks.task_synthesizer }, + cache, }) } + pub fn cache(&self) -> &TaskCache { + &self.cache + } + pub fn task_graph(&self) -> Option<&TaskGraph> { match &self.lazy_task_graph { LazyTaskGraph::Initialized(graph) => Some(graph.task_graph()), diff --git a/crates/vite_task_plan/src/context.rs b/crates/vite_task_plan/src/context.rs index d50803a5..75c4ed51 100644 --- a/crates/vite_task_plan/src/context.rs +++ b/crates/vite_task_plan/src/context.rs @@ -3,6 +3,7 @@ use std::{ }; use vite_path::AbsolutePath; +use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex, display::TaskDisplay}; use crate::{PlanRequestParser, path_env::prepend_path_env}; @@ -31,6 +32,10 @@ pub struct PlanContext<'a> { /// The current call stack of task index nodes being planned. task_call_stack: Vec<(TaskNodeIndex, Range)>, + /// The extra args (`vite run task [extra_arg...]`). + /// It may come from real cli args, or commands in task scripts. + extra_args: Arc<[Str]>, + indexed_task_graph: &'a IndexedTaskGraph, } @@ -75,7 +80,14 @@ impl<'a> PlanContext<'a> { callbacks: &'a mut (dyn PlanRequestParser + 'a), indexed_task_graph: &'a IndexedTaskGraph, ) -> Self { - Self { cwd, envs, callbacks, task_call_stack: Vec::new(), indexed_task_graph } + Self { + cwd, + envs, + callbacks, + task_call_stack: Vec::new(), + indexed_task_graph, + extra_args: Default::default(), + } } pub fn cwd(&self) -> &Arc { @@ -139,6 +151,14 @@ impl<'a> PlanContext<'a> { } } + pub fn extra_args(&self) -> &Arc<[Str]> { + &self.extra_args + } + + pub fn set_extra_args(&mut self, extra_args: Arc<[Str]>) { + self.extra_args = extra_args; + } + pub fn duplicate(&mut self) -> PlanContext<'_> { PlanContext { cwd: Arc::clone(&self.cwd), @@ -146,6 +166,7 @@ impl<'a> PlanContext<'a> { callbacks: self.callbacks, task_call_stack: self.task_call_stack.clone(), indexed_task_graph: self.indexed_task_graph, + extra_args: Arc::clone(&self.extra_args), } } } diff --git a/crates/vite_task_plan/src/error.rs b/crates/vite_task_plan/src/error.rs index 45e00a30..20fd1119 100644 --- a/crates/vite_task_plan/src/error.rs +++ b/crates/vite_task_plan/src/error.rs @@ -5,6 +5,15 @@ use crate::{ envs::ResolveEnvError, }; +#[derive(Debug, thiserror::Error)] +pub enum CdCommandError { + #[error("No home directory found for 'cd' command with no arguments")] + NoHomeDirectory, + + #[error("Too many args for 'cd' command")] + ToManyArgs, +} + /// Errors that can occur when planning a specific execution from a task . #[derive(Debug, thiserror::Error)] pub enum TaskPlanErrorKind { @@ -15,6 +24,13 @@ pub enum TaskPlanErrorKind { vite_task_graph::TaskGraphLoadError, ), + #[error("Failed to execute 'cd' command")] + CdCommandError( + #[source] + #[from] + CdCommandError, + ), + #[error("Failed to query tasks from task graph")] TaskQueryError( #[source] diff --git a/crates/vite_task_plan/src/in_process.rs b/crates/vite_task_plan/src/in_process.rs index 425fb974..c6ed141b 100644 --- a/crates/vite_task_plan/src/in_process.rs +++ b/crates/vite_task_plan/src/in_process.rs @@ -1,3 +1,6 @@ +use std::sync::Arc; + +use vite_path::AbsolutePath; use vite_str::Str; /// The output of an in-process execution. @@ -50,6 +53,7 @@ impl InProcessExecution { pub fn get_builtin_execution( name: &str, mut args: impl Iterator>, + _cwd: &Arc, ) -> Option { match name { "echo" => { diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 4410003a..2ab515c4 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -25,7 +25,7 @@ use crate::path_env::prepend_path_env; /// Resolved cache configuration for a spawn execution. #[derive(Debug)] -pub struct ResolvedCacheConfig { +pub struct ResolvedCacheMetadata { /// Environment variables that are used for fingerprinting the cache. pub resolved_envs: ResolvedEnvs, } @@ -35,8 +35,8 @@ pub struct ResolvedCacheConfig { /// like resolved environment variables, current working directory, and additional args from cli. #[derive(Debug)] pub struct SpawnExecution { - /// Resolved cache configuration for this execution. `None` means caching is disabled. - pub resolved_cache_config: Option, + /// Resolved cache metadata for this execution. `None` means caching is disabled. + pub resolved_cache_metadata: Option, /// Environment variables to set for the command, including both fingerprinted and pass-through envs. pub all_envs: Arc, Arc>>, @@ -78,6 +78,23 @@ pub struct ExecutionItem { /// The actual execution info (if this is spawn) is in `SpawnExecutionItem.command_kind`. pub command_span: Range, + /// Extra args appended to this execution item from the cli (`vite run task [extra_args...]`). + /// This is for computing the cache key along with the associated task. + /// + /// `kind` already contains the full resolved args for execution. No need to append these again. + pub extra_args: Arc<[Str]>, + + /// The cwd when this execution item is planned. + /// This is for displaying purpose only. + /// + /// `SpawnExecution.cwd` contains the actual cwd for execution. + /// These two may differ if the task synthesizer returns a task with a different cwd. + /// + /// Hypothetically , if `vite lint-src` under cwd `packages/lib` synthesizes a task spawning `oxlint` under `packages/lib/src`. + /// The spawned process' cwd will be `packages/lib/src`, while this field will be `packages/lib`, + /// which will be displayed like `packages/lib$ vite lint-src``. + pub plan_cwd: Arc, + /// The kind of this execution item pub kind: ExecutionItemKind, } @@ -110,8 +127,8 @@ pub trait PlanRequestParser: Debug { /// /// - If it returns `Err`, the planning will abort with the returned error. /// - If it returns `Ok(None)`, the command will be spawned as a normal process. - /// - If it returns `Ok(Some(ParsedArgs::TaskQuery)`, the command will be expanded as a `ExpandedExecution` with a task graph queried from the returned `TaskQuery`. - /// - If it returns `Ok(Some(ParsedArgs::Synthetic)`, the command will become a `SpawnExecution` with the synthetic task. + /// - If it returns `Ok(Some(PlanRequest::Query)`, the command will be expanded as a `ExpandedExecution` with a task graph queried from the returned `TaskQuery`. + /// - If it returns `Ok(Some(PlanRequest::Synthetic)`, the command will become a `SpawnExecution` with the synthetic task. async fn get_plan_request( &mut self, program: &str, diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index ede2894b..0864a460 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -1,6 +1,9 @@ use std::{ + borrow::Cow, collections::{BTreeMap, HashMap}, + env::home_dir, ffi::OsStr, + path::Path, sync::Arc, }; @@ -11,10 +14,10 @@ use vite_str::Str; use vite_task_graph::{TaskNodeIndex, config::ResolvedTaskOptions}; use crate::{ - ExecutionItem, ExecutionItemKind, LeafExecutionKind, PlanContext, ResolvedCacheConfig, + ExecutionItem, ExecutionItemKind, LeafExecutionKind, PlanContext, ResolvedCacheMetadata, SpawnCommandKind, SpawnExecution, TaskExecution, envs::ResolvedEnvs, - error::{Error, TaskPlanErrorKind, TaskPlanErrorKindResultExt}, + error::{CdCommandError, Error, TaskPlanErrorKind, TaskPlanErrorKindResultExt}, execution_graph::{ExecutionGraph, ExecutionNodeIndex}, in_process::InProcessExecution, plan_request::{PlanRequest, QueryPlanRequest, SyntheticPlanRequest}, @@ -48,30 +51,63 @@ async fn plan_task_as_execution_node( let mut items = Vec::::new(); + let mut cwd = Arc::clone(context.cwd()); + // TODO: variable expansion (https://crates.io/crates/shellexpand) BEFORE parsing // Try to parse the command string as a list of subcommands separated by `&&` if let Some(parsed_subcommands) = try_parse_as_and_list(command_str) { - for (and_item, add_item_span) in parsed_subcommands { + let and_item_count = parsed_subcommands.len(); + for (index, (and_item, add_item_span)) in parsed_subcommands.into_iter().enumerate() { // Duplicate the context before modifying it for each and_item let mut context = context.duplicate(); context.push_stack_frame(task_node_index, add_item_span.clone()); + let mut args = and_item.args; + let extra_args = if index == and_item_count - 1 { + // For the last and_item, append extra args from the plan context + Arc::clone(context.extra_args()) + } else { + Arc::new([]) + }; + args.extend(extra_args.iter().cloned()); + + // Handle `cd` builtin command + if and_item.program == "cd" { + let cd_target: Cow<'_, Path> = match args.as_slice() { + // No args, go to home directory + [] => home_dir() + .ok_or_else(|| { + TaskPlanErrorKind::CdCommandError(CdCommandError::NoHomeDirectory) + }) + .with_plan_context(&context)? + .into(), + [dir] => Path::new(dir.as_str()).into(), + _ => { + return Err(TaskPlanErrorKind::CdCommandError(CdCommandError::ToManyArgs)) + .with_plan_context(&context); + } + }; + cwd = cwd.join(cd_target.as_ref()).into(); + continue; + } + // Check for builtin commands like `echo ...` if let Some(builtin_execution) = - InProcessExecution::get_builtin_execution(&and_item.program, and_item.args.iter()) + InProcessExecution::get_builtin_execution(&and_item.program, args.iter(), &cwd) { items.push(ExecutionItem { command_span: add_item_span, + plan_cwd: Arc::clone(&cwd), + extra_args, kind: ExecutionItemKind::Leaf(LeafExecutionKind::InProcess(builtin_execution)), }); continue; } // Try to parse the args of an and_item to a task request like `run -r build` - let cwd = Arc::clone(context.cwd()); let task_request = context .callbacks() - .get_plan_request(&and_item.program, &and_item.args, &cwd) + .get_plan_request(&and_item.program, &args, &cwd) .await .map_err(|error| TaskPlanErrorKind::ParsePlanRequestError { error }) .with_plan_context(&context)?; @@ -101,7 +137,7 @@ async fn plan_task_as_execution_node( &and_item.envs, SpawnCommandKind::Program { program: OsStr::new(&and_item.program).into(), - args: and_item.args.into(), + args: args.into(), }, &task_node.resolved_config.resolved_options, context.envs(), @@ -110,7 +146,12 @@ async fn plan_task_as_execution_node( ExecutionItemKind::Leaf(LeafExecutionKind::Spawn(spawn_execution)) } }; - items.push(ExecutionItem { command_span: add_item_span, kind: execution_item_kind }); + items.push(ExecutionItem { + command_span: add_item_span, + plan_cwd: Arc::clone(&cwd), + extra_args, + kind: execution_item_kind, + }); } } else { let spawn_execution = plan_spawn_execution( @@ -122,6 +163,8 @@ async fn plan_task_as_execution_node( .with_plan_context(&context)?; items.push(ExecutionItem { command_span: 0..command_str.len(), + plan_cwd: cwd, + extra_args: Arc::clone(context.extra_args()), kind: ExecutionItemKind::Leaf(LeafExecutionKind::Spawn(spawn_execution)), }); } @@ -154,7 +197,7 @@ fn plan_spawn_execution( // all envs available in the current context let mut all_envs = envs.clone(); - let mut resolved_cache_config = None; + let mut resolved_cache_metadata = None; if let Some(cache_config) = &resolved_task_options.cache_config { // Resolve envs according cache configs let mut resolved_envs = ResolvedEnvs::resolve(&mut all_envs, &cache_config.env_config) @@ -164,7 +207,7 @@ fn plan_spawn_execution( resolved_envs .fingerprinted_envs .extend(prefix_envs.iter().map(|(name, value)| (name.clone(), value.as_str().into()))); - resolved_cache_config = Some(ResolvedCacheConfig { resolved_envs }); + resolved_cache_metadata = Some(ResolvedCacheMetadata { resolved_envs }); } // Add prefix envs to all envs @@ -174,7 +217,7 @@ fn plan_spawn_execution( Ok(SpawnExecution { all_envs: Arc::new(all_envs), - resolved_cache_config, + resolved_cache_metadata, cwd: Arc::clone(&resolved_task_options.cwd), command_kind, }) @@ -185,6 +228,7 @@ pub async fn plan_query_request( query_plan_request: QueryPlanRequest, mut context: PlanContext<'_>, ) -> Result { + context.set_extra_args(Arc::clone(&query_plan_request.plan_options.extra_args)); // Query matching tasks from the task graph let task_node_index_graph = context .indexed_task_graph() diff --git a/package.json b/package.json index 40db9854..fdfa8aa8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "type": "module", "scripts": { - "prepare": "husky" + "prepare": "husky", + "hello": "echo Hello, Vite Task Monorepo!" }, "devDependencies": { "husky": "catalog:", From 5748b898382efdef8eadbc6fe075e835b96bf18d Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 24 Dec 2025 16:01:37 +0800 Subject: [PATCH 03/27] refactor cli --- Cargo.lock | 1 + crates/vite_task/src/cli/mod.rs | 65 +++++++++++++++++--- crates/vite_task/src/execute/cache.rs | 16 +++-- crates/vite_task/src/execute/execute_plan.rs | 5 +- crates/vite_task/src/session.rs | 51 +++++++++++---- crates/vite_task_bin/src/main.rs | 35 ++++++----- crates/vite_task_plan/Cargo.toml | 1 + crates/vite_task_plan/src/lib.rs | 4 +- crates/vite_task_plan/src/plan.rs | 5 +- 9 files changed, 136 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 396e2533..64047639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3310,6 +3310,7 @@ dependencies = [ "futures-util", "petgraph", "sha2", + "shell-escape", "supports-color", "thiserror 2.0.17", "tracing", diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index 62b5736f..4c35fa7a 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -1,25 +1,70 @@ -use std::sync::Arc; +use std::{ffi::OsStr, sync::Arc}; -use clap::Subcommand; +use clap::{Parser, Subcommand}; use vite_path::AbsolutePath; use vite_str::Str; use vite_task_graph::{TaskSpecifier, query::TaskQueryKind}; use vite_task_plan::plan_request::{PlanOptions, PlanRequest, QueryPlanRequest}; -#[derive(Debug, clap::Parser)] -pub enum CLIArgs { - /// subcommands provided by vite task - #[command(flatten)] - ViteTaskSubCommand(ViteTaskSubCommand), +/// Represents the CLI arguments handled by vite-task, including both built-in and custom subcommands. +#[derive(Debug)] +pub struct TaskCLIArgs { + pub(crate) original: Arc<[Str]>, + pub(crate) parsed: ParsedTaskCLIArgs, +} +pub enum CLIArgs { + /// vite-task's own built-in subcommands + Task(TaskCLIArgs), /// custom subcommands provided by vite+ - #[command(flatten)] + NonTask(NonTaskSubCommand), +} + +impl + CLIArgs +{ + /// Get the original CLI arguments + pub fn try_parse_from( + args: impl Iterator>, + ) -> Result { + #[derive(Debug, clap::Parser)] + enum ParsedCLIArgs { + /// subcommands handled by vite task + #[command(flatten)] + Task(ParsedTaskCLIArgs), + + /// subcommands that are not handled by vite task + #[command(flatten)] + NonTask(NonTaskSubCommand), + } + + let args = args.map(|arg| Str::from(arg.as_ref())).collect::>(); + let parsed_cli_args = ParsedCLIArgs::::try_parse_from( + args.iter().map(|s| OsStr::new(s.as_str())), + )?; + + Ok(match parsed_cli_args { + ParsedCLIArgs::Task(parsed_task_cli_args) => { + Self::Task(TaskCLIArgs { original: args, parsed: parsed_task_cli_args }) + } + ParsedCLIArgs::NonTask(non_task_subcommand) => Self::NonTask(non_task_subcommand), + }) + } +} + +#[derive(Debug, Parser)] +pub(crate) enum ParsedTaskCLIArgs { + /// subcommands provided by vite task, like `run` + #[clap(flatten)] + BuiltIn(BuiltInCommand), + /// custom subcommands provided by vite+, like `lint` + #[clap(flatten)] Custom(CustomSubCommand), } /// vite task CLI subcommands #[derive(Debug, Subcommand)] -pub enum ViteTaskSubCommand { +pub(crate) enum BuiltInCommand { /// Run tasks Run { /// `packageName#taskName` or `taskName`. @@ -52,7 +97,7 @@ pub enum CLITaskQueryError { PackageNameSpecifiedWithRecursive { package_name: Str, task_name: Str }, } -impl ViteTaskSubCommand { +impl BuiltInCommand { /// Convert to `TaskQuery`, or return an error if invalid. pub fn into_plan_request( self, diff --git a/crates/vite_task/src/execute/cache.rs b/crates/vite_task/src/execute/cache.rs index ae36a723..0f70bbb2 100644 --- a/crates/vite_task/src/execute/cache.rs +++ b/crates/vite_task/src/execute/cache.rs @@ -47,18 +47,24 @@ pub struct TaskCache { conn: Mutex, } -/// Cache key to identify an execution directly from a custom vite-task subcommand. +/// Cache key to associate an execution with a custom vite-task subcommand (like `vite lint`) directly run by the user. #[derive(Debug, Encode, Decode, Serialize)] pub struct DirectExecutionCacheKey { - pub synthesization_cache_key: Arc<[Str]>, + /// The args after the program name, including the subcommand name. (like `["lint", "--fix"]` for `vite lint --fix`) + pub args: Arc<[Str]>, + + /// The cwd where the `vite [custom subcommand] ...` is run. + /// + /// This is not necessarily the actual cwd that the synthesized task runs in. pub plan_cwd: RelativePathBuf, } -/// Cache key to identify an execution from a user-defined task. +/// Cache key to associate an execution with a user-defined task (like `"lint-task": "vite lint" in package.json scripts`). #[derive(Debug, Encode, Decode, Serialize)] pub struct UserTaskExecutionCacheKey { - pub synthesization_cache_key: Arc<[Str]>, - pub plan_cwd: RelativePathBuf, + pub task_name: Str, + pub package_path: RelativePathBuf, + pub and_item_index: usize, } /// Key to identify an execution. diff --git a/crates/vite_task/src/execute/execute_plan.rs b/crates/vite_task/src/execute/execute_plan.rs index 8010606b..9e590038 100644 --- a/crates/vite_task/src/execute/execute_plan.rs +++ b/crates/vite_task/src/execute/execute_plan.rs @@ -6,6 +6,7 @@ use petgraph::{ algo::{Cycle, toposort}, graph::DiGraph, }; +use vite_str::Str; use vite_task_graph::IndexedTaskGraph; use vite_task_plan::{ ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnCommandKind, SpawnExecution, @@ -81,6 +82,7 @@ impl ExecutionContext<'_> { vite_str::format!("{}", task_display) }, command: item_command.into(), + plan_cwd: Arc::clone(&item.plan_cwd), }; self.execute_item_kind(&item.kind, Some(task_info)).boxed_local().await?; } @@ -148,7 +150,7 @@ impl ExecutionContext<'_> { cmd.args(args.iter().map(|arg| arg.as_str())); cmd } - SpawnCommandKind::ShellScript(script) => { + SpawnCommandKind::ShellScript { script, args } => { let mut cmd = if cfg!(windows) { let mut cmd = fspy::Command::new("cmd.exe"); // https://github.com/nodejs/node/blob/dbd24b165128affb7468ca42f69edaf7e0d85a9a/lib/child_process.js#L633 @@ -170,6 +172,7 @@ impl ExecutionContext<'_> { pub async fn execute_plan( plan: &ExecutionPlan, + args: &Arc<[Str]>, indexed_task_graph: Option<&IndexedTaskGraph>, event_handler: &mut (dyn FnMut(ExecutionEvent) + '_), cache: &TaskCache, diff --git a/crates/vite_task/src/session.rs b/crates/vite_task/src/session.rs index 3aff3454..8b95f3ca 100644 --- a/crates/vite_task/src/session.rs +++ b/crates/vite_task/src/session.rs @@ -10,7 +10,11 @@ use vite_task_plan::{ }; use vite_workspace::{WorkspaceRoot, find_workspace_root}; -use crate::{CLIArgs, TaskCache, collections::HashMap}; +use crate::{ + CLIArgs, TaskCache, + cli::{ParsedTaskCLIArgs, TaskCLIArgs}, + collections::HashMap, +}; #[derive(Debug)] enum LazyTaskGraph<'a> { @@ -61,14 +65,14 @@ struct PlanRequestParser<'a, CustomSubCommand> { impl PlanRequestParser<'_, CustomSubCommand> { async fn get_plan_request_from_cli_args( &mut self, - cli_args: CLIArgs, + cli_args: ParsedTaskCLIArgs, cwd: &Arc, ) -> anyhow::Result { match cli_args { - CLIArgs::ViteTaskSubCommand(vite_task_subcommand) => { + ParsedTaskCLIArgs::BuiltIn(vite_task_subcommand) => { Ok(vite_task_subcommand.into_plan_request(cwd)?) } - CLIArgs::Custom(custom_subcommand) => { + ParsedTaskCLIArgs::Custom(custom_subcommand) => { let synthetic_plan_request = self.task_synthesizer.synthesize_task(custom_subcommand, cwd).await?; Ok(PlanRequest::Synthetic(synthetic_plan_request)) @@ -90,9 +94,9 @@ impl vite_task_plan::PlanRequestParser Ok( if self.task_synthesizer.should_synthesize_for_program(program) && let Some(subcommand) = args.first() - && CLIArgs::::has_subcommand(subcommand) + && ParsedTaskCLIArgs::::has_subcommand(subcommand) { - let cli_args = CLIArgs::::try_parse_from( + let cli_args = ParsedTaskCLIArgs::::try_parse_from( std::iter::once(program).chain(args.iter().map(Str::as_str)), )?; Some(self.get_plan_request_from_cli_args(cli_args, cwd).await?) @@ -178,26 +182,49 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { } } +/// Represents a planned execution of tasks in a session, including information for caching. +#[derive(Debug)] +pub struct SessionExecutionPlan { + /// The original command-line arguments used to create this execution plan, excluding the program name. + /// + /// It's used to create cache keys for direct executions. See `DirectExecutionCacheKey` for details. + original_args: Arc<[Str]>, + + /// The current working directory used to create this execution plan. + /// + /// It's used to create cache keys for direct executions. See `DirectExecutionCacheKey` for details. + cwd: Arc, + + /// The actual content of the execution plan. + plan: vite_task_plan::ExecutionPlan, +} + impl<'a, CustomSubCommand: clap::Subcommand> Session<'a, CustomSubCommand> { pub async fn plan( &mut self, - cli_args: CLIArgs, - ) -> Result { + cwd: Arc, + cli_args: TaskCLIArgs, + ) -> Result { let plan_request = self .plan_request_parser - .get_plan_request_from_cli_args(cli_args, &self.cwd) + .get_plan_request_from_cli_args(cli_args.parsed, &cwd) .await .map_err(|error| { TaskPlanErrorKind::ParsePlanRequestError { error }.with_empty_call_stack() })?; - ExecutionPlan::plan( + let plan = ExecutionPlan::plan( plan_request, &self.workspace_path, - &self.cwd, + &cwd, &self.envs, &mut self.plan_request_parser, &mut self.lazy_task_graph, ) - .await + .await?; + Ok(SessionExecutionPlan { + original_args: cli_args.original.iter().skip(1).cloned().collect(), // Skip program name + cwd, + plan, + }) } } diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index 4db59348..71f11ee9 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -1,4 +1,9 @@ -use std::{env::join_paths, ffi::OsStr, path::PathBuf, sync::Arc}; +use std::{ + env::{self, join_paths}, + ffi::OsStr, + path::PathBuf, + sync::Arc, +}; use clap::Parser; use vite_path::{AbsolutePath, current_dir}; @@ -7,7 +12,7 @@ use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanR /// This is the custom subcommand that synthesizes tasks for vite-task #[derive(Debug, Parser)] -enum ViteTaskCustomSubCommand { +enum TaskCustomSubCommand { /// oxlint Lint { args: Vec }, } @@ -35,18 +40,18 @@ fn find_executable_in_node_modules_bin( } #[async_trait::async_trait(?Send)] -impl vite_task::TaskSynthesizer for TaskSynthesizer { +impl vite_task::TaskSynthesizer for TaskSynthesizer { fn should_synthesize_for_program(&self, program: &str) -> bool { program == "vite" } async fn synthesize_task( &mut self, - subcommand: ViteTaskCustomSubCommand, + subcommand: TaskCustomSubCommand, cwd: &Arc, ) -> anyhow::Result { match subcommand { - ViteTaskCustomSubCommand::Lint { args } => Ok(SyntheticPlanRequest { + TaskCustomSubCommand::Lint { args } => Ok(SyntheticPlanRequest { program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, args: args.into(), task_options: Default::default(), @@ -57,19 +62,17 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { #[tokio::main] async fn main() -> anyhow::Result<()> { - /// This is all the subcommands, including vite-task's own commands (run), - /// vite-task custom commands (lint), and non-task commands (version) - #[derive(Debug, Parser)] - enum Subcommand { - #[clap(flatten)] - Task(CLIArgs), + // This is the custom subcommand that is not handled by vite-task + #[derive(Debug, clap::Subcommand)] + enum NonTaskSubCommand { Version, } - // Pass vite-task's own/custom subcommands to vite-task's session. - let task_args = match Subcommand::parse() { - Subcommand::Task(task_args) => task_args, - Subcommand::Version => { + // Parse the CLI arguments and see if they are for vite-task or not + let args = CLIArgs::::try_parse_from(env::args())?; + let task_cli_args = match args { + CLIArgs::Task(task_cli_args) => task_cli_args, + CLIArgs::NonTask(NonTaskSubCommand::Version) => { // Non-task subcommands are not handled by vite-task's session. println!("{}", env!("CARGO_PKG_VERSION")); return Ok(()); @@ -83,7 +86,7 @@ async fn main() -> anyhow::Result<()> { user_config_loader: &mut config_loader, })?; - let plan = session.plan(task_args).await?; + let plan = session.plan(current_dir()?.into(), task_cli_args).await?; dbg!(plan); Ok(()) diff --git a/crates/vite_task_plan/Cargo.toml b/crates/vite_task_plan/Cargo.toml index b3ebad6a..f5d24e6e 100644 --- a/crates/vite_task_plan/Cargo.toml +++ b/crates/vite_task_plan/Cargo.toml @@ -16,6 +16,7 @@ async-trait = { workspace = true } futures-util = { workspace = true } petgraph = { workspace = true } sha2 = { workspace = true } +shell-escape = { workspace = true } supports-color = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 2ab515c4..83b53d8f 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -19,7 +19,7 @@ use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; use vite_path::AbsolutePath; use vite_str::Str; -use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, display::TaskDisplay, query::TaskQuery}; +use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, query::TaskQuery}; use crate::path_env::prepend_path_env; @@ -54,7 +54,7 @@ pub enum SpawnCommandKind { /// A program with args to be executed directly Program { program: Arc, args: Arc<[Str]> }, /// A script to be executed by os shell (sh or cmd) - ShellScript(Str), + ShellScript { script: Str, args: Arc<[Str]> }, } /// Represents how a task should be executed. It's the node type for the execution graph. Each node corresponds to a task. diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 0864a460..fc9b1080 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -156,7 +156,10 @@ async fn plan_task_as_execution_node( } else { let spawn_execution = plan_spawn_execution( &BTreeMap::new(), - SpawnCommandKind::ShellScript(command_str.into()), + SpawnCommandKind::ShellScript { + script: command_str.into(), + args: Arc::clone(context.extra_args()), + }, &task_node.resolved_config.resolved_options, context.envs(), ) From e9930a5d0c74eeba269ea9ec23fc7ebd2d1f66ee Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 24 Dec 2025 16:18:28 +0800 Subject: [PATCH 04/27] reorgnize files --- .../src/{execute/mod.rs => execute.rs} | 4 -- crates/vite_task/src/lib.rs | 2 +- .../src/{execute => session}/cache.rs | 2 +- .../src/{execute => session}/event.rs | 0 .../execute/mod.rs} | 35 ++++++++++------- .../src/{session.rs => session/mod.rs} | 15 ++++++- crates/vite_task_bin/src/main.rs | 39 +++++++++++-------- crates/vite_task_plan/src/plan_request.rs | 2 - 8 files changed, 60 insertions(+), 39 deletions(-) rename crates/vite_task/src/{execute/mod.rs => execute.rs} (99%) rename crates/vite_task/src/{execute => session}/cache.rs (99%) rename crates/vite_task/src/{execute => session}/event.rs (100%) rename crates/vite_task/src/{execute/execute_plan.rs => session/execute/mod.rs} (89%) rename crates/vite_task/src/{session.rs => session/mod.rs} (97%) diff --git a/crates/vite_task/src/execute/mod.rs b/crates/vite_task/src/execute.rs similarity index 99% rename from crates/vite_task/src/execute/mod.rs rename to crates/vite_task/src/execute.rs index db929ad8..da950f0f 100644 --- a/crates/vite_task/src/execute/mod.rs +++ b/crates/vite_task/src/execute.rs @@ -1,7 +1,3 @@ -pub(crate) mod cache; -pub mod event; -pub mod execute_plan; - use std::{ collections::hash_map::Entry, env::{join_paths, split_paths}, diff --git a/crates/vite_task/src/lib.rs b/crates/vite_task/src/lib.rs index 69d18083..3845e7fb 100644 --- a/crates/vite_task/src/lib.rs +++ b/crates/vite_task/src/lib.rs @@ -14,7 +14,7 @@ mod ui; // Public exports for vite-plus-cli to use pub use cache::TaskCache; -pub use cli::CLIArgs; +pub use cli::{CLIArgs, TaskCLIArgs}; pub use config::{ResolvedTask, Workspace}; pub use error::Error; pub use execute::{CURRENT_EXECUTION_ID, EXECUTION_SUMMARY_DIR}; diff --git a/crates/vite_task/src/execute/cache.rs b/crates/vite_task/src/session/cache.rs similarity index 99% rename from crates/vite_task/src/execute/cache.rs rename to crates/vite_task/src/session/cache.rs index 0f70bbb2..4dfbd4a2 100644 --- a/crates/vite_task/src/execute/cache.rs +++ b/crates/vite_task/src/session/cache.rs @@ -10,7 +10,7 @@ use vite_str::Str; use crate::{ Error, - config::{CommandFingerprint, ResolvedTask, TaskId}, + config::{CommandFingerprint, ResolvedTask}, execute::{ExecutedTask, StdOutput}, fingerprint::{PostRunFingerprint, PostRunFingerprintMismatch}, fs::FileSystem, diff --git a/crates/vite_task/src/execute/event.rs b/crates/vite_task/src/session/event.rs similarity index 100% rename from crates/vite_task/src/execute/event.rs rename to crates/vite_task/src/session/event.rs diff --git a/crates/vite_task/src/execute/execute_plan.rs b/crates/vite_task/src/session/execute/mod.rs similarity index 89% rename from crates/vite_task/src/execute/execute_plan.rs rename to crates/vite_task/src/session/execute/mod.rs index 9e590038..923bb6ae 100644 --- a/crates/vite_task/src/execute/execute_plan.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -21,6 +21,7 @@ use super::{ ExecutionStartedEvent, OutputKind, TaskInfo, }, }; +use crate::{Session, session::SessionExecutionPlan}; #[derive(Debug, thiserror::Error)] pub enum ExecuteError { @@ -161,6 +162,12 @@ impl ExecutionContext<'_> { cmd.args(["-c"]); cmd }; + + let mut script = script.clone(); + for arg in args.iter() { + script.push(' '); + script.push_str(shell_escape::escape(arg.as_str().into()).as_ref()); + } cmd.arg(script); cmd } @@ -170,18 +177,18 @@ impl ExecutionContext<'_> { } } -pub async fn execute_plan( - plan: &ExecutionPlan, - args: &Arc<[Str]>, - indexed_task_graph: Option<&IndexedTaskGraph>, - event_handler: &mut (dyn FnMut(ExecutionEvent) + '_), - cache: &TaskCache, -) -> Result<(), ExecuteError> { - let mut execution_context = ExecutionContext { - indexed_task_graph, - event_handler, - current_execution_id: ExecutionId::zero(), - cache, - }; - execution_context.execute_item_kind(plan.root_node(), None).await +impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { + pub async fn execute( + &self, + plan: SessionExecutionPlan, + event_handler: &mut (dyn FnMut(ExecutionEvent) + '_), + ) -> Result<(), ExecuteError> { + let mut execution_context = ExecutionContext { + indexed_task_graph: self.lazy_task_graph.try_get(), + event_handler, + current_execution_id: ExecutionId::zero(), + cache: &self.cache, + }; + execution_context.execute_item_kind(plan.plan.root_node(), None).await + } } diff --git a/crates/vite_task/src/session.rs b/crates/vite_task/src/session/mod.rs similarity index 97% rename from crates/vite_task/src/session.rs rename to crates/vite_task/src/session/mod.rs index 8b95f3ca..7fc3d3dd 100644 --- a/crates/vite_task/src/session.rs +++ b/crates/vite_task/src/session/mod.rs @@ -1,5 +1,10 @@ +mod cache; +mod event; +mod execute; + use std::{ffi::OsStr, fmt::Debug, sync::Arc}; +use cache::TaskCache; use clap::{Parser, Subcommand}; use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_str::Str; @@ -11,7 +16,6 @@ use vite_task_plan::{ use vite_workspace::{WorkspaceRoot, find_workspace_root}; use crate::{ - CLIArgs, TaskCache, cli::{ParsedTaskCLIArgs, TaskCLIArgs}, collections::HashMap, }; @@ -22,6 +26,15 @@ enum LazyTaskGraph<'a> { Initialized(IndexedTaskGraph), } +impl LazyTaskGraph<'_> { + fn try_get(&self) -> Option<&IndexedTaskGraph> { + match self { + Self::Initialized(graph) => Some(graph), + _ => None, + } + } +} + #[async_trait::async_trait(?Send)] impl TaskGraphLoader for LazyTaskGraph<'_> { async fn load_task_graph( diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index 71f11ee9..bdd9de00 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -5,18 +5,24 @@ use std::{ sync::Arc, }; -use clap::Parser; +use clap::{Parser, Subcommand}; use vite_path::{AbsolutePath, current_dir}; use vite_str::Str; use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanRequest}; -/// This is the custom subcommand that synthesizes tasks for vite-task -#[derive(Debug, Parser)] -enum TaskCustomSubCommand { +/// Theses are the custom subcommands that synthesize tasks for vite-task +#[derive(Debug, Subcommand)] +enum CustomTaskSubcommand { /// oxlint Lint { args: Vec }, } +// These are the subcommands that is not handled by vite-task +#[derive(Debug, Subcommand)] +enum NonTaskSubcommand { + Version, +} + #[derive(Debug)] struct TaskSynthesizer; @@ -40,18 +46,18 @@ fn find_executable_in_node_modules_bin( } #[async_trait::async_trait(?Send)] -impl vite_task::TaskSynthesizer for TaskSynthesizer { +impl vite_task::TaskSynthesizer for TaskSynthesizer { fn should_synthesize_for_program(&self, program: &str) -> bool { program == "vite" } async fn synthesize_task( &mut self, - subcommand: TaskCustomSubCommand, + subcommand: CustomTaskSubcommand, cwd: &Arc, ) -> anyhow::Result { match subcommand { - TaskCustomSubCommand::Lint { args } => Ok(SyntheticPlanRequest { + CustomTaskSubcommand::Lint { args } => Ok(SyntheticPlanRequest { program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, args: args.into(), task_options: Default::default(), @@ -62,17 +68,18 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { #[tokio::main] async fn main() -> anyhow::Result<()> { - // This is the custom subcommand that is not handled by vite-task - #[derive(Debug, clap::Subcommand)] - enum NonTaskSubCommand { - Version, - } - + let cwd: Arc = current_dir()?.into(); // Parse the CLI arguments and see if they are for vite-task or not - let args = CLIArgs::::try_parse_from(env::args())?; + let args = match CLIArgs::::try_parse_from(env::args()) + { + Ok(ok) => ok, + Err(err) => { + err.exit(); + } + }; let task_cli_args = match args { CLIArgs::Task(task_cli_args) => task_cli_args, - CLIArgs::NonTask(NonTaskSubCommand::Version) => { + CLIArgs::NonTask(NonTaskSubcommand::Version) => { // Non-task subcommands are not handled by vite-task's session. println!("{}", env!("CARGO_PKG_VERSION")); return Ok(()); @@ -86,7 +93,7 @@ async fn main() -> anyhow::Result<()> { user_config_loader: &mut config_loader, })?; - let plan = session.plan(current_dir()?.into(), task_cli_args).await?; + let plan = session.plan(cwd, task_cli_args).await?; dbg!(plan); Ok(()) diff --git a/crates/vite_task_plan/src/plan_request.rs b/crates/vite_task_plan/src/plan_request.rs index d3318856..1b34445b 100644 --- a/crates/vite_task_plan/src/plan_request.rs +++ b/crates/vite_task_plan/src/plan_request.rs @@ -3,8 +3,6 @@ use std::{ffi::OsStr, sync::Arc}; use vite_str::Str; use vite_task_graph::{config::user::UserTaskOptions, query::TaskQuery}; -use crate::SpawnCommandKind; - #[derive(Debug)] pub struct PlanOptions { pub extra_args: Arc<[Str]>, From f1e706ecc68972a4139408eddc750878de33d7aa Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 24 Dec 2025 21:14:12 +0800 Subject: [PATCH 05/27] resolve program path at plan stage --- Cargo.lock | 1 + .../src/session/cache/fingerprint.rs | 75 +++++++ .../src/session/{cache.rs => cache/mod.rs} | 10 +- crates/vite_task/src/session/event.rs | 11 +- crates/vite_task/src/session/execute/mod.rs | 183 ++++++++++++++---- crates/vite_task/src/session/mod.rs | 12 +- crates/vite_task_plan/Cargo.toml | 1 + crates/vite_task_plan/src/error.rs | 27 ++- crates/vite_task_plan/src/lib.rs | 2 +- crates/vite_task_plan/src/path_env.rs | 16 ++ crates/vite_task_plan/src/plan.rs | 35 +++- 11 files changed, 313 insertions(+), 60 deletions(-) create mode 100644 crates/vite_task/src/session/cache/fingerprint.rs rename crates/vite_task/src/session/{cache.rs => cache/mod.rs} (98%) diff --git a/Cargo.lock b/Cargo.lock index 64047639..6487c191 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3319,6 +3319,7 @@ dependencies = [ "vite_shell", "vite_str", "vite_task_graph", + "which", ] [[package]] diff --git a/crates/vite_task/src/session/cache/fingerprint.rs b/crates/vite_task/src/session/cache/fingerprint.rs new file mode 100644 index 00000000..ce70cd3c --- /dev/null +++ b/crates/vite_task/src/session/cache/fingerprint.rs @@ -0,0 +1,75 @@ +use std::{ + collections::{BTreeMap, BTreeSet}, + path::Path, + sync::Arc, +}; + +use bincode::{Decode, Encode}; +use diff::Diff; +use serde::{Deserialize, Serialize}; +use vite_path::{AbsolutePath, RelativePathBuf}; +use vite_str::Str; +use vite_task_plan::{SpawnCommandKind, SpawnExecution}; + +/// Fingerprint for command execution that affects caching. +/// +/// # Environment Variable Impact on Cache +/// +/// The `envs_without_pass_through` field is crucial for cache correctness: +/// - Only includes envs explicitly declared in the task's `envs` array +/// - Does NOT include pass-through envs (PATH, CI, etc.) +/// - These envs become part of the cache key +/// +/// When a task runs: +/// 1. All envs (including pass-through) are available to the process +/// 2. Only declared envs affect the cache key +/// 3. If a declared env changes value, cache will miss +/// 4. If a pass-through env changes, cache will still hit +/// +/// For built-in tasks (lint, build, etc): +/// - The resolver provides envs which become part of the fingerprint +/// - If resolver provides different envs between runs, cache breaks +/// - Each built-in task type must have unique task name to avoid cache collision +/// +/// # Fingerprint Ignores Impact on Cache +/// +/// The `fingerprint_ignores` field controls which files are tracked in `PostRunFingerprint`: +/// - Changes to this config must invalidate the cache +/// - Vec maintains insertion order (pattern order matters for last-match-wins semantics) +/// - Even though ignore patterns only affect `PostRunFingerprint`, the config itself is part of the cache key +#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq, Diff, Clone)] +#[diff(attr(#[derive(Debug)]))] +pub struct SpawnFingerprint { + pub cwd: RelativePathBuf, + pub command_fingerprint: CommandFingerprint, + /// Environment variables that affect caching (excludes pass-through envs) + pub fingerprinted_envs: BTreeMap, // using BTreeMap to have a stable order in cache db + + /// even though value changes to `pass_through_envs` shouldn't invalidate the cache, + /// The names should still be fingerprinted so that the cache can be invalidated if the `pass_through_envs` config changes + pub pass_through_envs: BTreeSet, // using BTreeSet to have a stable order in cache db + + /// Glob patterns for fingerprint filtering. Order matters (last match wins). + /// Changes to this config invalidate the cache to ensure correct fingerprint tracking. + pub fingerprint_ignores: Option>, +} + +/// The program fingerprint used in `SpawnFingerprint` +#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq, Diff, Clone)] +#[diff(attr(#[derive(Debug)]))] +enum ProgramFingerprint { + /// If the program is outside the workspace, fingerprint by its name only (like `node`, `npm`, etc) + OutsideWorkspace { program_name: Str }, + + /// If the program is inside the workspace, fingerprint by its path relative to the workspace root + InsideWorkspace { relative_path: RelativePathBuf }, +} + +#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq, Diff, Clone)] +#[diff(attr(#[derive(Debug)]))] +enum CommandFingerprint { + /// A program with args to be executed directly + Program { program_fingerprint: ProgramFingerprint, args: Vec }, + /// A script to be executed by os shell (sh or cmd) + ShellScript { script: Str, extra_args: Vec }, +} diff --git a/crates/vite_task/src/session/cache.rs b/crates/vite_task/src/session/cache/mod.rs similarity index 98% rename from crates/vite_task/src/session/cache.rs rename to crates/vite_task/src/session/cache/mod.rs index 4dfbd4a2..4b78eb22 100644 --- a/crates/vite_task/src/session/cache.rs +++ b/crates/vite_task/src/session/cache/mod.rs @@ -1,3 +1,5 @@ +pub mod fingerprint; + use std::{fmt::Display, io::Write, sync::Arc, time::Duration}; // use bincode::config::{Configuration, standard}; @@ -43,7 +45,7 @@ impl CommandCacheValue { } #[derive(Debug)] -pub struct TaskCache { +pub struct ExecutionCache { conn: Mutex, } @@ -51,7 +53,7 @@ pub struct TaskCache { #[derive(Debug, Encode, Decode, Serialize)] pub struct DirectExecutionCacheKey { /// The args after the program name, including the subcommand name. (like `["lint", "--fix"]` for `vite lint --fix`) - pub args: Arc<[Str]>, + pub args_without_program: Arc<[Str]>, /// The cwd where the `vite [custom subcommand] ...` is run. /// @@ -109,7 +111,7 @@ impl Display for FingerprintMismatch { } } -impl TaskCache { +impl ExecutionCache { pub fn load_from_path(cache_path: AbsolutePathBuf) -> Result { let path: &AbsolutePath = cache_path.as_ref(); tracing::info!("Creating task cache directory at {:?}", path); @@ -208,7 +210,7 @@ impl TaskCache { } // basic database operations -impl TaskCache { +impl ExecutionCache { async fn get_key_by_value>( &self, table: &str, diff --git a/crates/vite_task/src/session/event.rs b/crates/vite_task/src/session/event.rs index 63c41802..aa45f814 100644 --- a/crates/vite_task/src/session/event.rs +++ b/crates/vite_task/src/session/event.rs @@ -7,10 +7,11 @@ use vite_str::Str; use crate::collections::HashMap; #[derive(Clone, Debug)] -pub struct TaskInfo { - pub task_display_name: Str, +pub struct ExecutionStartInfo { + /// None if the execution is not associated with a specific task, but directly synthesized from CLI args, like `vite lint`/`vite exec ...` + pub task_display_name: Option, pub command: Str, - pub plan_cwd: Arc, + pub cwd: Arc, } #[derive(Debug)] @@ -45,7 +46,7 @@ impl ExecutionId { pub struct ExecutionStartedEvent { pub execution_id: ExecutionId, - pub display: TaskInfo, + pub display: ExecutionStartInfo, } pub struct ExecutionOutputEvent { @@ -62,7 +63,7 @@ pub struct ExecutionEvent { #[derive(Debug)] pub enum ExecutionEventKind { - Start { task_info: Option }, + Start(ExecutionStartInfo), Output { kind: OutputKind, content: BString }, Finish { status: Option, cache_status: CacheStatus }, } diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index 923bb6ae..bfc764a7 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -1,46 +1,102 @@ use core::task; -use std::sync::Arc; +use std::{borrow::Cow, ops::Range, path::Path, sync::Arc}; use futures_util::FutureExt; use petgraph::{ algo::{Cycle, toposort}, graph::DiGraph, }; +use sha2::digest::typenum::Abs; +use vite_path::{AbsolutePath, RelativePathBuf, relative::InvalidPathDataError}; use vite_str::Str; -use vite_task_graph::IndexedTaskGraph; +use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex}; use vite_task_plan::{ - ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnCommandKind, SpawnExecution, - TaskExecution, + ExecutionItem, ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnCommandKind, + SpawnExecution, TaskExecution, execution_graph::{ExecutionGraph, ExecutionIx, ExecutionNodeIndex}, }; use super::{ - cache::{ExecutionCacheKey, TaskCache}, + cache::{ExecutionCache, ExecutionCacheKey}, event::{ CacheDisabledReason, CacheStatus, ExecutionEvent, ExecutionEventKind, ExecutionId, - ExecutionStartedEvent, OutputKind, TaskInfo, + ExecutionStartInfo, ExecutionStartedEvent, OutputKind, + }, +}; +use crate::{ + Session, + session::{ + SessionExecutionPlan, + cache::{DirectExecutionCacheKey, UserTaskExecutionCacheKey}, }, }; -use crate::{Session, session::SessionExecutionPlan}; + +#[derive(Debug, thiserror::Error)] +pub enum PathError { + #[error("Path {path:?} is outside of the workspace {workspace_path:?}")] + PathOutsideWorkspace { path: Arc, workspace_path: Arc }, + #[error("Path {path:?} contains characters that make it non-portable")] + NonPortableRelativePath { + path: Arc, + #[source] + error: InvalidPathDataError, + }, +} #[derive(Debug, thiserror::Error)] pub enum ExecuteError { #[error("Cycle dependencies detected: {0:?}")] CycleDependencies(Cycle), + + #[error(transparent)] + PathError(#[from] PathError), } struct ExecutionContext<'a> { indexed_task_graph: Option<&'a IndexedTaskGraph>, event_handler: &'a mut (dyn FnMut(ExecutionEvent) + 'a), current_execution_id: ExecutionId, - cache: &'a TaskCache, + cache: &'a ExecutionCache, + /// All relative paths in cache are relative to this base path + cache_base_path: &'a Arc, +} + +/// The origin of the current execution item, either directly from CLI args, or from a task in the task graph +enum ExecutionOrigin<'a> { + CLIArgs { + args_without_program: &'a Arc<[Str]>, + cwd: &'a Arc, + }, + UserTask { + task_node_index: TaskNodeIndex, + item: &'a ExecutionItem, + item_index: usize, + item_count: usize, + }, } impl ExecutionContext<'_> { + fn strip_prefix_for_cache( + &self, + path: &Arc, + ) -> Result { + match path.strip_prefix(&*self.cache_base_path) { + Ok(Some(rel_path)) => Ok(rel_path), + Ok(None) => Err(PathError::PathOutsideWorkspace { + path: Arc::clone(path), + workspace_path: Arc::clone(self.cache_base_path), + }), + Err(err) => Err(PathError::NonPortableRelativePath { + path: err.stripped_path.into(), + error: err.invalid_path_data_error, + }), + } + } + async fn execute_item_kind( &mut self, item_kind: &ExecutionItemKind, - task_info: Option, + origin: ExecutionOrigin<'_>, ) -> Result<(), ExecuteError> { match item_kind { ExecutionItemKind::Expanded(graph) => { @@ -67,33 +123,25 @@ impl ExecutionContext<'_> { node_indices.into_iter().map(|id| graph.remove_node(id).unwrap()); for task_execution in ordered_executions { let indexed_task_graph = self.indexed_task_graph.unwrap(); - let task_command = indexed_task_graph.task_graph() - [task_execution.task_node_index] - .resolved_config - .command - .as_str(); let task_display = indexed_task_graph.display_task(task_execution.task_node_index); - for (index, item) in task_execution.items.iter().enumerate() { - let item_command = &task_command[item.command_span.clone()]; - let task_info = TaskInfo { - task_display_name: if task_execution.items.len() > 1 { - vite_str::format!("{} ({})", task_display, index) - } else { - vite_str::format!("{}", task_display) + for (item_index, item) in task_execution.items.iter().enumerate() { + self.execute_item_kind( + &item.kind, + ExecutionOrigin::UserTask { + item, + item_index, + item_count: task_execution.items.len(), + task_node_index: task_execution.task_node_index, }, - command: item_command.into(), - plan_cwd: Arc::clone(&item.plan_cwd), - }; - self.execute_item_kind(&item.kind, Some(task_info)).boxed_local().await?; + ) + .boxed_local() + .await?; } } } ExecutionItemKind::Leaf(leaf_execution_kind) => { - let execution_id = self.current_execution_id; - self.current_execution_id = self.current_execution_id.next(); - - self.execute_leaf(leaf_execution_kind, task_info, todo!()).await?; + self.execute_leaf(leaf_execution_kind, origin).await?; } } Ok(()) @@ -102,15 +150,47 @@ impl ExecutionContext<'_> { async fn execute_leaf( &mut self, leaf_execution_kind: &LeafExecutionKind, - task_info: Option, - task_run_cache_key: Option, + origin: ExecutionOrigin<'_>, ) -> Result<(), ExecuteError> { + let start_info = match origin { + ExecutionOrigin::CLIArgs { args_without_program, cwd } => ExecutionStartInfo { + task_display_name: None, + // display command with `vite` followed by the user supplied cli args + command: vite_str::format!( + "{}", + std::iter::once(Cow::Borrowed("vite")) + .chain( + args_without_program + .iter() + .map(|s| shell_escape::escape(s.as_str().into())) + ) + .collect::>() + .join(" ") + ), + cwd: Arc::clone(&cwd), + }, + ExecutionOrigin::UserTask { task_node_index, item, item_index, item_count } => { + let indexed_task_graph = self.indexed_task_graph.expect("Task graph must have been loaded if there exists an execution associated with a task"); + let task_node = &indexed_task_graph.task_graph()[task_node_index]; + let command = &task_node.resolved_config.command[item.command_span.clone()]; + let task_display = indexed_task_graph.display_task(task_node_index); + ExecutionStartInfo { + task_display_name: Some(if item_count > 1 { + vite_str::format!("{} ({})", task_display, item_index) + } else { + vite_str::format!("{}", task_display) + }), + command: command.into(), + cwd: Arc::clone(&item.plan_cwd), + } + } + }; + let execution_id = self.current_execution_id; self.current_execution_id = self.current_execution_id.next(); - (self.event_handler)(ExecutionEvent { execution_id, - kind: ExecutionEventKind::Start { task_info }, + kind: ExecutionEventKind::Start(start_info), }); match leaf_execution_kind { @@ -134,7 +214,7 @@ impl ExecutionContext<'_> { }); } LeafExecutionKind::Spawn(spawn_execution) => { - self.execute_spawn(execution_id, spawn_execution).await?; + self.execute_spawn(execution_id, origin, spawn_execution).await?; } } Ok(()) @@ -143,11 +223,31 @@ impl ExecutionContext<'_> { async fn execute_spawn( &mut self, execution_id: ExecutionId, + origin: ExecutionOrigin<'_>, spawn_execution: &SpawnExecution, ) -> Result<(), ExecuteError> { + let execution_cache_key = match origin { + ExecutionOrigin::CLIArgs { args_without_program, cwd } => { + ExecutionCacheKey::Direct(DirectExecutionCacheKey { + args_without_program: Arc::clone(&args_without_program), + plan_cwd: self.strip_prefix_for_cache(cwd)?, + }) + } + ExecutionOrigin::UserTask { task_node_index, item_index, .. } => { + let indexed_task_graph = self.indexed_task_graph.expect("Task graph must have been loaded if there exists an execution associated with a task"); + let task_node = &indexed_task_graph.task_graph()[task_node_index]; + let package_path = indexed_task_graph.get_package_path_for_task(task_node_index); + ExecutionCacheKey::UserTask(UserTaskExecutionCacheKey { + task_name: task_node.task_id.task_name.clone(), + package_path: self.strip_prefix_for_cache(&package_path)?, + and_item_index: item_index, + }) + } + }; + let mut cmd = match &spawn_execution.command_kind { - SpawnCommandKind::Program { program, args } => { - let mut cmd = fspy::Command::new(&*program); + SpawnCommandKind::Program { program_path, args } => { + let mut cmd = fspy::Command::new(program_path.as_path()); cmd.args(args.iter().map(|arg| arg.as_str())); cmd } @@ -188,7 +288,16 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { event_handler, current_execution_id: ExecutionId::zero(), cache: &self.cache, + cache_base_path: &self.workspace_path, }; - execution_context.execute_item_kind(plan.plan.root_node(), None).await + execution_context + .execute_item_kind( + plan.plan.root_node(), + ExecutionOrigin::CLIArgs { + args_without_program: &plan.cli_args_without_program, + cwd: &plan.cwd, + }, + ) + .await } } diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index 7fc3d3dd..0ce2125c 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -4,7 +4,7 @@ mod execute; use std::{ffi::OsStr, fmt::Debug, sync::Arc}; -use cache::TaskCache; +use cache::ExecutionCache; use clap::{Parser, Subcommand}; use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_str::Str; @@ -134,7 +134,7 @@ pub struct Session<'a, CustomSubCommand> { plan_request_parser: PlanRequestParser<'a, CustomSubCommand>, - cache: TaskCache, + cache: ExecutionCache, } fn get_cache_path_of_workspace(workspace_root: &AbsolutePath) -> AbsolutePathBuf { @@ -169,7 +169,7 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { tracing::info!("Creating task cache directory at {}", cache_dir.display()); std::fs::create_dir_all(cache_dir)?; } - let cache = TaskCache::load_from_path(cache_path)?; + let cache = ExecutionCache::load_from_path(cache_path)?; Ok(Self { workspace_path: Arc::clone(&workspace_root.path), lazy_task_graph: LazyTaskGraph::Uninitialized { @@ -183,7 +183,7 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { }) } - pub fn cache(&self) -> &TaskCache { + pub fn cache(&self) -> &ExecutionCache { &self.cache } @@ -201,7 +201,7 @@ pub struct SessionExecutionPlan { /// The original command-line arguments used to create this execution plan, excluding the program name. /// /// It's used to create cache keys for direct executions. See `DirectExecutionCacheKey` for details. - original_args: Arc<[Str]>, + cli_args_without_program: Arc<[Str]>, /// The current working directory used to create this execution plan. /// @@ -235,7 +235,7 @@ impl<'a, CustomSubCommand: clap::Subcommand> Session<'a, CustomSubCommand> { ) .await?; Ok(SessionExecutionPlan { - original_args: cli_args.original.iter().skip(1).cloned().collect(), // Skip program name + cli_args_without_program: cli_args.original.iter().skip(1).cloned().collect(), // Skip program name cwd, plan, }) diff --git a/crates/vite_task_plan/Cargo.toml b/crates/vite_task_plan/Cargo.toml index f5d24e6e..8355b0a8 100644 --- a/crates/vite_task_plan/Cargo.toml +++ b/crates/vite_task_plan/Cargo.toml @@ -25,3 +25,4 @@ vite_path = { workspace = true } vite_shell = { workspace = true } vite_str = { workspace = true } vite_task_graph = { workspace = true } +which = { workspace = true } diff --git a/crates/vite_task_plan/src/error.rs b/crates/vite_task_plan/src/error.rs index 20fd1119..5995a33a 100644 --- a/crates/vite_task_plan/src/error.rs +++ b/crates/vite_task_plan/src/error.rs @@ -1,4 +1,6 @@ -use std::env::JoinPathsError; +use std::{env::JoinPathsError, ffi::OsStr, fmt::Display, sync::Arc}; + +use vite_path::AbsolutePath; use crate::{ context::{PlanContext, TaskCallStackDisplay, TaskRecursionError}, @@ -14,6 +16,26 @@ pub enum CdCommandError { ToManyArgs, } +#[derive(Debug, thiserror::Error)] +pub struct WhichError { + pub program: Arc, + pub path_env: Option>, + pub cwd: Arc, + #[source] + pub error: which::Error, +} +impl Display for WhichError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Failed to find executable {:?} under cwd {:?} with ", self.program, self.cwd)?; + if let Some(path_env) = &self.path_env { + write!(f, "PATH: {:?}", path_env)? + } else { + write!(f, "No PATH")? + } + Ok(()) + } +} + /// Errors that can occur when planning a specific execution from a task . #[derive(Debug, thiserror::Error)] pub enum TaskPlanErrorKind { @@ -31,6 +53,9 @@ pub enum TaskPlanErrorKind { CdCommandError, ), + #[error(transparent)] + ProgramNotFound(#[from] WhichError), + #[error("Failed to query tasks from task graph")] TaskQueryError( #[source] diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 83b53d8f..617dd1ef 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -52,7 +52,7 @@ pub struct SpawnExecution { #[derive(Debug)] pub enum SpawnCommandKind { /// A program with args to be executed directly - Program { program: Arc, args: Arc<[Str]> }, + Program { program_path: Arc, args: Arc<[Str]> }, /// A script to be executed by os shell (sh or cmd) ShellScript { script: Str, args: Arc<[Str]> }, } diff --git a/crates/vite_task_plan/src/path_env.rs b/crates/vite_task_plan/src/path_env.rs index 3a246b1b..85e0983a 100644 --- a/crates/vite_task_plan/src/path_env.rs +++ b/crates/vite_task_plan/src/path_env.rs @@ -8,6 +8,22 @@ use std::{ use vite_path::AbsolutePath; +pub fn get_path_env(envs: &HashMap, Arc>) -> Option<&Arc> { + if cfg!(windows) { + // On Windows, environment variable names are case-insensitive (e.g., "PATH", "Path", "path" are all the same) + // However, Rust's HashMap keys are case-sensitive, so we need to find the existing PATH variable + // regardless of its casing. + envs.iter().find_map( + |(name, value)| { + if name.eq_ignore_ascii_case("path") { Some(value) } else { None } + }, + ) + } else { + // On Unix, environment variable names are case-sensitive + envs.get(OsStr::new("PATH")) + } +} + pub fn prepend_path_env( envs: &mut HashMap, Arc>, path_to_prepend: &AbsolutePath, diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index fc9b1080..00f81bc4 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -8,7 +8,7 @@ use std::{ }; use futures_util::FutureExt; -use vite_path::AbsolutePath; +use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_shell::try_parse_as_and_list; use vite_str::Str; use vite_task_graph::{TaskNodeIndex, config::ResolvedTaskOptions}; @@ -20,9 +20,30 @@ use crate::{ error::{CdCommandError, Error, TaskPlanErrorKind, TaskPlanErrorKindResultExt}, execution_graph::{ExecutionGraph, ExecutionNodeIndex}, in_process::InProcessExecution, + path_env::get_path_env, plan_request::{PlanRequest, QueryPlanRequest, SyntheticPlanRequest}, }; +/// Locate the executable path for a given program name in the provided envs and cwd. +fn which( + program: &Arc, + envs: &HashMap, Arc>, + cwd: &Arc, +) -> Result, crate::error::WhichError> { + let path_env = get_path_env(envs); + let executable_path = which::which_in(program, path_env, cwd.as_path()).map_err(|err| { + crate::error::WhichError { + program: Arc::clone(program), + path_env: path_env.map(Arc::clone), + cwd: Arc::clone(cwd), + error: err, + } + })?; + Ok(AbsolutePathBuf::new(executable_path) + .expect("path returned by which::which_in should always be absolute") + .into()) +} + async fn plan_task_as_execution_node( task_node_index: TaskNodeIndex, mut context: PlanContext<'_>, @@ -133,12 +154,13 @@ async fn plan_task_as_execution_node( } // Normal 3rd party tool command (like `tsc --noEmit`) None => { + let program_path = + which(&OsStr::new(&and_item.program).into(), context.envs(), &cwd) + .map_err(TaskPlanErrorKind::ProgramNotFound) + .with_plan_context(&context)?; let spawn_execution = plan_spawn_execution( &and_item.envs, - SpawnCommandKind::Program { - program: OsStr::new(&and_item.program).into(), - args: args.into(), - }, + SpawnCommandKind::Program { program_path, args: args.into() }, &task_node.resolved_config.resolved_options, context.envs(), ) @@ -182,10 +204,11 @@ pub fn plan_synthetic_request( envs: &HashMap, Arc>, ) -> Result { let SyntheticPlanRequest { program, args, task_options } = synthetic_plan_request; + let program_path = which(&program, envs, cwd).map_err(TaskPlanErrorKind::ProgramNotFound)?; let resolved_options = ResolvedTaskOptions::resolve(task_options, &cwd); plan_spawn_execution( prefix_envs, - SpawnCommandKind::Program { program, args }, + SpawnCommandKind::Program { program_path, args }, &resolved_options, envs, ) From 68d9a7d6a91f689beec95f1e5b0b73d47021c02e Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 24 Dec 2025 21:17:43 +0800 Subject: [PATCH 06/27] SubCommand -> Subcommand --- crates/vite_task/src/cli/mod.rs | 26 +++++++------- crates/vite_task/src/session/execute/mod.rs | 2 +- crates/vite_task/src/session/mod.rs | 40 ++++++++++----------- crates/vite_task_bin/src/main.rs | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index 4c35fa7a..96e57ba6 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -8,38 +8,38 @@ use vite_task_plan::plan_request::{PlanOptions, PlanRequest, QueryPlanRequest}; /// Represents the CLI arguments handled by vite-task, including both built-in and custom subcommands. #[derive(Debug)] -pub struct TaskCLIArgs { +pub struct TaskCLIArgs { pub(crate) original: Arc<[Str]>, - pub(crate) parsed: ParsedTaskCLIArgs, + pub(crate) parsed: ParsedTaskCLIArgs, } -pub enum CLIArgs { +pub enum CLIArgs { /// vite-task's own built-in subcommands - Task(TaskCLIArgs), + Task(TaskCLIArgs), /// custom subcommands provided by vite+ - NonTask(NonTaskSubCommand), + NonTask(NonTaskSubcommand), } -impl - CLIArgs +impl + CLIArgs { /// Get the original CLI arguments pub fn try_parse_from( args: impl Iterator>, ) -> Result { #[derive(Debug, clap::Parser)] - enum ParsedCLIArgs { + enum ParsedCLIArgs { /// subcommands handled by vite task #[command(flatten)] - Task(ParsedTaskCLIArgs), + Task(ParsedTaskCLIArgs), /// subcommands that are not handled by vite task #[command(flatten)] - NonTask(NonTaskSubCommand), + NonTask(NonTaskSubcommand), } let args = args.map(|arg| Str::from(arg.as_ref())).collect::>(); - let parsed_cli_args = ParsedCLIArgs::::try_parse_from( + let parsed_cli_args = ParsedCLIArgs::::try_parse_from( args.iter().map(|s| OsStr::new(s.as_str())), )?; @@ -53,13 +53,13 @@ impl } #[derive(Debug, Parser)] -pub(crate) enum ParsedTaskCLIArgs { +pub(crate) enum ParsedTaskCLIArgs { /// subcommands provided by vite task, like `run` #[clap(flatten)] BuiltIn(BuiltInCommand), /// custom subcommands provided by vite+, like `lint` #[clap(flatten)] - Custom(CustomSubCommand), + Custom(CustomSubcommand), } /// vite task CLI subcommands diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index bfc764a7..39bef4c1 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -277,7 +277,7 @@ impl ExecutionContext<'_> { } } -impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { +impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { pub async fn execute( &self, plan: SessionExecutionPlan, diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index 0ce2125c..20f0be1a 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -54,31 +54,31 @@ impl TaskGraphLoader for LazyTaskGraph<'_> { } } -pub struct SessionCallbacks<'a, CustomSubCommand> { - pub task_synthesizer: &'a mut (dyn TaskSynthesizer + 'a), +pub struct SessionCallbacks<'a, CustomSubcommand> { + pub task_synthesizer: &'a mut (dyn TaskSynthesizer + 'a), pub user_config_loader: &'a mut (dyn UserConfigLoader + 'a), } #[async_trait::async_trait(?Send)] -pub trait TaskSynthesizer: Debug { +pub trait TaskSynthesizer: Debug { fn should_synthesize_for_program(&self, program: &str) -> bool; async fn synthesize_task( &mut self, - subcommand: CustomSubCommand, + subcommand: CustomSubcommand, cwd: &Arc, ) -> anyhow::Result; } #[derive(derive_more::Debug)] -#[debug(bound())] // Avoid requiring CustomSubCommand: Debug -struct PlanRequestParser<'a, CustomSubCommand> { - task_synthesizer: &'a mut (dyn TaskSynthesizer + 'a), +#[debug(bound())] // Avoid requiring CustomSubcommand: Debug +struct PlanRequestParser<'a, CustomSubcommand> { + task_synthesizer: &'a mut (dyn TaskSynthesizer + 'a), } -impl PlanRequestParser<'_, CustomSubCommand> { +impl PlanRequestParser<'_, CustomSubcommand> { async fn get_plan_request_from_cli_args( &mut self, - cli_args: ParsedTaskCLIArgs, + cli_args: ParsedTaskCLIArgs, cwd: &Arc, ) -> anyhow::Result { match cli_args { @@ -95,8 +95,8 @@ impl PlanRequestParser<'_, CustomSubCommand> } #[async_trait::async_trait(?Send)] -impl vite_task_plan::PlanRequestParser - for PlanRequestParser<'_, CustomSubCommand> +impl vite_task_plan::PlanRequestParser + for PlanRequestParser<'_, CustomSubcommand> { async fn get_plan_request( &mut self, @@ -107,9 +107,9 @@ impl vite_task_plan::PlanRequestParser Ok( if self.task_synthesizer.should_synthesize_for_program(program) && let Some(subcommand) = args.first() - && ParsedTaskCLIArgs::::has_subcommand(subcommand) + && ParsedTaskCLIArgs::::has_subcommand(subcommand) { - let cli_args = ParsedTaskCLIArgs::::try_parse_from( + let cli_args = ParsedTaskCLIArgs::::try_parse_from( std::iter::once(program).chain(args.iter().map(Str::as_str)), )?; Some(self.get_plan_request_from_cli_args(cli_args, cwd).await?) @@ -123,7 +123,7 @@ impl vite_task_plan::PlanRequestParser /// Represents a vite task session for planning and executing tasks. A process typically has one session. /// /// A session manages task graph loading internally and provides non-consuming methods to plan and/or execute tasks (allows multiple plans/executions per session). -pub struct Session<'a, CustomSubCommand> { +pub struct Session<'a, CustomSubcommand> { workspace_path: Arc, /// A session doesn't necessarily load the task graph immediately. /// The task graph is loaded on-demand and cached for future use. @@ -132,7 +132,7 @@ pub struct Session<'a, CustomSubCommand> { envs: HashMap, Arc>, cwd: Arc, - plan_request_parser: PlanRequestParser<'a, CustomSubCommand>, + plan_request_parser: PlanRequestParser<'a, CustomSubcommand>, cache: ExecutionCache, } @@ -145,9 +145,9 @@ fn get_cache_path_of_workspace(workspace_root: &AbsolutePath) -> AbsolutePathBuf } } -impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { +impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { /// Initialize a session with real environment variables and cwd - pub fn init(callbacks: SessionCallbacks<'a, CustomSubCommand>) -> anyhow::Result { + pub fn init(callbacks: SessionCallbacks<'a, CustomSubcommand>) -> anyhow::Result { let envs = std::env::vars_os() .map(|(k, v)| (Arc::::from(k.as_os_str()), Arc::::from(v.as_os_str()))) .collect(); @@ -158,7 +158,7 @@ impl<'a, CustomSubCommand> Session<'a, CustomSubCommand> { pub fn init_with( envs: HashMap, Arc>, cwd: Arc, - callbacks: SessionCallbacks<'a, CustomSubCommand>, + callbacks: SessionCallbacks<'a, CustomSubcommand>, ) -> anyhow::Result { let (workspace_root, _) = find_workspace_root(&cwd)?; let cache_path = get_cache_path_of_workspace(&workspace_root.path); @@ -212,11 +212,11 @@ pub struct SessionExecutionPlan { plan: vite_task_plan::ExecutionPlan, } -impl<'a, CustomSubCommand: clap::Subcommand> Session<'a, CustomSubCommand> { +impl<'a, CustomSubcommand: clap::Subcommand> Session<'a, CustomSubcommand> { pub async fn plan( &mut self, cwd: Arc, - cli_args: TaskCLIArgs, + cli_args: TaskCLIArgs, ) -> Result { let plan_request = self .plan_request_parser diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index bdd9de00..6616011e 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -5,7 +5,7 @@ use std::{ sync::Arc, }; -use clap::{Parser, Subcommand}; +use clap::Subcommand; use vite_path::{AbsolutePath, current_dir}; use vite_str::Str; use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanRequest}; From a3ad5a1e5c3c27e3a5da1ef2b278a73184aee10a Mon Sep 17 00:00:00 2001 From: branchseer Date: Mon, 29 Dec 2025 12:32:13 +0800 Subject: [PATCH 07/27] update --- Cargo.lock | 2 + .../src/session/cache/fingerprint.rs | 2 +- crates/vite_task/src/session/execute/mod.rs | 58 ++--- crates/vite_task_bin/src/main.rs | 16 +- crates/vite_task_plan/Cargo.toml | 2 + crates/vite_task_plan/src/cache_metadata.rs | 109 ++++++++++ crates/vite_task_plan/src/context.rs | 10 + crates/vite_task_plan/src/envs.rs | 54 ++--- crates/vite_task_plan/src/error.rs | 43 +++- crates/vite_task_plan/src/lib.rs | 68 +++--- crates/vite_task_plan/src/plan.rs | 199 +++++++++++++++--- crates/vite_task_plan/src/plan_request.rs | 4 + 12 files changed, 440 insertions(+), 127 deletions(-) create mode 100644 crates/vite_task_plan/src/cache_metadata.rs diff --git a/Cargo.lock b/Cargo.lock index 6487c191..c3ec1a48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3307,8 +3307,10 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", + "bincode", "futures-util", "petgraph", + "serde", "sha2", "shell-escape", "supports-color", diff --git a/crates/vite_task/src/session/cache/fingerprint.rs b/crates/vite_task/src/session/cache/fingerprint.rs index ce70cd3c..8304c6ad 100644 --- a/crates/vite_task/src/session/cache/fingerprint.rs +++ b/crates/vite_task/src/session/cache/fingerprint.rs @@ -9,7 +9,7 @@ use diff::Diff; use serde::{Deserialize, Serialize}; use vite_path::{AbsolutePath, RelativePathBuf}; use vite_str::Str; -use vite_task_plan::{SpawnCommandKind, SpawnExecution}; +use vite_task_plan::SpawnExecution; /// Fingerprint for command execution that affects caching. /// diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index 39bef4c1..c87cfc04 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -11,8 +11,8 @@ use vite_path::{AbsolutePath, RelativePathBuf, relative::InvalidPathDataError}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex}; use vite_task_plan::{ - ExecutionItem, ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnCommandKind, - SpawnExecution, TaskExecution, + ExecutionItem, ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnExecution, + TaskExecution, execution_graph::{ExecutionGraph, ExecutionIx, ExecutionNodeIndex}, }; @@ -245,34 +245,34 @@ impl ExecutionContext<'_> { } }; - let mut cmd = match &spawn_execution.command_kind { - SpawnCommandKind::Program { program_path, args } => { - let mut cmd = fspy::Command::new(program_path.as_path()); - cmd.args(args.iter().map(|arg| arg.as_str())); - cmd - } - SpawnCommandKind::ShellScript { script, args } => { - let mut cmd = if cfg!(windows) { - let mut cmd = fspy::Command::new("cmd.exe"); - // https://github.com/nodejs/node/blob/dbd24b165128affb7468ca42f69edaf7e0d85a9a/lib/child_process.js#L633 - cmd.args(["/d", "/s", "/c"]); - cmd - } else { - let mut cmd = fspy::Command::new("sh"); - cmd.args(["-c"]); - cmd - }; + // let mut cmd = match &spawn_execution.command_kind { + // SpawnCommandKind::Program { program_path, args } => { + // let mut cmd = fspy::Command::new(program_path.as_path()); + // cmd.args(args.iter().map(|arg| arg.as_str())); + // cmd + // } + // SpawnCommandKind::ShellScript { script, args } => { + // let mut cmd = if cfg!(windows) { + // let mut cmd = fspy::Command::new("cmd.exe"); + // // https://github.com/nodejs/node/blob/dbd24b165128affb7468ca42f69edaf7e0d85a9a/lib/child_process.js#L633 + // cmd.args(["/d", "/s", "/c"]); + // cmd + // } else { + // let mut cmd = fspy::Command::new("sh"); + // cmd.args(["-c"]); + // cmd + // }; - let mut script = script.clone(); - for arg in args.iter() { - script.push(' '); - script.push_str(shell_escape::escape(arg.as_str().into()).as_ref()); - } - cmd.arg(script); - cmd - } - }; - cmd.envs(spawn_execution.all_envs.iter()).current_dir(&*spawn_execution.cwd); + // let mut script = script.clone(); + // for arg in args.iter() { + // script.push(' '); + // script.push_str(shell_escape::escape(arg.as_str().into()).as_ref()); + // } + // cmd.arg(script); + // cmd + // } + // }; + // cmd.envs(spawn_execution.all_envs.iter()).current_dir(&*spawn_execution.cwd); todo!() } } diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index 6616011e..433e4ffc 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -1,6 +1,7 @@ use std::{ env::{self, join_paths}, ffi::OsStr, + iter, path::PathBuf, sync::Arc, }; @@ -57,11 +58,16 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { cwd: &Arc, ) -> anyhow::Result { match subcommand { - CustomTaskSubcommand::Lint { args } => Ok(SyntheticPlanRequest { - program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, - args: args.into(), - task_options: Default::default(), - }), + CustomTaskSubcommand::Lint { args } => { + let direct_execution_cache_key: Arc<[Str]> = + iter::once(Str::from("lint")).chain(args.iter().cloned()).collect(); + Ok(SyntheticPlanRequest { + program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, + args: args.into(), + task_options: Default::default(), + direct_execution_cache_key, + }) + } } } } diff --git a/crates/vite_task_plan/Cargo.toml b/crates/vite_task_plan/Cargo.toml index 8355b0a8..b3b59bd3 100644 --- a/crates/vite_task_plan/Cargo.toml +++ b/crates/vite_task_plan/Cargo.toml @@ -13,8 +13,10 @@ workspace = true [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } +bincode = { workspace = true } futures-util = { workspace = true } petgraph = { workspace = true } +serde = { workspace = true, features = ["derive"] } sha2 = { workspace = true } shell-escape = { workspace = true } supports-color = { workspace = true } diff --git a/crates/vite_task_plan/src/cache_metadata.rs b/crates/vite_task_plan/src/cache_metadata.rs new file mode 100644 index 00000000..0f712f57 --- /dev/null +++ b/crates/vite_task_plan/src/cache_metadata.rs @@ -0,0 +1,109 @@ +use std::{ + collections::{BTreeMap, BTreeSet, HashMap}, + ffi::OsStr, + sync::Arc, +}; + +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; +use vite_path::RelativePathBuf; +use vite_str::Str; +use vite_task_graph::config::CacheConfig; + +use crate::{SpawnCommand, envs::EnvFingerprints}; + +/// The kind of a key to identify an execution. +#[derive(Debug, Encode, bincode::Decode, Serialize)] +pub(crate) enum ExecutionCacheKeyKind { + /// This execution is directly from a custom syntatic vite-task subcommand (like `vite lint`). + /// + /// Note that this is only for the case where the subcommand is directly typed in the cli, + /// not from a task script (like `"lint-task": "vite lint"`), which is covered by the `UserTask` variant. + DirectSyntatic { + /// Provided in `SyntheticPlanRequest.direct_execution_cache_key` by task synthezier + direct_execution_cache_key: Arc<[Str]>, + }, + /// This execution is from a script of a user-defined task. + UserTask { + /// The name of the user-defined task. + task_name: Str, + /// The index of the execution item in the task's command split by `&&`. + /// This is to distinguish multiple execution items from the same task. + and_item_index: usize, + }, +} + +/// Key to identify an execution +#[derive(Debug, Encode, Decode, Serialize)] +pub struct ExecutionCacheKey { + /// The kind of the execution cache key (DirectSyntatic or UserTask) + pub(crate) kind: ExecutionCacheKeyKind, + /// The origin path where this execution is planned from. + /// It's relative to the workspace root. + /// + /// - For DirectSyntatic, it's the cwd where the command `vite [custom subcommand] ...` is run. + /// It's not necessarily the actual cwd that the synthesized task runs in. + /// - For UserTask, it's the package path where the user-defined task is defined. + pub(crate) origin_path: RelativePathBuf, +} + +/// Cache information for a spawn execution. +/// It only contains information needed for hitting existing cache entries pre-execution. +/// It doesn't contain any post-execution information like file fingerprints +/// (which needs actual execution and is out of scope for planning). +#[derive(Debug, Encode, Decode, Serialize)] +pub struct CacheMetadata { + /// Fingerprint for spawn execution that affects caching. + pub spawn_fingerprint: SpawnFingerprint, + + /// Key to identify an execution. + pub execution_cache_key: ExecutionCacheKey, +} + +/// Fingerprint for spawn execution that affects caching. +/// +/// # Environment Variable Impact on Cache +/// +/// The `envs_without_pass_through` field is crucial for cache correctness: +/// - Only includes envs explicitly declared in the task's `envs` array +/// - Does NOT include pass-through envs (PATH, CI, etc.) +/// - These envs become part of the cache key +/// +/// When a task runs: +/// 1. All envs (including pass-through) are available to the process +/// 2. Only declared envs affect the cache key +/// 3. If a declared env changes value, cache will miss +/// 4. If a pass-through env changes, cache will still hit +/// +/// For built-in tasks (lint, build, etc): +/// - The resolver provides envs which become part of the fingerprint +/// - If resolver provides different envs between runs, cache breaks +/// - Each built-in task type must have unique task name to avoid cache collision +/// +/// # Fingerprint Ignores Impact on Cache +/// +/// The `fingerprint_ignores` field controls which files are tracked in `PostRunFingerprint`: +/// - Changes to this config must invalidate the cache +/// - Vec maintains insertion order (pattern order matters for last-match-wins semantics) +/// - Even though ignore patterns only affect `PostRunFingerprint`, the config itself is part of the cache key +#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq)] +pub struct SpawnFingerprint { + pub(crate) cwd: RelativePathBuf, + pub(crate) program_fingerprint: ProgramFingerprint, + pub(crate) args: Arc<[Str]>, + pub(crate) env_fingerprints: EnvFingerprints, + + /// Glob patterns for fingerprint filtering. Order matters (last match wins). + /// Changes to this config invalidate the cache to ensure correct fingerprint tracking. + pub(crate) fingerprint_ignores: Option>, +} + +/// The program fingerprint used in `SpawnFingerprint` +#[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq)] +pub(crate) enum ProgramFingerprint { + /// If the program is outside the workspace, fingerprint by its name only (like `node`, `npm`, etc) + OutsideWorkspace { program_name: Str }, + + /// If the program is inside the workspace, fingerprint by its path relative to the workspace root + InsideWorkspace { relative_program_path: RelativePathBuf }, +} diff --git a/crates/vite_task_plan/src/context.rs b/crates/vite_task_plan/src/context.rs index 75c4ed51..fb4e38e5 100644 --- a/crates/vite_task_plan/src/context.rs +++ b/crates/vite_task_plan/src/context.rs @@ -20,6 +20,9 @@ pub struct TaskRecursionError { /// The context for planning an execution from a task. #[derive(Debug)] pub struct PlanContext<'a> { + /// The root path of the workspace. + workspace_path: &'a Arc, + /// The current working directory. cwd: Arc, @@ -75,12 +78,14 @@ impl Display for TaskCallStackDisplay { impl<'a> PlanContext<'a> { pub fn new( + workspace_path: &'a Arc, cwd: Arc, envs: HashMap, Arc>, callbacks: &'a mut (dyn PlanRequestParser + 'a), indexed_task_graph: &'a IndexedTaskGraph, ) -> Self { Self { + workspace_path, cwd, envs, callbacks, @@ -129,6 +134,10 @@ impl<'a> PlanContext<'a> { self.indexed_task_graph } + pub fn workspace_path(&self) -> &Arc { + self.workspace_path + } + /// Push a new frame onto the task call stack. pub fn push_stack_frame(&mut self, task_node_index: TaskNodeIndex, command_span: Range) { self.task_call_stack.push((task_node_index, command_span)); @@ -161,6 +170,7 @@ impl<'a> PlanContext<'a> { pub fn duplicate(&mut self) -> PlanContext<'_> { PlanContext { + workspace_path: self.workspace_path, cwd: Arc::clone(&self.cwd), envs: self.envs.clone(), callbacks: self.callbacks, diff --git a/crates/vite_task_plan/src/envs.rs b/crates/vite_task_plan/src/envs.rs index 4ac930ff..4fb0ef13 100644 --- a/crates/vite_task_plan/src/envs.rs +++ b/crates/vite_task_plan/src/envs.rs @@ -4,18 +4,20 @@ use std::{ sync::Arc, }; +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; use sha2::{Digest as _, Sha256}; use supports_color::{Stream, on}; use vite_glob::GlobPatternSet; use vite_str::Str; use vite_task_graph::config::EnvConfig; -/// Resolved environment variables for a task to be fingerprinted. +/// Environment variable fingerprints for a task execution. /// /// Contents of this struct are only for fingerprinting and cache key computation (some of envs may be hashed for security). /// The actual environment variables to be passed to the execution are in `LeafExecutionItem.all_envs`. -#[derive(Debug)] -pub struct ResolvedEnvs { +#[derive(Debug, Encode, Decode, Serialize, Deserialize, PartialEq, Eq)] +pub struct EnvFingerprints { /// Environment variables that should be fingerprinted for this execution. /// /// Use `BTreeMap` to ensure stable order. @@ -24,7 +26,7 @@ pub struct ResolvedEnvs { /// Environment variable names that should be passed through without values being fingerprinted. /// /// Names are still included in the fingerprint so that changes to these names can invalidate the cache. - pub pass_through_envs: Arc<[Str]>, + pub pass_through_env_config: Arc<[Str]>, } #[derive(Debug, thiserror::Error)] @@ -39,7 +41,7 @@ pub enum ResolveEnvError { #[error("Env value is not valid unicode: {key} = {value:?}")] EnvValueIsNotValidUnicode { key: Str, value: Arc }, } -impl ResolvedEnvs { +impl EnvFingerprints { /// Resolves from all available envs and env config. /// /// Before the call, `all_envs` is expected to contain all available envs. @@ -119,7 +121,7 @@ impl ResolvedEnvs { Ok(Self { fingerprinted_envs, // Save pass_through_envs names as-is, so any changes to it will invalidate the cache - pass_through_envs: Arc::clone(&env_config.pass_through_envs), + pass_through_env_config: Arc::clone(&env_config.pass_through_envs), }) } } @@ -208,7 +210,7 @@ mod tests { let mut all_envs = create_test_envs(vec![("PATH", "/usr/bin")]); let env_config = create_env_config(&[], &["PATH"]); - let result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); // FORCE_COLOR should be automatically added if color is supported // Note: This test might vary based on the test environment @@ -224,7 +226,7 @@ mod tests { let mut all_envs = create_test_envs(vec![("PATH", "/usr/bin"), ("FORCE_COLOR", "2")]); let env_config = create_env_config(&[], &["PATH", "FORCE_COLOR"]); - let _result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let _result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); // Should contain the original FORCE_COLOR value assert!(all_envs.contains_key(OsStr::new("FORCE_COLOR"))); @@ -238,7 +240,7 @@ mod tests { let mut all_envs = create_test_envs(vec![("PATH", "/usr/bin"), ("NO_COLOR", "1")]); let env_config = create_env_config(&[], &["PATH", "NO_COLOR"]); - let _result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let _result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); assert!(all_envs.contains_key(OsStr::new("NO_COLOR"))); let no_color_value = all_envs.get(OsStr::new("NO_COLOR")).unwrap(); @@ -278,9 +280,9 @@ mod tests { let mut all_envs2 = create_test_envs(mock_envs.clone()); let mut all_envs3 = create_test_envs(mock_envs.clone()); - let result1 = ResolvedEnvs::resolve(&mut all_envs1, &env_config).unwrap(); - let result2 = ResolvedEnvs::resolve(&mut all_envs2, &env_config).unwrap(); - let result3 = ResolvedEnvs::resolve(&mut all_envs3, &env_config).unwrap(); + let result1 = EnvFingerprints::resolve(&mut all_envs1, &env_config).unwrap(); + let result2 = EnvFingerprints::resolve(&mut all_envs2, &env_config).unwrap(); + let result3 = EnvFingerprints::resolve(&mut all_envs3, &env_config).unwrap(); // Convert to vecs for comparison (BTreeMap already maintains stable ordering) let envs1: Vec<_> = result1.fingerprinted_envs.iter().collect(); @@ -331,7 +333,7 @@ mod tests { ("Test_Var", "mixed"), ]); - let result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); let fingerprinted_envs = &result.fingerprinted_envs; // On Unix, all three should be treated as separate variables @@ -369,9 +371,9 @@ mod tests { let mut all_envs2 = create_test_envs(mock_envs.clone()); let mut all_envs3 = create_test_envs(mock_envs.clone()); - let result1 = ResolvedEnvs::resolve(&mut all_envs1, &env_config).unwrap(); - let result2 = ResolvedEnvs::resolve(&mut all_envs2, &env_config).unwrap(); - let result3 = ResolvedEnvs::resolve(&mut all_envs3, &env_config).unwrap(); + let result1 = EnvFingerprints::resolve(&mut all_envs1, &env_config).unwrap(); + let result2 = EnvFingerprints::resolve(&mut all_envs2, &env_config).unwrap(); + let result3 = EnvFingerprints::resolve(&mut all_envs3, &env_config).unwrap(); let envs1: Vec<_> = result1.fingerprinted_envs.iter().collect(); let envs2: Vec<_> = result2.fingerprinted_envs.iter().collect(); @@ -411,8 +413,8 @@ mod tests { let mut all_envs2 = create_test_envs(vec![("ZZZ", "z"), ("BBB", "b"), ("AAA", "a"), ("MMM", "m")]); - let result1 = ResolvedEnvs::resolve(&mut all_envs1, &env_config).unwrap(); - let result2 = ResolvedEnvs::resolve(&mut all_envs2, &env_config).unwrap(); + let result1 = EnvFingerprints::resolve(&mut all_envs1, &env_config).unwrap(); + let result2 = EnvFingerprints::resolve(&mut all_envs2, &env_config).unwrap(); // Both should produce identical iteration order due to BTreeMap let keys1: Vec<_> = result1.fingerprinted_envs.keys().collect(); @@ -434,13 +436,13 @@ mod tests { ("CI", "true"), ]); - let result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); // Verify pass_through_envs names are stored - assert_eq!(result.pass_through_envs.len(), 3); - assert!(result.pass_through_envs.iter().any(|s| s.as_str() == "PATH")); - assert!(result.pass_through_envs.iter().any(|s| s.as_str() == "HOME")); - assert!(result.pass_through_envs.iter().any(|s| s.as_str() == "CI")); + assert_eq!(result.pass_through_env_config.len(), 3); + assert!(result.pass_through_env_config.iter().any(|s| s.as_str() == "PATH")); + assert!(result.pass_through_env_config.iter().any(|s| s.as_str() == "HOME")); + assert!(result.pass_through_env_config.iter().any(|s| s.as_str() == "CI")); } #[test] @@ -455,7 +457,7 @@ mod tests { ("ANOTHER_FILTERED", "also filtered"), ]); - let _result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let _result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); // all_envs should only contain fingerprinted + pass_through envs (plus auto-added ones) assert!(all_envs.contains_key(OsStr::new("KEEP_THIS"))); @@ -478,7 +480,7 @@ mod tests { .into_iter() .collect(); - let result = ResolvedEnvs::resolve(&mut all_envs, &env_config); + let result = EnvFingerprints::resolve(&mut all_envs, &env_config); assert!(result.is_err()); match result.unwrap_err() { @@ -505,7 +507,7 @@ mod tests { ("NORMAL_VAR", "normal_value"), ]); - let result = ResolvedEnvs::resolve(&mut all_envs, &env_config).unwrap(); + let result = EnvFingerprints::resolve(&mut all_envs, &env_config).unwrap(); // Sensitive envs should be hashed assert!(result.fingerprinted_envs.get("API_KEY").unwrap().starts_with("sha256:")); diff --git a/crates/vite_task_plan/src/error.rs b/crates/vite_task_plan/src/error.rs index 5995a33a..0ba65388 100644 --- a/crates/vite_task_plan/src/error.rs +++ b/crates/vite_task_plan/src/error.rs @@ -1,6 +1,6 @@ -use std::{env::JoinPathsError, ffi::OsStr, fmt::Display, sync::Arc}; +use std::{env::JoinPathsError, ffi::OsStr, fmt::Display, path::Path, sync::Arc}; -use vite_path::AbsolutePath; +use vite_path::{AbsolutePath, relative::InvalidPathDataError}; use crate::{ context::{PlanContext, TaskCallStackDisplay, TaskRecursionError}, @@ -36,6 +36,42 @@ impl Display for WhichError { } } +#[derive(Debug, thiserror::Error)] +pub enum PathFingerprintErrorKind { + #[error("Path {path:?} is outside of the workspace {workspace_path:?}")] + PathOutsideWorkspace { path: Arc, workspace_path: Arc }, + #[error("Path {path:?} contains characters that make it non-portable")] + NonPortableRelativePath { + path: Arc, + #[source] + error: InvalidPathDataError, + }, +} + +#[derive(Debug)] +pub enum PathType { + Cwd, + Program, + PackagePath, +} +impl Display for PathType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PathType::Cwd => write!(f, "current working directory"), + PathType::Program => write!(f, "program path"), + PathType::PackagePath => write!(f, "package path"), + } + } +} + +#[derive(Debug, thiserror::Error)] +#[error("Failed to fingerprint {path_type}")] +pub struct PathFingerprintError { + pub path_type: PathType, + #[source] + pub kind: PathFingerprintErrorKind, +} + /// Errors that can occur when planning a specific execution from a task . #[derive(Debug, thiserror::Error)] pub enum TaskPlanErrorKind { @@ -56,6 +92,9 @@ pub enum TaskPlanErrorKind { #[error(transparent)] ProgramNotFound(#[from] WhichError), + #[error(transparent)] + PathFingerprintError(#[from] PathFingerprintError), + #[error("Failed to query tasks from task graph")] TaskQueryError( #[source] diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 617dd1ef..84f3c95f 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -1,3 +1,4 @@ +pub mod cache_metadata; mod context; mod envs; mod error; @@ -9,52 +10,51 @@ pub mod plan_request; use std::{collections::HashMap, ffi::OsStr, fmt::Debug, ops::Range, sync::Arc}; +use bincode::Encode; use context::PlanContext; -use envs::ResolvedEnvs; +use envs::EnvFingerprints; use error::TaskPlanErrorKindResultExt; pub use error::{Error, TaskPlanErrorKind}; use execution_graph::ExecutionGraph; use in_process::InProcessExecution; use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; -use vite_path::AbsolutePath; +use serde::Serialize; +use vite_path::{AbsolutePath, RelativePathBuf}; use vite_str::Str; use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, query::TaskQuery}; -use crate::path_env::prepend_path_env; - -/// Resolved cache configuration for a spawn execution. -#[derive(Debug)] -pub struct ResolvedCacheMetadata { - /// Environment variables that are used for fingerprinting the cache. - pub resolved_envs: ResolvedEnvs, -} +use crate::{ + cache_metadata::{ExecutionCacheKey, ExecutionCacheKeyKind}, + path_env::prepend_path_env, +}; /// A resolved spawn execution. /// Unlike tasks in `vite_task_graph`, this struct contains all information needed for execution, /// like resolved environment variables, current working directory, and additional args from cli. #[derive(Debug)] pub struct SpawnExecution { - /// Resolved cache metadata for this execution. `None` means caching is disabled. - pub resolved_cache_metadata: Option, + /// Cache metadata for this execution. `None` means caching is disabled. + pub cache_metadata: Option, + + /// All information about a command to be spawned + pub spawn_command: SpawnCommand, +} + +/// All information about a command to be spawned. +#[derive(Debug)] +pub struct SpawnCommand { + /// A program with args to be executed directly + pub program_path: Arc, + + /// args to be passed to the program + pub args: Arc<[Str]>, /// Environment variables to set for the command, including both fingerprinted and pass-through envs. pub all_envs: Arc, Arc>>, /// Current working directory pub cwd: Arc, - - /// parsed program with args or shell script - pub command_kind: SpawnCommandKind, -} - -/// The kind of a spawn command -#[derive(Debug)] -pub enum SpawnCommandKind { - /// A program with args to be executed directly - Program { program_path: Arc, args: Arc<[Str]> }, - /// A script to be executed by os shell (sh or cmd) - ShellScript { script: Str, args: Arc<[Str]> }, } /// Represents how a task should be executed. It's the node type for the execution graph. Each node corresponds to a task. @@ -149,10 +149,6 @@ pub struct ExecutionPlan { root_node: ExecutionItemKind, } -pub struct Args { - pub query: TaskQuery, -} - impl ExecutionPlan { pub fn root_node(&self) -> &ExecutionItemKind { &self.root_node @@ -160,7 +156,7 @@ impl ExecutionPlan { pub async fn plan( plan_request: PlanRequest, - workspace_path: &AbsolutePath, + workspace_path: &Arc, cwd: &Arc, envs: &HashMap, Arc>, plan_request_parser: &mut (dyn PlanRequestParser + '_), @@ -182,6 +178,7 @@ impl ExecutionPlan { .with_empty_call_stack()?; let context = PlanContext::new( + workspace_path, Arc::clone(cwd), envs.clone(), plan_request_parser, @@ -191,10 +188,15 @@ impl ExecutionPlan { ExecutionItemKind::Expanded(execution_graph) } PlanRequest::Synthetic(synthetic_plan_request) => { - let execution = - plan_synthetic_request(&Default::default(), synthetic_plan_request, cwd, &envs) - .with_empty_call_stack()?; - + let execution = plan_synthetic_request( + workspace_path, + &Default::default(), + synthetic_plan_request, + None, + cwd, + &envs, + ) + .with_empty_call_stack()?; ExecutionItemKind::Leaf(LeafExecutionKind::Spawn(execution)) } }; diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 00f81bc4..c564cef4 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -3,21 +3,28 @@ use std::{ collections::{BTreeMap, HashMap}, env::home_dir, ffi::OsStr, - path::Path, - sync::Arc, + path::{Path, PathBuf}, + sync::{Arc, LazyLock}, }; use futures_util::FutureExt; -use vite_path::{AbsolutePath, AbsolutePathBuf}; +use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf, relative::InvalidPathDataError}; use vite_shell::try_parse_as_and_list; use vite_str::Str; use vite_task_graph::{TaskNodeIndex, config::ResolvedTaskOptions}; use crate::{ - ExecutionItem, ExecutionItemKind, LeafExecutionKind, PlanContext, ResolvedCacheMetadata, - SpawnCommandKind, SpawnExecution, TaskExecution, - envs::ResolvedEnvs, - error::{CdCommandError, Error, TaskPlanErrorKind, TaskPlanErrorKindResultExt}, + ExecutionItem, ExecutionItemKind, LeafExecutionKind, PlanContext, SpawnCommand, SpawnExecution, + TaskExecution, + cache_metadata::{ + CacheMetadata, ExecutionCacheKey, ExecutionCacheKeyKind, ProgramFingerprint, + SpawnFingerprint, + }, + envs::EnvFingerprints, + error::{ + CdCommandError, Error, PathFingerprintError, PathFingerprintErrorKind, PathType, + TaskPlanErrorKind, TaskPlanErrorKindResultExt, + }, execution_graph::{ExecutionGraph, ExecutionNodeIndex}, in_process::InProcessExecution, path_env::get_path_env, @@ -57,12 +64,9 @@ async fn plan_task_as_execution_node( let task_node = &context.indexed_task_graph().task_graph()[task_node_index]; let command_str = task_node.resolved_config.command.as_str(); + let package_path = context.indexed_task_graph().get_package_path_for_task(task_node_index); // Prepend {package_path}/node_modules/.bin to PATH - let package_node_modules_bin_path = context - .indexed_task_graph() - .get_package_path_for_task(task_node_index) - .join("node_modules") - .join(".bin"); + let package_node_modules_bin_path = package_path.join("node_modules").join(".bin"); if let Err(join_paths_error) = context.prepend_path(&package_node_modules_bin_path) { // Push the current task frame with full command span (the path was added for every and_item of the command) before returning the error context.push_stack_frame(task_node_index, 0..command_str.len()); @@ -125,15 +129,31 @@ async fn plan_task_as_execution_node( continue; } - // Try to parse the args of an and_item to a task request like `run -r build` - let task_request = context + // Create execution cache key for this and_item + let task_execution_cache_key = ExecutionCacheKey { + kind: ExecutionCacheKeyKind::UserTask { + task_name: task_node.task_id.task_name.clone(), + and_item_index: index, + }, + origin_path: strip_prefix_for_cache(package_path, context.workspace_path()) + .map_err(|kind| { + TaskPlanErrorKind::PathFingerprintError(PathFingerprintError { + kind, + path_type: PathType::PackagePath, + }) + }) + .with_plan_context(&context)?, + }; + + // Try to parse the args of an and_item to a plan request like `run -r build` + let plan_request = context .callbacks() .get_plan_request(&and_item.program, &args, &cwd) .await .map_err(|error| TaskPlanErrorKind::ParsePlanRequestError { error }) .with_plan_context(&context)?; - let execution_item_kind: ExecutionItemKind = match task_request { + let execution_item_kind: ExecutionItemKind = match plan_request { // Expand task query like `vite run -r build` Some(PlanRequest::Query(query_plan_request)) => { // Add prefix envs to the context @@ -144,8 +164,10 @@ async fn plan_task_as_execution_node( // Synthetic task, like `vite lint` Some(PlanRequest::Synthetic(synthetic_plan_request)) => { let spawn_execution = plan_synthetic_request( + context.workspace_path(), &and_item.envs, synthetic_plan_request, + Some(task_execution_cache_key), context.cwd(), context.envs(), ) @@ -159,10 +181,13 @@ async fn plan_task_as_execution_node( .map_err(TaskPlanErrorKind::ProgramNotFound) .with_plan_context(&context)?; let spawn_execution = plan_spawn_execution( + context.workspace_path(), + task_execution_cache_key, &and_item.envs, - SpawnCommandKind::Program { program_path, args: args.into() }, &task_node.resolved_config.resolved_options, context.envs(), + program_path, + args.into(), ) .with_plan_context(&context)?; ExecutionItemKind::Leaf(LeafExecutionKind::Spawn(spawn_execution)) @@ -176,14 +201,49 @@ async fn plan_task_as_execution_node( }); } } else { + let mut context = context.duplicate(); + context.push_stack_frame(task_node_index, 0..command_str.len()); + + static SHELL_PROGRAM_PATH: LazyLock> = LazyLock::new(|| { + if cfg!(target_os = "windows") { + AbsolutePathBuf::new( + which::which("cmd.exe") + .unwrap_or_else(|_| PathBuf::from("C:\\Windows\\System32\\cmd.exe")), + ) + .unwrap() + .into() + } else { + AbsolutePath::new("/bin/sh").unwrap().into() + } + }); + + let mut script = Str::from(command_str); + for arg in context.extra_args().iter() { + script.push(' '); + script.push_str(shell_escape::escape(arg.as_str().into()).as_ref()); + } + let spawn_execution = plan_spawn_execution( - &BTreeMap::new(), - SpawnCommandKind::ShellScript { - script: command_str.into(), - args: Arc::clone(context.extra_args()), + context.workspace_path(), + ExecutionCacheKey { + kind: ExecutionCacheKeyKind::UserTask { + task_name: task_node.task_id.task_name.clone(), + and_item_index: 0, + }, + origin_path: strip_prefix_for_cache(package_path, context.workspace_path()) + .map_err(|kind| { + TaskPlanErrorKind::PathFingerprintError(PathFingerprintError { + kind, + path_type: PathType::PackagePath, + }) + }) + .with_plan_context(&context)?, }, + &BTreeMap::new(), &task_node.resolved_config.resolved_options, context.envs(), + Arc::clone(&*SHELL_PROGRAM_PATH), + Arc::new([script]), ) .with_plan_context(&context)?; items.push(ExecutionItem { @@ -198,42 +258,116 @@ async fn plan_task_as_execution_node( } pub fn plan_synthetic_request( + workspace_path: &Arc, prefix_envs: &BTreeMap, synthetic_plan_request: SyntheticPlanRequest, + // generated from the task, overrides `synthetic_plan_request.direct_execution_cache_key` + task_execution_cache_key: Option, cwd: &Arc, envs: &HashMap, Arc>, ) -> Result { - let SyntheticPlanRequest { program, args, task_options } = synthetic_plan_request; + let SyntheticPlanRequest { program, args, task_options, direct_execution_cache_key } = + synthetic_plan_request; let program_path = which(&program, envs, cwd).map_err(TaskPlanErrorKind::ProgramNotFound)?; let resolved_options = ResolvedTaskOptions::resolve(task_options, &cwd); + + let execution_cache_key = if let Some(task_execution_cache_key) = task_execution_cache_key { + // Use task generated cache key if any + task_execution_cache_key + } else { + // Otherwise, use direct execution cache key + ExecutionCacheKey { + kind: ExecutionCacheKeyKind::DirectSyntatic { direct_execution_cache_key }, + origin_path: strip_prefix_for_cache(cwd, workspace_path) + .map_err(|kind| PathFingerprintError { kind, path_type: PathType::Cwd })?, + } + }; + plan_spawn_execution( + workspace_path, + execution_cache_key, prefix_envs, - SpawnCommandKind::Program { program_path, args }, &resolved_options, envs, + program_path, + args, ) } +fn strip_prefix_for_cache( + path: &Arc, + workspace_path: &Arc, +) -> Result { + match path.strip_prefix(&*workspace_path) { + Ok(Some(rel_path)) => Ok(rel_path), + Ok(None) => Err(PathFingerprintErrorKind::PathOutsideWorkspace { + path: Arc::clone(path), + workspace_path: Arc::clone(workspace_path), + }), + Err(err) => Err(PathFingerprintErrorKind::NonPortableRelativePath { + path: err.stripped_path.into(), + error: err.invalid_path_data_error, + }), + } +} + fn plan_spawn_execution( + workspace_path: &Arc, + execution_cache_key: ExecutionCacheKey, prefix_envs: &BTreeMap, - command_kind: SpawnCommandKind, resolved_task_options: &ResolvedTaskOptions, envs: &HashMap, Arc>, + program_path: Arc, + args: Arc<[Str]>, ) -> Result { // all envs available in the current context let mut all_envs = envs.clone(); + let cwd = Arc::clone(&resolved_task_options.cwd); let mut resolved_cache_metadata = None; if let Some(cache_config) = &resolved_task_options.cache_config { // Resolve envs according cache configs - let mut resolved_envs = ResolvedEnvs::resolve(&mut all_envs, &cache_config.env_config) - .map_err(TaskPlanErrorKind::ResolveEnvError)?; + let mut env_fingerprints = + EnvFingerprints::resolve(&mut all_envs, &cache_config.env_config) + .map_err(TaskPlanErrorKind::ResolveEnvError)?; // Add prefix envs to fingerprinted envs - resolved_envs + env_fingerprints .fingerprinted_envs .extend(prefix_envs.iter().map(|(name, value)| (name.clone(), value.as_str().into()))); - resolved_cache_metadata = Some(ResolvedCacheMetadata { resolved_envs }); + + let program_fingerprint = match strip_prefix_for_cache(&program_path, workspace_path) { + Ok(relative_program_path) => { + ProgramFingerprint::InsideWorkspace { relative_program_path } + } + Err(PathFingerprintErrorKind::PathOutsideWorkspace { path, .. }) => { + let program_name_os_str = path.as_path().file_name().unwrap_or_default(); + let Some(program_name_str) = program_name_os_str.to_str() else { + return Err(PathFingerprintError { + kind: PathFingerprintErrorKind::NonPortableRelativePath { + path: Path::new(program_name_os_str).into(), + error: InvalidPathDataError::NonUtf8, + }, + path_type: PathType::Program, + } + .into()); + }; + ProgramFingerprint::OutsideWorkspace { program_name: program_name_str.into() } + } + Err(err) => { + return Err(PathFingerprintError { kind: err, path_type: PathType::Program }.into()); + } + }; + + let spawn_fingerprint: SpawnFingerprint = SpawnFingerprint { + cwd: strip_prefix_for_cache(&cwd, workspace_path) + .map_err(|kind| PathFingerprintError { kind, path_type: PathType::Cwd })?, + program_fingerprint, + args: Arc::clone(&args), + env_fingerprints, + fingerprint_ignores: None, + }; + resolved_cache_metadata = Some(CacheMetadata { execution_cache_key, spawn_fingerprint }); } // Add prefix envs to all envs @@ -242,10 +376,13 @@ fn plan_spawn_execution( })); Ok(SpawnExecution { - all_envs: Arc::new(all_envs), - resolved_cache_metadata, - cwd: Arc::clone(&resolved_task_options.cwd), - command_kind, + spawn_command: SpawnCommand { + program_path, + args: Arc::clone(&args), + cwd, + all_envs: Arc::new(all_envs), + }, + cache_metadata: resolved_cache_metadata, }) } diff --git a/crates/vite_task_plan/src/plan_request.rs b/crates/vite_task_plan/src/plan_request.rs index 1b34445b..d6afe05d 100644 --- a/crates/vite_task_plan/src/plan_request.rs +++ b/crates/vite_task_plan/src/plan_request.rs @@ -31,6 +31,10 @@ pub struct SyntheticPlanRequest { /// The task options as if it's defined in `vite.config.*` pub task_options: UserTaskOptions, + + /// The cache key for execution directly issued from user command line. + /// It typically includes the subcommand name and all args after it. (e.g. `["lint", "--fix"]` for `vite lint --fix`) + pub direct_execution_cache_key: Arc<[Str]>, } #[derive(Debug)] From 710c6db874dd0d6a34edeba949163c76ed5e5b98 Mon Sep 17 00:00:00 2001 From: branchseer Date: Tue, 30 Dec 2025 23:02:27 +0800 Subject: [PATCH 08/27] wip --- .../src/session/cache/fingerprint.rs | 9 +-- crates/vite_task/src/session/event.rs | 2 - crates/vite_task/src/session/execute/mod.rs | 11 +-- crates/vite_task_bin/src/lib.rs | 73 ++++++++++++++++++ crates/vite_task_bin/src/main.rs | 74 +------------------ crates/vite_task_bin/tests/snapshots.rs | 1 + crates/vite_task_plan/src/cache_metadata.rs | 9 +-- crates/vite_task_plan/src/lib.rs | 12 +-- package.json | 3 +- 9 files changed, 90 insertions(+), 104 deletions(-) create mode 100644 crates/vite_task_bin/src/lib.rs create mode 100644 crates/vite_task_bin/tests/snapshots.rs diff --git a/crates/vite_task/src/session/cache/fingerprint.rs b/crates/vite_task/src/session/cache/fingerprint.rs index 8304c6ad..c691ce59 100644 --- a/crates/vite_task/src/session/cache/fingerprint.rs +++ b/crates/vite_task/src/session/cache/fingerprint.rs @@ -1,15 +1,10 @@ -use std::{ - collections::{BTreeMap, BTreeSet}, - path::Path, - sync::Arc, -}; +use std::collections::{BTreeMap, BTreeSet}; use bincode::{Decode, Encode}; use diff::Diff; use serde::{Deserialize, Serialize}; -use vite_path::{AbsolutePath, RelativePathBuf}; +use vite_path::RelativePathBuf; use vite_str::Str; -use vite_task_plan::SpawnExecution; /// Fingerprint for command execution that affects caching. /// diff --git a/crates/vite_task/src/session/event.rs b/crates/vite_task/src/session/event.rs index aa45f814..4cf6108f 100644 --- a/crates/vite_task/src/session/event.rs +++ b/crates/vite_task/src/session/event.rs @@ -4,8 +4,6 @@ use bstr::BString; use vite_path::AbsolutePath; use vite_str::Str; -use crate::collections::HashMap; - #[derive(Clone, Debug)] pub struct ExecutionStartInfo { /// None if the execution is not associated with a specific task, but directly synthesized from CLI args, like `vite lint`/`vite exec ...` diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index c87cfc04..2f522cd0 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -1,26 +1,23 @@ -use core::task; -use std::{borrow::Cow, ops::Range, path::Path, sync::Arc}; +use std::{borrow::Cow, path::Path, sync::Arc}; use futures_util::FutureExt; use petgraph::{ algo::{Cycle, toposort}, graph::DiGraph, }; -use sha2::digest::typenum::Abs; use vite_path::{AbsolutePath, RelativePathBuf, relative::InvalidPathDataError}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex}; use vite_task_plan::{ - ExecutionItem, ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnExecution, - TaskExecution, - execution_graph::{ExecutionGraph, ExecutionIx, ExecutionNodeIndex}, + ExecutionItem, ExecutionItemKind, LeafExecutionKind, SpawnExecution, TaskExecution, + execution_graph::{ExecutionIx, ExecutionNodeIndex}, }; use super::{ cache::{ExecutionCache, ExecutionCacheKey}, event::{ CacheDisabledReason, CacheStatus, ExecutionEvent, ExecutionEventKind, ExecutionId, - ExecutionStartInfo, ExecutionStartedEvent, OutputKind, + ExecutionStartInfo, OutputKind, }, }; use crate::{ diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs new file mode 100644 index 00000000..e1e2f297 --- /dev/null +++ b/crates/vite_task_bin/src/lib.rs @@ -0,0 +1,73 @@ +use std::{ + env::{self, join_paths}, + ffi::OsStr, + iter, + path::PathBuf, + sync::Arc, +}; + +use clap::Subcommand; +use vite_path::{AbsolutePath, current_dir}; +use vite_str::Str; +use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanRequest}; + +/// Theses are the custom subcommands that synthesize tasks for vite-task +#[derive(Debug, Subcommand)] +pub enum CustomTaskSubcommand { + /// oxlint + Lint { args: Vec }, +} + +// These are the subcommands that is not handled by vite-task +#[derive(Debug, Subcommand)] +pub enum NonTaskSubcommand { + Version, +} + +#[derive(Debug)] +pub struct TaskSynthesizer; + +fn find_executable_in_node_modules_bin( + cwd: &AbsolutePath, + executable: &str, +) -> anyhow::Result> { + let mut paths: Vec = vec![]; + let mut current_cwd_parent = cwd; + loop { + let node_modules_bin = current_cwd_parent.join("node_modules").join(".bin"); + paths.push(node_modules_bin.as_path().to_path_buf()); + if let Some(parent) = current_cwd_parent.parent() { + current_cwd_parent = parent; + } else { + break; + } + } + let executable_path = which::which_in(executable, Some(join_paths(paths)?), cwd)?; + Ok(executable_path.into_os_string().into()) +} + +#[async_trait::async_trait(?Send)] +impl vite_task::TaskSynthesizer for TaskSynthesizer { + fn should_synthesize_for_program(&self, program: &str) -> bool { + program == "vite" + } + + async fn synthesize_task( + &mut self, + subcommand: CustomTaskSubcommand, + cwd: &Arc, + ) -> anyhow::Result { + match subcommand { + CustomTaskSubcommand::Lint { args } => { + let direct_execution_cache_key: Arc<[Str]> = + iter::once(Str::from("lint")).chain(args.iter().cloned()).collect(); + Ok(SyntheticPlanRequest { + program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, + args: args.into(), + task_options: Default::default(), + direct_execution_cache_key, + }) + } + } + } +} diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index 433e4ffc..ff2b8a8f 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -1,76 +1,8 @@ -use std::{ - env::{self, join_paths}, - ffi::OsStr, - iter, - path::PathBuf, - sync::Arc, -}; +use std::{env, sync::Arc}; -use clap::Subcommand; use vite_path::{AbsolutePath, current_dir}; -use vite_str::Str; -use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanRequest}; - -/// Theses are the custom subcommands that synthesize tasks for vite-task -#[derive(Debug, Subcommand)] -enum CustomTaskSubcommand { - /// oxlint - Lint { args: Vec }, -} - -// These are the subcommands that is not handled by vite-task -#[derive(Debug, Subcommand)] -enum NonTaskSubcommand { - Version, -} - -#[derive(Debug)] -struct TaskSynthesizer; - -fn find_executable_in_node_modules_bin( - cwd: &AbsolutePath, - executable: &str, -) -> anyhow::Result> { - let mut paths: Vec = vec![]; - let mut current_cwd_parent = cwd; - loop { - let node_modules_bin = current_cwd_parent.join("node_modules").join(".bin"); - paths.push(node_modules_bin.as_path().to_path_buf()); - if let Some(parent) = current_cwd_parent.parent() { - current_cwd_parent = parent; - } else { - break; - } - } - let executable_path = which::which_in(executable, Some(join_paths(paths)?), cwd)?; - Ok(executable_path.into_os_string().into()) -} - -#[async_trait::async_trait(?Send)] -impl vite_task::TaskSynthesizer for TaskSynthesizer { - fn should_synthesize_for_program(&self, program: &str) -> bool { - program == "vite" - } - - async fn synthesize_task( - &mut self, - subcommand: CustomTaskSubcommand, - cwd: &Arc, - ) -> anyhow::Result { - match subcommand { - CustomTaskSubcommand::Lint { args } => { - let direct_execution_cache_key: Arc<[Str]> = - iter::once(Str::from("lint")).chain(args.iter().cloned()).collect(); - Ok(SyntheticPlanRequest { - program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, - args: args.into(), - task_options: Default::default(), - direct_execution_cache_key, - }) - } - } - } -} +use vite_task::{CLIArgs, Session, SessionCallbacks}; +use vite_task_bin::{CustomTaskSubcommand, NonTaskSubcommand, TaskSynthesizer}; #[tokio::main] async fn main() -> anyhow::Result<()> { diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -0,0 +1 @@ + diff --git a/crates/vite_task_plan/src/cache_metadata.rs b/crates/vite_task_plan/src/cache_metadata.rs index 0f712f57..a4739914 100644 --- a/crates/vite_task_plan/src/cache_metadata.rs +++ b/crates/vite_task_plan/src/cache_metadata.rs @@ -1,16 +1,11 @@ -use std::{ - collections::{BTreeMap, BTreeSet, HashMap}, - ffi::OsStr, - sync::Arc, -}; +use std::sync::Arc; use bincode::{Decode, Encode}; use serde::{Deserialize, Serialize}; use vite_path::RelativePathBuf; use vite_str::Str; -use vite_task_graph::config::CacheConfig; -use crate::{SpawnCommand, envs::EnvFingerprints}; +use crate::envs::EnvFingerprints; /// The kind of a key to identify an execution. #[derive(Debug, Encode, bincode::Decode, Serialize)] diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 84f3c95f..bd9afcfe 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -10,24 +10,18 @@ pub mod plan_request; use std::{collections::HashMap, ffi::OsStr, fmt::Debug, ops::Range, sync::Arc}; -use bincode::Encode; use context::PlanContext; -use envs::EnvFingerprints; use error::TaskPlanErrorKindResultExt; pub use error::{Error, TaskPlanErrorKind}; use execution_graph::ExecutionGraph; use in_process::InProcessExecution; use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; -use serde::Serialize; -use vite_path::{AbsolutePath, RelativePathBuf}; +use vite_path::AbsolutePath; use vite_str::Str; -use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, query::TaskQuery}; +use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex}; -use crate::{ - cache_metadata::{ExecutionCacheKey, ExecutionCacheKeyKind}, - path_env::prepend_path_env, -}; +use crate::path_env::prepend_path_env; /// A resolved spawn execution. /// Unlike tasks in `vite_task_graph`, this struct contains all information needed for execution, diff --git a/package.json b/package.json index fdfa8aa8..97c3c390 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "type": "module", "scripts": { "prepare": "husky", - "hello": "echo Hello, Vite Task Monorepo!" + "hello": "echo Hello, Vite Task Monorepo!", + "a": "vite foo" }, "devDependencies": { "husky": "catalog:", From 74d32982ef54e97b3d64466aa1d7248f7d2458a9 Mon Sep 17 00:00:00 2001 From: branchseer Date: Tue, 30 Dec 2025 23:20:48 +0800 Subject: [PATCH 09/27] move tests to vite_task_bin --- Cargo.lock | 32 +-- crates/vite_task/Cargo.toml | 7 - crates/vite_task/tests/snapshots.rs | 189 ------------------ ...itive@transitive-dependency-workspace.snap | 6 - crates/vite_task_bin/Cargo.toml | 11 + .../tests/fixtures/cache-sharing/package.json | 0 .../fixtures/cache-sharing/pnpm-lock.yaml | 0 .../cache-sharing/pnpm-workspace.yaml | 0 .../comprehensive-task-graph/package.json | 0 .../packages/api/package.json | 0 .../packages/app/package.json | 0 .../packages/config/package.json | 0 .../packages/pkg#special/package.json | 0 .../packages/shared/package.json | 0 .../packages/tools/package.json | 0 .../packages/ui/package.json | 0 .../pnpm-workspace.yaml | 0 .../tests/fixtures/conflict-test/package.json | 0 .../packages/scope-a-b/package.json | 0 .../packages/scope-a/package.json | 0 .../packages/test-package/package.json | 0 .../packages/test-package/vite.config.json | 0 .../conflict-test/pnpm-workspace.yaml | 0 .../package.json | 0 .../packages/a/package.json | 0 .../packages/a/vite.config.json | 0 .../packages/b/package.json | 0 .../pnpm-workspace.yaml | 0 .../fixtures/empty-package-test/package.json | 0 .../packages/another-empty/package.json | 0 .../packages/another-empty/vite.config.json | 0 .../packages/empty-name/package.json | 0 .../packages/empty-name/vite.config.json | 0 .../packages/normal-package/package.json | 0 .../packages/normal-package/vite.config.json | 0 .../empty-package-test/pnpm-workspace.yaml | 0 .../explicit-deps-workspace/package.json | 0 .../packages/app/package.json | 0 .../packages/app/vite.config.json | 0 .../packages/core/package.json | 0 .../packages/core/vite.config.json | 0 .../packages/utils/package.json | 0 .../packages/utils/vite.config.json | 0 .../pnpm-workspace.yaml | 0 .../fingerprint-ignore-test/README.md | 0 .../fingerprint-ignore-test/package.json | 0 .../fingerprint-ignore-test/vite.config.json | 0 .../apps/web/package.json | 0 .../package.json | 0 .../packages/app/package.json | 0 .../packages/core/package.json | 0 .../packages/utils/package.json | 0 .../pnpm-workspace.yaml | 0 .../cli-queries.toml | 0 .../packages/a/package.json | 0 .../packages/a/src/.gitkeep | 0 .../packages/a/vite.config.json | 0 .../packages/another-a/package.json | 0 .../packages/b1/package.json | 0 .../packages/b2/package.json | 0 .../packages/c/package.json | 0 .../pnpm-workspace.yaml | 0 crates/vite_task_bin/tests/snapshots.rs | 188 +++++++++++++++++ ... name@transitive-dependency-workspace.snap | 4 +- ...ckage@transitive-dependency-workspace.snap | 4 +- ...e cwd@transitive-dependency-workspace.snap | 4 +- ...ds on@transitive-dependency-workspace.snap | 4 +- ...itive@transitive-dependency-workspace.snap | 6 + ...rsive@transitive-dependency-workspace.snap | 4 +- ... name@transitive-dependency-workspace.snap | 4 +- ... task@transitive-dependency-workspace.snap | 4 +- ... task@transitive-dependency-workspace.snap | 4 +- ...itive@transitive-dependency-workspace.snap | 4 +- ...ckage@transitive-dependency-workspace.snap | 4 +- .../snapshots__task graph@cache-sharing.snap | 4 +- ...__task graph@comprehensive-task-graph.snap | 4 +- .../snapshots__task graph@conflict-test.snap | 4 +- ...aph@dependency-both-topo-and-explicit.snap | 4 +- ...pshots__task graph@empty-package-test.snap | 4 +- ...s__task graph@explicit-deps-workspace.snap | 4 +- ...s__task graph@fingerprint-ignore-test.snap | 4 +- ...graph@recursive-topological-workspace.snap | 4 +- ...graph@transitive-dependency-workspace.snap | 4 +- 83 files changed, 262 insertions(+), 253 deletions(-) delete mode 100644 crates/vite_task/tests/snapshots.rs delete mode 100644 crates/vite_task/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap rename crates/{vite_task => vite_task_bin}/tests/fixtures/cache-sharing/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/cache-sharing/pnpm-lock.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/cache-sharing/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/api/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/app/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/config/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/shared/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/tools/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/packages/ui/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/conflict-test/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/conflict-test/packages/scope-a-b/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/conflict-test/packages/scope-a/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/conflict-test/packages/test-package/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/conflict-test/packages/test-package/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/conflict-test/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/dependency-both-topo-and-explicit/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/packages/another-empty/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/packages/empty-name/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/packages/normal-package/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/empty-package-test/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/packages/app/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/packages/core/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/packages/utils/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/fingerprint-ignore-test/README.md (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/fingerprint-ignore-test/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/fingerprint-ignore-test/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/recursive-topological-workspace/apps/web/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/recursive-topological-workspace/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/recursive-topological-workspace/packages/app/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/recursive-topological-workspace/packages/core/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/recursive-topological-workspace/packages/utils/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/cli-queries.toml (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/a/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/packages/c/package.json (100%) rename crates/{vite_task => vite_task_bin}/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml (100%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap (72%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap (54%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap (54%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap (54%) create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap (87%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap (73%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap (73%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap (69%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap (86%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap (73%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@cache-sharing.snap (81%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap (98%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@conflict-test.snap (87%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap (79%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@empty-package-test.snap (96%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap (96%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap (75%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap (94%) rename crates/{vite_task => vite_task_bin}/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap (93%) diff --git a/Cargo.lock b/Cargo.lock index c3ec1a48..02fe3eef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1437,9 +1437,9 @@ checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" [[package]] name = "insta" -version = "1.44.3" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5c943d4415edd8153251b6f197de5eb1640e56d84e8d9159bea190421c73698" +checksum = "983e3b24350c84ab8a65151f537d67afbbf7153bb9f1110e03e9fa9b07f67a5c" dependencies = [ "console", "globset", @@ -1448,6 +1448,7 @@ dependencies = [ "pest_derive", "serde", "similar", + "tempfile", "walkdir", ] @@ -1995,9 +1996,9 @@ checksum = "132dca9b868d927b35b5dd728167b2dee150eb1ad686008fc71ccb298b776fca" [[package]] name = "pest" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" +checksum = "cbcfd20a6d4eeba40179f05735784ad32bdaef05ce8e8af05f180d45bb3e7e22" dependencies = [ "memchr", "ucd-trie", @@ -2005,9 +2006,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" +checksum = "51f72981ade67b1ca6adc26ec221be9f463f2b5839c7508998daa17c23d94d7f" dependencies = [ "pest", "pest_generator", @@ -2015,9 +2016,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" +checksum = "dee9efd8cdb50d719a80088b76f81aec7c41ed6d522ee750178f83883d271625" dependencies = [ "pest", "pest_meta", @@ -2028,9 +2029,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.3" +version = "2.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" +checksum = "bf1d70880e76bdc13ba52eafa6239ce793d85c8e43896507e43dd8984ff05b82" dependencies = [ "pest", "sha2", @@ -3231,14 +3232,12 @@ dependencies = [ "bstr", "clap", "compact_str 0.9.0", - "copy_dir", "dashmap", "derive_more", "diff-struct", "fspy", "futures-core", "futures-util", - "insta", "itertools 0.14.0", "nix 0.30.1", "owo-colors", @@ -3254,7 +3253,6 @@ dependencies = [ "thiserror 2.0.17", "tokio", "tokio-stream", - "toml", "tracing", "twox-hash", "uuid", @@ -3275,10 +3273,18 @@ dependencies = [ "anyhow", "async-trait", "clap", + "copy_dir", + "insta", + "petgraph", + "serde", + "tempfile", "tokio", + "toml", "vite_path", "vite_str", "vite_task", + "vite_task_graph", + "vite_workspace", "which", ] diff --git a/crates/vite_task/Cargo.toml b/crates/vite_task/Cargo.toml index be70ec5f..501965ea 100644 --- a/crates/vite_task/Cargo.toml +++ b/crates/vite_task/Cargo.toml @@ -52,10 +52,3 @@ wax = { workspace = true } [target.'cfg(unix)'.dependencies] nix = { workspace = true } - -[dev-dependencies] -copy_dir = { workspace = true } -insta = { workspace = true, features = ["glob", "json", "redactions"] } -tempfile = { workspace = true } -toml = { workspace = true } -vite_path = { workspace = true, features = ["absolute-redaction"] } diff --git a/crates/vite_task/tests/snapshots.rs b/crates/vite_task/tests/snapshots.rs deleted file mode 100644 index e003ca7d..00000000 --- a/crates/vite_task/tests/snapshots.rs +++ /dev/null @@ -1,189 +0,0 @@ -use core::panic; -use std::{path::Path, sync::Arc}; - -use clap::Parser; -use copy_dir::copy_dir; -use petgraph::visit::EdgeRef as _; -use tokio::runtime::Runtime; -use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; -use vite_str::Str; -use vite_task_graph::{ - IndexedTaskGraph, TaskDependencyType, TaskNodeIndex, - loader::JsonUserConfigLoader, - query::{TaskExecutionGraph, cli::CLITaskQuery}, -}; -use vite_workspace::find_workspace_root; - -#[derive(serde::Serialize, PartialEq, PartialOrd, Eq, Ord)] -struct TaskIdSnapshot { - package_dir: Arc, - task_name: Str, -} -impl TaskIdSnapshot { - fn new(task_index: TaskNodeIndex, indexed_task_graph: &IndexedTaskGraph) -> Self { - let task_id = &indexed_task_graph.task_graph()[task_index].task_id; - Self { - task_name: task_id.task_name.clone(), - package_dir: Arc::clone(&indexed_task_graph.get_package_path(task_id.package_index)), - } - } -} - -/// Create a stable json representation of the task graph for snapshot testing. -/// -/// All paths are relative to `base_dir`. -fn snapshot_task_graph(indexed_task_graph: &IndexedTaskGraph) -> impl serde::Serialize { - #[derive(serde::Serialize)] - struct TaskNodeSnapshot { - id: TaskIdSnapshot, - command: Str, - cwd: Arc, - depends_on: Vec<(TaskIdSnapshot, TaskDependencyType)>, - } - - let task_graph = indexed_task_graph.task_graph(); - let mut node_snapshots = Vec::::with_capacity(task_graph.node_count()); - for task_index in task_graph.node_indices() { - let task_node = &task_graph[task_index]; - let mut depends_on: Vec<(TaskIdSnapshot, TaskDependencyType)> = task_graph - .edges_directed(task_index, petgraph::Direction::Outgoing) - .map(|edge| (TaskIdSnapshot::new(edge.target(), indexed_task_graph), *edge.weight())) - .collect(); - depends_on.sort_unstable_by(|a, b| a.0.cmp(&b.0)); - node_snapshots.push(TaskNodeSnapshot { - id: TaskIdSnapshot::new(task_index, indexed_task_graph), - command: task_node.resolved_config.command.clone(), - cwd: Arc::clone(&task_node.resolved_config.resolved_options.cwd), - depends_on, - }); - } - node_snapshots.sort_unstable_by(|a, b| a.id.cmp(&b.id)); - - node_snapshots -} - -/// Create a stable json representation of the task graph for snapshot testing. -/// -/// All paths are relative to `base_dir`. -fn snapshot_execution_graph( - execution_graph: &TaskExecutionGraph, - indexed_task_graph: &IndexedTaskGraph, -) -> impl serde::Serialize { - #[derive(serde::Serialize, PartialEq)] - struct ExecutionNodeSnapshot { - task: TaskIdSnapshot, - deps: Vec, - } - - let mut execution_node_snapshots = Vec::::new(); - for task_index in execution_graph.nodes() { - let mut deps = execution_graph - .neighbors(task_index) - .map(|dep_index| TaskIdSnapshot::new(dep_index, indexed_task_graph)) - .collect::>(); - deps.sort_unstable(); - - execution_node_snapshots.push(ExecutionNodeSnapshot { - task: TaskIdSnapshot::new(task_index, indexed_task_graph), - deps, - }); - } - execution_node_snapshots.sort_unstable_by(|a, b| a.task.cmp(&b.task)); - execution_node_snapshots -} - -#[derive(serde::Deserialize)] -struct CLIQuery { - pub name: Str, - pub args: Vec, - pub cwd: RelativePathBuf, -} - -#[derive(serde::Deserialize, Default)] -struct CLIQueriesFile { - #[serde(rename = "query")] // toml usually uses singular for arrays - pub queries: Vec, -} - -fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, case_path: &Path) { - let case_name = case_path.file_name().unwrap().to_str().unwrap(); - if case_name.starts_with(".") { - return; // skip hidden files like .DS_Store - } - - // Copy the case directory to a temporary directory to avoid discovering workspace outside of the test case. - let case_stage_path = tmpdir.join(case_name); - copy_dir(case_path, &case_stage_path).unwrap(); - - let (workspace_root, _cwd) = find_workspace_root(&case_stage_path).unwrap(); - - assert_eq!( - &case_stage_path, &*workspace_root.path, - "folder '{}' should be a workspace root", - case_name - ); - - let cli_queries_toml_path = case_path.join("cli-queries.toml"); - let cli_queries_file: CLIQueriesFile = match std::fs::read(&cli_queries_toml_path) { - Ok(content) => toml::from_slice(&content).unwrap(), - Err(err) if err.kind() == std::io::ErrorKind::NotFound => Default::default(), - Err(err) => panic!("Failed to read cli-queries.toml for case {}: {}", case_name, err), - }; - - runtime.block_on(async { - let _redaction_guard = redact_absolute_paths(&workspace_root.path); - - let indexed_task_graph = vite_task_graph::IndexedTaskGraph::load( - &workspace_root, - &JsonUserConfigLoader::default(), - ) - .await - .expect(&format!("Failed to load task graph for case {case_name}")); - - let task_graph_snapshot = snapshot_task_graph(&indexed_task_graph); - insta::assert_json_snapshot!("task graph", task_graph_snapshot); - - for cli_query in cli_queries_file.queries { - let snapshot_name = format!("query - {}", cli_query.name); - - let cli_task_query = CLITaskQuery::try_parse_from( - std::iter::once("vite-run") // dummy program name - .chain(cli_query.args.iter().map(|s| s.as_str())), - ) - .expect(&format!( - "Failed to parse CLI args for query '{}' in case '{}'", - cli_query.name, case_name - )); - - let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); - let task_query = match cli_task_query.into_task_query(&cwd) { - Ok(ok) => ok, - Err(err) => { - insta::assert_json_snapshot!(snapshot_name, err); - continue; - } - }; - - let execution_graph = match indexed_task_graph.query_tasks(task_query) { - Ok(ok) => ok, - Err(err) => { - insta::assert_json_snapshot!(snapshot_name, err); - continue; - } - }; - - let execution_graph_snapshot = - snapshot_execution_graph(&execution_graph, &indexed_task_graph); - insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); - } - }); -} - -#[test] -fn test_snapshots() { - let tokio_runtime = Runtime::new().unwrap(); - let tmp_dir = tempfile::tempdir().unwrap(); - let tmp_dir_path = AbsolutePath::new(tmp_dir.path()).unwrap(); - - insta::glob!("fixtures/*", |case_path| run_case(&tokio_runtime, tmp_dir_path, case_path)); -} diff --git a/crates/vite_task/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap b/crates/vite_task/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap deleted file mode 100644 index c267178d..00000000 --- a/crates/vite_task/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: crates/vite_task/tests/snapshots.rs -expression: err -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace ---- -"RecursiveTransitiveConflict" diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index 9b311305..a176d044 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -20,5 +20,16 @@ vite_str = { workspace = true } vite_task = { workspace = true } which = { workspace = true } +[dev-dependencies] +copy_dir = { workspace = true } +insta = { workspace = true, features = ["glob", "json", "redactions"] } +petgraph = { workspace = true } +serde = { workspace = true, features = ["derive", "rc"] } +tempfile = { workspace = true } +toml = { workspace = true } +vite_path = { workspace = true, features = ["absolute-redaction"] } +vite_task_graph = { workspace = true } +vite_workspace = { workspace = true } + [lints] workspace = true diff --git a/crates/vite_task/tests/fixtures/cache-sharing/package.json b/crates/vite_task_bin/tests/fixtures/cache-sharing/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/cache-sharing/package.json rename to crates/vite_task_bin/tests/fixtures/cache-sharing/package.json diff --git a/crates/vite_task/tests/fixtures/cache-sharing/pnpm-lock.yaml b/crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-lock.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/cache-sharing/pnpm-lock.yaml rename to crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-lock.yaml diff --git a/crates/vite_task/tests/fixtures/cache-sharing/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/cache-sharing/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/api/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/api/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/api/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/api/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/app/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/app/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/app/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/app/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/config/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/config/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/config/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/config/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/shared/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/shared/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/shared/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/shared/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/tools/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/tools/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/tools/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/tools/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/ui/package.json b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/ui/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/packages/ui/package.json rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/ui/package.json diff --git a/crates/vite_task/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/conflict-test/package.json b/crates/vite_task_bin/tests/fixtures/conflict-test/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/conflict-test/package.json rename to crates/vite_task_bin/tests/fixtures/conflict-test/package.json diff --git a/crates/vite_task/tests/fixtures/conflict-test/packages/scope-a-b/package.json b/crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a-b/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/conflict-test/packages/scope-a-b/package.json rename to crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a-b/package.json diff --git a/crates/vite_task/tests/fixtures/conflict-test/packages/scope-a/package.json b/crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/conflict-test/packages/scope-a/package.json rename to crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a/package.json diff --git a/crates/vite_task/tests/fixtures/conflict-test/packages/test-package/package.json b/crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/conflict-test/packages/test-package/package.json rename to crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/package.json diff --git a/crates/vite_task/tests/fixtures/conflict-test/packages/test-package/vite.config.json b/crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/conflict-test/packages/test-package/vite.config.json rename to crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/vite.config.json diff --git a/crates/vite_task/tests/fixtures/conflict-test/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/conflict-test/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/conflict-test/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/conflict-test/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/package.json b/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/package.json rename to crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/package.json diff --git a/crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json b/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json rename to crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json diff --git a/crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json b/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json rename to crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json diff --git a/crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json b/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json rename to crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json diff --git a/crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/empty-package-test/package.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/package.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/package.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/packages/another-empty/package.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/packages/another-empty/package.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/package.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/packages/empty-name/package.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/packages/empty-name/package.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/package.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/packages/normal-package/package.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/packages/normal-package/package.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/package.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json b/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json rename to crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json diff --git a/crates/vite_task/tests/fixtures/empty-package-test/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/empty-package-test/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/empty-package-test/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/empty-package-test/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/package.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/package.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/package.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/app/package.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/app/package.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/package.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/core/package.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/core/package.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/package.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/utils/package.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/utils/package.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/package.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json diff --git a/crates/vite_task/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/fingerprint-ignore-test/README.md b/crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/README.md similarity index 100% rename from crates/vite_task/tests/fixtures/fingerprint-ignore-test/README.md rename to crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/README.md diff --git a/crates/vite_task/tests/fixtures/fingerprint-ignore-test/package.json b/crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/fingerprint-ignore-test/package.json rename to crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/package.json diff --git a/crates/vite_task/tests/fixtures/fingerprint-ignore-test/vite.config.json b/crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/fingerprint-ignore-test/vite.config.json rename to crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/vite.config.json diff --git a/crates/vite_task/tests/fixtures/recursive-topological-workspace/apps/web/package.json b/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/apps/web/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/recursive-topological-workspace/apps/web/package.json rename to crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/apps/web/package.json diff --git a/crates/vite_task/tests/fixtures/recursive-topological-workspace/package.json b/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/recursive-topological-workspace/package.json rename to crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/package.json diff --git a/crates/vite_task/tests/fixtures/recursive-topological-workspace/packages/app/package.json b/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/app/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/recursive-topological-workspace/packages/app/package.json rename to crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/app/package.json diff --git a/crates/vite_task/tests/fixtures/recursive-topological-workspace/packages/core/package.json b/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/core/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/recursive-topological-workspace/packages/core/package.json rename to crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/core/package.json diff --git a/crates/vite_task/tests/fixtures/recursive-topological-workspace/packages/utils/package.json b/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/utils/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/recursive-topological-workspace/packages/utils/package.json rename to crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/utils/package.json diff --git a/crates/vite_task/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/cli-queries.toml b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/cli-queries.toml similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/cli-queries.toml rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/cli-queries.toml diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/a/package.json b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/a/package.json rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/package.json diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/c/package.json b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/c/package.json similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/packages/c/package.json rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/c/package.json diff --git a/crates/vite_task/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index 8b137891..e003ca7d 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -1 +1,189 @@ +use core::panic; +use std::{path::Path, sync::Arc}; +use clap::Parser; +use copy_dir::copy_dir; +use petgraph::visit::EdgeRef as _; +use tokio::runtime::Runtime; +use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; +use vite_str::Str; +use vite_task_graph::{ + IndexedTaskGraph, TaskDependencyType, TaskNodeIndex, + loader::JsonUserConfigLoader, + query::{TaskExecutionGraph, cli::CLITaskQuery}, +}; +use vite_workspace::find_workspace_root; + +#[derive(serde::Serialize, PartialEq, PartialOrd, Eq, Ord)] +struct TaskIdSnapshot { + package_dir: Arc, + task_name: Str, +} +impl TaskIdSnapshot { + fn new(task_index: TaskNodeIndex, indexed_task_graph: &IndexedTaskGraph) -> Self { + let task_id = &indexed_task_graph.task_graph()[task_index].task_id; + Self { + task_name: task_id.task_name.clone(), + package_dir: Arc::clone(&indexed_task_graph.get_package_path(task_id.package_index)), + } + } +} + +/// Create a stable json representation of the task graph for snapshot testing. +/// +/// All paths are relative to `base_dir`. +fn snapshot_task_graph(indexed_task_graph: &IndexedTaskGraph) -> impl serde::Serialize { + #[derive(serde::Serialize)] + struct TaskNodeSnapshot { + id: TaskIdSnapshot, + command: Str, + cwd: Arc, + depends_on: Vec<(TaskIdSnapshot, TaskDependencyType)>, + } + + let task_graph = indexed_task_graph.task_graph(); + let mut node_snapshots = Vec::::with_capacity(task_graph.node_count()); + for task_index in task_graph.node_indices() { + let task_node = &task_graph[task_index]; + let mut depends_on: Vec<(TaskIdSnapshot, TaskDependencyType)> = task_graph + .edges_directed(task_index, petgraph::Direction::Outgoing) + .map(|edge| (TaskIdSnapshot::new(edge.target(), indexed_task_graph), *edge.weight())) + .collect(); + depends_on.sort_unstable_by(|a, b| a.0.cmp(&b.0)); + node_snapshots.push(TaskNodeSnapshot { + id: TaskIdSnapshot::new(task_index, indexed_task_graph), + command: task_node.resolved_config.command.clone(), + cwd: Arc::clone(&task_node.resolved_config.resolved_options.cwd), + depends_on, + }); + } + node_snapshots.sort_unstable_by(|a, b| a.id.cmp(&b.id)); + + node_snapshots +} + +/// Create a stable json representation of the task graph for snapshot testing. +/// +/// All paths are relative to `base_dir`. +fn snapshot_execution_graph( + execution_graph: &TaskExecutionGraph, + indexed_task_graph: &IndexedTaskGraph, +) -> impl serde::Serialize { + #[derive(serde::Serialize, PartialEq)] + struct ExecutionNodeSnapshot { + task: TaskIdSnapshot, + deps: Vec, + } + + let mut execution_node_snapshots = Vec::::new(); + for task_index in execution_graph.nodes() { + let mut deps = execution_graph + .neighbors(task_index) + .map(|dep_index| TaskIdSnapshot::new(dep_index, indexed_task_graph)) + .collect::>(); + deps.sort_unstable(); + + execution_node_snapshots.push(ExecutionNodeSnapshot { + task: TaskIdSnapshot::new(task_index, indexed_task_graph), + deps, + }); + } + execution_node_snapshots.sort_unstable_by(|a, b| a.task.cmp(&b.task)); + execution_node_snapshots +} + +#[derive(serde::Deserialize)] +struct CLIQuery { + pub name: Str, + pub args: Vec, + pub cwd: RelativePathBuf, +} + +#[derive(serde::Deserialize, Default)] +struct CLIQueriesFile { + #[serde(rename = "query")] // toml usually uses singular for arrays + pub queries: Vec, +} + +fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, case_path: &Path) { + let case_name = case_path.file_name().unwrap().to_str().unwrap(); + if case_name.starts_with(".") { + return; // skip hidden files like .DS_Store + } + + // Copy the case directory to a temporary directory to avoid discovering workspace outside of the test case. + let case_stage_path = tmpdir.join(case_name); + copy_dir(case_path, &case_stage_path).unwrap(); + + let (workspace_root, _cwd) = find_workspace_root(&case_stage_path).unwrap(); + + assert_eq!( + &case_stage_path, &*workspace_root.path, + "folder '{}' should be a workspace root", + case_name + ); + + let cli_queries_toml_path = case_path.join("cli-queries.toml"); + let cli_queries_file: CLIQueriesFile = match std::fs::read(&cli_queries_toml_path) { + Ok(content) => toml::from_slice(&content).unwrap(), + Err(err) if err.kind() == std::io::ErrorKind::NotFound => Default::default(), + Err(err) => panic!("Failed to read cli-queries.toml for case {}: {}", case_name, err), + }; + + runtime.block_on(async { + let _redaction_guard = redact_absolute_paths(&workspace_root.path); + + let indexed_task_graph = vite_task_graph::IndexedTaskGraph::load( + &workspace_root, + &JsonUserConfigLoader::default(), + ) + .await + .expect(&format!("Failed to load task graph for case {case_name}")); + + let task_graph_snapshot = snapshot_task_graph(&indexed_task_graph); + insta::assert_json_snapshot!("task graph", task_graph_snapshot); + + for cli_query in cli_queries_file.queries { + let snapshot_name = format!("query - {}", cli_query.name); + + let cli_task_query = CLITaskQuery::try_parse_from( + std::iter::once("vite-run") // dummy program name + .chain(cli_query.args.iter().map(|s| s.as_str())), + ) + .expect(&format!( + "Failed to parse CLI args for query '{}' in case '{}'", + cli_query.name, case_name + )); + + let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); + let task_query = match cli_task_query.into_task_query(&cwd) { + Ok(ok) => ok, + Err(err) => { + insta::assert_json_snapshot!(snapshot_name, err); + continue; + } + }; + + let execution_graph = match indexed_task_graph.query_tasks(task_query) { + Ok(ok) => ok, + Err(err) => { + insta::assert_json_snapshot!(snapshot_name, err); + continue; + } + }; + + let execution_graph_snapshot = + snapshot_execution_graph(&execution_graph, &indexed_task_graph); + insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); + } + }); +} + +#[test] +fn test_snapshots() { + let tokio_runtime = Runtime::new().unwrap(); + let tmp_dir = tempfile::tempdir().unwrap(); + let tmp_dir_path = AbsolutePath::new(tmp_dir.path()).unwrap(); + + insta::glob!("fixtures/*", |case_path| run_case(&tokio_runtime, tmp_dir_path, case_path)); +} diff --git a/crates/vite_task/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap similarity index 72% rename from crates/vite_task/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap index eafd86a2..dde1ad09 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: err -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- { "SpecifierLookupError": { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap similarity index 54% rename from crates/vite_task/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap index 3ff92394..e59b2f16 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap similarity index 54% rename from crates/vite_task/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap index 3ff92394..e59b2f16 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap similarity index 54% rename from crates/vite_task/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap index 5a65e8f5..9f2b6f1f 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap new file mode 100644 index 00000000..18b0f3a3 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap @@ -0,0 +1,6 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: err +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace +--- +"RecursiveTransitiveConflict" diff --git a/crates/vite_task/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap similarity index 87% rename from crates/vite_task/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap index fdc5c1a5..c90e57e8 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap similarity index 73% rename from crates/vite_task/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap index 41fc332c..af5c0b4a 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap similarity index 73% rename from crates/vite_task/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap index 95c858b1..e7ca94fe 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap similarity index 69% rename from crates/vite_task/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap index 3e61cf81..e269c0a5 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: err -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- { "SpecifierLookupError": { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap similarity index 86% rename from crates/vite_task/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap index 826bebad..a1c193e8 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap similarity index 73% rename from crates/vite_task/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap index 41fc332c..af5c0b4a 100644 --- a/crates/vite_task/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: execution_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@cache-sharing.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap similarity index 81% rename from crates/vite_task/tests/snapshots/snapshots__task graph@cache-sharing.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap index 2f23f391..86fabe02 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@cache-sharing.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/cache-sharing +input_file: crates/vite_task_bin/tests/fixtures/cache-sharing --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap similarity index 98% rename from crates/vite_task/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap index d0e44840..7a8593db 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/comprehensive-task-graph +input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@conflict-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap similarity index 87% rename from crates/vite_task/tests/snapshots/snapshots__task graph@conflict-test.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap index 80e5603f..090d0b44 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@conflict-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/conflict-test +input_file: crates/vite_task_bin/tests/fixtures/conflict-test --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap similarity index 79% rename from crates/vite_task/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap index b609a8d2..b655131b 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/dependency-both-topo-and-explicit +input_file: crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@empty-package-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap similarity index 96% rename from crates/vite_task/tests/snapshots/snapshots__task graph@empty-package-test.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap index 5508e88e..c375c8c1 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@empty-package-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/empty-package-test +input_file: crates/vite_task_bin/tests/fixtures/empty-package-test --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap similarity index 96% rename from crates/vite_task/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap index f2e12dd0..afa635c4 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/explicit-deps-workspace +input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap similarity index 75% rename from crates/vite_task/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap index 67c9f908..7781df6e 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/fingerprint-ignore-test +input_file: crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap similarity index 94% rename from crates/vite_task/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap index fef43080..5f2cc399 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/recursive-topological-workspace +input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace --- [ { diff --git a/crates/vite_task/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap similarity index 93% rename from crates/vite_task/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap index 98b23222..684caa80 100644 --- a/crates/vite_task/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task/tests/snapshots.rs +source: crates/vite_task_bin/tests/snapshots.rs expression: task_graph_snapshot -input_file: crates/vite_task/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- [ { From 7d799eb64eabb0c3a34a3ce52c512bafa3de3073 Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 31 Dec 2025 16:03:22 +0800 Subject: [PATCH 10/27] add prefix to refacted paths --- crates/vite_path/src/absolute/mod.rs | 5 +- ... name@transitive-dependency-workspace.snap | 4 +- ...ckage@transitive-dependency-workspace.snap | 2 +- ...e cwd@transitive-dependency-workspace.snap | 2 +- ...ds on@transitive-dependency-workspace.snap | 2 +- ...rsive@transitive-dependency-workspace.snap | 18 +-- ... name@transitive-dependency-workspace.snap | 6 +- ... task@transitive-dependency-workspace.snap | 6 +- ...itive@transitive-dependency-workspace.snap | 16 +-- ...ckage@transitive-dependency-workspace.snap | 6 +- .../snapshots__task graph@cache-sharing.snap | 12 +- ...__task graph@comprehensive-task-graph.snap | 128 +++++++++--------- .../snapshots__task graph@conflict-test.snap | 14 +- ...aph@dependency-both-topo-and-explicit.snap | 10 +- ...pshots__task graph@empty-package-test.snap | 50 +++---- ...s__task graph@explicit-deps-workspace.snap | 66 ++++----- ...s__task graph@fingerprint-ignore-test.snap | 4 +- ...graph@recursive-topological-workspace.snap | 44 +++--- ...graph@transitive-dependency-workspace.snap | 38 +++--- 19 files changed, 218 insertions(+), 215 deletions(-) diff --git a/crates/vite_path/src/absolute/mod.rs b/crates/vite_path/src/absolute/mod.rs index 928327cc..6458fd1b 100644 --- a/crates/vite_path/src/absolute/mod.rs +++ b/crates/vite_path/src/absolute/mod.rs @@ -38,7 +38,10 @@ impl Serialize for AbsolutePath { .with(|redaction_prefix| redaction_prefix.borrow().as_ref().map(Arc::clone)) { match self.strip_prefix(redaction_prefix) { - Ok(Some(stripped_path)) => return stripped_path.serialize(serializer), + Ok(Some(stripped_path)) => { + return serializer + .collect_str(&format_args!("/{}", stripped_path.as_str())); + } Err(strip_error) => { return Err(serde::ser::Error::custom(format!( "Failed to redact absolute path '{}': {}", diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap index dde1ad09..6619d365 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap @@ -13,8 +13,8 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace "AmbiguousPackageName": { "package_name": "@test/a", "package_paths": [ - "packages/a", - "packages/another-a" + "/packages/a", + "/packages/another-a" ] } } diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap index e59b2f16..4077dfa7 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap @@ -6,7 +6,7 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap index e59b2f16..4077dfa7 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap @@ -6,7 +6,7 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap index 9f2b6f1f..5a93d142 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap @@ -6,7 +6,7 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap index c90e57e8..0b2fcd86 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap @@ -6,53 +6,53 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "deps": [ { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, { - "package_dir": "packages/b2", + "package_dir": "/packages/b2", "task_name": "build" }, { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" } ] }, { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, "deps": [] }, { "task": { - "package_dir": "packages/another-a", + "package_dir": "/packages/another-a", "task_name": "build" }, "deps": [] }, { "task": { - "package_dir": "packages/b2", + "package_dir": "/packages/b2", "task_name": "build" }, "deps": [ { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" } ] }, { "task": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap index af5c0b4a..eafdcb21 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap @@ -6,19 +6,19 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "deps": [ { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" } ] }, { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap index e7ca94fe..9b176a9c 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap @@ -6,19 +6,19 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/b1", + "package_dir": "/packages/b1", "task_name": "lint" }, "deps": [ { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "lint" } ] }, { "task": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "lint" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap index a1c193e8..0baeb31b 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap @@ -6,46 +6,46 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "deps": [ { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, { - "package_dir": "packages/b2", + "package_dir": "/packages/b2", "task_name": "build" }, { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" } ] }, { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, "deps": [] }, { "task": { - "package_dir": "packages/b2", + "package_dir": "/packages/b2", "task_name": "build" }, "deps": [ { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" } ] }, { "task": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap index af5c0b4a..eafdcb21 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap @@ -6,19 +6,19 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "deps": [ { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" } ] }, { "task": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, "deps": [] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap index 86fabe02..5a9d46d5 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap @@ -6,29 +6,29 @@ input_file: crates/vite_task_bin/tests/fixtures/cache-sharing [ { "id": { - "package_dir": "", + "package_dir": "/", "task_name": "a" }, "command": "echo a", - "cwd": "", + "cwd": "/", "depends_on": [] }, { "id": { - "package_dir": "", + "package_dir": "/", "task_name": "b" }, "command": "echo a && echo b", - "cwd": "", + "cwd": "/", "depends_on": [] }, { "id": { - "package_dir": "", + "package_dir": "/", "task_name": "c" }, "command": "echo a && echo b && echo c", - "cwd": "", + "cwd": "/", "depends_on": [] } ] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap index 7a8593db..d42087b6 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap @@ -6,22 +6,22 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph [ { "id": { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "build" }, "command": "echo Generate schemas && echo Compile TypeScript && echo Bundle API && echo Copy assets", - "cwd": "packages/api", + "cwd": "/packages/api", "depends_on": [ [ { - "package_dir": "packages/config", + "package_dir": "/packages/config", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "build" }, "Topological" @@ -30,33 +30,33 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "dev" }, "command": "echo Watch mode && echo Start dev server", - "cwd": "packages/api", + "cwd": "/packages/api", "depends_on": [] }, { "id": { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "start" }, "command": "echo Starting API server", - "cwd": "packages/api", + "cwd": "/packages/api", "depends_on": [] }, { "id": { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "test" }, "command": "echo Testing API", - "cwd": "packages/api", + "cwd": "/packages/api", "depends_on": [ [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "test" }, "Topological" @@ -65,36 +65,36 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "build" }, "command": "echo Clean dist && echo Build client && echo Build server && echo Generate manifest && echo Optimize assets", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/pkg#special", + "package_dir": "/packages/pkg#special", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/ui", + "package_dir": "/packages/ui", "task_name": "build" }, "Topological" @@ -103,24 +103,24 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "deploy" }, "command": "echo Validate && echo Upload && echo Verify", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [] }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "dev" }, "command": "echo Running dev server", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "dev" }, "Topological" @@ -129,45 +129,45 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "preview" }, "command": "echo Preview build", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [] }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "test" }, "command": "echo Unit tests && echo Integration tests", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/api", + "package_dir": "/packages/api", "task_name": "test" }, "Topological" ], [ { - "package_dir": "packages/pkg#special", + "package_dir": "/packages/pkg#special", "task_name": "test" }, "Topological" ], [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "test" }, "Topological" ], [ { - "package_dir": "packages/ui", + "package_dir": "/packages/ui", "task_name": "test" }, "Topological" @@ -176,33 +176,33 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/config", + "package_dir": "/packages/config", "task_name": "build" }, "command": "echo Building config", - "cwd": "packages/config", + "cwd": "/packages/config", "depends_on": [] }, { "id": { - "package_dir": "packages/config", + "package_dir": "/packages/config", "task_name": "validate" }, "command": "echo Validating config", - "cwd": "packages/config", + "cwd": "/packages/config", "depends_on": [] }, { "id": { - "package_dir": "packages/pkg#special", + "package_dir": "/packages/pkg#special", "task_name": "build" }, "command": "echo Building package with hash", - "cwd": "packages/pkg#special", + "cwd": "/packages/pkg#special", "depends_on": [ [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "build" }, "Topological" @@ -211,15 +211,15 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/pkg#special", + "package_dir": "/packages/pkg#special", "task_name": "test" }, "command": "echo Testing package with hash", - "cwd": "packages/pkg#special", + "cwd": "/packages/pkg#special", "depends_on": [ [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "test" }, "Topological" @@ -228,60 +228,60 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "build" }, "command": "echo Cleaning && echo Compiling shared && echo Generating types", - "cwd": "packages/shared", + "cwd": "/packages/shared", "depends_on": [] }, { "id": { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "lint" }, "command": "echo Linting shared", - "cwd": "packages/shared", + "cwd": "/packages/shared", "depends_on": [] }, { "id": { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "test" }, "command": "echo Setting up test env && echo Running tests && echo Cleanup", - "cwd": "packages/shared", + "cwd": "/packages/shared", "depends_on": [] }, { "id": { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "typecheck" }, "command": "echo Type checking shared", - "cwd": "packages/shared", + "cwd": "/packages/shared", "depends_on": [] }, { "id": { - "package_dir": "packages/tools", + "package_dir": "/packages/tools", "task_name": "generate" }, "command": "echo Generating tools", - "cwd": "packages/tools", + "cwd": "/packages/tools", "depends_on": [] }, { "id": { - "package_dir": "packages/tools", + "package_dir": "/packages/tools", "task_name": "validate" }, "command": "echo Validating", - "cwd": "packages/tools", + "cwd": "/packages/tools", "depends_on": [ [ { - "package_dir": "packages/config", + "package_dir": "/packages/config", "task_name": "validate" }, "Topological" @@ -290,15 +290,15 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/ui", + "package_dir": "/packages/ui", "task_name": "build" }, "command": "echo Compile styles && echo Build components && echo Generate types", - "cwd": "packages/ui", + "cwd": "/packages/ui", "depends_on": [ [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "build" }, "Topological" @@ -307,15 +307,15 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/ui", + "package_dir": "/packages/ui", "task_name": "lint" }, "command": "echo Linting UI", - "cwd": "packages/ui", + "cwd": "/packages/ui", "depends_on": [ [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "lint" }, "Topological" @@ -324,24 +324,24 @@ input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph }, { "id": { - "package_dir": "packages/ui", + "package_dir": "/packages/ui", "task_name": "storybook" }, "command": "echo Running storybook", - "cwd": "packages/ui", + "cwd": "/packages/ui", "depends_on": [] }, { "id": { - "package_dir": "packages/ui", + "package_dir": "/packages/ui", "task_name": "test" }, "command": "echo Testing UI", - "cwd": "packages/ui", + "cwd": "/packages/ui", "depends_on": [ [ { - "package_dir": "packages/shared", + "package_dir": "/packages/shared", "task_name": "test" }, "Topological" diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap index 090d0b44..5ea05c74 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap @@ -6,33 +6,33 @@ input_file: crates/vite_task_bin/tests/fixtures/conflict-test [ { "id": { - "package_dir": "packages/scope-a", + "package_dir": "/packages/scope-a", "task_name": "b#c" }, "command": "echo Task b#c in scope-a", - "cwd": "packages/scope-a", + "cwd": "/packages/scope-a", "depends_on": [] }, { "id": { - "package_dir": "packages/scope-a-b", + "package_dir": "/packages/scope-a-b", "task_name": "c" }, "command": "echo Task c in scope-a#b", - "cwd": "packages/scope-a-b", + "cwd": "/packages/scope-a-b", "depends_on": [] }, { "id": { - "package_dir": "packages/test-package", + "package_dir": "/packages/test-package", "task_name": "test" }, "command": "echo Testing", - "cwd": "packages/test-package", + "cwd": "/packages/test-package", "depends_on": [ [ { - "package_dir": "packages/scope-a-b", + "package_dir": "/packages/scope-a-b", "task_name": "c" }, "Explicit" diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap index b655131b..299930c8 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap @@ -6,15 +6,15 @@ input_file: crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explici [ { "id": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "command": "build a", - "cwd": "packages/a", + "cwd": "/packages/a", "depends_on": [ [ { - "package_dir": "packages/b", + "package_dir": "/packages/b", "task_name": "build" }, "Both" @@ -23,11 +23,11 @@ input_file: crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explici }, { "id": { - "package_dir": "packages/b", + "package_dir": "/packages/b", "task_name": "build" }, "command": "build b", - "cwd": "packages/b", + "cwd": "/packages/b", "depends_on": [] } ] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap index c375c8c1..3e4c3367 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap @@ -6,29 +6,29 @@ input_file: crates/vite_task_bin/tests/fixtures/empty-package-test [ { "id": { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "build" }, "command": "echo 'Building another-empty package'", - "cwd": "packages/another-empty", + "cwd": "/packages/another-empty", "depends_on": [ [ { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "lint" }, "Explicit" ], [ { - "package_dir": "packages/normal-package", + "package_dir": "/packages/normal-package", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/normal-package", + "package_dir": "/packages/normal-package", "task_name": "test" }, "Explicit" @@ -37,22 +37,22 @@ input_file: crates/vite_task_bin/tests/fixtures/empty-package-test }, { "id": { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "deploy" }, "command": "echo 'Deploying another-empty package'", - "cwd": "packages/another-empty", + "cwd": "/packages/another-empty", "depends_on": [ [ { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "build" }, "Explicit" ], [ { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "test" }, "Explicit" @@ -61,24 +61,24 @@ input_file: crates/vite_task_bin/tests/fixtures/empty-package-test }, { "id": { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "lint" }, "command": "echo 'Linting another-empty package'", - "cwd": "packages/another-empty", + "cwd": "/packages/another-empty", "depends_on": [] }, { "id": { - "package_dir": "packages/another-empty", + "package_dir": "/packages/another-empty", "task_name": "test" }, "command": "echo 'Testing another-empty package'", - "cwd": "packages/another-empty", + "cwd": "/packages/another-empty", "depends_on": [ [ { - "package_dir": "packages/normal-package", + "package_dir": "/packages/normal-package", "task_name": "test" }, "Topological" @@ -87,15 +87,15 @@ input_file: crates/vite_task_bin/tests/fixtures/empty-package-test }, { "id": { - "package_dir": "packages/empty-name", + "package_dir": "/packages/empty-name", "task_name": "build" }, "command": "echo 'Building empty-name package'", - "cwd": "packages/empty-name", + "cwd": "/packages/empty-name", "depends_on": [ [ { - "package_dir": "packages/empty-name", + "package_dir": "/packages/empty-name", "task_name": "test" }, "Explicit" @@ -104,38 +104,38 @@ input_file: crates/vite_task_bin/tests/fixtures/empty-package-test }, { "id": { - "package_dir": "packages/empty-name", + "package_dir": "/packages/empty-name", "task_name": "lint" }, "command": "echo 'Linting empty-name package'", - "cwd": "packages/empty-name", + "cwd": "/packages/empty-name", "depends_on": [] }, { "id": { - "package_dir": "packages/empty-name", + "package_dir": "/packages/empty-name", "task_name": "test" }, "command": "echo 'Testing empty-name package'", - "cwd": "packages/empty-name", + "cwd": "/packages/empty-name", "depends_on": [] }, { "id": { - "package_dir": "packages/normal-package", + "package_dir": "/packages/normal-package", "task_name": "build" }, "command": "echo 'Building normal-package'", - "cwd": "packages/normal-package", + "cwd": "/packages/normal-package", "depends_on": [] }, { "id": { - "package_dir": "packages/normal-package", + "package_dir": "/packages/normal-package", "task_name": "test" }, "command": "echo 'Testing normal-package'", - "cwd": "packages/normal-package", + "cwd": "/packages/normal-package", "depends_on": [] } ] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap index afa635c4..0b4a9662 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap @@ -6,15 +6,15 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace [ { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "build" }, "command": "echo 'Building @test/app'", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "build" }, "Topological" @@ -23,29 +23,29 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "deploy" }, "command": "deploy-script --prod", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "build" }, "Explicit" ], [ { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "test" }, "Explicit" ], [ { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "lint" }, "Explicit" @@ -54,24 +54,24 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "start" }, "command": "echo 'Starting @test/app'", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [] }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "test" }, "command": "echo 'Testing @test/app'", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "test" }, "Topological" @@ -80,33 +80,33 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace }, { "id": { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "build" }, "command": "echo 'Building @test/core'", - "cwd": "packages/core", + "cwd": "/packages/core", "depends_on": [] }, { "id": { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "clean" }, "command": "echo 'Cleaning @test/core'", - "cwd": "packages/core", + "cwd": "/packages/core", "depends_on": [] }, { "id": { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "lint" }, "command": "eslint src", - "cwd": "packages/core", + "cwd": "/packages/core", "depends_on": [ [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "clean" }, "Explicit" @@ -115,24 +115,24 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace }, { "id": { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "test" }, "command": "echo 'Testing @test/core'", - "cwd": "packages/core", + "cwd": "/packages/core", "depends_on": [] }, { "id": { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "build" }, "command": "echo 'Building @test/utils'", - "cwd": "packages/utils", + "cwd": "/packages/utils", "depends_on": [ [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "build" }, "Topological" @@ -141,29 +141,29 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace }, { "id": { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "lint" }, "command": "eslint src", - "cwd": "packages/utils", + "cwd": "/packages/utils", "depends_on": [ [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "build" }, "Explicit" ], [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "lint" }, "Topological" ], [ { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "build" }, "Explicit" @@ -172,15 +172,15 @@ input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace }, { "id": { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "test" }, "command": "echo 'Testing @test/utils'", - "cwd": "packages/utils", + "cwd": "/packages/utils", "depends_on": [ [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "test" }, "Topological" diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap index 7781df6e..9c20d569 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap @@ -6,11 +6,11 @@ input_file: crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test [ { "id": { - "package_dir": "", + "package_dir": "/", "task_name": "create-files" }, "command": "mkdir -p node_modules/pkg-a && echo '{\"name\":\"pkg-a\"}' > node_modules/pkg-a/package.json && echo 'content' > node_modules/pkg-a/index.js && mkdir -p dist && echo 'output' > dist/bundle.js", - "cwd": "", + "cwd": "/", "depends_on": [] } ] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap index 5f2cc399..c9f7c13b 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap @@ -6,22 +6,22 @@ input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace [ { "id": { - "package_dir": "apps/web", + "package_dir": "/apps/web", "task_name": "build" }, "command": "echo 'Building @test/web'", - "cwd": "apps/web", + "cwd": "/apps/web", "depends_on": [ [ { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "build" }, "Topological" @@ -30,24 +30,24 @@ input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace }, { "id": { - "package_dir": "apps/web", + "package_dir": "/apps/web", "task_name": "dev" }, "command": "echo 'Running @test/web in dev mode'", - "cwd": "apps/web", + "cwd": "/apps/web", "depends_on": [] }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "build" }, "command": "echo 'Building @test/app'", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "build" }, "Topological" @@ -56,15 +56,15 @@ input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace }, { "id": { - "package_dir": "packages/app", + "package_dir": "/packages/app", "task_name": "test" }, "command": "echo 'Testing @test/app'", - "cwd": "packages/app", + "cwd": "/packages/app", "depends_on": [ [ { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "test" }, "Topological" @@ -73,33 +73,33 @@ input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace }, { "id": { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "build" }, "command": "echo 'Building @test/core'", - "cwd": "packages/core", + "cwd": "/packages/core", "depends_on": [] }, { "id": { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "test" }, "command": "echo 'Testing @test/core'", - "cwd": "packages/core", + "cwd": "/packages/core", "depends_on": [] }, { "id": { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "build" }, "command": "echo 'Preparing @test/utils' && echo 'Building @test/utils' && echo 'Done @test/utils'", - "cwd": "packages/utils", + "cwd": "/packages/utils", "depends_on": [ [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "build" }, "Topological" @@ -108,15 +108,15 @@ input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace }, { "id": { - "package_dir": "packages/utils", + "package_dir": "/packages/utils", "task_name": "test" }, "command": "echo 'Testing @test/utils'", - "cwd": "packages/utils", + "cwd": "/packages/utils", "depends_on": [ [ { - "package_dir": "packages/core", + "package_dir": "/packages/core", "task_name": "test" }, "Topological" diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap index 684caa80..f2b82e50 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap @@ -6,29 +6,29 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace [ { "id": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "build" }, "command": "echo Building A", - "cwd": "packages/a", + "cwd": "/packages/a", "depends_on": [ [ { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, "Explicit" ], [ { - "package_dir": "packages/b2", + "package_dir": "/packages/b2", "task_name": "build" }, "Topological" ], [ { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "Topological" @@ -37,33 +37,33 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace }, { "id": { - "package_dir": "packages/a", + "package_dir": "/packages/a", "task_name": "test" }, "command": "echo test a", - "cwd": "packages/a", + "cwd": "/packages/a", "depends_on": [] }, { "id": { - "package_dir": "packages/another-a", + "package_dir": "/packages/another-a", "task_name": "build" }, "command": "echo Building another A", - "cwd": "packages/another-a", + "cwd": "/packages/another-a", "depends_on": [] }, { "id": { - "package_dir": "packages/b1", + "package_dir": "/packages/b1", "task_name": "lint" }, "command": "echo lint b1", - "cwd": "packages/b1", + "cwd": "/packages/b1", "depends_on": [ [ { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "lint" }, "Topological" @@ -72,15 +72,15 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace }, { "id": { - "package_dir": "packages/b2", + "package_dir": "/packages/b2", "task_name": "build" }, "command": "echo build b2", - "cwd": "packages/b2", + "cwd": "/packages/b2", "depends_on": [ [ { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "Topological" @@ -89,20 +89,20 @@ input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace }, { "id": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "build" }, "command": "echo Building C", - "cwd": "packages/c", + "cwd": "/packages/c", "depends_on": [] }, { "id": { - "package_dir": "packages/c", + "package_dir": "/packages/c", "task_name": "lint" }, "command": "echo lint c", - "cwd": "packages/c", + "cwd": "/packages/c", "depends_on": [] } ] From 4a632ad52ada3504194b6a2e93174490e4021097 Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 31 Dec 2025 16:27:28 +0800 Subject: [PATCH 11/27] Fix comment --- crates/vite_task_graph/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/vite_task_graph/src/lib.rs b/crates/vite_task_graph/src/lib.rs index 755929a2..bd8f8a4d 100644 --- a/crates/vite_task_graph/src/lib.rs +++ b/crates/vite_task_graph/src/lib.rs @@ -58,12 +58,10 @@ impl TaskDependencyType { pub struct TaskId { /// This is the index of the package where the task is defined. /// - /// `package_index` is declared from `task_name` to make the `PartialOrd` implementation group tasks in same packages together. + /// `package_index` is declared before `task_name` to make the `PartialOrd` implementation group tasks in same packages together. pub package_index: PackageNodeIndex, - /// For user defined tasks, this is the name of the script or the entry in `vite.config.*`. - /// - /// For synthesized tasks, this is the program. + /// The name of the script or the entry in `vite.config.*`. pub task_name: Str, } From a25bec1a1a412e1fc8be20cc5f5f62c11b93a0a1 Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 31 Dec 2025 17:12:58 +0800 Subject: [PATCH 12/27] Make task_id internal --- crates/vite_task/src/session/execute/mod.rs | 62 ++----------------- crates/vite_task_bin/tests/snapshots.rs | 6 +- crates/vite_task_graph/src/display.rs | 11 +--- crates/vite_task_graph/src/lib.rs | 66 ++++++++++----------- crates/vite_task_graph/src/query/mod.rs | 3 +- crates/vite_task_plan/src/lib.rs | 4 +- crates/vite_task_plan/src/plan.rs | 6 +- 7 files changed, 52 insertions(+), 106 deletions(-) diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index 2f522cd0..f404f7a3 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -7,7 +7,7 @@ use petgraph::{ }; use vite_path::{AbsolutePath, RelativePathBuf, relative::InvalidPathDataError}; use vite_str::Str; -use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex}; +use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex, display::TaskDisplay}; use vite_task_plan::{ ExecutionItem, ExecutionItemKind, LeafExecutionKind, SpawnExecution, TaskExecution, execution_graph::{ExecutionIx, ExecutionNodeIndex}, @@ -65,7 +65,7 @@ enum ExecutionOrigin<'a> { cwd: &'a Arc, }, UserTask { - task_node_index: TaskNodeIndex, + task_display: TaskDisplay, item: &'a ExecutionItem, item_index: usize, item_count: usize, @@ -120,8 +120,7 @@ impl ExecutionContext<'_> { node_indices.into_iter().map(|id| graph.remove_node(id).unwrap()); for task_execution in ordered_executions { let indexed_task_graph = self.indexed_task_graph.unwrap(); - let task_display = - indexed_task_graph.display_task(task_execution.task_node_index); + let task_display = task_execution.task_display.clone(); for (item_index, item) in task_execution.items.iter().enumerate() { self.execute_item_kind( &item.kind, @@ -129,7 +128,7 @@ impl ExecutionContext<'_> { item, item_index, item_count: task_execution.items.len(), - task_node_index: task_execution.task_node_index, + task_display: task_execution.task_display.clone(), }, ) .boxed_local() @@ -149,39 +148,7 @@ impl ExecutionContext<'_> { leaf_execution_kind: &LeafExecutionKind, origin: ExecutionOrigin<'_>, ) -> Result<(), ExecuteError> { - let start_info = match origin { - ExecutionOrigin::CLIArgs { args_without_program, cwd } => ExecutionStartInfo { - task_display_name: None, - // display command with `vite` followed by the user supplied cli args - command: vite_str::format!( - "{}", - std::iter::once(Cow::Borrowed("vite")) - .chain( - args_without_program - .iter() - .map(|s| shell_escape::escape(s.as_str().into())) - ) - .collect::>() - .join(" ") - ), - cwd: Arc::clone(&cwd), - }, - ExecutionOrigin::UserTask { task_node_index, item, item_index, item_count } => { - let indexed_task_graph = self.indexed_task_graph.expect("Task graph must have been loaded if there exists an execution associated with a task"); - let task_node = &indexed_task_graph.task_graph()[task_node_index]; - let command = &task_node.resolved_config.command[item.command_span.clone()]; - let task_display = indexed_task_graph.display_task(task_node_index); - ExecutionStartInfo { - task_display_name: Some(if item_count > 1 { - vite_str::format!("{} ({})", task_display, item_index) - } else { - vite_str::format!("{}", task_display) - }), - command: command.into(), - cwd: Arc::clone(&item.plan_cwd), - } - } - }; + let start_info: ExecutionStartInfo = todo!(); let execution_id = self.current_execution_id; self.current_execution_id = self.current_execution_id.next(); @@ -223,24 +190,7 @@ impl ExecutionContext<'_> { origin: ExecutionOrigin<'_>, spawn_execution: &SpawnExecution, ) -> Result<(), ExecuteError> { - let execution_cache_key = match origin { - ExecutionOrigin::CLIArgs { args_without_program, cwd } => { - ExecutionCacheKey::Direct(DirectExecutionCacheKey { - args_without_program: Arc::clone(&args_without_program), - plan_cwd: self.strip_prefix_for_cache(cwd)?, - }) - } - ExecutionOrigin::UserTask { task_node_index, item_index, .. } => { - let indexed_task_graph = self.indexed_task_graph.expect("Task graph must have been loaded if there exists an execution associated with a task"); - let task_node = &indexed_task_graph.task_graph()[task_node_index]; - let package_path = indexed_task_graph.get_package_path_for_task(task_node_index); - ExecutionCacheKey::UserTask(UserTaskExecutionCacheKey { - task_name: task_node.task_id.task_name.clone(), - package_path: self.strip_prefix_for_cache(&package_path)?, - and_item_index: item_index, - }) - } - }; + let execution_cache_key: ExecutionCacheKey = todo!(); // let mut cmd = match &spawn_execution.command_kind { // SpawnCommandKind::Program { program_path, args } => { diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index e003ca7d..157abad0 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -21,10 +21,10 @@ struct TaskIdSnapshot { } impl TaskIdSnapshot { fn new(task_index: TaskNodeIndex, indexed_task_graph: &IndexedTaskGraph) -> Self { - let task_id = &indexed_task_graph.task_graph()[task_index].task_id; + let task_display = &indexed_task_graph.task_graph()[task_index].task_display; Self { - task_name: task_id.task_name.clone(), - package_dir: Arc::clone(&indexed_task_graph.get_package_path(task_id.package_index)), + task_name: task_display.task_name.clone(), + package_dir: Arc::clone(&task_display.package_path), } } } diff --git a/crates/vite_task_graph/src/display.rs b/crates/vite_task_graph/src/display.rs index 78afab73..d2594ba3 100644 --- a/crates/vite_task_graph/src/display.rs +++ b/crates/vite_task_graph/src/display.rs @@ -2,13 +2,14 @@ use std::{fmt::Display, sync::Arc}; +use serde::Serialize; use vite_path::AbsolutePath; use vite_str::Str; use crate::{IndexedTaskGraph, TaskNodeIndex}; /// struct for printing a task in a human-readable way. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize)] pub struct TaskDisplay { pub package_name: Str, pub task_name: Str, @@ -25,12 +26,6 @@ impl Display for TaskDisplay { impl IndexedTaskGraph { /// Get human-readable display for a task node. pub fn display_task(&self, task_index: TaskNodeIndex) -> TaskDisplay { - let task_node = &self.task_graph()[task_index]; - let package = &self.indexed_package_graph.package_graph()[task_node.task_id.package_index]; - TaskDisplay { - package_name: package.package_json.name.clone(), - task_name: task_node.task_id.task_name.clone(), - package_path: Arc::clone(&package.absolute_path), - } + self.task_graph()[task_index].task_display.clone() } } diff --git a/crates/vite_task_graph/src/lib.rs b/crates/vite_task_graph/src/lib.rs index bd8f8a4d..5c9d2578 100644 --- a/crates/vite_task_graph/src/lib.rs +++ b/crates/vite_task_graph/src/lib.rs @@ -55,7 +55,7 @@ impl TaskDependencyType { /// Uniquely identifies a task, by its name and the path where it's defined. #[derive(Debug, PartialEq, Eq, Hash, Clone, PartialOrd, Ord)] -pub struct TaskId { +struct TaskId { /// This is the index of the package where the task is defined. /// /// `package_index` is declared before `task_name` to make the `PartialOrd` implementation group tasks in same packages together. @@ -68,8 +68,8 @@ pub struct TaskId { /// A node in the task graph, representing a task with its resolved configuration. #[derive(Debug)] pub struct TaskNode { - /// The unique id of this task - pub task_id: TaskId, + /// Printing the task in a human-readable way. + pub task_display: TaskDisplay, /// The resolved configuration of this task. /// @@ -186,8 +186,11 @@ impl IndexedTaskGraph { let package_graph = vite_workspace::load_package_graph(workspace_root)?; // Record dependency specifiers for each task node to add explicit dependencies later - let mut dependency_specifiers_with_task_node_indices: Vec<(Arc<[Str]>, TaskNodeIndex)> = - Vec::new(); + let mut task_ids_with_dependency_specifiers: Vec<(TaskId, Arc<[Str]>)> = Vec::new(); + + // index tasks by ids + let mut node_indices_by_task_id: HashMap = + HashMap::with_capacity(task_graph.node_count()); // Load task nodes into `task_graph` for package_index in package_graph.node_indices() { @@ -231,11 +234,18 @@ impl IndexedTaskGraph { }, })?; - let task_node = TaskNode { task_id, resolved_config }; + let task_node = TaskNode { + task_display: TaskDisplay { + package_name: package.package_json.name.clone(), + task_name: task_name.clone(), + package_path: Arc::clone(&package_dir), + }, + resolved_config, + }; let node_index = task_graph.add_node(task_node); - dependency_specifiers_with_task_node_indices - .push((dependency_specifiers, node_index)); + task_ids_with_dependency_specifiers.push((task_id.clone(), dependency_specifiers)); + node_indices_by_task_id.insert(task_id, node_index); } // For remaining package.json scripts not defined in vite.config.*, create tasks with default config @@ -245,21 +255,15 @@ impl IndexedTaskGraph { &package_dir, package_json_script, ); - task_graph.add_node(TaskNode { task_id, resolved_config }); - } - } - - // index tasks by ids - let mut node_indices_by_task_id: HashMap = - HashMap::with_capacity(task_graph.node_count()); - for node_index in task_graph.node_indices() { - let task_node = &task_graph[node_index]; - - let existing_entry = - node_indices_by_task_id.insert(task_node.task_id.clone(), node_index); - if existing_entry.is_some() { - // This should never happen as we enforce unique task ids when adding nodes. - panic!("Duplicate task id found: {:?}", task_node.task_id); + let node_index = task_graph.add_node(TaskNode { + task_display: TaskDisplay { + package_name: package.package_json.name.clone(), + task_name: script_name.into(), + package_path: Arc::clone(&package_dir), + }, + resolved_config, + }); + node_indices_by_task_id.insert(task_id, node_index); } } @@ -286,10 +290,8 @@ impl IndexedTaskGraph { }; // Add explicit dependencies - for (dependency_specifiers, from_node_index) in dependency_specifiers_with_task_node_indices - { - let from_task_id = me.task_graph[from_node_index].task_id.clone(); - + for (from_task_id, dependency_specifiers) in task_ids_with_dependency_specifiers { + let from_node_index = me.node_indices_by_task_id[&from_task_id]; for specifier in dependency_specifiers.iter().cloned() { let to_node_index = me .get_task_index_by_specifier::( @@ -311,8 +313,7 @@ impl IndexedTaskGraph { // Add topological dependencies based on package dependencies let mut nearest_topological_tasks = Vec::::new(); - for task_index in me.task_graph.node_indices() { - let task_id = &me.task_graph[task_index].task_id; + for (task_id, task_index) in &me.node_indices_by_task_id { let task_name = task_id.task_name.as_str(); let package_index = task_id.package_index; @@ -325,7 +326,7 @@ impl IndexedTaskGraph { ); for nearest_task_index in nearest_topological_tasks.drain(..) { if let Some(existing_edge_index) = - me.task_graph.find_edge(task_index, nearest_task_index) + me.task_graph.find_edge(*task_index, nearest_task_index) { // If an edge already exists, let existing_edge = &mut me.task_graph[existing_edge_index]; @@ -341,7 +342,7 @@ impl IndexedTaskGraph { } else { // add new topological edge if not exists me.task_graph.add_edge( - task_index, + *task_index, nearest_task_index, TaskDependencyType(TaskDependencyTypeInner::Topological), ); @@ -465,7 +466,6 @@ impl IndexedTaskGraph { } pub fn get_package_path_for_task(&self, task_index: TaskNodeIndex) -> &Arc { - let task_node = &self.task_graph[task_index]; - self.get_package_path(task_node.task_id.package_index) + &self.task_graph[task_index].task_display.package_path } } diff --git a/crates/vite_task_graph/src/query/mod.rs b/crates/vite_task_graph/src/query/mod.rs index b5c41519..89ca51aa 100644 --- a/crates/vite_task_graph/src/query/mod.rs +++ b/crates/vite_task_graph/src/query/mod.rs @@ -130,7 +130,8 @@ impl IndexedTaskGraph { TaskQueryKind::Recursive { task_names } => { // Add all tasks matching the names across all packages for task_index in self.task_graph.node_indices() { - let current_task_name = self.task_graph[task_index].task_id.task_name.as_str(); + let current_task_name = + self.task_graph[task_index].task_display.task_name.as_str(); if task_names.contains(current_task_name) { execution_graph.add_node(task_index); } diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index bd9afcfe..d7518c86 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -19,7 +19,7 @@ use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; use vite_path::AbsolutePath; use vite_str::Str; -use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex}; +use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, display::TaskDisplay}; use crate::path_env::prepend_path_env; @@ -55,7 +55,7 @@ pub struct SpawnCommand { #[derive(Debug)] pub struct TaskExecution { /// The task this execution corresponds to - pub task_node_index: TaskNodeIndex, + pub task_display: TaskDisplay, /// A task's command is split by `&&` and expanded into multiple execution items. /// diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index c564cef4..77cfb09d 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -132,7 +132,7 @@ async fn plan_task_as_execution_node( // Create execution cache key for this and_item let task_execution_cache_key = ExecutionCacheKey { kind: ExecutionCacheKeyKind::UserTask { - task_name: task_node.task_id.task_name.clone(), + task_name: task_node.task_display.task_name.clone(), and_item_index: index, }, origin_path: strip_prefix_for_cache(package_path, context.workspace_path()) @@ -227,7 +227,7 @@ async fn plan_task_as_execution_node( context.workspace_path(), ExecutionCacheKey { kind: ExecutionCacheKeyKind::UserTask { - task_name: task_node.task_id.task_name.clone(), + task_name: task_node.task_display.task_name.clone(), and_item_index: 0, }, origin_path: strip_prefix_for_cache(package_path, context.workspace_path()) @@ -254,7 +254,7 @@ async fn plan_task_as_execution_node( }); } - Ok(TaskExecution { task_node_index, items }) + Ok(TaskExecution { task_display: task_node.task_display.clone(), items }) } pub fn plan_synthetic_request( From 13fc8fe45261d207a8441e2d4da3bd70f3cdb6dd Mon Sep 17 00:00:00 2001 From: branchseer Date: Thu, 1 Jan 2026 20:10:58 +0800 Subject: [PATCH 13/27] stablize snapshots --- Cargo.lock | 38 + Cargo.toml | 2 + crates/vite_graph_ser/Cargo.toml | 17 + crates/vite_graph_ser/src/lib.rs | 162 ++ crates/vite_task_bin/Cargo.toml | 5 +- crates/vite_task_bin/tests/snapshots.rs | 127 +- .../snapshots__task graph@cache-sharing.snap | 234 +- ...__task graph@comprehensive-task-graph.snap | 1898 ++++++++++++++--- .../snapshots__task graph@conflict-test.snap | 242 ++- ...aph@dependency-both-topo-and-explicit.snap | 166 +- ...pshots__task graph@empty-package-test.snap | 696 ++++-- ...s__task graph@explicit-deps-workspace.snap | 880 ++++++-- ...s__task graph@fingerprint-ignore-test.snap | 82 +- ...graph@recursive-topological-workspace.snap | 662 +++++- ...graph@transitive-dependency-workspace.snap | 578 ++++- crates/vite_task_graph/Cargo.toml | 1 + crates/vite_task_graph/src/config/mod.rs | 9 +- crates/vite_task_graph/src/lib.rs | 19 +- 18 files changed, 4768 insertions(+), 1050 deletions(-) create mode 100644 crates/vite_graph_ser/Cargo.toml create mode 100644 crates/vite_graph_ser/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 02fe3eef..fcc55e95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,6 +230,9 @@ name = "bitflags" version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +dependencies = [ + "serde_core", +] [[package]] name = "block-buffer" @@ -1446,6 +1449,8 @@ dependencies = [ "once_cell", "pest", "pest_derive", + "regex", + "ron", "serde", "similar", "tempfile", @@ -2365,6 +2370,20 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" +[[package]] +name = "ron" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32" +dependencies = [ + "bitflags 2.10.0", + "once_cell", + "serde", + "serde_derive", + "typeid", + "unicode-ident", +] + [[package]] name = "rusqlite" version = "0.37.0" @@ -3060,6 +3079,12 @@ dependencies = [ "rand 0.9.2", ] +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + [[package]] name = "typenum" version = "1.19.0" @@ -3187,6 +3212,15 @@ dependencies = [ "wax", ] +[[package]] +name = "vite_graph_ser" +version = "0.1.0" +dependencies = [ + "petgraph", + "serde", + "serde_json", +] + [[package]] name = "vite_path" version = "0.1.0" @@ -3276,10 +3310,13 @@ dependencies = [ "copy_dir", "insta", "petgraph", + "regex", "serde", + "serde_json", "tempfile", "tokio", "toml", + "vite_graph_ser", "vite_path", "vite_str", "vite_task", @@ -3302,6 +3339,7 @@ dependencies = [ "thiserror 2.0.17", "tokio", "vec1", + "vite_graph_ser", "vite_path", "vite_str", "vite_workspace", diff --git a/Cargo.toml b/Cargo.toml index 08bf0085..0e9b82a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,6 +91,7 @@ rand = "0.9.1" ratatui = "0.29.0" rayon = "1.10.0" ref-cast = "1.0.24" +regex = "1.11.3" rusqlite = "0.37.0" rustc-hash = "2.1.1" seccompiler = { git = "https://github.com/branchseer/seccompiler", branch = "seccomp-action-raw" } @@ -120,6 +121,7 @@ twox-hash = "2.1.1" uuid = "1.18.1" vec1 = "1.12.1" vite_glob = { path = "crates/vite_glob" } +vite_graph_ser = { path = "crates/vite_graph_ser" } vite_path = { path = "crates/vite_path" } vite_shell = { path = "crates/vite_shell" } vite_str = { path = "crates/vite_str" } diff --git a/crates/vite_graph_ser/Cargo.toml b/crates/vite_graph_ser/Cargo.toml new file mode 100644 index 00000000..d149a13a --- /dev/null +++ b/crates/vite_graph_ser/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "vite_graph_ser" +version = "0.1.0" +authors.workspace = true +edition.workspace = true +license.workspace = true +rust-version.workspace = true + +[dependencies] +petgraph = { workspace = true } +serde = { workspace = true, features = ["derive"] } + +[dev-dependencies] +serde_json = { workspace = true } + +[lints] +workspace = true diff --git a/crates/vite_graph_ser/src/lib.rs b/crates/vite_graph_ser/src/lib.rs new file mode 100644 index 00000000..b3718060 --- /dev/null +++ b/crates/vite_graph_ser/src/lib.rs @@ -0,0 +1,162 @@ +use std::{collections::BTreeMap, fmt::Display}; + +use petgraph::{ + graph::DiGraph, + visit::{EdgeRef as _, IntoNodeReferences}, +}; +use serde::{Serialize, Serializer, ser::SerializeMap}; + +/// Trait for getting a unique key for a node in the graph. +/// This key is used for serializing the graph with `serialize_by_key`. +pub trait GetKey { + type Key<'a>: Serialize + Ord + where + Self: 'a; + fn key(&self) -> Result, String>; +} + +#[derive(Serialize)] +#[serde(bound = "E: Serialize, N: Serialize")] +struct DiGraphValue<'a, N: GetKey, E> { + node: &'a N, + neighbors: BTreeMap, &'a E>, +} + +/// A wrapper around `DiGraph` that serializes nodes by their keys. +#[derive(Serialize)] +#[serde(transparent)] +pub struct SerializeByKey<'a, N: GetKey + Serialize, E: Serialize, Ix: petgraph::graph::IndexType>( + #[serde(serialize_with = "serialize_by_key")] pub &'a DiGraph, +); + +/// Serialize a directed graph into a map from node keys to their values and neighbors by keys. +/// +/// Keys in nodes and edges are sorted lexicographically. +/// +/// If there are multiple nodes with the same key, or multiple edges between nodes with the same keys, +/// an error will be returned. +/// +/// This is useful for serializing graphs in a stable and human-readable way. +pub fn serialize_by_key< + N: GetKey + Serialize, + E: Serialize, + Ix: petgraph::graph::IndexType, + S: Serializer, +>( + graph: &DiGraph, + serializer: S, +) -> Result { + let mut map = BTreeMap::, DiGraphValue<'_, N, E>>::new(); + + for (node_idx, node) in graph.node_references() { + let mut neighbors = BTreeMap::, &E>::new(); + + for edge in graph.edges(node_idx) { + let target_idx = edge.target(); + let target_node = graph.node_weight(target_idx).unwrap(); + let existing = neighbors + .insert(target_node.key().map_err(serde::ser::Error::custom)?, edge.weight()); + if existing.is_some() { + return Err(serde::ser::Error::custom( + "multiple edges between nodes with same id are not supported", + )); + } + } + let existing = map.insert( + node.key().map_err(serde::ser::Error::custom)?, + DiGraphValue { node, neighbors }, + ); + if existing.is_some() { + return Err(serde::ser::Error::custom( + "multiple nodes with the same id are not supported", + )); + } + } + map.serialize(serializer) +} + +#[cfg(test)] +mod tests { + use petgraph::graph::DiGraph; + + use super::*; + + #[derive(Debug, Clone, Serialize)] + struct TestNode { + id: &'static str, + value: i32, + } + + impl GetKey for TestNode { + type Key<'a> + = &'a str + where + Self: 'a; + + fn key(&self) -> Result, String> { + Ok(self.id) + } + } + + #[derive(Serialize)] + struct GraphWrapper { + #[serde(serialize_with = "serialize_by_key")] + graph: DiGraph, + } + + #[test] + fn test_serialize_graph_happy_path() { + let mut graph = DiGraph::::new(); + let a = graph.add_node(TestNode { id: "a", value: 1 }); + let b = graph.add_node(TestNode { id: "b", value: 2 }); + let c = graph.add_node(TestNode { id: "c", value: 3 }); + + graph.add_edge(a, b, "a->b"); + graph.add_edge(a, c, "a->c"); + graph.add_edge(b, c, "b->c"); + + let json = serde_json::to_value(GraphWrapper { graph }).unwrap(); + assert_eq!( + json, + serde_json::json!({ + "graph": { + "a": { + "node": {"id": "a", "value": 1}, + "neighbors": {"b": "a->b", "c": "a->c"} + }, + "b": { + "node": {"id": "b", "value": 2}, + "neighbors": {"c": "b->c"} + }, + "c": { + "node": {"id": "c", "value": 3}, + "neighbors": {} + } + } + }) + ); + } + + #[test] + fn test_serialize_graph_error_duplicate_nodes() { + let mut graph = DiGraph::::new(); + graph.add_node(TestNode { id: "a", value: 1 }); + graph.add_node(TestNode { id: "a", value: 2 }); // duplicate id + + let err = serde_json::to_string(&GraphWrapper { graph }).unwrap_err(); + assert!(err.to_string().contains("multiple nodes with the same id")); + } + + #[test] + fn test_serialize_graph_error_duplicate_edges() { + let mut graph = DiGraph::::new(); + let a = graph.add_node(TestNode { id: "a", value: 1 }); + let b = graph.add_node(TestNode { id: "b", value: 2 }); + + graph.add_edge(a, b, "first"); + graph.add_edge(a, b, "second"); // duplicate edge + + let err = serde_json::to_string(&GraphWrapper { graph }).unwrap_err(); + assert!(err.to_string().contains("multiple edges between nodes with same id")); + } +} diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index a176d044..bd1a9ccf 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -22,11 +22,14 @@ which = { workspace = true } [dev-dependencies] copy_dir = { workspace = true } -insta = { workspace = true, features = ["glob", "json", "redactions"] } +insta = { workspace = true, features = ["glob", "json", "redactions", "filters", "ron"] } petgraph = { workspace = true } +regex = { workspace = true } serde = { workspace = true, features = ["derive", "rc"] } +serde_json = { workspace = true } tempfile = { workspace = true } toml = { workspace = true } +vite_graph_ser = { workspace = true } vite_path = { workspace = true, features = ["absolute-redaction"] } vite_task_graph = { workspace = true } vite_workspace = { workspace = true } diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index 157abad0..a155e9aa 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -3,6 +3,7 @@ use std::{path::Path, sync::Arc}; use clap::Parser; use copy_dir::copy_dir; +use insta::internals::Content; use petgraph::visit::EdgeRef as _; use tokio::runtime::Runtime; use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; @@ -14,6 +15,23 @@ use vite_task_graph::{ }; use vite_workspace::find_workspace_root; +fn visit_json(value: &mut serde_json::Value, f: &mut impl FnMut(&mut serde_json::Value)) { + f(value); + match value { + serde_json::Value::Array(arr) => { + for item in arr { + visit_json(item, f); + } + } + serde_json::Value::Object(map) => { + for (_key, val) in map { + visit_json(val, f); + } + } + _ => {} + } +} + #[derive(serde::Serialize, PartialEq, PartialOrd, Eq, Ord)] struct TaskIdSnapshot { package_dir: Arc, @@ -62,36 +80,6 @@ fn snapshot_task_graph(indexed_task_graph: &IndexedTaskGraph) -> impl serde::Ser node_snapshots } -/// Create a stable json representation of the task graph for snapshot testing. -/// -/// All paths are relative to `base_dir`. -fn snapshot_execution_graph( - execution_graph: &TaskExecutionGraph, - indexed_task_graph: &IndexedTaskGraph, -) -> impl serde::Serialize { - #[derive(serde::Serialize, PartialEq)] - struct ExecutionNodeSnapshot { - task: TaskIdSnapshot, - deps: Vec, - } - - let mut execution_node_snapshots = Vec::::new(); - for task_index in execution_graph.nodes() { - let mut deps = execution_graph - .neighbors(task_index) - .map(|dep_index| TaskIdSnapshot::new(dep_index, indexed_task_graph)) - .collect::>(); - deps.sort_unstable(); - - execution_node_snapshots.push(ExecutionNodeSnapshot { - task: TaskIdSnapshot::new(task_index, indexed_task_graph), - deps, - }); - } - execution_node_snapshots.sort_unstable_by(|a, b| a.task.cmp(&b.task)); - execution_node_snapshots -} - #[derive(serde::Deserialize)] struct CLIQuery { pub name: Str, @@ -115,6 +103,11 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, case_path: &Path) { let case_stage_path = tmpdir.join(case_name); copy_dir(case_path, &case_stage_path).unwrap(); + // let mut settings = insta::Settings::clone_current(); + // let case_stage_path_str = case_stage_path.as_path().to_str().expect("path is valid unicode"); + // settings.add_filter(®ex::escape(case_stage_path_str), ""); + // let _guard = settings.bind_to_scope(); + let (workspace_root, _cwd) = find_workspace_root(&case_stage_path).unwrap(); assert_eq!( @@ -140,42 +133,44 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, case_path: &Path) { .await .expect(&format!("Failed to load task graph for case {case_name}")); - let task_graph_snapshot = snapshot_task_graph(&indexed_task_graph); - insta::assert_json_snapshot!("task graph", task_graph_snapshot); - - for cli_query in cli_queries_file.queries { - let snapshot_name = format!("query - {}", cli_query.name); - - let cli_task_query = CLITaskQuery::try_parse_from( - std::iter::once("vite-run") // dummy program name - .chain(cli_query.args.iter().map(|s| s.as_str())), - ) - .expect(&format!( - "Failed to parse CLI args for query '{}' in case '{}'", - cli_query.name, case_name - )); - - let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); - let task_query = match cli_task_query.into_task_query(&cwd) { - Ok(ok) => ok, - Err(err) => { - insta::assert_json_snapshot!(snapshot_name, err); - continue; - } - }; - - let execution_graph = match indexed_task_graph.query_tasks(task_query) { - Ok(ok) => ok, - Err(err) => { - insta::assert_json_snapshot!(snapshot_name, err); - continue; - } - }; - - let execution_graph_snapshot = - snapshot_execution_graph(&execution_graph, &indexed_task_graph); - insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); - } + insta::assert_ron_snapshot!( + "task graph", + vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph()) + ); + + // for cli_query in cli_queries_file.queries { + // let snapshot_name = format!("query - {}", cli_query.name); + + // let cli_task_query = CLITaskQuery::try_parse_from( + // std::iter::once("vite-run") // dummy program name + // .chain(cli_query.args.iter().map(|s| s.as_str())), + // ) + // .expect(&format!( + // "Failed to parse CLI args for query '{}' in case '{}'", + // cli_query.name, case_name + // )); + + // let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); + // let task_query = match cli_task_query.into_task_query(&cwd) { + // Ok(ok) => ok, + // Err(err) => { + // insta::assert_json_snapshot!(snapshot_name, err); + // continue; + // } + // }; + + // let execution_graph = match indexed_task_graph.query_tasks(task_query) { + // Ok(ok) => ok, + // Err(err) => { + // insta::assert_json_snapshot!(snapshot_name, err); + // continue; + // } + // }; + + // let execution_graph_snapshot = + // snapshot_execution_graph(&execution_graph, &indexed_task_graph); + // insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); + // } }); } diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap index 5a9d46d5..b83ed835 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap @@ -1,34 +1,208 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/cache-sharing --- -[ - { - "id": { - "package_dir": "/", - "task_name": "a" - }, - "command": "echo a", - "cwd": "/", - "depends_on": [] - }, - { - "id": { - "package_dir": "/", - "task_name": "b" - }, - "command": "echo a && echo b", - "cwd": "/", - "depends_on": [] - }, - { - "id": { - "package_dir": "/", - "task_name": "c" - }, - "command": "echo a && echo b && echo c", - "cwd": "/", - "depends_on": [] - } -] +{ + ("/", "a"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/cache-sharing", + task_name: "a", + package_path: "/", + ), + resolved_config: ResolvedTaskConfig( + command: "echo a", + resolved_options: ResolvedTaskOptions( + cwd: "/", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/", "b"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/cache-sharing", + task_name: "b", + package_path: "/", + ), + resolved_config: ResolvedTaskConfig( + command: "echo a && echo b", + resolved_options: ResolvedTaskOptions( + cwd: "/", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/", "c"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/cache-sharing", + task_name: "c", + package_path: "/", + ), + resolved_config: ResolvedTaskConfig( + command: "echo a && echo b && echo c", + resolved_options: ResolvedTaskOptions( + cwd: "/", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap index d42087b6..c29d5bfc 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap @@ -1,351 +1,1577 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph --- -[ - { - "id": { - "package_dir": "/packages/api", - "task_name": "build" +{ + ("/packages/api", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/api", + task_name: "build", + package_path: "/packages/api", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Generate schemas && echo Compile TypeScript && echo Bundle API && echo Copy assets", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/api", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/config", "build"): Topological, + ("/packages/shared", "build"): Topological, }, - "command": "echo Generate schemas && echo Compile TypeScript && echo Bundle API && echo Copy assets", - "cwd": "/packages/api", - "depends_on": [ - [ - { - "package_dir": "/packages/config", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/shared", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/api", - "task_name": "dev" + ), + ("/packages/api", "dev"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/api", + task_name: "dev", + package_path: "/packages/api", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Watch mode && echo Start dev server", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/api", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/api", "start"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/api", + task_name: "start", + package_path: "/packages/api", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Starting API server", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/api", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/api", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/api", + task_name: "test", + package_path: "/packages/api", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Testing API", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/api", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/shared", "test"): Topological, }, - "command": "echo Watch mode && echo Start dev server", - "cwd": "/packages/api", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/api", - "task_name": "start" + ), + ("/packages/app", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "build", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Clean dist && echo Build client && echo Build server && echo Generate manifest && echo Optimize assets", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/api", "build"): Topological, + ("/packages/pkg#special", "build"): Topological, + ("/packages/shared", "build"): Topological, + ("/packages/ui", "build"): Topological, }, - "command": "echo Starting API server", - "cwd": "/packages/api", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/api", - "task_name": "test" + ), + ("/packages/app", "deploy"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "deploy", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Validate && echo Upload && echo Verify", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/app", "dev"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "dev", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Running dev server", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/api", "dev"): Topological, }, - "command": "echo Testing API", - "cwd": "/packages/api", - "depends_on": [ - [ - { - "package_dir": "/packages/shared", - "task_name": "test" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "build" + ), + ("/packages/app", "preview"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "preview", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Preview build", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/app", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "test", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Unit tests && echo Integration tests", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/api", "test"): Topological, + ("/packages/pkg#special", "test"): Topological, + ("/packages/shared", "test"): Topological, + ("/packages/ui", "test"): Topological, }, - "command": "echo Clean dist && echo Build client && echo Build server && echo Generate manifest && echo Optimize assets", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/api", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/pkg#special", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/shared", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/ui", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "deploy" + ), + ("/packages/config", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/config", + task_name: "build", + package_path: "/packages/config", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Building config", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/config", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/config", "validate"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/config", + task_name: "validate", + package_path: "/packages/config", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Validating config", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/config", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/pkg#special", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/pkg#special", + task_name: "build", + package_path: "/packages/pkg#special", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Building package with hash", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/pkg#special", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/shared", "build"): Topological, }, - "command": "echo Validate && echo Upload && echo Verify", - "cwd": "/packages/app", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "dev" + ), + ("/packages/pkg#special", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/pkg#special", + task_name: "test", + package_path: "/packages/pkg#special", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Testing package with hash", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/pkg#special", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/shared", "test"): Topological, }, - "command": "echo Running dev server", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/api", - "task_name": "dev" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "preview" + ), + ("/packages/shared", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/shared", + task_name: "build", + package_path: "/packages/shared", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Cleaning && echo Compiling shared && echo Generating types", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/shared", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/shared", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/shared", + task_name: "lint", + package_path: "/packages/shared", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Linting shared", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/shared", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/shared", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/shared", + task_name: "test", + package_path: "/packages/shared", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Setting up test env && echo Running tests && echo Cleanup", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/shared", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/shared", "typecheck"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/shared", + task_name: "typecheck", + package_path: "/packages/shared", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Type checking shared", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/shared", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/tools", "generate"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/tools", + task_name: "generate", + package_path: "/packages/tools", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Generating tools", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/tools", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/tools", "validate"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/tools", + task_name: "validate", + package_path: "/packages/tools", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Validating", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/tools", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/config", "validate"): Topological, }, - "command": "echo Preview build", - "cwd": "/packages/app", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "test" + ), + ("/packages/ui", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/ui", + task_name: "build", + package_path: "/packages/ui", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Compile styles && echo Build components && echo Generate types", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/ui", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/shared", "build"): Topological, }, - "command": "echo Unit tests && echo Integration tests", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/api", - "task_name": "test" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/pkg#special", - "task_name": "test" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/shared", - "task_name": "test" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/ui", - "task_name": "test" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/config", - "task_name": "build" + ), + ("/packages/ui", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/ui", + task_name: "lint", + package_path: "/packages/ui", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Linting UI", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/ui", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/shared", "lint"): Topological, }, - "command": "echo Building config", - "cwd": "/packages/config", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/config", - "task_name": "validate" + ), + ("/packages/ui", "storybook"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/ui", + task_name: "storybook", + package_path: "/packages/ui", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Running storybook", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/ui", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/ui", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/ui", + task_name: "test", + package_path: "/packages/ui", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Testing UI", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/ui", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/shared", "test"): Topological, }, - "command": "echo Validating config", - "cwd": "/packages/config", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/pkg#special", - "task_name": "build" - }, - "command": "echo Building package with hash", - "cwd": "/packages/pkg#special", - "depends_on": [ - [ - { - "package_dir": "/packages/shared", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/pkg#special", - "task_name": "test" - }, - "command": "echo Testing package with hash", - "cwd": "/packages/pkg#special", - "depends_on": [ - [ - { - "package_dir": "/packages/shared", - "task_name": "test" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/shared", - "task_name": "build" - }, - "command": "echo Cleaning && echo Compiling shared && echo Generating types", - "cwd": "/packages/shared", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/shared", - "task_name": "lint" - }, - "command": "echo Linting shared", - "cwd": "/packages/shared", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/shared", - "task_name": "test" - }, - "command": "echo Setting up test env && echo Running tests && echo Cleanup", - "cwd": "/packages/shared", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/shared", - "task_name": "typecheck" - }, - "command": "echo Type checking shared", - "cwd": "/packages/shared", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/tools", - "task_name": "generate" - }, - "command": "echo Generating tools", - "cwd": "/packages/tools", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/tools", - "task_name": "validate" - }, - "command": "echo Validating", - "cwd": "/packages/tools", - "depends_on": [ - [ - { - "package_dir": "/packages/config", - "task_name": "validate" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/ui", - "task_name": "build" - }, - "command": "echo Compile styles && echo Build components && echo Generate types", - "cwd": "/packages/ui", - "depends_on": [ - [ - { - "package_dir": "/packages/shared", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/ui", - "task_name": "lint" - }, - "command": "echo Linting UI", - "cwd": "/packages/ui", - "depends_on": [ - [ - { - "package_dir": "/packages/shared", - "task_name": "lint" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/ui", - "task_name": "storybook" - }, - "command": "echo Running storybook", - "cwd": "/packages/ui", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/ui", - "task_name": "test" - }, - "command": "echo Testing UI", - "cwd": "/packages/ui", - "depends_on": [ - [ - { - "package_dir": "/packages/shared", - "task_name": "test" - }, - "Topological" - ] - ] - } -] + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap index 5ea05c74..c6a14c51 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap @@ -1,42 +1,210 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/conflict-test --- -[ - { - "id": { - "package_dir": "/packages/scope-a", - "task_name": "b#c" +{ + ("/packages/scope-a", "b#c"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/scope-a", + task_name: "b#c", + package_path: "/packages/scope-a", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Task b#c in scope-a", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/scope-a", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/scope-a-b", "c"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/scope-a#b", + task_name: "c", + package_path: "/packages/scope-a-b", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Task c in scope-a#b", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/scope-a-b", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/test-package", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/test-package", + task_name: "test", + package_path: "/packages/test-package", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Testing", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/test-package", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/scope-a-b", "c"): Explicit, }, - "command": "echo Task b#c in scope-a", - "cwd": "/packages/scope-a", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/scope-a-b", - "task_name": "c" - }, - "command": "echo Task c in scope-a#b", - "cwd": "/packages/scope-a-b", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/test-package", - "task_name": "test" - }, - "command": "echo Testing", - "cwd": "/packages/test-package", - "depends_on": [ - [ - { - "package_dir": "/packages/scope-a-b", - "task_name": "c" - }, - "Explicit" - ] - ] - } -] + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap index 299930c8..6a038f96 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap @@ -1,33 +1,143 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit --- -[ - { - "id": { - "package_dir": "/packages/a", - "task_name": "build" +{ + ("/packages/a", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + resolved_config: ResolvedTaskConfig( + command: "build a", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/a", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/b", "build"): Both, }, - "command": "build a", - "cwd": "/packages/a", - "depends_on": [ - [ - { - "package_dir": "/packages/b", - "task_name": "build" - }, - "Both" - ] - ] - }, - { - "id": { - "package_dir": "/packages/b", - "task_name": "build" - }, - "command": "build b", - "cwd": "/packages/b", - "depends_on": [] - } -] + ), + ("/packages/b", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/b", + task_name: "build", + package_path: "/packages/b", + ), + resolved_config: ResolvedTaskConfig( + command: "build b", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/b", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap index 3e4c3367..8b26ae99 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap @@ -1,141 +1,571 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/empty-package-test --- -[ - { - "id": { - "package_dir": "/packages/another-empty", - "task_name": "build" +{ + ("/packages/another-empty", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "build", + package_path: "/packages/another-empty", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building another-empty package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/another-empty", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/another-empty", "lint"): Explicit, + ("/packages/normal-package", "build"): Topological, + ("/packages/normal-package", "test"): Explicit, }, - "command": "echo 'Building another-empty package'", - "cwd": "/packages/another-empty", - "depends_on": [ - [ - { - "package_dir": "/packages/another-empty", - "task_name": "lint" - }, - "Explicit" - ], - [ - { - "package_dir": "/packages/normal-package", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/normal-package", - "task_name": "test" - }, - "Explicit" - ] - ] - }, - { - "id": { - "package_dir": "/packages/another-empty", - "task_name": "deploy" + ), + ("/packages/another-empty", "deploy"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "deploy", + package_path: "/packages/another-empty", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Deploying another-empty package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/another-empty", + cache_config: None, + ), + ), + ), + neighbors: { + ("/packages/another-empty", "build"): Explicit, + ("/packages/another-empty", "test"): Explicit, }, - "command": "echo 'Deploying another-empty package'", - "cwd": "/packages/another-empty", - "depends_on": [ - [ - { - "package_dir": "/packages/another-empty", - "task_name": "build" - }, - "Explicit" - ], - [ - { - "package_dir": "/packages/another-empty", - "task_name": "test" - }, - "Explicit" - ] - ] - }, - { - "id": { - "package_dir": "/packages/another-empty", - "task_name": "lint" + ), + ("/packages/another-empty", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "lint", + package_path: "/packages/another-empty", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Linting another-empty package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/another-empty", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/another-empty", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "test", + package_path: "/packages/another-empty", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing another-empty package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/another-empty", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/normal-package", "test"): Topological, }, - "command": "echo 'Linting another-empty package'", - "cwd": "/packages/another-empty", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/another-empty", - "task_name": "test" + ), + ("/packages/empty-name", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "build", + package_path: "/packages/empty-name", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building empty-name package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/empty-name", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/empty-name", "test"): Explicit, }, - "command": "echo 'Testing another-empty package'", - "cwd": "/packages/another-empty", - "depends_on": [ - [ - { - "package_dir": "/packages/normal-package", - "task_name": "test" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/empty-name", - "task_name": "build" - }, - "command": "echo 'Building empty-name package'", - "cwd": "/packages/empty-name", - "depends_on": [ - [ - { - "package_dir": "/packages/empty-name", - "task_name": "test" - }, - "Explicit" - ] - ] - }, - { - "id": { - "package_dir": "/packages/empty-name", - "task_name": "lint" - }, - "command": "echo 'Linting empty-name package'", - "cwd": "/packages/empty-name", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/empty-name", - "task_name": "test" - }, - "command": "echo 'Testing empty-name package'", - "cwd": "/packages/empty-name", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/normal-package", - "task_name": "build" - }, - "command": "echo 'Building normal-package'", - "cwd": "/packages/normal-package", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/normal-package", - "task_name": "test" - }, - "command": "echo 'Testing normal-package'", - "cwd": "/packages/normal-package", - "depends_on": [] - } -] + ), + ("/packages/empty-name", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "lint", + package_path: "/packages/empty-name", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Linting empty-name package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/empty-name", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/empty-name", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "test", + package_path: "/packages/empty-name", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing empty-name package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/empty-name", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/normal-package", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "normal-package", + task_name: "build", + package_path: "/packages/normal-package", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building normal-package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/normal-package", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/normal-package", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "normal-package", + task_name: "test", + package_path: "/packages/normal-package", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing normal-package\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/normal-package", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap index 0b4a9662..ffc4720f 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap @@ -1,190 +1,712 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace --- -[ - { - "id": { - "package_dir": "/packages/app", - "task_name": "build" +{ + ("/packages/app", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "build", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building @test/app\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/utils", "build"): Topological, }, - "command": "echo 'Building @test/app'", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/utils", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "deploy" + ), + ("/packages/app", "deploy"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "deploy", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "deploy-script --prod", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: None, + ), + ), + ), + neighbors: { + ("/packages/app", "build"): Explicit, + ("/packages/app", "test"): Explicit, + ("/packages/utils", "lint"): Explicit, }, - "command": "deploy-script --prod", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/app", - "task_name": "build" - }, - "Explicit" - ], - [ - { - "package_dir": "/packages/app", - "task_name": "test" - }, - "Explicit" - ], - [ - { - "package_dir": "/packages/utils", - "task_name": "lint" - }, - "Explicit" - ] - ] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "start" + ), + ("/packages/app", "start"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "start", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Starting @test/app\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/app", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "test", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing @test/app\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/utils", "test"): Topological, }, - "command": "echo 'Starting @test/app'", - "cwd": "/packages/app", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "test" + ), + ("/packages/core", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/core", + task_name: "build", + package_path: "/packages/core", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building @test/core\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/core", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/core", "clean"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/core", + task_name: "clean", + package_path: "/packages/core", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Cleaning @test/core\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/core", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/core", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/core", + task_name: "lint", + package_path: "/packages/core", + ), + resolved_config: ResolvedTaskConfig( + command: "eslint src", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/core", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/core", "clean"): Explicit, }, - "command": "echo 'Testing @test/app'", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/utils", - "task_name": "test" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/core", - "task_name": "build" + ), + ("/packages/core", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/core", + task_name: "test", + package_path: "/packages/core", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing @test/core\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/core", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/utils", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/utils", + task_name: "build", + package_path: "/packages/utils", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building @test/utils\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/utils", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/core", "build"): Topological, }, - "command": "echo 'Building @test/core'", - "cwd": "/packages/core", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/core", - "task_name": "clean" + ), + ("/packages/utils", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/utils", + task_name: "lint", + package_path: "/packages/utils", + ), + resolved_config: ResolvedTaskConfig( + command: "eslint src", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/utils", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/core", "build"): Explicit, + ("/packages/core", "lint"): Topological, + ("/packages/utils", "build"): Explicit, }, - "command": "echo 'Cleaning @test/core'", - "cwd": "/packages/core", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/core", - "task_name": "lint" + ), + ("/packages/utils", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/utils", + task_name: "test", + package_path: "/packages/utils", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing @test/utils\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/utils", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/core", "test"): Topological, }, - "command": "eslint src", - "cwd": "/packages/core", - "depends_on": [ - [ - { - "package_dir": "/packages/core", - "task_name": "clean" - }, - "Explicit" - ] - ] - }, - { - "id": { - "package_dir": "/packages/core", - "task_name": "test" - }, - "command": "echo 'Testing @test/core'", - "cwd": "/packages/core", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/utils", - "task_name": "build" - }, - "command": "echo 'Building @test/utils'", - "cwd": "/packages/utils", - "depends_on": [ - [ - { - "package_dir": "/packages/core", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/utils", - "task_name": "lint" - }, - "command": "eslint src", - "cwd": "/packages/utils", - "depends_on": [ - [ - { - "package_dir": "/packages/core", - "task_name": "build" - }, - "Explicit" - ], - [ - { - "package_dir": "/packages/core", - "task_name": "lint" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/utils", - "task_name": "build" - }, - "Explicit" - ] - ] - }, - { - "id": { - "package_dir": "/packages/utils", - "task_name": "test" - }, - "command": "echo 'Testing @test/utils'", - "cwd": "/packages/utils", - "depends_on": [ - [ - { - "package_dir": "/packages/core", - "task_name": "test" - }, - "Topological" - ] - ] - } -] + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap index 9c20d569..d9c25d0e 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap @@ -1,16 +1,74 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test --- -[ - { - "id": { - "package_dir": "/", - "task_name": "create-files" - }, - "command": "mkdir -p node_modules/pkg-a && echo '{\"name\":\"pkg-a\"}' > node_modules/pkg-a/package.json && echo 'content' > node_modules/pkg-a/index.js && mkdir -p dist && echo 'output' > dist/bundle.js", - "cwd": "/", - "depends_on": [] - } -] +{ + ("/", "create-files"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/fingerprint-ignore", + task_name: "create-files", + package_path: "/", + ), + resolved_config: ResolvedTaskConfig( + command: "mkdir -p node_modules/pkg-a && echo \'{\"name\":\"pkg-a\"}\' > node_modules/pkg-a/package.json && echo \'content\' > node_modules/pkg-a/index.js && mkdir -p dist && echo \'output\' > dist/bundle.js", + resolved_options: ResolvedTaskOptions( + cwd: "/", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap index c9f7c13b..080856fa 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap @@ -1,126 +1,554 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace --- -[ - { - "id": { - "package_dir": "/apps/web", - "task_name": "build" +{ + ("/apps/web", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/web", + task_name: "build", + package_path: "/apps/web", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building @test/web\'", + resolved_options: ResolvedTaskOptions( + cwd: "/apps/web", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/app", "build"): Topological, + ("/packages/core", "build"): Topological, }, - "command": "echo 'Building @test/web'", - "cwd": "/apps/web", - "depends_on": [ - [ - { - "package_dir": "/packages/app", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/core", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/apps/web", - "task_name": "dev" + ), + ("/apps/web", "dev"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/web", + task_name: "dev", + package_path: "/apps/web", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Running @test/web in dev mode\'", + resolved_options: ResolvedTaskOptions( + cwd: "/apps/web", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/app", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "build", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building @test/app\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/utils", "build"): Topological, }, - "command": "echo 'Running @test/web in dev mode'", - "cwd": "/apps/web", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "build" + ), + ("/packages/app", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/app", + task_name: "test", + package_path: "/packages/app", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing @test/app\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/app", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/utils", "test"): Topological, }, - "command": "echo 'Building @test/app'", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/utils", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/app", - "task_name": "test" + ), + ("/packages/core", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/core", + task_name: "build", + package_path: "/packages/core", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Building @test/core\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/core", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/core", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/core", + task_name: "test", + package_path: "/packages/core", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing @test/core\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/core", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/utils", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/utils", + task_name: "build", + package_path: "/packages/utils", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Preparing @test/utils\' && echo \'Building @test/utils\' && echo \'Done @test/utils\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/utils", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/core", "build"): Topological, }, - "command": "echo 'Testing @test/app'", - "cwd": "/packages/app", - "depends_on": [ - [ - { - "package_dir": "/packages/utils", - "task_name": "test" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/core", - "task_name": "build" + ), + ("/packages/utils", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/utils", + task_name: "test", + package_path: "/packages/utils", + ), + resolved_config: ResolvedTaskConfig( + command: "echo \'Testing @test/utils\'", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/utils", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/core", "test"): Topological, }, - "command": "echo 'Building @test/core'", - "cwd": "/packages/core", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/core", - "task_name": "test" - }, - "command": "echo 'Testing @test/core'", - "cwd": "/packages/core", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/utils", - "task_name": "build" - }, - "command": "echo 'Preparing @test/utils' && echo 'Building @test/utils' && echo 'Done @test/utils'", - "cwd": "/packages/utils", - "depends_on": [ - [ - { - "package_dir": "/packages/core", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/utils", - "task_name": "test" - }, - "command": "echo 'Testing @test/utils'", - "cwd": "/packages/utils", - "depends_on": [ - [ - { - "package_dir": "/packages/core", - "task_name": "test" - }, - "Topological" - ] - ] - } -] + ), +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap index f2b82e50..95e52c58 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap @@ -1,108 +1,484 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_snapshot +expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "id": { - "package_dir": "/packages/a", - "task_name": "build" +{ + ("/packages/a", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Building A", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/a", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/a", "test"): Explicit, + ("/packages/b2", "build"): Topological, + ("/packages/c", "build"): Topological, }, - "command": "echo Building A", - "cwd": "/packages/a", - "depends_on": [ - [ - { - "package_dir": "/packages/a", - "task_name": "test" - }, - "Explicit" - ], - [ - { - "package_dir": "/packages/b2", - "task_name": "build" - }, - "Topological" - ], - [ - { - "package_dir": "/packages/c", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/a", - "task_name": "test" + ), + ("/packages/a", "test"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "test", + package_path: "/packages/a", + ), + resolved_config: ResolvedTaskConfig( + command: "echo test a", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/a", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/another-a", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/another-a", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Building another A", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/another-a", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/b1", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/b1", + task_name: "lint", + package_path: "/packages/b1", + ), + resolved_config: ResolvedTaskConfig( + command: "echo lint b1", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/b1", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/c", "lint"): Topological, }, - "command": "echo test a", - "cwd": "/packages/a", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/another-a", - "task_name": "build" + ), + ("/packages/b2", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/b2", + task_name: "build", + package_path: "/packages/b2", + ), + resolved_config: ResolvedTaskConfig( + command: "echo build b2", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/b2", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: { + ("/packages/c", "build"): Topological, }, - "command": "echo Building another A", - "cwd": "/packages/another-a", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/b1", - "task_name": "lint" - }, - "command": "echo lint b1", - "cwd": "/packages/b1", - "depends_on": [ - [ - { - "package_dir": "/packages/c", - "task_name": "lint" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/b2", - "task_name": "build" - }, - "command": "echo build b2", - "cwd": "/packages/b2", - "depends_on": [ - [ - { - "package_dir": "/packages/c", - "task_name": "build" - }, - "Topological" - ] - ] - }, - { - "id": { - "package_dir": "/packages/c", - "task_name": "build" - }, - "command": "echo Building C", - "cwd": "/packages/c", - "depends_on": [] - }, - { - "id": { - "package_dir": "/packages/c", - "task_name": "lint" - }, - "command": "echo lint c", - "cwd": "/packages/c", - "depends_on": [] - } -] + ), + ("/packages/c", "build"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "build", + package_path: "/packages/c", + ), + resolved_config: ResolvedTaskConfig( + command: "echo Building C", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/c", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), + ("/packages/c", "lint"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "lint", + package_path: "/packages/c", + ), + resolved_config: ResolvedTaskConfig( + command: "echo lint c", + resolved_options: ResolvedTaskOptions( + cwd: "/packages/c", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), +} diff --git a/crates/vite_task_graph/Cargo.toml b/crates/vite_task_graph/Cargo.toml index 9df01208..cc1a8933 100644 --- a/crates/vite_task_graph/Cargo.toml +++ b/crates/vite_task_graph/Cargo.toml @@ -17,6 +17,7 @@ serde_json = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs"] } vec1 = { workspace = true, features = ["smallvec-v1"] } +vite_graph_ser = { workspace = true } vite_path = { workspace = true } vite_str = { workspace = true } vite_workspace = { workspace = true } diff --git a/crates/vite_task_graph/src/config/mod.rs b/crates/vite_task_graph/src/config/mod.rs index 67833360..91fad00a 100644 --- a/crates/vite_task_graph/src/config/mod.rs +++ b/crates/vite_task_graph/src/config/mod.rs @@ -3,6 +3,7 @@ pub mod user; use std::{collections::HashSet, sync::Arc}; use monostate::MustBe; +use serde::Serialize; pub use user::{UserCacheConfig, UserConfigFile, UserTaskConfig}; use vite_path::AbsolutePath; use vite_str::Str; @@ -19,7 +20,7 @@ use crate::config::user::UserTaskOptions; /// but `command` is not parsed into program and args yet because environment variables in it may need to be expanded. /// /// `depends_on` is not included here because it's represented by the edges of the task graph. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ResolvedTaskConfig { /// The command to run for this task, as a raw string. /// @@ -29,7 +30,7 @@ pub struct ResolvedTaskConfig { pub resolved_options: ResolvedTaskOptions, } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ResolvedTaskOptions { /// The working directory for the task pub cwd: Arc, @@ -61,12 +62,12 @@ impl ResolvedTaskOptions { } } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct CacheConfig { pub env_config: EnvConfig, } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct EnvConfig { /// environment variable names to be fingerprinted and passed to the task, with defaults populated pub fingerprinted_envs: HashSet, diff --git a/crates/vite_task_graph/src/lib.rs b/crates/vite_task_graph/src/lib.rs index 5c9d2578..297bbc7c 100644 --- a/crates/vite_task_graph/src/lib.rs +++ b/crates/vite_task_graph/src/lib.rs @@ -18,6 +18,7 @@ use petgraph::{ visit::{Control, DfsEvent, depth_first_search}, }; use serde::Serialize; +use serde_json::map::Keys; pub use specifier::TaskSpecifier; use vec1::smallvec_v1::SmallVec1; use vite_path::AbsolutePath; @@ -53,12 +54,10 @@ impl TaskDependencyType { } } -/// Uniquely identifies a task, by its name and the path where it's defined. +/// Uniquely identifies a task, by its name and the package where it's defined. #[derive(Debug, PartialEq, Eq, Hash, Clone, PartialOrd, Ord)] struct TaskId { - /// This is the index of the package where the task is defined. - /// - /// `package_index` is declared before `task_name` to make the `PartialOrd` implementation group tasks in same packages together. + /// The index of the package where the task is defined. pub package_index: PackageNodeIndex, /// The name of the script or the entry in `vite.config.*`. @@ -66,7 +65,7 @@ struct TaskId { } /// A node in the task graph, representing a task with its resolved configuration. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct TaskNode { /// Printing the task in a human-readable way. pub task_display: TaskDisplay, @@ -80,6 +79,14 @@ pub struct TaskNode { pub resolved_config: ResolvedTaskConfig, } +impl vite_graph_ser::GetKey for TaskNode { + type Key<'a> = (&'a AbsolutePath, &'a str); + + fn key(&self) -> Result, String> { + Ok((&self.task_display.package_path, &self.task_display.task_name)) + } +} + #[derive(Debug, thiserror::Error)] pub enum TaskGraphLoadError { #[error("Failed to load package graph: {0}")] @@ -137,7 +144,7 @@ pub enum SpecifierLookupError { } /// newtype of `DefaultIx` for indices in task graphs -#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct TaskIx(DefaultIx); unsafe impl IndexType for TaskIx { fn new(x: usize) -> Self { From 87e1f388faa9eccd1f2de57877b37610a0af0cf9 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sat, 3 Jan 2026 07:57:36 +0800 Subject: [PATCH 14/27] update snapshot tests --- crates/vite_graph_ser/src/lib.rs | 4 +- crates/vite_task/src/session/mod.rs | 6 + crates/vite_task_bin/src/lib.rs | 19 ++- crates/vite_task_bin/src/main.rs | 13 +- .../{cli-queries.toml => snapshots.toml} | 22 ++-- crates/vite_task_bin/tests/snapshots.rs | 121 ++++++++++-------- 6 files changed, 107 insertions(+), 78 deletions(-) rename crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/{cli-queries.toml => snapshots.toml} (89%) diff --git a/crates/vite_graph_ser/src/lib.rs b/crates/vite_graph_ser/src/lib.rs index b3718060..a8a9f299 100644 --- a/crates/vite_graph_ser/src/lib.rs +++ b/crates/vite_graph_ser/src/lib.rs @@ -1,10 +1,10 @@ -use std::{collections::BTreeMap, fmt::Display}; +use std::collections::BTreeMap; use petgraph::{ graph::DiGraph, visit::{EdgeRef as _, IntoNodeReferences}, }; -use serde::{Serialize, Serializer, ser::SerializeMap}; +use serde::{Serialize, Serializer}; /// Trait for getting a unique key for a node in the graph. /// This key is used for serializing the graph with `serialize_by_key`. diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index 20f0be1a..0da89c0e 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -154,6 +154,12 @@ impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { Self::init_with(envs, vite_path::current_dir()?.into(), callbacks) } + pub async fn ensure_task_graph_loaded( + &mut self, + ) -> Result<&IndexedTaskGraph, TaskGraphLoadError> { + self.lazy_task_graph.load_task_graph().await + } + /// Initialize a session with custom cwd, environment variables. Useful for testing. pub fn init_with( envs: HashMap, Arc>, diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs index e1e2f297..95e56220 100644 --- a/crates/vite_task_bin/src/lib.rs +++ b/crates/vite_task_bin/src/lib.rs @@ -24,8 +24,8 @@ pub enum NonTaskSubcommand { Version, } -#[derive(Debug)] -pub struct TaskSynthesizer; +#[derive(Debug, Default)] +pub struct TaskSynthesizer(()); fn find_executable_in_node_modules_bin( cwd: &AbsolutePath, @@ -71,3 +71,18 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { } } } + +#[derive(Default)] +pub struct OwnedSessionCallbacks { + task_synthesizer: TaskSynthesizer, + user_config_loader: vite_task::loader::JsonUserConfigLoader, +} + +impl OwnedSessionCallbacks { + pub fn as_callbacks(&mut self) -> SessionCallbacks<'_, CustomTaskSubcommand> { + SessionCallbacks { + task_synthesizer: &mut self.task_synthesizer, + user_config_loader: &mut self.user_config_loader, + } + } +} diff --git a/crates/vite_task_bin/src/main.rs b/crates/vite_task_bin/src/main.rs index ff2b8a8f..e457424c 100644 --- a/crates/vite_task_bin/src/main.rs +++ b/crates/vite_task_bin/src/main.rs @@ -2,7 +2,9 @@ use std::{env, sync::Arc}; use vite_path::{AbsolutePath, current_dir}; use vite_task::{CLIArgs, Session, SessionCallbacks}; -use vite_task_bin::{CustomTaskSubcommand, NonTaskSubcommand, TaskSynthesizer}; +use vite_task_bin::{ + CustomTaskSubcommand, NonTaskSubcommand, OwnedSessionCallbacks, TaskSynthesizer, +}; #[tokio::main] async fn main() -> anyhow::Result<()> { @@ -24,13 +26,8 @@ async fn main() -> anyhow::Result<()> { } }; - let mut task_synthesizer = TaskSynthesizer; - let mut config_loader = vite_task::loader::JsonUserConfigLoader::default(); - let mut session = Session::init(SessionCallbacks { - task_synthesizer: &mut task_synthesizer, - user_config_loader: &mut config_loader, - })?; - + let mut owned_callbacks = OwnedSessionCallbacks::default(); + let mut session = Session::init(owned_callbacks.as_callbacks())?; let plan = session.plan(cwd, task_cli_args).await?; dbg!(plan); diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/cli-queries.toml b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml similarity index 89% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/cli-queries.toml rename to crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml index 41491249..67e0e8ac 100644 --- a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/cli-queries.toml +++ b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml @@ -1,54 +1,54 @@ -[[query]] +[[plan]] name = "simple task by name" cwd = "packages/a" args = ["build"] -[[query]] +[[plan]] name = "under subfolder of package" cwd = "packages/a/src" args = ["build"] -[[query]] +[[plan]] name = "explicit package name under different package" cwd = "packages/a" args = ["@test/c#build"] -[[query]] +[[plan]] name = "explicit package name under non-package cwd" cwd = "" args = ["@test/c#build"] -[[query]] +[[plan]] name = "ambiguous task name" cwd = "" args = ["@test/a#build"] -[[query]] +[[plan]] name = "ignore depends on" cwd = "packages/a" args = ["--ignore-depends-on", "build"] -[[query]] +[[plan]] name = "transitive" cwd = "packages/a" args = ["--transitive", "build"] -[[query]] +[[plan]] name = "transitive in package without the task" cwd = "packages/a" args = ["--transitive", "lint"] -[[query]] +[[plan]] name = "transitive non existent task" cwd = "packages/a" args = ["--transitive", "non-existent-task"] -[[query]] +[[plan]] name = "recursive" cwd = "" args = ["--recursive", "build"] -[[query]] +[[plan]] name = "recursive and transitive" cwd = "" args = ["--recursive", "--transitive", "build"] diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index a155e9aa..4f03c616 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -8,6 +8,7 @@ use petgraph::visit::EdgeRef as _; use tokio::runtime::Runtime; use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; use vite_str::Str; +use vite_task::Session; use vite_task_graph::{ IndexedTaskGraph, TaskDependencyType, TaskNodeIndex, loader::JsonUserConfigLoader, @@ -80,97 +81,107 @@ fn snapshot_task_graph(indexed_task_graph: &IndexedTaskGraph) -> impl serde::Ser node_snapshots } -#[derive(serde::Deserialize)] -struct CLIQuery { +#[derive(serde::Deserialize, Debug)] +struct Plan { pub name: Str, pub args: Vec, pub cwd: RelativePathBuf, } +#[derive(serde::Deserialize, Debug)] +struct E2e { + pub steps: Vec, +} + #[derive(serde::Deserialize, Default)] -struct CLIQueriesFile { - #[serde(rename = "query")] // toml usually uses singular for arrays - pub queries: Vec, +struct PlansFile { + #[serde(rename = "plan", default)] // toml usually uses singular for arrays + pub plans: Vec, + #[serde(rename = "e2e", default)] // toml usually uses singular for arrays + pub e2es: Vec, } -fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, case_path: &Path) { - let case_name = case_path.file_name().unwrap().to_str().unwrap(); - if case_name.starts_with(".") { +fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { + let fixture_name = fixture_path.file_name().unwrap().to_str().unwrap(); + if fixture_name.starts_with(".") { return; // skip hidden files like .DS_Store } // Copy the case directory to a temporary directory to avoid discovering workspace outside of the test case. - let case_stage_path = tmpdir.join(case_name); - copy_dir(case_path, &case_stage_path).unwrap(); + let stage_path = tmpdir.join(fixture_name); + copy_dir(fixture_path, &stage_path).unwrap(); // let mut settings = insta::Settings::clone_current(); // let case_stage_path_str = case_stage_path.as_path().to_str().expect("path is valid unicode"); // settings.add_filter(®ex::escape(case_stage_path_str), ""); // let _guard = settings.bind_to_scope(); - let (workspace_root, _cwd) = find_workspace_root(&case_stage_path).unwrap(); + let (workspace_root, _cwd) = find_workspace_root(&stage_path).unwrap(); assert_eq!( - &case_stage_path, &*workspace_root.path, + &stage_path, &*workspace_root.path, "folder '{}' should be a workspace root", - case_name + fixture_name ); - let cli_queries_toml_path = case_path.join("cli-queries.toml"); - let cli_queries_file: CLIQueriesFile = match std::fs::read(&cli_queries_toml_path) { + let cases_toml_path = fixture_path.join("snapshots.toml"); + let cases_file: PlansFile = match std::fs::read(&cases_toml_path) { Ok(content) => toml::from_slice(&content).unwrap(), Err(err) if err.kind() == std::io::ErrorKind::NotFound => Default::default(), - Err(err) => panic!("Failed to read cli-queries.toml for case {}: {}", case_name, err), + Err(err) => panic!("Failed to read cases.toml for fixture {}: {}", fixture_name, err), }; runtime.block_on(async { let _redaction_guard = redact_absolute_paths(&workspace_root.path); - let indexed_task_graph = vite_task_graph::IndexedTaskGraph::load( - &workspace_root, - &JsonUserConfigLoader::default(), + let mut owned_callbacks = vite_task_bin::OwnedSessionCallbacks::default(); + let mut session = Session::init_with( + Default::default(), + Arc::clone(&workspace_root.path), + owned_callbacks.as_callbacks(), ) - .await - .expect(&format!("Failed to load task graph for case {case_name}")); + .unwrap(); insta::assert_ron_snapshot!( "task graph", - vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph()) + vite_graph_ser::SerializeByKey( + session.ensure_task_graph_loaded().await.unwrap().task_graph() + ) ); - // for cli_query in cli_queries_file.queries { - // let snapshot_name = format!("query - {}", cli_query.name); - - // let cli_task_query = CLITaskQuery::try_parse_from( - // std::iter::once("vite-run") // dummy program name - // .chain(cli_query.args.iter().map(|s| s.as_str())), - // ) - // .expect(&format!( - // "Failed to parse CLI args for query '{}' in case '{}'", - // cli_query.name, case_name - // )); - - // let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); - // let task_query = match cli_task_query.into_task_query(&cwd) { - // Ok(ok) => ok, - // Err(err) => { - // insta::assert_json_snapshot!(snapshot_name, err); - // continue; - // } - // }; - - // let execution_graph = match indexed_task_graph.query_tasks(task_query) { - // Ok(ok) => ok, - // Err(err) => { - // insta::assert_json_snapshot!(snapshot_name, err); - // continue; - // } - // }; - - // let execution_graph_snapshot = - // snapshot_execution_graph(&execution_graph, &indexed_task_graph); - // insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); - // } + for plan in cases_file.plans { + let snapshot_name = format!("query - {}", plan.name); + + let cli_task_query = CLITaskQuery::try_parse_from( + std::iter::once("vite") // dummy program name + .chain(plan.args.iter().map(|s| s.as_str())), + ) + .expect(&format!( + "Failed to parse CLI args for plan '{}' in '{}'", + plan.name, fixture_name + )); + + // let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); + // let task_query = match cli_task_query.into_task_query(&cwd) { + // Ok(ok) => ok, + // Err(err) => { + // insta::assert_json_snapshot!(snapshot_name, err); + // continue; + // } + // }; + + // let execution_graph = match indexed_task_graph.query_tasks(task_query) { + // Ok(ok) => ok, + // Err(err) => { + // insta::assert_json_snapshot!(snapshot_name, err); + // continue; + // } + // }; + + // let execution_graph_snapshot = + // snapshot_execution_graph(&execution_graph, &indexed_task_graph); + // insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); + } }); } From 6904b8a9b3949131ea40331bfeabf5a99712a017 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sat, 3 Jan 2026 13:59:47 +0800 Subject: [PATCH 15/27] redact absolute path debug --- crates/vite_path/src/absolute/mod.rs | 66 ++++++++++++------- .../snapshots.toml | 22 +++---- crates/vite_task_bin/tests/snapshots.rs | 26 +++++++- ... name@transitive-dependency-workspace.snap | 39 ++++++----- ...itive@transitive-dependency-workspace.snap | 9 ++- ... task@transitive-dependency-workspace.snap | 28 ++++---- 6 files changed, 124 insertions(+), 66 deletions(-) diff --git a/crates/vite_path/src/absolute/mod.rs b/crates/vite_path/src/absolute/mod.rs index 6458fd1b..139976d7 100644 --- a/crates/vite_path/src/absolute/mod.rs +++ b/crates/vite_path/src/absolute/mod.rs @@ -3,7 +3,7 @@ pub mod redaction; use std::{ ffi::OsStr, - fmt::Display, + fmt::{Debug, Display}, hash::Hash, ops::Deref, path::{Path, PathBuf}, @@ -16,7 +16,7 @@ use serde::Serialize; use crate::relative::{FromPathError, InvalidPathDataError, RelativePathBuf}; /// A path that is guaranteed to be absolute -#[derive(RefCastCustom, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[derive(RefCastCustom, PartialEq, Eq, PartialOrd, Ord)] #[repr(transparent)] pub struct AbsolutePath(Path); impl AsRef for AbsolutePath { @@ -25,33 +25,27 @@ impl AsRef for AbsolutePath { } } +impl Debug for AbsolutePath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug_tuple = f.debug_tuple("AbsolutePath"); + + if let Some(redacted_path) = self.try_redact().unwrap() { + debug_tuple.field(&redacted_path); + } else { + debug_tuple.field(&&self.0); + } + debug_tuple.finish() + } +} + impl Serialize for AbsolutePath { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { #[cfg(feature = "absolute-redaction")] - { - use redaction::REDACTION_PREFIX; - - if let Some(redaction_prefix) = REDACTION_PREFIX - .with(|redaction_prefix| redaction_prefix.borrow().as_ref().map(Arc::clone)) - { - match self.strip_prefix(redaction_prefix) { - Ok(Some(stripped_path)) => { - return serializer - .collect_str(&format_args!("/{}", stripped_path.as_str())); - } - Err(strip_error) => { - return Err(serde::ser::Error::custom(format!( - "Failed to redact absolute path '{}': {}", - self.as_path().display(), - strip_error - ))); - } - Ok(None) => { /* continue to serialize full path */ } - } - } + if let Some(redacted_path) = self.try_redact().map_err(serde::ser::Error::custom)? { + return serializer.serialize_str(&redacted_path); } self.as_path().serialize(serializer) } @@ -97,6 +91,30 @@ impl AbsolutePath { if path.is_absolute() { Some(unsafe { Self::assume_absolute(path) }) } else { None } } + #[cfg(feature = "absolute-redaction")] + fn try_redact(&self) -> Result, String> { + use redaction::REDACTION_PREFIX; + + if let Some(redaction_prefix) = REDACTION_PREFIX + .with(|redaction_prefix| redaction_prefix.borrow().as_ref().map(Arc::clone)) + { + match self.strip_prefix(redaction_prefix) { + Ok(Some(stripped_path)) => { + return Ok(Some(format!("/{}", stripped_path.as_str()))); + } + Err(strip_error) => { + return Err(format!( + "Failed to redact absolute path '{}': {}", + self.as_path().display(), + strip_error + )); + } + Ok(None) => { /* continue to serialize full path */ } + } + } + Ok(None) + } + #[ref_cast_custom] pub(crate) unsafe fn assume_absolute(abs_path: &Path) -> &Self; @@ -191,7 +209,7 @@ impl AsRef for AbsolutePath { } /// An owned path buf that is guaranteed to be absolute -#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct AbsolutePathBuf(PathBuf); impl From for Arc { diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml index 67e0e8ac..d038f29b 100644 --- a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml +++ b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml @@ -1,54 +1,54 @@ [[plan]] name = "simple task by name" cwd = "packages/a" -args = ["build"] +args = ["run", "build"] [[plan]] name = "under subfolder of package" cwd = "packages/a/src" -args = ["build"] +args = ["run", "build"] [[plan]] name = "explicit package name under different package" cwd = "packages/a" -args = ["@test/c#build"] +args = ["run", "@test/c#build"] [[plan]] name = "explicit package name under non-package cwd" cwd = "" -args = ["@test/c#build"] +args = ["run", "@test/c#build"] [[plan]] name = "ambiguous task name" cwd = "" -args = ["@test/a#build"] +args = ["run", "@test/a#build"] [[plan]] name = "ignore depends on" cwd = "packages/a" -args = ["--ignore-depends-on", "build"] +args = ["run", "--ignore-depends-on", "build"] [[plan]] name = "transitive" cwd = "packages/a" -args = ["--transitive", "build"] +args = ["run", "--transitive", "build"] [[plan]] name = "transitive in package without the task" cwd = "packages/a" -args = ["--transitive", "lint"] +args = ["run", "--transitive", "lint"] [[plan]] name = "transitive non existent task" cwd = "packages/a" -args = ["--transitive", "non-existent-task"] +args = ["run", "--transitive", "non-existent-task"] [[plan]] name = "recursive" cwd = "" -args = ["--recursive", "build"] +args = ["run", "--recursive", "build"] [[plan]] name = "recursive and transitive" cwd = "" -args = ["--recursive", "--transitive", "build"] +args = ["run", "--recursive", "--transitive", "build"] diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index 4f03c616..7a9f9fdf 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -1,5 +1,5 @@ use core::panic; -use std::{path::Path, sync::Arc}; +use std::{convert::Infallible, path::Path, sync::Arc}; use clap::Parser; use copy_dir::copy_dir; @@ -8,7 +8,8 @@ use petgraph::visit::EdgeRef as _; use tokio::runtime::Runtime; use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; use vite_str::Str; -use vite_task::Session; +use vite_task::{CLIArgs, Session}; +use vite_task_bin::CustomTaskSubcommand; use vite_task_graph::{ IndexedTaskGraph, TaskDependencyType, TaskNodeIndex, loader::JsonUserConfigLoader, @@ -152,7 +153,7 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { for plan in cases_file.plans { let snapshot_name = format!("query - {}", plan.name); - let cli_task_query = CLITaskQuery::try_parse_from( + let cli_args = CLIArgs::::try_parse_from( std::iter::once("vite") // dummy program name .chain(plan.args.iter().map(|s| s.as_str())), ) @@ -161,6 +162,25 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { plan.name, fixture_name )); + let task_cli_args = match cli_args { + CLIArgs::Task(task_cli_args) => task_cli_args, + CLIArgs::NonTask(never) => match never {}, + }; + + let plan_result = + session.plan(workspace_root.path.join(plan.cwd).into(), task_cli_args).await; + + match plan_result { + Ok(plan) => { + // let task_graph_snapshot = + // snapshot_task_graph(&plan.indexed_task_graph); + // insta::assert_json_snapshot!(snapshot_name, task_graph_snapshot); + } + Err(err) => { + insta::assert_debug_snapshot!(snapshot_name, err); + } + } + // let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); // let task_query = match cli_task_query.into_task_query(&cwd) { // Ok(ok) => ok, diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap index 6619d365..d4a46c7a 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap @@ -3,20 +3,29 @@ source: crates/vite_task_bin/tests/snapshots.rs expression: err input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -{ - "SpecifierLookupError": { - "specifier": { - "package_name": "@test/a", - "task_name": "build" +Error { + task_call_stack: TaskCallStackDisplay { + frames: [], }, - "lookup_error": { - "AmbiguousPackageName": { - "package_name": "@test/a", - "package_paths": [ - "/packages/a", - "/packages/another-a" - ] - } - } - } + kind: TaskQueryError( + SpecifierLookupError { + specifier: TaskSpecifier { + package_name: Some( + "@test/a", + ), + task_name: "build", + }, + lookup_error: AmbiguousPackageName { + package_name: "@test/a", + package_paths: [ + AbsolutePath( + "/packages/a", + ), + AbsolutePath( + "/packages/another-a", + ), + ], + }, + }, + ), } diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap index 18b0f3a3..3114fa95 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap @@ -3,4 +3,11 @@ source: crates/vite_task_bin/tests/snapshots.rs expression: err input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -"RecursiveTransitiveConflict" +Error { + task_call_stack: TaskCallStackDisplay { + frames: [], + }, + kind: ParsePlanRequestError { + error: RecursiveTransitiveConflict, + }, +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap index e269c0a5..7e634ea3 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap @@ -3,17 +3,21 @@ source: crates/vite_task_bin/tests/snapshots.rs expression: err input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -{ - "SpecifierLookupError": { - "specifier": { - "package_name": null, - "task_name": "non-existent-task" +Error { + task_call_stack: TaskCallStackDisplay { + frames: [], }, - "lookup_error": { - "TaskNameNotFound": { - "package_name": "@test/a", - "task_name": "non-existent-task" - } - } - } + kind: TaskQueryError( + SpecifierLookupError { + specifier: TaskSpecifier { + package_name: None, + task_name: "non-existent-task", + }, + lookup_error: TaskNameNotFound { + package_name: "@test/a", + task_name: "non-existent-task", + package_index: NodeIndex(PackageIx(0)), + }, + }, + ), } From 1f685eb7a50c9e64c2929f0517e5f5c12b5d3878 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 00:56:00 +0800 Subject: [PATCH 16/27] update plan snapshots --- Cargo.lock | 1 + crates/vite_task/src/session/mod.rs | 3 +- crates/vite_task_bin/tests/snapshots.rs | 12 +- ...ckage@transitive-dependency-workspace.snap | 51 +++- ...e cwd@transitive-dependency-workspace.snap | 51 +++- ...ds on@transitive-dependency-workspace.snap | 52 ++++- ...rsive@transitive-dependency-workspace.snap | 221 +++++++++++++----- ... name@transitive-dependency-workspace.snap | 94 ++++++-- ... task@transitive-dependency-workspace.snap | 95 ++++++-- ...itive@transitive-dependency-workspace.snap | 184 +++++++++++---- ...ckage@transitive-dependency-workspace.snap | 94 ++++++-- crates/vite_task_plan/Cargo.toml | 1 + crates/vite_task_plan/src/in_process.rs | 5 +- crates/vite_task_plan/src/lib.rs | 26 ++- 14 files changed, 671 insertions(+), 219 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcc55e95..4cdf92f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3361,6 +3361,7 @@ dependencies = [ "thiserror 2.0.17", "tracing", "vite_glob", + "vite_graph_ser", "vite_path", "vite_shell", "vite_str", diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index 0da89c0e..2b318a76 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -6,6 +6,7 @@ use std::{ffi::OsStr, fmt::Debug, sync::Arc}; use cache::ExecutionCache; use clap::{Parser, Subcommand}; +use serde::Serialize; use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskGraph, TaskGraphLoadError, loader::UserConfigLoader}; @@ -202,7 +203,7 @@ impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { } /// Represents a planned execution of tasks in a session, including information for caching. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct SessionExecutionPlan { /// The original command-line arguments used to create this execution plan, excluding the program name. /// diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index 7a9f9fdf..1422b281 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -170,16 +170,14 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { let plan_result = session.plan(workspace_root.path.join(plan.cwd).into(), task_cli_args).await; - match plan_result { - Ok(plan) => { - // let task_graph_snapshot = - // snapshot_task_graph(&plan.indexed_task_graph); - // insta::assert_json_snapshot!(snapshot_name, task_graph_snapshot); - } + let plan = match plan_result { + Ok(plan) => plan, Err(err) => { insta::assert_debug_snapshot!(snapshot_name, err); + continue; } - } + }; + insta::assert_ron_snapshot!(snapshot_name, &plan); // let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); // let task_query = match cli_task_query.into_task_query(&cwd) { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap index 4077dfa7..184d2e7f 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap @@ -1,14 +1,45 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/c", - "task_name": "build" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "@test/c#build", + ], + cwd: "/packages/a", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/c", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "build", + package_path: "/packages/c", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "C", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap index 4077dfa7..f92d2276 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap @@ -1,14 +1,45 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/c", - "task_name": "build" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "@test/c#build", + ], + cwd: "/", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/c", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "build", + package_path: "/packages/c", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "C", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap index 5a93d142..503d5a75 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap @@ -1,14 +1,46 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/a", - "task_name": "build" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "--ignore-depends-on", + "build", + ], + cwd: "/packages/a", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/a", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "A", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap index 0b2fcd86..369405df 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap @@ -1,60 +1,169 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/a", - "task_name": "build" - }, - "deps": [ - { - "package_dir": "/packages/a", - "task_name": "test" - }, - { - "package_dir": "/packages/b2", - "task_name": "build" - }, - { - "package_dir": "/packages/c", - "task_name": "build" - } - ] - }, - { - "task": { - "package_dir": "/packages/a", - "task_name": "test" - }, - "deps": [] - }, - { - "task": { - "package_dir": "/packages/another-a", - "task_name": "build" - }, - "deps": [] - }, - { - "task": { - "package_dir": "/packages/b2", - "task_name": "build" - }, - "deps": [ - { - "package_dir": "/packages/c", - "task_name": "build" - } - ] - }, - { - "task": { - "package_dir": "/packages/c", - "task_name": "build" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "--recursive", + "build", + ], + cwd: "/", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/a", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "A", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/a", "test"): (), + ("/packages/b2", "build"): (), + ("/packages/c", "build"): (), + }, + ), + ("/packages/a", "test"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "test", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 11, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "test", + "a", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + ("/packages/another-a", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/another-a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 23, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "another", + "A", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + ("/packages/b2", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/b2", + task_name: "build", + package_path: "/packages/b2", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 13, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "build", + "b2", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/c", "build"): (), + }, + ), + ("/packages/c", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "build", + package_path: "/packages/c", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "C", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap index eafdcb21..2249a1ad 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap @@ -1,26 +1,76 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/a", - "task_name": "build" - }, - "deps": [ - { - "package_dir": "/packages/a", - "task_name": "test" - } - ] - }, - { - "task": { - "package_dir": "/packages/a", - "task_name": "test" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "build", + ], + cwd: "/packages/a", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/a", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "A", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/a", "test"): (), + }, + ), + ("/packages/a", "test"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "test", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 11, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "test", + "a", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap index 9b176a9c..80a892b5 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap @@ -1,26 +1,77 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/b1", - "task_name": "lint" - }, - "deps": [ - { - "package_dir": "/packages/c", - "task_name": "lint" - } - ] - }, - { - "task": { - "package_dir": "/packages/c", - "task_name": "lint" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "--transitive", + "lint", + ], + cwd: "/packages/a", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/b1", "lint"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/b1", + task_name: "lint", + package_path: "/packages/b1", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 12, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "lint", + "b1", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/c", "lint"): (), + }, + ), + ("/packages/c", "lint"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "lint", + package_path: "/packages/c", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 11, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "lint", + "c", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap index 0baeb31b..09226351 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap @@ -1,53 +1,139 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/a", - "task_name": "build" - }, - "deps": [ - { - "package_dir": "/packages/a", - "task_name": "test" - }, - { - "package_dir": "/packages/b2", - "task_name": "build" - }, - { - "package_dir": "/packages/c", - "task_name": "build" - } - ] - }, - { - "task": { - "package_dir": "/packages/a", - "task_name": "test" - }, - "deps": [] - }, - { - "task": { - "package_dir": "/packages/b2", - "task_name": "build" - }, - "deps": [ - { - "package_dir": "/packages/c", - "task_name": "build" - } - ] - }, - { - "task": { - "package_dir": "/packages/c", - "task_name": "build" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "--transitive", + "build", + ], + cwd: "/packages/a", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/a", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "A", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/a", "test"): (), + ("/packages/b2", "build"): (), + ("/packages/c", "build"): (), + }, + ), + ("/packages/a", "test"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "test", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 11, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "test", + "a", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + ("/packages/b2", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/b2", + task_name: "build", + package_path: "/packages/b2", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 13, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "build", + "b2", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/c", "build"): (), + }, + ), + ("/packages/c", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/c", + task_name: "build", + package_path: "/packages/c", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/packages/a", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "C", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap index eafdcb21..6396c831 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap @@ -1,26 +1,76 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: execution_graph_snapshot +expression: "&plan" input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -[ - { - "task": { - "package_dir": "/packages/a", - "task_name": "build" - }, - "deps": [ - { - "package_dir": "/packages/a", - "task_name": "test" - } - ] - }, - { - "task": { - "package_dir": "/packages/a", - "task_name": "test" - }, - "deps": [] - } -] +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "build", + ], + cwd: "/packages/a/src", + plan: ExecutionPlan( + root_node: Expanded({ + ("/packages/a", "build"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "build", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 15, + ), + extra_args: [], + plan_cwd: "/packages/a/src", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "Building", + "A", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: { + ("/packages/a", "test"): (), + }, + ), + ("/packages/a", "test"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "@test/a", + task_name: "test", + package_path: "/packages/a", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 11, + ), + extra_args: [], + plan_cwd: "/packages/a/src", + kind: Leaf(InProcess(InProcessExecution( + kind: Echo( + strings: [ + "test", + "a", + ], + trailing_newline: true, + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_plan/Cargo.toml b/crates/vite_task_plan/Cargo.toml index b3b59bd3..446e8130 100644 --- a/crates/vite_task_plan/Cargo.toml +++ b/crates/vite_task_plan/Cargo.toml @@ -23,6 +23,7 @@ supports-color = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } vite_glob = { workspace = true } +vite_graph_ser = { workspace = true } vite_path = { workspace = true } vite_shell = { workspace = true } vite_str = { workspace = true } diff --git a/crates/vite_task_plan/src/in_process.rs b/crates/vite_task_plan/src/in_process.rs index c6ed141b..bcb19599 100644 --- a/crates/vite_task_plan/src/in_process.rs +++ b/crates/vite_task_plan/src/in_process.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use serde::Serialize; use vite_path::AbsolutePath; use vite_str::Str; @@ -12,7 +13,7 @@ pub struct InProcessExecutionOutput { } /// An in-process execution item -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct InProcessExecution { kind: InProcessExecutionKind, } @@ -38,7 +39,7 @@ impl InProcessExecution { } /// The kind of an in-process execution. -#[derive(Debug)] +#[derive(Debug, Serialize)] enum InProcessExecutionKind { /// echo command Echo { diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index d7518c86..e286f2e6 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -17,6 +17,8 @@ use execution_graph::ExecutionGraph; use in_process::InProcessExecution; use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; +use serde::Serialize; +use vite_graph_ser::serialize_by_key; use vite_path::AbsolutePath; use vite_str::Str; use vite_task_graph::{TaskGraphLoadError, TaskNodeIndex, display::TaskDisplay}; @@ -26,7 +28,7 @@ use crate::path_env::prepend_path_env; /// A resolved spawn execution. /// Unlike tasks in `vite_task_graph`, this struct contains all information needed for execution, /// like resolved environment variables, current working directory, and additional args from cli. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct SpawnExecution { /// Cache metadata for this execution. `None` means caching is disabled. pub cache_metadata: Option, @@ -36,7 +38,7 @@ pub struct SpawnExecution { } /// All information about a command to be spawned. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct SpawnCommand { /// A program with args to be executed directly pub program_path: Arc, @@ -52,7 +54,7 @@ pub struct SpawnCommand { } /// Represents how a task should be executed. It's the node type for the execution graph. Each node corresponds to a task. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct TaskExecution { /// The task this execution corresponds to pub task_display: TaskDisplay, @@ -63,8 +65,16 @@ pub struct TaskExecution { pub items: Vec, } +impl vite_graph_ser::GetKey for TaskExecution { + type Key<'a> = (&'a AbsolutePath, &'a str); + + fn key(&self) -> Result, String> { + Ok((&self.task_display.package_path, &self.task_display.task_name)) + } +} + /// An execution item, either expanded from a known vite subcommand, or a spawn execution. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ExecutionItem { /// The range of the task command that this execution item is resolved from. /// @@ -94,7 +104,7 @@ pub struct ExecutionItem { } /// The kind of a leaf execution item, which cannot be expanded further. -#[derive(Debug)] +#[derive(Debug, Serialize)] pub enum LeafExecutionKind { /// The execution is a spawn of a child process Spawn(SpawnExecution), @@ -103,10 +113,10 @@ pub enum LeafExecutionKind { } /// An execution item, from a split subcommand in a task's command (`item1 && item2 && ...`). -#[derive(Debug)] +#[derive(Debug, Serialize)] pub enum ExecutionItemKind { /// Expanded from a known vite subcommand, like `vite run ...` or `vite lint`. - Expanded(ExecutionGraph), + Expanded(#[serde(serialize_with = "serialize_by_key")] ExecutionGraph), /// A normal execution that spawns a child process, like `tsc --noEmit`. Leaf(LeafExecutionKind), } @@ -138,7 +148,7 @@ pub trait TaskGraphLoader { ) -> Result<&vite_task_graph::IndexedTaskGraph, TaskGraphLoadError>; } -#[derive(Debug)] +#[derive(Debug, Serialize)] pub struct ExecutionPlan { root_node: ExecutionItemKind, } From 5e0eec69acddafc5c9f0576a70a41b50483e1e00 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 01:55:32 +0800 Subject: [PATCH 17/27] update snapshot tests --- crates/vite_task_bin/tests/bins/README.md | 1 + crates/vite_task_bin/tests/bins/readfile | 2 + crates/vite_task_bin/tests/bins/readfile.cmd | 2 + .../tests/fixtures/cache/package.json | 5 + .../tests/fixtures/cache/snapshots.toml | 3 + .../snapshots.toml | 108 ++++++++-------- crates/vite_task_bin/tests/snapshots.rs | 15 ++- ...ts__query - user task cache key@cache.snap | 117 ++++++++++++++++++ .../snapshots__task graph@cache.snap | 74 +++++++++++ crates/vite_task_plan/src/lib.rs | 28 ++++- crates/vite_task_plan/src/plan.rs | 2 +- 11 files changed, 297 insertions(+), 60 deletions(-) create mode 100644 crates/vite_task_bin/tests/bins/README.md create mode 100755 crates/vite_task_bin/tests/bins/readfile create mode 100644 crates/vite_task_bin/tests/bins/readfile.cmd create mode 100644 crates/vite_task_bin/tests/fixtures/cache/package.json create mode 100644 crates/vite_task_bin/tests/fixtures/cache/snapshots.toml create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap diff --git a/crates/vite_task_bin/tests/bins/README.md b/crates/vite_task_bin/tests/bins/README.md new file mode 100644 index 00000000..12aadd2e --- /dev/null +++ b/crates/vite_task_bin/tests/bins/README.md @@ -0,0 +1 @@ +THis folder contains test binaries used in the tests for vite_task_bin crate. diff --git a/crates/vite_task_bin/tests/bins/readfile b/crates/vite_task_bin/tests/bins/readfile new file mode 100755 index 00000000..c8872e78 --- /dev/null +++ b/crates/vite_task_bin/tests/bins/readfile @@ -0,0 +1,2 @@ +#!/bin/sh +cat $1 diff --git a/crates/vite_task_bin/tests/bins/readfile.cmd b/crates/vite_task_bin/tests/bins/readfile.cmd new file mode 100644 index 00000000..df8df539 --- /dev/null +++ b/crates/vite_task_bin/tests/bins/readfile.cmd @@ -0,0 +1,2 @@ +@echo off +type %1 diff --git a/crates/vite_task_bin/tests/fixtures/cache/package.json b/crates/vite_task_bin/tests/fixtures/cache/package.json new file mode 100644 index 00000000..918238dc --- /dev/null +++ b/crates/vite_task_bin/tests/fixtures/cache/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "hello": "readfile hello.txt" + } +} diff --git a/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml b/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml new file mode 100644 index 00000000..89ab31c3 --- /dev/null +++ b/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml @@ -0,0 +1,3 @@ +[[plan]] +name = "user task cache key" +args = ["run", "hello"] diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml index d038f29b..8a612268 100644 --- a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml +++ b/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml @@ -1,54 +1,54 @@ -[[plan]] -name = "simple task by name" -cwd = "packages/a" -args = ["run", "build"] - -[[plan]] -name = "under subfolder of package" -cwd = "packages/a/src" -args = ["run", "build"] - -[[plan]] -name = "explicit package name under different package" -cwd = "packages/a" -args = ["run", "@test/c#build"] - -[[plan]] -name = "explicit package name under non-package cwd" -cwd = "" -args = ["run", "@test/c#build"] - -[[plan]] -name = "ambiguous task name" -cwd = "" -args = ["run", "@test/a#build"] - -[[plan]] -name = "ignore depends on" -cwd = "packages/a" -args = ["run", "--ignore-depends-on", "build"] - -[[plan]] -name = "transitive" -cwd = "packages/a" -args = ["run", "--transitive", "build"] - -[[plan]] -name = "transitive in package without the task" -cwd = "packages/a" -args = ["run", "--transitive", "lint"] - -[[plan]] -name = "transitive non existent task" -cwd = "packages/a" -args = ["run", "--transitive", "non-existent-task"] - -[[plan]] -name = "recursive" -cwd = "" -args = ["run", "--recursive", "build"] - -[[plan]] -name = "recursive and transitive" -cwd = "" -args = ["run", "--recursive", "--transitive", "build"] +# [[plan]] +# name = "simple task by name" +# cwd = "packages/a" +# args = ["build"] + +# [[plan]] +# name = "under subfolder of package" +# cwd = "packages/a/src" +# args = ["build"] + +# [[plan]] +# name = "explicit package name under different package" +# cwd = "packages/a" +# args = ["@test/c#build"] + +# [[plan]] +# name = "explicit package name under non-package cwd" +# cwd = "" +# args = ["@test/c#build"] + +# [[plan]] +# name = "ambiguous task name" +# cwd = "" +# args = ["@test/a#build"] + +# [[plan]] +# name = "ignore depends on" +# cwd = "packages/a" +# args = ["--ignore-depends-on", "build"] + +# [[plan]] +# name = "transitive" +# cwd = "packages/a" +# args = ["--transitive", "build"] + +# [[plan]] +# name = "transitive in package without the task" +# cwd = "packages/a" +# args = ["--transitive", "lint"] + +# [[plan]] +# name = "transitive non existent task" +# cwd = "packages/a" +# args = ["--transitive", "non-existent-task"] + +# [[plan]] +# name = "recursive" +# cwd = "" +# args = ["--recursive", "build"] + +# [[plan]] +# name = "recursive and transitive" +# cwd = "" +# args = ["--recursive", "--transitive", "build"] diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index 1422b281..faeb3104 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -1,5 +1,5 @@ use core::panic; -use std::{convert::Infallible, path::Path, sync::Arc}; +use std::{collections::HashMap, convert::Infallible, ffi::OsStr, path::Path, sync::Arc}; use clap::Parser; use copy_dir::copy_dir; @@ -86,6 +86,7 @@ fn snapshot_task_graph(indexed_task_graph: &IndexedTaskGraph) -> impl serde::Ser struct Plan { pub name: Str, pub args: Vec, + #[serde(default)] pub cwd: RelativePathBuf, } @@ -132,12 +133,22 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { Err(err) => panic!("Failed to read cases.toml for fixture {}: {}", fixture_name, err), }; + // Add bins to PATH so test programs (such as readfile) in fixtures can be found. + let envs: HashMap, Arc> = [( + Arc::::from(OsStr::new("PATH")), + Arc::::from( + std::env::current_dir().unwrap().join("tests").join("bins").into_os_string(), + ), + )] + .into_iter() + .collect(); + runtime.block_on(async { let _redaction_guard = redact_absolute_paths(&workspace_root.path); let mut owned_callbacks = vite_task_bin::OwnedSessionCallbacks::default(); let mut session = Session::init_with( - Default::default(), + envs, Arc::clone(&workspace_root.path), owned_callbacks.as_callbacks(), ) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap new file mode 100644 index 00000000..63352757 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap @@ -0,0 +1,117 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: "&plan" +input_file: crates/vite_task_bin/tests/fixtures/cache +--- +SessionExecutionPlan( + cli_args_without_program: [ + "run", + "hello", + ], + cwd: "/", + plan: ExecutionPlan( + root_node: Expanded({ + ("/", "hello"): DiGraphValue( + node: TaskExecution( + task_display: TaskDisplay( + package_name: "", + task_name: "hello", + package_path: "/", + ), + items: [ + ExecutionItem( + command_span: Range( + start: 0, + end: 18, + ), + extra_args: [], + plan_cwd: "/", + kind: Leaf(Spawn(SpawnExecution( + cache_metadata: Some(CacheMetadata( + spawn_fingerprint: SpawnFingerprint( + cwd: RelativePathBuf(""), + program_fingerprint: OutsideWorkspace( + program_name: "readfile", + ), + args: [ + "hello.txt", + ], + env_fingerprints: EnvFingerprints( + fingerprinted_envs: {}, + pass_through_env_config: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + fingerprint_ignores: None, + ), + execution_cache_key: ExecutionCacheKey( + kind: UserTask( + task_name: "hello", + and_item_index: 0, + ), + origin_path: RelativePathBuf(""), + ), + )), + spawn_command: SpawnCommand( + program_path: "/Volumes/code/vite-task/crates/vite_task_bin/tests/bins/readfile", + args: [ + "hello.txt", + ], + all_envs: { + "FORCE_COLOR": "3", + "PATH": "/var/folders/v7/bp3pvg2x2n1g07k3q9mv4nb40000gn/T/.tmp5Gy398/cache/node_modules/.bin:/Volumes/code/vite-task/crates/vite_task_bin/tests/bins", + }, + cwd: "/", + ), + ))), + ), + ], + ), + neighbors: {}, + ), + }), + ), +) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap new file mode 100644 index 00000000..ed389697 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap @@ -0,0 +1,74 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: "vite_graph_ser::SerializeByKey(session.ensure_task_graph_loaded().await.unwrap().task_graph())" +input_file: crates/vite_task_bin/tests/fixtures/cache +--- +{ + ("/", "hello"): DiGraphValue( + node: TaskNode( + task_display: TaskDisplay( + package_name: "", + task_name: "hello", + package_path: "/", + ), + resolved_config: ResolvedTaskConfig( + command: "readfile hello.txt", + resolved_options: ResolvedTaskOptions( + cwd: "/", + cache_config: Some(CacheConfig( + env_config: EnvConfig( + fingerprinted_envs: [], + pass_through_envs: [ + "HOME", + "USER", + "TZ", + "LANG", + "SHELL", + "PWD", + "PATH", + "CI", + "NODE_OPTIONS", + "COREPACK_HOME", + "NPM_CONFIG_STORE_DIR", + "PNPM_HOME", + "LD_LIBRARY_PATH", + "DYLD_FALLBACK_LIBRARY_PATH", + "LIBPATH", + "COLORTERM", + "TERM", + "TERM_PROGRAM", + "DISPLAY", + "FORCE_COLOR", + "NO_COLOR", + "TMP", + "TEMP", + "VERCEL", + "VERCEL_*", + "NEXT_*", + "USE_OUTPUT_FOR_EDGE_FUNCTIONS", + "NOW_BUILDER", + "APPDATA", + "PROGRAMDATA", + "SYSTEMROOT", + "SYSTEMDRIVE", + "USERPROFILE", + "HOMEDRIVE", + "HOMEPATH", + "ELECTRON_RUN_AS_NODE", + "JB_INTERPRETER", + "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", + "JB_IDE_*", + "VSCODE_*", + "DOCKER_*", + "BUILDKIT_*", + "COMPOSE_*", + "*_TOKEN", + ], + ), + )), + ), + ), + ), + neighbors: {}, + ), +} diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index e286f2e6..98c63c09 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -8,7 +8,13 @@ mod path_env; mod plan; pub mod plan_request; -use std::{collections::HashMap, ffi::OsStr, fmt::Debug, ops::Range, sync::Arc}; +use std::{ + collections::{BTreeMap, HashMap}, + ffi::OsStr, + fmt::Debug, + ops::Range, + sync::Arc, +}; use context::PlanContext; use error::TaskPlanErrorKindResultExt; @@ -17,7 +23,7 @@ use execution_graph::ExecutionGraph; use in_process::InProcessExecution; use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; -use serde::Serialize; +use serde::{Serialize, ser::SerializeMap as _}; use vite_graph_ser::serialize_by_key; use vite_path::AbsolutePath; use vite_str::Str; @@ -47,12 +53,28 @@ pub struct SpawnCommand { pub args: Arc<[Str]>, /// Environment variables to set for the command, including both fingerprinted and pass-through envs. - pub all_envs: Arc, Arc>>, + #[serde(serialize_with = "serialize_envs")] + pub all_envs: Arc, Arc>>, /// Current working directory pub cwd: Arc, } +/// Serialize environment variables as a map from string to string for better readability. +fn serialize_envs( + envs: &BTreeMap, Arc>, + serializer: S, +) -> Result +where + S: serde::Serializer, +{ + let mut map_ser = serializer.serialize_map(Some(envs.len()))?; + for (key, value) in envs { + map_ser.serialize_entry(&key.display().to_string(), &value.display().to_string())?; + } + map_ser.end() +} + /// Represents how a task should be executed. It's the node type for the execution graph. Each node corresponds to a task. #[derive(Debug, Serialize)] pub struct TaskExecution { diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 77cfb09d..04ebb458 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -380,7 +380,7 @@ fn plan_spawn_execution( program_path, args: Arc::clone(&args), cwd, - all_envs: Arc::new(all_envs), + all_envs: Arc::new(all_envs.into_iter().collect()), }, cache_metadata: resolved_cache_metadata, }) From 36ceed010a800bf45d47690e9ab0842aa28370ef Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 02:36:53 +0800 Subject: [PATCH 18/27] redact pass through envs --- Cargo.lock | 7 + Cargo.toml | 1 + crates/vite_graph_ser/src/lib.rs | 80 +- crates/vite_task_bin/Cargo.toml | 1 + crates/vite_task_bin/tests/snapshots.rs | 114 +- ...ts__query - user task cache key@cache.snap | 191 +- .../snapshots__task graph@cache-sharing.snap | 291 +- .../snapshots__task graph@cache.snap | 101 +- ...__task graph@comprehensive-task-graph.snap | 2335 ++++++----------- .../snapshots__task graph@conflict-test.snap | 299 +-- ...aph@dependency-both-topo-and-explicit.snap | 204 +- ...pshots__task graph@empty-package-test.snap | 860 +++--- ...s__task graph@explicit-deps-workspace.snap | 1082 +++----- ...s__task graph@fingerprint-ignore-test.snap | 101 +- ...graph@recursive-topological-workspace.snap | 814 ++---- ...graph@transitive-dependency-workspace.snap | 711 ++--- crates/vite_task_graph/src/config/mod.rs | 3 +- 17 files changed, 2439 insertions(+), 4756 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4cdf92f1..03e7c85d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -582,6 +582,12 @@ dependencies = [ "walkdir", ] +[[package]] +name = "cow-utils" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417bef24afe1460300965a25ff4a24b8b45ad011948302ec221e8a0a81eb2c79" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -3308,6 +3314,7 @@ dependencies = [ "async-trait", "clap", "copy_dir", + "cow-utils", "insta", "petgraph", "regex", diff --git a/Cargo.toml b/Cargo.toml index 0e9b82a4..8c72e9dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ compact_str = "0.9.0" const_format = "0.2.34" constcat = "0.6.1" copy_dir = "0.1.3" +cow-utils = "0.1.3" crossterm = { version = "0.29.0", features = ["event-stream"] } csv-async = { version = "1.3.1", features = ["tokio"] } ctor = "0.6" diff --git a/crates/vite_graph_ser/src/lib.rs b/crates/vite_graph_ser/src/lib.rs index a8a9f299..edc4fd5e 100644 --- a/crates/vite_graph_ser/src/lib.rs +++ b/crates/vite_graph_ser/src/lib.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeMap; - use petgraph::{ graph::DiGraph, visit::{EdgeRef as _, IntoNodeReferences}, @@ -17,9 +15,10 @@ pub trait GetKey { #[derive(Serialize)] #[serde(bound = "E: Serialize, N: Serialize")] -struct DiGraphValue<'a, N: GetKey, E> { +struct DiGraphNodeItem<'a, N: GetKey, E> { + key: N::Key<'a>, node: &'a N, - neighbors: BTreeMap, &'a E>, + neighbors: Vec<(N::Key<'a>, &'a E)>, } /// A wrapper around `DiGraph` that serializes nodes by their keys. @@ -46,33 +45,24 @@ pub fn serialize_by_key< graph: &DiGraph, serializer: S, ) -> Result { - let mut map = BTreeMap::, DiGraphValue<'_, N, E>>::new(); - + let mut items = Vec::>::with_capacity(graph.node_count()); for (node_idx, node) in graph.node_references() { - let mut neighbors = BTreeMap::, &E>::new(); + let mut neighbors = Vec::<(N::Key<'_>, &E)>::new(); for edge in graph.edges(node_idx) { let target_idx = edge.target(); let target_node = graph.node_weight(target_idx).unwrap(); - let existing = neighbors - .insert(target_node.key().map_err(serde::ser::Error::custom)?, edge.weight()); - if existing.is_some() { - return Err(serde::ser::Error::custom( - "multiple edges between nodes with same id are not supported", - )); - } - } - let existing = map.insert( - node.key().map_err(serde::ser::Error::custom)?, - DiGraphValue { node, neighbors }, - ); - if existing.is_some() { - return Err(serde::ser::Error::custom( - "multiple nodes with the same id are not supported", - )); + neighbors.push((target_node.key().map_err(serde::ser::Error::custom)?, edge.weight())); } + neighbors.sort_unstable_by(|a, b| a.0.cmp(&b.0)); + items.push(DiGraphNodeItem { + key: node.key().map_err(serde::ser::Error::custom)?, + node, + neighbors, + }); } - map.serialize(serializer) + items.sort_unstable_by(|a, b| a.key.cmp(&b.key)); + items.serialize(serializer) } #[cfg(test)] @@ -119,44 +109,24 @@ mod tests { assert_eq!( json, serde_json::json!({ - "graph": { - "a": { + "graph": [ + { + "key": "a", "node": {"id": "a", "value": 1}, - "neighbors": {"b": "a->b", "c": "a->c"} + "neighbors": [["b", "a->b"], ["c", "a->c"]] }, - "b": { + { + "key": "b", "node": {"id": "b", "value": 2}, - "neighbors": {"c": "b->c"} + "neighbors": [["c", "b->c"]] }, - "c": { + { + "key": "c", "node": {"id": "c", "value": 3}, - "neighbors": {} + "neighbors": [] } - } + ] }) ); } - - #[test] - fn test_serialize_graph_error_duplicate_nodes() { - let mut graph = DiGraph::::new(); - graph.add_node(TestNode { id: "a", value: 1 }); - graph.add_node(TestNode { id: "a", value: 2 }); // duplicate id - - let err = serde_json::to_string(&GraphWrapper { graph }).unwrap_err(); - assert!(err.to_string().contains("multiple nodes with the same id")); - } - - #[test] - fn test_serialize_graph_error_duplicate_edges() { - let mut graph = DiGraph::::new(); - let a = graph.add_node(TestNode { id: "a", value: 1 }); - let b = graph.add_node(TestNode { id: "b", value: 2 }); - - graph.add_edge(a, b, "first"); - graph.add_edge(a, b, "second"); // duplicate edge - - let err = serde_json::to_string(&GraphWrapper { graph }).unwrap_err(); - assert!(err.to_string().contains("multiple edges between nodes with same id")); - } } diff --git a/crates/vite_task_bin/Cargo.toml b/crates/vite_task_bin/Cargo.toml index bd1a9ccf..6a377b2a 100644 --- a/crates/vite_task_bin/Cargo.toml +++ b/crates/vite_task_bin/Cargo.toml @@ -22,6 +22,7 @@ which = { workspace = true } [dev-dependencies] copy_dir = { workspace = true } +cow-utils = { workspace = true } insta = { workspace = true, features = ["glob", "json", "redactions", "filters", "ron"] } petgraph = { workspace = true } regex = { workspace = true } diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index faeb3104..b65ef243 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -1,20 +1,19 @@ use core::panic; -use std::{collections::HashMap, convert::Infallible, ffi::OsStr, path::Path, sync::Arc}; +use std::{ + borrow::Cow, collections::HashMap, convert::Infallible, ffi::OsStr, path::Path, sync::Arc, +}; use clap::Parser; use copy_dir::copy_dir; use insta::internals::Content; use petgraph::visit::EdgeRef as _; +use serde::Serialize; use tokio::runtime::Runtime; use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; use vite_str::Str; use vite_task::{CLIArgs, Session}; use vite_task_bin::CustomTaskSubcommand; -use vite_task_graph::{ - IndexedTaskGraph, TaskDependencyType, TaskNodeIndex, - loader::JsonUserConfigLoader, - query::{TaskExecutionGraph, cli::CLITaskQuery}, -}; +use vite_task_graph::config::DEFAULT_PASSTHROUGH_ENVS; use vite_workspace::find_workspace_root; fn visit_json(value: &mut serde_json::Value, f: &mut impl FnMut(&mut serde_json::Value)) { @@ -34,52 +33,55 @@ fn visit_json(value: &mut serde_json::Value, f: &mut impl FnMut(&mut serde_json: } } -#[derive(serde::Serialize, PartialEq, PartialOrd, Eq, Ord)] -struct TaskIdSnapshot { - package_dir: Arc, - task_name: Str, -} -impl TaskIdSnapshot { - fn new(task_index: TaskNodeIndex, indexed_task_graph: &IndexedTaskGraph) -> Self { - let task_display = &indexed_task_graph.task_graph()[task_index].task_display; - Self { - task_name: task_display.task_name.clone(), - package_dir: Arc::clone(&task_display.package_path), +fn redact_strs(value: &mut serde_json::Value, redactions: &[(&str, &str)]) { + use cow_utils::CowUtils as _; + visit_json(value, &mut |v| { + if let serde_json::Value::String(s) = v { + for (from, to) in redactions { + if let Cow::Owned(replaced) = s.as_str().cow_replace(from, to) { + *s = replaced; + } + } } - } + }); } -/// Create a stable json representation of the task graph for snapshot testing. -/// -/// All paths are relative to `base_dir`. -fn snapshot_task_graph(indexed_task_graph: &IndexedTaskGraph) -> impl serde::Serialize { - #[derive(serde::Serialize)] - struct TaskNodeSnapshot { - id: TaskIdSnapshot, - command: Str, - cwd: Arc, - depends_on: Vec<(TaskIdSnapshot, TaskDependencyType)>, - } +fn redact_snapshot(value: &impl Serialize, workspace_root: &str) -> serde_json::Value { + let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + let mut json_value = serde_json::to_value(value).unwrap(); + redact_strs( + &mut json_value, + &[(workspace_root, ""), (manifest_dir.as_str(), "")], + ); - let task_graph = indexed_task_graph.task_graph(); - let mut node_snapshots = Vec::::with_capacity(task_graph.node_count()); - for task_index in task_graph.node_indices() { - let task_node = &task_graph[task_index]; - let mut depends_on: Vec<(TaskIdSnapshot, TaskDependencyType)> = task_graph - .edges_directed(task_index, petgraph::Direction::Outgoing) - .map(|edge| (TaskIdSnapshot::new(edge.target(), indexed_task_graph), *edge.weight())) - .collect(); - depends_on.sort_unstable_by(|a, b| a.0.cmp(&b.0)); - node_snapshots.push(TaskNodeSnapshot { - id: TaskIdSnapshot::new(task_index, indexed_task_graph), - command: task_node.resolved_config.command.clone(), - cwd: Arc::clone(&task_node.resolved_config.resolved_options.cwd), - depends_on, - }); - } - node_snapshots.sort_unstable_by(|a, b| a.id.cmp(&b.id)); + visit_json(&mut json_value, &mut |v| { + let serde_json::Value::Array(array) = v else { + return; + }; + let contains_all_default_pass_through_envs = + DEFAULT_PASSTHROUGH_ENVS.iter().all(|default_pass_through_envs| { + array.iter().any(|item| { + if let serde_json::Value::String(s) = item { + s == *default_pass_through_envs + } else { + false + } + }) + }); + // Remove default pass-through envs from snapshots to reduce noise + if contains_all_default_pass_through_envs { + array.retain(|item| { + if let serde_json::Value::String(s) = item { + !DEFAULT_PASSTHROUGH_ENVS.contains(&s.as_str()) + } else { + true + } + }); + array.push(serde_json::Value::String("".to_string())); + } + }); - node_snapshots + json_value } #[derive(serde::Deserialize, Debug)] @@ -144,8 +146,7 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { .collect(); runtime.block_on(async { - let _redaction_guard = redact_absolute_paths(&workspace_root.path); - + let workspace_root_str = workspace_root.path.as_path().to_str().unwrap(); let mut owned_callbacks = vite_task_bin::OwnedSessionCallbacks::default(); let mut session = Session::init_with( envs, @@ -154,12 +155,13 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { ) .unwrap(); - insta::assert_ron_snapshot!( - "task graph", - vite_graph_ser::SerializeByKey( - session.ensure_task_graph_loaded().await.unwrap().task_graph() - ) + let task_graph_json = redact_snapshot( + &vite_graph_ser::SerializeByKey( + session.ensure_task_graph_loaded().await.unwrap().task_graph(), + ), + workspace_root_str, ); + insta::assert_json_snapshot!("task graph", task_graph_json); for plan in cases_file.plans { let snapshot_name = format!("query - {}", plan.name); @@ -188,7 +190,9 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { continue; } }; - insta::assert_ron_snapshot!(snapshot_name, &plan); + + let plan_json = redact_snapshot(&plan, workspace_root_str); + insta::assert_json_snapshot!(snapshot_name, &plan_json); // let cwd: Arc = case_stage_path.join(&cli_query.cwd).into(); // let task_query = match cli_task_query.into_task_query(&cwd) { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap index 63352757..f9aeeeba 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap @@ -1,117 +1,88 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" +expression: "&plan_json" input_file: crates/vite_task_bin/tests/fixtures/cache --- -SessionExecutionPlan( - cli_args_without_program: [ +{ + "cli_args_without_program": [ "run", - "hello", + "hello" ], - cwd: "/", - plan: ExecutionPlan( - root_node: Expanded({ - ("/", "hello"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "", - task_name: "hello", - package_path: "/", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 18, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(Spawn(SpawnExecution( - cache_metadata: Some(CacheMetadata( - spawn_fingerprint: SpawnFingerprint( - cwd: RelativePathBuf(""), - program_fingerprint: OutsideWorkspace( - program_name: "readfile", - ), - args: [ - "hello.txt", - ], - env_fingerprints: EnvFingerprints( - fingerprinted_envs: {}, - pass_through_env_config: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - fingerprint_ignores: None, - ), - execution_cache_key: ExecutionCacheKey( - kind: UserTask( - task_name: "hello", - and_item_index: 0, - ), - origin_path: RelativePathBuf(""), - ), - )), - spawn_command: SpawnCommand( - program_path: "/Volumes/code/vite-task/crates/vite_task_bin/tests/bins/readfile", - args: [ - "hello.txt", - ], - all_envs: { - "FORCE_COLOR": "3", - "PATH": "/var/folders/v7/bp3pvg2x2n1g07k3q9mv4nb40000gn/T/.tmp5Gy398/cache/node_modules/.bin:/Volumes/code/vite-task/crates/vite_task_bin/tests/bins", - }, - cwd: "/", - ), - ))), - ), + "cwd": "/", + "plan": { + "root_node": { + "Expanded": [ + { + "key": [ + "/", + "hello" ], - ), - neighbors: {}, - ), - }), - ), -) + "node": { + "task_display": { + "package_name": "", + "task_name": "hello", + "package_path": "/" + }, + "items": [ + { + "command_span": { + "start": 0, + "end": 18 + }, + "extra_args": [], + "plan_cwd": "/", + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "readfile" + } + }, + "args": [ + "hello.txt" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "UserTask": { + "task_name": "hello", + "and_item_index": 0 + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/tests/bins/readfile", + "args": [ + "hello.txt" + ], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/tests/bins" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap index b83ed835..bef31544 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap @@ -1,208 +1,91 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/cache-sharing --- -{ - ("/", "a"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/cache-sharing", - task_name: "a", - package_path: "/", - ), - resolved_config: ResolvedTaskConfig( - command: "echo a", - resolved_options: ResolvedTaskOptions( - cwd: "/", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/", "b"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/cache-sharing", - task_name: "b", - package_path: "/", - ), - resolved_config: ResolvedTaskConfig( - command: "echo a && echo b", - resolved_options: ResolvedTaskOptions( - cwd: "/", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/", "c"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/cache-sharing", - task_name: "c", - package_path: "/", - ), - resolved_config: ResolvedTaskConfig( - command: "echo a && echo b && echo c", - resolved_options: ResolvedTaskOptions( - cwd: "/", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), -} +[ + { + "key": [ + "/", + "a" + ], + "node": { + "task_display": { + "package_name": "@test/cache-sharing", + "task_name": "a", + "package_path": "/" + }, + "resolved_config": { + "command": "echo a", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/", + "b" + ], + "node": { + "task_display": { + "package_name": "@test/cache-sharing", + "task_name": "b", + "package_path": "/" + }, + "resolved_config": { + "command": "echo a && echo b", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/", + "c" + ], + "node": { + "task_display": { + "package_name": "@test/cache-sharing", + "task_name": "c", + "package_path": "/" + }, + "resolved_config": { + "command": "echo a && echo b && echo c", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap index ed389697..345ddb42 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap @@ -1,74 +1,35 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(session.ensure_task_graph_loaded().await.unwrap().task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/cache --- -{ - ("/", "hello"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "hello", - package_path: "/", - ), - resolved_config: ResolvedTaskConfig( - command: "readfile hello.txt", - resolved_options: ResolvedTaskOptions( - cwd: "/", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), -} +[ + { + "key": [ + "/", + "hello" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "hello", + "package_path": "/" + }, + "resolved_config": { + "command": "readfile hello.txt", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap index c29d5bfc..3f2eb5a4 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap @@ -1,1577 +1,788 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph --- -{ - ("/packages/api", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/api", - task_name: "build", - package_path: "/packages/api", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Generate schemas && echo Compile TypeScript && echo Bundle API && echo Copy assets", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/api", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/config", "build"): Topological, - ("/packages/shared", "build"): Topological, +[ + { + "key": [ + "/packages/api", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/api", + "task_name": "build", + "package_path": "/packages/api" + }, + "resolved_config": { + "command": "echo Generate schemas && echo Compile TypeScript && echo Bundle API && echo Copy assets", + "resolved_options": { + "cwd": "/packages/api", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/api", "dev"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/api", - task_name: "dev", - package_path: "/packages/api", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Watch mode && echo Start dev server", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/api", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/api", "start"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/api", - task_name: "start", - package_path: "/packages/api", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Starting API server", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/api", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/api", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/api", - task_name: "test", - package_path: "/packages/api", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Testing API", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/api", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/shared", "test"): Topological, + "neighbors": [ + [ + [ + "/packages/config", + "build" + ], + "Topological" + ], + [ + [ + "/packages/shared", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/api", + "dev" + ], + "node": { + "task_display": { + "package_name": "@test/api", + "task_name": "dev", + "package_path": "/packages/api" + }, + "resolved_config": { + "command": "echo Watch mode && echo Start dev server", + "resolved_options": { + "cwd": "/packages/api", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/app", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "build", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Clean dist && echo Build client && echo Build server && echo Generate manifest && echo Optimize assets", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/api", "build"): Topological, - ("/packages/pkg#special", "build"): Topological, - ("/packages/shared", "build"): Topological, - ("/packages/ui", "build"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/api", + "start" + ], + "node": { + "task_display": { + "package_name": "@test/api", + "task_name": "start", + "package_path": "/packages/api" + }, + "resolved_config": { + "command": "echo Starting API server", + "resolved_options": { + "cwd": "/packages/api", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/app", "deploy"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "deploy", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Validate && echo Upload && echo Verify", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/app", "dev"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "dev", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Running dev server", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/api", "dev"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/api", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/api", + "task_name": "test", + "package_path": "/packages/api" + }, + "resolved_config": { + "command": "echo Testing API", + "resolved_options": { + "cwd": "/packages/api", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/app", "preview"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "preview", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Preview build", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/app", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "test", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Unit tests && echo Integration tests", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/api", "test"): Topological, - ("/packages/pkg#special", "test"): Topological, - ("/packages/shared", "test"): Topological, - ("/packages/ui", "test"): Topological, + "neighbors": [ + [ + [ + "/packages/shared", + "test" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/app", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "build", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo Clean dist && echo Build client && echo Build server && echo Generate manifest && echo Optimize assets", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/config", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/config", - task_name: "build", - package_path: "/packages/config", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Building config", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/config", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/config", "validate"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/config", - task_name: "validate", - package_path: "/packages/config", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Validating config", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/config", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/pkg#special", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/pkg#special", - task_name: "build", - package_path: "/packages/pkg#special", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Building package with hash", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/pkg#special", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/shared", "build"): Topological, + "neighbors": [ + [ + [ + "/packages/api", + "build" + ], + "Topological" + ], + [ + [ + "/packages/pkg#special", + "build" + ], + "Topological" + ], + [ + [ + "/packages/shared", + "build" + ], + "Topological" + ], + [ + [ + "/packages/ui", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/app", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "deploy", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo Validate && echo Upload && echo Verify", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/pkg#special", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/pkg#special", - task_name: "test", - package_path: "/packages/pkg#special", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Testing package with hash", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/pkg#special", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/shared", "test"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/app", + "dev" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "dev", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo Running dev server", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/shared", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/shared", - task_name: "build", - package_path: "/packages/shared", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Cleaning && echo Compiling shared && echo Generating types", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/shared", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/shared", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/shared", - task_name: "lint", - package_path: "/packages/shared", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Linting shared", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/shared", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/shared", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/shared", - task_name: "test", - package_path: "/packages/shared", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Setting up test env && echo Running tests && echo Cleanup", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/shared", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/shared", "typecheck"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/shared", - task_name: "typecheck", - package_path: "/packages/shared", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Type checking shared", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/shared", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/tools", "generate"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/tools", - task_name: "generate", - package_path: "/packages/tools", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Generating tools", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/tools", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/tools", "validate"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/tools", - task_name: "validate", - package_path: "/packages/tools", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Validating", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/tools", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/config", "validate"): Topological, + "neighbors": [ + [ + [ + "/packages/api", + "dev" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/app", + "preview" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "preview", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo Preview build", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/ui", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/ui", - task_name: "build", - package_path: "/packages/ui", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Compile styles && echo Build components && echo Generate types", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/ui", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/shared", "build"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/app", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "test", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo Unit tests && echo Integration tests", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/ui", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/ui", - task_name: "lint", - package_path: "/packages/ui", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Linting UI", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/ui", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/shared", "lint"): Topological, + "neighbors": [ + [ + [ + "/packages/api", + "test" + ], + "Topological" + ], + [ + [ + "/packages/pkg#special", + "test" + ], + "Topological" + ], + [ + [ + "/packages/shared", + "test" + ], + "Topological" + ], + [ + [ + "/packages/ui", + "test" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/config", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/config", + "task_name": "build", + "package_path": "/packages/config" + }, + "resolved_config": { + "command": "echo Building config", + "resolved_options": { + "cwd": "/packages/config", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/ui", "storybook"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/ui", - task_name: "storybook", - package_path: "/packages/ui", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Running storybook", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/ui", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/ui", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/ui", - task_name: "test", - package_path: "/packages/ui", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Testing UI", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/ui", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/shared", "test"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/config", + "validate" + ], + "node": { + "task_display": { + "package_name": "@test/config", + "task_name": "validate", + "package_path": "/packages/config" + }, + "resolved_config": { + "command": "echo Validating config", + "resolved_options": { + "cwd": "/packages/config", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), -} + "neighbors": [] + }, + { + "key": [ + "/packages/pkg#special", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/pkg#special", + "task_name": "build", + "package_path": "/packages/pkg#special" + }, + "resolved_config": { + "command": "echo Building package with hash", + "resolved_options": { + "cwd": "/packages/pkg#special", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/shared", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/pkg#special", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/pkg#special", + "task_name": "test", + "package_path": "/packages/pkg#special" + }, + "resolved_config": { + "command": "echo Testing package with hash", + "resolved_options": { + "cwd": "/packages/pkg#special", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/shared", + "test" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/shared", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/shared", + "task_name": "build", + "package_path": "/packages/shared" + }, + "resolved_config": { + "command": "echo Cleaning && echo Compiling shared && echo Generating types", + "resolved_options": { + "cwd": "/packages/shared", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/shared", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/shared", + "task_name": "lint", + "package_path": "/packages/shared" + }, + "resolved_config": { + "command": "echo Linting shared", + "resolved_options": { + "cwd": "/packages/shared", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/shared", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/shared", + "task_name": "test", + "package_path": "/packages/shared" + }, + "resolved_config": { + "command": "echo Setting up test env && echo Running tests && echo Cleanup", + "resolved_options": { + "cwd": "/packages/shared", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/shared", + "typecheck" + ], + "node": { + "task_display": { + "package_name": "@test/shared", + "task_name": "typecheck", + "package_path": "/packages/shared" + }, + "resolved_config": { + "command": "echo Type checking shared", + "resolved_options": { + "cwd": "/packages/shared", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/tools", + "generate" + ], + "node": { + "task_display": { + "package_name": "@test/tools", + "task_name": "generate", + "package_path": "/packages/tools" + }, + "resolved_config": { + "command": "echo Generating tools", + "resolved_options": { + "cwd": "/packages/tools", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/tools", + "validate" + ], + "node": { + "task_display": { + "package_name": "@test/tools", + "task_name": "validate", + "package_path": "/packages/tools" + }, + "resolved_config": { + "command": "echo Validating", + "resolved_options": { + "cwd": "/packages/tools", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/config", + "validate" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/ui", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/ui", + "task_name": "build", + "package_path": "/packages/ui" + }, + "resolved_config": { + "command": "echo Compile styles && echo Build components && echo Generate types", + "resolved_options": { + "cwd": "/packages/ui", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/shared", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/ui", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/ui", + "task_name": "lint", + "package_path": "/packages/ui" + }, + "resolved_config": { + "command": "echo Linting UI", + "resolved_options": { + "cwd": "/packages/ui", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/shared", + "lint" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/ui", + "storybook" + ], + "node": { + "task_display": { + "package_name": "@test/ui", + "task_name": "storybook", + "package_path": "/packages/ui" + }, + "resolved_config": { + "command": "echo Running storybook", + "resolved_options": { + "cwd": "/packages/ui", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/ui", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/ui", + "task_name": "test", + "package_path": "/packages/ui" + }, + "resolved_config": { + "command": "echo Testing UI", + "resolved_options": { + "cwd": "/packages/ui", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/shared", + "test" + ], + "Topological" + ] + ] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap index c6a14c51..c34aba11 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap @@ -1,210 +1,99 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/conflict-test --- -{ - ("/packages/scope-a", "b#c"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/scope-a", - task_name: "b#c", - package_path: "/packages/scope-a", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Task b#c in scope-a", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/scope-a", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/scope-a-b", "c"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/scope-a#b", - task_name: "c", - package_path: "/packages/scope-a-b", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Task c in scope-a#b", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/scope-a-b", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/test-package", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/test-package", - task_name: "test", - package_path: "/packages/test-package", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Testing", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/test-package", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/scope-a-b", "c"): Explicit, +[ + { + "key": [ + "/packages/scope-a", + "b#c" + ], + "node": { + "task_display": { + "package_name": "@test/scope-a", + "task_name": "b#c", + "package_path": "/packages/scope-a" + }, + "resolved_config": { + "command": "echo Task b#c in scope-a", + "resolved_options": { + "cwd": "/packages/scope-a", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), -} + "neighbors": [] + }, + { + "key": [ + "/packages/scope-a-b", + "c" + ], + "node": { + "task_display": { + "package_name": "@test/scope-a#b", + "task_name": "c", + "package_path": "/packages/scope-a-b" + }, + "resolved_config": { + "command": "echo Task c in scope-a#b", + "resolved_options": { + "cwd": "/packages/scope-a-b", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/test-package", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/test-package", + "task_name": "test", + "package_path": "/packages/test-package" + }, + "resolved_config": { + "command": "echo Testing", + "resolved_options": { + "cwd": "/packages/test-package", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/scope-a-b", + "c" + ], + "Explicit" + ] + ] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap index 6a038f96..a4514bf0 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap @@ -1,143 +1,71 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit --- -{ - ("/packages/a", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - resolved_config: ResolvedTaskConfig( - command: "build a", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/a", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/b", "build"): Both, +[ + { + "key": [ + "/packages/a", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/a", + "task_name": "build", + "package_path": "/packages/a" + }, + "resolved_config": { + "command": "build a", + "resolved_options": { + "cwd": "/packages/a", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/b", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/b", - task_name: "build", - package_path: "/packages/b", - ), - resolved_config: ResolvedTaskConfig( - command: "build b", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/b", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), -} + "neighbors": [ + [ + [ + "/packages/b", + "build" + ], + "Both" + ] + ] + }, + { + "key": [ + "/packages/b", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/b", + "task_name": "build", + "package_path": "/packages/b" + }, + "resolved_config": { + "command": "build b", + "resolved_options": { + "cwd": "/packages/b", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap index 8b26ae99..c237e876 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap @@ -1,571 +1,305 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/empty-package-test --- -{ - ("/packages/another-empty", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "build", - package_path: "/packages/another-empty", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building another-empty package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/another-empty", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/another-empty", "lint"): Explicit, - ("/packages/normal-package", "build"): Topological, - ("/packages/normal-package", "test"): Explicit, +[ + { + "key": [ + "/packages/another-empty", + "build" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "build", + "package_path": "/packages/another-empty" + }, + "resolved_config": { + "command": "echo 'Building another-empty package'", + "resolved_options": { + "cwd": "/packages/another-empty", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/another-empty", "deploy"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "deploy", - package_path: "/packages/another-empty", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Deploying another-empty package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/another-empty", - cache_config: None, - ), - ), - ), - neighbors: { - ("/packages/another-empty", "build"): Explicit, - ("/packages/another-empty", "test"): Explicit, + "neighbors": [ + [ + [ + "/packages/another-empty", + "lint" + ], + "Explicit" + ], + [ + [ + "/packages/normal-package", + "build" + ], + "Topological" + ], + [ + [ + "/packages/normal-package", + "test" + ], + "Explicit" + ] + ] + }, + { + "key": [ + "/packages/another-empty", + "deploy" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "deploy", + "package_path": "/packages/another-empty" + }, + "resolved_config": { + "command": "echo 'Deploying another-empty package'", + "resolved_options": { + "cwd": "/packages/another-empty", + "cache_config": null + } + } }, - ), - ("/packages/another-empty", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "lint", - package_path: "/packages/another-empty", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Linting another-empty package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/another-empty", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/another-empty", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "test", - package_path: "/packages/another-empty", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing another-empty package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/another-empty", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/normal-package", "test"): Topological, + "neighbors": [ + [ + [ + "/packages/another-empty", + "build" + ], + "Explicit" + ], + [ + [ + "/packages/another-empty", + "test" + ], + "Explicit" + ] + ] + }, + { + "key": [ + "/packages/another-empty", + "lint" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "lint", + "package_path": "/packages/another-empty" + }, + "resolved_config": { + "command": "echo 'Linting another-empty package'", + "resolved_options": { + "cwd": "/packages/another-empty", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/empty-name", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "build", - package_path: "/packages/empty-name", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building empty-name package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/empty-name", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/empty-name", "test"): Explicit, + "neighbors": [] + }, + { + "key": [ + "/packages/another-empty", + "test" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "test", + "package_path": "/packages/another-empty" + }, + "resolved_config": { + "command": "echo 'Testing another-empty package'", + "resolved_options": { + "cwd": "/packages/another-empty", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/empty-name", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "lint", - package_path: "/packages/empty-name", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Linting empty-name package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/empty-name", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/empty-name", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "", - task_name: "test", - package_path: "/packages/empty-name", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing empty-name package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/empty-name", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/normal-package", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "normal-package", - task_name: "build", - package_path: "/packages/normal-package", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building normal-package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/normal-package", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/normal-package", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "normal-package", - task_name: "test", - package_path: "/packages/normal-package", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing normal-package\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/normal-package", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), -} + "neighbors": [ + [ + [ + "/packages/normal-package", + "test" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/empty-name", + "build" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "build", + "package_path": "/packages/empty-name" + }, + "resolved_config": { + "command": "echo 'Building empty-name package'", + "resolved_options": { + "cwd": "/packages/empty-name", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/empty-name", + "test" + ], + "Explicit" + ] + ] + }, + { + "key": [ + "/packages/empty-name", + "lint" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "lint", + "package_path": "/packages/empty-name" + }, + "resolved_config": { + "command": "echo 'Linting empty-name package'", + "resolved_options": { + "cwd": "/packages/empty-name", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/empty-name", + "test" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "test", + "package_path": "/packages/empty-name" + }, + "resolved_config": { + "command": "echo 'Testing empty-name package'", + "resolved_options": { + "cwd": "/packages/empty-name", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/normal-package", + "build" + ], + "node": { + "task_display": { + "package_name": "normal-package", + "task_name": "build", + "package_path": "/packages/normal-package" + }, + "resolved_config": { + "command": "echo 'Building normal-package'", + "resolved_options": { + "cwd": "/packages/normal-package", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/normal-package", + "test" + ], + "node": { + "task_display": { + "package_name": "normal-package", + "task_name": "test", + "package_path": "/packages/normal-package" + }, + "resolved_config": { + "command": "echo 'Testing normal-package'", + "resolved_options": { + "cwd": "/packages/normal-package", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap index ffc4720f..f1d78ab5 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap @@ -1,712 +1,392 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace --- -{ - ("/packages/app", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "build", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building @test/app\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/utils", "build"): Topological, +[ + { + "key": [ + "/packages/app", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "build", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo 'Building @test/app'", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/app", "deploy"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "deploy", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "deploy-script --prod", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: None, - ), - ), - ), - neighbors: { - ("/packages/app", "build"): Explicit, - ("/packages/app", "test"): Explicit, - ("/packages/utils", "lint"): Explicit, + "neighbors": [ + [ + [ + "/packages/utils", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/app", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "deploy", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "deploy-script --prod", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": null + } + } }, - ), - ("/packages/app", "start"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "start", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Starting @test/app\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/app", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "test", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing @test/app\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/utils", "test"): Topological, + "neighbors": [ + [ + [ + "/packages/app", + "build" + ], + "Explicit" + ], + [ + [ + "/packages/app", + "test" + ], + "Explicit" + ], + [ + [ + "/packages/utils", + "lint" + ], + "Explicit" + ] + ] + }, + { + "key": [ + "/packages/app", + "start" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "start", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo 'Starting @test/app'", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/core", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/core", - task_name: "build", - package_path: "/packages/core", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building @test/core\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/core", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/core", "clean"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/core", - task_name: "clean", - package_path: "/packages/core", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Cleaning @test/core\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/core", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/core", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/core", - task_name: "lint", - package_path: "/packages/core", - ), - resolved_config: ResolvedTaskConfig( - command: "eslint src", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/core", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/core", "clean"): Explicit, + "neighbors": [] + }, + { + "key": [ + "/packages/app", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "test", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo 'Testing @test/app'", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/core", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/core", - task_name: "test", - package_path: "/packages/core", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing @test/core\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/core", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/utils", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/utils", - task_name: "build", - package_path: "/packages/utils", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building @test/utils\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/utils", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/core", "build"): Topological, + "neighbors": [ + [ + [ + "/packages/utils", + "test" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/core", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/core", + "task_name": "build", + "package_path": "/packages/core" + }, + "resolved_config": { + "command": "echo 'Building @test/core'", + "resolved_options": { + "cwd": "/packages/core", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/utils", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/utils", - task_name: "lint", - package_path: "/packages/utils", - ), - resolved_config: ResolvedTaskConfig( - command: "eslint src", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/utils", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/core", "build"): Explicit, - ("/packages/core", "lint"): Topological, - ("/packages/utils", "build"): Explicit, + "neighbors": [] + }, + { + "key": [ + "/packages/core", + "clean" + ], + "node": { + "task_display": { + "package_name": "@test/core", + "task_name": "clean", + "package_path": "/packages/core" + }, + "resolved_config": { + "command": "echo 'Cleaning @test/core'", + "resolved_options": { + "cwd": "/packages/core", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/utils", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/utils", - task_name: "test", - package_path: "/packages/utils", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing @test/utils\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/utils", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/core", "test"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/core", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/core", + "task_name": "lint", + "package_path": "/packages/core" + }, + "resolved_config": { + "command": "eslint src", + "resolved_options": { + "cwd": "/packages/core", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), -} + "neighbors": [ + [ + [ + "/packages/core", + "clean" + ], + "Explicit" + ] + ] + }, + { + "key": [ + "/packages/core", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/core", + "task_name": "test", + "package_path": "/packages/core" + }, + "resolved_config": { + "command": "echo 'Testing @test/core'", + "resolved_options": { + "cwd": "/packages/core", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/utils", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/utils", + "task_name": "build", + "package_path": "/packages/utils" + }, + "resolved_config": { + "command": "echo 'Building @test/utils'", + "resolved_options": { + "cwd": "/packages/utils", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/core", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/utils", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/utils", + "task_name": "lint", + "package_path": "/packages/utils" + }, + "resolved_config": { + "command": "eslint src", + "resolved_options": { + "cwd": "/packages/utils", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/core", + "build" + ], + "Explicit" + ], + [ + [ + "/packages/core", + "lint" + ], + "Topological" + ], + [ + [ + "/packages/utils", + "build" + ], + "Explicit" + ] + ] + }, + { + "key": [ + "/packages/utils", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/utils", + "task_name": "test", + "package_path": "/packages/utils" + }, + "resolved_config": { + "command": "echo 'Testing @test/utils'", + "resolved_options": { + "cwd": "/packages/utils", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/core", + "test" + ], + "Topological" + ] + ] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap index d9c25d0e..64bbc7be 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap @@ -1,74 +1,35 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test --- -{ - ("/", "create-files"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/fingerprint-ignore", - task_name: "create-files", - package_path: "/", - ), - resolved_config: ResolvedTaskConfig( - command: "mkdir -p node_modules/pkg-a && echo \'{\"name\":\"pkg-a\"}\' > node_modules/pkg-a/package.json && echo \'content\' > node_modules/pkg-a/index.js && mkdir -p dist && echo \'output\' > dist/bundle.js", - resolved_options: ResolvedTaskOptions( - cwd: "/", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), -} +[ + { + "key": [ + "/", + "create-files" + ], + "node": { + "task_display": { + "package_name": "@test/fingerprint-ignore", + "task_name": "create-files", + "package_path": "/" + }, + "resolved_config": { + "command": "mkdir -p node_modules/pkg-a && echo '{\"name\":\"pkg-a\"}' > node_modules/pkg-a/package.json && echo 'content' > node_modules/pkg-a/index.js && mkdir -p dist && echo 'output' > dist/bundle.js", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap index 080856fa..5d653d9f 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap @@ -1,554 +1,278 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace --- -{ - ("/apps/web", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/web", - task_name: "build", - package_path: "/apps/web", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building @test/web\'", - resolved_options: ResolvedTaskOptions( - cwd: "/apps/web", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/app", "build"): Topological, - ("/packages/core", "build"): Topological, +[ + { + "key": [ + "/apps/web", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/web", + "task_name": "build", + "package_path": "/apps/web" + }, + "resolved_config": { + "command": "echo 'Building @test/web'", + "resolved_options": { + "cwd": "/apps/web", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/apps/web", "dev"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/web", - task_name: "dev", - package_path: "/apps/web", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Running @test/web in dev mode\'", - resolved_options: ResolvedTaskOptions( - cwd: "/apps/web", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/app", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "build", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building @test/app\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/utils", "build"): Topological, + "neighbors": [ + [ + [ + "/packages/app", + "build" + ], + "Topological" + ], + [ + [ + "/packages/core", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/apps/web", + "dev" + ], + "node": { + "task_display": { + "package_name": "@test/web", + "task_name": "dev", + "package_path": "/apps/web" + }, + "resolved_config": { + "command": "echo 'Running @test/web in dev mode'", + "resolved_options": { + "cwd": "/apps/web", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/app", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/app", - task_name: "test", - package_path: "/packages/app", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing @test/app\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/app", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/utils", "test"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/app", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "build", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo 'Building @test/app'", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/core", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/core", - task_name: "build", - package_path: "/packages/core", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Building @test/core\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/core", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/core", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/core", - task_name: "test", - package_path: "/packages/core", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing @test/core\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/core", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/utils", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/utils", - task_name: "build", - package_path: "/packages/utils", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Preparing @test/utils\' && echo \'Building @test/utils\' && echo \'Done @test/utils\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/utils", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/core", "build"): Topological, + "neighbors": [ + [ + [ + "/packages/utils", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/app", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/app", + "task_name": "test", + "package_path": "/packages/app" + }, + "resolved_config": { + "command": "echo 'Testing @test/app'", + "resolved_options": { + "cwd": "/packages/app", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/utils", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/utils", - task_name: "test", - package_path: "/packages/utils", - ), - resolved_config: ResolvedTaskConfig( - command: "echo \'Testing @test/utils\'", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/utils", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/core", "test"): Topological, + "neighbors": [ + [ + [ + "/packages/utils", + "test" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/core", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/core", + "task_name": "build", + "package_path": "/packages/core" + }, + "resolved_config": { + "command": "echo 'Building @test/core'", + "resolved_options": { + "cwd": "/packages/core", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), -} + "neighbors": [] + }, + { + "key": [ + "/packages/core", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/core", + "task_name": "test", + "package_path": "/packages/core" + }, + "resolved_config": { + "command": "echo 'Testing @test/core'", + "resolved_options": { + "cwd": "/packages/core", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/utils", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/utils", + "task_name": "build", + "package_path": "/packages/utils" + }, + "resolved_config": { + "command": "echo 'Preparing @test/utils' && echo 'Building @test/utils' && echo 'Done @test/utils'", + "resolved_options": { + "cwd": "/packages/utils", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/core", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/utils", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/utils", + "task_name": "test", + "package_path": "/packages/utils" + }, + "resolved_config": { + "command": "echo 'Testing @test/utils'", + "resolved_options": { + "cwd": "/packages/utils", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/core", + "test" + ], + "Topological" + ] + ] + } +] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap index 95e52c58..5457027b 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap @@ -1,484 +1,241 @@ --- source: crates/vite_task_bin/tests/snapshots.rs -expression: "vite_graph_ser::SerializeByKey(indexed_task_graph.task_graph())" +expression: task_graph_json input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace --- -{ - ("/packages/a", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Building A", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/a", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/a", "test"): Explicit, - ("/packages/b2", "build"): Topological, - ("/packages/c", "build"): Topological, +[ + { + "key": [ + "/packages/a", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/a", + "task_name": "build", + "package_path": "/packages/a" + }, + "resolved_config": { + "command": "echo Building A", + "resolved_options": { + "cwd": "/packages/a", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/a", "test"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "test", - package_path: "/packages/a", - ), - resolved_config: ResolvedTaskConfig( - command: "echo test a", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/a", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/another-a", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/another-a", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Building another A", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/another-a", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/b1", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/b1", - task_name: "lint", - package_path: "/packages/b1", - ), - resolved_config: ResolvedTaskConfig( - command: "echo lint b1", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/b1", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/c", "lint"): Topological, + "neighbors": [ + [ + [ + "/packages/a", + "test" + ], + "Explicit" + ], + [ + [ + "/packages/b2", + "build" + ], + "Topological" + ], + [ + [ + "/packages/c", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/a", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/a", + "task_name": "test", + "package_path": "/packages/a" + }, + "resolved_config": { + "command": "echo test a", + "resolved_options": { + "cwd": "/packages/a", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/b2", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/b2", - task_name: "build", - package_path: "/packages/b2", - ), - resolved_config: ResolvedTaskConfig( - command: "echo build b2", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/b2", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: { - ("/packages/c", "build"): Topological, + "neighbors": [] + }, + { + "key": [ + "/packages/another-a", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/a", + "task_name": "build", + "package_path": "/packages/another-a" + }, + "resolved_config": { + "command": "echo Building another A", + "resolved_options": { + "cwd": "/packages/another-a", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } }, - ), - ("/packages/c", "build"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "build", - package_path: "/packages/c", - ), - resolved_config: ResolvedTaskConfig( - command: "echo Building C", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/c", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), - ("/packages/c", "lint"): DiGraphValue( - node: TaskNode( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "lint", - package_path: "/packages/c", - ), - resolved_config: ResolvedTaskConfig( - command: "echo lint c", - resolved_options: ResolvedTaskOptions( - cwd: "/packages/c", - cache_config: Some(CacheConfig( - env_config: EnvConfig( - fingerprinted_envs: [], - pass_through_envs: [ - "HOME", - "USER", - "TZ", - "LANG", - "SHELL", - "PWD", - "PATH", - "CI", - "NODE_OPTIONS", - "COREPACK_HOME", - "NPM_CONFIG_STORE_DIR", - "PNPM_HOME", - "LD_LIBRARY_PATH", - "DYLD_FALLBACK_LIBRARY_PATH", - "LIBPATH", - "COLORTERM", - "TERM", - "TERM_PROGRAM", - "DISPLAY", - "FORCE_COLOR", - "NO_COLOR", - "TMP", - "TEMP", - "VERCEL", - "VERCEL_*", - "NEXT_*", - "USE_OUTPUT_FOR_EDGE_FUNCTIONS", - "NOW_BUILDER", - "APPDATA", - "PROGRAMDATA", - "SYSTEMROOT", - "SYSTEMDRIVE", - "USERPROFILE", - "HOMEDRIVE", - "HOMEPATH", - "ELECTRON_RUN_AS_NODE", - "JB_INTERPRETER", - "_JETBRAINS_TEST_RUNNER_RUN_SCOPE_TYPE", - "JB_IDE_*", - "VSCODE_*", - "DOCKER_*", - "BUILDKIT_*", - "COMPOSE_*", - "*_TOKEN", - ], - ), - )), - ), - ), - ), - neighbors: {}, - ), -} + "neighbors": [] + }, + { + "key": [ + "/packages/b1", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/b1", + "task_name": "lint", + "package_path": "/packages/b1" + }, + "resolved_config": { + "command": "echo lint b1", + "resolved_options": { + "cwd": "/packages/b1", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/c", + "lint" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/b2", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/b2", + "task_name": "build", + "package_path": "/packages/b2" + }, + "resolved_config": { + "command": "echo build b2", + "resolved_options": { + "cwd": "/packages/b2", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [ + [ + [ + "/packages/c", + "build" + ], + "Topological" + ] + ] + }, + { + "key": [ + "/packages/c", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/c", + "task_name": "build", + "package_path": "/packages/c" + }, + "resolved_config": { + "command": "echo Building C", + "resolved_options": { + "cwd": "/packages/c", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, + { + "key": [ + "/packages/c", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/c", + "task_name": "lint", + "package_path": "/packages/c" + }, + "resolved_config": { + "command": "echo lint c", + "resolved_options": { + "cwd": "/packages/c", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_graph/src/config/mod.rs b/crates/vite_task_graph/src/config/mod.rs index 91fad00a..34f13bb8 100644 --- a/crates/vite_task_graph/src/config/mod.rs +++ b/crates/vite_task_graph/src/config/mod.rs @@ -120,7 +120,8 @@ impl ResolvedTaskConfig { // Exact matches for common environment variables // Referenced from Turborepo's implementation: // https://github.com/vercel/turborepo/blob/26d309f073ca3ac054109ba0c29c7e230e7caac3/crates/turborepo-lib/src/task_hash.rs#L439 -const DEFAULT_PASSTHROUGH_ENVS: &[&str] = &[ +#[doc(hidden)] // exported for redacting snapshots in tests +pub const DEFAULT_PASSTHROUGH_ENVS: &[&str] = &[ // System and shell "HOME", "USER", From e05100dd93fff5e16de6ac8aa0596db7522327e7 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 03:16:33 +0800 Subject: [PATCH 19/27] add test_bins to snapshot tests --- crates/vite_task/src/session/mod.rs | 21 +++++-- crates/vite_task_bin/src/lib.rs | 9 ++- crates/vite_task_bin/test_bins/README.md | 1 + crates/vite_task_bin/test_bins/package.json | 11 ++++ crates/vite_task_bin/test_bins/readfile.mjs | 4 ++ crates/vite_task_bin/tests/bins/README.md | 1 - crates/vite_task_bin/tests/bins/readfile | 2 - crates/vite_task_bin/tests/bins/readfile.cmd | 2 - .../tests/fixtures/cache/snapshots.toml | 4 ++ crates/vite_task_bin/tests/snapshots.rs | 7 ++- ...direct synthetic task cache key@cache.snap | 56 +++++++++++++++++++ ...ts__query - user task cache key@cache.snap | 4 +- crates/vite_task_plan/src/error.rs | 6 +- crates/vite_task_plan/src/lib.rs | 2 + crates/vite_task_plan/src/plan.rs | 10 +++- pnpm-lock.yaml | 9 +++ pnpm-workspace.yaml | 1 + 17 files changed, 131 insertions(+), 19 deletions(-) create mode 100644 crates/vite_task_bin/test_bins/README.md create mode 100644 crates/vite_task_bin/test_bins/package.json create mode 100755 crates/vite_task_bin/test_bins/readfile.mjs delete mode 100644 crates/vite_task_bin/tests/bins/README.md delete mode 100755 crates/vite_task_bin/tests/bins/readfile delete mode 100644 crates/vite_task_bin/tests/bins/readfile.cmd create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index 2b318a76..74ba5f27 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -6,12 +6,13 @@ use std::{ffi::OsStr, fmt::Debug, sync::Arc}; use cache::ExecutionCache; use clap::{Parser, Subcommand}; +use nix::libc::PATH_MAX; use serde::Serialize; use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskGraph, TaskGraphLoadError, loader::UserConfigLoader}; use vite_task_plan::{ - ExecutionPlan, TaskGraphLoader, TaskPlanErrorKind, + ExecutionPlan, TaskGraphLoader, TaskPlanErrorKind, get_path_env, plan_request::{PlanRequest, SyntheticPlanRequest}, }; use vite_workspace::{WorkspaceRoot, find_workspace_root}; @@ -66,6 +67,7 @@ pub trait TaskSynthesizer: Debug { async fn synthesize_task( &mut self, subcommand: CustomSubcommand, + path_env: Option<&Arc>, cwd: &Arc, ) -> anyhow::Result; } @@ -80,6 +82,7 @@ impl PlanRequestParser<'_, CustomSubcommand> async fn get_plan_request_from_cli_args( &mut self, cli_args: ParsedTaskCLIArgs, + path_env: Option<&Arc>, cwd: &Arc, ) -> anyhow::Result { match cli_args { @@ -88,7 +91,7 @@ impl PlanRequestParser<'_, CustomSubcommand> } ParsedTaskCLIArgs::Custom(custom_subcommand) => { let synthetic_plan_request = - self.task_synthesizer.synthesize_task(custom_subcommand, cwd).await?; + self.task_synthesizer.synthesize_task(custom_subcommand, path_env, cwd).await?; Ok(PlanRequest::Synthetic(synthetic_plan_request)) } } @@ -103,6 +106,7 @@ impl vite_task_plan::PlanRequestParser &mut self, program: &str, args: &[Str], + path_env: Option<&Arc>, cwd: &Arc, ) -> anyhow::Result> { Ok( @@ -113,7 +117,7 @@ impl vite_task_plan::PlanRequestParser let cli_args = ParsedTaskCLIArgs::::try_parse_from( std::iter::once(program).chain(args.iter().map(Str::as_str)), )?; - Some(self.get_plan_request_from_cli_args(cli_args, cwd).await?) + Some(self.get_plan_request_from_cli_args(cli_args, path_env, cwd).await?) } else { None }, @@ -225,12 +229,19 @@ impl<'a, CustomSubcommand: clap::Subcommand> Session<'a, CustomSubcommand> { cwd: Arc, cli_args: TaskCLIArgs, ) -> Result { + let path_env = get_path_env(&self.envs); let plan_request = self .plan_request_parser - .get_plan_request_from_cli_args(cli_args.parsed, &cwd) + .get_plan_request_from_cli_args(cli_args.parsed, path_env, &cwd) .await .map_err(|error| { - TaskPlanErrorKind::ParsePlanRequestError { error }.with_empty_call_stack() + TaskPlanErrorKind::ParsePlanRequestError { + error, + program: cli_args.original[0].clone(), + args: cli_args.original.iter().skip(1).cloned().collect(), + cwd: Arc::clone(&cwd), + } + .with_empty_call_stack() })?; let plan = ExecutionPlan::plan( plan_request, diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs index 95e56220..bae77ab3 100644 --- a/crates/vite_task_bin/src/lib.rs +++ b/crates/vite_task_bin/src/lib.rs @@ -27,11 +27,13 @@ pub enum NonTaskSubcommand { #[derive(Debug, Default)] pub struct TaskSynthesizer(()); -fn find_executable_in_node_modules_bin( +fn find_executable( + path_env: Option<&Arc>, cwd: &AbsolutePath, executable: &str, ) -> anyhow::Result> { - let mut paths: Vec = vec![]; + let mut paths: Vec = + if let Some(path_env) = path_env { env::split_paths(path_env).collect() } else { vec![] }; let mut current_cwd_parent = cwd; loop { let node_modules_bin = current_cwd_parent.join("node_modules").join(".bin"); @@ -55,6 +57,7 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { async fn synthesize_task( &mut self, subcommand: CustomTaskSubcommand, + path_env: Option<&Arc>, cwd: &Arc, ) -> anyhow::Result { match subcommand { @@ -62,7 +65,7 @@ impl vite_task::TaskSynthesizer for TaskSynthesizer { let direct_execution_cache_key: Arc<[Str]> = iter::once(Str::from("lint")).chain(args.iter().cloned()).collect(); Ok(SyntheticPlanRequest { - program: find_executable_in_node_modules_bin(&*cwd, "oxlint")?, + program: find_executable(path_env, &*cwd, "oxlint")?, args: args.into(), task_options: Default::default(), direct_execution_cache_key, diff --git a/crates/vite_task_bin/test_bins/README.md b/crates/vite_task_bin/test_bins/README.md new file mode 100644 index 00000000..40f338fd --- /dev/null +++ b/crates/vite_task_bin/test_bins/README.md @@ -0,0 +1 @@ +This package contains test binaries used in the tests for vite_task_bin crate. diff --git a/crates/vite_task_bin/test_bins/package.json b/crates/vite_task_bin/test_bins/package.json new file mode 100644 index 00000000..aad83f03 --- /dev/null +++ b/crates/vite_task_bin/test_bins/package.json @@ -0,0 +1,11 @@ +{ + "name": "vite-task-tests-bins", + "private": true, + "bin": { + "readfile": "./readfile.mjs" + }, + "dependencies": { + "oxlint": "catalog:", + "vite-task-tests-bins": "link:" + } +} diff --git a/crates/vite_task_bin/test_bins/readfile.mjs b/crates/vite_task_bin/test_bins/readfile.mjs new file mode 100755 index 00000000..d82e33e2 --- /dev/null +++ b/crates/vite_task_bin/test_bins/readfile.mjs @@ -0,0 +1,4 @@ +import { readFileSync } from 'fs'; + +const content = readFileSync(process.argv[2]); +process.stdout.write(content); diff --git a/crates/vite_task_bin/tests/bins/README.md b/crates/vite_task_bin/tests/bins/README.md deleted file mode 100644 index 12aadd2e..00000000 --- a/crates/vite_task_bin/tests/bins/README.md +++ /dev/null @@ -1 +0,0 @@ -THis folder contains test binaries used in the tests for vite_task_bin crate. diff --git a/crates/vite_task_bin/tests/bins/readfile b/crates/vite_task_bin/tests/bins/readfile deleted file mode 100755 index c8872e78..00000000 --- a/crates/vite_task_bin/tests/bins/readfile +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -cat $1 diff --git a/crates/vite_task_bin/tests/bins/readfile.cmd b/crates/vite_task_bin/tests/bins/readfile.cmd deleted file mode 100644 index df8df539..00000000 --- a/crates/vite_task_bin/tests/bins/readfile.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -type %1 diff --git a/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml b/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml index 89ab31c3..538e225d 100644 --- a/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml +++ b/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml @@ -1,3 +1,7 @@ [[plan]] name = "user task cache key" args = ["run", "hello"] + +[[plan]] +name = "direct synthetic task cache key" +args = ["lint"] diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/snapshots.rs index b65ef243..8bfdd15c 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/snapshots.rs @@ -139,7 +139,12 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { let envs: HashMap, Arc> = [( Arc::::from(OsStr::new("PATH")), Arc::::from( - std::env::current_dir().unwrap().join("tests").join("bins").into_os_string(), + std::env::current_dir() + .unwrap() + .join("test_bins") + .join("node_modules") + .join(".bin") + .into_os_string(), ), )] .into_iter() diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap new file mode 100644 index 00000000..a1aefa32 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap @@ -0,0 +1,56 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/fixtures/cache +--- +{ + "cli_args_without_program": [ + "lint" + ], + "cwd": "/", + "plan": { + "root_node": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "DirectSyntatic": { + "direct_execution_cache_key": [ + "lint" + ] + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap index f9aeeeba..c6751da4 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap @@ -64,13 +64,13 @@ input_file: crates/vite_task_bin/tests/fixtures/cache } }, "spawn_command": { - "program_path": "/tests/bins/readfile", + "program_path": "/test_bins/node_modules/.bin/readfile", "args": [ "hello.txt" ], "all_envs": { "FORCE_COLOR": "3", - "PATH": "/node_modules/.bin:/tests/bins" + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" }, "cwd": "/" } diff --git a/crates/vite_task_plan/src/error.rs b/crates/vite_task_plan/src/error.rs index 0ba65388..225f9e7a 100644 --- a/crates/vite_task_plan/src/error.rs +++ b/crates/vite_task_plan/src/error.rs @@ -1,6 +1,7 @@ use std::{env::JoinPathsError, ffi::OsStr, fmt::Display, path::Path, sync::Arc}; use vite_path::{AbsolutePath, relative::InvalidPathDataError}; +use vite_str::Str; use crate::{ context::{PlanContext, TaskCallStackDisplay, TaskRecursionError}, @@ -105,8 +106,11 @@ pub enum TaskPlanErrorKind { #[error(transparent)] TaskRecursionDetected(#[from] TaskRecursionError), - #[error("Invalid vite task command")] + #[error("Invalid vite task command: {program} with args {args:?} under cwd {cwd:?}")] ParsePlanRequestError { + program: Str, + args: Arc<[Str]>, + cwd: Arc, #[source] error: anyhow::Error, }, diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index 98c63c09..8ab60c53 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -21,6 +21,7 @@ use error::TaskPlanErrorKindResultExt; pub use error::{Error, TaskPlanErrorKind}; use execution_graph::ExecutionGraph; use in_process::InProcessExecution; +pub use path_env::get_path_env; use plan::{plan_query_request, plan_synthetic_request}; use plan_request::PlanRequest; use serde::{Serialize, ser::SerializeMap as _}; @@ -159,6 +160,7 @@ pub trait PlanRequestParser: Debug { &mut self, program: &str, args: &[Str], + path_env: Option<&Arc>, cwd: &Arc, ) -> anyhow::Result>; } diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 04ebb458..e10c66c9 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -146,11 +146,17 @@ async fn plan_task_as_execution_node( }; // Try to parse the args of an and_item to a plan request like `run -r build` + let path_env = get_path_env(context.envs()).cloned(); let plan_request = context .callbacks() - .get_plan_request(&and_item.program, &args, &cwd) + .get_plan_request(&and_item.program, &args, path_env.as_ref(), &cwd) .await - .map_err(|error| TaskPlanErrorKind::ParsePlanRequestError { error }) + .map_err(|error| TaskPlanErrorKind::ParsePlanRequestError { + program: and_item.program.clone(), + args: args.clone().into(), + cwd: Arc::clone(&cwd), + error, + }) .with_plan_context(&context)?; let execution_item_kind: ExecutionItemKind = match plan_request { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 416ba21c..4f3c8394 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,6 +36,15 @@ importers: specifier: 'catalog:' version: 0.10.0 + crates/vite_task_bin/test_bins: + dependencies: + oxlint: + specifier: 'catalog:' + version: 1.34.0(oxlint-tsgolint@0.10.0) + vite-task-tests-bins: + specifier: 'link:' + version: 'link:' + packages: '@oxlint-tsgolint/darwin-arm64@0.10.0': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index fd6770f7..635a7f28 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,6 @@ packages: - . + - crates/vite_task_bin/test_bins catalog: husky: ^9.1.7 From e931071f678cc65f6ccf3b91d59743b3408ec632 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 03:22:49 +0800 Subject: [PATCH 20/27] simplify session plan --- crates/vite_task/src/session/execute/mod.rs | 29 ++++--- crates/vite_task/src/session/mod.rs | 27 +------ .../{cache => cache-keys}/package.json | 0 .../{cache => cache-keys}/snapshots.toml | 5 ++ ...ic task cache key with cwd@cache-keys.snap | 50 ++++++++++++ ...t synthetic task cache key@cache-keys.snap | 50 ++++++++++++ ...uery - user task cache key@cache-keys.snap | 81 +++++++++++++++++++ .../snapshots__task graph@cache-keys.snap | 35 ++++++++ 8 files changed, 237 insertions(+), 40 deletions(-) rename crates/vite_task_bin/tests/fixtures/{cache => cache-keys}/package.json (100%) rename crates/vite_task_bin/tests/fixtures/{cache => cache-keys}/snapshots.toml (58%) create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap create mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap diff --git a/crates/vite_task/src/session/execute/mod.rs b/crates/vite_task/src/session/execute/mod.rs index f404f7a3..5569d23b 100644 --- a/crates/vite_task/src/session/execute/mod.rs +++ b/crates/vite_task/src/session/execute/mod.rs @@ -9,7 +9,8 @@ use vite_path::{AbsolutePath, RelativePathBuf, relative::InvalidPathDataError}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex, display::TaskDisplay}; use vite_task_plan::{ - ExecutionItem, ExecutionItemKind, LeafExecutionKind, SpawnExecution, TaskExecution, + ExecutionItem, ExecutionItemKind, ExecutionPlan, LeafExecutionKind, SpawnExecution, + TaskExecution, execution_graph::{ExecutionIx, ExecutionNodeIndex}, }; @@ -22,10 +23,7 @@ use super::{ }; use crate::{ Session, - session::{ - SessionExecutionPlan, - cache::{DirectExecutionCacheKey, UserTaskExecutionCacheKey}, - }, + session::cache::{DirectExecutionCacheKey, UserTaskExecutionCacheKey}, }; #[derive(Debug, thiserror::Error)] @@ -227,7 +225,7 @@ impl ExecutionContext<'_> { impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { pub async fn execute( &self, - plan: SessionExecutionPlan, + plan: ExecutionPlan, event_handler: &mut (dyn FnMut(ExecutionEvent) + '_), ) -> Result<(), ExecuteError> { let mut execution_context = ExecutionContext { @@ -237,14 +235,15 @@ impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { cache: &self.cache, cache_base_path: &self.workspace_path, }; - execution_context - .execute_item_kind( - plan.plan.root_node(), - ExecutionOrigin::CLIArgs { - args_without_program: &plan.cli_args_without_program, - cwd: &plan.cwd, - }, - ) - .await + Ok(()) + // execution_context + // .execute_item_kind( + // plan.plan.root_node(), + // ExecutionOrigin::CLIArgs { + // args_without_program: &plan.cli_args_without_program, + // cwd: &plan.cwd, + // }, + // ) + // .await } } diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index 74ba5f27..1e814af2 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -6,8 +6,6 @@ use std::{ffi::OsStr, fmt::Debug, sync::Arc}; use cache::ExecutionCache; use clap::{Parser, Subcommand}; -use nix::libc::PATH_MAX; -use serde::Serialize; use vite_path::{AbsolutePath, AbsolutePathBuf}; use vite_str::Str; use vite_task_graph::{IndexedTaskGraph, TaskGraph, TaskGraphLoadError, loader::UserConfigLoader}; @@ -206,29 +204,12 @@ impl<'a, CustomSubcommand> Session<'a, CustomSubcommand> { } } -/// Represents a planned execution of tasks in a session, including information for caching. -#[derive(Debug, Serialize)] -pub struct SessionExecutionPlan { - /// The original command-line arguments used to create this execution plan, excluding the program name. - /// - /// It's used to create cache keys for direct executions. See `DirectExecutionCacheKey` for details. - cli_args_without_program: Arc<[Str]>, - - /// The current working directory used to create this execution plan. - /// - /// It's used to create cache keys for direct executions. See `DirectExecutionCacheKey` for details. - cwd: Arc, - - /// The actual content of the execution plan. - plan: vite_task_plan::ExecutionPlan, -} - impl<'a, CustomSubcommand: clap::Subcommand> Session<'a, CustomSubcommand> { pub async fn plan( &mut self, cwd: Arc, cli_args: TaskCLIArgs, - ) -> Result { + ) -> Result { let path_env = get_path_env(&self.envs); let plan_request = self .plan_request_parser @@ -252,10 +233,6 @@ impl<'a, CustomSubcommand: clap::Subcommand> Session<'a, CustomSubcommand> { &mut self.lazy_task_graph, ) .await?; - Ok(SessionExecutionPlan { - cli_args_without_program: cli_args.original.iter().skip(1).cloned().collect(), // Skip program name - cwd, - plan, - }) + Ok(plan) } } diff --git a/crates/vite_task_bin/tests/fixtures/cache/package.json b/crates/vite_task_bin/tests/fixtures/cache-keys/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/cache/package.json rename to crates/vite_task_bin/tests/fixtures/cache-keys/package.json diff --git a/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml b/crates/vite_task_bin/tests/fixtures/cache-keys/snapshots.toml similarity index 58% rename from crates/vite_task_bin/tests/fixtures/cache/snapshots.toml rename to crates/vite_task_bin/tests/fixtures/cache-keys/snapshots.toml index 538e225d..1d4caff0 100644 --- a/crates/vite_task_bin/tests/fixtures/cache/snapshots.toml +++ b/crates/vite_task_bin/tests/fixtures/cache-keys/snapshots.toml @@ -5,3 +5,8 @@ args = ["run", "hello"] [[plan]] name = "direct synthetic task cache key" args = ["lint"] + +[[plan]] +name = "direct synthetic task cache key with cwd" +cwd = "subdir" +args = ["lint"] diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap new file mode 100644 index 00000000..9034f274 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap @@ -0,0 +1,50 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/fixtures/cache-keys +--- +{ + "root_node": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "subdir", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "DirectSyntatic": { + "direct_execution_cache_key": [ + "lint" + ] + } + }, + "origin_path": "subdir" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/subdir" + } + } + } + } +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap new file mode 100644 index 00000000..785fe04b --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap @@ -0,0 +1,50 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/fixtures/cache-keys +--- +{ + "root_node": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "DirectSyntatic": { + "direct_execution_cache_key": [ + "lint" + ] + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap new file mode 100644 index 00000000..d1e9eef3 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap @@ -0,0 +1,81 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/fixtures/cache-keys +--- +{ + "root_node": { + "Expanded": [ + { + "key": [ + "/", + "hello" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "hello", + "package_path": "/" + }, + "items": [ + { + "command_span": { + "start": 0, + "end": 18 + }, + "extra_args": [], + "plan_cwd": "/", + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "readfile" + } + }, + "args": [ + "hello.txt" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "UserTask": { + "task_name": "hello", + "and_item_index": 0 + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/readfile", + "args": [ + "hello.txt" + ], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } +} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap new file mode 100644 index 00000000..91e1bc17 --- /dev/null +++ b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap @@ -0,0 +1,35 @@ +--- +source: crates/vite_task_bin/tests/snapshots.rs +expression: task_graph_json +input_file: crates/vite_task_bin/tests/fixtures/cache-keys +--- +[ + { + "key": [ + "/", + "hello" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "hello", + "package_path": "/" + }, + "resolved_config": { + "command": "readfile hello.txt", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + } +] From 4f201c024e77ab24ab26077da7c382d4b335f1bc Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 09:55:06 +0800 Subject: [PATCH 21/27] restructure snapshot tests --- crates/vite_path/src/absolute/mod.rs | 6 +- ... name@transitive-dependency-workspace.snap | 31 ---- ...direct synthetic task cache key@cache.snap | 56 ------ ...ckage@transitive-dependency-workspace.snap | 45 ----- ...e cwd@transitive-dependency-workspace.snap | 45 ----- ...ds on@transitive-dependency-workspace.snap | 46 ----- ...itive@transitive-dependency-workspace.snap | 13 -- ...rsive@transitive-dependency-workspace.snap | 169 ------------------ ... name@transitive-dependency-workspace.snap | 76 -------- ... task@transitive-dependency-workspace.snap | 77 -------- ... task@transitive-dependency-workspace.snap | 23 --- ...itive@transitive-dependency-workspace.snap | 139 -------------- ...ckage@transitive-dependency-workspace.snap | 76 -------- ...ts__query - user task cache key@cache.snap | 88 --------- .../snapshots__task graph@cache-keys.snap | 35 ---- .../fixtures/cache-keys/package.json | 0 .../fixtures/cache-keys/snapshots.toml | 0 .../fixtures/cache-sharing/package.json | 0 .../fixtures/cache-sharing/pnpm-lock.yaml | 0 .../cache-sharing/pnpm-workspace.yaml | 0 .../comprehensive-task-graph/package.json | 0 .../packages/api/package.json | 0 .../packages/app/package.json | 0 .../packages/config/package.json | 0 .../packages/pkg#special/package.json | 0 .../packages/shared/package.json | 0 .../packages/tools/package.json | 0 .../packages/ui/package.json | 0 .../pnpm-workspace.yaml | 0 .../fixtures/conflict-test/package.json | 0 .../packages/scope-a-b/package.json | 0 .../packages/scope-a/package.json | 0 .../packages/test-package/package.json | 0 .../packages/test-package/vite.config.json | 0 .../conflict-test/pnpm-workspace.yaml | 0 .../package.json | 0 .../packages/a/package.json | 0 .../packages/a/vite.config.json | 0 .../packages/b/package.json | 0 .../pnpm-workspace.yaml | 0 .../fixtures/empty-package-test/package.json | 0 .../packages/another-empty/package.json | 0 .../packages/another-empty/vite.config.json | 0 .../packages/empty-name/package.json | 0 .../packages/empty-name/vite.config.json | 0 .../packages/normal-package/package.json | 0 .../packages/normal-package/vite.config.json | 0 .../empty-package-test/pnpm-workspace.yaml | 0 .../explicit-deps-workspace/package.json | 0 .../packages/app/package.json | 0 .../packages/app/vite.config.json | 0 .../packages/core/package.json | 0 .../packages/core/vite.config.json | 0 .../packages/utils/package.json | 0 .../packages/utils/vite.config.json | 0 .../pnpm-workspace.yaml | 0 .../fingerprint-ignore-test/README.md | 0 .../fingerprint-ignore-test/package.json | 0 .../fingerprint-ignore-test/vite.config.json | 0 .../apps/web/package.json | 0 .../package.json | 0 .../packages/app/package.json | 0 .../packages/core/package.json | 0 .../packages/utils/package.json | 0 .../pnpm-workspace.yaml | 0 .../packages/a/package.json | 0 .../packages/a/src/.gitkeep | 0 .../packages/a/vite.config.json | 0 .../packages/another-a/package.json | 0 .../packages/b1/package.json | 0 .../packages/b2/package.json | 0 .../packages/c/package.json | 0 .../pnpm-workspace.yaml | 0 .../snapshots.toml | 0 .../{snapshots.rs => test_snapshots/main.rs} | 22 ++- ...c task cache key with cwd@cache-keys.snap} | 4 +- ... synthetic task cache key@cache-keys.snap} | 4 +- ...ery - user task cache key@cache-keys.snap} | 4 +- ...est_snapshots__task graph@cache-keys.snap} | 4 +- ..._snapshots__task graph@cache-sharing.snap} | 4 +- ..._task graph@comprehensive-task-graph.snap} | 4 +- ..._snapshots__task graph@conflict-test.snap} | 4 +- ...ph@dependency-both-topo-and-explicit.snap} | 4 +- ...shots__task graph@empty-package-test.snap} | 4 +- ...__task graph@explicit-deps-workspace.snap} | 4 +- ...__task graph@fingerprint-ignore-test.snap} | 4 +- ...raph@recursive-topological-workspace.snap} | 4 +- ...raph@transitive-dependency-workspace.snap} | 4 +- 88 files changed, 45 insertions(+), 954 deletions(-) delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap delete mode 100644 crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/cache-keys/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/cache-keys/snapshots.toml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/cache-sharing/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/cache-sharing/pnpm-lock.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/cache-sharing/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/api/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/app/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/config/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/pkg#special/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/shared/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/tools/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/packages/ui/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/comprehensive-task-graph/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/conflict-test/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/conflict-test/packages/scope-a-b/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/conflict-test/packages/scope-a/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/conflict-test/packages/test-package/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/conflict-test/packages/test-package/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/conflict-test/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/dependency-both-topo-and-explicit/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/dependency-both-topo-and-explicit/packages/a/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/dependency-both-topo-and-explicit/packages/b/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/packages/another-empty/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/packages/another-empty/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/packages/empty-name/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/packages/empty-name/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/packages/normal-package/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/packages/normal-package/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/empty-package-test/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/packages/app/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/packages/app/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/packages/core/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/packages/core/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/packages/utils/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/packages/utils/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/explicit-deps-workspace/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/fingerprint-ignore-test/README.md (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/fingerprint-ignore-test/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/fingerprint-ignore-test/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/recursive-topological-workspace/apps/web/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/recursive-topological-workspace/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/recursive-topological-workspace/packages/app/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/recursive-topological-workspace/packages/core/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/recursive-topological-workspace/packages/utils/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/recursive-topological-workspace/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/a/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/a/vite.config.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/another-a/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/b1/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/b2/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/packages/c/package.json (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml (100%) rename crates/vite_task_bin/tests/{ => test_snapshots}/fixtures/transitive-dependency-workspace/snapshots.toml (100%) rename crates/vite_task_bin/tests/{snapshots.rs => test_snapshots/main.rs} (91%) rename crates/vite_task_bin/tests/{snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap => test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap} (90%) rename crates/vite_task_bin/tests/{snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap => test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key@cache-keys.snap} (90%) rename crates/vite_task_bin/tests/{snapshots/snapshots__query - user task cache key@cache-keys.snap => test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap} (94%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@cache.snap => test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap} (83%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@cache-sharing.snap => test_snapshots/snapshots/test_snapshots__task graph@cache-sharing.snap} (93%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@comprehensive-task-graph.snap => test_snapshots/snapshots/test_snapshots__task graph@comprehensive-task-graph.snap} (99%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@conflict-test.snap => test_snapshots/snapshots/test_snapshots__task graph@conflict-test.snap} (94%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap => test_snapshots/snapshots/test_snapshots__task graph@dependency-both-topo-and-explicit.snap} (90%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@empty-package-test.snap => test_snapshots/snapshots/test_snapshots__task graph@empty-package-test.snap} (98%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@explicit-deps-workspace.snap => test_snapshots/snapshots/test_snapshots__task graph@explicit-deps-workspace.snap} (98%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@fingerprint-ignore-test.snap => test_snapshots/snapshots/test_snapshots__task graph@fingerprint-ignore-test.snap} (85%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@recursive-topological-workspace.snap => test_snapshots/snapshots/test_snapshots__task graph@recursive-topological-workspace.snap} (97%) rename crates/vite_task_bin/tests/{snapshots/snapshots__task graph@transitive-dependency-workspace.snap => test_snapshots/snapshots/test_snapshots__task graph@transitive-dependency-workspace.snap} (97%) diff --git a/crates/vite_path/src/absolute/mod.rs b/crates/vite_path/src/absolute/mod.rs index 139976d7..909a2d52 100644 --- a/crates/vite_path/src/absolute/mod.rs +++ b/crates/vite_path/src/absolute/mod.rs @@ -28,12 +28,12 @@ impl AsRef for AbsolutePath { impl Debug for AbsolutePath { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut debug_tuple = f.debug_tuple("AbsolutePath"); - + #[cfg(feature = "absolute-redaction")] if let Some(redacted_path) = self.try_redact().unwrap() { debug_tuple.field(&redacted_path); - } else { - debug_tuple.field(&&self.0); + return debug_tuple.finish(); } + debug_tuple.field(&&self.0); debug_tuple.finish() } } diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap deleted file mode 100644 index d4a46c7a..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - ambiguous task name@transitive-dependency-workspace.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: err -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -Error { - task_call_stack: TaskCallStackDisplay { - frames: [], - }, - kind: TaskQueryError( - SpecifierLookupError { - specifier: TaskSpecifier { - package_name: Some( - "@test/a", - ), - task_name: "build", - }, - lookup_error: AmbiguousPackageName { - package_name: "@test/a", - package_paths: [ - AbsolutePath( - "/packages/a", - ), - AbsolutePath( - "/packages/another-a", - ), - ], - }, - }, - ), -} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap deleted file mode 100644 index a1aefa32..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan_json" -input_file: crates/vite_task_bin/tests/fixtures/cache ---- -{ - "cli_args_without_program": [ - "lint" - ], - "cwd": "/", - "plan": { - "root_node": { - "Leaf": { - "Spawn": { - "cache_metadata": { - "spawn_fingerprint": { - "cwd": "", - "program_fingerprint": { - "OutsideWorkspace": { - "program_name": "oxlint" - } - }, - "args": [], - "env_fingerprints": { - "fingerprinted_envs": {}, - "pass_through_env_config": [ - "" - ] - }, - "fingerprint_ignores": null - }, - "execution_cache_key": { - "kind": { - "DirectSyntatic": { - "direct_execution_cache_key": [ - "lint" - ] - } - }, - "origin_path": "" - } - }, - "spawn_command": { - "program_path": "/test_bins/node_modules/.bin/oxlint", - "args": [], - "all_envs": { - "FORCE_COLOR": "3", - "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" - }, - "cwd": "/" - } - } - } - } - } -} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap deleted file mode 100644 index 184d2e7f..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under different package@transitive-dependency-workspace.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "@test/c#build", - ], - cwd: "/packages/a", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/c", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "build", - package_path: "/packages/c", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "C", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap deleted file mode 100644 index f92d2276..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - explicit package name under non-package cwd@transitive-dependency-workspace.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "@test/c#build", - ], - cwd: "/", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/c", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "build", - package_path: "/packages/c", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "C", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap deleted file mode 100644 index 503d5a75..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - ignore depends on@transitive-dependency-workspace.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "--ignore-depends-on", - "build", - ], - cwd: "/packages/a", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/a", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "A", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap deleted file mode 100644 index 3114fa95..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive and transitive@transitive-dependency-workspace.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: err -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -Error { - task_call_stack: TaskCallStackDisplay { - frames: [], - }, - kind: ParsePlanRequestError { - error: RecursiveTransitiveConflict, - }, -} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap deleted file mode 100644 index 369405df..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - recursive@transitive-dependency-workspace.snap +++ /dev/null @@ -1,169 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "--recursive", - "build", - ], - cwd: "/", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/a", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "A", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/a", "test"): (), - ("/packages/b2", "build"): (), - ("/packages/c", "build"): (), - }, - ), - ("/packages/a", "test"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "test", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 11, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "test", - "a", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - ("/packages/another-a", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/another-a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 23, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "another", - "A", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - ("/packages/b2", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/b2", - task_name: "build", - package_path: "/packages/b2", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 13, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "build", - "b2", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/c", "build"): (), - }, - ), - ("/packages/c", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "build", - package_path: "/packages/c", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "C", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap deleted file mode 100644 index 2249a1ad..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - simple task by name@transitive-dependency-workspace.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "build", - ], - cwd: "/packages/a", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/a", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "A", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/a", "test"): (), - }, - ), - ("/packages/a", "test"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "test", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 11, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "test", - "a", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap deleted file mode 100644 index 80a892b5..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive in package without the task@transitive-dependency-workspace.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "--transitive", - "lint", - ], - cwd: "/packages/a", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/b1", "lint"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/b1", - task_name: "lint", - package_path: "/packages/b1", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 12, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "lint", - "b1", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/c", "lint"): (), - }, - ), - ("/packages/c", "lint"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "lint", - package_path: "/packages/c", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 11, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "lint", - "c", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap deleted file mode 100644 index 7e634ea3..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive non existent task@transitive-dependency-workspace.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: err -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -Error { - task_call_stack: TaskCallStackDisplay { - frames: [], - }, - kind: TaskQueryError( - SpecifierLookupError { - specifier: TaskSpecifier { - package_name: None, - task_name: "non-existent-task", - }, - lookup_error: TaskNameNotFound { - package_name: "@test/a", - task_name: "non-existent-task", - package_index: NodeIndex(PackageIx(0)), - }, - }, - ), -} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap deleted file mode 100644 index 09226351..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - transitive@transitive-dependency-workspace.snap +++ /dev/null @@ -1,139 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "--transitive", - "build", - ], - cwd: "/packages/a", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/a", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "A", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/a", "test"): (), - ("/packages/b2", "build"): (), - ("/packages/c", "build"): (), - }, - ), - ("/packages/a", "test"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "test", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 11, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "test", - "a", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - ("/packages/b2", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/b2", - task_name: "build", - package_path: "/packages/b2", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 13, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "build", - "b2", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/c", "build"): (), - }, - ), - ("/packages/c", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/c", - task_name: "build", - package_path: "/packages/c", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/packages/a", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "C", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap deleted file mode 100644 index 6396c831..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - under subfolder of package@transitive-dependency-workspace.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan" -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace ---- -SessionExecutionPlan( - cli_args_without_program: [ - "run", - "build", - ], - cwd: "/packages/a/src", - plan: ExecutionPlan( - root_node: Expanded({ - ("/packages/a", "build"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "build", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 15, - ), - extra_args: [], - plan_cwd: "/packages/a/src", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "Building", - "A", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: { - ("/packages/a", "test"): (), - }, - ), - ("/packages/a", "test"): DiGraphValue( - node: TaskExecution( - task_display: TaskDisplay( - package_name: "@test/a", - task_name: "test", - package_path: "/packages/a", - ), - items: [ - ExecutionItem( - command_span: Range( - start: 0, - end: 11, - ), - extra_args: [], - plan_cwd: "/packages/a/src", - kind: Leaf(InProcess(InProcessExecution( - kind: Echo( - strings: [ - "test", - "a", - ], - trailing_newline: true, - ), - ))), - ), - ], - ), - neighbors: {}, - ), - }), - ), -) diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap b/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap deleted file mode 100644 index c6751da4..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: "&plan_json" -input_file: crates/vite_task_bin/tests/fixtures/cache ---- -{ - "cli_args_without_program": [ - "run", - "hello" - ], - "cwd": "/", - "plan": { - "root_node": { - "Expanded": [ - { - "key": [ - "/", - "hello" - ], - "node": { - "task_display": { - "package_name": "", - "task_name": "hello", - "package_path": "/" - }, - "items": [ - { - "command_span": { - "start": 0, - "end": 18 - }, - "extra_args": [], - "plan_cwd": "/", - "kind": { - "Leaf": { - "Spawn": { - "cache_metadata": { - "spawn_fingerprint": { - "cwd": "", - "program_fingerprint": { - "OutsideWorkspace": { - "program_name": "readfile" - } - }, - "args": [ - "hello.txt" - ], - "env_fingerprints": { - "fingerprinted_envs": {}, - "pass_through_env_config": [ - "" - ] - }, - "fingerprint_ignores": null - }, - "execution_cache_key": { - "kind": { - "UserTask": { - "task_name": "hello", - "and_item_index": 0 - } - }, - "origin_path": "" - } - }, - "spawn_command": { - "program_path": "/test_bins/node_modules/.bin/readfile", - "args": [ - "hello.txt" - ], - "all_envs": { - "FORCE_COLOR": "3", - "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" - }, - "cwd": "/" - } - } - } - } - } - ] - }, - "neighbors": [] - } - ] - } - } -} diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap b/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap deleted file mode 100644 index 91e1bc17..00000000 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-keys.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/vite_task_bin/tests/snapshots.rs -expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/cache-keys ---- -[ - { - "key": [ - "/", - "hello" - ], - "node": { - "task_display": { - "package_name": "", - "task_name": "hello", - "package_path": "/" - }, - "resolved_config": { - "command": "readfile hello.txt", - "resolved_options": { - "cwd": "/", - "cache_config": { - "env_config": { - "fingerprinted_envs": [], - "pass_through_envs": [ - "" - ] - } - } - } - } - }, - "neighbors": [] - } -] diff --git a/crates/vite_task_bin/tests/fixtures/cache-keys/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/cache-keys/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json diff --git a/crates/vite_task_bin/tests/fixtures/cache-keys/snapshots.toml b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/cache-keys/snapshots.toml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml diff --git a/crates/vite_task_bin/tests/fixtures/cache-sharing/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/cache-sharing/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing/package.json diff --git a/crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-lock.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing/pnpm-lock.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-lock.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing/pnpm-lock.yaml diff --git a/crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/cache-sharing/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/api/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/api/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/api/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/api/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/app/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/app/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/app/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/app/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/config/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/config/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/config/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/config/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/pkg#special/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/pkg#special/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/pkg#special/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/shared/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/shared/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/shared/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/shared/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/tools/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/tools/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/tools/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/tools/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/ui/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/ui/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/packages/ui/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/packages/ui/package.json diff --git a/crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/comprehensive-task-graph/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/conflict-test/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/conflict-test/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/package.json diff --git a/crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a-b/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/scope-a-b/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a-b/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/scope-a-b/package.json diff --git a/crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/scope-a/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/conflict-test/packages/scope-a/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/scope-a/package.json diff --git a/crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/test-package/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/test-package/package.json diff --git a/crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/test-package/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/conflict-test/packages/test-package/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/packages/test-package/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/conflict-test/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/conflict-test/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/package.json diff --git a/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/packages/a/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/packages/a/package.json diff --git a/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/packages/a/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/packages/b/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/packages/b/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/packages/b/package.json diff --git a/crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/package.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/another-empty/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/another-empty/package.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/another-empty/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/packages/another-empty/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/another-empty/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/empty-name/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/empty-name/package.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/empty-name/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/packages/empty-name/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/empty-name/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/normal-package/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/normal-package/package.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/normal-package/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/packages/normal-package/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/packages/normal-package/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/empty-package-test/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/empty-package-test/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/package.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/app/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/app/package.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/app/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/app/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/app/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/core/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/core/package.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/core/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/core/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/core/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/utils/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/utils/package.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/utils/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/packages/utils/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/packages/utils/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/explicit-deps-workspace/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/README.md b/crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test/README.md similarity index 100% rename from crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/README.md rename to crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test/README.md diff --git a/crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test/package.json diff --git a/crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/apps/web/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/apps/web/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/apps/web/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/apps/web/package.json diff --git a/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/package.json diff --git a/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/app/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/packages/app/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/app/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/packages/app/package.json diff --git a/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/core/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/packages/core/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/core/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/packages/core/package.json diff --git a/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/utils/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/packages/utils/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/packages/utils/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/packages/utils/package.json diff --git a/crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/recursive-topological-workspace/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/a/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/a/package.json diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/a/src/.gitkeep diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/a/vite.config.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/a/vite.config.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/a/vite.config.json diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/another-a/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/another-a/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/another-a/package.json diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/b1/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b1/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/b1/package.json diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/b2/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/b2/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/b2/package.json diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/c/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/c/package.json similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/packages/c/package.json rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/packages/c/package.json diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/pnpm-workspace.yaml diff --git a/crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml b/crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/snapshots.toml similarity index 100% rename from crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace/snapshots.toml rename to crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace/snapshots.toml diff --git a/crates/vite_task_bin/tests/snapshots.rs b/crates/vite_task_bin/tests/test_snapshots/main.rs similarity index 91% rename from crates/vite_task_bin/tests/snapshots.rs rename to crates/vite_task_bin/tests/test_snapshots/main.rs index 8bfdd15c..24be50e8 100644 --- a/crates/vite_task_bin/tests/snapshots.rs +++ b/crates/vite_task_bin/tests/test_snapshots/main.rs @@ -33,12 +33,16 @@ fn visit_json(value: &mut serde_json::Value, f: &mut impl FnMut(&mut serde_json: } } -fn redact_strs(value: &mut serde_json::Value, redactions: &[(&str, &str)]) { +fn redact_paths(value: &mut serde_json::Value, redactions: &[(&str, &str)]) { use cow_utils::CowUtils as _; visit_json(value, &mut |v| { if let serde_json::Value::String(s) = v { for (from, to) in redactions { - if let Cow::Owned(replaced) = s.as_str().cow_replace(from, to) { + if let Cow::Owned(mut replaced) = s.as_str().cow_replace(from, to) { + if cfg!(windows) { + // Also replace with backslashes on Windows + replaced = replaced.cow_replace("\\", "/").into_owned(); + } *s = replaced; } } @@ -49,7 +53,7 @@ fn redact_strs(value: &mut serde_json::Value, redactions: &[(&str, &str)]) { fn redact_snapshot(value: &impl Serialize, workspace_root: &str) -> serde_json::Value { let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); let mut json_value = serde_json::to_value(value).unwrap(); - redact_strs( + redact_paths( &mut json_value, &[(workspace_root, ""), (manifest_dir.as_str(), "")], ); @@ -98,7 +102,7 @@ struct E2e { } #[derive(serde::Deserialize, Default)] -struct PlansFile { +struct SnapshotsFile { #[serde(rename = "plan", default)] // toml usually uses singular for arrays pub plans: Vec, #[serde(rename = "e2e", default)] // toml usually uses singular for arrays @@ -129,7 +133,7 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { ); let cases_toml_path = fixture_path.join("snapshots.toml"); - let cases_file: PlansFile = match std::fs::read(&cases_toml_path) { + let cases_file: SnapshotsFile = match std::fs::read(&cases_toml_path) { Ok(content) => toml::from_slice(&content).unwrap(), Err(err) if err.kind() == std::io::ErrorKind::NotFound => Default::default(), Err(err) => panic!("Failed to read cases.toml for fixture {}: {}", fixture_name, err), @@ -229,5 +233,11 @@ fn test_snapshots() { let tmp_dir = tempfile::tempdir().unwrap(); let tmp_dir_path = AbsolutePath::new(tmp_dir.path()).unwrap(); - insta::glob!("fixtures/*", |case_path| run_case(&tokio_runtime, tmp_dir_path, case_path)); + let tests_dir = std::env::current_dir().unwrap().join("tests"); + + insta::glob!(tests_dir, "test_snapshots/fixtures/*", |case_path| run_case( + &tokio_runtime, + tmp_dir_path, + case_path + )); } diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap similarity index 90% rename from crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap index 9034f274..9686af9a 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: "&plan_json" -input_file: crates/vite_task_bin/tests/fixtures/cache-keys +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys --- { "root_node": { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key@cache-keys.snap similarity index 90% rename from crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key@cache-keys.snap index 785fe04b..ae527c5b 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - direct synthetic task cache key@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key@cache-keys.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: "&plan_json" -input_file: crates/vite_task_bin/tests/fixtures/cache-keys +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys --- { "root_node": { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap similarity index 94% rename from crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap index d1e9eef3..38b0c529 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__query - user task cache key@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: "&plan_json" -input_file: crates/vite_task_bin/tests/fixtures/cache-keys +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys --- { "root_node": { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap similarity index 83% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap index 345ddb42..0eabcb25 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/cache +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-sharing.snap similarity index 93% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-sharing.snap index bef31544..706cec7e 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@cache-sharing.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-sharing.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/cache-sharing +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-sharing --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@comprehensive-task-graph.snap similarity index 99% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@comprehensive-task-graph.snap index 3f2eb5a4..a783d69b 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@comprehensive-task-graph.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@comprehensive-task-graph.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/comprehensive-task-graph +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/comprehensive-task-graph --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@conflict-test.snap similarity index 94% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@conflict-test.snap index c34aba11..f50f06f6 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@conflict-test.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@conflict-test.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/conflict-test +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/conflict-test --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@dependency-both-topo-and-explicit.snap similarity index 90% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@dependency-both-topo-and-explicit.snap index a4514bf0..44475332 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@dependency-both-topo-and-explicit.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@dependency-both-topo-and-explicit.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/dependency-both-topo-and-explicit +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/dependency-both-topo-and-explicit --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@empty-package-test.snap similarity index 98% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@empty-package-test.snap index c237e876..5a53bbd2 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@empty-package-test.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@empty-package-test.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/empty-package-test +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/empty-package-test --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@explicit-deps-workspace.snap similarity index 98% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@explicit-deps-workspace.snap index f1d78ab5..1df71374 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@explicit-deps-workspace.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@explicit-deps-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/explicit-deps-workspace +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/explicit-deps-workspace --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@fingerprint-ignore-test.snap similarity index 85% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@fingerprint-ignore-test.snap index 64bbc7be..bcc76c8a 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@fingerprint-ignore-test.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@fingerprint-ignore-test.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/fingerprint-ignore-test +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/fingerprint-ignore-test --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@recursive-topological-workspace.snap similarity index 97% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@recursive-topological-workspace.snap index 5d653d9f..74c5fa12 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@recursive-topological-workspace.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@recursive-topological-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/recursive-topological-workspace +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/recursive-topological-workspace --- [ { diff --git a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@transitive-dependency-workspace.snap similarity index 97% rename from crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap rename to crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@transitive-dependency-workspace.snap index 5457027b..5a8793a5 100644 --- a/crates/vite_task_bin/tests/snapshots/snapshots__task graph@transitive-dependency-workspace.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@transitive-dependency-workspace.snap @@ -1,7 +1,7 @@ --- -source: crates/vite_task_bin/tests/snapshots.rs +source: crates/vite_task_bin/tests/test_snapshots/main.rs expression: task_graph_json -input_file: crates/vite_task_bin/tests/fixtures/transitive-dependency-workspace +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/transitive-dependency-workspace --- [ { From eabe1be5b7698d0acbb919ca09de1d75d44d6ddd Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 14:44:14 +0800 Subject: [PATCH 22/27] fix cache key --- crates/vite_task/src/cli/mod.rs | 2 +- crates/vite_task_bin/src/lib.rs | 5 +- .../fixtures/cache-keys/package.json | 2 +- .../fixtures/cache-keys/snapshots.toml | 10 +- .../tests/test_snapshots/main.rs | 109 +++--------------- .../tests/test_snapshots/redact.rs | 76 ++++++++++++ ... cache key with extra args@cache-keys.snap | 50 ++++++++ ... cache key with extra args@cache-keys.snap | 83 +++++++++++++ ...uery - user task cache key@cache-keys.snap | 20 ++-- ...test_snapshots__task graph@cache-keys.snap | 6 +- 10 files changed, 252 insertions(+), 111 deletions(-) create mode 100644 crates/vite_task_bin/tests/test_snapshots/redact.rs create mode 100644 crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap create mode 100644 crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index 96e57ba6..72b6afaa 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -83,7 +83,7 @@ pub(crate) enum BuiltInCommand { ignore_depends_on: bool, /// Additional arguments to pass to the tasks - #[clap(trailing_var_arg = true)] + #[clap(trailing_var_arg = true, allow_hyphen_values = true)] additional_args: Vec, }, } diff --git a/crates/vite_task_bin/src/lib.rs b/crates/vite_task_bin/src/lib.rs index bae77ab3..ec51c189 100644 --- a/crates/vite_task_bin/src/lib.rs +++ b/crates/vite_task_bin/src/lib.rs @@ -15,7 +15,10 @@ use vite_task::{CLIArgs, Session, SessionCallbacks, plan_request::SyntheticPlanR #[derive(Debug, Subcommand)] pub enum CustomTaskSubcommand { /// oxlint - Lint { args: Vec }, + Lint { + #[clap(allow_hyphen_values = true, trailing_var_arg = true)] + args: Vec, + }, } // These are the subcommands that is not handled by vite-task diff --git a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json index 918238dc..3f45091c 100644 --- a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json +++ b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json @@ -1,5 +1,5 @@ { "scripts": { - "hello": "readfile hello.txt" + "lint": "vite lint" } } diff --git a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml index 1d4caff0..1c0a0753 100644 --- a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml +++ b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml @@ -1,6 +1,10 @@ [[plan]] name = "user task cache key" -args = ["run", "hello"] +args = ["run", "lint"] + +[[plan]] +name = "user task cache key with extra args" +args = ["run", "lint", "--fix"] [[plan]] name = "direct synthetic task cache key" @@ -10,3 +14,7 @@ args = ["lint"] name = "direct synthetic task cache key with cwd" cwd = "subdir" args = ["lint"] + +[[plan]] +name = "direct synthetic task cache key with extra args" +args = ["lint"] diff --git a/crates/vite_task_bin/tests/test_snapshots/main.rs b/crates/vite_task_bin/tests/test_snapshots/main.rs index 24be50e8..15773299 100644 --- a/crates/vite_task_bin/tests/test_snapshots/main.rs +++ b/crates/vite_task_bin/tests/test_snapshots/main.rs @@ -1,93 +1,16 @@ -use core::panic; -use std::{ - borrow::Cow, collections::HashMap, convert::Infallible, ffi::OsStr, path::Path, sync::Arc, -}; +mod redact; + +use std::{collections::HashMap, convert::Infallible, ffi::OsStr, path::Path, sync::Arc}; -use clap::Parser; use copy_dir::copy_dir; -use insta::internals::Content; -use petgraph::visit::EdgeRef as _; -use serde::Serialize; +use redact::redact_snapshot; use tokio::runtime::Runtime; -use vite_path::{AbsolutePath, RelativePathBuf, redaction::redact_absolute_paths}; +use vite_path::{AbsolutePath, RelativePathBuf}; use vite_str::Str; use vite_task::{CLIArgs, Session}; use vite_task_bin::CustomTaskSubcommand; -use vite_task_graph::config::DEFAULT_PASSTHROUGH_ENVS; use vite_workspace::find_workspace_root; -fn visit_json(value: &mut serde_json::Value, f: &mut impl FnMut(&mut serde_json::Value)) { - f(value); - match value { - serde_json::Value::Array(arr) => { - for item in arr { - visit_json(item, f); - } - } - serde_json::Value::Object(map) => { - for (_key, val) in map { - visit_json(val, f); - } - } - _ => {} - } -} - -fn redact_paths(value: &mut serde_json::Value, redactions: &[(&str, &str)]) { - use cow_utils::CowUtils as _; - visit_json(value, &mut |v| { - if let serde_json::Value::String(s) = v { - for (from, to) in redactions { - if let Cow::Owned(mut replaced) = s.as_str().cow_replace(from, to) { - if cfg!(windows) { - // Also replace with backslashes on Windows - replaced = replaced.cow_replace("\\", "/").into_owned(); - } - *s = replaced; - } - } - } - }); -} - -fn redact_snapshot(value: &impl Serialize, workspace_root: &str) -> serde_json::Value { - let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); - let mut json_value = serde_json::to_value(value).unwrap(); - redact_paths( - &mut json_value, - &[(workspace_root, ""), (manifest_dir.as_str(), "")], - ); - - visit_json(&mut json_value, &mut |v| { - let serde_json::Value::Array(array) = v else { - return; - }; - let contains_all_default_pass_through_envs = - DEFAULT_PASSTHROUGH_ENVS.iter().all(|default_pass_through_envs| { - array.iter().any(|item| { - if let serde_json::Value::String(s) = item { - s == *default_pass_through_envs - } else { - false - } - }) - }); - // Remove default pass-through envs from snapshots to reduce noise - if contains_all_default_pass_through_envs { - array.retain(|item| { - if let serde_json::Value::String(s) = item { - !DEFAULT_PASSTHROUGH_ENVS.contains(&s.as_str()) - } else { - true - } - }); - array.push(serde_json::Value::String("".to_string())); - } - }); - - json_value -} - #[derive(serde::Deserialize, Debug)] struct Plan { pub name: Str, @@ -104,9 +27,9 @@ struct E2e { #[derive(serde::Deserialize, Default)] struct SnapshotsFile { #[serde(rename = "plan", default)] // toml usually uses singular for arrays - pub plans: Vec, + pub plan_cases: Vec, #[serde(rename = "e2e", default)] // toml usually uses singular for arrays - pub e2es: Vec, + pub e2e_cases: Vec, } fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { @@ -172,18 +95,19 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { ); insta::assert_json_snapshot!("task graph", task_graph_json); - for plan in cases_file.plans { + for plan in cases_file.plan_cases { let snapshot_name = format!("query - {}", plan.name); - let cli_args = CLIArgs::::try_parse_from( + let cli_args = match CLIArgs::::try_parse_from( std::iter::once("vite") // dummy program name .chain(plan.args.iter().map(|s| s.as_str())), - ) - .expect(&format!( - "Failed to parse CLI args for plan '{}' in '{}'", - plan.name, fixture_name - )); - + ) { + Ok(ok) => ok, + Err(err) => { + insta::assert_snapshot!(snapshot_name, err); + continue; + } + }; let task_cli_args = match cli_args { CLIArgs::Task(task_cli_args) => task_cli_args, CLIArgs::NonTask(never) => match never {}, @@ -224,6 +148,7 @@ fn run_case(runtime: &Runtime, tmpdir: &AbsolutePath, fixture_path: &Path) { // snapshot_execution_graph(&execution_graph, &indexed_task_graph); // insta::assert_json_snapshot!(snapshot_name, execution_graph_snapshot); } + for e2e in cases_file.e2e_cases {} }); } diff --git a/crates/vite_task_bin/tests/test_snapshots/redact.rs b/crates/vite_task_bin/tests/test_snapshots/redact.rs new file mode 100644 index 00000000..074048d1 --- /dev/null +++ b/crates/vite_task_bin/tests/test_snapshots/redact.rs @@ -0,0 +1,76 @@ +use std::borrow::Cow; + +use serde::Serialize; +use vite_task_graph::config::DEFAULT_PASSTHROUGH_ENVS; + +fn visit_json(value: &mut serde_json::Value, f: &mut impl FnMut(&mut serde_json::Value)) { + f(value); + match value { + serde_json::Value::Array(arr) => { + for item in arr { + visit_json(item, f); + } + } + serde_json::Value::Object(map) => { + for (_key, val) in map { + visit_json(val, f); + } + } + _ => {} + } +} + +fn redact_paths(value: &mut serde_json::Value, redactions: &[(&str, &str)]) { + use cow_utils::CowUtils as _; + visit_json(value, &mut |v| { + if let serde_json::Value::String(s) = v { + for (from, to) in redactions { + if let Cow::Owned(mut replaced) = s.as_str().cow_replace(from, to) { + if cfg!(windows) { + // Also replace with backslashes on Windows + replaced = replaced.cow_replace("\\", "/").into_owned(); + } + *s = replaced; + } + } + } + }); +} + +pub fn redact_snapshot(value: &impl Serialize, workspace_root: &str) -> serde_json::Value { + let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + let mut json_value = serde_json::to_value(value).unwrap(); + redact_paths( + &mut json_value, + &[(workspace_root, ""), (manifest_dir.as_str(), "")], + ); + + visit_json(&mut json_value, &mut |v| { + let serde_json::Value::Array(array) = v else { + return; + }; + let contains_all_default_pass_through_envs = + DEFAULT_PASSTHROUGH_ENVS.iter().all(|default_pass_through_envs| { + array.iter().any(|item| { + if let serde_json::Value::String(s) = item { + s == *default_pass_through_envs + } else { + false + } + }) + }); + // Remove default pass-through envs from snapshots to reduce noise + if contains_all_default_pass_through_envs { + array.retain(|item| { + if let serde_json::Value::String(s) = item { + !DEFAULT_PASSTHROUGH_ENVS.contains(&s.as_str()) + } else { + true + } + }); + array.push(serde_json::Value::String("".to_string())); + } + }); + + json_value +} diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap new file mode 100644 index 00000000..ae527c5b --- /dev/null +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap @@ -0,0 +1,50 @@ +--- +source: crates/vite_task_bin/tests/test_snapshots/main.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys +--- +{ + "root_node": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "DirectSyntatic": { + "direct_execution_cache_key": [ + "lint" + ] + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } +} diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap new file mode 100644 index 00000000..3487f29b --- /dev/null +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap @@ -0,0 +1,83 @@ +--- +source: crates/vite_task_bin/tests/test_snapshots/main.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys +--- +{ + "root_node": { + "Expanded": [ + { + "key": [ + "/", + "lint" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "lint", + "package_path": "/" + }, + "items": [ + { + "command_span": { + "start": 0, + "end": 9 + }, + "extra_args": [ + "--fix" + ], + "plan_cwd": "/", + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [ + "--fix" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "UserTask": { + "task_name": "lint", + "and_item_index": 0 + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [ + "--fix" + ], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } +} diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap index 38b0c529..325f7541 100644 --- a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap @@ -9,19 +9,19 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys { "key": [ "/", - "hello" + "lint" ], "node": { "task_display": { "package_name": "", - "task_name": "hello", + "task_name": "lint", "package_path": "/" }, "items": [ { "command_span": { "start": 0, - "end": 18 + "end": 9 }, "extra_args": [], "plan_cwd": "/", @@ -33,12 +33,10 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys "cwd": "", "program_fingerprint": { "OutsideWorkspace": { - "program_name": "readfile" + "program_name": "oxlint" } }, - "args": [ - "hello.txt" - ], + "args": [], "env_fingerprints": { "fingerprinted_envs": {}, "pass_through_env_config": [ @@ -50,7 +48,7 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys "execution_cache_key": { "kind": { "UserTask": { - "task_name": "hello", + "task_name": "lint", "and_item_index": 0 } }, @@ -58,10 +56,8 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys } }, "spawn_command": { - "program_path": "/test_bins/node_modules/.bin/readfile", - "args": [ - "hello.txt" - ], + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [], "all_envs": { "FORCE_COLOR": "3", "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap index 0eabcb25..5eace13d 100644 --- a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap @@ -7,16 +7,16 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys { "key": [ "/", - "hello" + "lint" ], "node": { "task_display": { "package_name": "", - "task_name": "hello", + "task_name": "lint", "package_path": "/" }, "resolved_config": { - "command": "readfile hello.txt", + "command": "vite lint", "resolved_options": { "cwd": "/", "cache_config": { From 1186840570e33f1e166a3d64b60e13aab5df0d56 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 14:46:01 +0800 Subject: [PATCH 23/27] update extra arg cache key test --- .../test_snapshots/fixtures/cache-keys/snapshots.toml | 2 +- ...tic task cache key with extra args@cache-keys.snap | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml index 1c0a0753..4d0c1201 100644 --- a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml +++ b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml @@ -17,4 +17,4 @@ args = ["lint"] [[plan]] name = "direct synthetic task cache key with extra args" -args = ["lint"] +args = ["lint", "--fix"] diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap index ae527c5b..3a0bb210 100644 --- a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap @@ -15,7 +15,9 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys "program_name": "oxlint" } }, - "args": [], + "args": [ + "--fix" + ], "env_fingerprints": { "fingerprinted_envs": {}, "pass_through_env_config": [ @@ -28,7 +30,8 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys "kind": { "DirectSyntatic": { "direct_execution_cache_key": [ - "lint" + "lint", + "--fix" ] } }, @@ -37,7 +40,9 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys }, "spawn_command": { "program_path": "/test_bins/node_modules/.bin/oxlint", - "args": [], + "args": [ + "--fix" + ], "all_envs": { "FORCE_COLOR": "3", "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" From 7a60f5356c0e1c22ea65e3d9a21c447a6aac02d4 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 15:07:08 +0800 Subject: [PATCH 24/27] add extra_args to cache key --- .../fixtures/cache-keys/package.json | 4 +- .../fixtures/cache-keys/snapshots.toml | 8 ++ ...o and lint with extra args@cache-keys.snap | 108 ++++++++++++++++++ ...t and echo with extra args@cache-keys.snap | 102 +++++++++++++++++ ... cache key with extra args@cache-keys.snap | 5 +- ...uery - user task cache key@cache-keys.snap | 3 +- ...test_snapshots__task graph@cache-keys.snap | 56 +++++++++ crates/vite_task_plan/src/cache_metadata.rs | 3 + crates/vite_task_plan/src/plan.rs | 2 + 9 files changed, 288 insertions(+), 3 deletions(-) create mode 100644 crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - echo and lint with extra args@cache-keys.snap create mode 100644 crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - lint and echo with extra args@cache-keys.snap diff --git a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json index 3f45091c..07d41ec2 100644 --- a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json +++ b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/package.json @@ -1,5 +1,7 @@ { "scripts": { - "lint": "vite lint" + "lint": "vite lint", + "lint-and-echo": "vite lint && echo", + "echo-and-lint": "echo Linting && vite lint" } } diff --git a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml index 4d0c1201..1a31c3a7 100644 --- a/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml +++ b/crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys/snapshots.toml @@ -18,3 +18,11 @@ args = ["lint"] [[plan]] name = "direct synthetic task cache key with extra args" args = ["lint", "--fix"] + +[[plan]] +name = "lint and echo with extra args" +args = ["run", "lint-and-echo", "Linting complete"] + +[[plan]] +name = "echo and lint with extra args" +args = ["run", "echo-and-lint", "--fix"] diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - echo and lint with extra args@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - echo and lint with extra args@cache-keys.snap new file mode 100644 index 00000000..7063139d --- /dev/null +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - echo and lint with extra args@cache-keys.snap @@ -0,0 +1,108 @@ +--- +source: crates/vite_task_bin/tests/test_snapshots/main.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys +--- +{ + "root_node": { + "Expanded": [ + { + "key": [ + "/", + "echo-and-lint" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "echo-and-lint", + "package_path": "/" + }, + "items": [ + { + "command_span": { + "start": 0, + "end": 12 + }, + "extra_args": [], + "plan_cwd": "/", + "kind": { + "Leaf": { + "InProcess": { + "kind": { + "Echo": { + "strings": [ + "Linting" + ], + "trailing_newline": true + } + } + } + } + } + }, + { + "command_span": { + "start": 16, + "end": 25 + }, + "extra_args": [ + "--fix" + ], + "plan_cwd": "/", + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [ + "--fix" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "UserTask": { + "task_name": "echo-and-lint", + "and_item_index": 1, + "extra_args": [ + "--fix" + ] + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [ + "--fix" + ], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } +} diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - lint and echo with extra args@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - lint and echo with extra args@cache-keys.snap new file mode 100644 index 00000000..903d9c56 --- /dev/null +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - lint and echo with extra args@cache-keys.snap @@ -0,0 +1,102 @@ +--- +source: crates/vite_task_bin/tests/test_snapshots/main.rs +expression: "&plan_json" +input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys +--- +{ + "root_node": { + "Expanded": [ + { + "key": [ + "/", + "lint-and-echo" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "lint-and-echo", + "package_path": "/" + }, + "items": [ + { + "command_span": { + "start": 0, + "end": 9 + }, + "extra_args": [], + "plan_cwd": "/", + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "oxlint" + } + }, + "args": [], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "kind": { + "UserTask": { + "task_name": "lint-and-echo", + "and_item_index": 0, + "extra_args": [] + } + }, + "origin_path": "" + } + }, + "spawn_command": { + "program_path": "/test_bins/node_modules/.bin/oxlint", + "args": [], + "all_envs": { + "FORCE_COLOR": "3", + "PATH": "/node_modules/.bin:/test_bins/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + }, + { + "command_span": { + "start": 13, + "end": 17 + }, + "extra_args": [ + "Linting complete" + ], + "plan_cwd": "/", + "kind": { + "Leaf": { + "InProcess": { + "kind": { + "Echo": { + "strings": [ + "Linting complete" + ], + "trailing_newline": true + } + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } +} diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap index 3487f29b..7cc5012b 100644 --- a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key with extra args@cache-keys.snap @@ -53,7 +53,10 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys "kind": { "UserTask": { "task_name": "lint", - "and_item_index": 0 + "and_item_index": 0, + "extra_args": [ + "--fix" + ] } }, "origin_path": "" diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap index 325f7541..b00976f1 100644 --- a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - user task cache key@cache-keys.snap @@ -49,7 +49,8 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys "kind": { "UserTask": { "task_name": "lint", - "and_item_index": 0 + "and_item_index": 0, + "extra_args": [] } }, "origin_path": "" diff --git a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap index 5eace13d..91494e3a 100644 --- a/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap +++ b/crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__task graph@cache-keys.snap @@ -4,6 +4,34 @@ expression: task_graph_json input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys --- [ + { + "key": [ + "/", + "echo-and-lint" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "echo-and-lint", + "package_path": "/" + }, + "resolved_config": { + "command": "echo Linting && vite lint", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] + }, { "key": [ "/", @@ -31,5 +59,33 @@ input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-keys } }, "neighbors": [] + }, + { + "key": [ + "/", + "lint-and-echo" + ], + "node": { + "task_display": { + "package_name": "", + "task_name": "lint-and-echo", + "package_path": "/" + }, + "resolved_config": { + "command": "vite lint && echo", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + } + }, + "neighbors": [] } ] diff --git a/crates/vite_task_plan/src/cache_metadata.rs b/crates/vite_task_plan/src/cache_metadata.rs index a4739914..c95b8da4 100644 --- a/crates/vite_task_plan/src/cache_metadata.rs +++ b/crates/vite_task_plan/src/cache_metadata.rs @@ -25,6 +25,9 @@ pub(crate) enum ExecutionCacheKeyKind { /// The index of the execution item in the task's command split by `&&`. /// This is to distinguish multiple execution items from the same task. and_item_index: usize, + /// Extra args provided when invoking the user-defined task (`vite [task_name] [extra_args...]`). + /// These args are appended to the last and_item. Non-last and_items don't get extra args. + extra_args: Arc<[Str]>, }, } diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index e10c66c9..6647720d 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -134,6 +134,7 @@ async fn plan_task_as_execution_node( kind: ExecutionCacheKeyKind::UserTask { task_name: task_node.task_display.task_name.clone(), and_item_index: index, + extra_args: Arc::clone(&extra_args), }, origin_path: strip_prefix_for_cache(package_path, context.workspace_path()) .map_err(|kind| { @@ -235,6 +236,7 @@ async fn plan_task_as_execution_node( kind: ExecutionCacheKeyKind::UserTask { task_name: task_node.task_display.task_name.clone(), and_item_index: 0, + extra_args: Arc::clone(context.extra_args()), }, origin_path: strip_prefix_for_cache(package_path, context.workspace_path()) .map_err(|kind| { From 7d3fea38f1f7db4f9a9129fe9728104f02c87189 Mon Sep 17 00:00:00 2001 From: branchseer Date: Sun, 4 Jan 2026 18:11:05 +0800 Subject: [PATCH 25/27] update e2e tests --- crates/vite_task_bin/test_bins/package.json | 7 +- .../vite_task_bin/test_bins/src/json-edit.ts | 21 +++ .../{readfile.mjs => src/print-file.ts} | 2 +- .../fixtures/cache-keys/package.json | 1 + .../fixtures/cache-keys/snapshots.toml | 20 ++- .../tests/test_snapshots/main.rs | 129 ++++++++++++------ .../tests/test_snapshots/redact.rs | 37 +++-- ...est_snapshots__direct lint@cache-keys.snap | 100 ++++++++++++++ ...t synthetic task with cwd@cache-keys.snap} | 0 ...etic task with extra args@cache-keys.snap} | 0 ...y - direct synthetic task@cache-keys.snap} | 0 ...ormal task with extra args@cache-keys.snap | 86 ++++++++++++ ...nthetic task in user task@cache-keys.snap} | 0 ...h extra args in user task@cache-keys.snap} | 0 ...test_snapshots__task graph@cache-keys.snap | 28 ++++ package.json | 1 + pnpm-lock.yaml | 20 ++- pnpm-workspace.yaml | 1 + 18 files changed, 393 insertions(+), 60 deletions(-) create mode 100755 crates/vite_task_bin/test_bins/src/json-edit.ts rename crates/vite_task_bin/test_bins/{readfile.mjs => src/print-file.ts} (66%) create mode 100644 crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__direct lint@cache-keys.snap rename crates/vite_task_bin/tests/test_snapshots/snapshots/{test_snapshots__query - direct synthetic task cache key with cwd@cache-keys.snap => test_snapshots__query - direct synthetic task with cwd@cache-keys.snap} (100%) rename crates/vite_task_bin/tests/test_snapshots/snapshots/{test_snapshots__query - direct synthetic task cache key with extra args@cache-keys.snap => test_snapshots__query - direct synthetic task with extra args@cache-keys.snap} (100%) rename crates/vite_task_bin/tests/test_snapshots/snapshots/{test_snapshots__query - direct synthetic task cache key@cache-keys.snap => test_snapshots__query - direct synthetic task@cache-keys.snap} (100%) create mode 100644 crates/vite_task_bin/tests/test_snapshots/snapshots/test_snapshots__query - normal task with extra args@cache-keys.snap rename crates/vite_task_bin/tests/test_snapshots/snapshots/{test_snapshots__query - user task cache key@cache-keys.snap => test_snapshots__query - synthetic task in user task@cache-keys.snap} (100%) rename crates/vite_task_bin/tests/test_snapshots/snapshots/{test_snapshots__query - user task cache key with extra args@cache-keys.snap => test_snapshots__query - synthetic task with extra args in user task@cache-keys.snap} (100%) diff --git a/crates/vite_task_bin/test_bins/package.json b/crates/vite_task_bin/test_bins/package.json index aad83f03..123930c4 100644 --- a/crates/vite_task_bin/test_bins/package.json +++ b/crates/vite_task_bin/test_bins/package.json @@ -1,11 +1,12 @@ { - "name": "vite-task-tests-bins", + "name": "vite-task-test-bins", "private": true, "bin": { - "readfile": "./readfile.mjs" + "print-file": "./src/print-file.ts", + "json-edit": "./src/json-edit.ts" }, "dependencies": { "oxlint": "catalog:", - "vite-task-tests-bins": "link:" + "vite-task-test-bins": "link:" } } diff --git a/crates/vite_task_bin/test_bins/src/json-edit.ts b/crates/vite_task_bin/test_bins/src/json-edit.ts new file mode 100755 index 00000000..2eb1d1ce --- /dev/null +++ b/crates/vite_task_bin/test_bins/src/json-edit.ts @@ -0,0 +1,21 @@ +import { readFileSync, writeFileSync } from 'node:fs'; +import { parseArgs } from 'node:util'; + +const { positionals } = parseArgs({ + allowPositionals: true, +}); + +const filename = positionals[0]; +const script = positionals[1]; + +if (!filename || !script) { + console.error('Usage: json-edit