standarbuild-detect 0.3.0

Detect project kind (Rust, Node, Bun, Deno, Python, Lua, C/C++) AND workspace kind (Cargo, Npm/Pnpm/Yarn/Bun, Deno, Go, Lerna, Nx, Turborepo, Mira) in polyglot monorepos
Documentation

Detect the kind of a project (Rust, Node, Bun, Deno, Python, Lua, C, C++, or any custom kind you register) AND the workspace organizer (Cargo, Npm, Pnpm, Yarn, Bun, Deno, Go, Lerna, Nx, Turborepo, Mira) from on-disk signals, and scan a polyglot monorepo recursively.

Two ways in

For the common case where the built-ins are enough:

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

for hit in detect_in_dir(Path::new("./my-app")) {
    println!("{:?}", hit);
}

let result = discover(Path::new("./my-monorepo"), &DiscoverOptions::default());
for p in &result.projects {
    println!("{} -> {} at {} (member_of {:?})", p.label, p.kind, p.rel_path, p.member_of);
}
for w in &result.workspaces {
    println!("{} workspace at {:?} with {} members", w.kind, w.root, w.members.len());
}

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, Detector, DetectorHit, DetectorRegistry, KindId,
};

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

let mut registry = DetectorRegistry::with_builtins();
registry.remove("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.

Breaking changes vs 0.2

  • Detector::kind() -> KindId was replaced by Detector::name() -> &str (string identifier for registry removal). Each detector decides what facet(s) to emit via its DetectorHit return.
  • Detector::detect() -> Option<DetectMatch> is now Option<DetectorHit>. DetectMatch is gone; DetectorHit carries project + workspace info.
  • DetectorRegistry::detect(dir) returns Vec<DetectorHit> (previously Option<DetectMatch>) so multiple facets at the same dir (e.g. Cargo workspace + npm workspace) can all surface.
  • discover() / discover_with() return DetectionResult { projects, workspaces } instead of Vec<Discovered>. Discovered was renamed to ProjectInfo and gained member_of: Vec<PathBuf>.
  • DetectorRegistry::remove now takes &str (detector name) instead of &KindId, and returns the count of removed detectors instead of a bool.