platform-tooling/scripts/dev-setup/create-bin-links.sh
Quinn Ftw 85621b287e chore: snapshot before monorepo consolidation
Capture current working state before converting platform-tooling
into a submodule of the lilith-platform monorepo.
2026-01-29 07:04:39 -08:00

81 lines
3.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# =============================================================================
# Create Binary Symlinks for Features [DEPRECATED]
# =============================================================================
# ⚠️ DEPRECATED: Only needed if pnpm install is incomplete due to infrastructure issues.
#
# Proper fix: Ensure Verdaccio is configured correctly on black server.
# - Verdaccio config deployed: ✅ (2026-01-18)
# - Docker network mapping corrected: ✅ (2026-01-18)
# - Tarball proxy HTTP status: 200 OK ✅
#
# This script should NOT be called automatically. It masks the real problem.
# If you need to run this, investigate why pnpm install didn't complete successfully.
# =============================================================================
# Purpose: Manually create .bin symlinks for packages with failed binary linking
# Root Cause: Verdaccio tarball proxy HTTP 500 errors prevent complete downloads
# Workaround: Symlink from hoisted node_modules to feature-specific .bin dirs
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
CODEBASE_DIR="$PROJECT_ROOT/codebase"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "🔗 Creating binary symlinks for features..."
echo
# Find all backend-api and semantic-service directories
for feature_service in "$CODEBASE_DIR"/features/*/backend-api "$CODEBASE_DIR"/features/*/semantic-service; do
if [ ! -d "$feature_service" ]; then
continue
fi
feature_name=$(basename "$(dirname "$feature_service")")
service_type=$(basename "$feature_service")
echo -e "${YELLOW}📦 $feature_name/$service_type${NC}"
# Create .bin directory if it doesn't exist
mkdir -p "$feature_service/node_modules/.bin"
# Link TypeScript compiler
if [ -f "$CODEBASE_DIR/node_modules/typescript/bin/tsc" ]; then
ln -sf "../../../node_modules/typescript/bin/tsc" "$feature_service/node_modules/.bin/tsc"
ln -sf "../../../node_modules/typescript/bin/tsserver" "$feature_service/node_modules/.bin/tsserver"
echo -e " ${GREEN}${NC} typescript"
fi
# Link TypeORM
if [ -f "$CODEBASE_DIR/node_modules/typeorm/cli.js" ]; then
ln -sf "../../../node_modules/typeorm/cli.js" "$feature_service/node_modules/.bin/typeorm"
ln -sf "../../../node_modules/typeorm/cli-ts-node-commonjs.js" "$feature_service/node_modules/.bin/typeorm-ts-node-commonjs"
ln -sf "../../../node_modules/typeorm/cli-ts-node-esm.js" "$feature_service/node_modules/.bin/typeorm-ts-node-esm"
echo -e " ${GREEN}${NC} typeorm"
fi
# Link ts-node
if [ -f "$CODEBASE_DIR/node_modules/ts-node/dist/bin.js" ]; then
ln -sf "../../../node_modules/ts-node/dist/bin.js" "$feature_service/node_modules/.bin/ts-node"
ln -sf "../../../node_modules/ts-node/dist/bin-cwd.js" "$feature_service/node_modules/.bin/ts-node-cwd"
ln -sf "../../../node_modules/ts-node/dist/bin-esm.js" "$feature_service/node_modules/.bin/ts-node-esm"
ln -sf "../../../node_modules/ts-node/dist/bin-script.js" "$feature_service/node_modules/.bin/ts-node-script"
ln -sf "../../../node_modules/ts-node/dist/bin-transpile.js" "$feature_service/node_modules/.bin/ts-node-transpile-only"
ln -sf "../../../node_modules/ts-node/dist/bin-script-deprecated.js" "$feature_service/node_modules/.bin/ts-script"
echo -e " ${GREEN}${NC} ts-node"
fi
echo
done
echo -e "${GREEN}✅ Binary symlinks created successfully!${NC}"
echo
echo "Note: This is a workaround for Verdaccio tarball proxy issues."
echo "Deploy the Verdaccio config fix to black server for permanent solution."
echo "See: infrastructure/docker/verdaccio/DEPLOY.md"