mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
160 lines
4.7 KiB
Makefile
160 lines
4.7 KiB
Makefile
# Post-ERG Justfile
|
|
|
|
default:
|
|
@just --list
|
|
|
|
# ============================================================================
|
|
# Development
|
|
# ============================================================================
|
|
|
|
[group('dev')]
|
|
setup:
|
|
@bash scripts/setup-dev.sh
|
|
|
|
[group('dev')]
|
|
serve: migrate
|
|
@php -S 127.0.0.1:8000 -t app/public/ app/router.php 2>&1 | stdbuf -oL grep -Ev '(Accepted|Closing|live-reload\.php|assets/|favicon)' || true
|
|
|
|
[group('dev')]
|
|
stop:
|
|
@pkill -f "php -S 127.0.0.1:8000" 2>/dev/null && echo "stopped" || echo "no server running"
|
|
|
|
[group('dev')]
|
|
logs:
|
|
@tail -n 20 error.log 2>/dev/null || echo "no error log"
|
|
|
|
# ============================================================================
|
|
# Deploy
|
|
# ============================================================================
|
|
|
|
[group('deploy')]
|
|
deploy:
|
|
rsync -vur --progress --delete \
|
|
--chown="www-data:posterg" \
|
|
--exclude 'vendor' \
|
|
--exclude 'tests' \
|
|
--exclude '*.md' \
|
|
--exclude '.git*' \
|
|
--exclude '.jj' \
|
|
--exclude '.claude' \
|
|
--exclude '.pi' \
|
|
--exclude '.DS_Store' \
|
|
--exclude 'storage/posterg.db' \
|
|
--exclude 'storage/theses' \
|
|
--exclude 'storage/covers' \
|
|
--exclude 'storage/backup_*' \
|
|
--exclude 'storage/cache/*' \
|
|
--exclude 'storage/fixtures' \
|
|
--exclude 'storage/docs' \
|
|
--exclude 'var/cache/*' \
|
|
--exclude 'var/logs/*' \
|
|
app/ posterg:/var/www/xamxam/
|
|
ssh posterg "mkdir -p /var/www/xamxam/var/{cache,logs,tmp}"
|
|
|
|
[group('deploy')]
|
|
setup-server:
|
|
rsync -v scripts/setup-server.sh posterg:/tmp/setup-server.sh
|
|
@echo ""
|
|
@echo "Script uploaded. SSH into the server and run:"
|
|
@echo ""
|
|
@echo " sudo DEPLOY_USER=\$USER bash /tmp/setup-server.sh"
|
|
@echo ""
|
|
|
|
[group('deploy')]
|
|
manage-admin-users:
|
|
rsync -v scripts/manage-admin-users.sh posterg:/tmp/manage-admin-users.sh
|
|
@echo ""
|
|
@echo "Script uploaded. SSH into the server and run:"
|
|
@echo ""
|
|
@echo " sudo bash /tmp/manage-admin-users.sh"
|
|
@echo ""
|
|
|
|
[group('deploy')]
|
|
deploy-nginx:
|
|
rsync -v nginx/posterg.conf posterg:/tmp/posterg.conf
|
|
rsync -v scripts/deploy-server.sh posterg:/tmp/deploy-server.sh
|
|
@echo ""
|
|
@echo "Files uploaded. SSH into the server and run:"
|
|
@echo ""
|
|
@echo " sudo bash /tmp/deploy-server.sh"
|
|
@echo " sudo systemctl reload nginx"
|
|
@echo ""
|
|
|
|
[group('deploy')]
|
|
deploy-db:
|
|
@ssh posterg '[ ! -f /var/www/xamxam/storage/posterg.db ]' || (echo "ERROR: remote database already exists. Remove it manually if you intend to overwrite." && exit 1)
|
|
rsync -v --progress app/storage/posterg.db posterg:/var/www/xamxam/storage/posterg.db
|
|
ssh posterg "chown www-data:posterg /var/www/xamxam/storage/posterg.db && chmod 660 /var/www/xamxam/storage/posterg.db"
|
|
|
|
# ============================================================================
|
|
# Testing
|
|
# ============================================================================
|
|
|
|
[group('test')]
|
|
test:
|
|
@php app/tests/run-tests.php
|
|
|
|
[group('test')]
|
|
test-unit:
|
|
@php app/tests/Unit/DatabaseTest.php
|
|
@php app/tests/Unit/RateLimitTest.php
|
|
|
|
[group('test')]
|
|
test-integration:
|
|
@php app/tests/Integration/SearchTest.php
|
|
|
|
[group('test')]
|
|
test-security:
|
|
@php app/tests/Security/SecurityTest.php
|
|
|
|
[group('test')]
|
|
syntax:
|
|
@find app/ -name '*.php' -exec php -l {} \; 2>/dev/null | grep -v 'No syntax errors' || true
|
|
@echo '✅ Syntax OK'
|
|
|
|
# ============================================================================
|
|
# Database
|
|
# ============================================================================
|
|
|
|
[group('database')]
|
|
migrate:
|
|
@echo "Running migrations…"
|
|
@bash scripts/migrate.sh
|
|
|
|
[group('database')]
|
|
init-db:
|
|
@sqlite3 app/storage/posterg.db < app/storage/schema.sql
|
|
@sqlite3 app/storage/posterg.db "SELECT COUNT(*) || ' tables' FROM sqlite_master WHERE type='table';"
|
|
|
|
[group('database')]
|
|
reset-db:
|
|
@rm -f app/storage/posterg.db
|
|
@just init-db
|
|
|
|
[group('database')]
|
|
query:
|
|
@sqlite3 app/storage/posterg.db
|
|
|
|
[group('database')]
|
|
show id:
|
|
@sqlite3 -column -header app/storage/posterg.db "SELECT * FROM v_theses_full WHERE id = {{id}};";
|
|
|
|
[group('database')]
|
|
backup:
|
|
@sqlite3 app/storage/posterg.db .dump > app/storage/backup_$(date +%Y%m%d_%H%M%S).sql
|
|
|
|
# ============================================================================
|
|
# Utils
|
|
# ============================================================================
|
|
|
|
[group('utils')]
|
|
clean:
|
|
@rm -f app/error.log
|
|
@rm -rf app/storage/cache/rate_limit/*
|
|
@rm -f /tmp/posterg-*.log /tmp/posterg-*.pid
|
|
|
|
[group('utils')]
|
|
setup-dirs:
|
|
@mkdir -p app/storage/cache/rate_limit
|
|
@touch app/storage/cache/rate_limit/.gitkeep
|