From 52bb2289bbd6488ab80cb1d32b5cab05058b9217 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 19:54:36 -0600 Subject: [PATCH 1/7] feat: implement smart update script and modify update command in Makefile --- Makefile | 4 +- scripts/install-global-commands.sh | 22 +- scripts/smart-update.sh | 398 +++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+), 7 deletions(-) create mode 100755 scripts/smart-update.sh diff --git a/Makefile b/Makefile index f055544..bc8a0a3 100644 --- a/Makefile +++ b/Makefile @@ -118,9 +118,7 @@ status: ## Show container status fi update: ## Update to latest version and rebuild - @echo "$(BLUE)Updating LazyVim environment...$(NC)" - @git pull origin main || echo "$(YELLOW)Could not pull latest changes$(NC)" - @make build + @./scripts/smart-update.sh backup: ## Backup dotfiles and configuration @echo "$(BLUE)Creating backup of configuration...$(NC)" diff --git a/scripts/install-global-commands.sh b/scripts/install-global-commands.sh index e612418..3a3ed8d 100755 --- a/scripts/install-global-commands.sh +++ b/scripts/install-global-commands.sh @@ -116,11 +116,18 @@ lazy() { case "\$cmd" in start|enter|stop|status|health|build|restart|destroy|clean|quick|backup|restore|update|version|timezone|configure) printf "🚀 Running: make %s %s\n" "\$cmd" "\$@" - (cd "\$lazyvim_docker_path" && make "\$cmd" "\$@") + # Preserve TTY for interactive commands by not using subshell + local current_dir=\$(pwd) + cd "\$lazyvim_docker_path" + make "\$cmd" "\$@" + cd "\$current_dir" ;; uninstall) printf "🗑️ Running complete uninstaller...\n" - (cd "\$lazyvim_docker_path" && ./scripts/remote-uninstall.sh) + local current_dir=\$(pwd) + cd "\$lazyvim_docker_path" + ./scripts/remote-uninstall.sh + cd "\$current_dir" ;; *) printf "❌ Unknown command: %s\n" "\$cmd" @@ -206,11 +213,18 @@ lazy() { case "\$cmd" in start|enter|stop|status|health|build|restart|destroy|clean|quick|backup|restore|update|version|timezone|configure) printf "🚀 Running: make %s %s\n" "\$cmd" "\$@" - (cd "\$lazyvim_docker_path" && make "\$cmd" "\$@") + # Preserve TTY for interactive commands by not using subshell + local current_dir=\$(pwd) + cd "\$lazyvim_docker_path" + make "\$cmd" "\$@" + cd "\$current_dir" ;; uninstall) printf "🗑️ Running complete uninstaller...\n" - (cd "\$lazyvim_docker_path" && ./scripts/remote-uninstall.sh) + local current_dir=\$(pwd) + cd "\$lazyvim_docker_path" + ./scripts/remote-uninstall.sh + cd "\$current_dir" ;; *) printf "❌ Unknown command: %s\n" "\$cmd" diff --git a/scripts/smart-update.sh b/scripts/smart-update.sh new file mode 100755 index 0000000..aba1a16 --- /dev/null +++ b/scripts/smart-update.sh @@ -0,0 +1,398 @@ +#!/bin/bash + +# LazyVim Docker - Smart Update Script +# Interactive update with version checking and user prompts + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +PURPLE='\033[0;35m' +CYAN='\033[0;36m' +BOLD='\033[1m' +NC='\033[0m' # No Color + +# Configuration +REPO_URL="https://github.com/manghidev/lazyvim-docker" +CURRENT_DIR="$(pwd)" +BACKUP_DIR="./backups" + +# Print functions +print_header() { + printf "\n${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}\n" + printf "${CYAN}║ LazyVim Docker - Smart Updater ║${NC}\n" + printf "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}\n" + printf "\n" +} + +print_info() { + printf "${BLUE}[INFO]${NC} %s\n" "$1" +} + +print_success() { + printf "${GREEN}[✓]${NC} %s\n" "$1" +} + +print_warning() { + printf "${YELLOW}[⚠]${NC} %s\n" "$1" +} + +print_error() { + printf "${RED}[✗]${NC} %s\n" "$1" +} + +print_step() { + printf "${PURPLE}[STEP]${NC} %s\n" "$1" +} + +# Ask yes/no question with default +ask_yes_no() { + local question="$1" + local default="${2:-y}" + local prompt + + if [ "$default" = "y" ]; then + prompt="[Y/n]" + else + prompt="[y/N]" + fi + + printf "${BOLD}${CYAN}[?]${NC} %s %s: " "$question" "$prompt" + read -r response + + case "$response" in + "") + [ "$default" = "y" ] + ;; + [yY][eE][sS]|[yY]) + return 0 + ;; + [nN][oO]|[nN]) + return 1 + ;; + *) + printf "${YELLOW}Por favor responde 'y' o 'n'${NC}\n" + ask_yes_no "$question" "$default" + ;; + esac +} + +# Check if we're in a git repository +check_git_repo() { + if [ ! -d ".git" ]; then + print_error "No estás en un repositorio git de LazyVim Docker" + print_info "Este script debe ejecutarse desde la carpeta del proyecto" + exit 1 + fi +} + +# Get current version +get_current_version() { + if [ -f "VERSION" ]; then + cat "VERSION" | tr -d '\n' + else + echo "unknown" + fi +} + +# Get latest version from GitHub +get_latest_version() { + if command -v curl >/dev/null 2>&1; then + local latest=$(curl -s "https://api.github.com/repos/manghidev/lazyvim-docker/releases/latest" 2>/dev/null | \ + grep '"tag_name":' | \ + sed -E 's/.*"([^"]+)".*/\1/' 2>/dev/null || echo "") + + if [ -z "$latest" ]; then + # Fallback: check the remote main branch for latest commit + local remote_commit=$(git ls-remote origin main 2>/dev/null | cut -f1 | cut -c1-7 || echo "") + if [ -n "$remote_commit" ]; then + latest="main-$remote_commit" + else + latest="main" + fi + fi + + echo "$latest" + else + echo "unknown" + fi +} + +# Get remote commit info +get_remote_commit_info() { + local current_commit=$(git rev-parse HEAD 2>/dev/null | cut -c1-7 || echo "unknown") + local remote_commit=$(git ls-remote origin main 2>/dev/null | cut -f1 | cut -c1-7 || echo "unknown") + + printf " 🔹 Commit actual: ${CYAN}%s${NC}\n" "$current_commit" + printf " 🔹 Commit remoto: ${GREEN}%s${NC}\n" "$remote_commit" + + # Check if there are new commits + if [ "$current_commit" != "$remote_commit" ] && [ "$remote_commit" != "unknown" ]; then + return 0 # New commits available + else + return 1 # No new commits + fi +} + +# Compare versions +version_is_newer() { + local current="$1" + local latest="$2" + + # If latest version is unknown, can't update + [ "$latest" = "unknown" ] && return 1 + + # If current version is unknown or dev, consider latest newer + [ "$current" = "unknown" ] || [ "$current" = "dev" ] && return 0 + + # Normalize versions (remove 'v' prefix if present) + current=$(echo "$current" | sed 's/^v//') + latest=$(echo "$latest" | sed 's/^v//') + + # If versions are exactly the same, check git commits + if [ "$current" = "$latest" ]; then + # Check if there are new commits even with same version + get_remote_commit_info >/dev/null 2>&1 + return $? + fi + + # Different versions, consider it newer + return 0 +} + +# Create backup +create_backup() { + local backup_name="lazyvim-docker-backup-$(date +%Y%m%d-%H%M%S)" + local backup_path="$BACKUP_DIR/$backup_name" + + print_step "Creando backup de la configuración actual..." + + mkdir -p "$BACKUP_DIR" + mkdir -p "$backup_path" + + # Backup important directories and files + if [ -d ".dotfiles" ]; then + cp -r ".dotfiles" "$backup_path/" + print_info "✓ Backup de .dotfiles" + fi + + if [ -f "VERSION" ]; then + cp "VERSION" "$backup_path/" + print_info "✓ Backup de VERSION" + fi + + # Backup any user configurations + for config_file in "docker-compose.override.yml" ".env.local"; do + if [ -f "$config_file" ]; then + cp "$config_file" "$backup_path/" + print_info "✓ Backup de $config_file" + fi + done + + # Store backup path for reference + echo "$backup_path" > /tmp/lazyvim-last-backup + + print_success "Backup creado: $backup_name" + return 0 +} + +# Update from git +update_from_git() { + print_step "Descargando últimos cambios desde GitHub..." + + # Fetch latest changes + if git fetch origin main >/dev/null 2>&1; then + print_info "✓ Cambios descargados desde origin/main" + else + print_warning "No se pudieron descargar los cambios remotos" + return 1 + fi + + # Check if there are actually new changes + local local_commit=$(git rev-parse HEAD) + local remote_commit=$(git rev-parse origin/main) + + if [ "$local_commit" = "$remote_commit" ]; then + print_info "No hay cambios nuevos en el repositorio remoto" + return 2 # No changes available + fi + + # Stash any local changes (excluding .git) + local stash_created=false + if ! git diff-index --quiet HEAD -- 2>/dev/null; then + print_info "Guardando cambios locales temporalmente..." + git stash push -m "Smart update: temporary stash $(date)" >/dev/null 2>&1 + stash_created=true + fi + + # Merge the changes + if git merge origin/main --no-edit >/dev/null 2>&1; then + print_success "Cambios aplicados exitosamente" + + # Restore stash if it was created + if [ "$stash_created" = true ]; then + print_info "Restaurando cambios locales..." + if git stash pop >/dev/null 2>&1; then + print_info "✓ Cambios locales restaurados" + else + print_warning "Revisa posibles conflictos en tus cambios locales" + fi + fi + + return 0 + else + print_error "Error al aplicar los cambios" + + # Restore stash if it was created + if [ "$stash_created" = true ]; then + git stash pop >/dev/null 2>&1 + fi + + return 1 + fi +} + +# Ask about container restart +ask_container_restart() { + printf "\n" + + if ask_yes_no "¿Quieres recargar el contenedor para usar los nuevos cambios?" "y"; then + print_step "Recargando contenedor con los nuevos cambios..." + + # Stop current containers + if make stop >/dev/null 2>&1; then + print_info "✓ Contenedor detenido" + fi + + # Rebuild and start with new changes + if make build; then + print_success "Contenedor reconstruido e iniciado con los nuevos cambios" + else + print_error "Error al reconstruir el contenedor" + print_info "Puedes intentar manualmente con: ${GREEN}make build${NC}" + return 1 + fi + else + print_info "El contenedor no se recargará." + print_info "Los cambios estarán disponibles la próxima vez que uses ${GREEN}make build${NC}" + fi +} + +# Main update process +main() { + print_header + + # Check if we're in a git repo + check_git_repo + + # Get current version + local current_version=$(get_current_version) + + # Get latest version and check for updates + print_info "Verificando actualizaciones desde GitHub..." + local latest_version=$(get_latest_version) + + # Display version information + printf "${BOLD}Información de versiones:${NC}\n" + printf " 📦 Versión actual: ${CYAN}%s${NC}\n" "$current_version" + printf " 🚀 Última versión: ${GREEN}%s${NC}\n" "$latest_version" + printf "\n" + + # Check commit information + printf "${BOLD}Información de commits:${NC}\n" + local has_new_commits=false + if get_remote_commit_info; then + has_new_commits=true + fi + printf "\n" + + # Determine if update is needed + local needs_update=false + + if version_is_newer "$current_version" "$latest_version"; then + needs_update=true + elif [ "$has_new_commits" = true ]; then + needs_update=true + fi + + # Check if update is needed + if [ "$needs_update" = false ]; then + print_success "¡Ya tienes la última versión y los últimos cambios!" + printf "\n" + + if ask_yes_no "¿Quieres forzar la actualización de todas formas?" "n"; then + print_info "Procediendo con actualización forzada..." + else + print_info "Actualización cancelada" + exit 0 + fi + else + printf "${GREEN}🎉 ¡Nuevos cambios disponibles!${NC}\n" + printf "\n" + + if ! ask_yes_no "¿Quieres descargar e instalar los nuevos cambios?" "y"; then + print_info "Actualización cancelada por el usuario" + exit 0 + fi + fi + + printf "\n" + + # Create backup + if ! create_backup; then + print_error "Error al crear backup" + if ! ask_yes_no "¿Continuar sin backup?" "n"; then + exit 1 + fi + fi + + printf "\n" + + # Update from git + local update_result=0 + if [ "$has_new_commits" = true ]; then + update_from_git + update_result=$? + else + print_info "No hay cambios remotos para descargar (actualización forzada de versión local)" + update_result=2 + fi + + if [ $update_result -eq 1 ]; then + print_error "Error al actualizar desde git" + exit 1 + elif [ $update_result -eq 2 ]; then + print_info "No había cambios para descargar" + # When forcing update, still consider it successful + fi + + printf "\n" + print_success "🎉 ¡LazyVim Docker actualizado exitosamente!" + + local new_version=$(get_current_version) + printf "\n" + printf " 📦 Versión anterior: ${CYAN}%s${NC}\n" "$current_version" + printf " 🚀 Versión actual: ${GREEN}%s${NC}\n" "$new_version" + printf "\n" + + # Ask about container restart + ask_container_restart + + printf "\n" + print_info "Para usar LazyVim en cualquier momento: ${GREEN}lazy enter${NC}" + printf "\n" +} + +# Handle interruption (preserve .git) +cleanup() { + print_info "Limpieza interrumpida por el usuario" + exit 1 +} + +trap cleanup INT TERM + +# Run main function +main "$@" From f10b4ba9317f9073bb6c5ad97762d08ff999bd17 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:10:46 -0600 Subject: [PATCH 2/7] feat: refactor uninstall and update scripts, removing remote versions and enhancing functionality --- Makefile | 14 +- README.md | 30 +-- scripts/install-global-commands.sh | 4 +- scripts/remote-update.sh | 225 ------------------ scripts/{remote-uninstall.sh => uninstall.sh} | 0 5 files changed, 25 insertions(+), 248 deletions(-) delete mode 100755 scripts/remote-update.sh rename scripts/{remote-uninstall.sh => uninstall.sh} (100%) diff --git a/Makefile b/Makefile index bc8a0a3..348e483 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # Provides easy-to-use commands for managing the LazyVim Docker environment .PHONY: default build start enter stop destroy clean status update backup restore dev quick version bump-version restart -.PHONY: install-global uninstall install-remote remote-uninstall remote-update configure +.PHONY: install-global uninstall install-remote configure # Default target .DEFAULT_GOAL := default @@ -167,7 +167,7 @@ install-global: ## Install global 'lazy' commands to use from anywhere uninstall: ## Complete uninstall - removes everything (same as curl method) @echo "$(BLUE)Running complete LazyVim Docker uninstall...$(NC)" - @./scripts/remote-uninstall.sh + @./scripts/uninstall.sh install-remote: @echo "$(BLUE)LazyVim Docker - Remote Installation$(NC)" @@ -183,9 +183,9 @@ install-remote: remote-install: install-remote -test-remote-scripts: - @echo "$(BLUE)Testing remote installation scripts...$(NC)" +test-scripts: + @echo "$(BLUE)Testing installation scripts...$(NC)" @bash -n scripts/start.sh && echo "$(GREEN)✓ start.sh syntax OK$(NC)" - @bash -n scripts/remote-uninstall.sh && echo "$(GREEN)✓ remote-uninstall.sh syntax OK$(NC)" - @bash -n scripts/remote-update.sh && echo "$(GREEN)✓ remote-update.sh syntax OK$(NC)" - @echo "$(GREEN)All remote scripts passed syntax check!$(NC)" + @bash -n scripts/uninstall.sh && echo "$(GREEN)✓ uninstall.sh syntax OK$(NC)" + @bash -n scripts/smart-update.sh && echo "$(GREEN)✓ smart-update.sh syntax OK$(NC)" + @echo "$(GREEN)All scripts passed syntax check!$(NC)" diff --git a/README.md b/README.md index 6738821..8209dff 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Complete removal when you no longer need LazyVim Docker: lazy uninstall # Or run directly -curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/remote-uninstall.sh | bash +curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/uninstall.sh | bash ``` **Removes everything**: Docker containers, installation files, global commands, and shell configurations in one step. @@ -113,14 +113,14 @@ curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scrip - ✅ Creates shell configuration backups ### 🔄 Update Script -**`remote-update.sh`** - Keep your installation up to date +**Smart Update System** - Keep your installation up to date ```bash -# Update to latest version +# Update to latest version (recommended) lazy update -# Or run directly -curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/remote-update.sh | bash +# Or from project directory +make update ``` **What it does:** @@ -132,14 +132,14 @@ curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scrip - ✅ Optionally rebuilds Docker containers ### 🗑️ Uninstallation Script -**`remote-uninstall.sh`** - Complete and safe cleanup +**Smart Uninstaller** - Complete and safe cleanup ```bash # Interactive uninstall with confirmation prompt lazy uninstall # Or run directly with prompts -curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/remote-uninstall.sh | bash +curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/uninstall.sh | bash ``` **What it does when you confirm:** @@ -184,15 +184,17 @@ curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scrip - Creates `~/.local/bin/lazy` - Creates `~/.local/share/lazyvim-docker/` -### 🔄 remote-update.sh -**Purpose**: Update existing remote installation to latest version +### 🔄 Smart Update System +**Purpose**: Update existing installation to latest version with intelligent version checking **Update Process:** 1. Checks current version vs latest GitHub release -2. Creates backup of current installation -3. Downloads latest version to temp directory -4. Preserves user configurations (.dotfiles, backups) -5. Replaces system files while keeping user data +2. Compares local and remote git commits +3. Interactive prompts for user confirmation +4. Creates backup of current installation +5. Downloads latest version preserving development setup +6. Preserves user configurations (.dotfiles, backups) +7. Offers container rebuild options 6. Optionally rebuilds Docker containers 7. Cleans up temporary files @@ -204,7 +206,7 @@ curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scrip **Safe Rollback:** - Backup created before update in `~/.local/share/lazyvim-docker-backup-[timestamp]` -### 🗑️ remote-uninstall.sh +### 🗑️ Smart Uninstaller **Purpose**: Complete and safe removal of LazyVim Docker installation **Removal Process:** diff --git a/scripts/install-global-commands.sh b/scripts/install-global-commands.sh index 3a3ed8d..7a5181f 100755 --- a/scripts/install-global-commands.sh +++ b/scripts/install-global-commands.sh @@ -126,7 +126,7 @@ lazy() { printf "🗑️ Running complete uninstaller...\n" local current_dir=\$(pwd) cd "\$lazyvim_docker_path" - ./scripts/remote-uninstall.sh + ./scripts/uninstall.sh cd "\$current_dir" ;; *) @@ -223,7 +223,7 @@ lazy() { printf "🗑️ Running complete uninstaller...\n" local current_dir=\$(pwd) cd "\$lazyvim_docker_path" - ./scripts/remote-uninstall.sh + ./scripts/uninstall.sh cd "\$current_dir" ;; *) diff --git a/scripts/remote-update.sh b/scripts/remote-update.sh deleted file mode 100755 index 84066b7..0000000 --- a/scripts/remote-update.sh +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/bash - -# LazyVim Docker - Remote Update Script -# This script updates LazyVim Docker to the latest version - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -PURPLE='\033[0;35m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color - -# Configuration -REPO_URL="https://github.com/manghidev/lazyvim-docker" -INSTALL_DIR="$HOME/.local/share/lazyvim-docker" -TEMP_DIR="/tmp/lazyvim-docker-update" -BACKUP_DIR="$HOME/.local/share/lazyvim-docker-backup-$(date +%Y%m%d-%H%M%S)" - -# Print functions -print_header() { - printf "${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}\n" - printf "${CYAN}║ LazyVim Docker - Updater ║${NC}\n" - printf "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}\n" - printf "\n" -} - -print_info() { - printf "${BLUE}[INFO]${NC} %s\n" "$1" -} - -print_success() { - printf "${GREEN}[SUCCESS]${NC} %s\n" "$1" -} - -print_warning() { - printf "${YELLOW}[WARNING]${NC} %s\n" "$1" -} - -print_error() { - printf "${RED}[ERROR]${NC} %s\n" "$1" -} - -print_step() { - printf "${PURPLE}[STEP]${NC} %s\n" "$1" -} - -# Check if installation exists -check_installation() { - if [ ! -d "$INSTALL_DIR" ]; then - print_error "LazyVim Docker installation not found at: $INSTALL_DIR" - print_info "Please install first:" - printf " curl -fsSL https://raw.githubusercontent.com/manghidev/lazyvim-docker/main/scripts/start.sh | bash\n" - exit 1 - fi -} - -# Get current version -get_current_version() { - if [ -f "$INSTALL_DIR/VERSION" ]; then - cat "$INSTALL_DIR/VERSION" - else - echo "unknown" - fi -} - -# Get latest version from GitHub -get_latest_version() { - if command -v curl >/dev/null 2>&1; then - curl -s "https://api.github.com/repos/manghidev/lazyvim-docker/releases/latest" | \ - grep '"tag_name":' | \ - sed -E 's/.*"([^"]+)".*/\1/' || echo "unknown" - else - echo "unknown" - fi -} - -# Backup current installation -backup_installation() { - print_step "Creating backup of current installation..." - - cp -r "$INSTALL_DIR" "$BACKUP_DIR" - print_success "Backup created at: $BACKUP_DIR" -} - -# Download latest version -download_latest() { - print_step "Downloading latest version..." - - # Remove temp directory if it exists - rm -rf "$TEMP_DIR" - - # Clone the repository to temp directory - if git clone --depth 1 "$REPO_URL" "$TEMP_DIR" >/dev/null 2>&1; then - print_success "Latest version downloaded" - else - print_error "Failed to download latest version" - exit 1 - fi -} - -# Update installation -update_installation() { - print_step "Updating installation..." - - # Stop containers first - cd "$INSTALL_DIR" - print_info "Stopping containers..." - make stop 2>/dev/null || true - - # Preserve user configurations - local preserve_dirs=("backups" ".dotfiles") - local temp_preserve="/tmp/lazyvim-preserve-$$" - mkdir -p "$temp_preserve" - - for dir in "${preserve_dirs[@]}"; do - if [ -d "$INSTALL_DIR/$dir" ]; then - cp -r "$INSTALL_DIR/$dir" "$temp_preserve/" - print_info "Preserved: $dir" - fi - done - - # Remove old installation (except preserved items) - find "$INSTALL_DIR" -mindepth 1 -maxdepth 1 ! -name "backups" ! -name ".dotfiles" -exec rm -rf {} + - - # Copy new files - cp -r "$TEMP_DIR"/* "$INSTALL_DIR/" - - # Restore preserved configurations - for dir in "${preserve_dirs[@]}"; do - if [ -d "$temp_preserve/$dir" ]; then - cp -r "$temp_preserve/$dir" "$INSTALL_DIR/" - fi - done - - # Cleanup temp preserve - rm -rf "$temp_preserve" - - # Make scripts executable - chmod +x "$INSTALL_DIR/scripts/"*.sh - chmod +x "$INSTALL_DIR/Makefile" - - print_success "Installation updated successfully" -} - -# Rebuild if needed -rebuild_containers() { - printf "\n" - printf "Do you want to rebuild Docker containers with the latest changes? [Y/n]: " - read -r response - - case "$response" in - [nN][oO]|[nN]) - print_info "Skipping container rebuild" - ;; - *) - print_step "Rebuilding Docker containers..." - cd "$INSTALL_DIR" - if make build; then - print_success "Containers rebuilt successfully" - else - print_warning "Container rebuild failed. You can try 'lazyvim build' later." - fi - ;; - esac -} - -# Cleanup -cleanup() { - print_step "Cleaning up temporary files..." - rm -rf "$TEMP_DIR" - print_success "Cleanup completed" -} - -# Main update process -main() { - print_header - - check_installation - - local current_version=$(get_current_version) - local latest_version=$(get_latest_version) - - print_info "Current version: $current_version" - print_info "Latest version: $latest_version" - printf "\n" - - if [ "$current_version" = "$latest_version" ] && [ "$current_version" != "unknown" ]; then - print_success "You already have the latest version!" - printf "\n" - printf "Do you want to force update anyway? [y/N]: " - read -r response - case "$response" in - [yY][eE][sS]|[yY]) - print_info "Proceeding with forced update..." - ;; - *) - print_info "Update cancelled" - exit 0 - ;; - esac - fi - - backup_installation - download_latest - update_installation - rebuild_containers - cleanup - - printf "\n" - print_success "🎉 LazyVim Docker updated successfully!" - printf "\n" - print_info "Updated to version: $(get_current_version)" - print_info "Backup available at: $BACKUP_DIR" - printf "\n" - print_info "To start using the updated version:" - printf " ${GREEN}lazyvim enter${NC}\n" - printf "\n" -} - -# Run main function -main "$@" diff --git a/scripts/remote-uninstall.sh b/scripts/uninstall.sh similarity index 100% rename from scripts/remote-uninstall.sh rename to scripts/uninstall.sh From de99a0f4df5c9081e5d34e02449ab10004e324df Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:18:42 -0600 Subject: [PATCH 3/7] fix: enhance output formatting for container restart messages in smart update script --- scripts/smart-update.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/smart-update.sh b/scripts/smart-update.sh index aba1a16..668704a 100755 --- a/scripts/smart-update.sh +++ b/scripts/smart-update.sh @@ -272,12 +272,12 @@ ask_container_restart() { print_success "Contenedor reconstruido e iniciado con los nuevos cambios" else print_error "Error al reconstruir el contenedor" - print_info "Puedes intentar manualmente con: ${GREEN}make build${NC}" + printf "${BLUE}[INFO]${NC} Puedes intentar manualmente con: ${GREEN}make build${NC}\n" return 1 fi else print_info "El contenedor no se recargará." - print_info "Los cambios estarán disponibles la próxima vez que uses ${GREEN}make build${NC}" + printf "${BLUE}[INFO]${NC} Los cambios estarán disponibles la próxima vez que uses ${GREEN}make build${NC}\n" fi } @@ -382,7 +382,7 @@ main() { ask_container_restart printf "\n" - print_info "Para usar LazyVim en cualquier momento: ${GREEN}lazy enter${NC}" + printf "${BLUE}[INFO]${NC} Para usar LazyVim en cualquier momento: ${GREEN}lazy enter${NC}\n" printf "\n" } From add2b66611e4808cf4eb9db30d38101b4b1464a0 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:22:58 -0600 Subject: [PATCH 4/7] feat: enhance command output formatting in lazy command help --- scripts/install-global-commands.sh | 98 +++++++++++++++++------------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/scripts/install-global-commands.sh b/scripts/install-global-commands.sh index 7a5181f..eeb3d50 100755 --- a/scripts/install-global-commands.sh +++ b/scripts/install-global-commands.sh @@ -79,34 +79,41 @@ $marker_start # Use 'lazy ' from anywhere to control LazyVim Docker lazyvim_docker_path="$LAZYVIM_DOCKER_PATH" +# Colors for lazy command output +LAZY_RED='\033[0;31m' +LAZY_GREEN='\033[0;32m' +LAZY_YELLOW='\033[1;33m' +LAZY_BLUE='\033[0;34m' +LAZY_NC='\033[0m' # No Color + lazy() { if [[ \$# -eq 0 ]]; then - printf "LazyVim Docker - Available Commands\n" + printf "\${LAZY_BLUE}LazyVim Docker - Available Commands\${LAZY_NC}\n" printf "\n" printf "Usage: lazy \n" printf "\n" printf "Available commands:\n" - printf " start Start the container\n" - printf " enter Enter the container (starts if stopped)\n" - printf " stop Stop the container\n" - printf " status Show container status\n" - printf " health Run health diagnostics\n" - printf " build Build/rebuild the container\n" - printf " restart Restart the container\n" - printf " destroy Destroy everything\n" - printf " clean Clean up Docker resources\n" - printf " quick Quick start (build + enter)\n" - printf " backup Backup configurations\n" - printf " restore Restore from backup\n" - printf " update Update to latest version\n" - printf " version Show version\n" - printf " timezone Check timezone configuration\n" - printf " configure Reconfigure directories and timezone\n" - printf " uninstall Complete removal (same as curl method)\n" + printf " \${LAZY_GREEN}start\${LAZY_NC} Start the container\n" + printf " \${LAZY_GREEN}enter\${LAZY_NC} Enter the container (starts if stopped)\n" + printf " \${LAZY_GREEN}stop\${LAZY_NC} Stop the container\n" + printf " \${LAZY_GREEN}status\${LAZY_NC} Show container status\n" + printf " \${LAZY_GREEN}health\${LAZY_NC} Run health diagnostics\n" + printf " \${LAZY_GREEN}build\${LAZY_NC} Build/rebuild the container\n" + printf " \${LAZY_GREEN}restart\${LAZY_NC} Restart the container\n" + printf " \${LAZY_GREEN}destroy\${LAZY_NC} Destroy everything\n" + printf " \${LAZY_GREEN}clean\${LAZY_NC} Clean up Docker resources\n" + printf " \${LAZY_GREEN}quick\${LAZY_NC} Quick start (build + enter)\n" + printf " \${LAZY_GREEN}backup\${LAZY_NC} Backup configurations\n" + printf " \${LAZY_GREEN}restore\${LAZY_NC} Restore from backup\n" + printf " \${LAZY_GREEN}update\${LAZY_NC} Update to latest version\n" + printf " \${LAZY_GREEN}version\${LAZY_NC} Show version\n" + printf " \${LAZY_GREEN}timezone\${LAZY_NC} Check timezone configuration\n" + printf " \${LAZY_GREEN}configure\${LAZY_NC} Reconfigure directories and timezone\n" + printf " \${LAZY_GREEN}uninstall\${LAZY_NC} Complete removal (same as curl method)\n" printf "\n" - printf "Examples:\n" - printf " lazy enter # Enter LazyVim from anywhere\n" - printf " lazy build # Build the environment\n" + printf "\${LAZY_YELLOW}Examples:\${LAZY_NC}\n" + printf " \${LAZY_GREEN}lazy enter\${LAZY_NC} # Enter LazyVim from anywhere\n" + printf " \${LAZY_GREEN}lazy build\${LAZY_NC} # Build the environment\n" return 0 fi @@ -176,34 +183,41 @@ $marker_start # Use 'lazy ' from anywhere to control LazyVim Docker lazyvim_docker_path="$LAZYVIM_DOCKER_PATH" +# Colors for lazy command output +LAZY_RED='\033[0;31m' +LAZY_GREEN='\033[0;32m' +LAZY_YELLOW='\033[1;33m' +LAZY_BLUE='\033[0;34m' +LAZY_NC='\033[0m' # No Color + lazy() { if [[ \$# -eq 0 ]]; then - printf "LazyVim Docker - Available Commands\n" + printf "\${LAZY_BLUE}LazyVim Docker - Available Commands\${LAZY_NC}\n" printf "\n" printf "Usage: lazy \n" printf "\n" printf "Available commands:\n" - printf " start Start the container\n" - printf " enter Enter the container (starts if stopped)\n" - printf " stop Stop the container\n" - printf " status Show container status\n" - printf " health Run health diagnostics\n" - printf " build Build/rebuild the container\n" - printf " restart Restart the container\n" - printf " destroy Destroy everything\n" - printf " clean Clean up Docker resources\n" - printf " quick Quick start (build + enter)\n" - printf " backup Backup configurations\n" - printf " restore Restore from backup\n" - printf " update Update to latest version\n" - printf " version Show version\n" - printf " timezone Check timezone configuration\n" - printf " configure Reconfigure directories and timezone\n" - printf " uninstall Complete removal (same as curl method)\n" + printf " \${LAZY_GREEN}start\${LAZY_NC} Start the container\n" + printf " \${LAZY_GREEN}enter\${LAZY_NC} Enter the container (starts if stopped)\n" + printf " \${LAZY_GREEN}stop\${LAZY_NC} Stop the container\n" + printf " \${LAZY_GREEN}status\${LAZY_NC} Show container status\n" + printf " \${LAZY_GREEN}health\${LAZY_NC} Run health diagnostics\n" + printf " \${LAZY_GREEN}build\${LAZY_NC} Build/rebuild the container\n" + printf " \${LAZY_GREEN}restart\${LAZY_NC} Restart the container\n" + printf " \${LAZY_GREEN}destroy\${LAZY_NC} Destroy everything\n" + printf " \${LAZY_GREEN}clean\${LAZY_NC} Clean up Docker resources\n" + printf " \${LAZY_GREEN}quick\${LAZY_NC} Quick start (build + enter)\n" + printf " \${LAZY_GREEN}backup\${LAZY_NC} Backup configurations\n" + printf " \${LAZY_GREEN}restore\${LAZY_NC} Restore from backup\n" + printf " \${LAZY_GREEN}update\${LAZY_NC} Update to latest version\n" + printf " \${LAZY_GREEN}version\${LAZY_NC} Show version\n" + printf " \${LAZY_GREEN}timezone\${LAZY_NC} Check timezone configuration\n" + printf " \${LAZY_GREEN}configure\${LAZY_NC} Reconfigure directories and timezone\n" + printf " \${LAZY_GREEN}uninstall\${LAZY_NC} Complete removal (same as curl method)\n" printf "\n" - printf "Examples:\n" - printf " lazy enter # Enter LazyVim from anywhere\n" - printf " lazy build # Build the environment\n" + printf "\${LAZY_YELLOW}Examples:\${LAZY_NC}\n" + printf " \${LAZY_GREEN}lazy enter\${LAZY_NC} # Enter LazyVim from anywhere\n" + printf " \${LAZY_GREEN}lazy build\${LAZY_NC} # Build the environment\n" return 0 fi From 943f10dd2f7dc3a993335b732d1df7eb2d39bf07 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:44:36 -0600 Subject: [PATCH 5/7] feat: add bash to the list of installed development tools in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b3d9ec9..3db6ffe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ LABEL maintainer="ManghiDev " \ #* Install necessary dependencies and development tools RUN apk add --no-cache \ # Core tools - git lazygit fzf curl neovim ripgrep alpine-sdk zsh sudo \ + git lazygit fzf curl neovim ripgrep alpine-sdk bash zsh sudo \ # Additional development tools tmux tree htop unzip zip \ # Language tools From 672563eb94f80fb9d9ae60fb210621a6ec94844f Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:57:46 -0600 Subject: [PATCH 6/7] fix: translate Spanish messages to English in smart update script --- scripts/smart-update.sh | 100 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/scripts/smart-update.sh b/scripts/smart-update.sh index 668704a..da35d8f 100755 --- a/scripts/smart-update.sh +++ b/scripts/smart-update.sh @@ -74,7 +74,7 @@ ask_yes_no() { return 1 ;; *) - printf "${YELLOW}Por favor responde 'y' o 'n'${NC}\n" + printf "${YELLOW}Please answer 'y' or 'n'${NC}\n" ask_yes_no "$question" "$default" ;; esac @@ -83,8 +83,8 @@ ask_yes_no() { # Check if we're in a git repository check_git_repo() { if [ ! -d ".git" ]; then - print_error "No estás en un repositorio git de LazyVim Docker" - print_info "Este script debe ejecutarse desde la carpeta del proyecto" + print_error "You are not in a LazyVim Docker git repository" + print_info "This script must be run from the project directory" exit 1 fi } @@ -126,8 +126,8 @@ get_remote_commit_info() { local current_commit=$(git rev-parse HEAD 2>/dev/null | cut -c1-7 || echo "unknown") local remote_commit=$(git ls-remote origin main 2>/dev/null | cut -f1 | cut -c1-7 || echo "unknown") - printf " 🔹 Commit actual: ${CYAN}%s${NC}\n" "$current_commit" - printf " 🔹 Commit remoto: ${GREEN}%s${NC}\n" "$remote_commit" + printf " 🔹 Current commit: ${CYAN}%s${NC}\n" "$current_commit" + printf " 🔹 Remote commit: ${GREEN}%s${NC}\n" "$remote_commit" # Check if there are new commits if [ "$current_commit" != "$remote_commit" ] && [ "$remote_commit" != "unknown" ]; then @@ -168,7 +168,7 @@ create_backup() { local backup_name="lazyvim-docker-backup-$(date +%Y%m%d-%H%M%S)" local backup_path="$BACKUP_DIR/$backup_name" - print_step "Creando backup de la configuración actual..." + print_step "Creating backup of current configuration..." mkdir -p "$BACKUP_DIR" mkdir -p "$backup_path" @@ -176,38 +176,38 @@ create_backup() { # Backup important directories and files if [ -d ".dotfiles" ]; then cp -r ".dotfiles" "$backup_path/" - print_info "✓ Backup de .dotfiles" + print_info "✓ Backup of .dotfiles" fi if [ -f "VERSION" ]; then cp "VERSION" "$backup_path/" - print_info "✓ Backup de VERSION" + print_info "✓ Backup of VERSION" fi # Backup any user configurations for config_file in "docker-compose.override.yml" ".env.local"; do if [ -f "$config_file" ]; then cp "$config_file" "$backup_path/" - print_info "✓ Backup de $config_file" + print_info "✓ Backup of $config_file" fi done # Store backup path for reference echo "$backup_path" > /tmp/lazyvim-last-backup - print_success "Backup creado: $backup_name" + print_success "Backup created: $backup_name" return 0 } # Update from git update_from_git() { - print_step "Descargando últimos cambios desde GitHub..." + print_step "Downloading latest changes from GitHub..." # Fetch latest changes if git fetch origin main >/dev/null 2>&1; then - print_info "✓ Cambios descargados desde origin/main" + print_info "✓ Changes downloaded from origin/main" else - print_warning "No se pudieron descargar los cambios remotos" + print_warning "Could not download remote changes" return 1 fi @@ -216,35 +216,35 @@ update_from_git() { local remote_commit=$(git rev-parse origin/main) if [ "$local_commit" = "$remote_commit" ]; then - print_info "No hay cambios nuevos en el repositorio remoto" + print_info "No new changes in remote repository" return 2 # No changes available fi # Stash any local changes (excluding .git) local stash_created=false if ! git diff-index --quiet HEAD -- 2>/dev/null; then - print_info "Guardando cambios locales temporalmente..." + print_info "Saving local changes temporarily..." git stash push -m "Smart update: temporary stash $(date)" >/dev/null 2>&1 stash_created=true fi # Merge the changes if git merge origin/main --no-edit >/dev/null 2>&1; then - print_success "Cambios aplicados exitosamente" + print_success "Changes applied successfully" # Restore stash if it was created if [ "$stash_created" = true ]; then - print_info "Restaurando cambios locales..." + print_info "Restoring local changes..." if git stash pop >/dev/null 2>&1; then - print_info "✓ Cambios locales restaurados" + print_info "✓ Local changes restored" else - print_warning "Revisa posibles conflictos en tus cambios locales" + print_warning "Please check possible conflicts in your local changes" fi fi return 0 else - print_error "Error al aplicar los cambios" + print_error "Error applying changes" # Restore stash if it was created if [ "$stash_created" = true ]; then @@ -259,25 +259,25 @@ update_from_git() { ask_container_restart() { printf "\n" - if ask_yes_no "¿Quieres recargar el contenedor para usar los nuevos cambios?" "y"; then - print_step "Recargando contenedor con los nuevos cambios..." + if ask_yes_no "Do you want to reload the container to use the new changes?" "y"; then + print_step "Reloading container with new changes..." # Stop current containers if make stop >/dev/null 2>&1; then - print_info "✓ Contenedor detenido" + print_info "✓ Container stopped" fi # Rebuild and start with new changes if make build; then - print_success "Contenedor reconstruido e iniciado con los nuevos cambios" + print_success "Container rebuilt and started with new changes" else - print_error "Error al reconstruir el contenedor" - printf "${BLUE}[INFO]${NC} Puedes intentar manualmente con: ${GREEN}make build${NC}\n" + print_error "Error rebuilding container" + printf "${BLUE}[INFO]${NC} You can try manually with: ${GREEN}make build${NC}\n" return 1 fi else - print_info "El contenedor no se recargará." - printf "${BLUE}[INFO]${NC} Los cambios estarán disponibles la próxima vez que uses ${GREEN}make build${NC}\n" + print_info "Container will not be reloaded." + printf "${BLUE}[INFO]${NC} Changes will be available next time you use ${GREEN}make build${NC}\n" fi } @@ -292,17 +292,17 @@ main() { local current_version=$(get_current_version) # Get latest version and check for updates - print_info "Verificando actualizaciones desde GitHub..." + print_info "Checking for updates from GitHub..." local latest_version=$(get_latest_version) # Display version information - printf "${BOLD}Información de versiones:${NC}\n" - printf " 📦 Versión actual: ${CYAN}%s${NC}\n" "$current_version" - printf " 🚀 Última versión: ${GREEN}%s${NC}\n" "$latest_version" + printf "${BOLD}Version information:${NC}\n" + printf " 📦 Current version: ${CYAN}%s${NC}\n" "$current_version" + printf " 🚀 Latest version: ${GREEN}%s${NC}\n" "$latest_version" printf "\n" # Check commit information - printf "${BOLD}Información de commits:${NC}\n" + printf "${BOLD}Commit information:${NC}\n" local has_new_commits=false if get_remote_commit_info; then has_new_commits=true @@ -320,21 +320,21 @@ main() { # Check if update is needed if [ "$needs_update" = false ]; then - print_success "¡Ya tienes la última versión y los últimos cambios!" + print_success "You already have the latest version and latest changes!" printf "\n" - if ask_yes_no "¿Quieres forzar la actualización de todas formas?" "n"; then - print_info "Procediendo con actualización forzada..." + if ask_yes_no "Do you want to force the update anyway?" "n"; then + print_info "Proceeding with forced update..." else - print_info "Actualización cancelada" + print_info "Update cancelled" exit 0 fi else - printf "${GREEN}🎉 ¡Nuevos cambios disponibles!${NC}\n" + printf "${GREEN}🎉 New changes available!${NC}\n" printf "\n" - if ! ask_yes_no "¿Quieres descargar e instalar los nuevos cambios?" "y"; then - print_info "Actualización cancelada por el usuario" + if ! ask_yes_no "Do you want to download and install the new changes?" "y"; then + print_info "Update cancelled by user" exit 0 fi fi @@ -343,8 +343,8 @@ main() { # Create backup if ! create_backup; then - print_error "Error al crear backup" - if ! ask_yes_no "¿Continuar sin backup?" "n"; then + print_error "Error creating backup" + if ! ask_yes_no "Continue without backup?" "n"; then exit 1 fi fi @@ -357,38 +357,38 @@ main() { update_from_git update_result=$? else - print_info "No hay cambios remotos para descargar (actualización forzada de versión local)" + print_info "No remote changes to download (forced update of local version)" update_result=2 fi if [ $update_result -eq 1 ]; then - print_error "Error al actualizar desde git" + print_error "Error updating from git" exit 1 elif [ $update_result -eq 2 ]; then - print_info "No había cambios para descargar" + print_info "No changes to download" # When forcing update, still consider it successful fi printf "\n" - print_success "🎉 ¡LazyVim Docker actualizado exitosamente!" + print_success "🎉 LazyVim Docker updated successfully!" local new_version=$(get_current_version) printf "\n" - printf " 📦 Versión anterior: ${CYAN}%s${NC}\n" "$current_version" - printf " 🚀 Versión actual: ${GREEN}%s${NC}\n" "$new_version" + printf " 📦 Previous version: ${CYAN}%s${NC}\n" "$current_version" + printf " 🚀 Current version: ${GREEN}%s${NC}\n" "$new_version" printf "\n" # Ask about container restart ask_container_restart printf "\n" - printf "${BLUE}[INFO]${NC} Para usar LazyVim en cualquier momento: ${GREEN}lazy enter${NC}\n" + printf "${BLUE}[INFO]${NC} To use LazyVim anytime: ${GREEN}lazy enter${NC}\n" printf "\n" } # Handle interruption (preserve .git) cleanup() { - print_info "Limpieza interrumpida por el usuario" + print_info "Cleanup interrupted by user" exit 1 } From 5c1a22d72bb20d18d692b3814436bd088d085667 Mon Sep 17 00:00:00 2001 From: Ricardo <31641216+manghidev@users.noreply.github.com> Date: Sat, 12 Jul 2025 23:06:54 -0600 Subject: [PATCH 7/7] chore: bump version to 1.3.4 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 31e5c84..d0149fe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.3 +1.3.4