diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..5e3c2db --- /dev/null +++ b/.air.toml @@ -0,0 +1,26 @@ +root = "." +tmp_dir = "tmp" + +[build] + cmd = "go build -o ./tmp/main ./cmd/server/main.go" + bin = "./tmp/main" + full_bin = "" + include_ext = ["go", "tpl", "tmpl", "html"] + exclude_dir = ["data", "full_db_backups", "internal/web/dist", "web", "assets", "tmp", "vendor", "node_modules"] + include_dir = [] + exclude_file = [] + delay = 1000 # ms + stop_on_error = true + log = "air_errors.log" + +[log] + time = true + +[color] + main = "magenta" + watcher = "cyan" + build = "yellow" + runner = "green" + +[misc] + clean_on_exit = true diff --git a/dev.sh b/dev.sh new file mode 100755 index 0000000..21ec88c --- /dev/null +++ b/dev.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# Scriberr Development Environment Script +# This script starts both the Go backend (with Air live reload) and the React frontend (with Vite HMR) concurrently. + +set -e + +# --- Helper Functions --- + +cleanup() { + echo "" + echo "🛑 Stopping development servers..." + kill $(jobs -p) 2>/dev/null || true + echo "✅ Stopped." + exit 0 +} + +# Trap signals for cleanup +trap cleanup SIGINT SIGTERM + +# --- Step 1: Ensure Air is installed --- + +if ! command -v air &> /dev/null; then + echo "⚠️ 'air' command not found." + echo "📦 Auto-installing 'air' for live reload..." + + # Check if GOPATH/bin is in PATH + GOPATH=$(go env GOPATH) + if [[ ":$PATH:" != *":$GOPATH/bin:"* ]]; then + echo "⚠️ $GOPATH/bin is not in your PATH. Adding it temporarily..." + export PATH=$PATH:$GOPATH/bin + fi + + go install github.com/air-verse/air@latest + + if ! command -v air &> /dev/null; then + echo "❌ Failed to install 'air'. Please install it manually: go install github.com/air-verse/air@latest" + echo "🔄 Falling back to 'go run' (no live reload for backend)..." + USE_GO_RUN=true + else + echo "✅ 'air' installed successfully." + USE_GO_RUN=false + fi +else + USE_GO_RUN=false +fi + +# --- Step 2: Ensure Embed Directory Exists & is Populated --- + +DIST_DIR="internal/web/dist" +if [ ! -d "$DIST_DIR" ]; then + echo "📁 Creating placeholder dist directory for Go embed..." + mkdir -p "$DIST_DIR" +fi + +# Go's embed directive requires at least one file to match "dist/*" +# If the directory is empty, create a dummy file to prevent compilation errors. +if [ -z "$(ls -A $DIST_DIR)" ]; then + echo "📄 Creating dummy index.html to satisfy embed directive..." + echo "" > "$DIST_DIR/index.html" + # Also add a dummy asset to satisfy the static routes if needed + echo "placeholder" > "$DIST_DIR/dummy_asset" +fi + +# --- Step 3: Start Servers --- + +echo "🚀 Starting development environment..." + +# Start Backend +if [ "$USE_GO_RUN" = true ]; then + echo "🔧 Starting Go backend (standard run)..." + go run cmd/server/main.go & +else + echo "🔥 Starting Go backend (with Air live reload)..." + air & +fi + +# Start Frontend +echo "⚛️ Starting React frontend (Vite)..." +cd web/frontend +npm run dev & + +# Wait for all background processes +wait diff --git a/web/frontend/src/components/ScriberrLogo.tsx b/web/frontend/src/components/ScriberrLogo.tsx index af48871..71fcbdc 100644 --- a/web/frontend/src/components/ScriberrLogo.tsx +++ b/web/frontend/src/components/ScriberrLogo.tsx @@ -25,10 +25,8 @@ export function ScriberrLogo({ className = "", onClick }: { className?: string; } }} > - - - {/* Text Logo - Temporarily hidden */} - + + ) } diff --git a/web/frontend/src/index.css b/web/frontend/src/index.css index c65e020..b40f041 100644 --- a/web/frontend/src/index.css +++ b/web/frontend/src/index.css @@ -118,7 +118,8 @@ :root { /* --- BRAND IDENTITY --- */ /* Extracted from your logo */ - --brand-gradient: linear-gradient(135deg, #FFAB40 0%, #FF3D00 100%); + /* --brand-gradient: linear-gradient(135deg, #FFAB40 0%, #FF3D00 100%); */ + --brand-gradient: linear-gradient(135deg, #FF9800 0%, #FF3D00 100%); --brand-solid: #FF6D20; /* The midpoint color for text/icons */ --brand-light: rgba(255, 171, 64, 0.12); diff --git a/web/frontend/vite.config.ts b/web/frontend/vite.config.ts index 2134c6b..3cb3044 100644 --- a/web/frontend/vite.config.ts +++ b/web/frontend/vite.config.ts @@ -63,5 +63,29 @@ export default defineConfig({ // Improve performance by optimizing chunk sizes chunkSizeWarningLimit: 1000, }, + server: { + proxy: { + '/api': { + target: 'http://localhost:8080', + changeOrigin: true, + }, + '/health': { + target: 'http://localhost:8080', + changeOrigin: true, + }, + '/swagger': { + target: 'http://localhost:8080', + changeOrigin: true, + }, + '/install.sh': { + target: 'http://localhost:8080', + changeOrigin: true, + }, + '/install-cli.sh': { + target: 'http://localhost:8080', + changeOrigin: true, + } + } + }, base: "/", })