Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
62 lines
1.5 KiB
Bash
Executable file
62 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
# Sync scripts to Cloudflare R2 before build
|
|
# This script uploads manuals and thumbnails to R2, then builds the Next.js app
|
|
|
|
set -e # Exit on error
|
|
|
|
echo "🚀 Syncing assets to R2 and building..."
|
|
|
|
# Check if we're in the right directory
|
|
if [ ! -f "package.json" ]; then
|
|
echo "❌ Error: Must run from code/ directory"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for required environment variables
|
|
if [ -z "$CLOUDFLARE_R2_ACCESS_KEY_ID" ] || [ -z "$CLOUDFLARE_R2_SECRET_ACCESS_KEY" ]; then
|
|
echo "⚠️ Warning: R2 credentials not set. Skipping R2 upload."
|
|
echo " Set CLOUDFLARE_R2_ACCESS_KEY_ID and CLOUDFLARE_R2_SECRET_ACCESS_KEY to enable uploads"
|
|
SKIP_R2=true
|
|
else
|
|
SKIP_R2=false
|
|
fi
|
|
|
|
# Upload to R2 if credentials are available
|
|
if [ "$SKIP_R2" = false ]; then
|
|
echo ""
|
|
echo "📤 Uploading to R2..."
|
|
|
|
# Check if upload script exists
|
|
if [ ! -f "scripts/upload-to-r2.js" ]; then
|
|
echo "❌ Error: upload-to-r2.js not found"
|
|
exit 1
|
|
fi
|
|
|
|
# Run upload script
|
|
node scripts/upload-to-r2.js --type all --incremental
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ R2 upload completed"
|
|
else
|
|
echo "⚠️ R2 upload failed, but continuing with build..."
|
|
fi
|
|
else
|
|
echo "⏭️ Skipping R2 upload (credentials not set)"
|
|
fi
|
|
|
|
# Build Next.js app
|
|
echo ""
|
|
echo "🔨 Building Next.js app..."
|
|
npm run build
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo ""
|
|
echo "✅ Build completed successfully!"
|
|
echo "📁 Output directory: out/"
|
|
else
|
|
echo ""
|
|
echo "❌ Build failed"
|
|
exit 1
|
|
fi
|
|
|
|
|