mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 16:45:22 +00:00
55 lines
1.8 KiB
Bash
Executable File
55 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -u
|
|
|
|
PACKAGE_SOURCE=${PI_PACKAGE_SOURCE:-git:git@bitbucket.org:siakitem/my-pi.git}
|
|
uninstall_failed=0
|
|
|
|
ask_yes_no() {
|
|
prompt=$1
|
|
printf '%s [y/N] ' "$prompt"
|
|
if ! IFS= read -r answer; then
|
|
answer=n
|
|
fi
|
|
case $answer in
|
|
y|Y|yes|YES|Yes) return 0 ;;
|
|
*) return 1 ;;
|
|
esac
|
|
}
|
|
|
|
if ! command -v pi >/dev/null 2>&1; then
|
|
printf '错误: 找不到 pi,无法卸载组合包。请确保 pi 位于 PATH。\n' >&2
|
|
exit 127
|
|
fi
|
|
|
|
printf '正在从 Pi 中移除组合包:%s\n' "$PACKAGE_SOURCE"
|
|
if ! pi remove "$PACKAGE_SOURCE"; then
|
|
printf '%s\n' '错误: 组合包移除失败。' >&2
|
|
exit 1
|
|
fi
|
|
|
|
if command -v hippo >/dev/null 2>&1; then
|
|
hippo_version=$(hippo --version 2>/dev/null | sed -n 's/^[^0-9]*\([0-9][0-9.]*\).*$/\1/p' | sed -n '1p')
|
|
if ask_yes_no "检测到 Hippo Memory CLI ${hippo_version:-未知版本}。是否同时卸载 npm 全局 hippo-memory?项目与全局记忆数据会保留。"; then
|
|
if ! command -v npm >/dev/null 2>&1; then
|
|
printf '%s\n' '警告: 找不到 npm,无法卸载 Hippo Memory CLI。' >&2
|
|
uninstall_failed=1
|
|
elif ! npm list -g --depth=0 hippo-memory >/dev/null 2>&1; then
|
|
printf '%s\n' '警告: 当前 hippo 不属于 npm 全局 hippo-memory 安装,已保留。' >&2
|
|
uninstall_failed=1
|
|
elif npm uninstall -g hippo-memory; then
|
|
printf '%s\n' 'Hippo Memory CLI 已卸载;.hippo 与用户级记忆数据均已保留。'
|
|
else
|
|
printf '%s\n' '警告: Hippo Memory CLI 卸载失败。' >&2
|
|
uninstall_failed=1
|
|
fi
|
|
else
|
|
printf '%s\n' 'Hippo Memory CLI 已保留。'
|
|
fi
|
|
else
|
|
printf '%s\n' '未检测到 Hippo Memory CLI,无需额外卸载。'
|
|
fi
|
|
|
|
printf '%s\n' '组合包已移除。CodeGraph、Kotlin LSP、JDT LS、Java 和记忆数据均未卸载,因为它们可能仍被其他项目使用。'
|
|
exit "$uninstall_failed"
|