diff --git a/Cargo.lock b/Cargo.lock index 5170ee8..02d725e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,6 +362,7 @@ dependencies = [ "serde_json", "serde_yaml", "tokio", + "toml", "tracing", ] @@ -1475,6 +1476,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1743,6 +1753,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -2180,6 +2224,15 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +[[package]] +name = "winnow" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/crates/cuddle-ci/src/lib.rs b/crates/cuddle-ci/src/lib.rs index a41176c..8b763da 100644 --- a/crates/cuddle-ci/src/lib.rs +++ b/crates/cuddle-ci/src/lib.rs @@ -7,41 +7,9 @@ pub mod rust_lib; pub mod rust_service; pub mod cuddle_file; -pub mod rust_workspace { - use serde::Deserialize; - - #[derive(Deserialize, Clone, Debug)] - pub struct Workspace { - pub members: Vec, - } - - #[derive(Deserialize, Clone, Debug)] - pub struct File { - pub workspace: Option, - } - - impl File { - pub async fn read_file() -> eyre::Result> { - let file = match tokio::fs::read_to_string("Cargo.toml").await { - Ok(file) => file, - Err(e) => { - tracing::warn!("Cargo.toml was not found: {}", e); - return Ok(None); - } - }; - - let workspace_file: File = toml::from_str(&file)?; - - Ok(Some(workspace_file)) - } - - pub fn get_workspace_members(&self) -> Option> { - self.workspace.as_ref().map(|w| w.members.clone()) - } - } -} pub mod cuddle_please; pub mod cuddle_releaser; pub mod cuddle_x; pub mod dagger_middleware; pub mod drone_templater; +pub mod rust_workspace; diff --git a/crates/cuddle-ci/src/rust_workspace.rs b/crates/cuddle-ci/src/rust_workspace.rs new file mode 100644 index 0000000..0b1b8c2 --- /dev/null +++ b/crates/cuddle-ci/src/rust_workspace.rs @@ -0,0 +1,31 @@ +use serde::Deserialize; + +#[derive(Deserialize, Clone, Debug)] +pub struct Workspace { + pub members: Vec, +} + +#[derive(Deserialize, Clone, Debug)] +pub struct File { + pub workspace: Option, +} + +impl File { + pub async fn read_file() -> eyre::Result> { + let file = match tokio::fs::read_to_string("Cargo.toml").await { + Ok(file) => file, + Err(e) => { + tracing::warn!("Cargo.toml was not found: {}", e); + return Ok(None); + } + }; + + let workspace_file: File = toml::from_str(&file)?; + + Ok(Some(workspace_file)) + } + + pub fn get_workspace_members(&self) -> Option> { + self.workspace.as_ref().map(|w| w.members.clone()) + } +}