Files
zesdex/install.sh
T

42 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
BIN_NAME="zesdex"
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
TMP_BIN="/tmp/$BIN_NAME"
# Need Bun to compile the CLI.
if ! command -v bun >/dev/null 2>&1; then
echo "ERROR: 'bun' is required to build $BIN_NAME." >&2
echo "Install it from https://bun.sh (curl -fsSL https://bun.sh/install | bash)" >&2
exit 1
fi
echo "==> Installing dependencies..."
bun install --cwd "$REPO_DIR" --frozen-lockfile
echo "==> Compiling $BIN_NAME (self-contained executable)..."
bun build "$REPO_DIR/src/interfaces/cli/index.ts" --compile --outfile "$TMP_BIN"
if [ ! -f "$TMP_BIN" ]; then
echo "ERROR: build succeeded but binary not found at $TMP_BIN" >&2
exit 1
fi
chmod +x "$TMP_BIN"
echo "==> Binary built: $TMP_BIN"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
mkdir -p "$INSTALL_DIR"
BIN_PATH="$INSTALL_DIR/$BIN_NAME"
if [ -L "$BIN_PATH" ] || [ -f "$BIN_PATH" ]; then
echo "==> Removing existing symlink or file at $BIN_PATH"
rm -f "$BIN_PATH"
fi
mv "$TMP_BIN" "$BIN_PATH"
echo "==> Installed: $BIN_PATH"
echo ""
echo "Done. Make sure $INSTALL_DIR is in your PATH."