This commit is contained in:
commit
41816fbbae
21 files changed
+1003
No files matched your search
@@ -0,0 +1,49 @@
|
||||
# Erzeugt die Skill-Tabelle in README.md zwischen <!-- skills:start --> und <!-- skills:end -->
|
||||
# neu. Mit -Check wird nur geprueft, ob die Tabelle aktuell ist (Exit-Code 1, wenn nicht).
|
||||
# Aufruf: scripts\update-readme.ps1 [-Check]
|
||||
param([switch]$Check)
|
||||
. (Join-Path $PSScriptRoot 'lib.ps1')
|
||||
|
||||
$readme = Join-Path $Root 'README.md'
|
||||
$current = Read-Text $readme
|
||||
$lines = $current -split "`n"
|
||||
$start = [Array]::IndexOf($lines, '<!-- skills:start -->')
|
||||
$end = [Array]::IndexOf($lines, '<!-- skills:end -->')
|
||||
if ($start -lt 0 -or $end -lt $start) {
|
||||
Write-Error 'README.md enthaelt die Marker <!-- skills:start --> / <!-- skills:end --> nicht.'
|
||||
exit 1
|
||||
}
|
||||
|
||||
$table = @('| Skill | Beschreibung | Version |', '|---|---|---|')
|
||||
foreach ($n in (Get-SkillNames)) {
|
||||
$dir = Join-Path $SkillsDir $n
|
||||
$desc = ''
|
||||
$skill = Join-Path $dir 'SKILL.md'
|
||||
if (Test-Path $skill) {
|
||||
$fm = Get-Frontmatter $skill
|
||||
if ($null -ne $fm) {
|
||||
$d = Get-FmValue $fm 'description'
|
||||
if ($d) { $desc = $d }
|
||||
}
|
||||
}
|
||||
$desc = $desc.Replace('|', '\|')
|
||||
$table += ('| [{0}](skills/{0}/) | {1} | {2} |' -f $n, $desc, (Get-SkillVersion $dir))
|
||||
}
|
||||
|
||||
$newLines = @()
|
||||
if ($start -ge 0) { $newLines += $lines[0..$start] }
|
||||
$newLines += $table
|
||||
$newLines += $lines[$end..($lines.Count - 1)]
|
||||
$new = $newLines -join "`n"
|
||||
|
||||
if ($Check) {
|
||||
if ($new -cne $current) {
|
||||
Write-Host 'README.md ist nicht aktuell - scripts\update-readme.ps1 ausfuehren und committen.'
|
||||
exit 1
|
||||
}
|
||||
Write-Host 'README.md ist aktuell.'
|
||||
}
|
||||
else {
|
||||
Write-Text $readme $new
|
||||
Write-Host 'README.md aktualisiert.'
|
||||
}
|
||||
Reference in new issue
Block a user