🚀 MAJOR: Full migration to Just modules with modern features

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.
This commit is contained in:
sHa
2025-09-27 02:27:53 +03:00
parent c359858ee9
commit d3fec4b85a
11 changed files with 928 additions and 775 deletions

121
volumes/mod.just Normal file
View File

@@ -0,0 +1,121 @@
# Universal volume management operations
# Clean all volumes used by compose file (DESTRUCTIVE!)
[group('volumes')]
[confirm]
clean-all compose-file="":
#!/usr/bin/env bash
set -euo pipefail
compose_file="{{compose-file}}"
compose_cmd=$(just _detect_compose)
# Build compose file argument
file_arg=""
if [ -n "$compose_file" ]; then
file_arg="-f $compose_file"
fi
echo -e "{{RED}}⚠️ WARNING: This will DELETE ALL DATA!{{NORMAL}}"
echo -e "{{YELLOW}}This will remove all volumes defined in the compose file{{NORMAL}}"
# Show which volumes would be removed
echo -e "{{BLUE}}Volumes that will be removed:{{NORMAL}}"
$compose_cmd $file_arg config --volumes 2>/dev/null || echo "Cannot list volumes from compose file"
echo ""
echo -e "{{BLUE}}Stopping services...{{NORMAL}}"
$compose_cmd $file_arg down
echo -e "{{BLUE}}Removing volumes...{{NORMAL}}"
$compose_cmd $file_arg down -v
echo -e "{{GREEN}}✓ All volumes removed{{NORMAL}}"
# Remove specific volume by name (DESTRUCTIVE!)
[group('volumes')]
[confirm]
remove volume_name:
#!/usr/bin/env bash
set -euo pipefail
volume_name="{{volume_name}}"
if [ -z "$volume_name" ]; then
echo "{{BOLD}}{{RED}}Error:{{NORMAL}} Volume name is required" >&2
echo "{{YELLOW}}Usage:{{NORMAL}} just volumes remove my_volume_name" >&2
exit 1
fi
runtime=$(just _detect_runtime)
# Check if volume exists
if ! $runtime volume ls --format "table {{{{.Name}}}}" | grep -q "^${volume_name}$"; then
echo -e "{{YELLOW}}Volume '$volume_name' does not exist{{NORMAL}}"
exit 0
fi
echo -e "{{RED}}⚠️ WARNING: This will DELETE VOLUME DATA!{{NORMAL}}"
echo -e "{{YELLOW}}This will remove volume: $volume_name{{NORMAL}}"
echo -e "{{BLUE}}Removing volume: $volume_name{{NORMAL}}"
$runtime volume rm "$volume_name" 2>/dev/null || true
echo -e "{{GREEN}}✓ Volume '$volume_name' removed{{NORMAL}}"
# Remove volumes matching pattern (DESTRUCTIVE!)
[group('volumes')]
[confirm]
remove-pattern pattern:
#!/usr/bin/env bash
set -euo pipefail
pattern="{{pattern}}"
if [ -z "$pattern" ]; then
echo "{{BOLD}}{{RED}}Error:{{NORMAL}} Volume pattern is required" >&2
echo "{{YELLOW}}Usage:{{NORMAL}} just volumes remove-pattern 'myproject_*'" >&2
exit 1
fi
runtime=$(just _detect_runtime)
# Find matching volumes
matching_volumes=$($runtime volume ls --format "table {{{{.Name}}}}" | grep "$pattern" || true)
if [ -z "$matching_volumes" ]; then
echo -e "{{YELLOW}}No volumes found matching pattern: $pattern{{NORMAL}}"
exit 0
fi
echo -e "{{RED}}⚠️ WARNING: This will DELETE VOLUME DATA!{{NORMAL}}"
echo -e "{{YELLOW}}Volumes matching pattern '$pattern':{{NORMAL}}"
echo "$matching_volumes"
echo ""
echo -e "{{BLUE}}Removing matching volumes...{{NORMAL}}"
echo "$matching_volumes" | while IFS= read -r volume; do
if [ -n "$volume" ]; then
echo "Removing: $volume"
$runtime volume rm "$volume" 2>/dev/null || true
fi
done
echo -e "{{GREEN}}✓ Matching volumes removed{{NORMAL}}"
# List all volumes or filter by pattern
[group('volumes')]
list pattern="":
#!/usr/bin/env bash
set -euo pipefail
pattern="{{pattern}}"
runtime=$(just _detect_runtime)
if [ -n "$pattern" ]; then
echo -e "{{BLUE}}Volumes matching pattern '$pattern':{{NORMAL}}"
$runtime volume ls | grep "$pattern" || echo "No volumes found matching pattern: $pattern"
else
echo -e "{{BLUE}}All volumes:{{NORMAL}}"
$runtime volume ls
fi