Skip to content

Commit da491b9

Browse files
rcourtmanclaude
andcommitted
fix: support tarball installations in installer script
- Add detection for tarball vs git installations via package.json validation - Handle version checking for tarball installations using remote API - Provide proper update paths for both installation types - Fix "invalid git repository" error for tarball installations - Ensure both installation types can be updated seamlessly This resolves issues where tarball installations were incorrectly flagged as invalid and prevented from updating. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent eb1081f commit da491b9

File tree

1 file changed

+118
-4
lines changed

1 file changed

+118
-4
lines changed

scripts/install-pulse.sh

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,28 @@ check_installation_status_and_determine_action() {
700700

701701
print_info "Checking Pulse installation at $PULSE_DIR..."
702702
if [ -d "$PULSE_DIR" ]; then
703-
if [ -d "$PULSE_DIR/.git" ]; then
703+
# Check if this is a valid Pulse installation (either git or tarball)
704+
if [ -f "$PULSE_DIR/package.json" ] && grep -q '"name".*"pulse"' "$PULSE_DIR/package.json" 2>/dev/null; then
705+
print_info "Found valid Pulse installation"
706+
707+
# Determine installation type
708+
local is_git_install=false
709+
if [ -d "$PULSE_DIR/.git" ]; then
710+
is_git_install=true
711+
print_info "Installation type: Git repository"
712+
else
713+
print_info "Installation type: Tarball installation"
714+
fi
715+
else
716+
print_error "Directory $PULSE_DIR exists but does not appear to be a valid Pulse installation."
717+
print_error "Missing or invalid package.json file."
718+
print_error "Please remove this directory manually ($PULSE_DIR) or choose a different installation path and re-run the script."
719+
INSTALL_MODE="error"
720+
return
721+
fi
722+
723+
# Handle git installations
724+
if [ "$is_git_install" = true ]; then
704725
cd "$PULSE_DIR" || { print_error "Failed to cd into $PULSE_DIR"; INSTALL_MODE="error"; return; }
705726

706727
local current_tag
@@ -893,9 +914,102 @@ check_installation_status_and_determine_action() {
893914
fi
894915

895916
else
896-
print_error "Directory $PULSE_DIR exists but does not appear to be a valid Pulse git repository."
897-
print_error "Please remove this directory manually \($PULSE_DIR\) or choose a different installation path and re-run the script."
898-
INSTALL_MODE="error"
917+
# Handle tarball installations
918+
print_info "Handling tarball installation..."
919+
920+
# Get current version from package.json
921+
local current_version=""
922+
if [ -f "$PULSE_DIR/package.json" ]; then
923+
current_version=$(grep '"version"' "$PULSE_DIR/package.json" | sed 's/.*"version": *"\([^"]*\)".*/\1/')
924+
print_info "Current installed version: $current_version"
925+
fi
926+
927+
# Determine latest version for comparison
928+
local latest_tag=""
929+
latest_tag=$(git ls-remote --tags --sort='-version:refname' https://github.com/rcourtman/Pulse.git | grep 'refs/tags/v' | head -n 1 | sed 's/.*refs\/tags\///' | sed 's/\^{}.*//')
930+
if [ -n "$latest_tag" ]; then
931+
local latest_version=$(echo "$latest_tag" | sed 's/^v//')
932+
print_info "Latest available version: $latest_version"
933+
934+
# Compare versions
935+
if [ -n "$SPECIFIED_VERSION_TAG" ]; then
936+
TARGET_TAG="$SPECIFIED_VERSION_TAG"
937+
print_info "Will target specified version: $TARGET_TAG"
938+
INSTALL_MODE="update"
939+
elif [ -n "$SPECIFIED_BRANCH" ]; then
940+
TARGET_BRANCH="$SPECIFIED_BRANCH"
941+
print_info "Will switch to branch: $TARGET_BRANCH"
942+
INSTALL_MODE="update"
943+
elif [ "$current_version" = "$latest_version" ]; then
944+
print_info "Pulse is already up-to-date with the latest release $latest_tag."
945+
INSTALL_MODE="uptodate"
946+
TARGET_TAG="$latest_tag"
947+
else
948+
print_warning "Pulse is installed, but an update to $latest_tag is available."
949+
INSTALL_MODE="update"
950+
TARGET_TAG="$latest_tag"
951+
fi
952+
else
953+
print_warning "Could not determine latest version. Will proceed with update."
954+
INSTALL_MODE="update"
955+
fi
956+
957+
# Handle user interaction for tarball installations
958+
if [ "$INSTALL_MODE" = "uptodate" ]; then
959+
if [ -n "$MODE_UPDATE" ]; then
960+
print_info "Pulse is already up-to-date. Skipping update."
961+
INSTALL_MODE="cancel"
962+
else
963+
echo "Choose an action:"
964+
echo " 1) Manage automatic updates"
965+
echo " 2) Re-install current version"
966+
echo " 3) Test a feature branch"
967+
echo " 4) Remove Pulse"
968+
echo " 5) Cancel"
969+
read -p "Enter your choice [1-5]: " user_choice
970+
case $user_choice in
971+
1) prompt_for_cron_setup; INSTALL_MODE="cancel" ;;
972+
2) INSTALL_MODE="update" ;;
973+
3)
974+
if prompt_for_branch_selection; then
975+
INSTALL_MODE="update"
976+
else
977+
INSTALL_MODE="cancel"
978+
fi
979+
;;
980+
4) INSTALL_MODE="remove" ;;
981+
5) INSTALL_MODE="cancel" ;;
982+
*) print_error "Invalid choice."; INSTALL_MODE="error" ;;
983+
esac
984+
fi
985+
elif [ "$INSTALL_MODE" = "update" ]; then
986+
if [ -n "$MODE_UPDATE" ]; then
987+
# In non-interactive mode, proceed with update
988+
: # Do nothing, keep INSTALL_MODE as "update"
989+
else
990+
echo "Choose an action:"
991+
echo " 1) Update Pulse to the latest version ${TARGET_TAG:-$latest_tag}"
992+
echo " 2) Test a feature branch"
993+
echo " 3) Remove Pulse"
994+
echo " 4) Cancel"
995+
echo " 5) Manage automatic updates"
996+
read -p "Enter your choice [1-5]: " user_choice
997+
case $user_choice in
998+
1) INSTALL_MODE="update" ;;
999+
2)
1000+
if prompt_for_branch_selection; then
1001+
INSTALL_MODE="update"
1002+
else
1003+
INSTALL_MODE="cancel"
1004+
fi
1005+
;;
1006+
3) INSTALL_MODE="remove" ;;
1007+
4) INSTALL_MODE="cancel" ;;
1008+
5) prompt_for_cron_setup; INSTALL_MODE="cancel" ;;
1009+
*) print_error "Invalid choice."; INSTALL_MODE="error" ;;
1010+
esac
1011+
fi
1012+
fi
8991013
fi
9001014
else
9011015
print_info "Pulse is not currently installed."

0 commit comments

Comments
 (0)