diff --git a/pvm.sh b/pvm.sh index 4cfa6d34dda..3d73ffb578b 100755 --- a/pvm.sh +++ b/pvm.sh @@ -1,47 +1,47 @@ #!/bin/bash -# Verificar si Homebrew está instalado +# Check if Homebrew is installed if ! command -v brew &> /dev/null; then - echo "❌ Homebrew no está instalado. Por favor, instálalo desde https://brew.sh/" + echo "❌ Homebrew is not installed. Please install it from https://brew.sh/" exit 1 fi -# Verificar si jq está instalado +# Check if jq is installed if ! command -v jq &> /dev/null; then - echo "❌ El script requiere 'jq'. Instalalo con 'brew install jq'." + echo "❌ The script requires 'jq'. Install it with 'brew install jq'." exit 1 fi -# Obtener la versión de PHP desde composer.json +# Get PHP version from composer.json PHP_VERSION=$(cat composer.json | grep '"php":' | awk -F'"' '{print $4}' | sed 's/\^//') if [ -z "$PHP_VERSION" ]; then - echo "❌ No se encontró la versión de PHP en composer.json" + echo "❌ PHP version not found in composer.json" exit 1 fi -echo "🔍 Versión de PHP requerida: $PHP_VERSION" +echo "🔍 Required PHP version: $PHP_VERSION" -# Obtener la versión estable actual de PHP en Homebrew +# Get current stable PHP version from Homebrew LATEST_PHP_VERSION_FULL=$(brew info php --json | jq -r '.[0].versions.stable') LATEST_PHP_VERSION=$(echo "$LATEST_PHP_VERSION_FULL" | cut -d'.' -f1,2) -# Usar la fórmula correcta según si es la versión latest o no +# Use the correct formula depending on whether it's the latest version or not if [[ "$PHP_VERSION" == "$LATEST_PHP_VERSION" ]]; then BREW_PHP_VERSION="php" else BREW_PHP_VERSION="php@$PHP_VERSION" fi -# Comprobar si la versión ya está instalada +# Check if the version is already installed if brew list --formula | grep -q "^$BREW_PHP_VERSION\$"; then - echo "✅ La versión $PHP_VERSION ya está instalada." + echo "✅ Version $PHP_VERSION is already installed." else - echo "⚠️ La versión $PHP_VERSION no está instalada. Instalándola ahora..." + echo "⚠️ Version $PHP_VERSION is not installed. Installing now..." brew install $BREW_PHP_VERSION fi -# Obtener la versión actual de PHP activa en el sistema +# Get the current active PHP version in the system CURRENT_PHP_VERSION=$(php -v | head -n 1 | awk '{print $2}' | cut -d'.' -f1,2) if [[ "$CURRENT_PHP_VERSION" == "$LATEST_PHP_VERSION" ]]; then @@ -50,14 +50,14 @@ else BREW_CURRENT_PHP="php@$CURRENT_PHP_VERSION" fi -# Si no coincide la versión activa, cambiarla +# If active version doesn't match, change it if [ "$BREW_CURRENT_PHP" != "$BREW_PHP_VERSION" ]; then - echo "🔄 Cambiando de PHP $CURRENT_PHP_VERSION a PHP $PHP_VERSION..." + echo "🔄 Switching from PHP $CURRENT_PHP_VERSION to PHP $PHP_VERSION..." brew unlink $BREW_CURRENT_PHP brew link --force --overwrite $BREW_PHP_VERSION else - echo "✅ PHP ya está en la versión correcta ($PHP_VERSION)." + echo "✅ PHP is already at the correct version ($PHP_VERSION)." fi -# Mostrar la versión actual después del cambio +# Show current version after the change php -v