Skip to content

Commit

Permalink
feat: add uuid in the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenLoc committed Jun 18, 2024
1 parent 0acc38a commit 73d5762
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 16 deletions.
15 changes: 15 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ reqwest = { version = "0.12.4", features = ["blocking"] }
anyhow = "1.0.86"
thiserror = "1.0.61"

[dependencies.uuid]
version = "1.8.0"
features = [
"v4",
"fast-rng",
"macro-diagnostics",
"serde"
]

[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
Expand Down
25 changes: 25 additions & 0 deletions src-tauri/src/dep_core/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use serde_derive::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Eq, Hash)]
#[serde(rename_all = "camelCase")]
pub struct FlatDep {
pub uuid: Uuid,
pub org: String,
pub repo: String,
pub package_type: String,
Expand All @@ -15,6 +17,25 @@ impl FlatDep {
pub fn searchable_key(&self) -> String {
self.dep_name.clone()
}

pub fn new(
org: String,
repo: String,
package_type: String,
dep_name: String,
license: String,
current_value: Option<String>,
) -> Self {
Self {
uuid: random_id(),
org,
repo,
package_type,
dep_name,
license,
current_value,
}
}
}

use thiserror::Error;
Expand Down Expand Up @@ -66,3 +87,7 @@ impl From<std::string::String> for DepError {
Self::InvalidGeneric(value.to_string())
}
}

pub fn random_id() -> Uuid {
Uuid::new_v4()
}
16 changes: 8 additions & 8 deletions src-tauri/src/github/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ pub struct GitHubDep {

impl GitHubDep {
pub fn to_flat_dep(&self, org: &str) -> FlatDep {
FlatDep {
org: org.to_string(),
repo: self.repo.to_string(),
package_type: self._type.to_string(),
dep_name: self.name.to_string(),
license: self.license.to_string(),
current_value: Some(self.version.clone()),
}
FlatDep::new(
org.to_string(),
self.repo.to_string(),
self._type.to_string(),
self.name.to_string(),
self.license.to_string(),
Some(self.version.clone()),
)
}
}

Expand Down
17 changes: 9 additions & 8 deletions src-tauri/src/renovate/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ pub fn flatten(root_deps: renovate_representation::Deps) -> Vec<FlatDep> {

for group in groups.iter() {
for dep in group.deps.clone() {
let flat = FlatDep {
org: org.clone(),
repo: repo_name.clone(),
package_type: current_package_type.clone(),
dep_name: dep.dep_name,
license: "unknown".to_string(),
current_value: dep.current_value,
};
let flat = FlatDep::new(
org.clone(),
repo_name.clone(),
current_package_type.clone(),
dep.dep_name,
"unknown".to_string(),
dep.current_value,
);

deps.push(flat)
}
}
Expand Down

0 comments on commit 73d5762

Please sign in to comment.