# AIK Digital × EFU Life — Quick Setup Script (Windows PowerShell)
# Run: .\setup.ps1

Write-Host "=== AIK Digital x EFU Life Setup ===" -ForegroundColor Cyan

# 1. Install dependencies
Write-Host "`n[1/5] Installing Composer dependencies..." -ForegroundColor Yellow
composer install

# 2. Copy env
if (-Not (Test-Path ".env")) {
    Copy-Item ".env.example" ".env"
    Write-Host "[2/5] Created .env from .env.example" -ForegroundColor Yellow
} else {
    Write-Host "[2/5] .env already exists — skipped" -ForegroundColor Gray
}

# 3. Generate app key
Write-Host "`n[3/5] Generating application key..." -ForegroundColor Yellow
php artisan key:generate

# 4. Generate RSA keys
Write-Host "`n[4/5] Generating RSA keys..." -ForegroundColor Yellow
php generate-keys.php

# 5. Run migrations (SQLite, no DB config needed)
Write-Host "`n[5/5] Running database migrations..." -ForegroundColor Yellow
php artisan migrate --force

Write-Host "`n=== Setup Complete! ===" -ForegroundColor Green
Write-Host ""
Write-Host "NEXT STEPS:" -ForegroundColor Cyan
Write-Host "  1. Edit .env and set your AIK_CLIENT_ID, AIK_API_KEY, AIK_MERCHANT_ID"
Write-Host "  2. Share storage/keys/efu_public.pem with AIK Digital"
Write-Host "  3. Replace storage/keys/aik_public.pem with AIK Digital's public key"
Write-Host "  4. Run: php artisan serve"
Write-Host "  5. Import AIK_EFU_Integration.postman_collection.json into Postman"
Write-Host ""
Write-Host "Server will be at: http://localhost:8000" -ForegroundColor Green
