Skip to content

Commit fd5f4e7

Browse files
authored
Merge pull request #179 from Tuntii/chore/zero-dependencies
chore: remove async-trait, base64, smallvec, thiserror (zero-dependencies pass)
2 parents 5f12738 + 45eff6a commit fd5f4e7

38 files changed

Lines changed: 881 additions & 538 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ serde_json = "1.0"
4646
tower-service = "0.3"
4747

4848
# Utilities
49-
thiserror = "2.0"
5049
tracing = "0.1"
5150
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
5251
futures-util = "0.3"

crates/cargo-rustapi/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ indicatif = { workspace = true }
2424
console = { workspace = true }
2525

2626
# File system
27-
walkdir = "2.5"
2827
toml_edit = "0.22"
29-
notify = "8.0"
30-
notify-debouncer-mini = "0.7"
28+
notify = { version = "8.0", optional = true }
29+
notify-debouncer-mini = { version = "0.7", optional = true }
3130

3231
# Async
3332
tokio = { workspace = true, features = ["process", "fs", "macros", "rt-multi-thread", "time", "signal", "sync"] }
@@ -42,7 +41,6 @@ toml = "1.1"
4241
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false, optional = true }
4342

4443
# Utilities
45-
thiserror = { workspace = true }
4644
tracing = { workspace = true }
4745
tracing-subscriber = { workspace = true }
4846
anyhow = "1.0"
@@ -54,5 +52,6 @@ predicates = "3.1"
5452

5553
[features]
5654
default = ["remote-spec", "replay"]
55+
native-watch = ["dep:notify", "dep:notify-debouncer-mini"]
5756
remote-spec = ["dep:reqwest"]
5857
replay = ["dep:reqwest"]

crates/cargo-rustapi/src/commands/doctor.rs

Lines changed: 70 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use console::{style, Emoji};
66
use std::fs;
77
use std::path::{Path, PathBuf};
88
use tokio::process::Command;
9-
use walkdir::WalkDir;
109

1110
#[derive(Args, Debug, Clone)]
1211
pub struct DoctorArgs {
@@ -382,61 +381,86 @@ fn build_project_checks(workspace_root: &Path) -> Result<Vec<DoctorCheck>> {
382381
fn scan_workspace_signals(workspace_root: &Path) -> Result<WorkspaceSignals> {
383382
let mut signals = WorkspaceSignals::default();
384383

385-
for entry in WalkDir::new(workspace_root)
386-
.into_iter()
387-
.filter_entry(|entry| should_scan(entry.path()))
388-
{
384+
scan_workspace_dir(workspace_root, &mut signals)?;
385+
386+
Ok(signals)
387+
}
388+
389+
fn scan_workspace_dir(dir: &Path, signals: &mut WorkspaceSignals) -> Result<()> {
390+
if !should_scan(dir) {
391+
return Ok(());
392+
}
393+
394+
for entry in fs::read_dir(dir).with_context(|| format!("failed to read {}", dir.display()))? {
389395
let entry = entry?;
390-
if !entry.file_type().is_file() || !is_scannable_file(entry.path()) {
396+
let path = entry.path();
397+
398+
if !should_scan(&path) {
399+
continue;
400+
}
401+
402+
let file_type = match entry.file_type() {
403+
Ok(file_type) => file_type,
404+
Err(_) => continue,
405+
};
406+
407+
if file_type.is_dir() {
408+
scan_workspace_dir(&path, signals)?;
391409
continue;
392410
}
393411

394-
let contents = match fs::read_to_string(entry.path()) {
412+
if !file_type.is_file() || !is_scannable_file(&path) {
413+
continue;
414+
}
415+
416+
let contents = match fs::read_to_string(&path) {
395417
Ok(contents) => contents,
396418
Err(_) => continue,
397419
};
398420

399-
signals.production_defaults |= contains_any(
400-
&contents,
401-
&[".production_defaults(", ".production_defaults_with_config("],
402-
);
403-
signals.health_endpoints |= contains_any(
404-
&contents,
405-
&[
406-
".health_endpoints(",
407-
".health_endpoint_config(",
408-
"HealthEndpointConfig",
409-
],
410-
);
411-
signals.health_checks |= contents.contains(".with_health_check(");
412-
signals.request_id |= contents.contains("RequestIdLayer");
413-
signals.tracing |= contains_any(&contents, &["TracingLayer", "tracing_subscriber"]);
414-
signals.shutdown |= contents.contains("run_with_shutdown(");
415-
signals.shutdown_hooks |= contents.contains(".on_shutdown(");
416-
signals.structured_logging |= contains_any(
417-
&contents,
418-
&["StructuredLoggingLayer", "structured_logging("],
419-
);
420-
signals.otel |= contains_any(&contents, &["OtelLayer", "otel("]);
421-
signals.rate_limit |= contains_any(&contents, &["RateLimitLayer", "rate_limit("]);
422-
signals.security_headers |=
423-
contains_any(&contents, &["SecurityHeadersLayer", "security_headers("]);
424-
signals.timeout |= contains_any(&contents, &["TimeoutLayer", "timeout("]);
425-
signals.cors |= contains_any(&contents, &["CorsLayer", "cors("]);
426-
signals.body_limit |= contains_any(&contents, &["BodyLimitLayer", ".body_limit("]);
427-
signals.env_production |= contains_any(
428-
&contents,
429-
&[
430-
"RUSTAPI_ENV=production",
431-
"RUSTAPI_ENV: production",
432-
"RUSTAPI_ENV = \"production\"",
433-
"RUSTAPI_ENV','production",
434-
"RUSTAPI_ENV\", \"production\"",
435-
],
436-
);
421+
apply_workspace_signals(signals, &contents);
437422
}
438423

439-
Ok(signals)
424+
Ok(())
425+
}
426+
427+
fn apply_workspace_signals(signals: &mut WorkspaceSignals, contents: &str) {
428+
signals.production_defaults |= contains_any(
429+
contents,
430+
&[".production_defaults(", ".production_defaults_with_config("],
431+
);
432+
signals.health_endpoints |= contains_any(
433+
contents,
434+
&[
435+
".health_endpoints(",
436+
".health_endpoint_config(",
437+
"HealthEndpointConfig",
438+
],
439+
);
440+
signals.health_checks |= contents.contains(".with_health_check(");
441+
signals.request_id |= contents.contains("RequestIdLayer");
442+
signals.tracing |= contains_any(contents, &["TracingLayer", "tracing_subscriber"]);
443+
signals.shutdown |= contents.contains("run_with_shutdown(");
444+
signals.shutdown_hooks |= contents.contains(".on_shutdown(");
445+
signals.structured_logging |=
446+
contains_any(contents, &["StructuredLoggingLayer", "structured_logging("]);
447+
signals.otel |= contains_any(contents, &["OtelLayer", "otel("]);
448+
signals.rate_limit |= contains_any(contents, &["RateLimitLayer", "rate_limit("]);
449+
signals.security_headers |=
450+
contains_any(contents, &["SecurityHeadersLayer", "security_headers("]);
451+
signals.timeout |= contains_any(contents, &["TimeoutLayer", "timeout("]);
452+
signals.cors |= contains_any(contents, &["CorsLayer", "cors("]);
453+
signals.body_limit |= contains_any(contents, &["BodyLimitLayer", ".body_limit("]);
454+
signals.env_production |= contains_any(
455+
contents,
456+
&[
457+
"RUSTAPI_ENV=production",
458+
"RUSTAPI_ENV: production",
459+
"RUSTAPI_ENV = \"production\"",
460+
"RUSTAPI_ENV','production",
461+
"RUSTAPI_ENV\", \"production\"",
462+
],
463+
);
440464
}
441465

442466
fn find_workspace_root(start: &Path) -> Option<PathBuf> {

0 commit comments

Comments
 (0)