Skip to content

Commit

Permalink
better organization
Browse files Browse the repository at this point in the history
  • Loading branch information
m1guelpf committed Jul 23, 2024
1 parent 7c86bae commit 41acbad
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ jobs:

- name: Publish Crate
uses: seunlanlege/cargo-auto-publish@2
with:
toml: crates/types/Cargo.toml crates/client/Cargo.toml crates/cli/Cargo.toml crates/server/Cargo/toml
22 changes: 11 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["orbit-cli", "orbit-client", "orbit-core", "orbit-server"]
members = ["crates/*"]

[workspace.package]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions orbit-cli/Cargo.toml → crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ authors.workspace = true
url = "2.5.2"
futures-util = "0.3.30"
tokio = { version = "1.38.1", features = ["full"] }
orbit-types = { version = "0.1.0", path = "../types" }
orbit-client = { version = "0.1.0", path = "../client" }
clap = { version = "4.5.9", features = ["derive", "env"] }
orbit-core = { version = "0.1.0", path = "../orbit-core" }
orbit-client = { version = "0.1.0", path = "../orbit-client" }
6 changes: 4 additions & 2 deletions orbit-cli/src/main.rs → crates/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]

use clap::{Parser, Subcommand};
use futures_util::StreamExt;
use orbit_client::Client;
use orbit_core::{Log, Progress, Stage};
use orbit_types::{Log, Progress, Stage};
use url::Url;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -38,7 +40,7 @@ async fn main() {
}

async fn run_deploy(slug: String, r#ref: Option<String>, client: &Client) {
let stream = client.deploy(&slug, r#ref.as_deref()).await;
let stream = client.deploy(&slug, r#ref.as_deref());

stream
.map(|result| result.unwrap())
Expand Down
2 changes: 1 addition & 1 deletion orbit-client/Cargo.toml → crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ thiserror = "1.0.63"
serde_json = "1.0.120"
async-fn-stream = "0.2.2"
reqwest-eventsource = "0.6.0"
orbit-core = { version = "0.1.0", path = "../orbit-core" }
orbit-types = { version = "0.1.0", path = "../types" }
12 changes: 9 additions & 3 deletions orbit-client/src/lib.rs → crates/client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]

use async_fn_stream::try_fn_stream;
use futures::{stream::StreamExt, Stream};
use orbit_core::{ErrorResponse, Progress};
use orbit_types::{ErrorResponse, Progress};
use reqwest::{Response, StatusCode};
use reqwest_eventsource::{Event, RequestBuilderExt};
use url::Url;
Expand Down Expand Up @@ -29,18 +31,22 @@ pub enum Error {
}

impl Client {
/// Create a new client.
#[must_use]
pub fn new(base_url: Url) -> Self {
Self {
url: base_url,
client: reqwest::Client::new(),
}
}

pub async fn deploy(
/// Deploy a site.
#[allow(clippy::missing_panics_doc)]
pub fn deploy(
&self,
name: &str,
r#ref: Option<&str>,
) -> impl Stream<Item = Result<Result<Progress, orbit_core::Error>, Error>> {
) -> impl Stream<Item = Result<Result<Progress, orbit_types::Error>, Error>> {
let mut stream = self
.client
.post(self.url.join(&format!("/sites/{name}/deploy")).unwrap())
Expand Down
2 changes: 1 addition & 1 deletion orbit-server/Cargo.toml → crates/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ futures-util = "0.3.30"
async-fn-stream = "0.2.2"
uuid = { version = "1.10.0", features = ["v7"] }
tokio = { version = "1.29.1", features = ["full"] }
orbit-types = { version = "0.1.0", path = "../types" }
aide = { version = "0.13.4", features = ["axum", "scalar"] }
axum-jsonschema = { version = "0.8.0", features = ["aide"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
orbit-core = { version = "0.1.0", path = "../orbit-core" }

[build-dependencies]
chrono = "0.4.26"
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions orbit-server/src/deploy.rs → crates/server/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use async_fn_stream::try_fn_stream;
use flate2::read::GzDecoder;
use futures_util::{Stream, TryStreamExt};
use http::header;
use orbit_core::{Log, Progress, Stage};
use orbit_types::{Log, Progress, Stage};
use std::{env, fs, path::PathBuf};
use tokio::process::Command;
use uuid::Uuid;
Expand All @@ -27,7 +27,7 @@ pub enum Error {
Publish(std::io::Error),
}

impl From<Error> for orbit_core::Error {
impl From<Error> for orbit_types::Error {
fn from(value: Error) -> Self {
match value {
Error::Cleanup(_) => Self::Cleanup,
Expand All @@ -39,9 +39,9 @@ impl From<Error> for orbit_core::Error {
}
}

impl From<Error> for orbit_core::ErrorResponse {
impl From<Error> for orbit_types::ErrorResponse {
fn from(value: Error) -> Self {
Self::from(orbit_core::Error::from(value))
Self::from(orbit_types::Error::from(value))
}
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion orbit-server/src/misc.rs → crates/server/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use axum::response::{
};
use futures_util::Stream;
use indexmap::IndexMap;
use orbit_core::Log;
use orbit_types::Log;
use schemars::JsonSchema;
use std::{io, process::Stdio};
use tokio::{
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use axum::{
Extension,
};
use futures_util::{stream::Stream, StreamExt};
use orbit_core::{ErrorResponse, Progress};
use orbit_types::{ErrorResponse, Progress};
use schemars::JsonSchema;
use serde::Deserialize;

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion orbit-core/Cargo.toml → crates/types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
version = "0.1.0"
name = "orbit-core"
name = "orbit-types"
license.workspace = true
edition.workspace = true
authors.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions orbit-core/src/lib.rs → crates/types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]

use serde::{Deserialize, Serialize};

/// A progress update for a deployment.
Expand Down

0 comments on commit 41acbad

Please sign in to comment.