#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
use serde::{Deserialize, Serialize};
pub enum Progress {
Log(Log),
Stage(Stage),
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "type", content = "log")]
pub enum Log {
Info(String),
Error(String),
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Stage {
Starting,
Downloaded,
DepsInstalled,
Migrated,
Optimized,
Deployed,
}
#[derive(Debug, thiserror::Error, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Error {
#[error("Failed to bootstrap the project.")]
Bootstrap,
#[error("Failed to clone the repository.")]
Download,
#[error("Failed to extract the repository contents.")]
Extraction,
#[error("Failed to configure the deployment.")]
Configure,
#[error("Failed to install dependencies.")]
InstallDeps,
#[error("Failed to run defined commands.")]
RunCommands,
#[error("Failed to optimize the deployment.")]
Optimize,
#[error("Failed to cleanup old deployments.")]
Cleanup,
#[error("Failed to publish the new deployment.")]
Publish,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ErrorResponse {
pub error: Error,
pub message: String,
}
impl From<Error> for ErrorResponse {
fn from(error: Error) -> Self {
Self {
message: error.to_string(),
error,
}
}
}
impl From<Stage> for Progress {
fn from(value: Stage) -> Self {
Self::Stage(value)
}
}