Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/vite_task_plan/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub enum Error {
#[error(transparent)]
TaskRecursionDetected(#[from] TaskRecursionError),

#[error("Invalid vite task command: {program} with args {args:?} under cwd {cwd:?}")]
#[error("Invalid vite task command: {program} with args {args:?} under cwd \"{cwd}\"")]
ParsePlanRequest {
program: Str,
args: Arc<[Str]>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test-workspace",
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@test/app",
"version": "1.0.0",
"scripts": {
"build": "echo 'Building @test/app'"
},
"dependencies": {
"@test/utils": "workspace:*"
},
"devDependencies": {
"@test/core": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@test/core",
"version": "1.0.0",
"scripts": {
"build": "echo 'Building @test/core'"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@test/utils",
"version": "1.0.0",
"scripts": {
"build": "echo 'Building @test/utils'"
},
"dependencies": {
"@test/core": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- 'packages/*'
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Tests --direct / -d flag: select direct dependencies only (one hop).
# Topology: app → utils (dependency), app → core (devDependency), utils → core
# Both dependency types are traversed.

# -d from app: should select utils (dep) and core (devDep), NOT app itself.
[[plan]]
compact = true
name = "dependencies from app"
args = ["run", "-d", "build"]
cwd = "packages/app"

# -d from utils: should select core only (direct dep), NOT utils itself.
[[plan]]
compact = true
name = "dependencies from utils"
args = ["run", "-d", "build"]
cwd = "packages/utils"

# -d from core: core has no deps, so no packages selected.
[[plan]]
compact = true
name = "dependencies from leaf package"
args = ["run", "-d", "build"]
cwd = "packages/core"

# Contrast with -t from app: should select app, utils, AND core (full transitive).
[[plan]]
compact = true
name = "transitive from app for comparison"
args = ["run", "-t", "build"]
cwd = "packages/app"

# -d with package specifier: direct deps of @test/app.
[[plan]]
compact = true
name = "dependencies with package specifier"
args = ["run", "-d", "@test/app#build"]

# -d with --workspace-root: direct deps of the workspace root package.
[[plan]]
compact = true
name = "dependencies with workspace root"
args = ["run", "-d", "-w", "build"]

# Error: -d and -r conflict.
[[plan]]
compact = true
name = "direct with recursive conflict"
args = ["run", "-d", "-r", "build"]

# Error: -d and -t conflict.
[[plan]]
compact = true
name = "direct with transitive conflict"
args = ["run", "-d", "-t", "build"]

# Error: -d and --filter conflict.
[[plan]]
compact = true
name = "direct with filter conflict"
args = ["run", "-d", "--filter", "@test/app", "build"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-d"
- build
cwd: packages/app
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
{
"packages/core#build": [],
"packages/utils#build": [
"packages/core#build"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-d"
- build
cwd: packages/core
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-d"
- build
cwd: packages/utils
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
{
"packages/core#build": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-d"
- "@test/app#build"
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
{
"packages/core#build": [],
"packages/utils#build": [
"packages/core#build"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-d"
- "-w"
- build
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: err_str.as_ref()
info:
args:
- run
- "-d"
- "--filter"
- "@test/app"
- build
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
Invalid vite task command: vt with args [] under cwd "<workspace>/": --filter and --direct cannot be used together
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: err
info:
args:
- run
- "-d"
- "-r"
- build
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
error: the argument '--direct' cannot be used with '--recursive'

Usage: vt run --direct <TASK_SPECIFIER> <ADDITIONAL_ARGS>...

For more information, try '--help'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: err
info:
args:
- run
- "-d"
- "-t"
- build
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
error: the argument '--direct' cannot be used with '--transitive'

Usage: vt run --direct <TASK_SPECIFIER> <ADDITIONAL_ARGS>...

For more information, try '--help'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: "&compact_plan"
info:
args:
- run
- "-t"
- build
cwd: packages/app
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
{
"packages/app#build": [
"packages/core#build",
"packages/utils#build"
],
"packages/core#build": [],
"packages/utils#build": [
"packages/core#build"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
source: crates/vite_task_plan/tests/plan_snapshots/main.rs
expression: task_graph_json
input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/direct-dependencies
---
[
{
"key": [
"<workspace>/packages/app",
"build"
],
"node": {
"task_display": {
"package_name": "@test/app",
"task_name": "build",
"package_path": "<workspace>/packages/app"
},
"resolved_config": {
"command": "echo 'Building @test/app'",
"resolved_options": {
"cwd": "<workspace>/packages/app",
"cache_config": {
"env_config": {
"fingerprinted_envs": [],
"untracked_env": [
"<default untracked envs>"
]
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
}
}
}
},
"source": "PackageJsonScript"
},
"neighbors": []
},
{
"key": [
"<workspace>/packages/core",
"build"
],
"node": {
"task_display": {
"package_name": "@test/core",
"task_name": "build",
"package_path": "<workspace>/packages/core"
},
"resolved_config": {
"command": "echo 'Building @test/core'",
"resolved_options": {
"cwd": "<workspace>/packages/core",
"cache_config": {
"env_config": {
"fingerprinted_envs": [],
"untracked_env": [
"<default untracked envs>"
]
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
}
}
}
},
"source": "PackageJsonScript"
},
"neighbors": []
},
{
"key": [
"<workspace>/packages/utils",
"build"
],
"node": {
"task_display": {
"package_name": "@test/utils",
"task_name": "build",
"package_path": "<workspace>/packages/utils"
},
"resolved_config": {
"command": "echo 'Building @test/utils'",
"resolved_options": {
"cwd": "<workspace>/packages/utils",
"cache_config": {
"env_config": {
"fingerprinted_envs": [],
"untracked_env": [
"<default untracked envs>"
]
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
}
}
}
},
"source": "PackageJsonScript"
},
"neighbors": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,18 @@ cwd = "packages/middle"
compact = true
name = "transitive with package specifier lacking task"
args = ["run", "-t", "@test/middle#build"]

# -d from top: direct deps are {middle}. middle lacks build → empty.
# Unlike -t which walks transitively through middle to find bottom.
[[plan]]
compact = true
name = "direct from top stops at direct deps"
args = ["run", "-d", "build"]
cwd = "packages/top"

# -d from middle: direct dep is {bottom}. bottom has build → bottom#build.
[[plan]]
compact = true
name = "direct from middle finds direct dep"
args = ["run", "-d", "build"]
cwd = "packages/middle"
Loading
Loading