Files
jiapuapp/tests/repository-hygiene-contract.ps1
T
2026-07-22 17:31:38 +08:00

41 lines
1.3 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$ignorePath = Join-Path $root '.gitignore'
if (-not (Test-Path -LiteralPath $ignorePath -PathType Leaf)) {
throw '仓库缺少 .gitignore'
}
$ignore = Get-Content -Raw -Encoding UTF8 -LiteralPath $ignorePath
# 第一步:只锁定仍有长期价值的依赖、构建输出和本地验证缓存,避免把可再生成内容混入正式资料。
foreach ($pattern in @(
'**/node_modules/',
'/tmp/',
'/unpackage/',
'/.vite/',
'/design-pipeline/generated/'
)) {
if (-not $ignore.Contains($pattern)) {
throw "缺少仓库卫生忽略规则:$pattern"
}
}
# 已退役资料没有合法生产者,继续忽略只会把回归重新藏起来。
foreach ($retiredPattern in @(
'/docs/design/screens/runtime/',
'/docs/superpowers/specs/design/'
)) {
if ($ignore.Contains($retiredPattern)) {
throw "仍在忽略已退役的资料目录:$retiredPattern"
}
}
# 第二步:曾经误放到规格目录中的设计归档不能重新成为当前资料入口。
$misplacedDesignDirectory = Join-Path $root 'docs/superpowers/specs/design'
if (Test-Path -LiteralPath $misplacedDesignDirectory) {
throw '规格目录中重新出现了错误放置的设计归档'
}
Write-Output 'REPOSITORY-HYGIENE-CONTRACT PASS'