use crate::{config_struct, config_unit_enum};
use moon_common::Id;
use schematic::{Config, ConfigEnum};
config_unit_enum!(
#[derive(ConfigEnum, PartialOrd, Ord)]
pub enum DependencyScope {
Build,
Development,
Peer,
#[default]
Production,
Root,
}
);
config_unit_enum!(
#[derive(ConfigEnum)]
pub enum DependencySource {
#[default]
Explicit,
Implicit,
}
);
config_struct!(
#[derive(Config)]
pub struct ProjectDependencyConfig {
pub id: Id,
pub scope: DependencyScope,
pub source: DependencySource,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub via: Option<String>,
}
);
impl ProjectDependencyConfig {
pub fn new(id: Id) -> Self {
Self {
id,
..Default::default()
}
}
pub fn is_build_scope(&self) -> bool {
matches!(self.scope, DependencyScope::Build)
}
pub fn is_root_scope(&self) -> bool {
matches!(self.scope, DependencyScope::Root)
}
}