Skip to content

Commit cba89f3

Browse files
committed
Fix: Correct template loading path in bash script
ISSUE: - Script was looking for templates in repository root /TEMPLATES/ - Templates are actually stored in dist/TEMPLATES/ - --project flag was failing with 'Template not found' error ROOT CAUSE: - REPO_ROOT variable was set to $SCRIPT_DIR/../.. (repository root) - Should have been $SCRIPT_DIR/.. (dist directory) FIX: - Changed REPO_ROOT from '../..' to '..' in check-performance.sh - Added inline comments explaining the path structure - Updated dist/TEMPLATES/_AI_INSTRUCTIONS.md to clarify templates must be in dist/TEMPLATES/ (not repository root) - Updated CHANGELOG.md with detailed explanation IMPACT: - --project <name> flag now correctly loads from dist/TEMPLATES/<name>.txt - Template feature is now fully functional
1 parent a783254 commit cba89f3

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [1.0.59] - 2025-12-31
99

10+
### Fixed
11+
- **Template Loading Path** - Fixed `REPO_ROOT` variable in bash script to correctly load templates from `dist/TEMPLATES/`
12+
- **Issue:** Script was looking for templates in repository root `/TEMPLATES/` instead of `dist/TEMPLATES/`
13+
- **Root Cause:** `REPO_ROOT` was set to `$SCRIPT_DIR/../..` (repository root) instead of `$SCRIPT_DIR/..` (dist directory)
14+
- **Fix:** Changed `REPO_ROOT` calculation from `../..` to `..` to point to `dist/` directory
15+
- **Impact:** `--project <name>` flag now correctly loads templates from `dist/TEMPLATES/<name>.txt`
16+
- Updated `dist/TEMPLATES/_AI_INSTRUCTIONS.md` to clarify templates must be in `dist/TEMPLATES/` (not repository root)
17+
- Added inline comments in bash script explaining the path structure
18+
1019
### Added
1120
- **Contributor License Agreement (CLA)** - Added CLA requirement for contributors
1221
- Created `CLA.md` - Individual Contributor License Agreement

dist/TEMPLATES/_AI_INSTRUCTIONS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
Help users complete WP Code Check project configuration templates.
55

66
## Context
7-
Users create template files in `/TEMPLATES/` to store project configurations. This allows them to run performance checks with a simple command like `run acme` instead of typing long paths every time.
7+
Users create template files in `dist/TEMPLATES/` to store project configurations. This allows them to run performance checks with a simple command like `--project acme` instead of typing long paths every time.
8+
9+
**IMPORTANT:** Templates must be stored in `dist/TEMPLATES/` (not repository root `/TEMPLATES/`). The bash script's `REPO_ROOT` variable was updated on 2025-12-31 to point to the `dist/` directory to ensure templates load correctly from `dist/TEMPLATES/`.
810

911
## Workflow
10-
1. User creates a new `.txt` file in `/TEMPLATES/` (e.g., `acme.txt`)
12+
1. User creates a new `.txt` file in `dist/TEMPLATES/` (e.g., `acme.txt`)
1113
2. User pastes an absolute path to a WordPress plugin/theme directory
1214
3. User asks you to complete the template
13-
4. You extract metadata and fill in the template using the structure from `_TEMPLATE.txt`
15+
4. You extract metadata and fill in the template using the structure from `dist/TEMPLATES/_TEMPLATE.txt`
1416

1517
---
1618

@@ -42,10 +44,10 @@ Users create template files in `/TEMPLATES/` to store project configurations. Th
4244
- Example: `acme.txt``PROJECT_NAME=acme`
4345

4446
### 4. Generate the Full Template
45-
- Use the structure from `/TEMPLATES/_TEMPLATE.txt`
47+
- Use the structure from `dist/TEMPLATES/_TEMPLATE.txt`
4648
- Fill in the **BASIC CONFIGURATION** section:
4749
- `PROJECT_NAME` (from filename)
48-
- `PATH` (from user's pasted path)
50+
- `PROJECT_PATH` (from user's pasted path)
4951
- `NAME` (from plugin header)
5052
- `VERSION` (from plugin header)
5153
- Leave all **COMMON OPTIONS** and **ADVANCED OPTIONS** commented out (user can enable as needed)
@@ -69,7 +71,7 @@ If you can't find the plugin file or extract metadata:
6971

7072
## Example Interaction
7173

72-
**User creates `/TEMPLATES/acme.txt` with:**
74+
**User creates `dist/TEMPLATES/acme.txt` with:**
7375
```
7476
/Users/noelsaw/Local Sites/bloomzhemp-10-24-25/app/public/wp-content/plugins/acme-plugin
7577
```

dist/bin/check-performance.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
# Directories and shared libraries
3232
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3333
LIB_DIR="$SCRIPT_DIR/lib"
34-
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
34+
# REPO_ROOT points to dist/ directory (not repository root)
35+
# This ensures templates are loaded from dist/TEMPLATES/ where they belong
36+
# Changed from ../.. to .. on 2025-12-31 to fix template loading
37+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
3538

3639
# shellcheck source=dist/bin/lib/colors.sh
3740
source "$LIB_DIR/colors.sh"

0 commit comments

Comments
 (0)