Skip to content

Commit 9ce14cf

Browse files
branchseerclaude
andauthored
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

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 changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/vite-task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cacheScripts": true,
2+
"cache": true,
33
"tasks": {
44
"no-cache-task": {
55
"command": "print-file test.txt",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/vite-task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cacheScripts": true,
2+
"cache": true,
33
"tasks": {
44
"test": {
55
"command": "print-file test.txt",

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-subcommand/vite-task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cacheScripts": true,
2+
"cache": true,
33
"tasks": {
44
"cached-task": {
55
"command": "print-file test.txt",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"cacheScripts": true
2+
"cache": true
33
}

0 commit comments

Comments
 (0)