Files
jiapuapp/tests/active-page-business-ownership-contract.ps1
T
2026-07-24 18:03:14 +08:00

38 lines
1.8 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$pages = Get-Content -LiteralPath (Join-Path $root 'pages.json') -Raw -Encoding UTF8 | ConvertFrom-Json
$activePaths = @($pages.pages | ForEach-Object { "$($_.path).vue" })
foreach ($relativePath in $activePaths) {
$fullPath = Join-Path $root $relativePath
if (-not (Test-Path -LiteralPath $fullPath)) { throw "Missing active page: $relativePath" }
$source = Get-Content -LiteralPath $fullPath -Raw -Encoding UTF8
if ($source -match '<ModulePage(?:\s|/|>)|import\s+ModulePage\s+from') {
throw "Active page must own its business content instead of ModulePage: $relativePath"
}
if ($source -match 'uni\.(showToast|showModal|showLoading|showActionSheet)') {
throw "$relativePath must use project feedback components"
}
}
$recordContracts = [ordered]@{
'pages/records/r03-gift-list.vue' = @('appApi.getRelativeRecords', 'appApi')
'pages/records/r04-gift-editor.vue' = @('appApi.createRelativeRecord', 'pickAndUploadImage')
'pages/records/r05-ritual-list.vue' = @('appApi.getCeremonies', 'appApi')
'pages/records/r06-ritual-detail.vue' = @('appApi.getCeremonyDetail', 'appApi')
'pages/records/r07-ritual-editor.vue' = @('appApi.createCeremony', 'appApi')
'pages/records/r08-growth-journal.vue' = @('appApi.getGrowthRecords', 'appApi.createGrowthRecord')
'pages/records/r10-memo-list.vue' = @('appApi.getMemos', 'appApi.createMemo')
'pages/records/r11-merit-records.vue' = @('appApi.getMeritRecords', 'appApi.createMeritRecord')
}
foreach ($entry in $recordContracts.GetEnumerator()) {
$source = Get-Content -LiteralPath (Join-Path $root $entry.Key) -Raw -Encoding UTF8
foreach ($token in $entry.Value) {
if (-not $source.Contains($token)) { throw "$($entry.Key) missing active interface owner: $token" }
}
}
Write-Output 'ACTIVE-PAGE-BUSINESS-OWNERSHIP-CONTRACT PASS'