From 3ac43ff7a016ba51223718973892e2f0b0ed668a Mon Sep 17 00:00:00 2001 From: "Mauro Rosero P." Date: Sat, 5 Apr 2025 19:31:35 -0500 Subject: [PATCH] [ADDED] Soporte para glow (Charm Markdown renderer) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Añadida función para instalar Glow (renderizador de Markdown) - Integrado en bootstrap.sh para instalación automática - Actualizado README.md para reflejar nueva herramienta - Usa repositorios oficiales de Charm cuando están disponibles - Alternativa con instalación de binarios para sistemas sin repo oficial 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- README.md | 2 +- bin/bootstrap.sh | 9 ++++++ bin/lib/bootstrap.lib | 71 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a50bd31..7ffaa97 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ MRDevs Tools utiliza una estructura organizada que separa el código (en ~/devs) | Comando | Descripción | |---------|-------------| -| `bin/bootstrap.sh` | Instala herramientas básicas (incluyendo oathtool, zbar, redis-cli y gum) y configura la gestión de contenedores | +| `bin/bootstrap.sh` | Instala herramientas básicas (incluyendo oathtool, zbar, redis-cli, gum y glow) y configura la gestión de contenedores | | `bin/update.sh` | Actualiza el entorno de desarrollo y herramientas (incluyendo oathtool, zbar, redis-cli y gum) | | `bin/npm_install.sh` | Instala NodeJS y npm de forma interactiva | | `bin/project_new.sh` | Crea un nuevo proyecto con estructura estandarizada según el tipo seleccionado | diff --git a/bin/bootstrap.sh b/bin/bootstrap.sh index 538c907..814b520 100755 --- a/bin/bootstrap.sh +++ b/bin/bootstrap.sh @@ -90,6 +90,7 @@ install() { local ZBAR_PACKAGE=zbar local REDIS_CLI_PACKAGE=redis-tools local GUM_PACKAGE=gum + local GLOW_PACKAGE=glow # Load base bash library BIN_HOME=$BIN_PATH @@ -239,6 +240,14 @@ install() { echo "Instalando gum..." gum_install fi + + # Install glow if not already installed + command_installed glow + if [ $? -ne 0 ] + then + echo "Instalando glow..." + glow_install + fi } diff --git a/bin/lib/bootstrap.lib b/bin/lib/bootstrap.lib index 24f85e4..de80a78 100755 --- a/bin/lib/bootstrap.lib +++ b/bin/lib/bootstrap.lib @@ -513,3 +513,74 @@ gpgkey=https://repo.charm.sh/yum/gpg.key' | tee /etc/yum.repos.d/charm.repo echo "gum instalado correctamente." return 0 } + +# Install glow package (Markdown renderer) +function glow_install() { + echo "Instalando glow (renderizador de Markdown para terminal)..." + + if [ "$(uname)" == "Darwin" ]; then + # En macOS, instalamos a través de Homebrew + brew install glow + elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then + # En sistemas Debian y derivados + mkdir -p /etc/apt/keyrings + curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg + echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" > /etc/apt/sources.list.d/charm.list + apt update + apt install -y glow + elif [ -f /etc/redhat-release ]; then + # En sistemas Red Hat + echo '[charm] +name=Charm +baseurl=https://repo.charm.sh/yum/ +enabled=1 +gpgcheck=1 +gpgkey=https://repo.charm.sh/yum/gpg.key' | tee /etc/yum.repos.d/charm.repo + dnf install -y glow + elif [ -f /etc/arch-release ]; then + # En Arch Linux, instalamos desde AUR + command_installed "yay" + if [ $? -ne 0 ]; then + echo "Instalando yay para acceder a AUR..." + pacman -Sy --noconfirm git base-devel + git clone https://aur.archlinux.org/yay.git /tmp/yay + cd /tmp/yay + makepkg -si --noconfirm + cd - > /dev/null + rm -rf /tmp/yay + fi + yay -S --noconfirm glow + elif [ -f /etc/rc.conf ]; then + # En FreeBSD + pkg install -y glow + else + # Para otros sistemas, descargamos el binario precompilado + local arch=$(uname -m) + local os=$(uname -s | tr '[:upper:]' '[:lower:]') + local latest_version=$(curl -s https://api.github.com/repos/charmbracelet/glow/releases/latest | grep -oP '"tag_name": "\K[^"]+') + + # Convertir arquitectura para compatibilidad con las versiones de GitHub + case $arch in + x86_64) arch="amd64" ;; + aarch64|arm64) arch="arm64" ;; + armv7*) arch="armv7" ;; + esac + + # Descargar el binario adecuado + local download_url="https://github.com/charmbracelet/glow/releases/download/${latest_version}/glow_${latest_version#v}_${os}_${arch}.tar.gz" + cd /tmp + curl -Lo glow.tar.gz "$download_url" + tar xzf glow.tar.gz + mv glow /usr/local/bin/ + chmod +x /usr/local/bin/glow + rm -f glow.tar.gz + + if [ $? -ne 0 ]; then + echo "Error al instalar glow." + return 1 + fi + fi + + echo "glow instalado correctamente." + return 0 +}