set shell := ["bash", "-cu"]
assets_dir := "assets"
tailwind := "./node_modules/.bin/tailwindcss"
esbuild := "./node_modules/.bin/esbuild"
css_in := "f/css/style.css"
css_out := "f/css/app.css"
js_in := "f/js/src.js"
js_out := "f/js/app.js"
# Default: list available recipes
default:
@just --list
# Install JS deps (run once after cloning)
deps:
cd {{assets_dir}} && npm install
# One-shot CSS + JS build + sync vendored webfonts
assets: webfonts js
cd {{assets_dir}} && {{tailwind}} -c tailwind.config.js -i {{css_in}} -o {{css_out}}
# Bundle + minify JS (src.js -> app.js)
js:
cd {{assets_dir}} && {{esbuild}} {{js_in}} --bundle --minify --outfile={{js_out}}
# Watch CSS for changes; webfonts/JS rebuild on dep/source change
watch: webfonts js
cd {{assets_dir}} && {{tailwind}} -c tailwind.config.js -i {{css_in}} -o {{css_out}} --watch
# Tailwind rescans templates/ so new utility classes appear automatically;
# minijinja hot-reloads templates, so edits show on a browser refresh (no
# restart). Restart only for Rust changes. Ctrl-C stops everything.
# Run `just db-up` first. Run this in a real terminal (watchers follow stdin).
# Frontend dev loop: watch+rebuild CSS/JS and run the server together
dev: assets
#!/usr/bin/env bash
set -euo pipefail
cd {{assets_dir}}
{{tailwind}} -c tailwind.config.js -i {{css_in}} -o {{css_out}} --watch &
tw=$!
{{esbuild}} {{js_in}} --bundle --outfile={{js_out}} --watch &
es=$!
cd ..
trap 'kill $tw $es 2>/dev/null' EXIT INT TERM
echo "▶ assets watching (tailwind+esbuild); starting server…"
cargo run
# Copy vendored fonts into the served /assets tree.
webfonts:
mkdir -p {{assets_dir}}/f/webfonts
cp -u {{assets_dir}}/node_modules/@fortawesome/fontawesome-free/webfonts/*.woff2 {{assets_dir}}/f/webfonts/
cp -u {{assets_dir}}/node_modules/@fortawesome/fontawesome-free/webfonts/*.ttf {{assets_dir}}/f/webfonts/
# Apply pending DB migrations
migrate:
cargo run -p migration -- up
# Run the webservice (auto-migrates by default)
serve:
cargo run
# Admin CLI passthrough. Usage: just manage user list
manage *args:
cargo run --bin manage -- {{args}}
# Create a staff account directly (prints a generated password once).
# Usage: just admin <username> <email>
admin username email:
cargo run --bin manage -- user create {{username}} --email {{email}} --staff
# Generate an invite token. Usage: just invite [days]
invite days="7":
cargo run --bin manage -- invite create --days {{days}}
# Grant staff/admin. Usage: just staff <username> (add --revoke to remove)
staff username *flags:
cargo run --bin manage -- user set-staff {{username}} {{flags}}
# Set a user's trust level 0-4. Usage: just trust <username> <level>
trust username level:
cargo run --bin manage -- user set-trust {{username}} {{level}}
# Lint + test (unit only)
check:
cargo check --bins --lib
cargo test --lib
# The /api/v1 tests against a real database (tests/api_db.rs). They create
# their own rows with unique names, but use a scratch database, not your dev one:
# podman exec recourse_postgres createdb -U recourse_user recourse_test
test-db url="postgres://recourse_user:recourse_password@localhost:5439/recourse_test":
TEST_DATABASE_URL={{url}} cargo test --test api_db
# Re-capture the API responses the Android ContractTest decodes (needs the test database)
fixtures url="postgres://recourse_user:recourse_password@localhost:5439/recourse_test":
TEST_DATABASE_URL={{url}} WRITE_ANDROID_FIXTURES=1 cargo test --test api_db android_fixtures
# A fresh database (no users yet) is also migrated and given demo content
# (`seed --demo`); an existing one is left alone.
# Bring up just Postgres for local dev (fresh DB: migrate + seed --demo)
db-up:
#!/usr/bin/env bash
set -euo pipefail
podman compose up -d postgres
for _ in $(seq 1 30); do
podman exec recourse_postgres pg_isready -U recourse_user -d recourse >/dev/null 2>&1 && break
sleep 1
done
users=$(podman exec recourse_postgres psql -U recourse_user -d recourse -tAc \
"SELECT CASE WHEN to_regclass('public.users') IS NULL THEN 0 ELSE (SELECT count(*) FROM users) END")
if [ "$users" = "0" ]; then
echo "▶ fresh database: migrating and seeding demo content"
cargo run -p migration -- up
cargo run --bin manage -- seed --demo
fi
# Baseline categories (3 levels), reaction types and tags. Idempotent; fine in production.
seed:
cargo run --bin manage -- seed
# Baseline + demo accounts and conversations. Development only.
seed-demo:
cargo run --bin manage -- seed --demo
# Build the runtime image
build-image:
podman compose build webservice
# Bring up the full stack (postgres + webservice)
up:
podman compose up -d
down:
podman compose down
# Tail webservice logs
logs:
podman compose logs -f webservice
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
4.8 KiB · text
History
63417ef