- Add restore command to CLI root (cmd/root.go) - Add restore-clean justfile target for development workflow - Update justfile clean command to remove backups - Improve auth UI status display and enhance button visibility - Clean up auth.js formatting and enhance button management
194 lines
5.8 KiB
Makefile
194 lines
5.8 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 ""
|
|
echo "📝 Unified logs below (API server + Demo site):"
|
|
echo "🔌 [SERVER] = API server logs"
|
|
echo "🌐 [DEMO] = Demo site logs"
|
|
echo ""
|
|
|
|
# Function to cleanup background processes
|
|
cleanup() {
|
|
echo ""
|
|
echo "🛑 Shutting down servers..."
|
|
kill $SERVER_PID $DEMO_PID 2>/dev/null || true
|
|
wait $SERVER_PID $DEMO_PID 2>/dev/null || true
|
|
echo "✅ Shutdown complete"
|
|
exit 0
|
|
}
|
|
trap cleanup SIGINT SIGTERM
|
|
|
|
# Start API server with prefixed output
|
|
echo "🔌 Starting API server (localhost:8080)..."
|
|
INSERTR_DATABASE_PATH=./dev.db ./insertr serve --dev-mode 2>&1 | sed 's/^/🔌 [SERVER] /' &
|
|
SERVER_PID=$!
|
|
|
|
# Wait for server startup
|
|
echo "⏳ Waiting for API server startup..."
|
|
sleep 3
|
|
|
|
# Check server health
|
|
if curl -s http://localhost:8080/health > /dev/null 2>&1; then
|
|
echo "✅ API server ready!"
|
|
else
|
|
echo "⚠️ API server may not be ready yet"
|
|
fi
|
|
|
|
echo ""
|
|
echo "🌐 Starting demo site (localhost:3000)..."
|
|
echo "📝 Full-stack ready - edit content with real-time persistence!"
|
|
echo ""
|
|
|
|
# Start demo site with prefixed output (this will block) - use local installation
|
|
cd {{justfile_directory()}} && npx --prefer-offline live-server demo-site --port=3000 --host=localhost --open=/index.html 2>&1 | sed 's/^/🌐 [DEMO] /' &
|
|
DEMO_PID=$!
|
|
|
|
# Wait for both processes
|
|
wait $DEMO_PID $SERVER_PID
|
|
|
|
# Demo site only (for specific use cases)
|
|
demo-only:
|
|
@echo "🌐 Starting demo site only (no API server)"
|
|
@echo "⚠️ Content edits will not persist without API server"
|
|
npx --prefer-offline live-server demo-site --port=3000 --host=localhost --open=/index.html
|
|
|
|
# Start development server for about page
|
|
dev-about: build-lib build
|
|
#!/usr/bin/env bash
|
|
echo "🚀 Starting full-stack development (about page)..."
|
|
INSERTR_DATABASE_PATH=./dev.db ./insertr serve --dev-mode &
|
|
SERVER_PID=$!
|
|
sleep 3
|
|
npx --prefer-offline live-server demo-site --port=3000 --host=localhost --open=/about.html
|
|
kill $SERVER_PID 2>/dev/null || true
|
|
|
|
# Check project status and validate setup
|
|
check:
|
|
npm run check
|
|
|
|
# Show demo instructions
|
|
demo:
|
|
npm run demo
|
|
|
|
# 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
|
|
|
|
# Parse demo site with CLI
|
|
parse:
|
|
./insertr enhance demo-site/ --output ./dist --mock
|
|
|
|
# Enhance demo site (build-time content injection)
|
|
enhance input="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=./dev.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}}
|
|
|
|
# Start API server with auto-restart on Go file changes
|
|
serve-dev port="8080":
|
|
find . -name "*.go" | entr -r bash -c 'INSERTR_DATABASE_PATH=./dev.db ./insertr serve --port {{port}} --dev-mode'
|
|
|
|
# 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"
|
|
|
|
# Restore demo site to clean original state
|
|
restore-clean:
|
|
@echo "🧹 Restoring demo site to clean state..."
|
|
./insertr restore demo --clean
|
|
|
|
# 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 demo-site/index.html 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-only - Demo site only (no persistence)"
|
|
@echo " just serve - API server only (localhost:8080)"
|
|
@echo " just enhance - Build-time content injection"
|
|
@echo ""
|
|
@echo "🔍 Check server: just health"
|
|
@echo "🧹 Restore clean: just restore-clean"
|
|
|
|
# Generate sqlc code (for database schema changes)
|
|
sqlc:
|
|
sqlc generate
|