Files
seedpgp-web/Makefile
LC mac 3bcb343fe3 docs: update version to v1.4.7 and organize documentation
- Update package.json version to v1.4.7
- Update README.md header to v1.4.7
- Update GEMINI.md version references to v1.4.7
- Update RECOVERY_PLAYBOOK.md version to v1.4.7
- Update SECURITY_AUDIT_REPORT.md version to v1.4.7
- Move documentation files to doc/ directory for better organization
- Add new documentation files: LOCAL_TESTING_GUIDE.md, SERVE.md, TAILS_OFFLINE_PLAYBOOK.md
- Add Makefile and serve.ts for improved development workflow
2026-02-13 23:24:26 +08:00

101 lines
3.7 KiB
Makefile

.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