agenshield 0.11.2 → 0.11.3-beta.534
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/agenshield +55 -1
- package/package.json +1 -1
package/bin/agenshield
CHANGED
|
@@ -24,7 +24,22 @@ case "$(uname -m)" in
|
|
|
24
24
|
*) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
|
|
25
25
|
esac
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
# Resolve $0 through symlinks before computing SCRIPT_DIR. npm installs this
|
|
28
|
+
# launcher as `node_modules/.bin/agenshield`, a SYMLINK into the real package
|
|
29
|
+
# (`../agenshield/bin/agenshield`). `dirname "$0"` on the symlink yields the
|
|
30
|
+
# `.bin/` directory, where the bundled `install.sh` does NOT live — so the
|
|
31
|
+
# bootstrap failed with "bundled installer missing (.../.bin/install.sh)" even
|
|
32
|
+
# though install.sh is present next to the real script. Walk the symlink chain
|
|
33
|
+
# by hand (macOS /bin/sh has no `readlink -f`).
|
|
34
|
+
SELF="$0"
|
|
35
|
+
while [ -L "$SELF" ]; do
|
|
36
|
+
_link="$(readlink "$SELF")"
|
|
37
|
+
case "$_link" in
|
|
38
|
+
/*) SELF="$_link" ;;
|
|
39
|
+
*) SELF="$(dirname "$SELF")/$_link" ;;
|
|
40
|
+
esac
|
|
41
|
+
done
|
|
42
|
+
SCRIPT_DIR="$(cd "$(dirname "$SELF")" && pwd)"
|
|
28
43
|
INSTALLER="$SCRIPT_DIR/install.sh"
|
|
29
44
|
HOME_BIN="${HOME}/.agenshield/bin/agenshield"
|
|
30
45
|
|
|
@@ -95,6 +110,45 @@ if [ "${1:-}" = "install" ]; then
|
|
|
95
110
|
exec env AGENSHIELD_VERSION="$WRAPPER_VERSION" sh "$INSTALLER" "$@"
|
|
96
111
|
fi
|
|
97
112
|
|
|
113
|
+
# ── `uninstall` → delegate if installed; NEVER bootstrap-install ─────────────
|
|
114
|
+
# `npx agenshield uninstall` must never reinstall AgenShield just to remove it.
|
|
115
|
+
# The generic path below bootstraps (downloads + runs install.sh) whenever no
|
|
116
|
+
# binary is found — so a SECOND `uninstall` after the first one removed the
|
|
117
|
+
# binary used to re-download and launch the INSTALLER. If the binary is already
|
|
118
|
+
# gone, there is nothing to uninstall: report and exit cleanly instead.
|
|
119
|
+
if [ "${1:-}" = "uninstall" ]; then
|
|
120
|
+
BIN="$(find_installed || true)"
|
|
121
|
+
if [ -n "$BIN" ]; then
|
|
122
|
+
exec "$BIN" "$@"
|
|
123
|
+
fi
|
|
124
|
+
echo "agenshield: not installed — nothing to uninstall." >&2
|
|
125
|
+
exit 0
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# ── Info-only flags → delegate if installed; NEVER bootstrap-install ─────────
|
|
129
|
+
# `npx agenshield --help/--version` must not download + run the installer just
|
|
130
|
+
# to print text. If installed, delegate so the user sees the real CLI output;
|
|
131
|
+
# otherwise answer from the wrapper (version) or hint (help) and exit cleanly.
|
|
132
|
+
case "${1:-}" in
|
|
133
|
+
-h|--help|help|-v|--version)
|
|
134
|
+
BIN="$(find_installed || true)"
|
|
135
|
+
if [ -n "$BIN" ]; then
|
|
136
|
+
exec "$BIN" "$@"
|
|
137
|
+
fi
|
|
138
|
+
case "${1:-}" in
|
|
139
|
+
-v|--version)
|
|
140
|
+
# Not installed — report the wrapper's own version (what `install` would
|
|
141
|
+
# lay down). Mirrors AGENSHIELD_NPX_PACKAGE_VERSION set above.
|
|
142
|
+
echo "${WRAPPER_VERSION:-unknown}"
|
|
143
|
+
;;
|
|
144
|
+
*)
|
|
145
|
+
echo "agenshield: not installed. Run 'npx agenshield install' to install." >&2
|
|
146
|
+
;;
|
|
147
|
+
esac
|
|
148
|
+
exit 0
|
|
149
|
+
;;
|
|
150
|
+
esac
|
|
151
|
+
|
|
98
152
|
# ── Every other subcommand: ensure installed, then delegate ─────────────────
|
|
99
153
|
BIN="$(find_installed || true)"
|
|
100
154
|
|