#!/bin/bash # Vercel Project Setup Script for AudiobookPipeline # This script creates and configures the Vercel project # Requires: VERCEL_TOKEN environment variable or `vercel login` set -e echo "🚀 Setting up Vercel project for AudiobookPipeline..." # Check if Vercel CLI is installed if ! npx vercel --version &> /dev/null; then echo "đŸ“Ļ Installing Vercel CLI..." npm install -g vercel fi VERCEL_CMD="npx vercel" # Use VERCEL_TOKEN if available, otherwise require login if [ -n "$VERCEL_TOKEN" ]; then echo "🔐 Using VERCEL_TOKEN for authentication..." export VERCEL_TOKEN else echo "🔐 Authenticating with Vercel..." $VERCEL_CMD login fi # Create Vercel project echo "📁 Creating Vercel project..." PROJECT=$($VERCEL_CMD ls | grep -i audiobookpipeline || echo "") if [ -z "$PROJECT" ]; then $VERCEL_CMD init --name audiobookpipeline --framework vite echo "✅ Project created successfully" else echo "â„šī¸ Project already exists: $PROJECT" fi # Configure environment variables echo "âš™ī¸ Configuring environment variables..." # Read from .env.local and set in Vercel if [ -f ".env.local" ]; then while IFS='=' read -r key value; do # Skip comments and empty lines [[ "$key" =~ ^#.*$ ]] && continue [[ -z "$key" ]] && continue # Remove any trailing whitespace value=$(echo "$value" | xargs) echo "Setting $key..." $VERCEL_CMD env set "$key" "$value" --env production --override $VERCEL_CMD env set "$key" "$value" --env development --override $VERCEL_CMD env set "$key" "$value" --env preview --override done < .env.local echo "✅ Environment variables configured" else echo "âš ī¸ .env.local not found. Please create it with the required variables." fi # Deploy to verify configuration echo "đŸšĸ Testing deployment..." $VERCEL_CMD deploy --prod --prebuilt echo "✨ Vercel setup complete!" echo "📎 View your deployment at: https://audiobookpipeline.vercel.app"