185 lines
5.5 KiB
PowerShell
185 lines
5.5 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
|
||
$changesList = @()
|
||
$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
|
||
$pattern = '//\s*CHANGES\s*:?\s*(.+?)(?=\r?\n|//|$)'
|
||
|
||
$changeMatches = [regex]::Matches($content, $pattern, 'IgnoreCase')
|
||
foreach ($match in $changeMatches) {
|
||
$txt = $match.Groups[1].Value.Trim()
|
||
if ($txt) {
|
||
$changesList += [PSCustomObject]@{
|
||
Datei = if ($file.Name.StartsWith("Form")) {
|
||
$file.Name.Substring(4)
|
||
} else {$file.Name}
|
||
Text = $txt
|
||
}
|
||
}
|
||
$markdownLines = @()
|
||
|
||
# Nach Class gruppieren, Class‑Namen sortieren, dann pro Gruppe Text sortieren
|
||
$changesList |
|
||
Group-Object -Property Datei |
|
||
Sort-Object -Property Name |
|
||
ForEach-Object {
|
||
$datei = $_.Name
|
||
|
||
$markdownLines += "## $datei ##"
|
||
$markdownLines += ""
|
||
|
||
$_.Group |
|
||
Sort-Object -Property Text |
|
||
ForEach-Object {
|
||
$markdownLines += "- ✨ $($_.Text)"
|
||
}
|
||
|
||
$markdownLines += ""
|
||
}
|
||
}
|
||
}
|
||
|
||
# Duplikate entfernen
|
||
$openTodos = $openTodos | Sort-Object | Get-Unique
|
||
$doneTodos = $doneTodos | Sort-Object | Get-Unique
|
||
$installReminders = $installReminders | 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 ($markdownLines.Count -gt 0) {
|
||
@("=== ✨ CHANGES ($($markdownLines.Count)) ===") +
|
||
($markdownLines | 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"
|
||
$markdown = $markdownLines -join "`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: $($changesList.Count)
|
||
|
||
=== ✨ CHANGES ($($changesList.Count)) ===
|
||
$markdown
|
||
|
||
$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"
|