Skip to content

Commit 6761f92

Browse files
authored
feat: task query (#52)
# Task Query System This PR adds a task query system to Vite, enabling users to run tasks with various filtering options. Key changes include: - Implemented task specifier parsing for both package-qualified (`packageName#taskName`) and simple task names - Created a query system that supports: - Running specific tasks by name - Running tasks with their dependencies (explicit and/or topological) - Running tasks recursively across all packages - Added support for finding nearest topological tasks when a package doesn't contain the requested task - Improved the task graph structure with better indexing for faster lookups - Added comprehensive test coverage for various query scenarios
1 parent 51cbf9c commit 6761f92

34 files changed

+1273
-191
lines changed

Cargo.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ bstr = { version = "1.12.0", default-features = false, features = ["alloc", "std
4646
bumpalo = { version = "3.17.0", features = ["allocator-api2"] }
4747
bytemuck = { version = "1.23.0", features = ["extern_crate_alloc", "must_cast"] }
4848
cc = "1.2.39"
49+
clap = "4.5.53"
4950
color-eyre = "0.6.5"
5051
compact_str = "0.9.0"
5152
const_format = "0.2.34"

crates/vite_path/src/absolute.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ impl Hash for AbsolutePath {
3838
}
3939
}
4040

41+
impl From<&AbsolutePath> for Arc<AbsolutePath> {
42+
fn from(path: &AbsolutePath) -> Self {
43+
let arc: Arc<Path> = path.0.into();
44+
let arc_raw = Arc::into_raw(arc) as *const AbsolutePath;
45+
unsafe { Self::from_raw(arc_raw) }
46+
}
47+
}
48+
4149
impl AbsolutePath {
4250
/// Creates a [`AbsolutePath`] if the give path is absolute.
4351
pub fn new<P: AsRef<Path> + ?Sized>(path: &P) -> Option<&Self> {

crates/vite_task_bin/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "vite_task_bin"
3+
version = "0.1.0"
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
rust-version.workspace = true
8+
9+
[[bin]]
10+
name = "vite"
11+
path = "src/vite.rs"
12+
13+
[dependencies]
14+
clap = { workspace = true, features = ["derive"] }
15+
vite_str = { workspace = true }
16+
vite_task_graph = { path = "../vite_task_graph" }
17+
18+
[lints]
19+
workspace = true

crates/vite_task_bin/src/vite.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use clap::Parser;
2+
use vite_str::Str;
3+
4+
#[derive(Parser)]
5+
enum SubCommand {
6+
/// Run tasks
7+
Run {
8+
#[clap(flatten)]
9+
query: vite_task_graph::query::cli::CLITaskQuery,
10+
11+
/// Additional arguments to pass to the tasks
12+
#[clap(last = true)]
13+
args: Vec<Str>,
14+
},
15+
}
16+
17+
fn main() {
18+
let _subcommand = SubCommand::parse();
19+
}

crates/vite_task_graph/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rust-version.workspace = true
88

99
[dependencies]
1010
anyhow = { workspace = true }
11+
clap = { workspace = true, features = ["derive"] }
1112
monostate = "1.0.2"
1213
petgraph = { workspace = true }
1314
serde = { workspace = true, features = ["derive"] }
@@ -24,6 +25,7 @@ copy_dir = { workspace = true }
2425
insta = { workspace = true, features = ["glob", "json"] }
2526
tempfile = { workspace = true }
2627
tokio = { workspace = true, features = ["fs", "rt-multi-thread"] }
28+
toml = { workspace = true }
2729

2830
[lints]
2931
workspace = true

0 commit comments

Comments
 (0)