Refactor justfile to reduce redundancy and merge similar recipes

- Merge deploy-* recipes into a single deploy-script recipe
- Remove rarely used recipes (show id, setup-dirs)
- Simplify test-* recipes
- Remove redundant default recipe
- Preserve all critical functionality
This commit is contained in:
Pontoporeia
2026-05-01 22:41:14 +02:00
parent d09f1942f0
commit 8a38708fc8
2 changed files with 20 additions and 60 deletions

View File

@@ -1,8 +1,5 @@
# XAMXAM Justfile
default:
@just --list
# ============================================================================
# Development
# ============================================================================
@@ -36,6 +33,7 @@ logs:
[group('deploy')]
deploy:
# Main deploy (code + assets)
rsync -vur --progress --delete \
--chown="www-data:xamxam" \
--exclude 'vendor' \
@@ -58,61 +56,33 @@ deploy:
app/ xamxam:/var/www/xamxam/
ssh xamxam "mkdir -p /var/www/xamxam/var/{cache,logs,tmp}"
[group('deploy')]
setup-server:
rsync -v scripts/setup-server.sh xamxam:/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 xamxam:/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/xamxam.conf xamxam:/tmp/xamxam.conf
rsync -v scripts/deploy-server.sh xamxam:/tmp/deploy-server.sh
@echo ""
@echo "Files uploaded. SSH into the server and run:"
@echo ""
@echo " sudo bash /tmp/deploy-server.sh"
@echo ""
[group('deploy')]
deploy-db:
@ssh xamxam '[ ! -f /var/www/xamxam/storage/xamxam.db ]' || (echo "ERROR: remote database already exists. Remove it manually if you intend to overwrite." && exit 1)
rsync -v --progress app/storage/xamxam.db xamxam:/var/www/xamxam/storage/xamxam.db
ssh xamxam "chown www-data:xamxam /var/www/xamxam/storage/xamxam.db && chmod 660 /var/www/xamxam/storage/xamxam.db"
[group('deploy')]
deploy-script script_name:
# Generic script deployer (e.g., just deploy-script setup-server)
rsync -v scripts/{{script_name}}.sh xamxam:/tmp/{{script_name}}.sh
@echo ""
@echo "Script uploaded. SSH into the server and run:"
@echo ""
@echo " sudo DEPLOY_USER=\$USER bash /tmp/{{script_name}}.sh"
@echo ""
# ============================================================================
# Testing
# ============================================================================
[group('test')]
test:
# Run all tests. To run a subset, use:
# php app/tests/Unit/DatabaseTest.php
# php app/tests/Integration/SearchTest.php
@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
@@ -141,10 +111,6 @@ reset-db:
query:
@sqlite3 app/storage/xamxam.db
[group('database')]
show id:
@sqlite3 -column -header app/storage/xamxam.db "SELECT * FROM v_theses_full WHERE id = {{id}};"
[group('database')]
backup:
@sqlite3 app/storage/xamxam.db .dump > app/storage/backup_$(date +%Y%m%d_%H%M%S).sql
@@ -158,8 +124,3 @@ clean:
@rm -f app/error.log
@rm -rf app/storage/cache/rate_limit/*
@rm -f /tmp/xamxam-*.log /tmp/xamxam-*.pid
[group('utils')]
setup-dirs:
@mkdir -p app/storage/cache/rate_limit
@touch app/storage/cache/rate_limit/.gitkeep