standarbuild-detect 0.2.0

Detect project kind (Rust, Node, Bun, Deno, Python, Lua, C/C++) and scan polyglot monorepo workspaces
Documentation

Detect the kind of a project (Rust, Node, Bun, Deno, Python, Lua, C, C++, or any custom kind you register) from on-disk signals (Cargo.toml, package.json, …) and scan a polyglot monorepo workspace recursively.

Two ways in

For the common case where the built-in kinds are enough:

use std::path::Path;
use standarbuild_detect::{detect_in_dir, discover, DiscoverOptions, KindId};

if let Some(m) = detect_in_dir(Path::new("./my-app")) {
    println!("{} matched on {:?}", m.kind, m.signals);
}

for p in discover(Path::new("./my-monorepo"), &DiscoverOptions::default()) {
    println!("{} -> {} at {}", p.label, p.kind, p.rel_path);
}

To extend the detection space (custom kinds, custom precedence, or disabling a built-in), build your own registry:

use std::path::Path;
use standarbuild_detect::{
    builtin, DetectMatch, Detector, DetectorRegistry, KindId,
};

struct WgslDetector;
impl Detector for WgslDetector {
    fn kind(&self) -> KindId { KindId::custom("wgsl") }
    fn priority(&self) -> i32 { 60 }
    fn detect(&self, dir: &Path) -> Option<DetectMatch> {
        dir.join("shaders").is_dir().then(|| DetectMatch {
            kind: KindId::custom("wgsl"),
            signals: vec!["shaders/".into()],
        })
    }
}

let mut registry = DetectorRegistry::with_builtins();
registry.remove(&KindId::C); // we don't care about plain C
registry.add(WgslDetector);

Features

  • serde (default) — derives Serialize/Deserialize on the public types and exposes POSIX-path serializers in [path_norm]. Disable with default-features = false for the leanest dep tree.