- Replace complex multi-server setup (live-server + API) with unified Go server
- Serve all sites at /sites/{site_id} endpoints, eliminating port conflicts
- Fix content-type middleware to serve proper MIME types for static files
- Prevent script injection duplication with future-proof CDN-compatible detection
- Remove auto page reload from enhance button to eliminate editing interruptions
- Enable seamless content editing workflow with manual enhancement control
Development now requires only 'just dev' instead of complex demo commands.
All sites immediately available at localhost:8080 without hot reload conflicts.
250 lines
7.6 KiB
Makefile
250 lines
7.6 KiB
Makefile
# Insertr Development Commands
|
|
# Use `just <command>` to run any of these tasks
|
|
|
|
# Default recipe - show available commands
|
|
default:
|
|
@just --list
|
|
|
|
# Install all dependencies (root + lib)
|
|
install:
|
|
npm install
|
|
cd lib && npm install
|
|
|
|
# Start full-stack development (primary workflow)
|
|
dev: build-lib build
|
|
#!/usr/bin/env bash
|
|
echo "🚀 Starting Full-Stack Insertr Development..."
|
|
echo "================================================"
|
|
echo ""
|
|
|
|
# Enhance demo site if needed
|
|
if [ ! -d "./test-sites/demo-site_enhanced" ]; then
|
|
echo "🔧 Demo site not ready - enhancing now..."
|
|
./insertr enhance test-sites/demo-site --output test-sites/demo-site_enhanced --config test-sites/demo-site/insertr.yaml
|
|
echo "✅ Demo site enhanced!"
|
|
fi
|
|
|
|
echo ""
|
|
echo "🔌 Starting Insertr server with all sites..."
|
|
echo ""
|
|
|
|
# Function to cleanup background processes
|
|
cleanup() {
|
|
echo ""
|
|
echo "🛑 Shutting down server..."
|
|
kill $SERVER_PID 2>/dev/null || true
|
|
wait $SERVER_PID 2>/dev/null || true
|
|
echo "✅ Shutdown complete"
|
|
exit 0
|
|
}
|
|
trap cleanup SIGINT SIGTERM
|
|
|
|
# Start server (serves API + all static sites)
|
|
INSERTR_DATABASE_PATH=./insertr.db ./insertr serve --dev-mode &
|
|
SERVER_PID=$!
|
|
|
|
echo ""
|
|
echo "🌐 All sites available at:"
|
|
echo " Demo site: http://localhost:8080/sites/demo/"
|
|
echo " Simple site: http://localhost:8080/sites/simple/"
|
|
echo " Dan Eden site: http://localhost:8080/sites/dan-eden/"
|
|
echo ""
|
|
echo "📝 Full-stack ready - edit content with real-time persistence!"
|
|
echo "🔄 Press Ctrl+C to shutdown"
|
|
echo ""
|
|
|
|
# Wait for server process
|
|
wait $SERVER_PID
|
|
|
|
# Start development server for about page
|
|
dev-about: build-lib build
|
|
#!/usr/bin/env bash
|
|
echo "🚀 Starting full-stack development..."
|
|
echo "🌐 About page available at: http://localhost:8080/sites/demo/about.html"
|
|
INSERTR_DATABASE_PATH=./insertr.db ./insertr serve --dev-mode
|
|
|
|
# Check project status and validate setup
|
|
check:
|
|
npm run check
|
|
|
|
# Simple demo launcher - all sites now served from main server
|
|
demo:
|
|
@echo "🌐 All demo sites are served from the main server:"
|
|
@echo " http://localhost:8080/sites/demo/ - Main demo site"
|
|
@echo " http://localhost:8080/sites/simple/ - Simple test site"
|
|
@echo " http://localhost:8080/sites/dan-eden/ - Dan Eden portfolio"
|
|
@echo ""
|
|
@echo "🚀 To start the development server:"
|
|
@echo " just dev"
|
|
|
|
# Build the entire project (library + unified binary)
|
|
build:
|
|
npm run build
|
|
|
|
# Build only the JavaScript library
|
|
build-lib:
|
|
npm run build:lib
|
|
|
|
# Watch library files for changes (auto-rebuild)
|
|
watch:
|
|
cd lib && npm run dev
|
|
|
|
# Start Air hot-reload for unified binary development
|
|
air:
|
|
air
|
|
|
|
# Build unified binary only
|
|
build-insertr:
|
|
go build -o insertr .
|
|
|
|
# Run insertr help
|
|
help:
|
|
./insertr --help
|
|
|
|
|
|
|
|
# Enhance demo site (build-time content injection)
|
|
enhance input="test-sites/demo-site" output="dist":
|
|
./insertr enhance {{input}} --output {{output}} --mock
|
|
|
|
# === Content API Server Commands ===
|
|
|
|
# Start content API server (default port 8080)
|
|
serve port="8080":
|
|
INSERTR_DATABASE_PATH=./insertr.db ./insertr serve --port {{port}} --dev-mode
|
|
|
|
# Start API server in production mode
|
|
serve-prod port="8080" db="./insertr.db":
|
|
INSERTR_DATABASE_PATH={{db}} ./insertr serve --port {{port}}
|
|
|
|
|
|
|
|
# Check API server health
|
|
health port="8080":
|
|
@echo "🔍 Checking API server health..."
|
|
@curl -s http://localhost:{{port}}/health | jq . || echo "❌ Server not responding at localhost:{{port}}"
|
|
|
|
# Clean all build artifacts and backups
|
|
clean:
|
|
rm -rf lib/dist
|
|
rm -rf insertr
|
|
rm -rf tmp
|
|
rm -rf dist
|
|
rm -rf node_modules
|
|
rm -rf lib/node_modules
|
|
rm -f dev.db
|
|
rm -f insertr.db
|
|
@echo "🧹 Cleaned all build artifacts and backups"
|
|
|
|
|
|
|
|
# Lint code (placeholder for now)
|
|
lint:
|
|
npm run lint
|
|
|
|
# Run tests (placeholder for now)
|
|
test:
|
|
npm run test
|
|
|
|
# Development workflow: install deps, build lib, start dev server
|
|
dev-setup: install build-lib dev
|
|
|
|
# Production workflow: install deps, build everything
|
|
prod-build: install build
|
|
|
|
# Show project status
|
|
status:
|
|
@echo "🏗️ Insertr Project Status"
|
|
@echo "========================="
|
|
@echo "📁 Root files:"
|
|
@ls -la package.json justfile go.mod insertr.yaml 2>/dev/null || echo " Missing files"
|
|
@echo "\n📚 Library files:"
|
|
@ls -la lib/package.json lib/src lib/dist 2>/dev/null || echo " Missing library components"
|
|
@echo "\n🔧 Unified binary:"
|
|
@ls -la insertr main.go cmd/ internal/ 2>/dev/null || echo " Missing unified binary components"
|
|
@echo "\n🌐 Demo site:"
|
|
@ls -la test-sites/demo-site/index.html test-sites/demo-site/about.html 2>/dev/null || echo " Missing demo files"
|
|
@echo ""
|
|
@echo "🚀 Development Commands:"
|
|
@echo " just dev - Full-stack development (recommended)"
|
|
@echo " just demo - Show available demo sites"
|
|
@echo " just serve - API server only (localhost:8080)"
|
|
@echo " just enhance - Build-time content injection"
|
|
@echo ""
|
|
@echo "🔍 Check server: just health"
|
|
|
|
|
|
# Generate sqlc code (for database schema changes)
|
|
sqlc:
|
|
sqlc generate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Clean generated demo directories
|
|
clean-demos:
|
|
#!/usr/bin/env bash
|
|
echo "🧹 Cleaning generated demo directories..."
|
|
echo "========================================="
|
|
|
|
# Demo directories
|
|
if [ -d "./test-sites/demo-site_enhanced" ]; then
|
|
rm -rf "./test-sites/demo-site_enhanced"
|
|
echo "🗑️ Removed: demo-site_enhanced"
|
|
fi
|
|
|
|
if [ -d "./test-sites/simple/dan-eden-portfolio_enhanced" ]; then
|
|
rm -rf "./test-sites/simple/dan-eden-portfolio_enhanced"
|
|
echo "🗑️ Removed: dan-eden-portfolio_enhanced"
|
|
fi
|
|
|
|
if [ -d "./test-sites/simple/test-simple_enhanced" ]; then
|
|
rm -rf "./test-sites/simple/test-simple_enhanced"
|
|
echo "🗑️ Removed: test-simple_enhanced"
|
|
fi
|
|
|
|
# Clean up any temporary directories
|
|
if [ -d "./test-sites/simple/dan-eden-portfolio-temp" ]; then
|
|
rm -rf "./test-sites/simple/dan-eden-portfolio-temp"
|
|
echo "🗑️ Removed: dan-eden-portfolio-temp"
|
|
fi
|
|
|
|
if [ -d "./test-sites/simple/test-simple-temp" ]; then
|
|
rm -rf "./test-sites/simple/test-simple-temp"
|
|
echo "🗑️ Removed: test-simple-temp"
|
|
fi
|
|
|
|
# Legacy directories (cleanup from old workflow)
|
|
for legacy_dir in dan-eden-portfolio-auto-enhanced dan-eden-portfolio-full dan-eden-portfolio-auto dan-eden-portfolio-auto-v2 dan-eden-portfolio-auto-enhanced test-simple-auto-enhanced test-simple-full dan-eden-portfolio-enhanced test-simple-enhanced; do
|
|
if [ -d "./test-sites/simple/${legacy_dir}" ]; then
|
|
rm -rf "./test-sites/simple/${legacy_dir}"
|
|
echo "🗑️ Removed: ${legacy_dir} (legacy)"
|
|
fi
|
|
done
|
|
|
|
if [ -d "./test-sites/simple/dan-eden-portfolio-full" ]; then
|
|
rm -rf "./test-sites/simple/dan-eden-portfolio-full"
|
|
echo "🗑️ Removed: dan-eden-portfolio-full"
|
|
fi
|
|
|
|
if [ -d "./test-sites/simple/test-simple-auto-enhanced" ]; then
|
|
rm -rf "./test-sites/simple/test-simple-auto-enhanced"
|
|
echo "🗑️ Removed: test-simple-auto-enhanced"
|
|
fi
|
|
|
|
if [ -d "./test-sites/simple/test-simple-full" ]; then
|
|
rm -rf "./test-sites/simple/test-simple-full"
|
|
echo "🗑️ Removed: test-simple-full"
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
echo "✅ Demo cleanup complete!"
|
|
echo "🔧 Sites will auto-enhance when you run demo commands"
|
|
|
|
|