Skip to content

[no-task] Translate Pvm Script To English #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions pvm.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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