Skip to content

Commit c69a26d

Browse files
branchseerclaude
andauthored
fix: rename inputs/envs to input/env (#225)
This PR standardizes the naming convention for task configuration fields by renaming plural forms to singular forms across the codebase. ## Summary Renamed configuration field names from plural to singular to improve consistency and clarity: - `inputs` → `input` (for file input patterns in cache configuration) - `envs` → `env` (for environment variables in cache configuration) ## Key Changes **Configuration Schema Updates:** - Updated `EnabledCacheConfig` struct fields: `envs: Option<Box<[Str]>>` → `env: Option<Box<[Str]>>` - Updated `EnabledCacheConfig` struct fields: `inputs: Option<UserInputsConfig>` → `input: Option<UserInputsConfig>` - Updated TypeScript type definitions in `run-config.ts` to reflect the new field names - Updated documentation comment for `UserInputEntry` to reference `input` array instead of `inputs` **Code Updates:** - Updated all references throughout the codebase to use the new field names - Updated test cases and test fixtures to use `input` and `env` instead of `inputs` and `envs` - Updated configuration deserialization and serialization logic - Updated default values in `UserTaskOptions::default()` - Updated synthetic task creation in `lib.rs` and `main.rs` **Documentation Updates:** - Updated `task-cache.md` documentation to reference `input` and `env` fields - Updated `wildcard-env-patterns.md` to use `env` terminology - Updated `CLAUDE.md` reference documentation - Updated test snapshot descriptions and comments **Test Fixtures:** - Updated all `vite-task.json` fixture files to use `input` instead of `inputs` - Updated all `vite-task.json` fixture files to use `env` instead of `envs` - Updated test snapshot files and descriptions - Updated e2e test configuration files ## Implementation Details - The change is applied consistently across all configuration layers (user config, resolved config, cache metadata) - All serde deserialization/serialization updated to handle the new field names - Comments and documentation updated to reflect singular naming convention - Test names updated to match the new terminology (e.g., `test_inputs_*` → `test_input_*`) https://claude.ai/code/session_01565Vu5goEjTJjXVVpvaQnb Co-authored-by: Claude <noreply@anthropic.com>
1 parent 34bce5c commit c69a26d

File tree

91 files changed

+125
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+125
-125
lines changed

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ Tasks are defined in `vite-task.json`:
132132
"cwd": "relative/path",
133133
"dependsOn": ["build", "package#task"],
134134
"cache": true,
135-
"envs": ["NODE_ENV"],
135+
"env": ["NODE_ENV"],
136136
"passThroughEnvs": ["CI"],
137-
"inputs": ["src/**", "!dist/**", { "auto": true }]
137+
"input": ["src/**", "!dist/**", { "auto": true }]
138138
}
139139
}
140140
}
@@ -145,9 +145,9 @@ Tasks are defined in `vite-task.json`:
145145
- `cwd`: working directory relative to the package root
146146
- `dependsOn`: explicit task dependencies (`taskName` or `package#task`)
147147
- `cache` (task): enable/disable caching for this task (default: `true`)
148-
- `envs`: env var names to fingerprint and pass to the task
148+
- `env`: env var names to fingerprint and pass to the task
149149
- `passThroughEnvs`: env var names to pass without fingerprinting
150-
- `inputs`: files for cache fingerprinting (globs, `{ "auto": true }`, negation patterns)
150+
- `input`: files for cache fingerprinting (globs, `{ "auto": true }`, negation patterns)
151151

152152
## Task Dependencies
153153

crates/vite_task/docs/task-cache.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The task cache system enables:
1111
- **Content-based hashing**: Cache keys based on actual content, not timestamps
1212
- **Output replay**: Cached stdout/stderr are replayed exactly as originally produced
1313
- **Two-tier caching**: Cache entries shared across tasks, with task-run associations
14-
- **Configurable inputs**: Control which files are tracked for cache invalidation
14+
- **Configurable input**: Control which files are tracked for cache invalidation
1515

1616
### Shared caching
1717

@@ -56,7 +56,7 @@ the task cache system is able to hit the same cache for the `test` task and for
5656
│ ▼ │
5757
│ 2. Cache Key Generation │
5858
│ ────────────────────── │
59-
│ • Spawn fingerprint (cwd, program, args, envs) │
59+
│ • Spawn fingerprint (cwd, program, args, env) │
6060
│ • Input configuration │
6161
│ │ │
6262
│ ▼ │
@@ -131,15 +131,15 @@ This ensures cache invalidation when:
131131

132132
The `fingerprinted_envs` field is crucial for cache correctness:
133133

134-
- Only includes envs explicitly declared in the task's `envs` array
134+
- Only includes env vars explicitly declared in the task's `env` array
135135
- Does NOT include pass-through envs (PATH, CI, etc.)
136-
- These envs become part of the cache key
136+
- These env vars become part of the cache key
137137

138138
When a task runs:
139139

140-
1. All envs (including pass-through) are available to the process
141-
2. Only declared envs affect the cache key
142-
3. If a declared env changes value, cache will miss
140+
1. All env vars (including pass-through) are available to the process
141+
2. Only declared env vars affect the cache key
142+
3. If a declared env var changes value, cache will miss
143143
4. If a pass-through env changes, cache will still hit
144144

145145
The `pass_through_envs` field stores env names (not values) — if the set of pass-through env names changes, the cache invalidates, but value changes don't.
@@ -220,13 +220,13 @@ Vite Task uses `fspy` to monitor file system access during task execution:
220220

221221
### 7. Inputs Configuration
222222

223-
The `inputs` field in `vite-task.json` controls which files are tracked for cache fingerprinting:
223+
The `input` field in `vite-task.json` controls which files are tracked for cache fingerprinting:
224224

225225
```json
226226
{
227227
"tasks": {
228228
"build": {
229-
"inputs": ["src/**", "!dist/**", { "auto": true }]
229+
"input": ["src/**", "!dist/**", { "auto": true }]
230230
}
231231
}
232232
}
@@ -382,7 +382,7 @@ Cache entries are automatically invalidated when:
382382
4. **Pass-through config changes**: Pass-through environment names added/removed from configuration
383383
5. **Input files change**: Content hash differs (detected via xxHash3)
384384
6. **File structure changes**: Files added, removed, or type changed
385-
7. **Input config changes**: The `inputs` configuration itself changes
385+
7. **Input config changes**: The `input` configuration itself changes
386386

387387
## Configuration
388388

@@ -535,13 +535,13 @@ Ensure commands produce identical outputs for identical inputs:
535535
}
536536
```
537537

538-
### 3. Use `inputs` for Precise Cache Control
538+
### 3. Use `input` for Precise Cache Control
539539

540540
```json
541541
{
542542
"tasks": {
543543
"build": {
544-
"inputs": ["src/**", "tsconfig.json", "!src/**/*.test.ts"]
544+
"input": ["src/**", "tsconfig.json", "!src/**/*.test.ts"]
545545
}
546546
}
547547
}

crates/vite_task/docs/wildcard-env-patterns.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Common Wildcard Pattern for Task Envs
1+
# Common Wildcard Pattern for Task Env
22

33
## Executive Summary
44

@@ -13,7 +13,7 @@ Currently, vite-plus requires explicit listing of environment variables in task
1313
"tasks": {
1414
"build": {
1515
"command": "vite build",
16-
"envs": ["NODE_ENV", "NODE_OPTIONS", "VITE_API_URL", "VITE_APP_TITLE", "MY_APP_PORT"]
16+
"env": ["NODE_ENV", "NODE_OPTIONS", "VITE_API_URL", "VITE_APP_TITLE", "MY_APP_PORT"]
1717
}
1818
}
1919
}
@@ -23,7 +23,7 @@ This approach becomes cumbersome when dealing with multiple environment variable
2323

2424
## Goals
2525

26-
1. **Simplify Configuration**: Allow wildcard patterns in the `envs` array to match multiple environment variables
26+
1. **Simplify Configuration**: Allow wildcard patterns in the `env` array to match multiple environment variables
2727
2. **Maintain Cache Correctness**: Ensure wildcard-matched variables are properly included in cache fingerprints
2828
3. **Backward Compatibility**: Support both explicit variable names and wildcard patterns
2929
4. **Performance**: Minimal overhead when resolving environment variables
@@ -32,7 +32,7 @@ This approach becomes cumbersome when dealing with multiple environment variable
3232
## Non-Goals
3333

3434
1. Full regex support (only glob-style wildcards)
35-
2. Wildcard patterns in `pass_through_envs` (same as `envs`)
35+
2. Wildcard patterns in `passThroughEnvs` (same as `env`)
3636
3. Complex glob patterns like `{VITE,NODE}_*` (supported by wax crate)
3737

3838
## Proposed Solution
@@ -63,7 +63,7 @@ We don't support `!` for negated patterns. If match the negated pattern, will ig
6363
```
6464
┌─────────────────┐
6565
│ Task Config │
66-
envs: [ │
66+
env: [ │
6767
│ "NODE_*", │
6868
│ "VITE_*", │
6969
│ "CI" │
@@ -164,7 +164,7 @@ pub struct CommandFingerprint {
164164
"tasks": {
165165
"build": {
166166
"command": "vite build",
167-
"envs": [
167+
"env": [
168168
"NODE_ENV",
169169
"NODE_OPTIONS",
170170
"VITE_API_URL",
@@ -184,7 +184,7 @@ pub struct CommandFingerprint {
184184
"tasks": {
185185
"build": {
186186
"command": "vite build",
187-
"envs": ["NODE_*", "VITE_*"]
187+
"env": ["NODE_*", "VITE_*"]
188188
}
189189
}
190190
}

crates/vite_task/src/session/cache/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn format_cache_status_inline(cache_status: &CacheStatus) -> Option<Str> {
173173
None => "configuration changed",
174174
}
175175
}
176-
FingerprintMismatch::InputConfig => "inputs configuration changed",
176+
FingerprintMismatch::InputConfig => "input configuration changed",
177177
FingerprintMismatch::InputChanged { kind, path } => {
178178
let desc = format_input_change_str(*kind, path.as_str());
179179
return Some(vite_str::format!("✗ cache miss: {desc}, executing"));

crates/vite_task/src/session/cache/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Display for FingerprintMismatch {
119119
write!(f, "Spawn fingerprint changed: old={old:?}, new={new:?}")
120120
}
121121
Self::InputConfig => {
122-
write!(f, "inputs configuration changed")
122+
write!(f, "input configuration changed")
123123
}
124124
Self::InputChanged { kind, path } => {
125125
write!(f, "{}", display::format_input_change_str(*kind, path.as_str()))

crates/vite_task/src/session/reporter/summary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl TaskResult {
439439
}
440440
}
441441
SavedCacheMissReason::ConfigChanged => {
442-
Str::from("→ Cache miss: inputs configuration changed")
442+
Str::from("→ Cache miss: input configuration changed")
443443
}
444444
SavedCacheMissReason::InputChanged { kind, path } => {
445445
let desc = format_input_change_str(*kind, path.as_str());

crates/vite_task_bin/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ fn synthesize_node_modules_bin_task(
6262
program: find_executable(get_path_env(envs), cwd, executable_name)?,
6363
args: args.into(),
6464
cache_config: UserCacheConfig::with_config(EnabledCacheConfig {
65-
envs: None,
65+
env: None,
6666
pass_through_envs: None,
67-
inputs: None,
67+
input: None,
6868
}),
6969
envs: Arc::clone(envs),
7070
})
@@ -127,9 +127,9 @@ impl vite_task::CommandHandler for CommandHandler {
127127
args: [name.clone()].into(),
128128
cache_config: UserCacheConfig::with_config({
129129
EnabledCacheConfig {
130-
envs: None,
130+
env: None,
131131
pass_through_envs: Some(vec![name]),
132-
inputs: None,
132+
input: None,
133133
}
134134
}),
135135
envs: Arc::new(envs),

crates/vite_task_bin/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ async fn run() -> anyhow::Result<ExitStatus> {
3333
args: [Str::from("FOO")].into(),
3434
cache_config: UserCacheConfig::with_config({
3535
EnabledCacheConfig {
36-
envs: Some(Box::from([Str::from("FOO")])),
36+
env: Some(Box::from([Str::from("FOO")])),
3737
pass_through_envs: None,
38-
inputs: None,
38+
input: None,
3939
}
4040
}),
4141
envs: Arc::clone(envs),

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ steps = [
6161
]
6262

6363
[[e2e]]
64-
name = "inputs config changed"
64+
name = "input config changed"
6565
steps = [
6666
"vp run test # cache miss",
67-
"json-edit vite-task.json \"_.tasks.test.inputs = ['test.txt']\" # change inputs config",
67+
"json-edit vite-task.json \"_.tasks.test.input = ['test.txt']\" # change input config",
6868
"vp run test # cache miss: configuration changed",
6969
]
7070

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/inputs config changed.snap renamed to crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots/input config changed.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ expression: e2e_outputs
55
> vp run test # cache miss
66
$ print-file test.txt
77
initial content
8-
> json-edit vite-task.json "_.tasks.test.inputs = ['test.txt']" # change inputs config
8+
> json-edit vite-task.json "_.tasks.test.input = ['test.txt']" # change input config
99

1010
> vp run test # cache miss: configuration changed
11-
$ print-file test.txtcache miss: inputs configuration changed, executing
11+
$ print-file test.txtcache miss: input configuration changed, executing
1212
initial content

0 commit comments

Comments
 (0)