use std::path::{Path, PathBuf};
use crate::config::DeploymentTarget;
use crate::error::DeploymentError;
#[derive(Debug)]
pub struct ProjectInfo {
pub name: String,
pub root_dir: PathBuf,
pub target: DeploymentTarget,
pub has_cargo_toml: bool,
pub has_dockerfile: bool,
pub has_mise_toml: bool,
pub config_file: PathBuf,
}
pub struct ProjectScanner;
impl ProjectScanner {
pub fn scan(root: &Path) -> Result<ProjectInfo, DeploymentError> {
let target =
DeploymentTarget::detect(root).ok_or_else(|| DeploymentError::NoProviderDetected {
project_dir: root.display().to_string(),
})?;
let name = root.file_name().map_or_else(
|| "unknown".to_string(),
|n| n.to_string_lossy().into_owned(),
);
Ok(ProjectInfo {
name,
root_dir: root.to_path_buf(),
target,
has_cargo_toml: root.join("Cargo.toml").exists(),
has_dockerfile: root.join("Dockerfile").exists(),
has_mise_toml: root.join("mise.toml").exists(),
config_file: root.join(target.config_file()),
})
}
}