mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
206 lines
8.2 KiB
Makefile
206 lines
8.2 KiB
Makefile
# Default recipe - show available commands
|
|
default:
|
|
@just --list
|
|
|
|
# ============================================================================
|
|
# Deploy Group
|
|
# ============================================================================
|
|
# Note: Regular deploy recipes exclude test.db and all *.db files by default
|
|
# Use test-deploy explicitly to deploy the test database
|
|
|
|
[group('deploy')]
|
|
deploy-public:
|
|
rsync -vur --progress --exclude 'test.db' --exclude '*.db' --exclude 'tests/' --exclude 'cache/' --exclude '*.md' --exclude 'run-tests.php' ./apps/public/ posterg:/var/www/html/
|
|
rsync -vur --progress --exclude 'test.db' ./shared/ posterg:/var/www/html/shared/
|
|
@echo "Fixing shared library paths for production..."
|
|
ssh posterg "cd /var/www/html && find . -maxdepth 1 -name '*.php' -type f -exec sed -i \"s|__DIR__ \. '/\.\./\.\./shared/|__DIR__ . '/shared/|g\" {} \;"
|
|
@echo "Fixing permissions..."
|
|
ssh posterg "chgrp -R posterg /var/www/html/inc && chmod 755 /var/www/html/inc && chmod 644 /var/www/html/inc/*"
|
|
@echo "✓ Deployment complete"
|
|
|
|
[group('deploy')]
|
|
deploy-admin:
|
|
rsync -vur --progress --exclude 'test.db' --exclude '*.db' --exclude 'cache/' --exclude '*.md' ./apps/admin/ posterg:/var/www/html/admin/
|
|
rsync -vur --progress --exclude 'test.db' ./shared/ posterg:/var/www/html/shared/
|
|
@echo "Fixing shared library paths for production (admin)..."
|
|
ssh posterg "cd /var/www/html/formulaire && find . -maxdepth 1 -name '*.php' -type f -exec sed -i \"s|__DIR__ \. '/\.\./\.\./shared/|__DIR__ . '/../shared/|g\" {} \;"
|
|
@echo "✓ Admin paths fixed"
|
|
|
|
[group('deploy')]
|
|
deploy: deploy-public deploy-admin
|
|
@echo ""
|
|
@echo "✅ Deployment complete (test.db excluded)"
|
|
@echo "To deploy test database, run: just test-deploy"
|
|
|
|
[group('deploy')]
|
|
deploy-database:
|
|
@echo "Deploying database directory (excludes test.db by default)..."
|
|
rsync -vur --progress --exclude 'test.db' --exclude '*.db-journal' ./database/ posterg:/var/www/html/database/
|
|
@echo "✅ Database directory deployed (schema, fixtures, docs only)"
|
|
|
|
[group('deploy')]
|
|
test-deploy:
|
|
@echo "⚠️ Deploying test database (will overwrite remote test.db)"
|
|
@echo "Creating database directory if needed..."
|
|
ssh posterg "mkdir -p /var/www/html/database"
|
|
rsync -vur --progress ./database/test.db posterg:/var/www/html/database/test.db
|
|
@echo "Setting correct permissions..."
|
|
ssh posterg "chgrp posterg /var/www/html/database /var/www/html/database/test.db && chmod 775 /var/www/html/database && chmod 660 /var/www/html/database/test.db"
|
|
@echo "✅ Test database deployed and configured"
|
|
|
|
[group('deploy')]
|
|
deploy-nginx:
|
|
@echo "🚀 Deploying production nginx configuration..."
|
|
rsync -vur --progress ./nginx/posterg.conf posterg:/tmp/posterg.conf
|
|
rsync -vur --progress ./nginx/deploy-production.sh posterg:/tmp/deploy-production.sh
|
|
@echo "✅ Files uploaded to server"
|
|
@echo ""
|
|
@echo "Next steps on the server:"
|
|
@echo " ssh posterg"
|
|
@echo " sudo bash /tmp/deploy-production.sh"
|
|
@echo ""
|
|
@echo "This will:"
|
|
@echo " • Fix file permissions (posterg group)"
|
|
@echo " • Install nginx configuration"
|
|
@echo " • Set up admin password (if needed)"
|
|
@echo " • Test and reload nginx"
|
|
|
|
[group('deploy')]
|
|
deploy-admin-tools:
|
|
@echo "📤 Uploading admin user management tools..."
|
|
rsync -vur --progress ./nginx/manage-admin-users.sh posterg:/tmp/manage-admin-users.sh
|
|
@echo "✅ Script uploaded"
|
|
@echo ""
|
|
@echo "To manage admin users on the server:"
|
|
@echo " ssh posterg"
|
|
@echo " sudo bash /tmp/manage-admin-users.sh"
|
|
|
|
# ============================================================================
|
|
# Public Site Development
|
|
# ============================================================================
|
|
|
|
[group('public-dev')]
|
|
serve-public:
|
|
@echo "Starting public site on http://localhost:8002"
|
|
@echo "Press Ctrl+C to stop"
|
|
@cd apps/public && php -S 127.0.0.1:8002
|
|
|
|
[group('public-dev')]
|
|
test-public:
|
|
@echo "Testing public site..."
|
|
@cd apps/public && php test_db.php
|
|
|
|
[group('public-dev')]
|
|
test-public-all:
|
|
@echo "Running all public site tests..."
|
|
@cd apps/public && php run-tests.php
|
|
|
|
[group('public-dev')]
|
|
stats-public:
|
|
@echo "=== Public Database Statistics ==="
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' total theses' FROM theses;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' published theses' FROM theses WHERE is_published = 1;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' authors' FROM authors;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' keywords' FROM keywords;"
|
|
|
|
[group('public-dev')]
|
|
recent-public:
|
|
@echo "=== Recent Published Theses ==="
|
|
@sqlite3 -column -header database/test.db "SELECT id, title, year, authors FROM v_theses_public ORDER BY year DESC, title LIMIT 10;"
|
|
|
|
[group('public-dev')]
|
|
check-public:
|
|
@echo "Checking public site PHP syntax..."
|
|
@cd apps/public && find . -name "*.php" -not -path "./vendor/*" -not -path "./tests/*" -exec php -l {} \; | grep -v "No syntax errors"
|
|
@echo "✓ All files have valid syntax"
|
|
|
|
[group('public-dev')]
|
|
logs-public:
|
|
@if [ -f apps/public/error.log ]; then tail -n 50 apps/public/error.log; else echo "No error log found"; fi
|
|
|
|
# ============================================================================
|
|
# Admin Panel Development
|
|
# ============================================================================
|
|
|
|
[group('admin-dev')]
|
|
init-test-db:
|
|
@echo "Creating test database from schema..."
|
|
@sqlite3 database/test.db < database/schema.sql
|
|
@echo "✓ Test database created"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' tables created' FROM sqlite_master WHERE type='table';"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' orientations loaded' FROM orientations;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' AP programs loaded' FROM ap_programs;"
|
|
|
|
[group('admin-dev')]
|
|
serve-admin: init-test-db
|
|
@echo "Starting admin panel on http://localhost:3000"
|
|
@echo "Press Ctrl+C to stop"
|
|
@cd apps/admin && php -S 127.0.0.1:3000
|
|
|
|
[group('admin-dev')]
|
|
serve-admin-only:
|
|
@echo "Starting admin panel on http://localhost:3000"
|
|
@echo "Press Ctrl+C to stop"
|
|
@cd apps/admin && php -S 127.0.0.1:3000
|
|
|
|
[group('admin-dev')]
|
|
cleanup-admin:
|
|
@echo "Cleaning up admin test files..."
|
|
@rm -f database/test.db
|
|
@rm -f apps/admin/error.log
|
|
@rm -rf apps/admin/data/theses/*
|
|
@rm -rf apps/admin/data/covers/*
|
|
@echo "✓ Cleanup complete"
|
|
|
|
[group('admin-dev')]
|
|
reset-admin: cleanup-admin init-test-db
|
|
@echo "✓ Admin test environment reset"
|
|
|
|
[group('admin-dev')]
|
|
stats-admin:
|
|
@echo "=== Admin Database Statistics ==="
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' theses' FROM theses;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' authors' FROM authors;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' supervisors' FROM supervisors;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' keywords' FROM keywords;"
|
|
@sqlite3 database/test.db "SELECT COUNT(*) || ' files uploaded' FROM thesis_files;"
|
|
|
|
[group('admin-dev')]
|
|
recent-admin:
|
|
@echo "=== Recent Submissions ==="
|
|
@sqlite3 -column -header database/test.db "SELECT identifier, title, year, submitted_at FROM theses ORDER BY submitted_at DESC LIMIT 5;"
|
|
|
|
[group('admin-dev')]
|
|
setup-dirs:
|
|
@mkdir -p apps/admin/data/theses
|
|
@mkdir -p apps/admin/data/covers
|
|
@mkdir -p apps/admin/data/yaml
|
|
@touch apps/admin/data/theses/.gitkeep
|
|
@touch apps/admin/data/covers/.gitkeep
|
|
@echo "✓ Data directories created"
|
|
|
|
[group('admin-dev')]
|
|
dev-admin: setup-dirs init-test-db serve-admin
|
|
|
|
# ============================================================================
|
|
# Database Operations
|
|
# ============================================================================
|
|
|
|
[group('database')]
|
|
query-db:
|
|
@sqlite3 database/test.db
|
|
|
|
[group('database')]
|
|
show-thesis id:
|
|
@sqlite3 -column -header database/test.db "SELECT * FROM v_theses_full WHERE id = {{id}};"
|
|
|
|
[group('database')]
|
|
dump-db:
|
|
@sqlite3 database/test.db .dump > database/backup_$(date +%Y%m%d_%H%M%S).sql
|
|
@echo "✓ Database dumped to database/backup_$(date +%Y%m%d_%H%M%S).sql"
|
|
|
|
[group('database')]
|
|
create-fixtures:
|
|
@echo "Creating test database with fixtures..."
|
|
@php database/fixtures/CreateTestDatabase.php
|