-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·108 lines (98 loc) · 3.21 KB
/
uninstall.sh
File metadata and controls
executable file
·108 lines (98 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# DeployNOPE Uninstaller
# Removes commands, hooks, and hook configuration from the user level.
set -euo pipefail
DEPLOYNOPE_DIR="$(cd "$(dirname "$0")" && pwd)"
CLAUDE_DIR="$HOME/.claude"
CLAUDE_HOOKS_DIR="$CLAUDE_DIR/hooks"
CLAUDE_COMMANDS_DIR="$CLAUDE_DIR/commands"
CLAUDE_SETTINGS="$CLAUDE_DIR/settings.json"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
info() { printf "${GREEN}[+]${NC} %s\n" "$1"; }
warn() { printf "${YELLOW}[!]${NC} %s\n" "$1"; }
# --- Remove command symlinks (only those pointing into this repo) ---
REMOVED=0
if [ -d "$CLAUDE_COMMANDS_DIR" ]; then
for f in "$CLAUDE_COMMANDS_DIR"/deploynope-*.md; do
[ -L "$f" ] || continue
TARGET="$(readlink "$f")"
if echo "$TARGET" | grep -q "$DEPLOYNOPE_DIR"; then
rm "$f"
REMOVED=$((REMOVED + 1))
fi
done
fi
info "Removed $REMOVED command symlinks."
# --- Remove hooks symlink (only if it points to this repo) ---
if [ -L "$CLAUDE_HOOKS_DIR" ]; then
TARGET="$(readlink "$CLAUDE_HOOKS_DIR")"
if [ "$TARGET" = "$DEPLOYNOPE_DIR/.claude/hooks" ]; then
rm "$CLAUDE_HOOKS_DIR"
info "Removed hooks symlink."
else
warn "~/.claude/hooks points to $TARGET (not this repo). Skipping."
fi
elif [ -e "$CLAUDE_HOOKS_DIR" ]; then
warn "~/.claude/hooks is not a symlink. Skipping."
else
info "No hooks symlink found."
fi
# --- Remove hooks config from settings.json ---
if [ -f "$CLAUDE_SETTINGS" ] && command -v jq &>/dev/null; then
DEPLOYNOPE_HOOK_REGEX='(^|/)\.claude/hooks/check-(git-commit|git-push|git-reset|gh-pr-create|gh-release|gh-api-protection|git-branch-delete|git-tag|git-merge)\.sh$'
if jq -e --arg deploynopeHookRegex "$DEPLOYNOPE_HOOK_REGEX" \
'
[
(.hooks.PreToolUse // [])[]?
| (.hooks // [])[]?
| select((.type == "command") and ((.command // "") | test($deploynopeHookRegex)))
] | length > 0
' "$CLAUDE_SETTINGS" >/dev/null; then
jq --arg deploynopeHookRegex "$DEPLOYNOPE_HOOK_REGEX" '
def isDeploynopeCommandHook:
(.type == "command")
and ((.command // "") | test($deploynopeHookRegex));
.hooks.PreToolUse = (
(.hooks.PreToolUse // [])
| map(
if ((.hooks // null) | type) == "array" then
.hooks |= map(select((isDeploynopeCommandHook) | not))
else
.
end
)
| map(
if ((.hooks // null) | type) == "array" then
select((.hooks | length) > 0)
else
.
end
)
)
| if ((.hooks.PreToolUse // []) | length) == 0 then
del(.hooks.PreToolUse)
else
.
end
| if (.hooks == {}) then
del(.hooks)
else
.
end
' "$CLAUDE_SETTINGS" > "$CLAUDE_SETTINGS.tmp"
mv "$CLAUDE_SETTINGS.tmp" "$CLAUDE_SETTINGS"
info "Removed DeployNOPE hook entries from $CLAUDE_SETTINGS (preserved unrelated hooks)."
else
info "No DeployNOPE hooks found in settings.json."
fi
else
info "No settings file to clean up."
fi
echo ""
info "DeployNOPE uninstalled."
echo " Commands and hooks have been removed from user-level configuration."
echo " The DeployNOPE repo itself has not been modified."
echo ""