#!/bin/bash
set -e

echo "Installing dependencies for slack5-1770529463..."
echo ""

# Check for pnpm, install if not present
if ! command -v pnpm &> /dev/null; then
  echo "Installing pnpm..."
  npm install -g pnpm
fi

# Install all Node dependencies at workspace root (pnpm handles workspace:* refs)
if [ -f "pnpm-lock.yaml" ] || [ -f "package.json" ]; then
  echo "Installing Node dependencies with pnpm..."
  pnpm install
fi

# Install Go dependencies
for dir in services/*/ workers/*/ cli/*/; do
  if [ -f "${dir}go.mod" ]; then
    echo "Installing Go deps for $(basename $dir)..."
    (cd "$dir" && go mod download)
  fi
done

echo ""
echo "All dependencies installed!"
