setup-plan.ps1 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env pwsh
  2. # Setup implementation plan for a feature
  3. [CmdletBinding()]
  4. param(
  5. [switch]$Json,
  6. [switch]$Help
  7. )
  8. $ErrorActionPreference = 'Stop'
  9. # Show help if requested
  10. if ($Help) {
  11. Write-Output "Usage: ./setup-plan.ps1 [-Json] [-Help]"
  12. Write-Output " -Json Output results in JSON format"
  13. Write-Output " -Help Show this help message"
  14. exit 0
  15. }
  16. # Load common functions
  17. . "$PSScriptRoot/common.ps1"
  18. # Get all paths and variables from common functions
  19. $paths = Get-FeaturePathsEnv
  20. # Check if we're on a proper feature branch (only for git repos)
  21. if (-not (Test-FeatureBranch -Branch $paths.CURRENT_BRANCH -HasGit $paths.HAS_GIT)) {
  22. exit 1
  23. }
  24. # Ensure the feature directory exists
  25. New-Item -ItemType Directory -Path $paths.FEATURE_DIR -Force | Out-Null
  26. # Copy plan template if it exists, otherwise note it or create empty file
  27. $template = Resolve-Template -TemplateName 'plan-template' -RepoRoot $paths.REPO_ROOT
  28. if ($template -and (Test-Path $template)) {
  29. Copy-Item $template $paths.IMPL_PLAN -Force
  30. Write-Output "Copied plan template to $($paths.IMPL_PLAN)"
  31. } else {
  32. Write-Warning "Plan template not found"
  33. # Create a basic plan file if template doesn't exist
  34. New-Item -ItemType File -Path $paths.IMPL_PLAN -Force | Out-Null
  35. }
  36. # Output results
  37. if ($Json) {
  38. $result = [PSCustomObject]@{
  39. FEATURE_SPEC = $paths.FEATURE_SPEC
  40. IMPL_PLAN = $paths.IMPL_PLAN
  41. SPECS_DIR = $paths.FEATURE_DIR
  42. BRANCH = $paths.CURRENT_BRANCH
  43. HAS_GIT = $paths.HAS_GIT
  44. }
  45. $result | ConvertTo-Json -Compress
  46. } else {
  47. Write-Output "FEATURE_SPEC: $($paths.FEATURE_SPEC)"
  48. Write-Output "IMPL_PLAN: $($paths.IMPL_PLAN)"
  49. Write-Output "SPECS_DIR: $($paths.FEATURE_DIR)"
  50. Write-Output "BRANCH: $($paths.CURRENT_BRANCH)"
  51. Write-Output "HAS_GIT: $($paths.HAS_GIT)"
  52. }