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" ) . (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) { $tree += " frontend/ # $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 += "| Frontend | $FrontendMode |`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" } } # --- 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) { $frontendSection = @" ## Frontend Framework: **$FrontendMode** ``````bash cd frontend npm install npm run dev `````` > Varsayilan adres: http://localhost:5173 "@ } # --- 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 |