modules/solution/Write-Readme.ps1
|
param( [string]$ProjectName, [string]$OrmMode, [string]$DbProvider, [string]$FrontendMode, [string[]]$Entities, [string]$OutputPath, [bool]$SkipFrontend = $false, [bool]$SkipTests = $false, [bool]$SkipCi = $false, [switch]$Observability, [string]$CiProvider = "GitHub", [string]$Platform = "Web", [string]$ConnectionString = "" ) . (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "..\core\Utils.ps1") # --- Proje yapisi (ASCII agac) --- $tree = "$ProjectName/`n" $tree += " src/`n" $tree += " $ProjectName.Domain/ # Entity'ler, arayuzler, is kurallari`n" $tree += " $ProjectName.Application/ # Use case'ler, CQRS handler'lar, DTO'lar`n" $tree += " $ProjectName.Infrastructure/ # Harici servisler, kimlik dogrulama`n" $tree += " $ProjectName.Persistence/ # Veritabani erisimi ($OrmMode)`n" $tree += " $ProjectName.WebApi/ # REST API, controller'lar, middleware`n" if (-not $SkipTests) { $tree += " tests/`n" $tree += " $ProjectName.Domain.Tests/`n" $tree += " $ProjectName.Application.Tests/`n" $tree += " $ProjectName.Integration.Tests/`n" } if (-not $SkipFrontend) { if ($Platform -eq "Both") { $tree += " apps/`n" $tree += " web/ # Web ($FrontendMode) uygulamasi`n" $tree += " mobile/ # Mobil (React Native / Expo) uygulamasi`n" $tree += " packages/`n" $tree += " shared/ # Web/Mobile ortak tipler, apiClient ve i18n`n" } elseif ($Platform -eq "Mobile") { $tree += " mobile/ # Mobil (React Native / Expo) uygulamasi`n" } else { $tree += " frontend/ # Web ($FrontendMode) uygulamasi`n" } } $tree += " docker-compose.yml" # --- Teknoloji tablosu --- $techTable = "| Katman | Teknoloji |`n" $techTable += "|---------------|--------------------------------|`n" $techTable += "| Backend | .NET 8, ASP.NET Core |`n" $techTable += "| ORM | $OrmMode |`n" $techTable += "| Veritabani | $DbProvider |`n" if (-not $SkipFrontend) { $techTable += "| Platform | $Platform |`n" if ($Platform -match "Web|Both") { $techTable += "| Web UI | $FrontendMode |`n" } if ($Platform -match "Mobile|Both") { $techTable += "| Mobile UI | React Native / Expo Go |`n" } } $techTable += "| Auth | JWT Bearer |" if ($Observability) { $techTable += "`n| Logging | Serilog + OpenTelemetry |" } # --- Baglanti dizesi --- $dbConnectionString = switch ($DbProvider) { "MSSQL" { "Server=localhost;Database=$ProjectName;Trusted_Connection=True;TrustServerCertificate=True" } "Postgres" { "Host=localhost;Database=$ProjectName;Username=postgres;Password=your_password" } "SQLite" { "Data Source=$ProjectName.db" } } if ($ConnectionString) { $dbConnectionString = $ConnectionString } # --- Migration bolumu --- $migrationSection = "" if ($OrmMode -ne "Dapper") { $migrationSection = @" ## Veritabani Migration ```bash dotnet ef migrations add InitialCreate --project src/$ProjectName.Persistence --startup-project src/$ProjectName.WebApi dotnet ef database update --project src/$ProjectName.Persistence --startup-project src/$ProjectName.WebApi ``` "@ } # --- Frontend bolumu --- $frontendSection = "" if (-not $SkipFrontend) { if ($Platform -match "Web|Both") { $webDir = "frontend" if ($Platform -eq "Both") { $webDir = "apps/web" } $frontendSection += @" ## Web Frontend Framework: **$FrontendMode** ```bash cd $webDir npm install npm run dev ``` > Varsayilan adres: http://localhost:5173 (NextJS ise http://localhost:3000) "@ } if ($Platform -match "Mobile|Both") { $mobileDir = "mobile" if ($Platform -eq "Both") { $mobileDir = "apps/mobile" } $frontendSection += @" ## Mobil Frontend Framework: **React Native (Expo Managed Workflow)** ```bash cd $mobileDir npm install npm start ``` > Expo Metro bundler basladiktan sonra QR kodu telefonunuzla taratarak Expo Go uzerinden test edebilirsiniz. "@ } } # --- CI bolumu --- $ciSection = "" if (-not $SkipCi) { $ciFile = switch ($CiProvider) { "GitHub" { ".github/workflows/ci.yml" } "GitLab" { ".gitlab-ci.yml" } default { "" } } if ($ciFile) { $ciSection = @" ## CI/CD $CiProvider pipeline: ``$ciFile`` Her push ve pull request'te otomatik build + test calisir. "@ } } # --- Observability bolumu --- $obsSection = "" if ($Observability) { $obsSection = @" ## Observability - **Serilog** ile yapilandirilmis loglama - **OpenTelemetry** ile tracing ve metrics "@ } # --- Entity listesi --- $entityList = ($Entities | ForEach-Object { "- ``$_``" }) -join "`n" # --- Gereksinimler --- $prereqs = "- .NET 8 SDK" if (-not $SkipFrontend) { $prereqs += "`n- Node.js 18+" } if ($DbProvider -eq "MSSQL") { $prereqs += "`n- SQL Server (veya Docker)" } if ($DbProvider -eq "Postgres") { $prereqs += "`n- PostgreSQL (veya Docker)" } $content = @" # $ProjectName Clean Architecture tabanli .NET 8 projesi. Bu proje **Clean Architecture Template Generator** ile olusturulmustur. ## Proje Yapisi ``` $tree ``` ## Teknoloji Yigini $techTable ## Entity'ler $entityList ## Baslangic ### Gereksinimler $prereqs ### Backend ```bash # Baglanti dizesini ayarla # src/$ProjectName.WebApi/appsettings.json icinde: # "ConnectionStrings": { "DefaultConnection": "$dbConnectionString" } dotnet restore dotnet build dotnet run --project src/$ProjectName.WebApi ``` > Swagger UI: http://localhost:5000/swagger $frontendSection $migrationSection ## Kimlik Dogrulama JWT tabanli kimlik dogrulama kullanilmaktadir. ### Varsayilan Kullanici (Seed) | Alan | Deger | |----------|------------| | Kullanici Adi | ``admin`` | | Sifre | ``Admin123!`` | > Uretim ortaminda bu sifreyi degistirin. ### Giris Akisi 1. ``POST /api/auth/login`` -- Kullanici adi ve sifre ile token alin 2. Swagger'da **Authorize** butonuna tiklayin ve ``Bearer <token>`` girin 3. ``POST /api/auth/register`` -- Yeni kullanici olusturmak icin $ciSection $obsSection ## Docker ile Calistirma ```bash docker compose up -d --build ``` "@ Write-CoreFile (Join-Path $OutputPath "README.md") $content |