a834083a0b
- scripts/link-dev.sh: one-command setup to switch ~/.uncaged-nerve to use monorepo packages instead of npm registry versions - Builds all packages, links CLI globally, links all @uncaged/* packages into the nerve workspace, and restarts daemon - Prevents version mismatch between CLI and daemon during development
67 lines
2.0 KiB
Bash
Executable File
67 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# link-dev.sh — Switch ~/.uncaged-nerve to use the local monorepo packages.
|
|
#
|
|
# What it does:
|
|
# 1. Build all packages (pnpm -r build)
|
|
# 2. Link the CLI globally (nerve command → local build)
|
|
# 3. Link all @uncaged/* packages into ~/.uncaged-nerve/
|
|
# 4. Restart the daemon if it was running
|
|
#
|
|
# Usage:
|
|
# pnpm run link:dev # from monorepo root
|
|
# bash scripts/link-dev.sh # or directly
|
|
|
|
set -euo pipefail
|
|
|
|
NERVE_ROOT="${NERVE_ROOT:-$HOME/.uncaged-nerve}"
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
# ── Colors ──
|
|
bold="\033[1m"
|
|
green="\033[32m"
|
|
yellow="\033[33m"
|
|
reset="\033[0m"
|
|
|
|
info() { printf "${bold}${green}✓${reset} %s\n" "$1"; }
|
|
warn() { printf "${bold}${yellow}⚠${reset} %s\n" "$1"; }
|
|
|
|
# ── 1. Build ──
|
|
printf "\n${bold}Building all packages…${reset}\n"
|
|
cd "$REPO_ROOT"
|
|
pnpm -r run build
|
|
|
|
# ── 2. Global link (CLI → nerve command) ──
|
|
printf "\n${bold}Linking CLI globally…${reset}\n"
|
|
cd "$REPO_ROOT/packages/cli"
|
|
pnpm link --global
|
|
info "nerve CLI linked globally"
|
|
|
|
# ── 3. Link all @uncaged/* packages into workspace ──
|
|
if [ ! -d "$NERVE_ROOT" ]; then
|
|
warn "$NERVE_ROOT does not exist. Run 'nerve init' first, then re-run this script."
|
|
exit 1
|
|
fi
|
|
|
|
printf "\n${bold}Linking packages into ${NERVE_ROOT}…${reset}\n"
|
|
cd "$NERVE_ROOT"
|
|
for pkg_dir in "$REPO_ROOT"/packages/*/; do
|
|
pkg_name=$(node -e "console.log(require('${pkg_dir}package.json').name)" 2>/dev/null) || continue
|
|
# Only link @uncaged/* packages
|
|
if [[ "$pkg_name" == @uncaged/* ]]; then
|
|
pnpm link "$pkg_dir"
|
|
info "$pkg_name → $(basename "$pkg_dir")"
|
|
fi
|
|
done
|
|
|
|
# ── 4. Restart daemon if running ──
|
|
printf "\n${bold}Restarting daemon…${reset}\n"
|
|
if nerve daemon status >/dev/null 2>&1; then
|
|
nerve daemon restart
|
|
info "Daemon restarted with local packages"
|
|
else
|
|
warn "Daemon not running — skipping restart. Use 'nerve daemon start' when ready."
|
|
fi
|
|
|
|
printf "\n${bold}${green}Done!${reset} All packages linked to local monorepo build.\n"
|