Skip to content

Commit bc12aef

Browse files
fengmk2claude
andauthored
fix(cache): forward cache command to local CLI and update cache path (#427)
- Add 'cache' to LOCAL_CLI_COMMANDS in global CLI to forward to local CLI - Change task cache path from `.vite-plus` to `node_modules/.vite/task-cache` - Update cache-clean snap test to use `vite fmt` instead of `echo hello` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 26bb5e4 commit bc12aef

5 files changed

Lines changed: 21 additions & 23 deletions

File tree

packages/cli/binding/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ async fn handle_cache_command(
578578
) -> Result<ExitStatus, Error> {
579579
// Get cache path - need to find workspace root first
580580
let (workspace_root, _) = vite_workspace::find_workspace_root(&cwd)?;
581-
let cache_path = workspace_root.path.join(".vite-plus");
581+
let cache_path = workspace_root.path.join("node_modules/.vite/task-cache");
582582

583583
match subcmd {
584584
CacheSubcommand::Clean => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"scripts": {
3-
"hello": "echo hello"
3+
"hello": "vite fmt"
44
}
55
}
Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,69 @@
11
> vite run hello # create the cache for 'echo hello'
2-
$ echo hello ⊘ cache disabled: built-in command
3-
hello
2+
$ vite fmt
43

54

65
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
76
Vite+ Task Runner • Execution Summary
87
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
98

10-
Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled
9+
Statistics: 1 tasks • 0 cache hits • 1 cache misses
1110
Performance: 0% cache hit rate
1211

1312
Task Details:
1413
────────────────────────────────────────────────
15-
[1] hello: $ echo hello
16-
→ Cache disabled for built-in command
14+
[1] hello: $ vite fmt
15+
→ Cache miss: no previous cache entry found
1716
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1817

1918
> vite run hello # hit the cache
20-
$ echo hello ⊘ cache disabled: built-in command
21-
hello
19+
$ vite fmt ✓ cache hit, replaying
2220

2321

2422
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2523
Vite+ Task Runner • Execution Summary
2624
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2725

28-
Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled
29-
Performance: 0% cache hit rate
26+
Statistics: 1 tasks • 1 cache hits • 0 cache misses
27+
Performance: 100% cache hit rate, <variable>ms saved in total
3028

3129
Task Details:
3230
────────────────────────────────────────────────
33-
[1] hello: $ echo hello
34-
→ Cache disabled for built-in command
31+
[1] hello: $ vite fmt
32+
→ Cache hit - output replayed - <variable>ms saved
3533
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3634

3735
> vite cache clean # clean the cache
3836
> vite run hello # cache miss after clean
39-
$ echo hello ⊘ cache disabled: built-in command
40-
hello
37+
$ vite fmt
4138

4239

4340
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4441
Vite+ Task Runner • Execution Summary
4542
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4643

47-
Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled
44+
Statistics: 1 tasks • 0 cache hits • 1 cache misses
4845
Performance: 0% cache hit rate
4946

5047
Task Details:
5148
────────────────────────────────────────────────
52-
[1] hello: $ echo hello
53-
→ Cache disabled for built-in command
49+
[1] hello: $ vite fmt
50+
→ Cache miss: no previous cache entry found
5451
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
5552

5653
> cd subfolder && vite cache clean # cache can be located and cleaned from subfolder
5754
> vite run hello # cache miss after clean
58-
$ echo hello ⊘ cache disabled: built-in command
59-
hello
55+
$ vite fmt
6056

6157

6258
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6359
Vite+ Task Runner • Execution Summary
6460
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6561

66-
Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled
62+
Statistics: 1 tasks • 0 cache hits • 1 cache misses
6763
Performance: 0% cache hit rate
6864

6965
Task Details:
7066
────────────────────────────────────────────────
71-
[1] hello: $ echo hello
72-
→ Cache disabled for built-in command
67+
[1] hello: $ vite fmt
68+
→ Cache miss: no previous cache entry found
7369
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const hello = 'world';

packages/global/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const LOCAL_CLI_COMMANDS = [
1212
'doc',
1313
'run',
1414
'preview',
15+
'cache',
1516
];
1617

1718
const command = args[0];

0 commit comments

Comments
 (0)