modules/core/Get-GeneratorVersion.ps1
|
#Requires -Version 5.1 <# .SYNOPSIS Generator versiyonunu ve son degisiklikleri gosterir. .EXAMPLE .\Get-GeneratorVersion.ps1 .\Get-GeneratorVersion.ps1 -Full # Tum changelog gosterilir #> param( [switch]$Full, [switch]$OnlyVersion, [Alias("h")] [switch]$Help ) if ($Help) { Write-Host "" Write-Host " Get-GeneratorVersion" -ForegroundColor Cyan Write-Host " --------------------" -ForegroundColor DarkCyan Write-Host " Generator versiyonunu ve son degisiklikleri (changelog) gosterir." Write-Host "" Write-Host " Parametreler:" Write-Host " -Full : Tum changelog gecmisini gosterir" Write-Host " -OnlyVersion : Sadece versiyon numarasini dondurur (0.0.0)" Write-Host "" return } $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $GenRoot = Split-Path (Split-Path $ScriptDir -Parent) -Parent $ManifestPath = Join-Path $GenRoot "generator.manifest.json" $ChangelogPath = Join-Path (Split-Path $GenRoot -Parent) "docs\releases\changelog.md" $KnownIssues = Join-Path (Split-Path $GenRoot -Parent) "docs\technical\known-issues.md" # 1. Version extraction from manifest (Primary source of truth) $Version = "0.0.0" if (Test-Path $ManifestPath) { $manifest = Get-Content $ManifestPath | ConvertFrom-Json $Version = $manifest.version } elseif (Test-Path $ChangelogPath) { # Fallback to changelog $lines = Get-Content $ChangelogPath $versionLine = $lines | Where-Object { $_ -match '^\s*##\s*\[v' } | Select-Object -First 1 if ($versionLine -match '\[v?(.+?)\]') { $Version = $Matches[1] } } if ($OnlyVersion) { return $Version } Write-Host "" Write-Host " Clean Architecture Template Generator" -ForegroundColor Cyan Write-Host " --------------------------------------" -ForegroundColor DarkCyan Write-Host " Versiyon : v$Version" -ForegroundColor White if (Test-Path $ChangelogPath) { $lines = Get-Content $ChangelogPath Write-Host "" if ($Full) { Write-Host "--- CHANGELOG -------------------------------" -ForegroundColor DarkCyan $lines | ForEach-Object { Write-Host " $_" } } else { # Son versiyonun icerigi (ilk ## blogu) $inBlock = $false $blockLines = @() foreach ($line in $lines) { if ($line -match '^\s*##\s*\[v') { if ($inBlock) { break } $inBlock = $true continue } if ($inBlock) { $blockLines += $line } } Write-Host " Son degisiklikler:" -ForegroundColor White $blockLines | Select-Object -First 15 | ForEach-Object { Write-Host " $_" } Write-Host "" Write-Host " Tum gecmis icin: (docs/releases/changelog.md)" -ForegroundColor DarkGray } } if (Test-Path $KnownIssues) { $issues = Get-Content $KnownIssues | Where-Object { $_ -match '^\s*-\s*\[' } | Select-Object -First 5 if ($issues) { Write-Host " Acik sorunlar:" -ForegroundColor Yellow $issues | ForEach-Object { Write-Host " $_" -ForegroundColor DarkYellow } Write-Host "" } } Write-Host " Moduller dizini : $(Split-Path $ScriptDir -Parent)" -ForegroundColor DarkGray Write-Host " Dokumantasyon : docs/README.md" -ForegroundColor DarkGray Write-Host "" |