Programm_Wirl/UpdateVerwaltungReadMe.ps1

154 lines
4.7 KiB
PowerShell

# =====================================
# Skript: UpdateVerwaltungReadMe.ps1 - mit INSTALL-REMINDER + CHANGES
# =====================================
$ProjectDir = Split-Path $MyInvocation.MyCommand.Path -Parent
$readmePath = Join-Path $ProjectDir "Verwaltung_ReadMe.txt"
Write-Host "Aktualisiere ReadMe in: $ProjectDir"
# ReadMe-Vorlage (falls nicht vorhanden)
if (-not (Test-Path $readmePath)) {
@"
=====================================
NEUIGKEITEN - Version ##VERSION##
=====================================
Build-Info:
- Build-Typ: ##CUSTOM##
- Erledigte TODOs: ##DONE_COUNT##
- Offene TODOs: ##OPEN_COUNT##
- Install-Reminders: ##REMINDER_COUNT##
- Changes: ##CHANGE_COUNT##
##INSTALL_REMINDERS##
##CHANGES##
Installation: ##BUILD_DATE##
=====================================
"@ | Out-File $readmePath -Encoding UTF8
Write-Host "✅ ReadMe-Vorlage erstellt!"
}
# Version bestimmen
$version = "1.0.0.0"
$assemblyInfoPath = Join-Path $ProjectDir "Properties\AssemblyInfo.cs"
if (Test-Path $assemblyInfoPath) {
$assemblyContent = Get-Content $assemblyInfoPath -Raw -ErrorAction SilentlyContinue
if ($assemblyContent -match 'AssemblyVersion\s*\(\s*"([^"]+)"\s*\)') {
$version = $matches[1]
Write-Host "✓ Version: $version"
}
}
# Dateien durchsuchen
$openTodos = @()
$doneTodos = @()
$installReminders = @()
$changes = @()
$csFiles = Get-ChildItem -Path $ProjectDir -Recurse -Filter "*.cs" -ErrorAction SilentlyContinue
foreach ($file in $csFiles) {
$content = Get-Content $file.FullName -Raw -ErrorAction SilentlyContinue
# TODO erkennen
$openMatches = [regex]::Matches($content, '//\s*(TODO|todo:|TODO\[[^x]\])\s*:?\s*(.+?)(?=\r?\n|//|$)', 'IgnoreCase')
foreach ($match in $openMatches) {
$txt = $match.Groups[2].Value.Trim()
if ($txt) { $openTodos += "🔄 $txt [$($file.Name)]" }
}
# DONE erkennen
$doneMatches = [regex]::Matches($content, '//\s*(DONE|TODO:\s*\[x\])\s*(.+?)(?=\r?\n|//|$)', 'IgnoreCase')
foreach ($match in $doneMatches) {
$txt = $match.Groups[2].Value.Trim()
if ($txt) { $doneTodos += "$txt [$($file.Name)]" }
}
# INSTALL-REMINDER erkennen
$reminderMatches = [regex]::Matches($content, '//\s*INSTALL-REMINDER\s*:?\s*(.+?)(?=\r?\n|//|$)', 'IgnoreCase')
foreach ($match in $reminderMatches) {
$txt = $match.Groups[1].Value.Trim()
if ($txt) { $installReminders += "⚙️ $txt [$($file.Name)]" }
}
# CHANGES erkennen
$changeMatches = [regex]::Matches($content, '//\s*CHANGES\s*:?\s*(.+?)(?=\r?\n|//|$)', 'IgnoreCase')
foreach ($match in $changeMatches) {
$txt = $match.Groups[1].Value.Trim()
if ($txt) { $changes += "$txt [$($file.Name)]" }
}
}
# Duplikate entfernen
$openTodos = $openTodos | Sort-Object | Get-Unique
$doneTodos = $doneTodos | Sort-Object | Get-Unique
$installReminders = $installReminders | Sort-Object | Get-Unique
$changes = $changes | Sort-Object | Get-Unique
# Formatierte Abschnitte
$doneSection = if ($doneTodos.Count -gt 0) {
@("=== ✅ ERLEDIGTE TODOs ($($doneTodos.Count)) ===") +
($doneTodos | ForEach-Object { "- $_" })
} else {
@("Keine erledigten TODOs")
}
$openSection = if ($openTodos.Count -gt 0) {
@("=== 🔄 OFFENE TODOs ($($openTodos.Count)) ===") +
($openTodos | ForEach-Object { "- $_" })
} else {
@("Keine offenen TODOs 🎉")
}
$installSection = if ($installReminders.Count -gt 0) {
@("=== ⚙️ INSTALL-REMINDER ($($installReminders.Count)) ===") +
($installReminders | ForEach-Object { "- $_" })
} else {
@("Keine Install-Reminder vorhanden ✅")
}
$changesSection = if ($changes.Count -gt 0) {
@("=== ✨ CHANGES ($($changes.Count)) ===") +
($changes | ForEach-Object { "- $_" })
} else {
@("Keine Changes vorhanden")
}
# Textaufbereitung
$doneText = $doneSection -join "`r`n"
$openText = $openSection -join "`r`n"
$installText = $installSection -join "`r`n"
$changesText = $changesSection -join "`r`n"
$custom = "Release Build"
$buildDate = Get-Date -Format "dd.MM.yyyy HH:mm"
# ReadMe aufbauen (CHANGES nach INSTALL-REMINDER)
$readmeContent = @"
=====================================
NEUIGKEITEN - Version $version
=====================================
Build-Info:
- Build-Typ: $custom
- Erledigte TODOs: $($doneTodos.Count)
- Offene TODOs: $($openTodos.Count)
- Install-Reminders: $($installReminders.Count)
- Changes: $($changes.Count)
$changesText
$installText
Installation: $buildDate
=====================================
"@
# Schreiben
$readmeContent | Out-File $readmePath -Encoding UTF8
Write-Host "✅ Verwaltung_ReadMe.txt erfolgreich aktualisiert!"
Write-Host "📊 Stats: $($doneTodos.Count) DONE, $($openTodos.Count) TODO, $($installReminders.Count) REMINDER, $($changes.Count) CHANGES"