callisto_graph/locate/
mod.rs1use std::path::PathBuf;
2
3use callisto_model::{DeclaredEdge, ProjectRoot};
4
5pub mod git;
6pub mod ignore_walk;
7pub mod root;
8
9pub use git::probe_git;
10pub use ignore_walk::IgnoreWalkLocator;
11pub use root::find_workspace_root;
12
13pub trait ProjectLocator: Send + Sync {
14 fn projects(&self) -> Result<Vec<ProjectRoot>, LocateError>;
15 fn declared_edges(&self) -> Option<Vec<DeclaredEdge>> {
16 None
17 }
18}
19
20#[derive(Clone, Debug, thiserror::Error, miette::Diagnostic, PartialEq, Eq)]
21#[non_exhaustive]
22pub enum LocateError {
23 #[error("workspace root not found starting from `{start}`")]
24 #[diagnostic(code(E030), help("Ensure callisto.toml exists in workspace root."))]
25 WorkspaceRootNotFound { start: PathBuf },
26
27 #[error("failed to walk filesystem under `{path}`: {message}")]
28 #[diagnostic(code(E031))]
29 Walk { path: PathBuf, message: String },
30
31 #[error("project path `{path}` is outside the workspace root `{root}`")]
32 #[diagnostic(code(E032))]
33 OutsideWorkspaceRoot { path: PathBuf, root: PathBuf },
34
35 #[error("moon CLI is unavailable or exited non-zero")]
36 MoonUnavailable,
37
38 #[error("Failed to parse moon project-graph output: {message}")]
39 MoonOutputParse { message: String },
40
41 #[error("Incompatible moon version found: {found}, required: {required}")]
42 IncompatibleMoonVersion { found: String, required: String },
43
44 #[error(transparent)]
45 Graph(#[from] Box<crate::error::GraphError>),
46}