This commit is contained in:
commit
41816fbbae
21 files changed
+1003
No files matched your search
@@ -0,0 +1,77 @@
|
||||
# Prueft alle Skills (oder nur den angegebenen) auf die Regeln aus CONTRIBUTING.md.
|
||||
# Aufruf: scripts\validate.ps1 [-Name <skill-name>]
|
||||
param([string]$Name)
|
||||
. (Join-Path $PSScriptRoot 'lib.ps1')
|
||||
|
||||
function Test-Skill([string]$N) {
|
||||
$dir = Join-Path $SkillsDir $N
|
||||
if (-not (Test-Path $dir -PathType Container)) { return @("Ordner skills/$N existiert nicht") }
|
||||
|
||||
$errs = @(Get-NameErrors $N)
|
||||
$skill = Join-Path $dir 'SKILL.md'
|
||||
|
||||
if (-not (Test-Path $skill)) {
|
||||
$errs += 'SKILL.md fehlt'
|
||||
}
|
||||
elseif (Test-Bom $skill) {
|
||||
$errs += 'SKILL.md beginnt mit einem BOM - als UTF-8 ohne BOM speichern'
|
||||
}
|
||||
else {
|
||||
$fm = Get-Frontmatter $skill
|
||||
if ($null -eq $fm) {
|
||||
$errs += "SKILL.md hat kein Frontmatter (erste Zeile '---', danach schliessendes '---')"
|
||||
}
|
||||
else {
|
||||
$fmName = Get-FmValue $fm 'name'
|
||||
if (-not $fmName) { $errs += "Frontmatter: 'name' fehlt" }
|
||||
elseif ($fmName -cne $N) { $errs += "Frontmatter: name '$fmName' passt nicht zum Ordnernamen '$N'" }
|
||||
|
||||
$desc = Get-FmValue $fm 'description'
|
||||
if (-not $desc) {
|
||||
$errs += "Frontmatter: 'description' fehlt oder ist leer"
|
||||
}
|
||||
else {
|
||||
if ($desc.Length -gt 1024) { $errs += "Frontmatter: description ist laenger als 1024 Zeichen ($($desc.Length))" }
|
||||
if ($desc -match '[<>]') { $errs += 'Frontmatter: description darf keine spitzen Klammern < > enthalten' }
|
||||
$raw = Get-FmRaw $fm 'description'
|
||||
if (-not ($raw.StartsWith('"') -or $raw.StartsWith("'")) -and $raw.Contains(': ')) {
|
||||
$errs += "Frontmatter: description enthaelt ': ' - in Anfuehrungszeichen setzen, sonst ist das YAML ungueltig"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path (Join-Path $dir 'CHANGELOG.md'))) {
|
||||
$errs += 'CHANGELOG.md fehlt'
|
||||
}
|
||||
else {
|
||||
$h = Get-ChangelogHeading $dir
|
||||
if (-not $h) { $errs += "CHANGELOG.md hat keinen Eintrag '## x.y.z (YYYY-MM-DD)'" }
|
||||
elseif (-not (Get-SkillVersion $dir)) { $errs += "CHANGELOG.md: oberster Eintrag '$h' hat nicht das Format '## x.y.z (YYYY-MM-DD)'" }
|
||||
}
|
||||
|
||||
return $errs
|
||||
}
|
||||
|
||||
if ($Name) { $names = @($Name) } else { $names = @(Get-SkillNames) }
|
||||
|
||||
if ($names.Count -eq 0) {
|
||||
Write-Host 'Keine Skills unter skills/ gefunden.'
|
||||
exit 0
|
||||
}
|
||||
|
||||
$failed = $false
|
||||
foreach ($n in $names) {
|
||||
$errs = @(Test-Skill $n)
|
||||
if ($errs.Count -eq 0) {
|
||||
Write-Host ("OK {0} ({1})" -f $n, (Get-SkillVersion (Join-Path $SkillsDir $n)))
|
||||
}
|
||||
else {
|
||||
Write-Host "FEHLER $n"
|
||||
foreach ($e in $errs) { Write-Host " - $e" }
|
||||
$failed = $true
|
||||
}
|
||||
}
|
||||
|
||||
if ($failed) { exit 1 }
|
||||
exit 0
|
||||
Reference in new issue
Block a user