76 lines
2.1 KiB
Bash
Executable File
76 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "🚀 Setting up Aseret Bank Platform..."
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check if pnpm is installed
|
|
if ! command -v pnpm &> /dev/null; then
|
|
echo -e "${RED}❌ pnpm is not installed. Please install it first:${NC}"
|
|
echo "npm install -g pnpm"
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${GREEN}✅ pnpm found${NC}"
|
|
|
|
# Check if .env exists
|
|
if [ ! -f .env ]; then
|
|
echo -e "${YELLOW}⚠️ .env file not found. Creating from .env.example...${NC}"
|
|
if [ -f .env.example ]; then
|
|
cp .env.example .env
|
|
echo -e "${GREEN}✅ Created .env file. Please update it with your configuration.${NC}"
|
|
else
|
|
echo -e "${RED}❌ .env.example not found${NC}"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo -e "${GREEN}✅ .env file exists${NC}"
|
|
fi
|
|
|
|
# Install dependencies
|
|
echo -e "${YELLOW}📦 Installing dependencies...${NC}"
|
|
pnpm install
|
|
|
|
# Generate Prisma client
|
|
echo -e "${YELLOW}🔧 Generating Prisma client...${NC}"
|
|
pnpm db:generate
|
|
|
|
# Check if Docker is available
|
|
if command -v docker &> /dev/null && command -v docker-compose &> /dev/null; then
|
|
echo -e "${GREEN}✅ Docker found${NC}"
|
|
echo -e "${YELLOW}🐳 Starting Docker services...${NC}"
|
|
docker-compose up -d
|
|
|
|
echo -e "${YELLOW}⏳ Waiting for services to be ready...${NC}"
|
|
sleep 5
|
|
|
|
# Run migrations
|
|
echo -e "${YELLOW}🗄️ Running database migrations...${NC}"
|
|
pnpm db:migrate
|
|
|
|
# Seed database
|
|
echo -e "${YELLOW}🌱 Seeding database...${NC}"
|
|
pnpm db:seed || echo -e "${YELLOW}⚠️ Seeding failed (this is okay if database already has data)${NC}"
|
|
|
|
echo -e "${GREEN}✅ Setup complete!${NC}"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Start development servers: pnpm dev"
|
|
echo "2. Backend API: http://localhost:3001"
|
|
echo "3. Frontend: http://localhost:3000"
|
|
echo "4. API Docs: http://localhost:3001/api-docs"
|
|
else
|
|
echo -e "${YELLOW}⚠️ Docker not found. Skipping database setup.${NC}"
|
|
echo ""
|
|
echo "Please set up PostgreSQL and Redis manually, then run:"
|
|
echo "1. pnpm db:migrate"
|
|
echo "2. pnpm db:seed"
|
|
echo "3. pnpm dev"
|
|
fi
|