From 12cea1c6db213f0e34fe54bd3732229fc47a9203 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:05:21 +0000 Subject: [PATCH 1/8] feat: add --cache/--no-cache CLI flags and move cache resolution to plan stage Move global cache config resolution from task graph load time to plan time, enabling CLI overrides and proper nested vp run support. Key changes: - Add TaskSource enum to distinguish TaskConfig vs PackageJsonScript - Store ResolvedGlobalCacheConfig on IndexedTaskGraph without applying the global kill switch at graph load time - Add CacheOverride enum (None/ForceEnabled/ForceDisabled) to PlanOptions - Add --cache and --no-cache flags to RunFlags with conflicts_with - Compute final ResolvedGlobalCacheConfig in PlanContext by combining graph config with CLI override - Apply effective_cache_config per task at plan time using TaskSource - Nested vp run --cache/--no-cache overrides parent's resolved config https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- crates/vite_task/src/cli/mod.rs | 34 +++++++-- crates/vite_task_graph/src/config/mod.rs | 19 ++--- crates/vite_task_graph/src/config/user.rs | 1 + crates/vite_task_graph/src/lib.rs | 44 ++++++++---- crates/vite_task_plan/src/context.rs | 16 ++++- crates/vite_task_plan/src/lib.rs | 23 ++++++- crates/vite_task_plan/src/plan.rs | 66 +++++++++++++++--- crates/vite_task_plan/src/plan_request.rs | 13 ++++ .../additional-envs/snapshots/task graph.snap | 6 +- .../cache-keys/snapshots/task graph.snap | 12 ++-- .../snapshots/task graph.snap | 24 +++++-- .../snapshots/task graph.snap | 6 +- .../snapshots/task graph.snap | 18 +++-- .../cache-sharing/snapshots/task graph.snap | 9 ++- .../snapshots/task graph.snap | 3 +- .../snapshots/task graph.snap | 36 ++++++++-- .../snapshots/task graph.snap | 9 ++- .../cd-in-scripts/snapshots/task graph.snap | 9 ++- .../snapshots/task graph.snap | 69 ++++++++++++------- .../conflict-test/snapshots/task graph.snap | 9 ++- .../snapshots/task graph.snap | 6 +- .../snapshots/task graph.snap | 6 +- .../snapshots/task graph.snap | 24 +++++-- .../snapshots/task graph.snap | 27 +++++--- .../snapshots/task graph.snap | 33 ++++++--- .../snapshots/task graph.snap | 39 +++++++---- .../snapshots/task graph.snap | 3 +- .../nested-tasks/snapshots/task graph.snap | 6 +- .../snapshots/task graph.snap | 3 +- .../snapshots/task graph.snap | 24 ++++--- .../shell-fallback/snapshots/task graph.snap | 3 +- .../snapshots/task graph.snap | 39 ++++++++--- .../snapshots/task graph.snap | 6 +- .../snapshots/task graph.snap | 36 ++++++++-- .../vpr-shorthand/snapshots/task graph.snap | 6 +- .../snapshots/task graph.snap | 6 +- 36 files changed, 516 insertions(+), 177 deletions(-) diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index 15adc85f..07ca39c2 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -4,7 +4,7 @@ use clap::Parser; use vite_path::AbsolutePath; use vite_str::Str; use vite_task_graph::{TaskSpecifier, query::TaskQuery}; -use vite_task_plan::plan_request::{PlanOptions, QueryPlanRequest}; +use vite_task_plan::plan_request::{CacheOverride, PlanOptions, QueryPlanRequest}; use vite_workspace::package_filter::{PackageQueryArgs, PackageQueryError}; #[derive(Debug, Clone, clap::Subcommand)] @@ -15,6 +15,7 @@ pub enum CacheSubcommand { /// Flags that control how a `run` command selects tasks. #[derive(Debug, Clone, PartialEq, Eq, clap::Args)] +#[expect(clippy::struct_excessive_bools, reason = "CLI flags are naturally boolean")] pub struct RunFlags { #[clap(flatten)] pub package_query: PackageQueryArgs, @@ -26,6 +27,27 @@ pub struct RunFlags { /// Show full detailed summary after execution. #[clap(default_value = "false", short = 'v', long)] pub verbose: bool, + + /// Force caching on for all tasks and scripts. + #[clap(long, conflicts_with = "no_cache")] + pub cache: bool, + + /// Force caching off for all tasks and scripts. + #[clap(long, conflicts_with = "cache")] + pub no_cache: bool, +} + +impl RunFlags { + #[must_use] + pub const fn cache_override(&self) -> CacheOverride { + if self.cache { + CacheOverride::ForceEnabled + } else if self.no_cache { + CacheOverride::ForceDisabled + } else { + CacheOverride::None + } + } } // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -155,11 +177,12 @@ impl ResolvedRunCommand { let raw_specifier = self.task_specifier.ok_or(CLITaskQueryError::MissingTaskSpecifier)?; let task_specifier = TaskSpecifier::parse_raw(&raw_specifier); + let cache_override = self.flags.cache_override(); + let include_explicit_deps = !self.flags.ignore_depends_on; + let (package_query, is_cwd_only) = self.flags.package_query.into_package_query(task_specifier.package_name, cwd)?; - let include_explicit_deps = !self.flags.ignore_depends_on; - Ok(( QueryPlanRequest { query: TaskQuery { @@ -167,7 +190,10 @@ impl ResolvedRunCommand { task_name: task_specifier.task_name, include_explicit_deps, }, - plan_options: PlanOptions { extra_args: self.additional_args.into() }, + plan_options: PlanOptions { + extra_args: self.additional_args.into(), + cache_override, + }, }, is_cwd_only, )) diff --git a/crates/vite_task_graph/src/config/mod.rs b/crates/vite_task_graph/src/config/mod.rs index 6512c3f2..34ba3d8c 100644 --- a/crates/vite_task_graph/src/config/mod.rs +++ b/crates/vite_task_graph/src/config/mod.rs @@ -100,29 +100,18 @@ pub enum ResolveTaskConfigError { } impl ResolvedTaskConfig { - /// Resolve from package.json script only (no vite-task.json config for this task) + /// Resolve from package.json script only (no config entry for this task). /// - /// The `cache_scripts` parameter determines whether caching is enabled for the script. - /// When `true`, caching is enabled with default settings. - /// When `false`, caching is disabled. + /// Always resolves with caching enabled (default settings). + /// The global cache config is applied at plan time, not here. #[must_use] pub fn resolve_package_json_script( package_dir: &Arc, package_json_script: &str, - cache_scripts: bool, ) -> Self { - let cache_config = if cache_scripts { - UserCacheConfig::Enabled { - cache: None, - enabled_cache_config: EnabledCacheConfig { envs: None, pass_through_envs: None }, - } - } else { - UserCacheConfig::Disabled { cache: MustBe!(false) } - }; - let options = UserTaskOptions { cache_config, ..Default::default() }; Self { command: package_json_script.into(), - resolved_options: ResolvedTaskOptions::resolve(options, package_dir), + resolved_options: ResolvedTaskOptions::resolve(UserTaskOptions::default(), package_dir), } } diff --git a/crates/vite_task_graph/src/config/user.rs b/crates/vite_task_graph/src/config/user.rs index 60feb652..8a54ad58 100644 --- a/crates/vite_task_graph/src/config/user.rs +++ b/crates/vite_task_graph/src/config/user.rs @@ -150,6 +150,7 @@ pub enum UserGlobalCacheConfig { } /// Resolved global cache configuration with concrete boolean values. +#[derive(Debug, Clone, Copy)] pub struct ResolvedGlobalCacheConfig { pub scripts: bool, pub tasks: bool, diff --git a/crates/vite_task_graph/src/lib.rs b/crates/vite_task_graph/src/lib.rs index d09e7fe5..d0f91a81 100644 --- a/crates/vite_task_graph/src/lib.rs +++ b/crates/vite_task_graph/src/lib.rs @@ -6,7 +6,7 @@ mod specifier; use std::{convert::Infallible, sync::Arc}; -use config::{ResolvedTaskConfig, UserRunConfig}; +use config::{ResolvedGlobalCacheConfig, ResolvedTaskConfig, UserRunConfig}; use petgraph::graph::{DefaultIx, DiGraph, EdgeIndex, IndexType, NodeIndex}; use rustc_hash::{FxBuildHasher, FxHashMap}; use serde::Serialize; @@ -47,6 +47,15 @@ pub(crate) struct TaskId { pub task_name: Str, } +/// Whether a task originates from the `tasks` map or from a package.json script. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +pub enum TaskSource { + /// Defined in the `tasks` map in the workspace config. + TaskConfig, + /// Pure package.json script (not in the tasks map). + PackageJsonScript, +} + /// A node in the task graph, representing a task with its resolved configuration. #[derive(Debug, Serialize)] pub struct TaskNode { @@ -60,6 +69,9 @@ pub struct TaskNode { /// /// However, it does not contain external factors like additional args from cli and env vars. pub resolved_config: ResolvedTaskConfig, + + /// Whether this task comes from the tasks map or a package.json script. + pub source: TaskSource, } impl vite_graph_ser::GetKey for TaskNode { @@ -166,6 +178,9 @@ pub struct IndexedTaskGraph { /// task indices by task id for quick lookup pub(crate) node_indices_by_task_id: FxHashMap, + + /// Global cache configuration resolved from the workspace root config. + resolved_global_cache: ResolvedGlobalCacheConfig, } pub type TaskGraph = DiGraph; @@ -234,11 +249,9 @@ impl IndexedTaskGraph { package_configs.push((package_index, package_dir, user_config)); } - let resolved_cache = config::ResolvedGlobalCacheConfig::resolve_from(root_cache.as_ref()); - let cache_scripts = resolved_cache.scripts; - let cache_tasks = resolved_cache.tasks; + let resolved_global_cache = ResolvedGlobalCacheConfig::resolve_from(root_cache.as_ref()); - // Second pass: create task nodes using resolved cache config + // Second pass: create task nodes (cache is NOT applied here; it's applied at plan time) for (package_index, package_dir, user_config) in package_configs { let package = &package_graph[package_index]; @@ -250,19 +263,15 @@ impl IndexedTaskGraph { .map(|(name, value)| (name.as_str(), value.as_str())) .collect(); - for (task_name, mut task_user_config) in user_config.tasks.unwrap_or_default() { - // Apply cache.tasks kill switch: when false, override all tasks to disable caching - if !cache_tasks { - task_user_config.options.cache_config = config::UserCacheConfig::disabled(); - } - // For each task defined in vite.config.*, look up the corresponding package.json script (if any) + for (task_name, task_user_config) in user_config.tasks.unwrap_or_default() { + // For each task defined in the config, look up the corresponding package.json script (if any) let package_json_script = package_json_scripts.remove(task_name.as_str()); let task_id = TaskId { task_name: task_name.clone(), package_index }; let dependency_specifiers = task_user_config.options.depends_on.clone(); - // Resolve the task configuration combining vite.config.* and package.json script + // Resolve the task configuration combining config and package.json script let resolved_config = ResolvedTaskConfig::resolve( task_user_config, &package_dir, @@ -284,6 +293,7 @@ impl IndexedTaskGraph { package_path: Arc::clone(&package_dir), }, resolved_config, + source: TaskSource::TaskConfig, }; let node_index = task_graph.add_node(task_node); @@ -291,13 +301,12 @@ impl IndexedTaskGraph { 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 + // For remaining package.json scripts not in the tasks map, create tasks with default config for (script_name, package_json_script) in package_json_scripts { let task_id = TaskId { task_name: Str::from(script_name), package_index }; let resolved_config = ResolvedTaskConfig::resolve_package_json_script( &package_dir, package_json_script, - cache_scripts, ); let node_index = task_graph.add_node(TaskNode { task_display: TaskDisplay { @@ -306,6 +315,7 @@ impl IndexedTaskGraph { package_path: Arc::clone(&package_dir), }, resolved_config, + source: TaskSource::PackageJsonScript, }); node_indices_by_task_id.insert(task_id, node_index); } @@ -316,6 +326,7 @@ impl IndexedTaskGraph { task_graph, indexed_package_graph: IndexedPackageGraph::index(package_graph), node_indices_by_task_id, + resolved_global_cache, }; // Add explicit dependencies @@ -420,4 +431,9 @@ impl IndexedTaskGraph { let index = self.indexed_package_graph.get_package_index_from_cwd(cwd)?; Some(self.get_package_path(index)) } + + #[must_use] + pub const fn global_cache_config(&self) -> &ResolvedGlobalCacheConfig { + &self.resolved_global_cache + } } diff --git a/crates/vite_task_plan/src/context.rs b/crates/vite_task_plan/src/context.rs index 0f67a05f..3f2ec1fe 100644 --- a/crates/vite_task_plan/src/context.rs +++ b/crates/vite_task_plan/src/context.rs @@ -3,7 +3,7 @@ use std::{env::JoinPathsError, ffi::OsStr, ops::Range, sync::Arc}; use rustc_hash::FxHashMap; use vite_path::AbsolutePath; use vite_str::Str; -use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex}; +use vite_task_graph::{IndexedTaskGraph, TaskNodeIndex, config::ResolvedGlobalCacheConfig}; use crate::{PlanRequestParser, path_env::prepend_path_env}; @@ -39,6 +39,9 @@ pub struct PlanContext<'a> { extra_args: Arc<[Str]>, indexed_task_graph: &'a IndexedTaskGraph, + + /// Final resolved global cache config, combining the graph's config with any CLI override. + resolved_global_cache: ResolvedGlobalCacheConfig, } impl<'a> PlanContext<'a> { @@ -48,6 +51,7 @@ impl<'a> PlanContext<'a> { envs: FxHashMap, Arc>, callbacks: &'a mut (dyn PlanRequestParser + 'a), indexed_task_graph: &'a IndexedTaskGraph, + resolved_global_cache: ResolvedGlobalCacheConfig, ) -> Self { Self { workspace_path, @@ -57,6 +61,7 @@ impl<'a> PlanContext<'a> { task_call_stack: Vec::new(), indexed_task_graph, extra_args: Arc::default(), + resolved_global_cache, } } @@ -115,6 +120,14 @@ impl<'a> PlanContext<'a> { self.extra_args = extra_args; } + pub const fn resolved_global_cache(&self) -> &ResolvedGlobalCacheConfig { + &self.resolved_global_cache + } + + pub const fn set_resolved_global_cache(&mut self, config: ResolvedGlobalCacheConfig) { + self.resolved_global_cache = config; + } + pub fn duplicate(&mut self) -> PlanContext<'_> { PlanContext { workspace_path: self.workspace_path, @@ -124,6 +137,7 @@ impl<'a> PlanContext<'a> { task_call_stack: self.task_call_stack.clone(), indexed_task_graph: self.indexed_task_graph, extra_args: Arc::clone(&self.extra_args), + resolved_global_cache: self.resolved_global_cache, } } } diff --git a/crates/vite_task_plan/src/lib.rs b/crates/vite_task_plan/src/lib.rs index c321c893..61178566 100644 --- a/crates/vite_task_plan/src/lib.rs +++ b/crates/vite_task_plan/src/lib.rs @@ -16,7 +16,7 @@ pub use execution_graph::ExecutionGraph; pub use in_process::InProcessExecution; pub use path_env::{get_path_env, prepend_path_env}; use plan::{ParentCacheConfig, plan_query_request, plan_synthetic_request}; -use plan_request::{PlanRequest, QueryPlanRequest, SyntheticPlanRequest}; +use plan_request::{CacheOverride, PlanRequest, QueryPlanRequest, SyntheticPlanRequest}; use rustc_hash::FxHashMap; use serde::{Serialize, ser::SerializeMap as _}; use vite_path::AbsolutePath; @@ -200,16 +200,37 @@ pub async fn plan_query( ) -> Result { let indexed_task_graph = task_graph_loader.load_task_graph().await?; + let resolved_global_cache = resolve_cache_with_override( + *indexed_task_graph.global_cache_config(), + query_plan_request.plan_options.cache_override, + ); + let context = PlanContext::new( workspace_path, Arc::clone(cwd), envs.clone(), plan_request_parser, indexed_task_graph, + resolved_global_cache, ); plan_query_request(query_plan_request, context).await } +const fn resolve_cache_with_override( + graph_cache: vite_task_graph::config::ResolvedGlobalCacheConfig, + cache_override: CacheOverride, +) -> vite_task_graph::config::ResolvedGlobalCacheConfig { + match cache_override { + CacheOverride::ForceEnabled => { + vite_task_graph::config::ResolvedGlobalCacheConfig { scripts: true, tasks: true } + } + CacheOverride::ForceDisabled => { + vite_task_graph::config::ResolvedGlobalCacheConfig { scripts: false, tasks: false } + } + CacheOverride::None => graph_cache, + } +} + /// Plan a synthetic task execution, returning the resolved [`SpawnExecution`] directly. /// /// Unlike [`plan_query`] which returns a full execution graph, synthetic executions diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 0d95dad3..5cfdbfca 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -17,9 +17,9 @@ use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf, relative::Invali use vite_shell::try_parse_as_and_list; use vite_str::Str; use vite_task_graph::{ - TaskNodeIndex, + TaskNodeIndex, TaskSource, config::{ - CacheConfig, ResolvedTaskOptions, + CacheConfig, ResolvedGlobalCacheConfig, ResolvedTaskOptions, user::{UserCacheConfig, UserTaskOptions}, }, }; @@ -33,7 +33,10 @@ use crate::{ execution_graph::{ExecutionGraph, ExecutionNodeIndex, InnerExecutionGraph}, in_process::InProcessExecution, path_env::get_path_env, - plan_request::{PlanRequest, QueryPlanRequest, ScriptCommand, SyntheticPlanRequest}, + plan_request::{ + CacheOverride, PlanRequest, QueryPlanRequest, ScriptCommand, SyntheticPlanRequest, + }, + resolve_cache_with_override, }; /// Locate the executable path for a given program name in the provided envs and cwd. @@ -56,6 +59,23 @@ fn which( .into()) } +/// Compute the effective cache config for a task, applying the global cache config. +/// +/// The task graph stores per-task cache config without applying the global kill switch. +/// This function applies the global config at plan time, checking `cache.scripts` for +/// package.json scripts and `cache.tasks` for task-map entries. +fn effective_cache_config( + task_cache_config: Option<&CacheConfig>, + source: TaskSource, + resolved_global_cache: ResolvedGlobalCacheConfig, +) -> Option { + let enabled = match source { + TaskSource::PackageJsonScript => resolved_global_cache.scripts, + TaskSource::TaskConfig => resolved_global_cache.tasks, + }; + if enabled { task_cache_config.cloned() } else { None } +} + #[expect(clippy::too_many_lines, reason = "sequential planning steps are clearer in one function")] #[expect(clippy::future_not_send, reason = "PlanContext contains !Send dyn PlanRequestParser")] async fn plan_task_as_execution_node( @@ -202,10 +222,12 @@ async fn plan_task_as_execution_node( } // Synthetic task (from CommandHandler) Some(PlanRequest::Synthetic(synthetic_plan_request)) => { - let parent_cache_config = task_node - .resolved_config - .resolved_options - .cache_config + let task_effective_cache = effective_cache_config( + task_node.resolved_config.resolved_options.cache_config.as_ref(), + task_node.source, + *context.resolved_global_cache(), + ); + let parent_cache_config = task_effective_cache .as_ref() .map_or(ParentCacheConfig::Disabled, |config| { ParentCacheConfig::Inherited(config.clone()) @@ -227,11 +249,19 @@ async fn plan_task_as_execution_node( &script_command.envs, &script_command.cwd, )?; + let resolved_options = ResolvedTaskOptions { + cwd: Arc::clone(&task_node.resolved_config.resolved_options.cwd), + cache_config: effective_cache_config( + task_node.resolved_config.resolved_options.cache_config.as_ref(), + task_node.source, + *context.resolved_global_cache(), + ), + }; let spawn_execution = plan_spawn_execution( context.workspace_path(), Some(task_execution_cache_key), &and_item.envs, - &task_node.resolved_config.resolved_options, + &resolved_options, &script_command.envs, program_path, script_command.args, @@ -275,6 +305,14 @@ async fn plan_task_as_execution_node( script.push_str(shell_escape::escape(arg.as_str().into()).as_ref()); } + let resolved_options = ResolvedTaskOptions { + cwd: Arc::clone(&task_node.resolved_config.resolved_options.cwd), + cache_config: effective_cache_config( + task_node.resolved_config.resolved_options.cache_config.as_ref(), + task_node.source, + *context.resolved_global_cache(), + ), + }; let spawn_execution = plan_spawn_execution( context.workspace_path(), Some(ExecutionCacheKey::UserTask { @@ -288,7 +326,7 @@ async fn plan_task_as_execution_node( })?, }), &BTreeMap::new(), - &task_node.resolved_config.resolved_options, + &resolved_options, context.envs(), Arc::clone(&*SHELL_PROGRAM_PATH), SHELL_ARGS.iter().map(|s| Str::from(*s)).chain(std::iter::once(script)).collect(), @@ -519,6 +557,16 @@ pub async fn plan_query_request( query_plan_request: QueryPlanRequest, mut context: PlanContext<'_>, ) -> Result { + // Apply cache override from this request (nested `vp run --no-cache` etc.) + // If the nested command has no override, inherit the parent's resolved config. + let cache_override = query_plan_request.plan_options.cache_override; + if cache_override != CacheOverride::None { + let final_cache = resolve_cache_with_override( + *context.indexed_task_graph().global_cache_config(), + cache_override, + ); + context.set_resolved_global_cache(final_cache); + } context.set_extra_args(Arc::clone(&query_plan_request.plan_options.extra_args)); // Query matching tasks from the task graph. // An empty graph means no tasks matched; the caller (session) handles diff --git a/crates/vite_task_plan/src/plan_request.rs b/crates/vite_task_plan/src/plan_request.rs index cd85f651..a0ca12b2 100644 --- a/crates/vite_task_plan/src/plan_request.rs +++ b/crates/vite_task_plan/src/plan_request.rs @@ -31,9 +31,22 @@ impl ScriptCommand { } } +/// CLI-level cache override from `--cache` / `--no-cache` flags. +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub enum CacheOverride { + /// No override — use the resolved config from the task graph. + #[default] + None, + /// Force all caching on (`--cache` flag). + ForceEnabled, + /// Force all caching off (`--no-cache` flag). + ForceDisabled, +} + #[derive(Debug)] pub struct PlanOptions { pub extra_args: Arc<[Str]>, + pub cache_override: CacheOverride, } #[derive(Debug)] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots/task graph.snap index 65a1b8fd..19119cb4 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/additional-envs } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots/task graph.snap index 563cf097..1159aa12 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -112,7 +115,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-keys } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap index b20ad283..e7289b35 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap @@ -19,9 +19,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-de "command": "echo building", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -40,9 +48,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-de "command": "echo testing", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-enabled/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-enabled/snapshots/task graph.snap index 457d4193..fcaa05d4 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-enabled/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-enabled/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-en } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-en } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap index fcf03317..9a8e7b21 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-ta } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-ta } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -75,9 +77,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-ta "command": "echo testing", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing/snapshots/task graph.snap index 73487482..75c12f88 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-sharing } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-subcommand/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-subcommand/snapshots/task graph.snap index 34095de6..bc3ce966 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-subcommand/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-subcommand/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-subcommand } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap index 781d1cbf..d3803329 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap @@ -19,9 +19,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disa "command": "echo building", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -40,9 +48,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disa "command": "echo deploying", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -61,9 +77,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disa "command": "echo testing", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap index a62b5101..a16d7ff3 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap @@ -21,7 +21,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-fo "cwd": "/", "cache_config": null } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -49,7 +50,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-fo } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -77,7 +79,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-fo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts/snapshots/task graph.snap index 2d914518..09efb044 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cd-in-scripts } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-task-graph/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-task-graph/snapshots/task graph.snap index 47530078..a4a0ceda 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-task-graph/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-task-graph/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -112,7 +115,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -140,7 +144,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -168,7 +173,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -196,7 +202,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -224,7 +231,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -252,7 +260,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -280,7 +289,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -308,7 +318,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -336,7 +347,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -364,7 +376,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -392,7 +405,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -420,7 +434,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -448,7 +463,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -476,7 +492,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -504,7 +521,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -532,7 +550,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -560,7 +579,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -588,7 +608,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -616,7 +637,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -644,7 +666,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/comprehensive-ta } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test/snapshots/task graph.snap index 9dfc5dae..441061e3 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/conflict-test } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cycle-dependency/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cycle-dependency/snapshots/task graph.snap index 41ec81de..8e578194 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cycle-dependency/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cycle-dependency/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cycle-dependency } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -61,7 +62,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cycle-dependency } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/dependency-both-topo-and-explicit/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/dependency-both-topo-and-explicit/snapshots/task graph.snap index 79d4c1e1..659a3440 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/dependency-both-topo-and-explicit/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/dependency-both-topo-and-explicit/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/dependency-both- } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -61,7 +62,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/dependency-both- } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/duplicate-package-names/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/duplicate-package-names/snapshots/task graph.snap index 4a80eea2..3df2b750 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/duplicate-package-names/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/duplicate-package-names/snapshots/task graph.snap @@ -19,9 +19,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/duplicate-packag "command": "echo build-a", "resolved_options": { "cwd": "/packages/pkg-a", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -40,9 +48,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/duplicate-packag "command": "echo build-b", "resolved_options": { "cwd": "/packages/pkg-b", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-test/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-test/snapshots/task graph.snap index 1b3f0a3d..f33ccfee 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-test/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-test/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -58,7 +59,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te "cwd": "/packages/another-empty", "cache_config": null } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -95,7 +97,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -123,7 +126,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -151,7 +155,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -184,7 +189,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -212,7 +218,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -240,7 +247,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -268,7 +276,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/empty-package-te } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-workspace/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-workspace/snapshots/task graph.snap index f6ab0d3f..316a0ad9 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-workspace/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-workspace/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -49,7 +50,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo "cwd": "/packages/app", "cache_config": null } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -90,7 +92,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -118,7 +121,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -146,7 +150,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -174,7 +179,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -202,7 +208,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -235,7 +242,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -263,7 +271,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -291,7 +300,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "TaskConfig" }, "neighbors": [ [ @@ -328,7 +338,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/explicit-deps-wo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace/snapshots/task graph.snap index 940f7cb9..16271d36 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -112,7 +115,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -140,7 +144,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -168,7 +173,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -196,7 +202,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -224,7 +231,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -252,7 +260,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -280,7 +289,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -308,7 +318,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -336,7 +347,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -364,7 +376,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/filter-workspace } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/fingerprint-ignore-test/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/fingerprint-ignore-test/snapshots/task graph.snap index c8846d14..0036eca1 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/fingerprint-ignore-test/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/fingerprint-ignore-test/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/fingerprint-igno } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap index ead28462..f70f89a4 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-tasks } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/pnpm-workspace-packages-optional/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/pnpm-workspace-packages-optional/snapshots/task graph.snap index 2a686412..728b66a7 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/pnpm-workspace-packages-optional/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/pnpm-workspace-packages-optional/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/pnpm-workspace-p } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topological-workspace/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topological-workspace/snapshots/task graph.snap index 078a225b..5a9fd1c4 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topological-workspace/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topological-workspace/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -84,7 +86,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -112,7 +115,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -140,7 +144,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -168,7 +173,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -196,7 +202,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -224,7 +231,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/recursive-topolo } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots/task graph.snap index bdf877e4..79b113c1 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/shell-fallback } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache-disabled/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache-disabled/snapshots/task graph.snap index ffe498b2..7be0e02e 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache-disabled/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache-disabled/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -47,9 +48,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- "command": "vp lint", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -70,7 +79,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- "cwd": "/", "cache_config": null } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -98,7 +108,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -127,7 +138,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -146,9 +158,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- "command": "vp run build", "resolved_options": { "cwd": "/", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -169,7 +189,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-cache- "cwd": "/", "cache_config": null } - } + }, + "source": "TaskConfig" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots/task graph.snap index c94cb31e..07ed52b1 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-subpackage/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-sub } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/synthetic-in-sub } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip-intermediate/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip-intermediate/snapshots/task graph.snap index 0bf76c85..30771c36 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip-intermediate/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip-intermediate/snapshots/task graph.snap @@ -19,9 +19,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip- "command": "echo 'Building @test/bottom'", "resolved_options": { "cwd": "/packages/bottom", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -40,9 +48,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip- "command": "echo 'Linting @test/middle'", "resolved_options": { "cwd": "/packages/middle", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -61,9 +77,17 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/transitive-skip- "command": "echo 'Building @test/top'", "resolved_options": { "cwd": "/packages/top", - "cache_config": null + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/vpr-shorthand/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/vpr-shorthand/snapshots/task graph.snap index 1dcf808c..5aeff92d 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/vpr-shorthand/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/vpr-shorthand/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/vpr-shorthand } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/vpr-shorthand } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-no-package-json/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-no-package-json/snapshots/task graph.snap index 051e2c04..520f4db9 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-no-package-json/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-no-package-json/snapshots/task graph.snap @@ -28,7 +28,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-n } } } - } + }, + "source": "TaskConfig" }, "neighbors": [] }, @@ -56,7 +57,8 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/workspace-root-n } } } - } + }, + "source": "PackageJsonScript" }, "neighbors": [] } From 3faa87249d78dcaf65fd6b33a2409379633a9c9b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:26:05 +0000 Subject: [PATCH 2/8] test: add plan tests for --cache/--no-cache override rules and nested scope Add two new plan snapshot test fixtures: - cache-cli-override: Tests CLI flag overriding rules - --cache enables task/script caching when globally disabled - --cache does not override per-task cache: false - --no-cache disables caching even with per-task cache: true - --cache and --no-cache conflict produces an error - nested-cache-override: Tests scope of nested vp run cache flags - nested --no-cache disables inner task caching - nested --cache enables inner task caching - nested run without flags inherits parent resolved cache - outer --no-cache does not propagate into nested --cache - outer --no-cache propagates to nested run without flags https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- .../fixtures/cache-cli-override/package.json | 7 + .../cache-cli-override/snapshots.toml | 41 +++++ ...ery - --cache and --no-cache conflict.snap | 16 ++ ...oes not override per-task cache false.snap | 58 +++++++ ...uery - --cache enables script caching.snap | 85 ++++++++++ ...aching even when cache.tasks is false.snap | 85 ++++++++++ ...h per-task cache true enables caching.snap | 85 ++++++++++ ...ry - --no-cache disables task caching.snap | 58 +++++++ ...o-cache overrides per-task cache true.snap | 58 +++++++ ... not cached when cache.tasks is false.snap | 57 +++++++ .../snapshots/task graph.snap | 145 ++++++++++++++++++ .../cache-cli-override/vite-task.json | 16 ++ .../nested-cache-override/package.json | 9 ++ .../nested-cache-override/snapshots.toml | 26 ++++ ...ed --cache enables inner task caching.snap | 116 ++++++++++++++ ...-no-cache disables inner task caching.snap | 89 +++++++++++ ...n without flags inherits parent cache.snap | 116 ++++++++++++++ ...oes not propagate into nested --cache.snap | 117 ++++++++++++++ ...ropagates to nested run without flags.snap | 90 +++++++++++ .../snapshots/task graph.snap | 123 +++++++++++++++ .../nested-cache-override/vite-task.json | 3 + 21 files changed, 1400 insertions(+) create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/package.json create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots.toml create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache does not override per-task cache false.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables script caching.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables task caching even when cache.tasks is false.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache on task with per-task cache true enables caching.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache disables task caching.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache overrides per-task cache true.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - baseline - tasks not cached when cache.tasks is false.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/task graph.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/vite-task.json create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/package.json create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --cache enables inner task caching.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --no-cache disables inner task caching.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache does not propagate into nested --cache.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache propagates to nested run without flags.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/task graph.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/package.json new file mode 100644 index 00000000..d8674607 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/package.json @@ -0,0 +1,7 @@ +{ + "name": "@test/cache-cli-override", + "scripts": { + "test": "print-file package.json", + "lint": "print-file vite-task.json" + } +} diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots.toml new file mode 100644 index 00000000..7b36dc48 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots.toml @@ -0,0 +1,41 @@ +# Tests --cache and --no-cache CLI flag overriding rules + +# Baseline: without flags, tasks are not cached because cache.tasks is false +[[plan]] +name = "baseline - tasks not cached when cache.tasks is false" +args = ["run", "build"] + +# --cache enables caching for tasks that don't have explicit cache: false +[[plan]] +name = "--cache enables task caching even when cache.tasks is false" +args = ["run", "--cache", "build"] + +# --cache does NOT force-enable tasks with explicit cache: false +[[plan]] +name = "--cache does not override per-task cache false" +args = ["run", "--cache", "deploy"] + +# --cache enables script caching even when cache.scripts is not set +[[plan]] +name = "--cache enables script caching" +args = ["run", "--cache", "test"] + +# --no-cache disables caching for everything +[[plan]] +name = "--no-cache disables task caching" +args = ["run", "--no-cache", "build"] + +# --no-cache overrides per-task cache: true +[[plan]] +name = "--no-cache overrides per-task cache true" +args = ["run", "--no-cache", "check"] + +# --cache on task with per-task cache: true (redundant but valid) +[[plan]] +name = "--cache on task with per-task cache true enables caching" +args = ["run", "--cache", "check"] + +# --cache and --no-cache conflict +[[plan]] +name = "--cache and --no-cache conflict" +args = ["run", "--cache", "--no-cache", "build"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap new file mode 100644 index 00000000..68cdd5f7 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap @@ -0,0 +1,16 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: err +info: + args: + - run + - "--cache" + - "--no-cache" + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +error: the argument '--cache' cannot be used with '--no-cache' + +Usage: vp run --cache [ADDITIONAL_ARGS]... + +For more information, try '--help'. diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache does not override per-task cache false.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache does not override per-task cache false.snap new file mode 100644 index 00000000..56305ec9 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache does not override per-task cache false.snap @@ -0,0 +1,58 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--cache" + - deploy +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "deploy", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "deploy", + "package_path": "/" + }, + "command": "print-file vite-task.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "vite-task.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables script caching.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables script caching.snap new file mode 100644 index 00000000..06a1e725 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables script caching.snap @@ -0,0 +1,85 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--cache" + - test +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "test", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "test", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "test", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables task caching even when cache.tasks is false.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables task caching even when cache.tasks is false.snap new file mode 100644 index 00000000..0b09b38f --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache enables task caching even when cache.tasks is false.snap @@ -0,0 +1,85 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--cache" + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "build", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache on task with per-task cache true enables caching.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache on task with per-task cache true enables caching.snap new file mode 100644 index 00000000..517c6f69 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache on task with per-task cache true enables caching.snap @@ -0,0 +1,85 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--cache" + - check +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "check" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "check", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "check", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "check", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache disables task caching.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache disables task caching.snap new file mode 100644 index 00000000..115f4b49 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache disables task caching.snap @@ -0,0 +1,58 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--no-cache" + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache overrides per-task cache true.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache overrides per-task cache true.snap new file mode 100644 index 00000000..17c00630 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --no-cache overrides per-task cache true.snap @@ -0,0 +1,58 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--no-cache" + - check +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "check" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "check", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "check", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - baseline - tasks not cached when cache.tasks is false.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - baseline - tasks not cached when cache.tasks is false.snap new file mode 100644 index 00000000..222b403f --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - baseline - tasks not cached when cache.tasks is false.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/task graph.snap new file mode 100644 index 00000000..59d13b75 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/task graph.snap @@ -0,0 +1,145 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: task_graph_json +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "build", + "package_path": "/" + }, + "resolved_config": { + "command": "print-file package.json", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "TaskConfig" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "check" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "check", + "package_path": "/" + }, + "resolved_config": { + "command": "print-file package.json", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "TaskConfig" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "deploy", + "package_path": "/" + }, + "resolved_config": { + "command": "print-file vite-task.json", + "resolved_options": { + "cwd": "/", + "cache_config": null + } + }, + "source": "TaskConfig" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "lint" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "lint", + "package_path": "/" + }, + "resolved_config": { + "command": "print-file vite-task.json", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "PackageJsonScript" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/cache-cli-override", + "task_name": "test", + "package_path": "/" + }, + "resolved_config": { + "command": "print-file package.json", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "PackageJsonScript" + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/vite-task.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/vite-task.json new file mode 100644 index 00000000..12d7aec7 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/vite-task.json @@ -0,0 +1,16 @@ +{ + "cache": { "tasks": false }, + "tasks": { + "build": { + "command": "print-file package.json" + }, + "deploy": { + "command": "print-file vite-task.json", + "cache": false + }, + "check": { + "command": "print-file package.json", + "cache": true + } + } +} diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/package.json new file mode 100644 index 00000000..03221999 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/nested-cache-override", + "scripts": { + "inner": "print-file package.json", + "outer-no-cache": "vp run --no-cache inner", + "outer-cache": "vp run --cache inner", + "outer-inherit": "vp run inner" + } +} diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml new file mode 100644 index 00000000..6f30230c --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml @@ -0,0 +1,26 @@ +# Tests scope of --cache/--no-cache in nested vp run commands + +# Nested vp run --no-cache disables caching for inner task +[[plan]] +name = "nested --no-cache disables inner task caching" +args = ["run", "outer-no-cache"] + +# Nested vp run --cache enables caching for inner task +[[plan]] +name = "nested --cache enables inner task caching" +args = ["run", "outer-cache"] + +# Nested vp run without flags inherits parent resolved cache +[[plan]] +name = "nested run without flags inherits parent cache" +args = ["run", "outer-inherit"] + +# Outer --no-cache with nested --cache: inner overrides outer +[[plan]] +name = "outer --no-cache does not propagate into nested --cache" +args = ["run", "--no-cache", "outer-cache"] + +# Outer --no-cache with nested run (no flags): inner inherits outer +[[plan]] +name = "outer --no-cache propagates to nested run without flags" +args = ["run", "--no-cache", "outer-inherit"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --cache enables inner task caching.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --cache enables inner task caching.snap new file mode 100644 index 00000000..f80fb7d7 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --cache enables inner task caching.snap @@ -0,0 +1,116 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - outer-cache +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "outer-cache" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-cache", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-cache", + "package_path": "/" + }, + "command": "vp run --cache inner", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "inner", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --no-cache disables inner task caching.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --no-cache disables inner task caching.snap new file mode 100644 index 00000000..d690e74e --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested --no-cache disables inner task caching.snap @@ -0,0 +1,89 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - outer-no-cache +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "outer-no-cache" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-no-cache", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-no-cache", + "package_path": "/" + }, + "command": "vp run --no-cache inner", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap new file mode 100644 index 00000000..22576651 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap @@ -0,0 +1,116 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - outer-inherit +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "outer-inherit" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "command": "vp run inner", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "inner", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache does not propagate into nested --cache.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache does not propagate into nested --cache.snap new file mode 100644 index 00000000..51d15e09 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache does not propagate into nested --cache.snap @@ -0,0 +1,117 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--no-cache" + - outer-cache +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "outer-cache" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-cache", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-cache", + "package_path": "/" + }, + "command": "vp run --cache inner", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "inner", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache propagates to nested run without flags.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache propagates to nested run without flags.snap new file mode 100644 index 00000000..b5e9b0cb --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --no-cache propagates to nested run without flags.snap @@ -0,0 +1,90 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--no-cache" + - outer-inherit +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "outer-inherit" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "command": "vp run inner", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/task graph.snap new file mode 100644 index 00000000..72e7589a --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/task graph.snap @@ -0,0 +1,123 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: task_graph_json +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "resolved_config": { + "command": "print-file package.json", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "PackageJsonScript" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "outer-cache" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-cache", + "package_path": "/" + }, + "resolved_config": { + "command": "vp run --cache inner", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "PackageJsonScript" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "outer-inherit" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "resolved_config": { + "command": "vp run inner", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "PackageJsonScript" + }, + "neighbors": [] + }, + { + "key": [ + "/", + "outer-no-cache" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-no-cache", + "package_path": "/" + }, + "resolved_config": { + "command": "vp run --no-cache inner", + "resolved_options": { + "cwd": "/", + "cache_config": { + "env_config": { + "fingerprinted_envs": [], + "pass_through_envs": [ + "" + ] + } + } + } + }, + "source": "PackageJsonScript" + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json new file mode 100644 index 00000000..d548edfa --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json @@ -0,0 +1,3 @@ +{ + "cache": true +} From b33983ef25d77709ffd2d6aa2daf8b13de1b4eab Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:31:25 +0000 Subject: [PATCH 3/8] test: add plan cases to existing cache fixtures to verify resolved cache The task graph now stores per-task cache config without applying the global kill switch. Add plan test cases to verify cache is correctly resolved to null at plan time when the global config disables caching. Updated fixtures (commands changed from echo to print-file to produce Spawn nodes with visible cache_metadata in plan snapshots): - cache-tasks-disabled: verify tasks/scripts not cached with cache.tasks: false - cache-scripts-default: verify scripts not cached by default - cache-scripts-task-override: verify tasks cached, scripts not cached by default - cache-true-no-force-enable: verify per-task cache: false respected with cache: true https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- .../cache-scripts-default/package.json | 4 +- .../cache-scripts-default/snapshots.toml | 6 ++ .../query - script not cached by default.snap | 57 +++++++++++++ .../snapshots/task graph.snap | 4 +- .../cache-scripts-task-override/package.json | 4 +- .../snapshots.toml | 16 ++++ .../query - script not cached by default.snap | 57 +++++++++++++ .../query - task cached by default.snap | 84 +++++++++++++++++++ ...- task with command cached by default.snap | 84 +++++++++++++++++++ .../snapshots/task graph.snap | 6 +- .../vite-task.json | 2 +- .../cache-tasks-disabled/package.json | 4 +- .../cache-tasks-disabled/snapshots.toml | 16 ++++ ...e still disabled by cache.tasks false.snap | 57 +++++++++++++ .../snapshots/query - script not cached.snap | 57 +++++++++++++ ... not cached when cache.tasks is false.snap | 57 +++++++++++++ .../snapshots/task graph.snap | 6 +- .../cache-tasks-disabled/vite-task.json | 2 +- .../cache-true-no-force-enable/package.json | 4 +- .../cache-true-no-force-enable/snapshots.toml | 16 ++++ ... script cached when global cache true.snap | 84 +++++++++++++++++++ ... - task cached when global cache true.snap | 84 +++++++++++++++++++ ... not cached despite global cache true.snap | 57 +++++++++++++ .../snapshots/task graph.snap | 6 +- .../cache-true-no-force-enable/vite-task.json | 2 +- 25 files changed, 754 insertions(+), 22 deletions(-) create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots.toml create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/query - script not cached by default.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots.toml create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - script not cached by default.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task cached by default.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task with command cached by default.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots.toml create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - per-task cache true still disabled by cache.tasks false.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - script not cached.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - task not cached when cache.tasks is false.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots.toml create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - script cached when global cache true.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task cached when global cache true.snap create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task with cache false not cached despite global cache true.snap diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/package.json index 6bfb25cc..d717f308 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/package.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/package.json @@ -1,7 +1,7 @@ { "name": "@test/cache-scripts-default", "scripts": { - "build": "echo building", - "test": "echo testing" + "build": "print-file package.json", + "test": "print-file package.json" } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots.toml new file mode 100644 index 00000000..a487879e --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots.toml @@ -0,0 +1,6 @@ +# Verifies default behavior: scripts are not cached without explicit cache.scripts + +# Script should not be cached by default +[[plan]] +name = "script not cached by default" +args = ["run", "build"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/query - script not cached by default.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/query - script not cached by default.snap new file mode 100644 index 00000000..675d76d8 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/query - script not cached by default.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-scripts-default", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-scripts-default", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap index e7289b35..852aa4cf 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-default/snapshots/task graph.snap @@ -16,7 +16,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-de "package_path": "/" }, "resolved_config": { - "command": "echo building", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { @@ -45,7 +45,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-de "package_path": "/" }, "resolved_config": { - "command": "echo testing", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/package.json index 2990ff19..7c4673a3 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/package.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/package.json @@ -1,7 +1,7 @@ { "name": "@test/cache-scripts-task-override", "scripts": { - "build": "echo building", - "test": "echo testing" + "build": "print-file package.json", + "test": "print-file package.json" } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots.toml new file mode 100644 index 00000000..28ad4d0d --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots.toml @@ -0,0 +1,16 @@ +# Verifies default cache behavior: tasks cached, scripts not cached + +# Task should be cached (tasks default to true) +[[plan]] +name = "task cached by default" +args = ["run", "build"] + +# Task with explicit command should be cached +[[plan]] +name = "task with command cached by default" +args = ["run", "deploy"] + +# Script not wrapped by a task should not be cached +[[plan]] +name = "script not cached by default" +args = ["run", "test"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - script not cached by default.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - script not cached by default.snap new file mode 100644 index 00000000..dafc235f --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - script not cached by default.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - test +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override +--- +[ + { + "key": [ + "/", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/cache-scripts-task-override", + "task_name": "test", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-scripts-task-override", + "task_name": "test", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task cached by default.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task cached by default.snap new file mode 100644 index 00000000..54a470d9 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task cached by default.snap @@ -0,0 +1,84 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-scripts-task-override", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-scripts-task-override", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "build", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task with command cached by default.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task with command cached by default.snap new file mode 100644 index 00000000..b816a161 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/query - task with command cached by default.snap @@ -0,0 +1,84 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - deploy +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override +--- +[ + { + "key": [ + "/", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/cache-scripts-task-override", + "task_name": "deploy", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-scripts-task-override", + "task_name": "deploy", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "deploy", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap index 9a8e7b21..4c99d0c5 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/snapshots/task graph.snap @@ -16,7 +16,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-ta "package_path": "/" }, "resolved_config": { - "command": "echo building", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { @@ -45,7 +45,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-ta "package_path": "/" }, "resolved_config": { - "command": "echo deploying", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { @@ -74,7 +74,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-ta "package_path": "/" }, "resolved_config": { - "command": "echo testing", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/vite-task.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/vite-task.json index 5c71428c..8a8200da 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/vite-task.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-scripts-task-override/vite-task.json @@ -2,7 +2,7 @@ "tasks": { "build": {}, "deploy": { - "command": "echo deploying" + "command": "print-file package.json" } } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/package.json index 877751fb..96eab87e 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/package.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/package.json @@ -1,7 +1,7 @@ { "name": "@test/cache-tasks-disabled", "scripts": { - "build": "echo building", - "test": "echo testing" + "build": "print-file package.json", + "test": "print-file package.json" } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots.toml new file mode 100644 index 00000000..a4fc9cb3 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots.toml @@ -0,0 +1,16 @@ +# Verifies cache.tasks: false disables caching at plan time + +# Task without per-task cache override should not be cached +[[plan]] +name = "task not cached when cache.tasks is false" +args = ["run", "build"] + +# Task with per-task cache: true is still disabled by cache.tasks: false +[[plan]] +name = "per-task cache true still disabled by cache.tasks false" +args = ["run", "deploy"] + +# Script should not be cached (scripts default to false) +[[plan]] +name = "script not cached" +args = ["run", "test"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - per-task cache true still disabled by cache.tasks false.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - per-task cache true still disabled by cache.tasks false.snap new file mode 100644 index 00000000..9118bb90 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - per-task cache true still disabled by cache.tasks false.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - deploy +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled +--- +[ + { + "key": [ + "/", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/cache-tasks-disabled", + "task_name": "deploy", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-tasks-disabled", + "task_name": "deploy", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - script not cached.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - script not cached.snap new file mode 100644 index 00000000..af460270 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - script not cached.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - test +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled +--- +[ + { + "key": [ + "/", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/cache-tasks-disabled", + "task_name": "test", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-tasks-disabled", + "task_name": "test", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - task not cached when cache.tasks is false.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - task not cached when cache.tasks is false.snap new file mode 100644 index 00000000..f4406214 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/query - task not cached when cache.tasks is false.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-tasks-disabled", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-tasks-disabled", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap index d3803329..370cea7b 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/snapshots/task graph.snap @@ -16,7 +16,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disa "package_path": "/" }, "resolved_config": { - "command": "echo building", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { @@ -45,7 +45,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disa "package_path": "/" }, "resolved_config": { - "command": "echo deploying", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { @@ -74,7 +74,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disa "package_path": "/" }, "resolved_config": { - "command": "echo testing", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/vite-task.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/vite-task.json index eb7bf948..31908df8 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/vite-task.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-tasks-disabled/vite-task.json @@ -3,7 +3,7 @@ "tasks": { "build": {}, "deploy": { - "command": "echo deploying", + "command": "print-file package.json", "cache": true } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/package.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/package.json index ae0f53ab..8bace95e 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/package.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/package.json @@ -1,7 +1,7 @@ { "name": "@test/cache-true-no-force-enable", "scripts": { - "build": "echo building", - "test": "echo testing" + "build": "print-file package.json", + "test": "print-file package.json" } } diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots.toml new file mode 100644 index 00000000..06941988 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots.toml @@ -0,0 +1,16 @@ +# Verifies cache: true enables caching but does not override per-task cache: false + +# Task with per-task cache: false should not be cached +[[plan]] +name = "task with cache false not cached despite global cache true" +args = ["run", "build"] + +# Task without per-task override should be cached +[[plan]] +name = "task cached when global cache true" +args = ["run", "deploy"] + +# Script should be cached (cache: true enables scripts too) +[[plan]] +name = "script cached when global cache true" +args = ["run", "test"] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - script cached when global cache true.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - script cached when global cache true.snap new file mode 100644 index 00000000..2e7fc39b --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - script cached when global cache true.snap @@ -0,0 +1,84 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - test +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable +--- +[ + { + "key": [ + "/", + "test" + ], + "node": { + "task_display": { + "package_name": "@test/cache-true-no-force-enable", + "task_name": "test", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-true-no-force-enable", + "task_name": "test", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "test", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task cached when global cache true.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task cached when global cache true.snap new file mode 100644 index 00000000..50210a10 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task cached when global cache true.snap @@ -0,0 +1,84 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - deploy +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable +--- +[ + { + "key": [ + "/", + "deploy" + ], + "node": { + "task_display": { + "package_name": "@test/cache-true-no-force-enable", + "task_name": "deploy", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-true-no-force-enable", + "task_name": "deploy", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "deploy", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task with cache false not cached despite global cache true.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task with cache false not cached despite global cache true.snap new file mode 100644 index 00000000..301ceab8 --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/query - task with cache false not cached despite global cache true.snap @@ -0,0 +1,57 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - build +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable +--- +[ + { + "key": [ + "/", + "build" + ], + "node": { + "task_display": { + "package_name": "@test/cache-true-no-force-enable", + "task_name": "build", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/cache-true-no-force-enable", + "task_name": "build", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": null, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap index a16d7ff3..a865f485 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/snapshots/task graph.snap @@ -16,7 +16,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-fo "package_path": "/" }, "resolved_config": { - "command": "echo building", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": null @@ -38,7 +38,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-fo "package_path": "/" }, "resolved_config": { - "command": "echo deploying", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { @@ -67,7 +67,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-fo "package_path": "/" }, "resolved_config": { - "command": "echo testing", + "command": "print-file package.json", "resolved_options": { "cwd": "/", "cache_config": { diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/vite-task.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/vite-task.json index b1e5d424..7f6f8a25 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/vite-task.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-true-no-force-enable/vite-task.json @@ -5,7 +5,7 @@ "cache": false }, "deploy": { - "command": "echo deploying" + "command": "print-file package.json" } } } From c18a7cb3438a2b325a718511c1e162e7ca93e1fb Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:40:06 +0000 Subject: [PATCH 4/8] test: prove --cache propagation to nested scripts with default config Change nested-cache-override fixture from `"cache": true` to default config (scripts: false, tasks: true). This makes the tests more meaningful since scripts aren't cached by default. Add "outer --cache propagates to nested run without flags" test case to verify that `vp run --cache outer` where outer runs `vp run inner` correctly caches the inner script despite scripts being off globally. https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- .../nested-cache-override/snapshots.toml | 5 + ...n without flags inherits parent cache.snap | 29 +---- ...ropagates to nested run without flags.snap | 117 ++++++++++++++++++ .../nested-cache-override/vite-task.json | 1 - 4 files changed, 123 insertions(+), 29 deletions(-) create mode 100644 crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --cache propagates to nested run without flags.snap diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml index 6f30230c..805b52fd 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots.toml @@ -15,6 +15,11 @@ args = ["run", "outer-cache"] name = "nested run without flags inherits parent cache" args = ["run", "outer-inherit"] +# Outer --cache propagates to nested run without flags +[[plan]] +name = "outer --cache propagates to nested run without flags" +args = ["run", "--cache", "outer-inherit"] + # Outer --no-cache with nested --cache: inner overrides outer [[plan]] name = "outer --no-cache does not propagate into nested --cache" diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap index 22576651..4d2c993a 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - nested run without flags inherits parent cache.snap @@ -59,34 +59,7 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-ove "kind": { "Leaf": { "Spawn": { - "cache_metadata": { - "spawn_fingerprint": { - "cwd": "", - "program_fingerprint": { - "OutsideWorkspace": { - "program_name": "print-file" - } - }, - "args": [ - "package.json" - ], - "env_fingerprints": { - "fingerprinted_envs": {}, - "pass_through_env_config": [ - "" - ] - }, - "fingerprint_ignores": null - }, - "execution_cache_key": { - "UserTask": { - "task_name": "inner", - "and_item_index": 0, - "extra_args": [], - "package_path": "" - } - } - }, + "cache_metadata": null, "spawn_command": { "program_path": "/node_modules/.bin/print-file", "args": [ diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --cache propagates to nested run without flags.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --cache propagates to nested run without flags.snap new file mode 100644 index 00000000..89d3c5aa --- /dev/null +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/snapshots/query - outer --cache propagates to nested run without flags.snap @@ -0,0 +1,117 @@ +--- +source: crates/vite_task_plan/tests/plan_snapshots/main.rs +expression: "&plan_json" +info: + args: + - run + - "--cache" + - outer-inherit +input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override +--- +[ + { + "key": [ + "/", + "outer-inherit" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "outer-inherit", + "package_path": "/" + }, + "command": "vp run inner", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Expanded": [ + { + "key": [ + "/", + "inner" + ], + "node": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "items": [ + { + "execution_item_display": { + "task_display": { + "package_name": "@test/nested-cache-override", + "task_name": "inner", + "package_path": "/" + }, + "command": "print-file package.json", + "and_item_index": null, + "cwd": "/" + }, + "kind": { + "Leaf": { + "Spawn": { + "cache_metadata": { + "spawn_fingerprint": { + "cwd": "", + "program_fingerprint": { + "OutsideWorkspace": { + "program_name": "print-file" + } + }, + "args": [ + "package.json" + ], + "env_fingerprints": { + "fingerprinted_envs": {}, + "pass_through_env_config": [ + "" + ] + }, + "fingerprint_ignores": null + }, + "execution_cache_key": { + "UserTask": { + "task_name": "inner", + "and_item_index": 0, + "extra_args": [], + "package_path": "" + } + } + }, + "spawn_command": { + "program_path": "/node_modules/.bin/print-file", + "args": [ + "package.json" + ], + "all_envs": { + "NO_COLOR": "1", + "PATH": "/node_modules/.bin:/node_modules/.bin" + }, + "cwd": "/" + } + } + } + } + } + ] + }, + "neighbors": [] + } + ] + } + } + ] + }, + "neighbors": [] + } +] diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json index d548edfa..2c63c085 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/nested-cache-override/vite-task.json @@ -1,3 +1,2 @@ { - "cache": true } From 79c11c0abb6ead613ff153be0e82fd1ce471b7bc Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:44:07 +0000 Subject: [PATCH 5/8] docs: clarify cache override propagation and inheritance in comments Update CacheOverride::None doc to explain inheritance from parent context. Add comments on the if-guard in plan_query_request explaining why skipping the update enables propagation, and why overrides are relative to the workspace config rather than the parent's resolved state. https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- crates/vite_task_plan/src/plan.rs | 11 +++++++++-- crates/vite_task_plan/src/plan_request.rs | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/vite_task_plan/src/plan.rs b/crates/vite_task_plan/src/plan.rs index 5cfdbfca..78495e0f 100644 --- a/crates/vite_task_plan/src/plan.rs +++ b/crates/vite_task_plan/src/plan.rs @@ -557,10 +557,17 @@ pub async fn plan_query_request( query_plan_request: QueryPlanRequest, mut context: PlanContext<'_>, ) -> Result { - // Apply cache override from this request (nested `vp run --no-cache` etc.) - // If the nested command has no override, inherit the parent's resolved config. + // Apply cache override from `--cache` / `--no-cache` flags on this request. + // + // When `None`, we skip the update so the context keeps whatever the parent + // resolved — this is how `vp run --cache outer` propagates to a nested + // `vp run inner` that has no flags of its own. let cache_override = query_plan_request.plan_options.cache_override; if cache_override != CacheOverride::None { + // Override is relative to the *workspace* config, not the parent's + // resolved config. This means `vp run --no-cache outer` where outer + // runs `vp run --cache inner` re-enables caching from the workspace + // defaults, rather than from the parent's disabled state. let final_cache = resolve_cache_with_override( *context.indexed_task_graph().global_cache_config(), cache_override, diff --git a/crates/vite_task_plan/src/plan_request.rs b/crates/vite_task_plan/src/plan_request.rs index a0ca12b2..71474f77 100644 --- a/crates/vite_task_plan/src/plan_request.rs +++ b/crates/vite_task_plan/src/plan_request.rs @@ -34,7 +34,9 @@ impl ScriptCommand { /// CLI-level cache override from `--cache` / `--no-cache` flags. #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] pub enum CacheOverride { - /// No override — use the resolved config from the task graph. + /// No override — inherit the parent's resolved cache config. + /// For a top-level `vp run`, this is the workspace config. + /// For a nested `vp run` inside a script, this is whatever the parent resolved. #[default] None, /// Force all caching on (`--cache` flag). From 959c3131cba4f804463db8105495f6799f584c1f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:49:21 +0000 Subject: [PATCH 6/8] docs: update cache decision tree to match --cache implementation --cache acts as cache: true, overriding both cache.tasks and cache.scripts (not just scripts). Restructure the decision tree to reflect that --cache/--no-cache are resolved first as global overrides, then per-task cache: false is checked, then the task-vs-script distinction determines which global switch applies. https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- docs/task-configuration.md | 175 +++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 docs/task-configuration.md diff --git a/docs/task-configuration.md b/docs/task-configuration.md new file mode 100644 index 00000000..f72438e8 --- /dev/null +++ b/docs/task-configuration.md @@ -0,0 +1,175 @@ +# Task Configuration + +Tasks are configured in the `run` section of your `vite.config.ts`. There are two ways tasks can exist: **explicit task definitions** and **package.json scripts**. + +## Configuration Location + +Each package can have its own `vite.config.ts` that configures tasks for that package: + +```ts +// packages/app/vite.config.ts +import { defineConfig } from 'vite-plus'; + +export default defineConfig({ + run: { + tasks: { + build: { + command: 'tsc', + dependsOn: ['lint'], + cache: true, + envs: ['NODE_ENV'], + passThroughEnvs: ['CI'], + }, + lint: { + command: 'vp lint', + }, + deploy: { + command: 'deploy-script --prod', + cache: false, + }, + }, + }, +}); +``` + +## Task Definition Schema + +Each task supports these fields: + +| Field | Type | Default | Description | +| ----------------- | ---------- | ------------------- | ---------------------------------------------------------------------------------------------- | +| `command` | `string` | — | The shell command to run. If omitted, falls back to the package.json script of the same name. | +| `cwd` | `string` | package root | Working directory relative to the package root. | +| `dependsOn` | `string[]` | `[]` | Explicit task dependencies. See [Task Orchestration](./task-orchestration.md). | +| `cache` | `boolean` | `true` | Whether to cache this task's output. | +| `envs` | `string[]` | `[]` | Environment variables to include in the cache fingerprint. | +| `passThroughEnvs` | `string[]` | (built-in defaults) | Environment variables passed to the process but NOT included in the cache fingerprint. | +| `inputs`\* | `Array` | auto-inferred | Which files to track for cache invalidation. See [Caching — Inputs](./caching.md#task-inputs). | + +## Scripts vs Tasks + +Vite Task recognizes two sources of runnable commands: + +### 1. Package.json Scripts + +Any `"scripts"` entry in a package's `package.json` is automatically available: + +```json +// packages/app/package.json +{ + "name": "@my/app", + "scripts": { + "build": "tsc", + "test": "vitest run", + "dev": "vite dev" + } +} +``` + +These scripts can be run directly with `vp run build` (from within the `packages/app` directory). + +### 2. Explicit Task Definitions + +Tasks defined in a package's `vite.config.ts` only affect that package. A task definition applies when: + +- The package has a matching script in `package.json`, or +- The task itself specifies a `command` + +```ts +// packages/app/vite.config.ts +export default defineConfig({ + run: { + tasks: { + build: { + // No command — uses this package's "build" script from package.json + dependsOn: ['lint'], + envs: ['NODE_ENV'], + }, + }, + }, +}); +``` + +In this example, `build` runs `@my/app`'s own `package.json` `"build"` script but with the added `dependsOn` and cache configuration. + +**Conflict rule:** If both the task definition and the `package.json` script specify a command, it's an error. Either define the command in `vite.config.ts` or in `package.json` — not both. + +## Global Cache Configuration\* + +The `cache` field is only allowed in the **workspace root** `vite.config.ts` and controls workspace-wide cache behavior: + +```ts +// vite.config.ts (workspace root only) +export default defineConfig({ + run: { + cache: { scripts: true, tasks: true }, + }, +}); +``` + +| Setting | Type | Default | Meaning | +| --------------- | ------------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `cache` | `boolean \| { scripts, tasks }` | `{ scripts: false, tasks: true }` | Global cache toggle | +| `cache.tasks` | `boolean` | `true` | When `true`, respects individual task cache config. When `false`, disables all task caching globally. | +| `cache.scripts` | `boolean` | `false` | When `true`, caches `package.json` scripts even without explicit task entries. | + +Shorthands: + +- `cache: true` → `{ scripts: true, tasks: true }` +- `cache: false` → `{ scripts: false, tasks: false }` + +### CLI Overrides\* + +You can override the global cache config per invocation: + +```bash +vp run build --cache # Force all caching on (scripts + tasks) +vp run build --no-cache # Force all caching off +``` + +### When Is Caching Enabled? + +A command run by `vp run` is either a **task** (has an entry in `vite.config.ts`) or a **script** (only exists in `package.json` with no corresponding task entry). A script that has a matching task entry is treated as a task. + +``` +--no-cache on the command line? +├─ YES → NOT CACHED (overrides everything) +└─ NO + │ + --cache on the command line? + ├─ YES → acts as cache: true (sets scripts: true, tasks: true) + └─ NO → uses workspace config + │ + Per-task cache set to false? + ├─ YES → NOT CACHED (--cache does NOT override this) + └─ NO or not set + │ + Does the command have a task entry in vite.config.ts? + │ + ├─ YES (task) ────────────────────────────────────────── + │ │ + │ Global cache.tasks enabled? (default: true, or true via --cache) + │ ├─ NO → NOT CACHED + │ └─ YES → CACHED <----- this is the default for tasks + │ + └─ NO (script) ───────────────────────────────────────── + │ + Global cache.scripts enabled? (default: false, or true via --cache) + ├─ YES → CACHED + └─ NO → NOT CACHED <----- this is the default for scripts +``` + +In short: **tasks are cached by default, scripts are not.** `--no-cache` turns off caching for everything. `--cache` is equivalent to `cache: true` — it enables both `cache.tasks` and `cache.scripts`, but cannot override a task's per-task `cache: false`. + +## Compound Commands and Nested `vp run` + +Commands joined with `&&` are split into independently-cached sub-tasks. Commands containing `vp run` calls are expanded at plan time into the execution graph. Both features work in task `command` fields and `package.json` scripts. See [Task Orchestration](./task-orchestration.md#compound-commands) for details. + +## Environment Variables + +See [Caching — Environment Variables](./caching.md#environment-variables) for full details on how `envs` and `passThroughEnvs` work with the cache system. + +Quick summary: + +- **`envs`**: Included in the cache fingerprint. Changing a value here invalidates the cache. +- **`passThroughEnvs`**: Passed to the process but NOT fingerprinted. Changing values here does NOT invalidate the cache. From fec674eb49745c726f4c1d873ffb4c0f07a96410 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:52:34 +0000 Subject: [PATCH 7/8] docs: move per-task cache check under task branch in decision tree Per-task cache: false only applies to tasks (scripts can't have it), so it belongs under the task branch, not before the task/script split. https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- docs/task-configuration.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/task-configuration.md b/docs/task-configuration.md index f72438e8..f82f7bea 100644 --- a/docs/task-configuration.md +++ b/docs/task-configuration.md @@ -140,23 +140,23 @@ A command run by `vp run` is either a **task** (has an entry in `vite.config.ts` ├─ YES → acts as cache: true (sets scripts: true, tasks: true) └─ NO → uses workspace config │ - Per-task cache set to false? - ├─ YES → NOT CACHED (--cache does NOT override this) - └─ NO or not set - │ - Does the command have a task entry in vite.config.ts? - │ - ├─ YES (task) ────────────────────────────────────────── - │ │ - │ Global cache.tasks enabled? (default: true, or true via --cache) - │ ├─ NO → NOT CACHED - │ └─ YES → CACHED <----- this is the default for tasks + Does the command have a task entry in vite.config.ts? + │ + ├─ YES (task) ────────────────────────────────────────── + │ │ + │ Global cache.tasks enabled? (default: true, or true via --cache) + │ ├─ NO → NOT CACHED + │ └─ YES + │ │ + │ Per-task cache set to false? + │ ├─ YES → NOT CACHED (--cache does NOT override this) + │ └─ NO or not set → CACHED <----- this is the default for tasks + │ + └─ NO (script) ───────────────────────────────────────── │ - └─ NO (script) ───────────────────────────────────────── - │ - Global cache.scripts enabled? (default: false, or true via --cache) - ├─ YES → CACHED - └─ NO → NOT CACHED <----- this is the default for scripts + Global cache.scripts enabled? (default: false, or true via --cache) + ├─ YES → CACHED + └─ NO → NOT CACHED <----- this is the default for scripts ``` In short: **tasks are cached by default, scripts are not.** `--no-cache` turns off caching for everything. `--cache` is equivalent to `cache: true` — it enables both `cache.tasks` and `cache.scripts`, but cannot override a task's per-task `cache: false`. From 2537b346cc3a9168e30d8e3d18774571b7821e70 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 17:54:19 +0000 Subject: [PATCH 8/8] chore: remove docs file from feature branch This file belongs on the docs branch, not here. https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah --- docs/task-configuration.md | 175 ------------------------------------- 1 file changed, 175 deletions(-) delete mode 100644 docs/task-configuration.md diff --git a/docs/task-configuration.md b/docs/task-configuration.md deleted file mode 100644 index f82f7bea..00000000 --- a/docs/task-configuration.md +++ /dev/null @@ -1,175 +0,0 @@ -# Task Configuration - -Tasks are configured in the `run` section of your `vite.config.ts`. There are two ways tasks can exist: **explicit task definitions** and **package.json scripts**. - -## Configuration Location - -Each package can have its own `vite.config.ts` that configures tasks for that package: - -```ts -// packages/app/vite.config.ts -import { defineConfig } from 'vite-plus'; - -export default defineConfig({ - run: { - tasks: { - build: { - command: 'tsc', - dependsOn: ['lint'], - cache: true, - envs: ['NODE_ENV'], - passThroughEnvs: ['CI'], - }, - lint: { - command: 'vp lint', - }, - deploy: { - command: 'deploy-script --prod', - cache: false, - }, - }, - }, -}); -``` - -## Task Definition Schema - -Each task supports these fields: - -| Field | Type | Default | Description | -| ----------------- | ---------- | ------------------- | ---------------------------------------------------------------------------------------------- | -| `command` | `string` | — | The shell command to run. If omitted, falls back to the package.json script of the same name. | -| `cwd` | `string` | package root | Working directory relative to the package root. | -| `dependsOn` | `string[]` | `[]` | Explicit task dependencies. See [Task Orchestration](./task-orchestration.md). | -| `cache` | `boolean` | `true` | Whether to cache this task's output. | -| `envs` | `string[]` | `[]` | Environment variables to include in the cache fingerprint. | -| `passThroughEnvs` | `string[]` | (built-in defaults) | Environment variables passed to the process but NOT included in the cache fingerprint. | -| `inputs`\* | `Array` | auto-inferred | Which files to track for cache invalidation. See [Caching — Inputs](./caching.md#task-inputs). | - -## Scripts vs Tasks - -Vite Task recognizes two sources of runnable commands: - -### 1. Package.json Scripts - -Any `"scripts"` entry in a package's `package.json` is automatically available: - -```json -// packages/app/package.json -{ - "name": "@my/app", - "scripts": { - "build": "tsc", - "test": "vitest run", - "dev": "vite dev" - } -} -``` - -These scripts can be run directly with `vp run build` (from within the `packages/app` directory). - -### 2. Explicit Task Definitions - -Tasks defined in a package's `vite.config.ts` only affect that package. A task definition applies when: - -- The package has a matching script in `package.json`, or -- The task itself specifies a `command` - -```ts -// packages/app/vite.config.ts -export default defineConfig({ - run: { - tasks: { - build: { - // No command — uses this package's "build" script from package.json - dependsOn: ['lint'], - envs: ['NODE_ENV'], - }, - }, - }, -}); -``` - -In this example, `build` runs `@my/app`'s own `package.json` `"build"` script but with the added `dependsOn` and cache configuration. - -**Conflict rule:** If both the task definition and the `package.json` script specify a command, it's an error. Either define the command in `vite.config.ts` or in `package.json` — not both. - -## Global Cache Configuration\* - -The `cache` field is only allowed in the **workspace root** `vite.config.ts` and controls workspace-wide cache behavior: - -```ts -// vite.config.ts (workspace root only) -export default defineConfig({ - run: { - cache: { scripts: true, tasks: true }, - }, -}); -``` - -| Setting | Type | Default | Meaning | -| --------------- | ------------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `cache` | `boolean \| { scripts, tasks }` | `{ scripts: false, tasks: true }` | Global cache toggle | -| `cache.tasks` | `boolean` | `true` | When `true`, respects individual task cache config. When `false`, disables all task caching globally. | -| `cache.scripts` | `boolean` | `false` | When `true`, caches `package.json` scripts even without explicit task entries. | - -Shorthands: - -- `cache: true` → `{ scripts: true, tasks: true }` -- `cache: false` → `{ scripts: false, tasks: false }` - -### CLI Overrides\* - -You can override the global cache config per invocation: - -```bash -vp run build --cache # Force all caching on (scripts + tasks) -vp run build --no-cache # Force all caching off -``` - -### When Is Caching Enabled? - -A command run by `vp run` is either a **task** (has an entry in `vite.config.ts`) or a **script** (only exists in `package.json` with no corresponding task entry). A script that has a matching task entry is treated as a task. - -``` ---no-cache on the command line? -├─ YES → NOT CACHED (overrides everything) -└─ NO - │ - --cache on the command line? - ├─ YES → acts as cache: true (sets scripts: true, tasks: true) - └─ NO → uses workspace config - │ - Does the command have a task entry in vite.config.ts? - │ - ├─ YES (task) ────────────────────────────────────────── - │ │ - │ Global cache.tasks enabled? (default: true, or true via --cache) - │ ├─ NO → NOT CACHED - │ └─ YES - │ │ - │ Per-task cache set to false? - │ ├─ YES → NOT CACHED (--cache does NOT override this) - │ └─ NO or not set → CACHED <----- this is the default for tasks - │ - └─ NO (script) ───────────────────────────────────────── - │ - Global cache.scripts enabled? (default: false, or true via --cache) - ├─ YES → CACHED - └─ NO → NOT CACHED <----- this is the default for scripts -``` - -In short: **tasks are cached by default, scripts are not.** `--no-cache` turns off caching for everything. `--cache` is equivalent to `cache: true` — it enables both `cache.tasks` and `cache.scripts`, but cannot override a task's per-task `cache: false`. - -## Compound Commands and Nested `vp run` - -Commands joined with `&&` are split into independently-cached sub-tasks. Commands containing `vp run` calls are expanded at plan time into the execution graph. Both features work in task `command` fields and `package.json` scripts. See [Task Orchestration](./task-orchestration.md#compound-commands) for details. - -## Environment Variables - -See [Caching — Environment Variables](./caching.md#environment-variables) for full details on how `envs` and `passThroughEnvs` work with the cache system. - -Quick summary: - -- **`envs`**: Included in the cache fingerprint. Changing a value here invalidates the cache. -- **`passThroughEnvs`**: Passed to the process but NOT fingerprinted. Changing values here does NOT invalidate the cache.