Commit 9ce14cf
Refactor cache configuration from cacheScripts to flexible cache option (#191)
## Summary
This PR replaces the simple boolean `cacheScripts` configuration option
with a more flexible `cache` configuration that supports both boolean
and detailed object formats, enabling independent control over caching
for package.json scripts and task entries.
## Key Changes
- **New `UserGlobalCacheConfig` enum**: Replaces `cache_scripts: bool`
with a flexible configuration that accepts:
- `true` / `false` (boolean shorthand)
- `{ scripts?: bool, tasks?: bool }` (detailed configuration)
- **New `ResolvedGlobalCacheConfig` struct**: Provides a resolution
mechanism with sensible defaults:
- `scripts`: defaults to `false`
- `tasks`: defaults to `true`
- **Configuration field rename**: `UserRunConfig.cache_scripts` →
`UserRunConfig.cache`
- **Error message update**:
`TaskGraphLoadError::CacheScriptsInNonRootPackage` →
`TaskGraphLoadError::CacheInNonRootPackage`
- **TypeScript types**: Generated `UserGlobalCacheConfig` type in
`run-config.ts` with comprehensive documentation
- **Test fixtures**: Added two new test fixtures demonstrating the new
configuration:
- `cache-true-no-force-enable`: Shows how `cache: true` with individual
task `cache: false` overrides work
- `cache-tasks-disabled`: Shows how `cache: { tasks: false }` disables
all task caching while respecting individual task settings
- **Test coverage**: Added comprehensive unit tests for all
configuration variants (boolean true/false, detailed with various field
combinations, defaults, and error cases)
- **Migration**: Updated all existing test fixtures from `cacheScripts`
to `cache` format
## Implementation Details
The resolution logic ensures backward compatibility while providing more
granular control:
- When `cache` is omitted, defaults to `{ scripts: false, tasks: true }`
- Boolean `true` expands to `{ scripts: true, tasks: true }`
- Boolean `false` expands to `{ scripts: false, tasks: false }`
- Detailed objects use provided values with appropriate defaults for
missing fields
https://claude.ai/code/session_01AYbt3E5j8Adk9NB7Sprkah
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent b75475f commit 9ce14cf
File tree
62 files changed
+410
-68
lines changed- crates
- vite_task_bin/tests/e2e_snapshots/fixtures
- associate-existing-cache
- builtin-different-cwd
- builtin-non-zero-exit
- cache-disabled
- cache-miss-command-change
- cache-miss-reasons
- cache-subcommand
- colon-in-name
- e2e-env-test
- e2e-lint-cache
- error_cycle_dependency
- exec-api
- exit-codes
- filter-unmatched
- individual-cache-for-adt-args
- individual-cache-for-envs
- lint-dot-git
- replay-logs-chronological-order
- signal-exit
- stdin-inheritance
- stdio-detection
- stdio-graph-criteria
- summary-output
- task-no-trailing-newline
- topological-execution-order
- vite-task-smoke
- vite_task_graph
- src
- config
- vite_task_plan
- src
- tests/plan_snapshots/fixtures
- additional-envs
- cache-keys
- cache-scripts-enabled
- cache-scripts-error-non-root
- packages/pkg-a
- snapshots
- cache-sharing
- cache-subcommand
- cache-tasks-disabled
- snapshots
- cache-true-no-force-enable
- snapshots
- cd-in-scripts
- comprehensive-task-graph
- conflict-test
- dependency-both-topo-and-explicit
- empty-package-test
- explicit-deps-workspace
- filter-workspace
- fingerprint-ignore-test
- nested-tasks
- pnpm-workspace-packages-optional
- recursive-topological-workspace
- shell-fallback
- synthetic-cache-disabled
- snapshots
- synthetic-in-subpackage
- vpr-shorthand
- workspace-root-no-package-json
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
62 files changed
+410
-68
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
0 commit comments