feat: WIP setup actions

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2024-10-24 22:59:27 +02:00
parent dfa70b3485
commit db49af5fa2
16 changed files with 815 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
use crate::plan::{ClonedPlan, Plan};
use crate::project::ProjectPlan;
use crate::state::validated_project::Project;
use crate::state::{self, ValidatedState};
pub struct Start {}
@@ -54,7 +55,7 @@ impl Cuddle<PrepareProject> {
impl Cuddle<PreparePlan> {
pub async fn build_state(&self) -> anyhow::Result<Cuddle<ValidatedState>> {
let state = if let Some(project) = &self.state.project {
let mut state = if let Some(project) = &self.state.project {
let state = state::State::new();
let raw_state = state.build_state(project, &self.state.plan).await?;
@@ -63,6 +64,8 @@ impl Cuddle<PreparePlan> {
ValidatedState::default()
};
state.build_actions().await?;
Ok(Cuddle { state })
}
}
@@ -79,4 +82,13 @@ impl Cuddle<ValidatedState> {
false
}
pub fn project(&self) -> Option<&Project> {
self.state.project.as_ref()
}
pub fn must_project(&self) -> anyhow::Result<&Project> {
self.project()
.ok_or(anyhow::anyhow!("project is not available in this context"))
}
}