.PHONY: help install build build-offline serve-local audit clean verify-offline help: @echo "seedpgp-web Makefile - Bun-based build system" @echo "" @echo "Usage:" @echo " make install - Install dependencies with Bun" @echo " make build - Build production bundle (for Cloudflare)" @echo " make build-offline - Build with relative paths (for offline/Tails use)" @echo " make serve-local - Serve dist/ locally for testing (http://localhost:8000)" @echo " make audit - Run security audit" @echo " make verify-offline - Verify offline compatibility" @echo " make clean - Clean build artifacts" @echo "" # Install dependencies install: @echo "๐Ÿ“ฆ Installing dependencies with Bun..." bun install # Build for Cloudflare (absolute paths) build: @echo "๐Ÿ”จ Building for Cloudflare Pages (absolute paths)..." VITE_BASE_PATH="/" bun run vite build @echo "โœ… Build complete: dist/" # Build for offline/Tails (relative paths) build-offline: @echo "๐Ÿ”จ Building for offline/Tails (relative paths)..." VITE_BASE_PATH="./" bun run vite build @echo "โœ… Build complete: dist/ (with relative asset paths)" # Development server (for testing locally) serve-local: @echo "๐Ÿš€ Starting local server at http://localhost:8000" @echo " Press Ctrl+C to stop" # Use Python builtin http.server for a simple, dependency-free static server cd dist && python3 -m http.server 8000 serve-bun: @echo "๐Ÿš€ Starting Bun static server at http://127.0.0.1:8000" @echo " Press Ctrl+C to stop" bun ./serve.ts # Security audit - check for network calls and suspicious patterns audit: @echo "๐Ÿ” Running security audit..." @echo "" @echo "Checking for fetch/XHR calls..." @grep -r "fetch\|XMLHttpRequest\|axios\|http\|https" src/ --include="*.ts" --include="*.tsx" --include="*.js" || echo "โœ… No network calls found" @echo "" @echo "Checking dist/ for external resources..." @grep -r "cloudflare\|googleapis\|cdn\|http:" dist/ || echo "โœ… No external URLs in build" @echo "" @echo "Checking for localStorage/sessionStorage usage..." @grep -r "localStorage\|sessionStorage" src/ --include="*.ts" --include="*.tsx" || echo "โœ… No persistent storage calls" @echo "" @echo "โœ… Security audit complete" # Verify offline compatibility verify-offline: @echo "๐Ÿงช Verifying offline compatibility..." @echo "" @echo "Checking dist/ file structure..." @find dist -type f | wc -l | xargs echo "Total files:" @echo "" @echo "Verifying index.html exists and is readable..." @[ -f dist/index.html ] && echo "โœ… index.html found" || echo "โŒ index.html NOT found" @echo "" @echo "Checking for asset references in index.html..." @head -20 dist/index.html | grep -q "assets" && echo "โœ… Assets referenced" || echo "โš ๏ธ No assets referenced" @echo "" @echo "Checking for relative path usage..." @grep -q 'src="./' dist/index.html && echo "โœ… Relative paths detected" || echo "โš ๏ธ Check asset paths" @echo "" @echo "โœ… Offline compatibility check complete" # Clean build artifacts clean: @echo "๐Ÿ—‘๏ธ Cleaning build artifacts..." rm -rf dist/ rm -rf .dist/ @echo "โœ… Clean complete" # Full pipeline: clean, build for offline, verify full-build-offline: clean build-offline verify-offline audit @echo "" @echo "โœ… Full offline build pipeline complete!" @echo " Ready to copy to USB for Tails" @echo "" @echo "Next steps:" @echo " 1. Format USB: diskutil secureErase freespace 0 /dev/diskX" @echo " 2. Copy: cp -R dist/* /Volumes/SEEDPGP/" @echo " 3. Eject: diskutil eject /Volumes/SEEDPGP" @echo " 4. Boot Tails and insert Application USB" # Quick development setup dev: @echo "๐Ÿš€ Starting Bun dev server..." bun run dev