gearbox-code 0.1.12 → 0.1.14
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/README.md +9 -0
- package/dist/cli.mjs +80053 -79959
- package/install.sh +46 -4
- package/package.json +1 -1
package/install.sh
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Installs the published npm package into user-owned directories:
|
|
5
5
|
# ~/.local/share/gearbox/<version>/cli.mjs
|
|
6
|
-
# ~/.local/bin/gearbox
|
|
6
|
+
# first user-owned PATH bin dir containing gearbox, or ~/.local/bin/gearbox
|
|
7
7
|
#
|
|
8
8
|
# This intentionally avoids `npm install -g`, sudo, /usr/local, and any system
|
|
9
9
|
# prefix. It follows the same practical model as modern CLI installers: place a
|
|
@@ -13,9 +13,45 @@ set -euo pipefail
|
|
|
13
13
|
|
|
14
14
|
PACKAGE_NAME="${GEARBOX_PACKAGE:-gearbox-code}"
|
|
15
15
|
VERSION="${GEARBOX_VERSION:-latest}"
|
|
16
|
-
BIN_DIR="${GEARBOX_BIN_DIR:-${HOME}/.local/bin}"
|
|
17
16
|
INSTALL_ROOT="${GEARBOX_INSTALL_DIR:-${HOME}/.local/share/gearbox}"
|
|
18
17
|
|
|
18
|
+
default_bin_dir() {
|
|
19
|
+
if [[ -n "${GEARBOX_BIN_DIR:-}" ]]; then
|
|
20
|
+
echo "$GEARBOX_BIN_DIR"
|
|
21
|
+
return
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# If an older user-owned gearbox shim is already first on PATH, replace it.
|
|
25
|
+
# This fixes stale Bun/npm links such as ~/.bun/bin/gearbox -> src/cli.tsx,
|
|
26
|
+
# which would otherwise keep shadowing the good ~/.local/bin installer shim.
|
|
27
|
+
local existing dir
|
|
28
|
+
existing="$(command -v gearbox 2>/dev/null || true)"
|
|
29
|
+
if [[ -n "$existing" ]]; then
|
|
30
|
+
dir="$(dirname "$existing")"
|
|
31
|
+
if [[ "$dir" == "$HOME"/* && -d "$dir" && -w "$dir" ]]; then
|
|
32
|
+
echo "$dir"
|
|
33
|
+
return
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
local path_dir
|
|
38
|
+
IFS=':' read -r -a path_dirs <<< "${PATH:-}"
|
|
39
|
+
for path_dir in "${path_dirs[@]}"; do
|
|
40
|
+
if [[ "$path_dir" == "$HOME"/* && -d "$path_dir" && -w "$path_dir" ]]; then
|
|
41
|
+
case "$path_dir" in
|
|
42
|
+
"$HOME/.local/bin"|"$HOME/.bun/bin"|"$HOME/bin")
|
|
43
|
+
echo "$path_dir"
|
|
44
|
+
return
|
|
45
|
+
;;
|
|
46
|
+
esac
|
|
47
|
+
fi
|
|
48
|
+
done
|
|
49
|
+
|
|
50
|
+
echo "${HOME}/.local/bin"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
BIN_DIR="$(default_bin_dir)"
|
|
54
|
+
|
|
19
55
|
need() {
|
|
20
56
|
if ! command -v "$1" >/dev/null 2>&1; then
|
|
21
57
|
echo "Gearbox installer needs '$1'." >&2
|
|
@@ -65,6 +101,10 @@ fi
|
|
|
65
101
|
cp "${extract_dir}/package/dist/cli.mjs" "${target_dir}/cli.mjs"
|
|
66
102
|
chmod 0755 "${target_dir}/cli.mjs"
|
|
67
103
|
|
|
104
|
+
# Replace stale symlinks instead of following them. Old Bun-linked installs can
|
|
105
|
+
# leave ~/.bun/bin/gearbox -> .../src/cli.tsx; `cat > symlink` would overwrite
|
|
106
|
+
# the target and keep the broken link in place.
|
|
107
|
+
rm -f "${BIN_DIR}/gearbox"
|
|
68
108
|
cat > "${BIN_DIR}/gearbox" <<EOF
|
|
69
109
|
#!/usr/bin/env sh
|
|
70
110
|
exec node "${target_dir}/cli.mjs" "\$@"
|
|
@@ -97,8 +137,10 @@ esac
|
|
|
97
137
|
if [[ "${GEARBOX_SKIP_ONBOARD:-}" != "1" ]]; then
|
|
98
138
|
echo ""
|
|
99
139
|
echo "Starting setup..."
|
|
100
|
-
if [[ -r /dev/tty && -w /dev/tty ]]; then
|
|
101
|
-
"${BIN_DIR}/gearbox" onboard < /dev/tty > /dev/tty
|
|
140
|
+
if [[ -t 1 && -e /dev/tty && -r /dev/tty && -w /dev/tty ]]; then
|
|
141
|
+
if ! "${BIN_DIR}/gearbox" onboard < /dev/tty > /dev/tty; then
|
|
142
|
+
echo "Setup did not complete. Run: ${BIN_DIR}/gearbox onboard"
|
|
143
|
+
fi
|
|
102
144
|
else
|
|
103
145
|
echo "No interactive terminal detected. Run: ${BIN_DIR}/gearbox onboard"
|
|
104
146
|
fi
|
package/package.json
CHANGED