claude-hooks/scripts/uninstall.sh
Ryan Malloy 9445e09c48 Add NPM distribution support with hybrid installation approach
Major changes:
- Add package.json with NPM packaging configuration
- Create Node.js CLI interface (bin/claude-hooks.js) with full command set
- Convert bash scripts to Python for better npm integration
- Add npm postinstall/preuninstall hooks for automatic setup
- Update bootstrap prompt to recommend NPM method with git fallback
- Enhance README with NPM-first documentation
- Maintain backward compatibility with existing git installation

Features:
- npm install -g claude-hooks for easy distribution
- claude-hooks init/status/test/backup/uninstall commands
- Automatic Python dependency installation
- Conflict detection and prevention
- Hybrid approach supporting both npm and git workflows

This resolves installation complexity while maintaining developer flexibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-19 21:03:13 -06:00

103 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# Claude Hooks Uninstallation Script
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
CLAUDE_CONFIG_DIR="$HOME/.config/claude"
HOOKS_CONFIG_FILE="$CLAUDE_CONFIG_DIR/hooks.json"
CLAUDE_HOOKS_CMD="$HOME/.local/bin/claude-hooks"
echo -e "${BLUE}Claude Code Hooks Uninstallation${NC}"
echo "===================================="
# Check if hooks are installed
if [ ! -f "$HOOKS_CONFIG_FILE" ] && [ ! -f "$CLAUDE_HOOKS_CMD" ]; then
echo -e "${YELLOW}No Claude Hooks installation found${NC}"
echo "Nothing to uninstall."
exit 0
fi
echo -e "${YELLOW}This will remove Claude Hooks from your system:${NC}"
echo "- Remove hooks configuration: $HOOKS_CONFIG_FILE"
echo "- Remove claude-hooks command: $CLAUDE_HOOKS_CMD"
echo "- Preserve hook data and backups"
echo ""
read -p "Continue with uninstallation? (y/n): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Uninstallation cancelled."
exit 0
fi
# Remove hooks configuration
echo -n "Removing hooks configuration... "
if [ -f "$HOOKS_CONFIG_FILE" ]; then
rm -f "$HOOKS_CONFIG_FILE"
echo -e "${GREEN}SUCCESS${NC}"
else
echo -e "${YELLOW}Not found${NC}"
fi
# Remove claude-hooks command
echo -n "Removing claude-hooks command... "
if [ -f "$CLAUDE_HOOKS_CMD" ]; then
rm -f "$CLAUDE_HOOKS_CMD"
echo -e "${GREEN}SUCCESS${NC}"
else
echo -e "${YELLOW}Not found${NC}"
fi
# Remove from Claude settings if it exists
if [ -f "$HOME/.config/claude/settings.json" ]; then
echo -n "Removing hooks from Claude settings... "
if grep -q "hooks" "$HOME/.config/claude/settings.json" 2>/dev/null; then
# Backup settings
cp "$HOME/.config/claude/settings.json" "$HOME/.config/claude/settings.json.backup"
# Remove hooks from settings
python3 << EOF
import json
import sys
import os
try:
settings_path = os.path.expanduser('~/.config/claude/settings.json')
with open(settings_path, 'r') as f:
settings = json.load(f)
# Remove hooks key if it exists
if 'hooks' in settings:
del settings['hooks']
with open(settings_path, 'w') as f:
json.dump(settings, f, indent=2)
print("SUCCESS")
else:
print("Not found in settings")
except Exception as e:
print(f"ERROR: {e}")
sys.exit(1)
EOF
echo -e "${GREEN}SUCCESS${NC}"
else
echo -e "${YELLOW}Not found in settings${NC}"
fi
fi
echo ""
echo -e "${GREEN}Uninstallation Complete!${NC}"
echo ""
echo -e "${BLUE}Next Steps:${NC}"
echo "1. Restart Claude Code to deactivate hooks"
echo "2. Hook data and backups are preserved in case you reinstall"
echo ""
echo -e "${YELLOW}Note:${NC} To completely remove all data, delete the claude-hooks directory manually"