Fix pre-commit script to properly handle multiple files and resolve ESLint warnings

This commit is contained in:
William Valentin
2025-09-07 13:34:39 -07:00
parent 8fa2d3fb60
commit 315303b120
33 changed files with 561 additions and 404 deletions

View File

@@ -10,31 +10,31 @@ echo "🚀 Starting deploymif docker compose -f docker/docker-compose.yaml -p rx
else
print_error "Docker Compose services failed to start"
docker compose -f docker/docker-compose.yaml -p rxminder-validation logsalidation..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Cleanup function
cleanup() {
print_status "Cleaning up test containers..."
@@ -42,48 +42,48 @@ else
docker rm rxminder-validation-test 2>/dev/null || true
docker compose -f docker/docker-compose.yaml -p rxminder-validation down 2>/dev/null || true
}
# Set trap for cleanup
trap cleanup EXIT
print_status "1. Validating environment files..."
# Check if required environment files exist
if [[ ! -f .env ]]; then
print_error ".env file not found. Run 'cp .env.example .env' and configure it."
exit 1
fi
if [[ ! -f .env.example ]]; then
print_error ".env.example file not found."
exit 1
fi
print_success "Environment files exist"
# Validate environment consistency
print_status "2. Checking environment variable consistency..."
./validate-env.sh
print_status "3. Setting up Docker Buildx..."
# Ensure buildx is available
if ! docker buildx version >/dev/null 2>&1; then
print_error "Docker Buildx is not available. Please update Docker to a version that supports Buildx."
exit 1
fi
# Create a new builder instance if it doesn't exist
if ! docker buildx ls | grep -q "rxminder-builder"; then
print_status "Creating new buildx builder instance..."
docker buildx create --name rxminder-builder --driver docker-container --bootstrap
fi
# Use the builder
docker buildx use rxminder-builder
print_status "4. Building multi-platform Docker image with buildx..."
# Build the image with buildx for multiple platforms
docker buildx build --no-cache \
--platform linux/amd64,linux/arm64 \
@@ -102,29 +102,29 @@ else
-t rxminder-validation \
--load \
.
print_success "Docker image built successfully"
print_status "5. Testing container startup and health..."
# Run container in background
docker run --rm -d \
-p 8083:80 \
--name rxminder-validation-test \
rxminder-validation
# Wait for container to start
sleep 5
# Check if container is running
if ! docker ps | grep -q rxminder-validation-test; then
print_error "Container failed to start"
docker logs rxminder-validation-test
exit 1
fi
print_success "Container started successfully"
# Test health endpoint
print_status "5. Testing health endpoint..."
for i in {1..10}; do
@@ -139,7 +139,7 @@ else
sleep 2
fi
done
# Test main application
print_status "6. Testing main application..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8083)
@@ -149,20 +149,20 @@ else
print_error "Main application not responding properly (HTTP $HTTP_CODE)"
exit 1
fi
# Test docker-compose build
print_status "7. Testing Docker Compose build..."
docker compose -f docker/docker-compose.yaml build frontend --no-cache
print_success "Docker Compose build successful"
# Test docker-compose with validation project name
print_status "8. Testing Docker Compose deployment..."
docker compose -f docker/docker-compose.yaml -p rxminder-validation up -d --build
# Wait for services to start
sleep 10
# Check service health
if docker compose -f docker/docker-compose.yaml -p meds-validation ps | grep -q "Up"; then
print_success "Docker Compose services started successfully"
@@ -171,20 +171,20 @@ else
docker compose -f docker/docker-compose.yaml -p meds-validation logs
exit 1
fi
# Test health of compose deployment
if curl -s -f http://localhost:8080/health > /dev/null; then
print_success "Docker Compose health endpoint responding"
else
print_warning "Docker Compose health endpoint not responding (may need CouchDB)"
fi
print_status "9. Checking image size..."
IMAGE_SIZE=$(docker image inspect rxminder-validation --format='{{.Size}}' | numfmt --to=iec)
print_success "Image size: $IMAGE_SIZE"
print_status "10. Validating security configuration..."
# Check if image runs as non-root
USER_INFO=$(docker run --rm rxminder-validation whoami)
if [[ "$USER_INFO" != "root" ]]; then
@@ -192,7 +192,7 @@ else
else
print_warning "Container runs as root user (security consideration)"
fi
# Check nginx configuration
if docker run --rm rxminder-validation nginx -t 2>/dev/null; then
print_success "Nginx configuration is valid"
@@ -200,9 +200,9 @@ else
print_error "Nginx configuration has issues"
exit 1
fi
print_status "11. Final validation complete!"
echo
echo "🎉 Deployment validation successful!"
echo
@@ -223,4 +223,4 @@ else
echo "3. Set up monitoring and backups"
echo "4. Configure SSL/TLS certificates"
echo