bookworm-boot/generate-integrity.ps1
bookworm 5e0ff18aa1 feat: Bookworm Portable v1.5 — 8 fixes (P0 NDA + P1 banners + P2 perf)
- P1: Banner v1.3→v1.5, Hooks 29→34
- P1: 卸载脚本补删 更新Bookworm.lnk
- P1: git stash pop 安全检查
- P2: Playwright 检测改用 npm list
- P2: 代理端口扫描 500ms async 超时

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 23:34:27 +08:00

52 lines
1.5 KiB
PowerShell

<#
.SYNOPSIS
生成 integrity.sha256 文件
.DESCRIPTION
计算 hooks 和关键配置文件的 SHA256 哈希,
写入 integrity.sha256 供 install.ps1 校验.
每次 prepare-repo.ps1 推送前应运行此脚本.
.USAGE
.\generate-integrity.ps1
#>
$ClaudeDir = Join-Path $env:USERPROFILE ".claude"
$OutputFile = Join-Path $ClaudeDir "integrity.sha256"
if (-not (Test-Path $ClaudeDir)) {
Write-Host "[ERROR] .claude 目录不存在" -ForegroundColor Red
exit 1
}
Write-Host " 生成 integrity.sha256..." -ForegroundColor Cyan
# 需要校验的关键文件模式
$patterns = @(
"hooks/*.js",
"hooks/lib/*.js",
"scripts/paths.config.js",
"CLAUDE.md",
"settings.template.json",
"settings.local.template.json"
)
$hashes = @()
foreach ($pattern in $patterns) {
$fullPattern = Join-Path $ClaudeDir $pattern
foreach ($file in (Get-Item $fullPattern -ErrorAction SilentlyContinue)) {
$hash = (Get-FileHash $file.FullName -Algorithm SHA256).Hash.ToLower()
$relPath = $file.FullName.Substring($ClaudeDir.Length + 1).Replace('\', '/')
$hashes += "$hash $relPath"
}
}
# 去重并排序
$hashes = $hashes | Sort-Object -Unique
$hashes | Set-Content $OutputFile -Encoding UTF8
$count = $hashes.Count
Write-Host " [OK] 已生成 $count 个文件哈希" -ForegroundColor Green
Write-Host " 路径: $OutputFile" -ForegroundColor Gray
Write-Host ""
Write-Host " 注意: 请在 git commit 前运行此脚本" -ForegroundColor Yellow