chore: unify HA manufacturer and add refactor guards

This commit is contained in:
2026-02-18 02:25:07 +01:00
parent 00b2eb859a
commit 9495e7e8de
6 changed files with 171 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).ProviderPath
$configPath = (Resolve-Path (Join-Path $repoRoot "include/config.h")).ProviderPath
$mqttPath = (Resolve-Path (Join-Path $repoRoot "src/mqtt_client.cpp")).ProviderPath
$configText = Get-Content -Raw -Path $configPath
if ($configText -notmatch 'HA_MANUFACTURER\[\]\s*=\s*"AcidBurns"\s*;') {
throw "include/config.h must define HA_MANUFACTURER as exactly ""AcidBurns""."
}
$mqttText = Get-Content -Raw -Path $mqttPath
if ($mqttText -notmatch 'device\["manufacturer"\]\s*=\s*HA_MANUFACTURER\s*;') {
throw "src/mqtt_client.cpp must assign device[""manufacturer""] from HA_MANUFACTURER."
}
if ($mqttText -match 'device\["manufacturer"\]\s*=\s*"[^"]+"\s*;') {
throw "src/mqtt_client.cpp must not hardcode manufacturer string literals."
}
$roots = @(
Join-Path $repoRoot "src"
Join-Path $repoRoot "include"
)
$literalHits = Get-ChildItem -Path $roots -Recurse -File -Include *.c,*.cc,*.cpp,*.h,*.hpp |
Select-String -Pattern '"AcidBurns"' |
Where-Object { (Resolve-Path $_.Path).ProviderPath -ne $configPath }
if ($literalHits) {
$details = $literalHits | ForEach-Object {
"$($_.Path):$($_.LineNumber)"
}
throw "Unexpected hardcoded ""AcidBurns"" literal(s) outside include/config.h:`n$($details -join "`n")"
}
Write-Host "HA manufacturer drift check passed."