From 460ece2a9bc4a43ffebfb14b3637c4e8455358d2 Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Sat, 5 Oct 2024 18:13:38 +0900 Subject: [PATCH] refac: split into workspace --- .gitignore | 2 +- Cargo.lock | 15 +++++++++- Cargo.toml | 30 ++----------------- README.md | 2 +- crates/json_http/Cargo.toml | 20 +++++++++++++ {src => crates/json_http/src}/main.rs | 0 .../json_http/src}/route/collate_strings.rs | 0 .../json_http/src}/route/frontmatter_file.rs | 0 .../json_http/src}/route/frontmatter_list.rs | 0 {src => crates/json_http/src}/route/mod.rs | 0 crates/lib/Cargo.toml | 20 +++++++++++++ {src => crates/lib/src}/collate.rs | 0 {src => crates/lib/src}/frontmatter_file.rs | 0 .../lib/src}/frontmatter_file/keeper.rs | 0 {src => crates/lib/src}/frontmatter_query.rs | 0 {src => crates/lib/src}/fs.rs | 0 {src => crates/lib/src}/lib.rs | 0 {src => crates/lib/src}/list.rs | 0 {src => crates/lib/src}/markup.rs | 0 {src => crates/lib/src}/single.rs | 0 20 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 crates/json_http/Cargo.toml rename {src => crates/json_http/src}/main.rs (100%) rename {src => crates/json_http/src}/route/collate_strings.rs (100%) rename {src => crates/json_http/src}/route/frontmatter_file.rs (100%) rename {src => crates/json_http/src}/route/frontmatter_list.rs (100%) rename {src => crates/json_http/src}/route/mod.rs (100%) create mode 100644 crates/lib/Cargo.toml rename {src => crates/lib/src}/collate.rs (100%) rename {src => crates/lib/src}/frontmatter_file.rs (100%) rename {src => crates/lib/src}/frontmatter_file/keeper.rs (100%) rename {src => crates/lib/src}/frontmatter_query.rs (100%) rename {src => crates/lib/src}/fs.rs (100%) rename {src => crates/lib/src}/lib.rs (100%) rename {src => crates/lib/src}/list.rs (100%) rename {src => crates/lib/src}/markup.rs (100%) rename {src => crates/lib/src}/single.rs (100%) diff --git a/.gitignore b/.gitignore index 17bf9b0..91f7b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /target -tests/markdown_files +crates/json_http/tests/markdown_files/ diff --git a/Cargo.lock b/Cargo.lock index 54d2705..43018ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,6 +205,20 @@ dependencies = [ "anyhow", "axum", "camino", + "custard_lib", + "notify", + "pretty_assertions", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "custard_lib" +version = "0.1.0" +dependencies = [ + "anyhow", + "camino", "chrono", "notify", "pretty_assertions", @@ -212,7 +226,6 @@ dependencies = [ "serde_json", "serde_yaml", "thiserror", - "tokio", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e3fcf6a..a848b85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,3 @@ -[package] -name = "custard" -version = "0.3.1" -edition = "2021" -license = "MIT" -description = "A frontmatter-querying server" -repository = "https://github.com/Teajey/custard" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -name = "custard_lib" - -[dependencies] -anyhow = "1.0.75" -axum = "0.6.20" -camino = "1.1.6" -chrono = { version = "0.4.31", features = ["serde"] } -notify = "5.2.0" -serde = { version = "1.0.188", features = ["serde_derive"] } -serde_json = "1.0.107" -serde_yaml = "0.9.25" -thiserror = "1.0.49" -tokio = { version = "1.32.0", features = ["full"] } - -[dev-dependencies] -pretty_assertions = "1.4.0" +[workspace] +resolver = "2" +members = ["crates/*"] diff --git a/README.md b/README.md index 2040d67..d88144d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -Serves plain-text files from a given directory using basic HTTP. More complex queries can be made for files that contain a Markdown-style frontmatter! +Serves plain-text files from a given directory. More complex queries can be made for files that contain a Markdown-style frontmatter! Inspired by [Obsidian](https://obsidian.md/), I wanted to make a service to host markdown for my website in a similar manner :^) diff --git a/crates/json_http/Cargo.toml b/crates/json_http/Cargo.toml new file mode 100644 index 0000000..4c393dc --- /dev/null +++ b/crates/json_http/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "custard" +version = "0.3.1" +edition = "2021" +license = "MIT" +description = "A frontmatter-querying server" +repository = "https://github.com/Teajey/custard" + +[dependencies] +anyhow = "1.0.75" +camino = "1.1.6" +axum = "0.6.20" +custard_lib = { version = "0.1.0", path = "../lib" } +notify = "5.2.0" +serde = { version = "1.0.188", features = ["serde_derive"] } +serde_json = "1.0.107" +tokio = { version = "1.32.0", features = ["full"] } + +[dev-dependencies] +pretty_assertions = "1.4.0" diff --git a/src/main.rs b/crates/json_http/src/main.rs similarity index 100% rename from src/main.rs rename to crates/json_http/src/main.rs diff --git a/src/route/collate_strings.rs b/crates/json_http/src/route/collate_strings.rs similarity index 100% rename from src/route/collate_strings.rs rename to crates/json_http/src/route/collate_strings.rs diff --git a/src/route/frontmatter_file.rs b/crates/json_http/src/route/frontmatter_file.rs similarity index 100% rename from src/route/frontmatter_file.rs rename to crates/json_http/src/route/frontmatter_file.rs diff --git a/src/route/frontmatter_list.rs b/crates/json_http/src/route/frontmatter_list.rs similarity index 100% rename from src/route/frontmatter_list.rs rename to crates/json_http/src/route/frontmatter_list.rs diff --git a/src/route/mod.rs b/crates/json_http/src/route/mod.rs similarity index 100% rename from src/route/mod.rs rename to crates/json_http/src/route/mod.rs diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml new file mode 100644 index 0000000..53742fd --- /dev/null +++ b/crates/lib/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "custard_lib" +version = "0.1.0" +edition = "2021" +license = "MIT" +description = "A core library for Custard" +repository = "https://github.com/Teajey/custard" + +[dependencies] +anyhow = "1.0.75" +camino = "1.1.6" +chrono = { version = "0.4.31", features = ["serde"] } +notify = "5.2.0" +serde = { version = "1.0.188", features = ["serde_derive"] } +serde_json = "1.0.107" +serde_yaml = "0.9.25" +thiserror = "1.0.49" + +[dev-dependencies] +pretty_assertions = "1.4.0" diff --git a/src/collate.rs b/crates/lib/src/collate.rs similarity index 100% rename from src/collate.rs rename to crates/lib/src/collate.rs diff --git a/src/frontmatter_file.rs b/crates/lib/src/frontmatter_file.rs similarity index 100% rename from src/frontmatter_file.rs rename to crates/lib/src/frontmatter_file.rs diff --git a/src/frontmatter_file/keeper.rs b/crates/lib/src/frontmatter_file/keeper.rs similarity index 100% rename from src/frontmatter_file/keeper.rs rename to crates/lib/src/frontmatter_file/keeper.rs diff --git a/src/frontmatter_query.rs b/crates/lib/src/frontmatter_query.rs similarity index 100% rename from src/frontmatter_query.rs rename to crates/lib/src/frontmatter_query.rs diff --git a/src/fs.rs b/crates/lib/src/fs.rs similarity index 100% rename from src/fs.rs rename to crates/lib/src/fs.rs diff --git a/src/lib.rs b/crates/lib/src/lib.rs similarity index 100% rename from src/lib.rs rename to crates/lib/src/lib.rs diff --git a/src/list.rs b/crates/lib/src/list.rs similarity index 100% rename from src/list.rs rename to crates/lib/src/list.rs diff --git a/src/markup.rs b/crates/lib/src/markup.rs similarity index 100% rename from src/markup.rs rename to crates/lib/src/markup.rs diff --git a/src/single.rs b/crates/lib/src/single.rs similarity index 100% rename from src/single.rs rename to crates/lib/src/single.rs