# Justfile for Post-ERG thesis form testing # Default recipe - show available commands default: @just --list # Create test database from schema init-test-db: @echo "Creating test database from schema..." @sqlite3 test.db < ../db/schema.sql @echo "✓ Test database created: test.db" @sqlite3 test.db "SELECT COUNT(*) || ' tables created' FROM sqlite_master WHERE type='table';" @sqlite3 test.db "SELECT COUNT(*) || ' orientations loaded' FROM orientations;" @sqlite3 test.db "SELECT COUNT(*) || ' AP programs loaded' FROM ap_programs;" # Start PHP development server serve: init-test-db @echo "Starting PHP development server on http://localhost:3000" @echo "Press Ctrl+C to stop" @php -S 127.0.0.1:3000 # Start server without reinitializing database serve-only: @echo "Starting PHP development server on http://localhost:3000" @echo "Press Ctrl+C to stop" @php -S 127.0.0.1:3000 # Clean up test database and uploaded files cleanup: @echo "Cleaning up test files..." @rm -f test.db @rm -f error.log @rm -rf data/theses/* @rm -rf data/covers/* @echo "✓ Cleanup complete" # Reset: cleanup and reinitialize reset: cleanup init-test-db @echo "✓ Test environment reset" # Show database statistics stats: @echo "=== Database Statistics ===" @sqlite3 test.db "SELECT COUNT(*) || ' theses' FROM theses;" @sqlite3 test.db "SELECT COUNT(*) || ' authors' FROM authors;" @sqlite3 test.db "SELECT COUNT(*) || ' supervisors' FROM supervisors;" @sqlite3 test.db "SELECT COUNT(*) || ' keywords' FROM keywords;" @sqlite3 test.db "SELECT COUNT(*) || ' files uploaded' FROM thesis_files;" # Show recent submissions recent: @echo "=== Recent Submissions ===" @sqlite3 -column -header test.db "SELECT identifier, title, year, submitted_at FROM theses ORDER BY submitted_at DESC LIMIT 5;" # Query database interactively query: @sqlite3 test.db # Show full thesis details show id: @sqlite3 -column -header test.db "SELECT * FROM v_theses_full WHERE id = {{id}};" # Dump database to SQL dump: @sqlite3 test.db .dump > test_backup_$(date +%Y%m%d_%H%M%S).sql @echo "✓ Database dumped to test_backup_$(date +%Y%m%d_%H%M%S).sql" # Create data directories if they don't exist setup-dirs: @mkdir -p data/theses @mkdir -p data/covers @mkdir -p data/yaml @touch data/theses/.gitkeep @touch data/covers/.gitkeep @echo "✓ Data directories created" # Full setup: directories + database + serve dev: setup-dirs init-test-db serve