#!/bin/bash

# Install all packages
echo "📦 Installing packages..."
pnpm i

# Copy the .env.example file to .env if it doesn't exist and replace the TURBO_TOKEN with the user's token
if [[ ! -f .env ]]; then
  echo "📝 Copying .env.example to .env..."
  cp .env.example .env
fi

# Copy backend/apps/api/.env.example
if [[ ! -f backend/apps/api/.env ]]; then
  echo "📝 Copying backend/apps/api/.env.example to backend/apps/api/.env..."
  cp backend/apps/api/.env.example backend/apps/api/.env
fi

# Copy frontend/.env.example
if [[ ! -f frontend/.env ]]; then
  echo "📝 Copying frontend/.env.example to frontend/.env..."
  cp frontend/.env.example frontend/.env
fi

echo "🚀 Done!"