Skip to content
Merged
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
11 changes: 5 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ jobs:
tools: dprint,cargo-shear
components: clippy rust-docs rustfmt

- run: |
dprint check
cargo shear
cargo fmt --check
# cargo clippy --all-targets --all-features -- -D warnings
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
- run: dprint check
- run: cargo shear
- run: cargo fmt --check
# - run: cargo clippy --all-targets --all-features -- -D warnings
- run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items

- uses: crate-ci/typos@85f62a8a84f939ae994ab3763f01a0296d61a7ee # v1.36.2
with:
Expand Down
47 changes: 46 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ passfd = { git = "https://github.com/polachok/passfd", rev = "d55881752c16aced1a
petgraph = "0.8.2"
phf = { version = "0.11.3", features = ["macros"] }
portable-pty = "0.9.0"
pretty_assertions = "1.4.1"
rand = "0.9.1"
ratatui = "0.29.0"
rayon = "1.10.0"
Expand Down Expand Up @@ -116,6 +117,7 @@ toml = "0.9.5"
tracing = "0.1.43"
tracing-error = "0.2.1"
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "serde"] }
ts-rs = { version = "11.1.0" }
tui-term = "0.2.0"
twox-hash = "2.1.1"
uuid = "1.18.1"
Expand Down
2 changes: 2 additions & 0 deletions crates/vite_path/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ diff-struct = { workspace = true }
ref-cast = { workspace = true }
serde = { workspace = true, features = ["derive", "rc"] }
thiserror = { workspace = true }
ts-rs = { workspace = true, optional = true }
vite_str = { workspace = true }

[features]
absolute-redaction = []
ts-rs = ["dep:ts-rs", "vite_str/ts-rs"]

[lints]
workspace = true
Expand Down
32 changes: 32 additions & 0 deletions crates/vite_path/src/relative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,38 @@ pub enum FromPathError {
InvalidPathData(#[from] InvalidPathDataError),
}

#[cfg(feature = "ts-rs")]
mod ts_impl {
use ts_rs::TS;

use super::RelativePathBuf;

impl TS for RelativePathBuf {
type OptionInnerType = Self;
type WithoutGenerics = Self;

fn name() -> String {
"string".to_owned()
}

fn inline() -> String {
"string".to_owned()
}

fn inline_flattened() -> String {
panic!("RelativePathBuf cannot be flattened")
}

fn decl() -> String {
panic!("RelativePathBuf is a primitive type")
}

fn decl_concrete() -> String {
panic!("RelativePathBuf is a primitive type")
}
}
}

#[cfg(test)]
mod tests {

Expand Down
4 changes: 4 additions & 0 deletions crates/vite_str/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ bincode = { workspace = true }
compact_str = { workspace = true, features = ["serde"] }
diff-struct = { workspace = true }
serde = { workspace = true, features = ["derive"] }
ts-rs = { workspace = true, optional = true }

[features]
ts-rs = ["dep:ts-rs"]

[lints]
workspace = true
32 changes: 32 additions & 0 deletions crates/vite_str/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,38 @@ impl PartialEq<str> for Str {
}
}

#[cfg(feature = "ts-rs")]
mod ts_impl {
use ts_rs::TS;

use super::Str;

impl TS for Str {
type OptionInnerType = Self;
type WithoutGenerics = Self;

fn name() -> String {
"string".to_owned()
}

fn inline() -> String {
"string".to_owned()
}

fn inline_flattened() -> String {
panic!("Str cannot be flattened")
}

fn decl() -> String {
panic!("Str is a primitive type")
}

fn decl_concrete() -> String {
panic!("Str is a primitive type")
}
}
}

#[cfg(test)]
mod tests {
use bincode::{config::standard, decode_from_slice, encode_to_vec};
Expand Down
1 change: 0 additions & 1 deletion crates/vite_task_bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ path = "src/main.rs"
anyhow = { workspace = true }
async-trait = { workspace = true }
clap = { workspace = true, features = ["derive"] }
monostate = { workspace = true }
tokio = { workspace = true, features = ["full"] }
vite_path = { workspace = true }
vite_str = { workspace = true }
Expand Down
7 changes: 3 additions & 4 deletions crates/vite_task_bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
};

use clap::Subcommand;
use monostate::MustBe;
use vite_path::AbsolutePath;
use vite_str::Str;
use vite_task::{
Expand Down Expand Up @@ -120,10 +119,10 @@ impl vite_task::TaskSynthesizer<CustomTaskSubcommand> for TaskSynthesizer {
args: [name.clone()].into(),
task_options: UserTaskOptions {
cache_config: UserCacheConfig::Enabled {
cache: MustBe!(true),
cache: None,
enabled_cache_config: EnabledCacheConfig {
envs: Box::new([]),
pass_through_envs: vec![name],
envs: None,
pass_through_envs: Some(vec![name]),
},
},
..Default::default()
Expand Down
5 changes: 5 additions & 0 deletions crates/vite_task_graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ vite_str = { workspace = true }
vite_workspace = { workspace = true }

[dev-dependencies]
pretty_assertions = { workspace = true }
tokio = { workspace = true, features = ["fs", "rt-multi-thread"] }
ts-rs = { workspace = true }
vite_path = { workspace = true, features = ["ts-rs"] }
vite_str = { workspace = true, features = ["ts-rs"] }
which = { workspace = true }

[lints]
workspace = true
22 changes: 12 additions & 10 deletions crates/vite_task_graph/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,23 @@ pub struct ResolvedTaskOptions {
impl ResolvedTaskOptions {
/// Resolves from user-defined options and the directory path where the options are defined.
pub fn resolve(user_options: UserTaskOptions, dir: &Arc<AbsolutePath>) -> Self {
let cwd: Arc<AbsolutePath> = if user_options.cwd_relative_to_package.as_str().is_empty() {
Arc::clone(dir)
} else {
dir.join(user_options.cwd_relative_to_package).into()
let cwd: Arc<AbsolutePath> = match user_options.cwd_relative_to_package {
Some(ref cwd) if !cwd.as_str().is_empty() => dir.join(cwd).into(),
_ => Arc::clone(dir),
};
let cache_config = match user_options.cache_config {
UserCacheConfig::Disabled { cache: MustBe!(false) } => None,
UserCacheConfig::Enabled { cache: MustBe!(true), mut enabled_cache_config } => {
enabled_cache_config
.pass_through_envs
.extend(DEFAULT_PASSTHROUGH_ENVS.iter().copied().map(Str::from));
UserCacheConfig::Enabled { cache: _, enabled_cache_config } => {
let mut pass_through_envs =
enabled_cache_config.pass_through_envs.unwrap_or_default();
pass_through_envs.extend(DEFAULT_PASSTHROUGH_ENVS.iter().copied().map(Str::from));
Some(CacheConfig {
env_config: EnvConfig {
fingerprinted_envs: enabled_cache_config.envs.into_iter().collect(),
pass_through_envs: enabled_cache_config.pass_through_envs.into(),
fingerprinted_envs: enabled_cache_config
.envs
.map(|e| e.into_vec().into_iter().collect())
.unwrap_or_default(),
pass_through_envs: pass_through_envs.into(),
},
})
}
Expand Down
Loading