claude-code-ultimate-guide/scripts/sync-version.sh
Florian BRUNIAUX 0cc01e5d3a fix: correct multi-agent review findings across guide docs
- architecture.md: fix Asana attribution (not Atlassian), Daniela Amodei
  title (President not CEO), update model refs (3.5→4+), update footer
- cheatsheet.md: update date to Feb 2026, TodoWrite→Tasks API in decision tree
- methodologies.md: update date to Feb 2026
- sync-version.sh: escape dots in sed patterns to prevent URL corruption

Findings from 3-agent parallel code review (Agent Teams experiment).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 12:38:22 +01:00

83 lines
2 KiB
Bash
Executable file

#!/bin/bash
# sync-version.sh - Sync version from VERSION file to all documentation
# Usage: ./scripts/sync-version.sh [--check]
# --check : Only check, don't modify (exit 1 if mismatch)
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"
# Read source of truth
if [[ ! -f VERSION ]]; then
echo "❌ VERSION file not found"
exit 1
fi
VERSION=$(cat VERSION | tr -d '[:space:]')
CHECK_ONLY=false
ERRORS=0
if [[ "${1:-}" == "--check" ]]; then
CHECK_ONLY=true
fi
echo "=== Version Sync ==="
echo "Source: VERSION → $VERSION"
echo ""
# Function to check/update a file
check_file() {
local file="$1"
if [[ ! -f "$file" ]]; then
echo "⚠️ $file not found"
return
fi
# Find version numbers in file (3.x.x pattern only)
local old_versions=$(grep -oE '3\.[0-9]+\.[0-9]+' "$file" 2>/dev/null | sort -u | grep -v "^${VERSION}$" || true)
if [[ -n "$old_versions" ]]; then
echo "📍 $file: found outdated versions"
for v in $old_versions; do
echo " - $v$VERSION"
done
if $CHECK_ONLY; then
ERRORS=$((ERRORS + 1))
else
# Replace all old 3.x.x versions with current version
for v in $old_versions; do
# Escape dots for sed regex (prevents matching digits in URLs/IDs)
local escaped_v=$(echo "$v" | sed 's/\./\\./g')
# macOS compatible sed
sed -i '' "s/$escaped_v/$VERSION/g" "$file"
done
echo "$file: updated"
fi
else
# Check if file contains current version
if grep -q "$VERSION" "$file" 2>/dev/null; then
echo "$file: OK ($VERSION)"
else
echo "⚠️ $file: no version found"
fi
fi
}
# Check main files
check_file "README.md"
check_file "guide/cheatsheet.md"
check_file "guide/ultimate-guide.md"
check_file "machine-readable/reference.yaml"
echo ""
if $CHECK_ONLY && [[ $ERRORS -gt 0 ]]; then
echo "$ERRORS file(s) need version update"
echo "Run: ./scripts/sync-version.sh"
exit 1
fi
echo "✅ Done"