Skip to content

Commit 8882d95

Browse files
committed
Fix: Version drift - Create single source of truth for version number
ISSUE: - Script had 4 different hardcoded version strings out of sync - Header comment: 1.0.59 (correct) - Banner: 1.0.58 (wrong) - JSON output: 1.0.58 (wrong) - Log file: 1.0.58 (wrong) - This caused incorrect version reporting in logs and JSON ROOT CAUSE: - Version number was hardcoded in 4 different locations - No single source of truth for version number - Easy to forget to update all locations when bumping version FIX: - Created SCRIPT_VERSION='1.0.59' constant at line 50 - Added prominent comment block explaining this is the ONLY place to update version number - Replaced all 3 hardcoded version strings with $SCRIPT_VERSION: * Line 415: Log file version * Line 608: JSON output version * Line 1216: Banner version - Header comment (line 4) kept for documentation IMPACT: - Version now displays consistently: 1.0.59 everywhere - Future version bumps: only update ONE line (line 50) - Prevents version drift from ever happening again - Verified in banner, logs, and JSON output TESTING: - Ran script with --format json: version shows 1.0.59 ✓ - Ran script with --format text: banner shows v1.0.59 ✓ - Checked log file: Script Version shows 1.0.59 ✓
1 parent 720edf2 commit 8882d95

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

File renamed without changes.

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [1.0.59] - 2025-12-31
99

1010
### Fixed
11+
- **Version Drift Bug** - Created single source of truth for version number to prevent version inconsistencies
12+
- **Issue:** Script had 4 different hardcoded version strings that were out of sync (header: 1.0.59, banner/logs/JSON: 1.0.58)
13+
- **Root Cause:** Version number was hardcoded in 4 different locations instead of using a single variable
14+
- **Fix:** Created `SCRIPT_VERSION="1.0.59"` constant at top of script and replaced all hardcoded references
15+
- **Impact:** Version now displays consistently across banner, logs, and JSON output
16+
- **Locations Updated:**
17+
- Line 50: Created `SCRIPT_VERSION` variable (single source of truth)
18+
- Line 415: Log file version (now uses `$SCRIPT_VERSION`)
19+
- Line 608: JSON output version (now uses `$SCRIPT_VERSION`)
20+
- Line 1216: Banner version (now uses `$SCRIPT_VERSION`)
21+
- **Future-Proof:** Only need to update ONE line (line 50) when bumping versions
22+
1123
- **Template Loading Path** - Fixed `REPO_ROOT` variable in bash script to correctly load templates from `dist/TEMPLATES/`
1224
- **Issue:** Script was looking for templates in repository root `/TEMPLATES/` instead of `dist/TEMPLATES/`
1325
- **Root Cause:** `REPO_ROOT` was set to `$SCRIPT_DIR/../..` (repository root) instead of `$SCRIPT_DIR/..` (dist directory)

dist/bin/check-performance.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ source "$LIB_DIR/colors.sh"
4141
# shellcheck source=dist/bin/lib/common-helpers.sh
4242
source "$LIB_DIR/common-helpers.sh"
4343

44+
# ============================================================
45+
# VERSION - SINGLE SOURCE OF TRUTH
46+
# ============================================================
47+
# This is the ONLY place the version number should be defined.
48+
# All other references (logs, JSON, banners) use this variable.
49+
# Update this ONE line when bumping versions - never hardcode elsewhere.
50+
SCRIPT_VERSION="1.0.59"
51+
4452
# Defaults
4553
PATHS="."
4654
STRICT=false
@@ -404,7 +412,7 @@ if [ "$ENABLE_LOGGING" = true ]; then
404412

405413
echo "Generated (UTC): $(date -u +"%Y-%m-%d %H:%M:%S")"
406414
echo "Local Time: $(get_local_timestamp)"
407-
echo "Script Version: 1.0.58"
415+
echo "Script Version: $SCRIPT_VERSION"
408416
echo "Paths Scanned: $PATHS"
409417
echo "Strict Mode: $STRICT"
410418
echo "Verbose Mode: $VERBOSE"
@@ -597,7 +605,7 @@ output_json() {
597605

598606
cat <<EOF
599607
{
600-
"version": "1.0.58",
608+
"version": "$SCRIPT_VERSION",
601609
"timestamp": "$timestamp",
602610
"project": $project_info,
603611
"paths_scanned": "$(json_escape "$PATHS")",
@@ -1205,7 +1213,7 @@ PROJECT_NAME=$(echo "$PROJECT_INFO_JSON" | grep -o '"name": "[^"]*"' | cut -d'"'
12051213
PROJECT_VERSION=$(echo "$PROJECT_INFO_JSON" | grep -o '"version": "[^"]*"' | cut -d'"' -f4)
12061214

12071215
text_echo "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
1208-
text_echo "${BLUE} WP Code Check by Hypercart - Performance Analyzer v1.0.58${NC}"
1216+
text_echo "${BLUE} WP Code Check by Hypercart - Performance Analyzer v$SCRIPT_VERSION${NC}"
12091217
text_echo "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
12101218
text_echo ""
12111219

0 commit comments

Comments
 (0)