Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

44 linhas
1.9KB

  1. <#
  2. .SYNOPSIS
  3. Validate a project brief (draft or approved) and say where to resume the interview.
  4. .DESCRIPTION
  5. -Mode Draft (default for briefs whose status is "draft"): lists what is still missing,
  6. grouped by interview stage, plus any errors or conflicts, and prints the stage and questions
  7. to resume with.
  8. -Mode Approved: everything must be complete, approved and free of conflicts; this is the
  9. same check the generator runs before writing anything.
  10. Exit codes: 0 = valid for the chosen mode, 1 = not valid, 4 = conflicts present
  11. (constraints the user must choose between).
  12. .EXAMPLE
  13. pwsh -File tools/Test-FoundryBrief.ps1 drafts/my-game.json
  14. pwsh -File tools/Test-FoundryBrief.ps1 examples/traffic-control-64/brief.json -Mode Approved
  15. #>
  16. [CmdletBinding()]
  17. param(
  18. [Parameter(Mandatory, Position = 0)][string]$Path,
  19. [ValidateSet('Draft', 'Approved', 'Auto')][string]$Mode = 'Auto',
  20. [switch]$Json
  21. )
  22. Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
  23. try {
  24. $full = (Resolve-Path -LiteralPath $Path).ProviderPath
  25. $brief = Read-FoundryJson $full
  26. } catch {
  27. Write-Host "ERROR: $($_.Exception.Message)" -ForegroundColor Red
  28. exit 1
  29. }
  30. $schema = Join-Path $PSScriptRoot '../schema/project-brief.schema.json'
  31. $schemaOk = Test-Json -Path $full -SchemaFile $schema -ErrorAction SilentlyContinue
  32. if (-not $schemaOk) {
  33. Write-Host "SCHEMA: $Path does not match schema/project-brief.schema.json (wrong type or an unknown enum value). Details from the rule checks follow." -ForegroundColor Red
  34. }
  35. if ($Mode -eq 'Auto') { $Mode = if ($brief.status -eq 'approved') { 'Approved' } else { 'Draft' } }
  36. $result = Test-FoundryBrief -Brief $brief -Mode $Mode -BriefPath $full
  37. if ($Json) { $result | ConvertTo-Json -Depth 6 } else { Format-FoundryValidation $result | Write-Host }
  38. if ($result.Conflicts.Count) { exit 4 }
  39. if (-not $result.Valid -or -not $schemaOk) { exit 1 }
  40. exit 0

Powered by TurnKey Linux.