Просмотр исходного кода

fix(install): resolve temp_dir trap issue and improve PATH configuration

- Change log() to write to stderr to prevent output capture in command substitutions
- Remove problematic EXIT trap for temp_dir that caused 'unbound variable' errors
- Add explicit cleanup of temp directory on both success and error paths
- Detect when boilerplate command is not in PATH after installation
- Provide shell-specific instructions (bash/zsh) for adding pipx bin to PATH
- Show immediate workaround using full path to boilerplate executable
- Make pipx ensurepath output visible to users for transparency
xcad 4 месяцев назад
Родитель
Сommit
fc22cb4167
1 измененных файлов с 40 добавлено и 2 удалено
  1. 40 2
      scripts/install.sh

+ 40 - 2
scripts/install.sh

@@ -423,7 +423,8 @@ install_pipx_with_pip() {
 }
 
 pipx_install() {
-  "${PIPX_CMD}" ensurepath >/dev/null 2>&1 || warn "pipx ensurepath failed; make sure pipx's bin dir is on PATH"
+  log "Configuring pipx PATH..."
+  "${PIPX_CMD}" ensurepath 2>&1 | grep -v "^$" || true
   log "Installing/updating boilerplates via pipx"
   "${PIPX_CMD}" install --editable --force "$TARGET_DIR"
 }
@@ -468,13 +469,50 @@ main() {
   local installed_version
   installed_version=$(check_current_version)
 
+  # Check if boilerplate is in PATH
+  local path_warning=""
+  if ! command -v boilerplate >/dev/null 2>&1; then
+    local user_bin
+    user_bin="$(python3 -m site --user-base 2>/dev/null)/bin"
+    
+    # Detect shell and provide appropriate instructions
+    local shell_config
+    if [[ -n "${BASH_VERSION:-}" ]]; then
+      shell_config="~/.bashrc"
+    elif [[ -n "${ZSH_VERSION:-}" ]]; then
+      shell_config="~/.zshrc"
+    else
+      shell_config="your shell's config file"
+    fi
+    
+    path_warning=$(cat <<'PATHWARN'
+
+⚠️  PATH Configuration Required
+
+The 'boilerplate' command is not in your PATH. To use it, add this to SHELL_CONFIG:
+
+  export PATH="$PATH:USER_BIN"
+
+Then reload your shell:
+
+  source SHELL_CONFIG
+
+Or use the full path for now:
+
+  USER_BIN/boilerplate --help
+PATHWARN
+)
+    path_warning="${path_warning//SHELL_CONFIG/$shell_config}"
+    path_warning="${path_warning//USER_BIN/$user_bin}"
+  fi
+
   cat <<EOF2
 
 ✓ Installation complete!
 
 Version: $installed_version
 Location: $TARGET_DIR
-pipx environment: $pipx_info
+pipx environment: $pipx_info$path_warning
 
 To use the CLI:
   boilerplate --help