Add Justfile and fix server implementation
Server improvements: - Complete rewrite with robust IPv4/IPv6 support - Graceful fallback from IPv6 dual-stack to IPv4-only - Better error handling and informative startup messages - Proper socket cleanup and server shutdown - Custom logging with timestamps Justfile additions: - serve/serve-bg/stop - Server management - lint-all/format-all/check-all - Code quality commands - install/setup/clean - Project management - validate/info/status - Development helpers - icons-png/icons-browser - Icon generation - commit/quick-commit - Git workflow helpers The server now works reliably across different network configurations and the justfile provides a comprehensive development workflow. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
736f784511
commit
749df446e9
2 changed files with 257 additions and 32 deletions
138
justfile
Normal file
138
justfile
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
# GlitchCraft Development Commands
|
||||
# Install just: https://github.com/casey/just
|
||||
|
||||
# Default recipe - show available commands
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Development server management
|
||||
# Start the development server
|
||||
serve:
|
||||
python3 server.py
|
||||
|
||||
# Start server in background
|
||||
serve-bg:
|
||||
python3 server.py &
|
||||
@echo "Server started in background"
|
||||
@echo "Use 'just stop' to stop it"
|
||||
|
||||
# Stop background server
|
||||
stop:
|
||||
@echo "Stopping GlitchCraft server..."
|
||||
pkill -f "python.*server.py" || echo "No server process found"
|
||||
|
||||
# Code quality and linting
|
||||
# Lint all JavaScript files
|
||||
lint-js:
|
||||
bun run lint:js
|
||||
|
||||
# Lint and auto-fix JavaScript
|
||||
fix-js:
|
||||
bun run lint:js:fix
|
||||
|
||||
# Format all code with Prettier
|
||||
format:
|
||||
bun run format
|
||||
|
||||
# Check code formatting without modifying files
|
||||
check-format:
|
||||
bun run check
|
||||
|
||||
# Lint Python code
|
||||
lint-python:
|
||||
black --check server.py
|
||||
pylint server.py
|
||||
|
||||
# Format Python code
|
||||
format-python:
|
||||
black server.py
|
||||
|
||||
# Lint and format everything
|
||||
lint-all: lint-js lint-python
|
||||
@echo "✓ All linting completed"
|
||||
|
||||
# Format everything
|
||||
format-all: format-python format
|
||||
@echo "✓ All formatting completed"
|
||||
|
||||
# Check everything (linting + formatting)
|
||||
check-all: lint-all check-format
|
||||
@echo "✓ All checks passed"
|
||||
|
||||
# PWA icon generation
|
||||
# Generate PNG icons (requires canvas package)
|
||||
icons-png:
|
||||
bun add canvas
|
||||
node app/create-icons.js
|
||||
|
||||
# Open browser-based icon generator
|
||||
icons-browser:
|
||||
@echo "Opening app/generate-icons.html..."
|
||||
@echo "Right-click each canvas to save icons"
|
||||
python3 -c "import webbrowser; webbrowser.open('app/generate-icons.html')"
|
||||
|
||||
# Development workflow
|
||||
# Install dependencies
|
||||
install:
|
||||
bun install
|
||||
|
||||
# Clean up generated files
|
||||
clean:
|
||||
rm -rf node_modules/
|
||||
rm -f bun.lockb
|
||||
find . -name "*.pyc" -delete
|
||||
find . -name "__pycache__" -type d -exec rm -rf {} +
|
||||
|
||||
# Full setup from scratch
|
||||
setup: install icons-png
|
||||
@echo "✓ GlitchCraft setup complete!"
|
||||
@echo "Run 'just serve' to start development"
|
||||
|
||||
# Testing and validation
|
||||
# Validate HTML files
|
||||
validate-html:
|
||||
bunx vnu-jar app/index.html app/generate-icons.html
|
||||
|
||||
# Test PWA manifest
|
||||
validate-manifest:
|
||||
python3 -m json.tool app/manifest.json > /dev/null && echo "✓ Manifest is valid JSON"
|
||||
|
||||
# Run all validations
|
||||
validate: validate-html validate-manifest check-all
|
||||
@echo "✓ All validations passed"
|
||||
|
||||
# Git helpers
|
||||
# Create a commit with all changes
|
||||
commit message:
|
||||
git add -A
|
||||
git commit -m "{{message}}\n\n🤖 Generated with [Claude Code](https://claude.ai/code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>"
|
||||
|
||||
# Quick commit with lint/format
|
||||
quick-commit message: format-all lint-all
|
||||
just commit "{{message}}"
|
||||
|
||||
# Development info
|
||||
# Show project info
|
||||
info:
|
||||
@echo "🎨 GlitchCraft - Artisanal text corruption, served fresh!"
|
||||
@echo ""
|
||||
@echo "📁 Project structure:"
|
||||
@echo " app/ - Main application (deploy this directory)"
|
||||
@echo " server.py - Development server (IPv4/IPv6)"
|
||||
@echo " justfile - Development commands"
|
||||
@echo ""
|
||||
@echo "🚀 Quick start:"
|
||||
@echo " just install - Install dependencies"
|
||||
@echo " just serve - Start development server"
|
||||
@echo " just check-all - Run all linting and validation"
|
||||
@echo ""
|
||||
@echo "🔗 Server URLs:"
|
||||
@echo " http://localhost:8000/"
|
||||
@echo " http://127.0.0.1:8000/ (IPv4)"
|
||||
@echo " http://[::1]:8000/ (IPv6)"
|
||||
|
||||
# Show server status
|
||||
status:
|
||||
@echo "Checking server status..."
|
||||
@pgrep -f "python.*server.py" > /dev/null && echo "✓ Server is running" || echo "✗ Server is not running"
|
||||
@echo "Use 'just serve' to start or 'just stop' to stop"
|
||||
Loading…
Add table
Add a link
Reference in a new issue