diff --git a/Justfile b/Justfile index 0640993..e30e1f9 100644 --- a/Justfile +++ b/Justfile @@ -1,3 +1,7 @@ +# Justfile for dynamic-preauth +# Uses bacon for Rust watching, pnpm for frontend +# Frontend builds to ./public, which backend serves as static files + # Variables image_name := "dynamic-preauth" container_name := "dynamic-preauth-dev" @@ -41,15 +45,26 @@ frontend-build: @echo "Building frontend..." pnpm --dir frontend build -# Development server with hot reload -dev: - @echo "Starting development server..." - cargo watch -x run --bin backend +# Development server with hot reload (backend + ensures frontend is built) +dev: frontend-build + @echo "Starting backend development server with bacon..." + @echo "Frontend is served from ./public (built from frontend/)" + bacon run + +# Watch backend only (for when frontend is already built) +dev-backend: + @echo "Starting backend watch with bacon..." + bacon run + +# Watch and serve frontend only +dev-frontend: + @echo "Starting frontend dev server..." + pnpm --dir frontend dev # Simple development run (no hot reload) run: @echo "Starting server..." - cargo run --bin backend + cargo run --bin dynamic-preauth # Build release build: @@ -61,8 +76,8 @@ audit: @echo "Running security audit..." cargo audit -# Build Docker image -docker-build: +# Build Docker image (ensures frontend is built first) +docker-build: frontend-build @echo "Building Docker image..." docker build -t {{image_name}}:latest . @@ -99,6 +114,8 @@ clean: ci: format-check lint frontend-check build docker-build @echo "CI pipeline completed!" -# Quick development check -quick: format lint +# Quick development check (format + clippy) +quick: format + @echo "Running quick clippy check..." + cargo clippy --workspace --all-targets --all-features -- -D warnings @echo "Quick check completed!" diff --git a/backend/src/state.rs b/backend/src/state.rs index 79eb0db..cd3a389 100644 --- a/backend/src/state.rs +++ b/backend/src/state.rs @@ -42,12 +42,8 @@ impl State { .unwrap_or_default() .to_string(); - let key_start = - Executable::search_pattern(&data, pattern.as_bytes(), 0).ok_or_else(|| { - AppError::KeyPatternNotFound { - name: name.clone(), - } - })?; + let key_start = Executable::search_pattern(&data, pattern.as_bytes(), 0) + .ok_or_else(|| AppError::KeyPatternNotFound { name: name.clone() })?; let key_end = key_start + pattern.len(); let extension = path diff --git a/bacon.toml b/bacon.toml new file mode 100644 index 0000000..0776870 --- /dev/null +++ b/bacon.toml @@ -0,0 +1,36 @@ +# Bacon configuration for dynamic-preauth + +default_job = "check" + +[jobs.check] +command = ["cargo", "check", "--workspace", "--all-targets", "--all-features", "--color", "always"] +need_stdout = false + +[jobs.clippy] +command = ["cargo", "clippy", "--workspace", "--all-targets", "--all-features", "--color", "always", "--", "-D", "warnings"] +need_stdout = false + +[jobs.test] +command = ["cargo", "test", "--workspace", "--color", "always"] +need_stdout = true + +[jobs.run] +command = ["cargo", "run", "--bin", "dynamic-preauth", "--color", "always"] +need_stdout = true +on_success = "back" + +[jobs.doc] +command = ["cargo", "doc", "--workspace", "--all-features", "--no-deps", "--color", "always"] +need_stdout = false + +[keybindings] +# Use 'c' to switch to check job +c = "job:check" +# Use 'l' to switch to clippy job +l = "job:clippy" +# Use 't' to switch to test job +t = "job:test" +# Use 'r' to switch to run job +r = "job:run" +# Use 'd' to switch to doc job +d = "job:doc" diff --git a/frontend/astro.config.mjs b/frontend/astro.config.mjs index 21de429..8a7b3c6 100644 --- a/frontend/astro.config.mjs +++ b/frontend/astro.config.mjs @@ -20,6 +20,7 @@ if ( // https://astro.build/config export default defineConfig({ + outDir: "../public", build: { assets: "assets", },