mirror of
https://github.com/Xevion/dynamic-preauth.git
synced 2025-12-17 08:11:43 -06:00
refactor: convert to Cargo workspace structure
This commit is contained in:
45
.dockerignore
Normal file
45
.dockerignore
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.github
|
||||||
|
|
||||||
|
# Rust
|
||||||
|
target/
|
||||||
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# Node.js
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
.pnpm-store/
|
||||||
|
|
||||||
|
# Frontend build output
|
||||||
|
frontend/dist/
|
||||||
|
frontend/.next/
|
||||||
|
frontend/out/
|
||||||
|
|
||||||
|
# Environment files
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
|
||||||
|
# CI/CD
|
||||||
|
.github/
|
||||||
|
|
||||||
|
# Other
|
||||||
|
Justfile
|
||||||
|
.dockerignore
|
||||||
18
.github/workflows/quality.yaml
vendored
18
.github/workflows/quality.yaml
vendored
@@ -18,10 +18,7 @@ jobs:
|
|||||||
components: rustfmt
|
components: rustfmt
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt -- --check
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
- name: Check demo formatting
|
|
||||||
run: cargo fmt --manifest-path demo/Cargo.toml -- --check
|
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
@@ -37,10 +34,7 @@ jobs:
|
|||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
run: cargo clippy --all-targets --all-features -- -D warnings
|
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
- name: Run clippy on demo
|
|
||||||
run: cargo clippy --manifest-path demo/Cargo.toml --all-targets --all-features -- -D warnings
|
|
||||||
|
|
||||||
audit:
|
audit:
|
||||||
name: Audit
|
name: Audit
|
||||||
@@ -53,9 +47,6 @@ jobs:
|
|||||||
- name: Run audit
|
- name: Run audit
|
||||||
run: cargo audit
|
run: cargo audit
|
||||||
|
|
||||||
- name: Run audit on demo
|
|
||||||
run: cargo audit --file demo/Cargo.lock
|
|
||||||
|
|
||||||
check:
|
check:
|
||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -68,10 +59,7 @@ jobs:
|
|||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Run check
|
- name: Run check
|
||||||
run: cargo check --all-targets --all-features
|
run: cargo check --workspace --all-targets --all-features
|
||||||
|
|
||||||
- name: Run check on demo
|
|
||||||
run: cargo check --manifest-path demo/Cargo.toml --all-targets --all-features
|
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
name: Frontend
|
name: Frontend
|
||||||
|
|||||||
14
Cargo.lock
generated
14
Cargo.lock
generated
@@ -294,6 +294,18 @@ dependencies = [
|
|||||||
"cipher",
|
"cipher",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "demo"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"hex",
|
||||||
|
"reqwest",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sha2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deranged"
|
name = "deranged"
|
||||||
version = "0.5.5"
|
version = "0.5.5"
|
||||||
@@ -476,6 +488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1536,6 +1549,7 @@ dependencies = [
|
|||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"h2",
|
"h2",
|
||||||
|
|||||||
13
Cargo.toml
13
Cargo.toml
@@ -1,20 +1,25 @@
|
|||||||
[package]
|
[workspace]
|
||||||
name = "dynamic-preauth"
|
resolver = "2"
|
||||||
|
members = ["backend", "demo"]
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[workspace.dependencies]
|
||||||
anyhow = "1.0.95"
|
anyhow = "1.0.95"
|
||||||
chrono = { version = "0.4.39", features = ["serde"] }
|
chrono = { version = "0.4.39", features = ["serde"] }
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
envy = "0.4.2"
|
envy = "0.4.2"
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
|
hex = "0.4.3"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
regex = "1.10"
|
regex = "1.10"
|
||||||
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false }
|
reqwest = { version = "0.12", default-features = false }
|
||||||
salvo = { version = "0.74.3", features = ["affix-state", "catch-panic", "cors", "logging", "serve-static", "test", "websocket"] }
|
salvo = { version = "0.74.3", features = ["affix-state", "catch-panic", "cors", "logging", "serve-static", "test", "websocket"] }
|
||||||
serde = { version = "1.0.216", features = ["derive"] }
|
serde = { version = "1.0.216", features = ["derive"] }
|
||||||
serde_json = "1.0.134"
|
serde_json = "1.0.134"
|
||||||
|
sha2 = "0.10.8"
|
||||||
tokio = { version = "1", features = ["macros"] }
|
tokio = { version = "1", features = ["macros"] }
|
||||||
tokio-stream = "0.1.17"
|
tokio-stream = "0.1.17"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|||||||
28
Dockerfile
28
Dockerfile
@@ -7,9 +7,10 @@ WORKDIR /app
|
|||||||
|
|
||||||
# --- Demo Planner Stage ---
|
# --- Demo Planner Stage ---
|
||||||
FROM chef AS demo-planner
|
FROM chef AS demo-planner
|
||||||
COPY demo/Cargo.toml demo/Cargo.lock* demo/build.rs ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY demo/src ./src
|
COPY backend ./backend
|
||||||
RUN cargo chef prepare --recipe-path recipe.json
|
COPY demo ./demo
|
||||||
|
RUN cargo chef prepare --recipe-path recipe.json --bin demo
|
||||||
|
|
||||||
# --- Demo Builder Stage ---
|
# --- Demo Builder Stage ---
|
||||||
FROM chef AS demo-builder
|
FROM chef AS demo-builder
|
||||||
@@ -24,18 +25,19 @@ RUN rustup target add x86_64-pc-windows-gnu x86_64-unknown-linux-gnu
|
|||||||
|
|
||||||
# Copy recipe and cook dependencies
|
# Copy recipe and cook dependencies
|
||||||
COPY --from=demo-planner /app/recipe.json recipe.json
|
COPY --from=demo-planner /app/recipe.json recipe.json
|
||||||
RUN cargo chef cook --release --target x86_64-unknown-linux-gnu --recipe-path recipe.json
|
RUN cargo chef cook --release --target x86_64-unknown-linux-gnu --recipe-path recipe.json --bin demo
|
||||||
RUN cargo chef cook --release --target x86_64-pc-windows-gnu --recipe-path recipe.json
|
RUN cargo chef cook --release --target x86_64-pc-windows-gnu --recipe-path recipe.json --bin demo
|
||||||
|
|
||||||
# Copy source and build
|
# Copy source and build
|
||||||
COPY demo/Cargo.toml demo/Cargo.lock* demo/build.rs ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY demo/src ./src
|
COPY backend ./backend
|
||||||
|
COPY demo ./demo
|
||||||
|
|
||||||
ARG RAILWAY_PUBLIC_DOMAIN
|
ARG RAILWAY_PUBLIC_DOMAIN
|
||||||
ENV RAILWAY_PUBLIC_DOMAIN=${RAILWAY_PUBLIC_DOMAIN}
|
ENV RAILWAY_PUBLIC_DOMAIN=${RAILWAY_PUBLIC_DOMAIN}
|
||||||
|
|
||||||
RUN cargo build --release --target x86_64-unknown-linux-gnu
|
RUN cargo build --release --target x86_64-unknown-linux-gnu --bin demo
|
||||||
RUN cargo build --release --target x86_64-pc-windows-gnu
|
RUN cargo build --release --target x86_64-pc-windows-gnu --bin demo
|
||||||
|
|
||||||
# Strip binaries
|
# Strip binaries
|
||||||
RUN strip target/x86_64-unknown-linux-gnu/release/demo
|
RUN strip target/x86_64-unknown-linux-gnu/release/demo
|
||||||
@@ -43,7 +45,8 @@ RUN strip target/x86_64-unknown-linux-gnu/release/demo
|
|||||||
# --- Server Planner Stage ---
|
# --- Server Planner Stage ---
|
||||||
FROM chef AS server-planner
|
FROM chef AS server-planner
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY src ./src
|
COPY backend ./backend
|
||||||
|
COPY demo ./demo
|
||||||
RUN cargo chef prepare --recipe-path recipe.json
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
# --- Server Builder Stage ---
|
# --- Server Builder Stage ---
|
||||||
@@ -55,8 +58,9 @@ RUN cargo chef cook --release --recipe-path recipe.json
|
|||||||
|
|
||||||
# Copy source and build
|
# Copy source and build
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
COPY src ./src
|
COPY backend ./backend
|
||||||
RUN cargo build --release
|
COPY demo ./demo
|
||||||
|
RUN cargo build --release --bin dynamic-preauth
|
||||||
|
|
||||||
# Strip binary
|
# Strip binary
|
||||||
RUN strip target/release/dynamic-preauth
|
RUN strip target/release/dynamic-preauth
|
||||||
|
|||||||
23
Justfile
23
Justfile
@@ -7,27 +7,29 @@ port := "5800"
|
|||||||
default:
|
default:
|
||||||
@just --list
|
@just --list
|
||||||
|
|
||||||
# Run all checks (format, clippy, frontend)
|
# Run all checks (matches quality workflow)
|
||||||
check: format-check lint frontend-check
|
check: format-check cargo-check lint audit frontend-check frontend-build
|
||||||
@echo "All checks passed!"
|
@echo "All checks passed!"
|
||||||
|
|
||||||
# Format all Rust code
|
# Format all Rust code
|
||||||
format:
|
format:
|
||||||
@echo "Formatting code..."
|
@echo "Formatting code..."
|
||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
cargo fmt --manifest-path demo/Cargo.toml --all
|
|
||||||
|
|
||||||
# Check formatting without modifying
|
# Check formatting without modifying
|
||||||
format-check:
|
format-check:
|
||||||
@echo "Checking formatting..."
|
@echo "Checking formatting..."
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
cargo fmt --manifest-path demo/Cargo.toml --all -- --check
|
|
||||||
|
# Check code without building
|
||||||
|
cargo-check:
|
||||||
|
@echo "Running cargo check..."
|
||||||
|
cargo check --workspace --all-targets --all-features
|
||||||
|
|
||||||
# Lint with clippy
|
# Lint with clippy
|
||||||
lint:
|
lint:
|
||||||
@echo "Running clippy..."
|
@echo "Running clippy..."
|
||||||
cargo clippy --all-targets --all-features -- -D warnings
|
cargo clippy --workspace --all-targets --all-features -- -D warnings
|
||||||
cargo clippy --manifest-path demo/Cargo.toml --all-targets --all-features -- -D warnings
|
|
||||||
|
|
||||||
# Frontend type check
|
# Frontend type check
|
||||||
frontend-check:
|
frontend-check:
|
||||||
@@ -52,18 +54,12 @@ run:
|
|||||||
# Build release
|
# Build release
|
||||||
build:
|
build:
|
||||||
@echo "Building release..."
|
@echo "Building release..."
|
||||||
cargo build --release
|
cargo build --workspace --release
|
||||||
|
|
||||||
# Build demo executables
|
|
||||||
build-demo:
|
|
||||||
@echo "Building demo executables..."
|
|
||||||
cargo build --manifest-path demo/Cargo.toml --release
|
|
||||||
|
|
||||||
# Security audit
|
# Security audit
|
||||||
audit:
|
audit:
|
||||||
@echo "Running security audit..."
|
@echo "Running security audit..."
|
||||||
cargo audit
|
cargo audit
|
||||||
cargo audit --file demo/Cargo.lock
|
|
||||||
|
|
||||||
# Build Docker image
|
# Build Docker image
|
||||||
docker-build:
|
docker-build:
|
||||||
@@ -98,7 +94,6 @@ docker-clean: docker-stop
|
|||||||
clean:
|
clean:
|
||||||
@echo "Cleaning cargo artifacts..."
|
@echo "Cleaning cargo artifacts..."
|
||||||
cargo clean
|
cargo clean
|
||||||
cargo clean --manifest-path demo/Cargo.toml
|
|
||||||
|
|
||||||
# Full CI pipeline
|
# Full CI pipeline
|
||||||
ci: format-check lint frontend-check build docker-build
|
ci: format-check lint frontend-check build docker-build
|
||||||
|
|||||||
25
backend/Cargo.toml
Normal file
25
backend/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[package]
|
||||||
|
name = "dynamic-preauth"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "dynamic-preauth"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow.workspace = true
|
||||||
|
chrono.workspace = true
|
||||||
|
dotenvy.workspace = true
|
||||||
|
envy.workspace = true
|
||||||
|
futures-util.workspace = true
|
||||||
|
rand.workspace = true
|
||||||
|
regex.workspace = true
|
||||||
|
reqwest = { workspace = true, features = ["json", "rustls-tls"] }
|
||||||
|
salvo.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
tokio.workspace = true
|
||||||
|
tokio-stream.workspace = true
|
||||||
|
tracing.workspace = true
|
||||||
|
tracing-subscriber.workspace = true
|
||||||
1707
demo/Cargo.lock
generated
1707
demo/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,26 +1,19 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "demo"
|
name = "demo"
|
||||||
version = "0.1.0"
|
version.workspace = true
|
||||||
edition = "2021"
|
edition.workspace = true
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hex = "0.4.3"
|
hex.workspace = true
|
||||||
reqwest = { version = "0.12.9", features = ["blocking", "json"] }
|
reqwest = { workspace = true, features = ["blocking", "json"] }
|
||||||
serde = { version = "1.0.216", features = ["derive"] }
|
serde.workspace = true
|
||||||
serde_json = "1.0.134"
|
serde_json.workspace = true
|
||||||
sha2 = "0.10.8"
|
sha2.workspace = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
chrono = "0.4.39"
|
chrono.workspace = true
|
||||||
hex = "0.4.3"
|
hex.workspace = true
|
||||||
serde = { version = "1.0.216", features = ["derive"] }
|
serde.workspace = true
|
||||||
serde_json = "1.0.134"
|
serde_json.workspace = true
|
||||||
sha2 = "0.10.8"
|
sha2.workspace = true
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
strip = true
|
|
||||||
opt-level = "z"
|
|
||||||
lto = true
|
|
||||||
codegen-units = 1
|
|
||||||
panic = "abort"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user