//! Publish module
use super::Result;

/// Publish planner for determining release order
pub struct PublishPlanner;

impl PublishPlanner {
    /// Calculate publish order for crates
    pub fn calculate_order(
        workspace: &super::domain::workspace::Workspace,
    ) -> Result<Vec<String>> {
        workspace
            .publish_order()
            .map(|crates| crates.iter().map(|c| c.name().to_string()).collect())
            .map_err(|e| super::Error::Git(e.to_string()))
    }
}
