|
1 | | -# Vite-Plus |
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## Project Overview |
2 | 4 |
|
3 | 5 | A monorepo task runner (like nx/turbo) with intelligent caching and dependency resolution. |
4 | 6 |
|
5 | | -## Core Concept |
| 7 | +## Build Commands |
6 | 8 |
|
7 | | -**Task Execution**: Run tasks across monorepo packages with automatic dependency ordering. |
| 9 | +```bash |
| 10 | +just init # Install build tools and dependencies |
| 11 | +just ready # Full quality check (fmt, check, test, lint, doc) |
| 12 | +just fmt # Format code (cargo fmt, cargo shear, dprint) |
| 13 | +just check # Check compilation with all features |
| 14 | +just test # Run all tests |
| 15 | +just lint # Clippy linting |
| 16 | +just doc # Documentation generation |
| 17 | +``` |
| 18 | + |
| 19 | +## Tests |
8 | 20 |
|
9 | 21 | ```bash |
10 | | -# Built-in commands |
11 | | -vite build # Run Vite build (dedicated command) |
12 | | -vite test # Run Vite test (dedicated command) |
13 | | -vite lint # Run oxlint (dedicated command) |
14 | | - |
15 | | -# Run tasks across packages (explicit mode) |
16 | | -vite run build -r # recursive with topological ordering |
17 | | -vite run app#build web#build # specific packages |
18 | | -vite run build -r --no-topological # recursive without implicit deps |
19 | | - |
20 | | -# Run task in current package (implicit mode - for non-built-in tasks) |
21 | | -vite dev # runs dev script from package.json |
| 22 | +cargo test # All tests |
| 23 | +cargo test -p vite_task_bin --test e2e_snapshots # E2E snapshot tests |
| 24 | +cargo test -p vite_task_plan --test plan_snapshots # Plan snapshot tests |
| 25 | +cargo test --test e2e_snapshots -- stdin # Filter by test name |
| 26 | +INSTA_UPDATE=always cargo test # Update snapshots |
| 27 | +``` |
| 28 | + |
| 29 | +Integration tests (e2e, plan, fspy) require `pnpm install` in `packages/tools` first. You don't need `pnpm install` in test fixture directories. |
| 30 | + |
| 31 | +Test fixtures and snapshots: |
| 32 | + |
| 33 | +- **Plan**: `crates/vite_task_plan/tests/plan_snapshots/fixtures/` - quicker, sufficient for testing behaviour before actual execution: |
| 34 | + - task graph |
| 35 | + - resolved configurations |
| 36 | + - resolved program paths, cwd, and env vars |
| 37 | +- **E2E**: `crates/vite_task_bin/tests/e2e_snapshots/fixtures/` - needed for testing execution and beyond: caching, output styling |
| 38 | + |
| 39 | +## CLI Usage |
| 40 | + |
| 41 | +```bash |
| 42 | +# Run a task defined in vite.config.json |
| 43 | +vite run <task> # run task in current package |
| 44 | +vite run <package>#<task> # run task in specific package |
| 45 | +vite run <task> -r # run task in all packages (recursive) |
| 46 | +vite run <task> -t # run task in current package + transitive deps |
| 47 | +vite run <task> --extra --args # pass extra args to the task command |
| 48 | + |
| 49 | +# Built-in commands (run tools from node_modules/.bin) |
| 50 | +vite test [args...] # run vitest |
| 51 | +vite lint [args...] # run oxlint |
| 52 | + |
| 53 | +# Flags |
| 54 | +-r, --recursive # run across all packages |
| 55 | +-t, --transitive # run in current package and its dependencies |
| 56 | +--ignore-depends-on # skip explicit dependsOn dependencies |
22 | 57 | ``` |
23 | 58 |
|
24 | 59 | ## Key Architecture |
25 | 60 |
|
26 | | -- **Entry**: `crates/vite_task/src/lib.rs` - CLI parsing and main logic |
27 | | -- **Workspace**: `crates/vite_task/src/config/workspace.rs` - Loads packages, creates task graph |
28 | | -- **Task Graph**: `crates/vite_task/src/config/task_graph_builder.rs` - Builds dependency graph |
29 | | -- **Execution**: `crates/vite_task/src/schedule.rs` - Executes tasks in dependency order |
| 61 | +- **vite_task** - Main task runner with caching and session management |
| 62 | +- **vite_task_bin** - CLI binary (`vite` command) and task synthesizer |
| 63 | +- **vite_task_graph** - Task dependency graph construction and config loading |
| 64 | +- **vite_task_plan** - Execution planning (resolves env vars, working dirs, commands) |
| 65 | +- **vite_workspace** - Workspace detection and package dependency graph |
| 66 | +- **fspy** - File system access tracking for precise cache invalidation |
| 67 | + |
| 68 | +## Task Configuration |
| 69 | + |
| 70 | +Tasks are defined in `vite.config.json`: |
| 71 | + |
| 72 | +```json |
| 73 | +{ |
| 74 | + "tasks": { |
| 75 | + "test": { |
| 76 | + "command": "vitest run", |
| 77 | + "dependsOn": ["build", "lint"], |
| 78 | + "cache": true |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
30 | 83 |
|
31 | 84 | ## Task Dependencies |
32 | 85 |
|
33 | | -1. **Explicit** (always applied): Defined in `vite-task.json` |
34 | | - ```json |
35 | | - { |
36 | | - "tasks": { |
37 | | - "test": { |
38 | | - "command": "jest", |
39 | | - "dependsOn": ["build", "lint"] |
40 | | - } |
41 | | - } |
42 | | - } |
43 | | - ``` |
| 86 | +1. **Explicit**: Defined via `dependsOn` in `vite.config.json` (skip with `--ignore-depends-on`) |
| 87 | +2. **Topological**: Based on package.json dependencies |
| 88 | + - With `-r/--recursive`: runs task across all packages in dependency order |
| 89 | + - With `-t/--transitive`: runs task in current package and its dependencies |
44 | 90 |
|
45 | | -2. **Implicit** (when `--topological`): Based on package.json dependencies |
46 | | - - If A depends on B, then A#build depends on B#build automatically |
| 91 | +## Code Constraints |
47 | 92 |
|
48 | | -## Key Features |
| 93 | +These patterns are enforced by `.clippy.toml`: |
49 | 94 |
|
50 | | -- **Topological Flag**: Controls implicit dependencies from package relationships |
51 | | - - Default: ON for `--recursive`, OFF otherwise |
52 | | - - Toggle with `--no-topological` to disable |
53 | | - |
54 | | -- **Boolean Flags**: All support `--no-*` pattern for explicit disable |
55 | | - - Example: `--recursive` vs `--no-recursive` |
56 | | - - Conflicts handled by clap |
57 | | - - If you want to add a new boolean flag, follow this pattern |
| 95 | +| Instead of | Use | |
| 96 | +| ----------------------------------- | ---------------------------------------- | |
| 97 | +| `HashMap`/`HashSet` | `FxHashMap`/`FxHashSet` from rustc-hash | |
| 98 | +| `std::path::Path`/`PathBuf` | `vite_path::AbsolutePath`/`RelativePath` | |
| 99 | +| `std::format!` | `vite_str::format!` | |
| 100 | +| `String` (for small strings) | `vite_str::Str` | |
| 101 | +| `std::env::current_dir` | `vite_path::current_dir` | |
| 102 | +| `.to_lowercase()`/`.to_uppercase()` | `cow_utils` methods | |
58 | 103 |
|
59 | 104 | ## Path Type System |
60 | 105 |
|
61 | | -- **Type Safety**: All paths use typed `vite_path` instead of `std::path` for better safety |
| 106 | +- **Type Safety**: All paths use typed `vite_path` instead of `std::path` |
62 | 107 | - **Absolute Paths**: `vite_path::AbsolutePath` / `AbsolutePathBuf` |
63 | 108 | - **Relative Paths**: `vite_path::RelativePath` / `RelativePathBuf` |
64 | 109 |
|
65 | 110 | - **Usage Guidelines**: |
66 | | - - Use methods such as `strip_prefix`/`join` provided in `vite_path` for path operations instead of converting to std paths |
67 | | - - Only convert to std paths when interfacing with std library functions, and this should be implicit in most cases thanks to `AsRef<Path>` implementations |
| 111 | + - Use `AbsolutePath` for internal data flow; only convert to `RelativePath` when saving to cache |
| 112 | + - Use methods like `strip_prefix`/`join` from `vite_path` instead of converting to std paths |
| 113 | + - Only convert to std paths when interfacing with std library functions |
68 | 114 | - Add necessary methods in `vite_path` instead of falling back to std path types |
69 | 115 |
|
70 | 116 | ## Quick Reference |
71 | 117 |
|
72 | | -- **Compound Commands**: `"build": "tsc && rollup"` splits into subtasks |
73 | | -- **Task Format**: `package#task` (e.g., `app#build`) |
74 | | -- **Path Types**: Use `vite_path` types instead of `std::path` types for type safety |
75 | | -- **Tests**: Run `cargo test -p vite_task` to verify changes |
76 | | -- **Debug**: Use `--debug` to see cache operations |
77 | | - |
78 | | -## Tests |
79 | | - |
80 | | -- Run `cargo test` to execute all tests |
81 | | -- You never need to run `pnpm install` in the test fixtures dir, vite-plus should able to load and parse the workspace without `pnpm install`. |
| 118 | +- **Task Format**: `package#task` (e.g., `app#build`, `@test/utils#lint`) |
| 119 | +- **Config File**: `vite.config.json` in each package |
0 commit comments