60 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Brings the workspace up: initialises both submodules and installs their deps.
# Usage: ./scripts/bootstrap.sh
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
echo "==> Initialising submodules"
git submodule update --init --recursive
echo "==> Configuring the host fork remotes"
if ! git -C cloudcli remote | grep -qx upstream; then
git -C cloudcli remote add upstream https://github.com/siteboon/claudecodeui.git
fi
# upstream is fetch-only: pull requests are opened from origin (the fork).
git -C cloudcli remote set-url --push upstream DISABLED_fetch_only
git -C cloudcli fetch upstream --tags --quiet
echo "==> Installing host dependencies (cloudcli)"
# Not `npm ci`: the upstream lockfile pins a few tarballs on registry.npmmirror.com,
# and npm >= 12 refuses remote tarball URLs (EALLOWREMOTE) unless allowed explicitly.
(cd cloudcli && npm install --allow-remote=all --no-audit --no-fund)
echo "==> Building the host's native modules"
# npm >= 12 also blocks install scripts, so prebuilt binaries are never fetched
# and the server cannot start. Build only what the server actually needs, and
# only when it is missing (electron and friends stay unbuilt on purpose).
build_native() {
local module="$1" builder="$2"
if (cd "cloudcli" && node -e "require('$module')") >/dev/null 2>&1; then
echo " $module: ok"
return
fi
echo " $module: building"
(cd "cloudcli/node_modules/$module" && eval "$builder") >/dev/null 2>&1 || true
if (cd "cloudcli" && node -e "require('$module')") >/dev/null 2>&1; then
echo " $module: built"
else
echo " $module: FAILED — the host server will not start" >&2
fi
}
build_native better-sqlite3 "npx --no-install prebuild-install || npx --no-install node-gyp rebuild --release"
build_native bcrypt "npx --no-install node-gyp-build"
build_native node-pty "node scripts/prebuild.js || npx --no-install node-gyp rebuild"
echo "==> Building the plugin (plugin-taskwork)"
(cd plugin-taskwork && npm ci && npm run build)
cat <<'EOF'
Done.
Run the host: ./scripts/dev-host.sh start (http://localhost:5183)
Install the build: ./scripts/link-plugin.sh (dev-host.sh start does this too)
EOF