171 lines
5.9 KiB
PowerShell
171 lines
5.9 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
<#
|
|
.SYNOPSIS
|
|
Akiyama Manga Setup Helper Script
|
|
.DESCRIPTION
|
|
Quick setup script for Windows developers
|
|
.EXAMPLE
|
|
./setup.ps1
|
|
#>
|
|
|
|
function Show-Welcome {
|
|
Write-Host @"
|
|
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ ║
|
|
║ 🎌 AKIYAMA MANGA - Quick Setup Assistant 🎌 ║
|
|
║ ║
|
|
║ A modern manga platform written in Go with S3 support ║
|
|
║ ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
|
|
"@ -ForegroundColor Cyan
|
|
}
|
|
|
|
function Show-Menu {
|
|
Write-Host "Choose setup option:" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "1️⃣ Quick Start with Docker (Recommended)" -ForegroundColor Green
|
|
Write-Host "2️⃣ Local Development Setup" -ForegroundColor Green
|
|
Write-Host "3️⃣ View Documentation" -ForegroundColor Cyan
|
|
Write-Host "4️⃣ Exit" -ForegroundColor Red
|
|
Write-Host ""
|
|
}
|
|
|
|
function Setup-Docker {
|
|
Write-Host "🐳 Setting up with Docker..." -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Check if Docker is installed
|
|
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
|
Write-Host "❌ Docker is not installed!" -ForegroundColor Red
|
|
Write-Host "Please install Docker from: https://www.docker.com/products/docker-desktop" -ForegroundColor Yellow
|
|
return
|
|
}
|
|
|
|
Write-Host "✅ Docker found!" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# Copy .env
|
|
if (-not (Test-Path ".env")) {
|
|
Write-Host "📋 Creating .env file..." -ForegroundColor Yellow
|
|
Copy-Item ".env.example" ".env"
|
|
Write-Host "✅ .env created!" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "⚠️ IMPORTANT: Edit .env with your S3 credentials" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Read-Host "Press Enter to open .env in Notepad (or close and edit manually)"
|
|
|
|
notepad ".env"
|
|
|
|
Write-Host ""
|
|
Write-Host "🚀 Starting Docker containers..." -ForegroundColor Cyan
|
|
docker-compose up -d
|
|
|
|
Write-Host ""
|
|
Write-Host "✅ Setup complete!" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Services are running at:" -ForegroundColor Cyan
|
|
Write-Host " 📱 Application: http://localhost:8080" -ForegroundColor Green
|
|
Write-Host " 🗄️ PgAdmin: http://localhost:5050 (admin/admin)" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "View logs: docker-compose logs -f app" -ForegroundColor Yellow
|
|
}
|
|
|
|
function Setup-Local {
|
|
Write-Host "💻 Setting up for local development..." -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Check Go
|
|
if (-not (Get-Command go -ErrorAction SilentlyContinue)) {
|
|
Write-Host "❌ Go is not installed!" -ForegroundColor Red
|
|
Write-Host "Please install Go from: https://go.dev/dl/" -ForegroundColor Yellow
|
|
return
|
|
}
|
|
|
|
Write-Host "✅ Go found: $(go version)" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# Check PostgreSQL
|
|
$pgInstalled = Get-Command psql -ErrorAction SilentlyContinue
|
|
if (-not $pgInstalled) {
|
|
Write-Host "⚠️ PostgreSQL not found in PATH" -ForegroundColor Yellow
|
|
Write-Host "Please install PostgreSQL: https://www.postgresql.org/download/windows/" -ForegroundColor Yellow
|
|
return
|
|
}
|
|
|
|
Write-Host "✅ PostgreSQL found!" -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
# Setup environment
|
|
if (-not (Test-Path ".env")) {
|
|
Copy-Item ".env.example" ".env"
|
|
Write-Host "✅ .env created" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "📖 Next steps:" -ForegroundColor Cyan
|
|
Write-Host "1. Follow DATABASE_SETUP.md to create the database" -ForegroundColor Yellow
|
|
Write-Host "2. Follow S3_SETUP.md to configure S3" -ForegroundColor Yellow
|
|
Write-Host "3. Edit .env with your configuration" -ForegroundColor Yellow
|
|
Write-Host "4. Run: go mod download" -ForegroundColor Yellow
|
|
Write-Host "5. Run: go run cmd/server/main.go" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
}
|
|
|
|
function Show-Docs {
|
|
Write-Host "📚 Available Documentation:" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "📖 Quick Start" -ForegroundColor Yellow
|
|
Write-Host " 👉 QUICKSTART.md - Get running in 5 minutes"
|
|
Write-Host ""
|
|
Write-Host "🔧 Setup Guides" -ForegroundColor Yellow
|
|
Write-Host " 👉 DATABASE_SETUP.md - PostgreSQL configuration"
|
|
Write-Host " 👉 S3_SETUP.md - AWS S3 and alternatives"
|
|
Write-Host ""
|
|
Write-Host "📚 Development" -ForegroundColor Yellow
|
|
Write-Host " 👉 README.md - Full project documentation"
|
|
Write-Host " 👉 API.md - REST API reference"
|
|
Write-Host " 👉 CONTRIBUTING.md - Development guidelines"
|
|
Write-Host ""
|
|
Write-Host "🚀 Deployment" -ForegroundColor Yellow
|
|
Write-Host " 👉 DEPLOYMENT.md - Production deployment guide"
|
|
Write-Host ""
|
|
Write-Host "📇 Project Info" -ForegroundColor Yellow
|
|
Write-Host " 👉 INDEX.md - Project overview"
|
|
Write-Host ""
|
|
}
|
|
|
|
# Main loop
|
|
Show-Welcome
|
|
|
|
while ($true) {
|
|
Show-Menu
|
|
$choice = Read-Host "Enter your choice (1-4)"
|
|
|
|
switch ($choice) {
|
|
"1" {
|
|
Setup-Docker
|
|
break
|
|
}
|
|
"2" {
|
|
Setup-Local
|
|
break
|
|
}
|
|
"3" {
|
|
Show-Docs
|
|
Write-Host ""
|
|
Read-Host "Press Enter to continue"
|
|
}
|
|
"4" {
|
|
Write-Host "Goodbye! 👋" -ForegroundColor Cyan
|
|
exit 0
|
|
}
|
|
default {
|
|
Write-Host "Invalid choice. Please try again." -ForegroundColor Red
|
|
}
|
|
}
|
|
}
|