Files
inkreach-teable-cli/.agents/skills/inkreach-teable/scripts/install.sh
T
yeuimu d3790ab856 refactor: rename skill 'inkreach-teable-ops' -> 'inkreach-teable'
Rename the skill directory and update all references (SKILL.md frontmatter
name, AGENTS.md, design doc, install.sh). Git tracks this as a rename so
history is preserved.
2026-08-05 10:35:04 +08:00

74 lines
2.4 KiB
Bash

#!/bin/bash
# Install/upgrade the inkreach-teable CLI from the local monorepo source.
# Run from this skill's directory. Builds the CLI package and links it globally.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Resolve the project root: skill lives at <root>/.agents/skills/inkreach-teable/
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
CLI_DIR="$PROJECT_ROOT/packages/inkreach-cli"
echo "=== inkreach-teable CLI installation ==="
# Check Node.js
if ! command -v node &> /dev/null; then
echo "ERROR: Node.js is not installed. Install Node.js >= 18 first."
exit 1
fi
NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "ERROR: Node.js >= 18 required, found v$(node -v)"
exit 1
fi
echo "✓ Node.js $(node -v)"
# Check CLI source exists
if [ ! -d "$CLI_DIR" ]; then
echo "ERROR: CLI source not found at $CLI_DIR"
echo " Ensure the inkreach-teable repo is checked out at $PROJECT_ROOT"
exit 1
fi
# Build
echo "Building CLI from $CLI_DIR ..."
cd "$CLI_DIR"
if command -v pnpm &> /dev/null; then
pnpm install --prefer-offline 2>/dev/null || true
pnpm build
else
echo "ERROR: pnpm not found. Install pnpm first: npm i -g pnpm"
exit 1
fi
# Link globally. Prefer pnpm; fall back to npm link; finally create a wrapper.
echo "Linking 'inkreach-teable' command globally ..."
LINKED=0
if command -v pnpm &> /dev/null && pnpm link --global 2>/dev/null; then
LINKED=1
elif command -v npm &> /dev/null && npm link 2>/dev/null; then
LINKED=1
fi
# Ensure a usable wrapper exists on PATH even if global bin isn't configured.
BIN_DIR="${PNPM_GLOBAL_BIN:-$(npm bin -g 2>/dev/null):-${HOME}/.local/bin}"
mkdir -p "$HOME/.local/bin"
cat > "$HOME/.local/bin/inkreach-teable" <<WRAPPER
#!/bin/bash
exec node "$CLI_DIR/dist/bin.js" "\$@"
WRAPPER
chmod +x "$HOME/.local/bin/inkreach-teable"
# Verify
echo ""
echo "=== Verification ==="
if command -v inkreach-teable &> /dev/null; then
echo "✓ inkreach-teable CLI installed ($(inkreach-teable --version 2>/dev/null || echo 'unknown'))"
echo ""
echo "Next: configure endpoint + token:"
echo " inkreach-teable auth login --endpoint http://localhost:3000 --token <PAT>"
echo "Or create a PAT first:"
echo " inkreach-teable auth token create --name my-cli"
else
echo "⚠ 'inkreach-teable' not on PATH. Add pnpm/npm global bin to your PATH, or run directly:"
echo " node $CLI_DIR/dist/bin.js <command>"
fi