Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

58 řádky
2.9KB

  1. <#
  2. .SYNOPSIS
  3. Generate a self-contained C64/C128 project repository from an approved brief.
  4. .DESCRIPTION
  5. 1. Validates the brief (status must be "approved", no missing fields, no conflicts).
  6. 2. Validates the destination. An existing non-empty folder or Git repository is never
  7. touched; an empty folder is allowed.
  8. 3. Builds the repository in a temporary sibling folder (".<name>.foundry-staging-*"):
  9. templates, starter source, project-specific files (starter.filesDir), project.json.
  10. 4. Fails if any {{PLACEHOLDER}} is left unresolved.
  11. 5. Runs git init on branch main and commits if a Git identity is configured; otherwise
  12. the files are staged and ready to commit.
  13. 6. Moves the folder to the destination in one rename. If anything fails before this, the
  14. staging folder is removed and the destination is left as it was. Leftovers from an
  15. interrupted earlier attempt are removed on the next run.
  16. 7. Runs the generated repo's tools/smoke.ps1 (unless -SkipVerify) and reports the result.
  17. Exit codes: 0 = generated (see verification status), 1 = nothing generated.
  18. .EXAMPLE
  19. pwsh -File tools/New-FoundryProject.ps1 examples/traffic-control-64/brief.json
  20. pwsh -File tools/New-FoundryProject.ps1 drafts/my-game.json -Destination "D:\Retro Projects\my-game"
  21. #>
  22. [CmdletBinding()]
  23. param(
  24. [Parameter(Mandatory, Position = 0)][string]$BriefPath,
  25. [string]$Destination,
  26. [switch]$SkipVerify,
  27. [switch]$Json,
  28. [string]$FailAfterStep
  29. )
  30. Import-Module (Join-Path $PSScriptRoot 'Foundry.psm1') -Force
  31. try {
  32. $r = New-FoundryProject -BriefPath $BriefPath -Destination $Destination -SkipVerify:$SkipVerify -FailAfterStep $FailAfterStep
  33. } catch {
  34. Write-Host "NOT GENERATED: $($_.Exception.Message)" -ForegroundColor Red
  35. exit 1
  36. }
  37. if ($Json) { $r | ConvertTo-Json -Depth 6; exit 0 }
  38. Write-Host ""
  39. Write-Host "Project generated" -ForegroundColor Green
  40. Write-Host " Path : $($r.Destination)"
  41. Write-Host " Git : branch main, $(if ($r.Committed) { 'initial commit created' } else { 'files staged; no Git identity configured. Set one (git config --global user.name / user.email), then run: git commit -m "Initial handoff"' })"
  42. foreach ($t in $r.Targets) { Write-Host " Target : $($t.Id) -> $($t.Artifact) (starter configuration: $($t.Status))" }
  43. foreach ($w in $r.Warnings) { Write-Host " Warning : $w" -ForegroundColor Yellow }
  44. if ($r.StaleRemoved.Count) { Write-Host " Cleaned : removed $($r.StaleRemoved.Count) leftover staging folder(s) from an interrupted run" }
  45. Write-Host " Starter verification: $($r.Verification.status)"
  46. if ($r.Verification.output) {
  47. $r.Verification.output | Where-Object { $_ -match '^\s*(\[|MISSING| First| Unverified|ok |FAIL)|^\s+(ok|FAIL)\s' } | ForEach-Object { Write-Host " $_" }
  48. }
  49. Write-Host ""
  50. Write-Host "Next: open a fresh coding-agent session in the folder above and send:"
  51. Write-Host ""
  52. Write-Host " $($r.HandoffMessage)"
  53. exit 0

Powered by TurnKey Linux.