-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d4f187
commit 8ab75f1
Showing
10 changed files
with
505 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
justfile := justfile_directory() + "/.just/copier.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
# Create a copier answers file | ||
[no-cd] | ||
copy TEMPLATE_PATH DESTINATION_PATH=".": | ||
$python -m copier copy --trust {{ TEMPLATE_PATH }} {{ DESTINATION_PATH }} | ||
|
||
# Recopy the project from the original template | ||
[no-cd] | ||
recopy ANSWERS_FILE *ARGS: | ||
$python -m copier recopy --trust --answers-file {{ ANSWERS_FILE }} {{ ARGS }} | ||
|
||
# Loop through all answers files and recopy the project using copier | ||
[no-cd] | ||
@recopy-all *ARGS: | ||
for file in `ls .copier/`; do just --unstable copier recopy .copier/$file "{{ ARGS }}"; done | ||
|
||
# Update the project using a copier answers file | ||
[no-cd] | ||
update ANSWERS_FILE *ARGS: | ||
$python -m copier update --trust --answers-file {{ ANSWERS_FILE }} {{ ARGS }} | ||
|
||
# Loop through all answers files and update the project using copier | ||
[no-cd] | ||
@update-all *ARGS: | ||
for file in `ls .copier/`; do just --unstable copier update .copier/$file "{{ ARGS }}"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
justfile := justfile_directory() + "/.just/django.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
# Run a Django management command | ||
manage *COMMAND: | ||
@just docker command python -m manage {{ COMMAND }} | ||
|
||
# Alias for makemigrations | ||
alias mm := makemigrations | ||
|
||
# Generate Django migrations | ||
makemigrations *APPS: | ||
@just dj manage makemigrations {{ APPS }} | ||
|
||
# Run Django migrations | ||
migrate *ARGS: | ||
@just dj manage migrate {{ ARGS }} | ||
|
||
# Open a Django shell using django-extensions shell_plus command | ||
shell: | ||
@just dj manage shell_plus | ||
|
||
# Quickly create a superuser with the provided credentials | ||
createsuperuser USERNAME="admin" PASSWORD="admin" EMAIL="admin@localhost": | ||
@just docker run app "-e DJANGO_SUPERUSER_PASSWORD='{{ PASSWORD }}'" "/bin/bash -c 'python -m manage createsuperuser --noinput --username "{{ USERNAME }}" --email "{{ EMAIL }}"'" | ||
|
||
# Graph models using django-extensions graph_models command | ||
graph: | ||
@just dj manage graph_models users \ | ||
--exclude-models AbstractUser \ | ||
--group-models \ | ||
--output ./docs/applications/images/users.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
justfile := justfile_directory() + "/.just/docker.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
# Build services using docker compose | ||
[no-cd] | ||
build *ARGS: | ||
docker compose build {{ ARGS }} | ||
|
||
# Build production stack using docker compose | ||
[no-cd] | ||
build-prod: | ||
docker compose -f compose.yml -f compose.prod.yml build | ||
|
||
# Stop and remove all containers, networks, images, and volumes | ||
clean: | ||
@just docker down --volumes --rmi local | ||
|
||
# Run a command within the 'app' container | ||
command *ARGS: | ||
@just docker run app "" "/bin/bash -c '{{ ARGS }}'" | ||
|
||
# Stop and remove all containers defined in docker compose | ||
[no-cd] | ||
down *ARGS: | ||
docker compose down {{ ARGS }} | ||
|
||
# Display the logs for containers, optionally using provided arguments (e.g., --follow) | ||
[no-cd] | ||
logs *ARGS: | ||
docker compose logs {{ ARGS }} | ||
|
||
# Display the running containers and their statuses | ||
[no-cd] | ||
ps: | ||
docker compose ps | ||
|
||
# Pull the latest versions of all images defined in docker compose | ||
[no-cd] | ||
pull: | ||
docker compose pull | ||
|
||
# Restart services, optionally targeting specific ones | ||
[no-cd] | ||
restart *ARGS: | ||
docker compose restart {{ ARGS }} | ||
|
||
# Run a command within the specified container with command-line flags | ||
[no-cd] | ||
run CONTAINER FLAGS *ARGS: | ||
docker compose run --rm {{ FLAGS }} {{ CONTAINER }} {{ ARGS }} | ||
|
||
# Start development stack using docker compose | ||
start: | ||
@just docker up --detach | ||
|
||
# Start the full production stack using docker compose | ||
start-prod: | ||
@just docker up-prod --detach | ||
|
||
# Stop services by calling the 'down' command | ||
stop: | ||
@just docker down | ||
|
||
# Continuously follow the latest docker logs, optionally targeting specific containers | ||
tail *ARGS: | ||
@just docker logs --follow {{ ARGS }} | ||
|
||
# Start development stack using docker compose, with optional arguments | ||
[no-cd] | ||
up *ARGS: | ||
docker compose up {{ ARGS }} | ||
|
||
# Start the full production stack using docker compose | ||
[no-cd] | ||
up-prod *ARGS: | ||
docker compose -f compose.yml -f compose.prod.yml up {{ ARGS }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
justfile := justfile_directory() + "/.just/documentation.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
# Build documentation using Sphinx | ||
[no-cd] | ||
build LOCATION="docs/_build/html": cog | ||
sphinx-build docs {{ LOCATION }} | ||
|
||
# Install documentation dependencies | ||
[no-cd] | ||
install: | ||
$python -m uv pip install --upgrade -r docs/requirements.txt | ||
|
||
# Generate documentation requirements | ||
[no-cd] | ||
lock *ARGS: | ||
$python -m uv pip compile {{ ARGS }} --generate-hashes docs/requirements.in --output-file docs/requirements.txt | ||
|
||
# Serve documentation locally | ||
[no-cd] | ||
serve: cog | ||
#!/usr/bin/env sh | ||
if [ -f "/.dockerenv" ]; then | ||
sphinx-autobuild docs docs/_build/html --host "0.0.0.0" | ||
else | ||
sphinx-autobuild docs docs/_build/html --host "localhost" | ||
fi | ||
# Generate and upgrade documentation dependencies | ||
upgrade: | ||
@just lock --upgrade | ||
|
||
[private] | ||
[no-cd] | ||
cog: | ||
cog -r docs/just.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
justfile := justfile_directory() + "/.just/node.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
# Install dependencies | ||
[no-cd] | ||
install *ARGS: | ||
npm install | ||
|
||
# Generate package-lock.json file | ||
[no-cd] | ||
lock: | ||
npm install --package-lock-only | ||
|
||
# Update dependencies | ||
[no-cd] | ||
update: | ||
npm update | ||
|
||
# Generate and upgrade dependencies | ||
[no-cd] | ||
upgrade: | ||
npm upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
justfile := justfile_directory() + "/.just/postgres.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
DATABASE_URL := env_var("DATABASE_URL") | ||
|
||
# Dump our local database to file | ||
dump database_url=DATABASE_URL file='db.dump': | ||
just docker run db "" \ | ||
pg_dump \ | ||
--dbname {{ database_url }} \ | ||
--file /app/{{ file }} \ | ||
--format=c \ | ||
--verbose | ||
|
||
# Dump our production database to file | ||
dump-prod file='production.dump': | ||
set PROD_DATABASE_URL := "{{ env_var('PROD_DATABASE_URL') }}" | ||
@just pg_dump ${PROD_DATABASE_URL} {{ file }} | ||
|
||
# Restore database backup to our local database | ||
restore database_url=DATABASE_URL file='db.dump': | ||
just docker run db "" \ | ||
pg_restore \ | ||
--clean \ | ||
--dbname {{ database_url }} \ | ||
--if-exists \ | ||
--no-owner \ | ||
--verbose \ | ||
/app/{{ file }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
justfile := justfile_directory() + "/.just/project.just" | ||
|
||
[private] | ||
default: | ||
@just --list --justfile {{ justfile }} | ||
|
||
[private] | ||
fmt: | ||
@just --fmt --justfile {{ justfile }} | ||
|
||
# Remove all installed dependencies, caches, and generated files | ||
[no-cd] | ||
clean: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
for dir in \ | ||
"$VIRTUAL_ENV" \ | ||
.mypy_cache \ | ||
.pytest_cache \ | ||
.ruff_cache \ | ||
htmlcov \ | ||
node_modules; do | ||
[ -d "$dir" ] && rm -rf "$dir" | ||
done | ||
find . -name "__pycache__" -exec rm -rf {} + | ||
# Create .env file from .env.example, if it doesn't exist | ||
[no-cd] | ||
envfile: | ||
#!/usr/bin/env python | ||
from pathlib import Path | ||
envfile = Path("{{ justfile_directory() }}/.env") | ||
envfile_example = Path("{{ justfile_directory() }}/.env.example") | ||
|
||
if not envfile.exists(): | ||
envfile.write_text(envfile_example.read_text()) | ||
|
||
# Sync .env file back to .env.example | ||
[no-cd] | ||
envsync: envfile | ||
#!/usr/bin/env python | ||
from pathlib import Path | ||
envfile = Path("{{ justfile_directory() }}/.env") | ||
envfile_example = Path("{{ justfile_directory() }}/.env.example") | ||
|
||
with envfile.open() as f: | ||
lines = [line for line in f.readlines() if not line.endswith("# envsync: ignore\n")] | ||
lines = [ | ||
line.split("=")[0] + "=\n" if line.endswith("# envsync: no-value\n") else line | ||
for line in lines | ||
] | ||
|
||
lines.sort() | ||
envfile_example.write_text("".join(lines)) | ||
|
||
[no-cd] | ||
[private] | ||
install-precommit: install-uv | ||
$python -m uv pip install -c {{ justfile_directory() }}/requirements.txt pre-commit | ||
$python -m pre_commit install --install-hooks | ||
|
||
[no-cd] | ||
[private] | ||
install-uv: | ||
$python -m pip install --upgrade uv | ||
|
||
# Format justfile | ||
just-fmt: | ||
@just --fmt | ||
@just copier fmt | ||
@just dj fmt | ||
@just docker fmt | ||
@just docs fmt | ||
@just node fmt | ||
@just pg fmt | ||
@just project fmt | ||
@just py fmt | ||
|
||
# Run pre-commit on all files | ||
[no-cd] | ||
lint: install-precommit | ||
$python -m pre_commit run --all-files | ||
@just project just-fmt | ||
|
||
# Setup project scaffolding | ||
setup: | ||
@just project envfile | ||
@just py venv | ||
@just project install-uv | ||
@just project install-precommit |
Oops, something went wrong.