Skip to content

Commit

Permalink
ESlint and Prettier Fixed. Updated Depends
Browse files Browse the repository at this point in the history
  • Loading branch information
wyatt-herkamp committed Oct 10, 2024
1 parent ff9e986 commit daa5272
Show file tree
Hide file tree
Showing 164 changed files with 5,254 additions and 8,571 deletions.
620 changes: 431 additions & 189 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ toml = "0.8"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
tracing-appender = "0.2"
utoipa = { version = "5.0.0-alpha", features = ["chrono", "uuid"] }
utoipa = { version = "5.0.0-rc.0", features = [
"chrono",
"uuid",
"url",
"debug",
] }
rand = "0.8"

nr-core = { path = "crates/core" }
Expand Down Expand Up @@ -47,12 +52,7 @@ derive_builder = "0.20"

# Error Handling
schemars = { git = "https://github.com/wyatt-herkamp/schemars.git", branch = "if_for_adjacent" }
reqwest = { version = "0.12", features = [
"stream",
"http2",
"json",
"rustls-tls",
], default-features = false }

thiserror = "1"
anyhow = "1"
badge-maker = { git = "https://github.com/wyatt-herkamp/badge-maker.git", branch = "updates_and_improvements" }
Expand All @@ -76,7 +76,7 @@ sha2 = "0.10"
sha3 = "0.10"
[workspace.dependencies.sqlx]
version = "0.8"
default_features = false
default-features = false
features = [
"runtime-tokio-rustls",
"macros",
Expand All @@ -87,6 +87,10 @@ features = [
"uuid",
"migrate",
]
[workspace.dependencies.reqwest]
version = "0.12"
features = ["stream", "http2", "json", "rustls-tls"]
default-features = false
[workspace.lints.rust]
async_fn_in_trait = "allow"
deprecated = "deny"
Expand Down
6 changes: 6 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disallowed-types = [
{ path = "std::collections::HashMap", reason = "use ahash::HashMap" },
{ path = "std::collections::HashSet", reason = "use ahash::HashSet" },
{ path = "std::sync::Mutex", reason = "use parking_lot::Mutex" },
{ path = "std::sync::RwLock", reason = "use parking_lot::RwLock" },
]
1 change: 1 addition & 0 deletions crates/core/src/database/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ pub struct DBProjectVersion {
/// The version page. Such as a README
pub version_page: Option<String>,
/// The version data. More data can be added in the future and the data can be repository dependent
#[schema(value_type = VersionData)]
pub extra: Json<VersionData>,
/// When the version was created
pub updated_at: DateTime,
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/database/stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ use super::DateTime;
pub struct DBStage {
pub id: Uuid,
pub repository: Uuid,
#[schema(value_type = crate::utils::utopia::AnyType)]
pub stage_state: Json<Value>,
pub created_by: i32,
pub created_at: DateTime,
}

impl DBStage {
pub async fn get_stage_by_id(
id: Uuid,
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/database/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ pub struct DBStorage {
/// The configuration for the storage
/// This is based on the storage type. It is stored as a JSON object.
/// Requests should be JSON and the response will be JSON. Please refer to the storage type documentation for the configuration.
#[schema(value_type = crate::utils::utopia::AnyType)]
pub config: Json<Value>,
pub active: bool,
pub updated_at: DateTime,
pub created_at: DateTime,
}

impl StorageDBType for DBStorage {
fn columns() -> Vec<&'static str> {
vec![
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/repository/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pub enum RepositoryConfigError {
#[error("Invalid Change: {0}")]
InvalidChange(&'static str, &'static str),
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Digestible)]
#[derive(Default)]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Digestible, Default)]
pub struct ConfigDescription {
pub name: &'static str,
pub description: Option<&'static str>,
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub enum InvalidRepositoryName {
#[error("Repository name contains invalid character `{0}`. Repository Names can only contain letters, numbers, `_`, and `-`")]
InvalidCharacter(char),
}
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Default, Into)]
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Default, Into, ToSchema)]
#[sqlx(transparent)]
#[as_ref(forward)]
pub struct RepositoryName(String);
Expand Down
4 changes: 3 additions & 1 deletion crates/core/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use sqlx::Type;
pub use storage_path::*;
use thiserror::Error;
use tracing::instrument;
use utoipa::ToSchema;

use crate::utils::validations;
#[derive(Debug, Error)]
Expand All @@ -17,9 +18,10 @@ pub enum InvalidStorageName {
#[error("Storage Name contains invalid character `{0}`. Storage Names can only contain letters, numbers, `_`, and `-`")]
InvalidCharacter(char),
}
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Default, Into)]
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Default, Into, ToSchema)]
#[sqlx(transparent)]
pub struct StorageName(String);

impl StorageName {
#[instrument(name = "StorageName::new")]
pub fn new(storage_name: String) -> Result<Self, InvalidStorageName> {
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/storage/storage_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use http::Uri;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use thiserror::Error;
use tracing::instrument;
use utoipa::ToSchema;

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct StoragePathComponent(String);
Expand Down Expand Up @@ -46,8 +47,8 @@ impl AsRef<str> for StoragePathComponent {
}
}
/// A Storage path is a UTF-8 only path. Where the root is the base of the storage.
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
#[derive(Default)]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Default, ToSchema)]
#[schema(value_type = String)]
pub struct StoragePath(Vec<StoragePathComponent>);

impl StoragePath {
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/testing/env_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ impl EnvFile {
let mut key_values = HashMap::new();
for line in file_contents.lines() {
let (key, value) = line.split_once('=').unwrap();



key_values.insert(key.to_string(), value.to_string());
}
Ok(Self { file, key_values })
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use derive_more::derive::{AsRef, Deref, Into};
use sqlx::prelude::Type;
use thiserror::Error;
use tracing::instrument;
use utoipa::ToSchema;
pub mod scopes;
pub mod token;
use crate::utils::validations;
Expand All @@ -18,7 +19,7 @@ pub enum InvalidUsername {
#[error("Username contains invalid character `{0}`. Usernames can only contain letters, numbers, `_`, and `-`")]
InvalidCharacter(char),
}
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Into, Default)]
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Into, Default, ToSchema)]
#[sqlx(transparent)]
#[as_ref(forward)]

Expand Down Expand Up @@ -54,7 +55,7 @@ pub enum InvalidEmail {
#[error("Missing @ symbol in email")]
MissingAt,
}
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Into, Default)]
#[derive(Debug, Type, Deref, AsRef, Clone, PartialEq, Eq, Into, Default, ToSchema)]
#[as_ref(forward)]
#[sqlx(transparent)]

Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod time;
pub mod utopia;
pub mod base64_utils {
use base64::{engine::general_purpose::STANDARD, DecodeError, Engine};
use tracing::instrument;
Expand Down Expand Up @@ -32,7 +33,6 @@ pub mod base64_utils {
{
super::encode(data).serialize(serializer)
}

}
}
pub mod sha256 {
Expand Down
6 changes: 6 additions & 0 deletions crates/core/src/utils/utopia.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use utoipa::ToSchema;

#[derive(Debug, Clone, PartialEq, Eq, ToSchema)]
/// Used to Tell Utopia that the type is not standard. It is a generic JSON object.
pub struct AnyType;
6 changes: 5 additions & 1 deletion crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ proc-macro = true
[dependencies]
quote = "1"
proc-macro2 = "1"
syn = { version = "2", features = ["full", "extra-traits"] }
syn = { version = "2", features = ["full", "extra-traits", "parsing"] }

[dev-dependencies]
prettyplease = "0.2"
anyhow = "1"
49 changes: 49 additions & 0 deletions crates/macros/src/scopes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,52 @@ fn doc_attr_to_string(attr: &Attribute) -> Result<String> {
)),
}
}

#[cfg(test)]
mod tests {
use syn::{Attribute, DeriveInput};

#[test]
fn test() {
let input = r#"
pub enum NRScope {
/// Can read all repositories the user has access to
#[scope(title = "Read Repository", parent = "Repository")]
ReadRepository,
}
"#;

let derive_input = syn::parse_str::<syn::DeriveInput>(input).unwrap();

let result = super::expand(derive_input).unwrap();

let value = result.to_string();
let syn_file = syn::parse_file(&value).unwrap();
let prettyplease = prettyplease::unparse(&syn_file);
println!("{}", prettyplease);
}

#[test]
fn test_attribute() {
let attribute = create_attribute(
r#"
#[scope(title = "Read Repository", parent = "Repository")]
"#,
);
let result = attribute.parse_args::<super::ScopeAttribute>().unwrap();
assert_eq!(result.title.value(), "Read Repository");
assert_eq!(result.parent.unwrap().value(), "Repository");
}

fn create_attribute(attribute: &str) -> Attribute {
let actual_input = format!(
r#"
{attribute}
struct Test;
"#
);
let input = syn::parse_str::<DeriveInput>(&actual_input).unwrap();
let attributes = input.attrs;
attributes[0].clone()
}
}
1 change: 1 addition & 0 deletions crates/storage/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct StorageConfigInner {
pub storage_name: String,
pub storage_id: Uuid,
pub storage_type: String,
#[schema(value_type = chrono::DateTime<chrono::FixedOffset>, format = DateTime)]
pub created_at: ConfigTimeStamp,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/src/fs/file_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{
path::Path,
};
use tracing::{debug, instrument, warn};
use utoipa::ToSchema;
pub static HIDDEN_FILE_EXTENSIONS: &[&str] = &["nr-meta", "nr-repository-meta"];
pub static NITRO_REPO_META_EXTENSION: &str = "nr-meta";
pub static NITRO_REPO_REPOSITORY_META_EXTENSION: &str = "nr-repository-meta";
Expand All @@ -21,7 +22,7 @@ pub fn is_hidden_file(path: &Path) -> bool {
}
}
use crate::utils::{MetadataUtils, PathUtils};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default, ToSchema)]
pub struct FileHashes {
pub md5: Option<String>,
pub sha1: Option<String>,
Expand Down
4 changes: 3 additions & 1 deletion crates/storage/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ pub use file_meta::*;
mod file_reader;
pub use file_reader::*;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[derive(Debug, Clone, From, Into, Deref)]
use utoipa::ToSchema;
#[derive(Debug, Clone, From, Into, Deref, ToSchema)]
#[schema(value_type = String)]
pub struct SerdeMime(pub mime::Mime);

impl Serialize for SerdeMime {
Expand Down
33 changes: 31 additions & 2 deletions crates/storage/src/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,42 @@ use serde::{Deserialize, Serialize};
use tokio::task::JoinSet;
use tracing::{debug, error, info, instrument, trace, warn};
use utils::PathUtils;
use utoipa::ToSchema;

use crate::*;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, ToSchema)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct LocalConfig {
pub path: PathBuf,
}
impl utoipa::__dev::ComposeSchema for LocalConfig {
fn compose(
_generics: Vec<utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>>,
) -> utoipa::openapi::RefOr<utoipa::openapi::schema::Schema> {
utoipa::openapi::ObjectBuilder::new()
.property(
"path",
utoipa::openapi::ObjectBuilder::new().schema_type(
utoipa::openapi::schema::SchemaType::new(utoipa::openapi::schema::Type::String),
),
)
.required("path")
.into()
}
}
impl utoipa::ToSchema for LocalConfig {
fn name() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Borrowed("LocalConfig")
}
}
impl utoipa::__dev::SchemaReferences for LocalConfig {
fn schemas(
schemas: &mut Vec<(
String,
utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>,
)>,
) {
schemas.extend([]);
}
}
#[derive(Debug)]
pub struct LocalStorageInner {
pub config: LocalConfig,
Expand Down
21 changes: 10 additions & 11 deletions nitro_repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ axum-extra = { version = "0.9", features = [
"cookie",
"typed-header",
] }
tower = { version = "0.4", features = ["limit", "timeout"] }
tower-http = { version = "0.5", features = ["full"] }
tower = { version = "0.5", features = ["limit", "timeout"] }
tower-http = { version = "0.6", features = ["full"] }
tower-service = "0.3.2"
hyper.workspace = true
hyper-util.workspace = true
Expand Down Expand Up @@ -73,16 +73,15 @@ semver = { version = "1", features = ["std", "serde"] }
# Staging
tempfile = "3"
# Maven Stuff
maven-rs = { git = "https://github.com/wyatt-herkamp/maven-rs.git"}
maven-rs = { git = "https://github.com/wyatt-herkamp/maven-rs.git" }
zip = { version = "2" }
current_semver = "0.1"
nr-core.workspace = true
nr-macros.workspace = true
nr-storage.workspace = true
redb = { version = "2.1" }
config_types = { git = "https://github.com/wyatt-herkamp/config_types.git", features = [
"regex_types",
"strum",
tuxs-config-types = { git = "https://github.com/wyatt-herkamp/tuxs-config-types.git", features = [
"chrono",
] }
auto_impl.workspace = true
digestible.workspace = true
Expand All @@ -93,11 +92,11 @@ tracing-subscriber.workspace = true
tracing-appender.workspace = true

# OpenTelemetry - Tracing framework
tracing-opentelemetry = "0.25"
opentelemetry = { version = "0.24", features = [] }
opentelemetry_sdk = { version = "0.24", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.17", default-features = true }
lettre = { version = "=0.11.7", features = [
tracing-opentelemetry = "0.27"
opentelemetry = { version = "0.26", features = [] }
opentelemetry_sdk = { version = "0.26", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.26", default-features = true }
lettre = { version = "0.11.9", features = [
"builder",
"tokio1",
"smtp-transport",
Expand Down
Loading

0 comments on commit daa5272

Please sign in to comment.