mirror of
https://github.com/shadoll/just-commons.git
synced 2025-12-20 03:26:43 +00:00
BREAKING CHANGES: - Complete restructure to Just module architecture (requires Just 1.31.0+) - Command syntax changed: 'just postgres-sql' → 'just postgres sql' - Import syntax changed: import → mod declarations NEW FEATURES: ✨ Module-based architecture with optional modules ✨ Built-in Just colors ({{RED}}, {{GREEN}}, etc.) replace custom variables ✨ Enhanced [confirm] attributes for all destructive operations ✨ Organized [group('name')] attributes for better UX ✨ Modern justfile with comprehensive help system ✨ Updated documentation with migration guide MODULES: 📦 postgres/ - PostgreSQL operations (sql, check, create-database, etc.) 📦 mysql/ - MySQL operations (sql, check, create-user, etc.) 📦 volumes/ - Volume management (clean-all, remove, list) 📦 container/ - Container operations (start, stop, logs, shell, exec) 📦 registry/ - Registry auth (login, logout, check) 📦 images/ - Image operations (build, push, pull, tag, clean) USAGE: just postgres sql "SELECT version();" just volumes clean-all just images build myapp This is Just Commons v2.0 - a complete modernization using all of Just's latest features.
95 lines
3.3 KiB
Plaintext
95 lines
3.3 KiB
Plaintext
# Core utilities shared across all just-commons modules
|
|
|
|
# Detect container runtime (Docker or Podman)
|
|
_detect_runtime:
|
|
#!/usr/bin/env bash
|
|
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
|
|
echo "docker"
|
|
elif command -v podman >/dev/null 2>&1; then
|
|
echo "podman"
|
|
else
|
|
echo "Error: No container runtime available (docker or podman)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Detect compose command based on available and working container runtime
|
|
_detect_compose:
|
|
#!/usr/bin/env bash
|
|
# Check Docker first - but make sure daemon is actually running
|
|
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
|
|
# Docker daemon is running, check for compose
|
|
if docker compose version >/dev/null 2>&1; then
|
|
echo "docker compose"
|
|
elif command -v docker-compose >/dev/null 2>&1; then
|
|
echo "docker-compose"
|
|
else
|
|
echo "Error: Docker is running but no compose tool found" >&2
|
|
exit 1
|
|
fi
|
|
# Check Podman if Docker is not available or not running
|
|
elif command -v podman >/dev/null 2>&1; then
|
|
if command -v podman-compose >/dev/null 2>&1; then
|
|
echo "podman-compose"
|
|
else
|
|
echo "Error: Podman found but podman-compose not available" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Error: No container runtime (Docker or Podman) found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Environment detection and validation
|
|
[group('environment')]
|
|
env-check:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
|
|
echo "================================================"
|
|
echo " Container Environment Detection"
|
|
echo "================================================"
|
|
echo ""
|
|
|
|
# Check Docker
|
|
if command -v docker >/dev/null 2>&1; then
|
|
if docker info >/dev/null 2>&1; then
|
|
echo -e "{{GREEN}}✓ Docker Engine detected and running{{NORMAL}}"
|
|
docker_available=true
|
|
else
|
|
echo -e "{{YELLOW}}⚠ Docker is installed but daemon is not running{{NORMAL}}"
|
|
docker_available=false
|
|
fi
|
|
else
|
|
echo -e "{{RED}}✗ Docker not found{{NORMAL}}"
|
|
docker_available=false
|
|
fi
|
|
|
|
# Check Podman
|
|
if command -v podman >/dev/null 2>&1; then
|
|
echo -e "{{GREEN}}✓ Podman detected{{NORMAL}}"
|
|
podman_available=true
|
|
else
|
|
echo -e "{{RED}}✗ Podman not found{{NORMAL}}"
|
|
podman_available=false
|
|
fi
|
|
|
|
echo ""
|
|
echo "================================================"
|
|
echo " SUMMARY"
|
|
echo "================================================"
|
|
|
|
if [ "$docker_available" = true ] || [ "$podman_available" = true ]; then
|
|
echo -e "{{GREEN}}🎉 Container runtime available!{{NORMAL}}"
|
|
echo ""
|
|
echo "You can use these universal commands:"
|
|
echo " just images build <project> # Build any project image"
|
|
echo " just container start <service> # Start any service"
|
|
echo " just registry login # Login to registry"
|
|
else
|
|
echo -e "{{RED}}❌ No container runtime available{{NORMAL}}"
|
|
echo ""
|
|
echo "Please install Docker or Podman:"
|
|
echo " • Docker: https://docs.docker.com/get-docker/"
|
|
echo " • Podman: https://podman.io/getting-started/installation"
|
|
fi |