diff --git a/CHANGELOG.md b/CHANGELOG.md index 90fa2668..a6bd6c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +- **Fixed** `vp run --cache` now supports running without a task specifier and opens the interactive task selector, matching bare `vp run` behavior ([#312](https://github.com/voidzero-dev/vite-task/pull/313)) - **Added** object form for `input` entries: `{ "pattern": "...", "base": "workspace" | "package" }` to resolve glob patterns relative to the workspace root instead of the package directory ([#295](https://github.com/voidzero-dev/vite-task/pull/295)) - **Fixed** arguments after the task name being consumed by `vp` instead of passed through to the task ([#286](https://github.com/voidzero-dev/vite-task/pull/286), [#290](https://github.com/voidzero-dev/vite-task/pull/290)) - **Changed** default untracked env patterns to align with Turborepo, covering more CI and platform-specific variables ([#262](https://github.com/voidzero-dev/vite-task/pull/262)) diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index add1633a..3207a190 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -294,7 +294,12 @@ impl<'a> Session<'a> { let bare = RunCommand::try_parse_from::<_, &str>([]) .expect("parsing hardcoded bare command should never fail") .into_resolved(); - if run_command != bare { + + // Normalize the run_command for comparison by ignoring cache flags, which don't affect task selection. + let mut normalized_run_command = run_command.clone(); + normalized_run_command.flags.cache = false; + + if normalized_run_command != bare { return Err(vite_task_plan::Error::MissingTaskSpecifier.into()); } let qpr = self.handle_no_task(is_interactive, &run_command).await?; diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/package.json new file mode 100644 index 00000000..49b99b3b --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/package.json @@ -0,0 +1,4 @@ +{ + "name": "cache-task-select-test", + "private": true +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/snapshots.toml new file mode 100644 index 00000000..f2daacc4 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/snapshots.toml @@ -0,0 +1,20 @@ +[[e2e]] +name = "cache hit with interactive selector and --cache" +steps = [ + { argv = [ + "vt", + "run", + "--cache", + ], interactions = [ + { "expect-milestone" = "task-select::0" }, + { "write-key" = "enter" }, + ] }, + { argv = [ + "vt", + "run", + "--cache", + ], interactions = [ + { "expect-milestone" = "task-select::0" }, + { "write-key" = "enter" }, + ] }, +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/snapshots/cache hit with interactive selector and --cache.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/snapshots/cache hit with interactive selector and --cache.snap new file mode 100644 index 00000000..2b22f3c3 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/snapshots/cache hit with interactive selector and --cache.snap @@ -0,0 +1,28 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +assertion_line: 441 +expression: e2e_outputs +--- +> vt run --cache +@ expect-milestone: task-select::0 +Select a task (↑/↓, Enter to run, type to search): + + › build vtt print-file src/main.ts + lint echo lint app +@ write-key: enter +Selected task: build +$ vtt print-file src/main.ts +export const main = 'initial'; +> vt run --cache +@ expect-milestone: task-select::0 +Select a task (↑/↓, Enter to run, type to search): + + › build vtt print-file src/main.ts + lint echo lint app +@ write-key: enter +Selected task: build +$ vtt print-file src/main.ts ◉ cache hit, replaying +export const main = 'initial'; + +--- +vt run: cache hit. diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/src/main.ts b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/src/main.ts new file mode 100644 index 00000000..38e000a1 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/src/main.ts @@ -0,0 +1 @@ +export const main = 'initial'; diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/vite-task.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/vite-task.json new file mode 100644 index 00000000..322e22bc --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-task-select/vite-task.json @@ -0,0 +1,11 @@ +{ + "tasks": { + "build": { + "command": "vtt print-file src/main.ts", + "cache": true + }, + "lint": { + "command": "echo lint app" + } + } +} diff --git a/docs/cache-eviction.md b/docs/cache-eviction.md new file mode 100644 index 00000000..b263fe5d --- /dev/null +++ b/docs/cache-eviction.md @@ -0,0 +1,35 @@ +# Cache Eviction + +Available scoped cache eviction through `cache clear`: + +```bash +vp cache clear +vp cache clear --task +vp cache clear --package +``` + +Examples: + +```bash +vp cache clear +vp cache clear --task build +vp cache clear --package @my/abc +``` + +## Semantics + +- `vp cache clear`: evict all cache entries. +- `vp cache clear --task build`: evict entries for task name `build` across workspace. +- `vp cache clear --package @my/abc`: evict entries for package `@my/abc` across all tasks. + +Matching is exact (no wildcard/regex in this RFC). + +## CLI constraints + +- `--task` and `--package` are mutually exclusive. +- No flag means full clear. + +## Output + +- Success message includes cleared count. +- Non-zero exit only on invalid args or storage errors.