diff --git a/Cargo.lock b/Cargo.lock index 2669b4c44f..9bd8f84a4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1772,7 +1772,7 @@ dependencies = [ [[package]] name = "fspy" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "allocator-api2", "anyhow", @@ -1807,7 +1807,7 @@ dependencies = [ [[package]] name = "fspy_detours_sys" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "cc", "winapi", @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "fspy_preload_unix" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "bincode", @@ -1831,7 +1831,7 @@ dependencies = [ [[package]] name = "fspy_preload_windows" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "constcat", @@ -1847,7 +1847,7 @@ dependencies = [ [[package]] name = "fspy_seccomp_unotify" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "futures-util", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "fspy_shared" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "allocator-api2", "bincode", @@ -1882,7 +1882,7 @@ dependencies = [ [[package]] name = "fspy_shared_unix" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "base64 0.22.1", @@ -4600,7 +4600,7 @@ dependencies = [ [[package]] name = "pty_terminal_test_client" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" [[package]] name = "quote" @@ -7237,7 +7237,7 @@ dependencies = [ [[package]] name = "vite_glob" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "thiserror 2.0.18", "vite_path", @@ -7281,7 +7281,7 @@ dependencies = [ [[package]] name = "vite_graph_ser" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "petgraph 0.8.3", "serde", @@ -7363,7 +7363,7 @@ dependencies = [ [[package]] name = "vite_path" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "diff-struct", @@ -7377,7 +7377,7 @@ dependencies = [ [[package]] name = "vite_select" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "crossterm", @@ -7404,7 +7404,7 @@ dependencies = [ [[package]] name = "vite_shell" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "brush-parser 0.3.0 (git+https://github.com/reubeno/brush?rev=dcb760933b10ee0433d7b740a5709b06f5c67c6b)", @@ -7431,7 +7431,7 @@ dependencies = [ [[package]] name = "vite_str" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "bincode", "compact_str", @@ -7442,7 +7442,7 @@ dependencies = [ [[package]] name = "vite_task" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "async-trait", @@ -7477,7 +7477,7 @@ dependencies = [ [[package]] name = "vite_task_graph" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "async-trait", @@ -7499,7 +7499,7 @@ dependencies = [ [[package]] name = "vite_task_plan" version = "0.1.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "anyhow", "async-trait", @@ -7529,7 +7529,7 @@ version = "0.0.0" [[package]] name = "vite_workspace" version = "0.0.0" -source = "git+https://github.com/voidzero-dev/vite-task.git?rev=69cc6eba95a3b7f25f7d4d32c3f29b1386995907#69cc6eba95a3b7f25f7d4d32c3f29b1386995907" +source = "git+https://github.com/voidzero-dev/vite-task.git?rev=8c3cc35e31713738f45756b42e80996d97ec6429#8c3cc35e31713738f45756b42e80996d97ec6429" dependencies = [ "clap", "petgraph 0.8.3", diff --git a/Cargo.toml b/Cargo.toml index 310f87436c..4046bff285 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ dunce = "1.0.5" fast-glob = "1.0.0" flate2 = { version = "=1.1.9", features = ["zlib-rs"] } form_urlencoded = "1.2.1" -fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } +fspy = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } futures = "0.3.31" futures-util = "0.3.31" glob = "0.3.2" @@ -185,15 +185,15 @@ vfs = "0.13.0" vite_command = { path = "crates/vite_command" } vite_error = { path = "crates/vite_error" } vite_js_runtime = { path = "crates/vite_js_runtime" } -vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } +vite_glob = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } vite_install = { path = "crates/vite_install" } vite_migration = { path = "crates/vite_migration" } vite_shared = { path = "crates/vite_shared" } vite_static_config = { path = "crates/vite_static_config" } -vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } -vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } -vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } -vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "69cc6eba95a3b7f25f7d4d32c3f29b1386995907" } +vite_path = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } +vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } +vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } +vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "8c3cc35e31713738f45756b42e80996d97ec6429" } walkdir = "2.5.0" wax = "0.6.0" which = "8.0.0" diff --git a/packages/cli/binding/src/cli.rs b/packages/cli/binding/src/cli.rs index d33c960f9c..a5e0b82119 100644 --- a/packages/cli/binding/src/cli.rs +++ b/packages/cli/binding/src/cli.rs @@ -23,7 +23,7 @@ use vite_task::{ Command, CommandHandler, ExitStatus, HandledCommand, ScriptCommand, Session, SessionConfig, config::{ UserRunConfig, - user::{EnabledCacheConfig, UserCacheConfig}, + user::{EnabledCacheConfig, UserCacheConfig, UserInputEntry}, }, loader::UserConfigLoader, plan_request::SyntheticPlanRequest, @@ -329,7 +329,10 @@ impl SubcommandResolver { cache_config: UserCacheConfig::with_config(EnabledCacheConfig { env: Some(Box::new([Str::from("VITE_*")])), untracked_env: None, - input: None, + input: Some(vec![ + UserInputEntry::Auto { auto: true }, + UserInputEntry::Glob(Str::from("!node_modules/.vite-temp/**")), + ]), }), envs: merge_resolved_envs_with_version(envs, resolved.envs), }) @@ -381,7 +384,10 @@ impl SubcommandResolver { cache_config: UserCacheConfig::with_config(EnabledCacheConfig { env: None, untracked_env: None, - input: None, + input: Some(vec![ + UserInputEntry::Auto { auto: true }, + UserInputEntry::Glob(Str::from("!node_modules/.vite-temp/**")), + ]), }), envs: merge_resolved_envs(envs, resolved.envs), }) @@ -1534,7 +1540,7 @@ mod tests { use clap::Parser; use serde_json::json; - use vite_task::config::UserRunConfig; + use vite_task::{Command, config::UserRunConfig}; use super::{ CLIArgs, LintMessageKind, SynthesizableSubcommand, extract_unknown_argument, @@ -1570,11 +1576,13 @@ mod tests { } #[test] - fn unknown_argument_detected_with_pass_as_value_hint() { - let error = - CLIArgs::try_parse_from(["vp", "run", "--yolo"]).expect_err("Expected parse error"); - assert_eq!(extract_unknown_argument(&error).as_deref(), Some("--yolo")); - assert!(has_pass_as_value_suggestion(&error)); + fn run_accepts_unknown_flags_as_task_args() { + // After trailing_var_arg change, unknown flags like --yolo are + // accepted as task arguments instead of producing a parse error. + let args = CLIArgs::try_parse_from(["vp", "run", "--yolo"]).unwrap(); + let debug = vite_str::format!("{args:?}"); + assert!(debug.contains("\"--yolo\""), "Expected --yolo in task args, got: {debug}",); + assert!(matches!(args, CLIArgs::ViteTask(Command::Run(_)))); } #[test] diff --git a/packages/cli/snap-tests/command-pack-monorepo/snap.txt b/packages/cli/snap-tests/command-pack-monorepo/snap.txt index 556000d05d..f45b45ac7f 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/snap.txt +++ b/packages/cli/snap-tests/command-pack-monorepo/snap.txt @@ -1,49 +1,41 @@ -> vp run hello#build # should build the library +> vp run hello#build # should build the library from root > ls packages/hello/dist # should have the library index.cjs -> vp run hello#build 2>&1 # should hit cache but not working for now -~/packages/hello$ vp pack -ℹ entry: src/index.ts -ℹ Build start -ℹ Cleaning 1 files -ℹ dist/index.cjs kB │ gzip: kB -ℹ 1 files, total: kB -✔ Build complete in ms +> vp run hello#build 2>&1 | grep 'cache hit' # should hit cache from root +~/packages/hello$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. ---- -vp run: hello#build not cached because it modified its input. (Run `vp run --last-details` for full details) +> cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir +~/packages/hello$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. -> vp run array-config#build # should build the library supports array config +> cd packages/hello && vp pack 2>&1 # direct vp pack should not be cached +> cd packages/hello && vp pack 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp pack has no cache +0 +no cache + +> echo 'export function hello() { console.log("changed"); }' > packages/hello/src/hello.ts +> vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change +~/packages/hello$ vp pack ○ cache miss: 'packages/hello/src/hello.ts' modified, executing + +> cd packages/array-config && vp run build # should build the library from sub dir > ls packages/array-config/dist # should have the library index.d.mts index.mjs -> vp run array-config#build 2>&1 # should hit cache but not working -~/packages/array-config$ vp pack -ℹ entry: src/sub/index.ts -ℹ Build start -ℹ Cleaning 2 files -ℹ dist/index.mjs kB │ gzip: kB -ℹ dist/index.d.mts kB │ gzip: kB -ℹ 2 files, total: kB -✔ Build complete in ms +> cd packages/array-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir +~/packages/array-config$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. ---- -vp run: array-config#build not cached because it modified its input. (Run `vp run --last-details` for full details) +> vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build +~/packages/array-config$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. -> vp run default-config#build # should build the library supports default config +> vp run default-config#build # should build the library from root > ls packages/default-config/dist # should have the library index.mjs -> vp run default-config#build 2>&1 # should hit cache but not working -~/packages/default-config$ vp pack -ℹ entry: src/index.ts -ℹ Build start -ℹ Cleaning 1 files -ℹ dist/index.mjs kB │ gzip: kB -ℹ 1 files, total: kB -✔ Build complete in ms - ---- -vp run: default-config#build not cached because it modified its input. (Run `vp run --last-details` for full details) +> cd packages/default-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir +~/packages/default-config$ vp pack ◉ cache hit, replaying +vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/command-pack-monorepo/steps.json b/packages/cli/snap-tests/command-pack-monorepo/steps.json index 3dff4364be..59c31fe580 100644 --- a/packages/cli/snap-tests/command-pack-monorepo/steps.json +++ b/packages/cli/snap-tests/command-pack-monorepo/steps.json @@ -1,23 +1,31 @@ { - "ignoredPlatforms": ["win32"], "commands": [ { - "command": "vp run hello#build # should build the library", + "command": "vp run hello#build # should build the library from root", "ignoreOutput": true }, "ls packages/hello/dist # should have the library", - "vp run hello#build 2>&1 # should hit cache but not working for now", + "vp run hello#build 2>&1 | grep 'cache hit' # should hit cache from root", + "cd packages/hello && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", { - "command": "vp run array-config#build # should build the library supports array config", + "command": "cd packages/hello && vp pack 2>&1 # direct vp pack should not be cached", + "ignoreOutput": true + }, + "cd packages/hello && vp pack 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp pack has no cache", + "echo 'export function hello() { console.log(\"changed\"); }' > packages/hello/src/hello.ts", + "vp run hello#build 2>&1 | grep 'cache miss' # should miss cache after source change", + { + "command": "cd packages/array-config && vp run build # should build the library from sub dir", "ignoreOutput": true }, "ls packages/array-config/dist # should have the library", - "vp run array-config#build 2>&1 # should hit cache but not working", + "cd packages/array-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", + "vp run array-config#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build", { - "command": "vp run default-config#build # should build the library supports default config", + "command": "vp run default-config#build # should build the library from root", "ignoreOutput": true }, "ls packages/default-config/dist # should have the library", - "vp run default-config#build 2>&1 # should hit cache but not working" + "cd packages/default-config && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir" ] } diff --git a/packages/cli/snap-tests/command-pack/snap.txt b/packages/cli/snap-tests/command-pack/snap.txt index 074a58b0f8..10bbc5270b 100644 --- a/packages/cli/snap-tests/command-pack/snap.txt +++ b/packages/cli/snap-tests/command-pack/snap.txt @@ -59,20 +59,17 @@ $ vp pack src/index.ts ℹ 1 files, total: kB ✔ Build complete in ms ---- -vp run: command-pack#pack not cached because it modified its input. (Run `vp run --last-details` for full details) > ls dist # should have the library index.mjs > vp run pack # should hit cache -$ vp pack src/index.ts +$ vp pack src/index.ts ◉ cache hit, replaying ℹ entry: src/index.ts ℹ Build start -ℹ Cleaning 1 files ℹ dist/index.mjs kB │ gzip: kB ℹ 1 files, total: kB ✔ Build complete in ms --- -vp run: command-pack#pack not cached because it modified its input. (Run `vp run --last-details` for full details) +vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/command-vp-alias/snap.txt b/packages/cli/snap-tests/command-vp-alias/snap.txt index 424eb25c87..5082487baa 100644 --- a/packages/cli/snap-tests/command-vp-alias/snap.txt +++ b/packages/cli/snap-tests/command-vp-alias/snap.txt @@ -30,8 +30,10 @@ Run tasks Usage: vp run [OPTIONS] [TASK_SPECIFIER] [ADDITIONAL_ARGS]... Arguments: - [TASK_SPECIFIER] `packageName#taskName` or `taskName`. If omitted, lists all available tasks - [ADDITIONAL_ARGS]... Additional arguments to pass to the tasks + [TASK_SPECIFIER] [ADDITIONAL_ARGS]... + Task to run, as `packageName#taskName` or just `taskName`. + Any arguments after the task name are forwarded to the task process. + Running `vp run` without a task name shows an interactive task selector. Options: -r, --recursive Select all packages in the workspace diff --git a/packages/cli/snap-tests/pass-no-color-env/snap.txt b/packages/cli/snap-tests/pass-no-color-env/snap.txt index b8cd705caf..dab568862b 100644 --- a/packages/cli/snap-tests/pass-no-color-env/snap.txt +++ b/packages/cli/snap-tests/pass-no-color-env/snap.txt @@ -1,9 +1,9 @@ > vp run check -- --foo # get NO_COLOR=true from default env -$ node check.js --foo +$ node check.js -- --foo NO_COLOR=true, CI=true > NO_COLOR=false vp run check -- --bar # get NO_COLOR=false from custom env -$ node check.js --bar +$ node check.js -- --bar NO_COLOR=false, CI=true diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/package.json b/packages/cli/snap-tests/vp-build-cache-disabled/package.json new file mode 100644 index 0000000000..73c7e3ef15 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/package.json @@ -0,0 +1,8 @@ +{ + "name": "vp-build-cache-disabled", + "private": true, + "workspaces": [ + "packages/*" + ], + "packageManager": "pnpm@10.32.1" +} diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html new file mode 100644 index 0000000000..8d691b4891 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json new file mode 100644 index 0000000000..5958e45892 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/packages/app/package.json @@ -0,0 +1,7 @@ +{ + "name": "app", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/snap.txt b/packages/cli/snap-tests/vp-build-cache-disabled/snap.txt new file mode 100644 index 0000000000..45652564fa --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/snap.txt @@ -0,0 +1,11 @@ +> vp run app#build # first build +> ls packages/app/dist # should have the build output +assets +index.html + +> vp run app#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit +0 +no cache hit + +> vp run app#build 2>&1 | grep 'cache disabled' # should show cache disabled +~/packages/app$ vp build ⊘ cache disabled diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/steps.json b/packages/cli/snap-tests/vp-build-cache-disabled/steps.json new file mode 100644 index 0000000000..e200ca1953 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/steps.json @@ -0,0 +1,11 @@ +{ + "commands": [ + { + "command": "vp run app#build # first build", + "ignoreOutput": true + }, + "ls packages/app/dist # should have the build output", + "vp run app#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit", + "vp run app#build 2>&1 | grep 'cache disabled' # should show cache disabled" + ] +} diff --git a/packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts b/packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts new file mode 100644 index 0000000000..de01bdfd87 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-disabled/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: false, + }, +}; diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/package.json b/packages/cli/snap-tests/vp-build-cache-monorepo/package.json new file mode 100644 index 0000000000..514d12a003 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/package.json @@ -0,0 +1,8 @@ +{ + "name": "build-cache-monorepo", + "private": true, + "workspaces": [ + "packages/*" + ], + "packageManager": "pnpm@10.32.1" +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html new file mode 100644 index 0000000000..8d691b4891 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json new file mode 100644 index 0000000000..5958e45892 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/app/package.json @@ -0,0 +1,7 @@ +{ + "name": "app", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html new file mode 100644 index 0000000000..b5fbf6dcc5 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json new file mode 100644 index 0000000000..8bfdd7166f --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/packages/web/package.json @@ -0,0 +1,7 @@ +{ + "name": "web", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt new file mode 100644 index 0000000000..5a68d8b277 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/snap.txt @@ -0,0 +1,34 @@ +> vp run app#build # should build the app from root +> ls packages/app/dist # should have the build output +assets +index.html + +> vp run app#build 2>&1 | grep 'cache hit' # should hit cache from root +~/packages/app$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir +~/packages/app$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> cd packages/app && vp build 2>&1 # direct vp build should not be cached +> cd packages/app && vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache +0 +no cache + +> echo '' > packages/app/index.html +> vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change +~/packages/app$ vp build ○ cache miss: 'packages/app/index.html' modified, executing + +> cd packages/web && vp run build # should build from sub dir first +> ls packages/web/dist # should have the build output +assets +index.html + +> cd packages/web && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir +~/packages/web$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> vp run web#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build +~/packages/web$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json new file mode 100644 index 0000000000..140bd2b6cd --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/steps.json @@ -0,0 +1,25 @@ +{ + "commands": [ + { + "command": "vp run app#build # should build the app from root", + "ignoreOutput": true + }, + "ls packages/app/dist # should have the build output", + "vp run app#build 2>&1 | grep 'cache hit' # should hit cache from root", + "cd packages/app && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", + { + "command": "cd packages/app && vp build 2>&1 # direct vp build should not be cached", + "ignoreOutput": true + }, + "cd packages/app && vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache", + "echo '' > packages/app/index.html", + "vp run app#build 2>&1 | grep 'cache miss' # should miss cache after source change", + { + "command": "cd packages/web && vp run build # should build from sub dir first", + "ignoreOutput": true + }, + "ls packages/web/dist # should have the build output", + "cd packages/web && vp run build 2>&1 | grep 'cache hit' # should hit cache from sub dir", + "vp run web#build 2>&1 | grep 'cache hit' # should hit cache from root after sub dir build" + ] +} diff --git a/packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts b/packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts new file mode 100644 index 0000000000..5f95ceeb78 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache-monorepo/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: true, + }, +}; diff --git a/packages/cli/snap-tests/vp-build-cache/index.html b/packages/cli/snap-tests/vp-build-cache/index.html new file mode 100644 index 0000000000..7febab8c7e --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/index.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/packages/cli/snap-tests/vp-build-cache/package.json b/packages/cli/snap-tests/vp-build-cache/package.json new file mode 100644 index 0000000000..e46476bc41 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/package.json @@ -0,0 +1,7 @@ +{ + "name": "build-cache-test", + "private": true, + "scripts": { + "build": "vp build" + } +} diff --git a/packages/cli/snap-tests/vp-build-cache/snap.txt b/packages/cli/snap-tests/vp-build-cache/snap.txt new file mode 100644 index 0000000000..c3ec8b0fb5 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/snap.txt @@ -0,0 +1,9 @@ +> vp run build # first build +> vp run build 2>&1 | grep 'cache hit' # should hit cache +$ vp build ◉ cache hit, replaying +vp run: cache hit, ms saved. + +> vp build 2>&1 # direct vp build should not be cached +> vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache +0 +no cache diff --git a/packages/cli/snap-tests/vp-build-cache/steps.json b/packages/cli/snap-tests/vp-build-cache/steps.json new file mode 100644 index 0000000000..6c6e68595f --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/steps.json @@ -0,0 +1,14 @@ +{ + "commands": [ + { + "command": "vp run build # first build", + "ignoreOutput": true + }, + "vp run build 2>&1 | grep 'cache hit' # should hit cache", + { + "command": "vp build 2>&1 # direct vp build should not be cached", + "ignoreOutput": true + }, + "vp build 2>&1 | grep -c 'cache' || echo 'no cache' # direct vp build has no cache" + ] +} diff --git a/packages/cli/snap-tests/vp-build-cache/vite.config.ts b/packages/cli/snap-tests/vp-build-cache/vite.config.ts new file mode 100644 index 0000000000..5f95ceeb78 --- /dev/null +++ b/packages/cli/snap-tests/vp-build-cache/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: true, + }, +}; diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/package.json b/packages/cli/snap-tests/vp-pack-cache-disabled/package.json new file mode 100644 index 0000000000..8868be9ef7 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/package.json @@ -0,0 +1,8 @@ +{ + "name": "vp-pack-cache-disabled", + "private": true, + "workspaces": [ + "packages/*" + ], + "packageManager": "pnpm@10.32.1" +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json new file mode 100644 index 0000000000..d487f706fd --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/package.json @@ -0,0 +1,9 @@ +{ + "name": "hello", + "version": "1.0.0", + "type": "module", + "main": "src/index.ts", + "scripts": { + "build": "vp pack" + } +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts new file mode 100644 index 0000000000..b7c0fbaea2 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/hello.ts @@ -0,0 +1,3 @@ +export function hello() { + console.log('Hello tsdown!'); +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts new file mode 100644 index 0000000000..96fc953b72 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/src/index.ts @@ -0,0 +1,3 @@ +import { hello } from './hello.ts'; + +hello(); diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts new file mode 100644 index 0000000000..3f312c1769 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/packages/hello/vite.config.ts @@ -0,0 +1,6 @@ +export default { + pack: { + entry: 'src/index.ts', + format: ['cjs'], + }, +}; diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt b/packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt new file mode 100644 index 0000000000..c20d936c4b --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/snap.txt @@ -0,0 +1,10 @@ +> vp run hello#build # first build +> ls packages/hello/dist # should have the library +index.cjs + +> vp run hello#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit +0 +no cache hit + +> vp run hello#build 2>&1 | grep 'cache disabled' # should show cache disabled +~/packages/hello$ vp pack ⊘ cache disabled diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/steps.json b/packages/cli/snap-tests/vp-pack-cache-disabled/steps.json new file mode 100644 index 0000000000..6c7ba41b32 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/steps.json @@ -0,0 +1,11 @@ +{ + "commands": [ + { + "command": "vp run hello#build # first build", + "ignoreOutput": true + }, + "ls packages/hello/dist # should have the library", + "vp run hello#build 2>&1 | grep -c 'cache hit' || echo 'no cache hit' # cache disabled, no cache hit", + "vp run hello#build 2>&1 | grep 'cache disabled' # should show cache disabled" + ] +} diff --git a/packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts b/packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts new file mode 100644 index 0000000000..de01bdfd87 --- /dev/null +++ b/packages/cli/snap-tests/vp-pack-cache-disabled/vite.config.ts @@ -0,0 +1,5 @@ +export default { + run: { + cache: false, + }, +};