-
Notifications
You must be signed in to change notification settings - Fork 7.8k
fix: honor template overrides for tasks-template (#2278) #2292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nimraakram22
wants to merge
5
commits into
github:main
Choose a base branch
from
Nimraakram22:fix/honor-tasks-template-overrides-2278
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
05b1ea8
fix: honor template overrides for tasks-template (#2278)
Nimraakram12 01bff43
fix: remove stray EOF tokens from setup-tasks scripts
Nimraakram12 8dbe61e
fix: improve error messages for unresolved tasks-template
Nimraakram12 f4f3110
test: update file inventory tests to include setup-tasks scripts
Nimraakram12 4bb64bd
fix: use Console::Error.WriteLine instead of Write-Error in setup-tas…
Nimraakram12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| # Parse command line arguments | ||
| JSON_MODE=false | ||
|
|
||
| for arg in "$@"; do | ||
| case "$arg" in | ||
| --json) JSON_MODE=true ;; | ||
| --help|-h) | ||
| echo "Usage: $0 [--json]" | ||
| echo " --json Output results in JSON format" | ||
| echo " --help Show this help message" | ||
| exit 0 | ||
| ;; | ||
| *) echo "ERROR: Unknown option '$arg'" >&2; exit 1 ;; | ||
| esac | ||
| done | ||
|
|
||
| # Source common functions | ||
| SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| source "$SCRIPT_DIR/common.sh" | ||
|
|
||
| # Get feature paths | ||
| _paths_output=$(get_feature_paths) || { echo "ERROR: Failed to resolve feature paths" >&2; exit 1; } | ||
| eval "$_paths_output" | ||
| unset _paths_output | ||
|
|
||
| # Validate branch | ||
| check_feature_branch "$CURRENT_BRANCH" "$HAS_GIT" || exit 1 | ||
|
|
||
| # Validate prerequisites | ||
| if [[ ! -d "$FEATURE_DIR" ]]; then | ||
| echo "ERROR: Feature directory not found: $FEATURE_DIR" >&2 | ||
| echo "Run /speckit.specify first to create the feature structure." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -f "$IMPL_PLAN" ]]; then | ||
| echo "ERROR: plan.md not found in $FEATURE_DIR" >&2 | ||
| echo "Run /speckit.plan first to create the implementation plan." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Build available docs list | ||
| docs=() | ||
| [[ -f "$RESEARCH" ]] && docs+=("research.md") | ||
| [[ -f "$DATA_MODEL" ]] && docs+=("data-model.md") | ||
| if [[ -d "$CONTRACTS_DIR" ]] && [[ -n "$(ls -A "$CONTRACTS_DIR" 2>/dev/null)" ]]; then | ||
| docs+=("contracts/") | ||
| fi | ||
| [[ -f "$QUICKSTART" ]] && docs+=("quickstart.md") | ||
|
|
||
| # Resolve tasks template through override stack | ||
| TASKS_TEMPLATE=$(resolve_template "tasks-template" "$REPO_ROOT") || true | ||
| if [[ -z "$TASKS_TEMPLATE" ]] || [[ ! -f "$TASKS_TEMPLATE" ]]; then | ||
| echo "ERROR: Could not resolve required tasks-template in $REPO_ROOT" >&2 | ||
| echo "Expected shared core template at .specify/templates/tasks-template.md; run 'specify init' or reinstall shared infra to restore it." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Output results | ||
| if $JSON_MODE; then | ||
| if has_jq; then | ||
| if [[ ${#docs[@]} -eq 0 ]]; then | ||
| json_docs="[]" | ||
| else | ||
| json_docs=$(printf '%s\n' "${docs[@]}" | jq -R . | jq -s .) | ||
| fi | ||
| jq -cn \ | ||
| --arg feature_dir "$FEATURE_DIR" \ | ||
| --argjson docs "$json_docs" \ | ||
| --arg tasks_template "${TASKS_TEMPLATE:-}" \ | ||
| '{FEATURE_DIR:$feature_dir,AVAILABLE_DOCS:$docs,TASKS_TEMPLATE:$tasks_template}' | ||
| else | ||
| if [[ ${#docs[@]} -eq 0 ]]; then | ||
| json_docs="[]" | ||
| else | ||
| json_docs=$(for d in "${docs[@]}"; do printf '"%s",' "$(json_escape "$d")"; done) | ||
| json_docs="[${json_docs%,}]" | ||
| fi | ||
| printf '{"FEATURE_DIR":"%s","AVAILABLE_DOCS":%s,"TASKS_TEMPLATE":"%s"}\n' \ | ||
| "$(json_escape "$FEATURE_DIR")" "$json_docs" "$(json_escape "${TASKS_TEMPLATE:-}")" | ||
| fi | ||
| else | ||
| echo "FEATURE_DIR: $FEATURE_DIR" | ||
| echo "TASKS_TEMPLATE: ${TASKS_TEMPLATE:-not found}" | ||
| echo "AVAILABLE_DOCS:" | ||
| check_file "$RESEARCH" "research.md" | ||
| check_file "$DATA_MODEL" "data-model.md" | ||
| check_dir "$CONTRACTS_DIR" "contracts/" | ||
| check_file "$QUICKSTART" "quickstart.md" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/usr/bin/env pwsh | ||
|
|
||
| [CmdletBinding()] | ||
| param( | ||
| [switch]$Json, | ||
| [switch]$Help | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| if ($Help) { | ||
| Write-Output "Usage: setup-tasks.ps1 [-Json] [-Help]" | ||
| exit 0 | ||
| } | ||
|
|
||
| # Source common functions | ||
| . "$PSScriptRoot/common.ps1" | ||
|
|
||
| # Get feature paths and validate branch | ||
| $paths = Get-FeaturePathsEnv | ||
|
|
||
| if (-not (Test-FeatureBranch -Branch $paths.CURRENT_BRANCH -HasGit:$paths.HAS_GIT)) { | ||
| exit 1 | ||
| } | ||
|
|
||
| # Validate prerequisites | ||
| if (-not (Test-Path $paths.FEATURE_DIR -PathType Container)) { | ||
| Write-Output "ERROR: Feature directory not found: $($paths.FEATURE_DIR)" | ||
| Write-Output "Run /speckit.specify first to create the feature structure." | ||
| exit 1 | ||
| } | ||
|
|
||
| if (-not (Test-Path $paths.IMPL_PLAN -PathType Leaf)) { | ||
| Write-Output "ERROR: plan.md not found in $($paths.FEATURE_DIR)" | ||
| Write-Output "Run /speckit.plan first to create the implementation plan." | ||
| exit 1 | ||
| } | ||
|
|
||
| # Build available docs list | ||
| $docs = @() | ||
| if (Test-Path $paths.RESEARCH) { $docs += 'research.md' } | ||
| if (Test-Path $paths.DATA_MODEL) { $docs += 'data-model.md' } | ||
| if ((Test-Path $paths.CONTRACTS_DIR) -and (Get-ChildItem -Path $paths.CONTRACTS_DIR -ErrorAction SilentlyContinue | Select-Object -First 1)) { | ||
| $docs += 'contracts/' | ||
| } | ||
| if (Test-Path $paths.QUICKSTART) { $docs += 'quickstart.md' } | ||
|
|
||
| # Resolve tasks template through override stack | ||
| $tasksTemplate = Resolve-Template -TemplateName 'tasks-template' -RepoRoot $paths.REPO_ROOT | ||
| if (-not $tasksTemplate) { | ||
| $expectedCoreTemplate = Join-Path $paths.REPO_ROOT '.specify/templates/tasks-template.md' | ||
| Write-Error "Tasks template not found for repository root: $($paths.REPO_ROOT)`nExpected shared/core template location: $expectedCoreTemplate`nTo continue, restore the shared templates (for example by re-running 'specify init') so that '.specify/templates/tasks-template.md' exists, or add a valid tasks-template override." | ||
|
mnriem marked this conversation as resolved.
Outdated
|
||
| exit 1 | ||
| } | ||
|
|
||
| # Output results | ||
| if ($Json) { | ||
| [PSCustomObject]@{ | ||
| FEATURE_DIR = $paths.FEATURE_DIR | ||
| AVAILABLE_DOCS = $docs | ||
| TASKS_TEMPLATE = $tasksTemplate | ||
| } | ConvertTo-Json -Compress | ||
| } else { | ||
| Write-Output "FEATURE_DIR: $($paths.FEATURE_DIR)" | ||
| Write-Output "TASKS_TEMPLATE: $(if ($tasksTemplate) { $tasksTemplate } else { 'not found' })" | ||
| Write-Output "AVAILABLE_DOCS:" | ||
| Test-FileExists -Path $paths.RESEARCH -Description 'research.md' | Out-Null | ||
| Test-FileExists -Path $paths.DATA_MODEL -Description 'data-model.md' | Out-Null | ||
| Test-DirHasFiles -Path $paths.CONTRACTS_DIR -Description 'contracts/' | Out-Null | ||
| Test-FileExists -Path $paths.QUICKSTART -Description 'quickstart.md' | Out-Null | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error messages here are written with
Write-Output(stdout). For scripts that may be invoked with-Json, writing errors to stdout can break JSON consumers or downstream parsing. Prefer writing errors to stderr (e.g.,Write-Erroror[Console]::Error.WriteLine) and reserve stdout for the normal/text or JSON payload.This issue also appears on line 33 of the same file.