From ecaacc48faa325fb69f87549816090600341f60f Mon Sep 17 00:00:00 2001 From: CarterPerez-dev Date: Fri, 1 May 2026 14:53:28 -0400 Subject: [PATCH] chore(monitor): replace Makefile with Justfile (project convention) --- .../monitor-the-situation-dashboard/Justfile | 231 ++++++++++++++++++ .../monitor-the-situation-dashboard/Makefile | 107 -------- 2 files changed, 231 insertions(+), 107 deletions(-) create mode 100644 PROJECTS/advanced/monitor-the-situation-dashboard/Justfile delete mode 100644 PROJECTS/advanced/monitor-the-situation-dashboard/Makefile diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/Justfile b/PROJECTS/advanced/monitor-the-situation-dashboard/Justfile new file mode 100644 index 00000000..ffc21484 --- /dev/null +++ b/PROJECTS/advanced/monitor-the-situation-dashboard/Justfile @@ -0,0 +1,231 @@ +# ©AngelaMos | 2026 +# Justfile + +set export +set shell := ["bash", "-uc"] + +project := file_name(justfile_directory()) +version := `git describe --tags --always 2>/dev/null || echo "dev"` +binary := "monitor" + +# ============================================================================= +# Default +# ============================================================================= + +default: + @just --list --unsorted + +# ============================================================================= +# Linting and Formatting +# ============================================================================= + +[group('lint')] +lint *ARGS: + cd backend && golangci-lint run --timeout=5m {{ARGS}} + +[group('lint')] +lint-fix: + cd backend && golangci-lint run --timeout=5m --fix + +[group('lint')] +format: + cd backend && gofumpt -w . && goimports -w . + +[group('lint')] +tidy: + cd backend && go mod tidy + +[group('lint')] +vet: + cd backend && go vet ./... + +# ============================================================================= +# Testing +# ============================================================================= + +[group('test')] +test *ARGS: + cd backend && go test -race ./... {{ARGS}} + +[group('test')] +test-v *ARGS: + cd backend && go test -race -v ./... {{ARGS}} + +[group('test')] +cover: + cd backend && go test -race -cover ./... + +# ============================================================================= +# CI / Quality +# ============================================================================= + +[group('ci')] +ci: lint test + @echo "All checks passed." + +[group('ci')] +check: lint vet + +# ============================================================================= +# Development (host go) +# ============================================================================= + +[group('dev')] +run *ARGS: + cd backend && go run ./cmd/api {{ARGS}} + +[group('dev')] +dev-serve: + cd backend && go run ./cmd/api -config config.yaml + +# ============================================================================= +# Build (Production) +# ============================================================================= + +[group('prod')] +build: + cd backend && go build -ldflags="-s -w" -o ../bin/{{binary}} ./cmd/api + @echo "Built: bin/{{binary}} ($(du -h bin/{{binary}} | cut -f1))" + +[group('prod')] +build-static: + cd backend && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ../bin/{{binary}} ./cmd/api + @echo "Built static: bin/{{binary}} ($(du -h bin/{{binary}} | cut -f1))" + +[group('prod')] +build-debug: + cd backend && go build -o ../bin/{{binary}} ./cmd/api + +[group('prod')] +install: + cd backend && go install ./cmd/api + +# ============================================================================= +# Database +# ============================================================================= + +[group('db')] +migrate *ARGS: + docker compose -f compose.yml exec backend sh -c 'goose -dir /migrations postgres "$DATABASE_URL" up' {{ARGS}} + +[group('db')] +migrate-dev *ARGS: + docker compose -f dev.compose.yml exec backend sh -c 'cd /app && goose -dir migrations postgres "$DATABASE_URL" up' {{ARGS}} + +[group('db')] +migrate-down: + docker compose -f dev.compose.yml exec backend sh -c 'cd /app && goose -dir migrations postgres "$DATABASE_URL" down' + +[group('db')] +migrate-status: + docker compose -f dev.compose.yml exec backend sh -c 'cd /app && goose -dir migrations postgres "$DATABASE_URL" status' + +[group('db')] +psql: + docker compose -f dev.compose.yml exec postgres psql -U $${POSTGRES_USER:-monitor} -d $${POSTGRES_DB:-monitor} + +[group('db')] +redis-cli: + docker compose -f dev.compose.yml exec redis redis-cli + +# ============================================================================= +# Docker (production) +# ============================================================================= + +[group('docker')] +up *ARGS: + docker compose -f compose.yml up {{ARGS}} + +[group('docker')] +start *ARGS: + docker compose -f compose.yml up -d --build {{ARGS}} + +[group('docker')] +down *ARGS: + docker compose -f compose.yml down {{ARGS}} + +[group('docker')] +logs *SERVICE: + docker compose -f compose.yml logs -f {{SERVICE}} + +[group('docker')] +ps: + docker compose -f compose.yml ps + +[group('docker')] +build-prod: + docker compose -f compose.yml build + +# ============================================================================= +# Docker (development) +# ============================================================================= + +[group('docker')] +dev-up *ARGS: + docker compose -f dev.compose.yml up {{ARGS}} + +[group('docker')] +dev-start *ARGS: + docker compose -f dev.compose.yml up -d --build {{ARGS}} + +[group('docker')] +dev-down *ARGS: + docker compose -f dev.compose.yml down {{ARGS}} + +[group('docker')] +dev-logs *SERVICE: + docker compose -f dev.compose.yml logs -f {{SERVICE}} + +[group('docker')] +dev-ps: + docker compose -f dev.compose.yml ps + +[group('docker')] +dev-shell service='backend': + docker compose -f dev.compose.yml exec -it {{service}} /bin/sh + +[group('docker')] +dev-clean: + docker compose -f dev.compose.yml down -v + +# ============================================================================= +# Cloudflare Tunnel +# ============================================================================= + +[group('tunnel')] +tunnel-up *ARGS: + docker compose -f compose.yml -f cloudflared.compose.yml up {{ARGS}} + +[group('tunnel')] +tunnel-start *ARGS: + docker compose -f compose.yml -f cloudflared.compose.yml up -d --build {{ARGS}} + +[group('tunnel')] +tunnel-down *ARGS: + docker compose -f compose.yml -f cloudflared.compose.yml down {{ARGS}} + +[group('tunnel')] +tunnel-logs: + docker compose -f compose.yml -f cloudflared.compose.yml logs -f cloudflared + +# ============================================================================= +# Utilities +# ============================================================================= + +[group('util')] +info: + @echo "Project: {{project}}" + @echo "Version: {{version}}" + @echo "Go: $(cd backend && go version | cut -d' ' -f3)" + @echo "OS: {{os()}} ({{arch()}})" + @echo "Module: $(head -1 backend/go.mod | cut -d' ' -f2)" + +[group('util')] +clean: + -rm -rf bin/ + -rm -rf backend/tmp/ + @echo "Cleaned build artifacts." + +[group('util')] +env-init: + @if [ ! -f .env ]; then cp .env.example .env && echo "created .env from .env.example — fill in secrets"; else echo ".env already exists"; fi diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/Makefile b/PROJECTS/advanced/monitor-the-situation-dashboard/Makefile deleted file mode 100644 index d929628f..00000000 --- a/PROJECTS/advanced/monitor-the-situation-dashboard/Makefile +++ /dev/null @@ -1,107 +0,0 @@ -# ©AngelaMos | 2026 -# Makefile - -.DEFAULT_GOAL := help -SHELL := /bin/bash - -COMPOSE_PROD := docker compose -f compose.yml -COMPOSE_DEV := docker compose -f dev.compose.yml -COMPOSE_TUN := docker compose -f compose.yml -f cloudflared.compose.yml - -.PHONY: help up up-dev up-tunnel down down-dev logs logs-dev ps ps-dev migrate migrate-dev psql redis-cli backend-shell frontend-shell tidy fmt test build-prod stop clean - -help: - @echo 'Monitor the Situation — Make targets:' - @echo '' - @echo ' Production:' - @echo ' up start production stack (no tunnel)' - @echo ' up-tunnel start production stack + cloudflared' - @echo ' down stop production stack' - @echo ' logs tail production logs' - @echo ' ps status of production services' - @echo '' - @echo ' Development:' - @echo ' up-dev start dev stack (vite + air)' - @echo ' down-dev stop dev stack' - @echo ' logs-dev tail dev logs' - @echo ' ps-dev status of dev services' - @echo '' - @echo ' Database:' - @echo ' migrate run goose migrations against prod db' - @echo ' migrate-dev run goose migrations against dev db' - @echo ' psql psql shell into dev db' - @echo ' redis-cli redis-cli shell into dev redis' - @echo '' - @echo ' Backend:' - @echo ' backend-shell shell into the dev backend container' - @echo ' test run all backend tests with -race' - @echo ' fmt format Go code' - @echo ' tidy go mod tidy' - @echo '' - @echo ' Frontend:' - @echo ' frontend-shell shell into the dev frontend container' - @echo '' - -up: - $(COMPOSE_PROD) up -d --build - -up-tunnel: - $(COMPOSE_TUN) up -d --build - -up-dev: - $(COMPOSE_DEV) up -d --build - -down: - $(COMPOSE_PROD) down - -down-dev: - $(COMPOSE_DEV) down - -logs: - $(COMPOSE_PROD) logs -f --tail=200 - -logs-dev: - $(COMPOSE_DEV) logs -f --tail=200 - -ps: - $(COMPOSE_PROD) ps - -ps-dev: - $(COMPOSE_DEV) ps - -migrate: - $(COMPOSE_PROD) exec backend sh -c 'goose -dir /migrations postgres "$$DATABASE_URL" up' - -migrate-dev: - $(COMPOSE_DEV) exec backend sh -c 'cd /app && goose -dir migrations postgres "$$DATABASE_URL" up' - -psql: - $(COMPOSE_DEV) exec postgres psql -U $${POSTGRES_USER:-monitor} -d $${POSTGRES_DB:-monitor} - -redis-cli: - $(COMPOSE_DEV) exec redis redis-cli - -backend-shell: - $(COMPOSE_DEV) exec backend sh - -frontend-shell: - $(COMPOSE_DEV) exec frontend sh - -test: - cd backend && go test -race -count=1 ./... - -fmt: - cd backend && gofumpt -w . && goimports -w . - -tidy: - cd backend && go mod tidy - -build-prod: - $(COMPOSE_PROD) build - -stop: - $(COMPOSE_DEV) stop ; $(COMPOSE_PROD) stop - -clean: stop - $(COMPOSE_DEV) down -v - $(COMPOSE_PROD) down -v