-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·83 lines (70 loc) · 2.09 KB
/
setup.sh
File metadata and controls
executable file
·83 lines (70 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# ============================================================================
# Plante MongoDB Setup Script
# ============================================================================
#
# This script sets up the MongoDB database for the Plante application by:
# 1. Creating required database indexes for optimal query performance
# 2. Seeding achievement definitions
#
# Prerequisites:
# - Node.js installed
# - MONGODB_URI configured in .env file
# - npm dependencies installed (npm install)
#
# Usage:
# chmod +x setup.sh
# ./setup.sh
#
# ============================================================================
set -e # Exit on any error
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo ""
echo "🌱 Plante MongoDB Setup"
echo "========================"
echo ""
# Check if .env file exists and has MONGODB_URI
if [ ! -f .env ]; then
echo -e "${RED}❌ Error: .env file not found${NC}"
echo " Please create a .env file with MONGODB_URI"
echo " You can copy .env.example as a template:"
echo " cp .env.example .env"
exit 1
fi
if ! grep -q "MONGODB_URI=" .env; then
echo -e "${RED}❌ Error: MONGODB_URI not found in .env${NC}"
echo " Please add your MongoDB connection string to .env"
exit 1
fi
# Check if node_modules exists
if [ ! -d "node_modules" ]; then
echo -e "${YELLOW}📦 Installing dependencies...${NC}"
npm install
fi
# Load environment variables from .env
set -a
source .env
set +a
# Step 1: Create indexes
echo -e "${YELLOW}📇 Creating database indexes...${NC}"
npx tsx scripts/db/create-indexes.ts
echo ""
# Step 2: Seed achievements
echo -e "${YELLOW}🏆 Seeding achievements...${NC}"
npx tsx scripts/db/seed-achievements.ts
# Step 3: Seed farms
echo -e "${YELLOW}🌾 Seeding farms...${NC}"
npx tsx scripts/db/seed-farms.ts
echo ""
echo ""
echo -e "${GREEN}✅ Setup complete!${NC}"
echo ""
echo "Next steps:"
echo " 1. Start the dev server: npm run dev"
echo " 2. Navigate to http://localhost:3000"
echo " 3. Sign in with Google to create your user account"
echo ""