Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add common subcommands to the top-level Justfile #275

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 62 additions & 8 deletions src/django_twc_project/Justfile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,46 @@ clean:
@just project clean
@just docker clean

# Open a bash shell within a specified container (default: 'app')
shell CONTAINER="app":
# Open a bash console within a specified container (default: 'app')
console CONTAINER="app":
@just docker run {% raw %}{{ CONTAINER }}{% endraw %} "" "/bin/bash"

# Start development server
server:
# Stop local development environment
down:
@just docker down

# Run the linters on all files in project
lint:
@just project lint

# Generate lockfiles for all dependencies
lock:
@just py lock
@just node lock

# Print out the logs of all Docker containers, optionally specifying a container to focus on
logs *ARGS:
@just docker logs {{ ARGS }}

# Run Django migrations
migrate *ARGS:
@just dj migrate {{ ARGS }}

alias mm := makemigrations

# Generate Django migrations
makemigrations *ARGS:
@just dj makemigrations {{ ARGS }}

# Run a Django management command
manage *COMMAND:
@just dj manage {{ COMMAND }}

# Refresh local development environment
refresh:
@just docker stop
@just bootstrap
@just docker up
@just docker start

# Setup local development environment
setup:
Expand All @@ -55,8 +86,8 @@ setup:
@just project lint
@just docker down

# Open a tool's interative console within a specified container (default: 'app')
console CONTAINER="app" COMMAND="":
# Open a tool's interative shell within a specified container (default: 'app')
shell CONTAINER="app" COMMAND="":
#!/usr/bin/env bash
set -euo pipefail
if [ {% raw %}{{ CONTAINER }}{% endraw %} = 'db' ]; then
Expand All @@ -65,19 +96,42 @@ console CONTAINER="app" COMMAND="":
COMMAND="node"
elif [ "{% raw %}{{ CONTAINER }}{% endraw %}" = "app" ] || [ "{% raw %}{{ CONTAINER }}{% endraw %}" = "worker" ]; then
COMMAND="ipython"
elif [ {% raw %}{{ CONTAINER }}{% endraw %} = 'dj' ]; then
COMMAND="python -m manage shell_plus"
fi
[ -n "{% raw %}{{ COMMAND }}{% endraw %}" ] && COMMAND="{% raw %}{{ COMMAND }}{% endraw %}"
COMMAND="${COMMAND:-/bin/bash}"
just docker run {% raw %}{{ CONTAINER }}{% endraw %} "" $COMMAND

# Run all tests
# Start local development environment in background
start:
@just docker start

# Stop local development environment
stop:
@just docker stop

# Follow the logs of all Docker containers, optionally specifying a container to focus on
tail *ARGS:
@just docker tail {{ ARGS }}

# Run entire test suite, including generating code coverage
test:
@just py test
@just py coverage-html

# Start local development environment in foreground
up:
@just docker up

# Update local development environment
update:
@just docker pull
@just py lock
@just node lock
@just bootstrap

# Upgrade all dependencies to their newest versions
upgrade:
@just py upgrade
@just node upgrade