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

13
TODO.md
View File

@@ -1,9 +1,8 @@
# TODO # TODO
- [x] Investigate Mistral API 404 error - [x] Refactor `justfile` to reduce redundancy and merge similar recipes
- [x] Fix Mistral provider configuration (changed api to "mistral-conversations" and baseUrl to "https://api.mistral.ai") - [x] Merge `deploy-*` recipes into a single `deploy-script` recipe
- [x] Remove rarely used recipes (`show id`, `setup-dirs`)
## Issue Resolution - [x] Simplify `test-*` recipes
The Mistral provider had two configuration errors: - [x] Remove redundant `default` recipe
1. Used deprecated `api: "openai-completions"` instead of `api: "mistral-conversations"` - [x] Preserve all critical functionality
2. Incorrect baseUrl with `/v1` suffix. The Mistral SDK's `serverURL` expects the base URL without path suffixes - it appends the API paths internally. Changed from `https://api.mistral.ai/v1` to `https://api.mistral.ai`

View File

@@ -1,8 +1,5 @@
# XAMXAM Justfile # XAMXAM Justfile
default:
@just --list
# ============================================================================ # ============================================================================
# Development # Development
# ============================================================================ # ============================================================================
@@ -36,6 +33,7 @@ logs:
[group('deploy')] [group('deploy')]
deploy: deploy:
# Main deploy (code + assets)
rsync -vur --progress --delete \ rsync -vur --progress --delete \
--chown="www-data:xamxam" \ --chown="www-data:xamxam" \
--exclude 'vendor' \ --exclude 'vendor' \
@@ -58,61 +56,33 @@ deploy:
app/ xamxam:/var/www/xamxam/ app/ xamxam:/var/www/xamxam/
ssh xamxam "mkdir -p /var/www/xamxam/var/{cache,logs,tmp}" 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')] [group('deploy')]
deploy-db: 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) @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 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" 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 # Testing
# ============================================================================ # ============================================================================
[group('test')] [group('test')]
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 @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')] [group('test')]
syntax: syntax:
@find app/ -name '*.php' -exec php -l {} \; 2>/dev/null | grep -v 'No syntax errors' || true @find app/ -name '*.php' -exec php -l {} \; 2>/dev/null | grep -v 'No syntax errors' || true
@@ -141,10 +111,6 @@ reset-db:
query: query:
@sqlite3 app/storage/xamxam.db @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')] [group('database')]
backup: backup:
@sqlite3 app/storage/xamxam.db .dump > app/storage/backup_$(date +%Y%m%d_%H%M%S).sql @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 -f app/error.log
@rm -rf app/storage/cache/rate_limit/* @rm -rf app/storage/cache/rate_limit/*
@rm -f /tmp/xamxam-*.log /tmp/xamxam-*.pid @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