bookworm-boot/generate-integrity.ps1
bookworm d499342271 feat: Mac 支持 v1.5 同步 + 模板清理 + 卸载脚本
- Bookworm-Setup.sh: 重写为完整 Mac 安装器(依赖检测/代理/配置克隆/凭证解密/别名bw)
- install-mac.sh: 新建重定向脚本,消除文档断链
- uninstall-mac.sh: 新建 Mac 卸载脚本(进程/凭证/历史/别名清理)
- guide-mac.html: 修复所有过时引用(install-mac.sh/start-mac.sh/bookworm→bw)
- settings.template.json: 从 boot 仓库移除(由 build-portable.js 管理)
- prepare-repo.ps1/README/quick-reference: 更新模板引用

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 13:48:05 +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.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