governor_application/
ports.rs1use async_trait::async_trait;
4use governor_core::domain::changelog::Changelog;
5use governor_core::domain::version::SemanticVersion;
6use governor_owners::{PackageOwnersConfig, WorkspaceOwnersConfig};
7use serde::{Deserialize, Serialize};
8use std::path::{Path, PathBuf};
9
10use crate::error::ApplicationResult;
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct ReleaseWorkspace {
15 pub root: PathBuf,
17 pub name: String,
19 pub current_version: SemanticVersion,
21 pub packages: Vec<ReleasePackage>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ReleasePackage {
28 pub name: String,
30 pub version: SemanticVersion,
32 pub manifest_path: PathBuf,
34 pub dependencies: Vec<String>,
36 pub publish: bool,
38}
39
40#[derive(Debug, Clone)]
42pub struct OwnersWorkspace {
43 pub root: PathBuf,
45 pub workspace: Option<WorkspaceOwnersConfig>,
47 pub packages: Vec<OwnerPackage>,
49}
50
51#[derive(Debug, Clone)]
53pub struct OwnerPackage {
54 pub name: String,
56 pub owners: Option<PackageOwnersConfig>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct VersionUpdate {
63 pub modified_files: Vec<String>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct ChangelogUpdate {
70 pub updated: bool,
72 pub modified_files: Vec<String>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct CommandReport {
79 pub name: String,
81 pub success: bool,
83 pub exit_code: Option<i32>,
85 pub stdout: String,
87 pub stderr: String,
89}
90
91#[async_trait]
93pub trait WorkspacePort: Send + Sync {
94 fn name(&self) -> &str;
96
97 async fn load_release_workspace(
99 &self,
100 workspace_path: &Path,
101 ) -> ApplicationResult<ReleaseWorkspace>;
102
103 async fn load_owners_workspace(
105 &self,
106 workspace_path: &Path,
107 ) -> ApplicationResult<OwnersWorkspace>;
108
109 async fn update_workspace_version(
111 &self,
112 workspace_path: &Path,
113 version: &SemanticVersion,
114 dry_run: bool,
115 ) -> ApplicationResult<VersionUpdate>;
116
117 async fn update_changelog(
119 &self,
120 workspace_path: &Path,
121 changelog: &Changelog,
122 dry_run: bool,
123 ) -> ApplicationResult<ChangelogUpdate>;
124}
125
126#[async_trait]
128pub trait CommandPort: Send + Sync {
129 fn name(&self) -> &str;
131
132 async fn run_check(
134 &self,
135 workspace_path: &Path,
136 check: &str,
137 capture_output: bool,
138 ) -> ApplicationResult<CommandReport>;
139}