Files
links/justfile
T

137 lines
4.7 KiB
Makefile

# URL Manager — justfile
# Install just: brew install just
# Run `just` to see all available recipes.
set shell := ["bash", "-c"]
# Show available recipes
default:
@just --list
# ── Setup ─────────────────────────────────────────────────────────────────────
# Install Python dependencies and set up the project for first use
install:
uv sync
source .venv/bin/activate && uv run manage.py migrate
mkdir -p media/screenshots data
# Install Playwright browsers (needed for screenshot capture)
install-browsers:
source .venv/bin/activate && playwright install chromium
# ── Local Development ─────────────────────────────────────────────────────────
# Run Django server + Tailwind CSS together (Tailwind in background)
dev:
#!/usr/bin/env bash
set -eu
source .venv/bin/activate
uv run manage.py tailwind start &
TAILWIND_PID=$!
trap "kill $TAILWIND_PID 2>/dev/null" EXIT
uv run manage.py runserver 0.0.0.0:8000
# Run Tailwind CSS in watch mode (standalone)
tailwind:
source .venv/bin/activate && uv run manage.py tailwind start
# ── Database ──────────────────────────────────────────────────────────────────
# Apply all pending migrations
migrate:
source .venv/bin/activate && uv run manage.py migrate
# Create new migrations from model changes
makemigrations:
source .venv/bin/activate && uv run manage.py makemigrations
# Open Django shell
shell:
source .venv/bin/activate && uv run manage.py shell
# Open raw database shell
dbshell:
source .venv/bin/activate && uv run manage.py dbshell
# Create a Django superuser
superuser:
source .venv/bin/activate && uv run manage.py createsuperuser
# ── Static Assets ─────────────────────────────────────────────────────────────
# Build Tailwind CSS (minified, for production)
build-css:
source .venv/bin/activate && uv run manage.py tailwind build
# Collect all static files into staticfiles/
collectstatic:
source .venv/bin/activate && uv run manage.py collectstatic --no-input
# ── i18n ──────────────────────────────────────────────────────────────────────
# Compile translation files
compilemessages:
source .venv/bin/activate && uv run manage.py compilemessages
# Extract translatable strings for zh_Hans
makemessages:
source .venv/bin/activate && uv run manage.py makemessages -l zh_Hans
# ── Testing ───────────────────────────────────────────────────────────────────
# Run tests
test:
source .venv/bin/activate && pytest
# Run tests with coverage
test-cov:
source .venv/bin/activate && pytest --cov=links --cov-report=term-missing
# ── Docker ────────────────────────────────────────────────────────────────────
# Build Docker images
docker-build:
docker-compose build
# Start all Docker services (detached)
docker-start:
mkdir -p media/screenshots
chmod -R 777 media
docker-compose up -d
@echo "App running at http://localhost:8000"
# Stop all Docker services
docker-stop:
docker-compose down
# Restart Docker services
docker-restart:
docker-compose restart
# Tail logs for all services (or a specific one: just docker-logs web)
docker-logs service="":
#!/usr/bin/env bash
if [ -n "{{ service }}" ]; then
docker-compose logs -f {{ service }}
else
docker-compose logs -f
fi
# Open a shell inside the web container
docker-shell:
docker-compose exec web bash
# Run migrations inside Docker
docker-migrate:
docker-compose exec web uv run manage.py makemigrations
docker-compose exec web uv run manage.py migrate
# Collect static files inside Docker
docker-static:
docker-compose exec web uv run manage.py collectstatic --no-input
# Rebuild and restart a specific service (e.g.: just docker-rebuild web)
docker-rebuild service="web":
docker-compose up -d --build {{ service }}