TypeDialog/scripts/update-docs-refs.sh

137 lines
5.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Update references to renamed documentation files
# Run AFTER renaming docs to lowercase
set -e
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_ROOT"
echo "=== Updating documentation references ==="
echo ""
# Backup function
backup_file() {
local file=$1
if [ -f "$file" ]; then
cp "$file" "${file}.bak"
echo "✓ Backed up: $file"
fi
}
# Update function with display
update_refs() {
local file=$1
local search=$2
local replace=$3
if [ -f "$file" ]; then
if grep -q "$search" "$file" 2>/dev/null; then
backup_file "$file"
sed -i '' "s|$search|$replace|g" "$file"
echo "✓ Updated: $file"
echo " ├─ $search$replace"
fi
fi
}
echo "Step 1: Update root-level doc references"
echo "-----------------------------------------"
# Find all markdown files and update references
for file in $(find . -name "*.md" -type f -not -path "./target/*" -not -path "./.git/*" -not -path "./node_modules/*" -not -name "*.bak"); do
# Root level docs
update_refs "$file" 'docs/BUILD\.md' 'docs/build.md'
update_refs "$file" 'BUILD\.md' 'build.md'
update_refs "$file" 'docs/CONFIGURATION\.md' 'docs/configuration.md'
update_refs "$file" 'CONFIGURATION\.md' 'configuration.md'
update_refs "$file" 'docs/DEVELOPMENT\.md' 'docs/development.md'
update_refs "$file" 'DEVELOPMENT\.md' 'development.md'
update_refs "$file" 'docs/FIELD_TYPES\.md' 'docs/field_types.md'
update_refs "$file" 'FIELD_TYPES\.md' 'field_types.md'
update_refs "$file" 'docs/INSTALLATION\.md' 'docs/installation.md'
update_refs "$file" 'INSTALLATION\.md' 'installation.md'
update_refs "$file" 'docs/NICKEL\.md' 'docs/nickel.md'
update_refs "$file" 'NICKEL\.md' 'nickel.md'
update_refs "$file" 'docs/PRE-COMMIT-SETUP\.md' 'docs/pre-commit-setup.md'
update_refs "$file" 'PRE-COMMIT-SETUP\.md' 'pre-commit-setup.md'
update_refs "$file" 'docs/RELEASE\.md' 'docs/release.md'
update_refs "$file" 'RELEASE\.md' 'release.md'
done
echo ""
echo "Step 2: Update agent/ doc references"
echo "-------------------------------------"
for file in $(find . -name "*.md" -type f -not -path "./target/*" -not -path "./.git/*" -not -path "./node_modules/*" -not -name "*.bak"); do
update_refs "$file" 'docs/agent/GETTING_STARTED\.md' 'docs/agent/getting_started.md'
update_refs "$file" 'agent/GETTING_STARTED\.md' 'agent/getting_started.md'
update_refs "$file" 'GETTING_STARTED\.md' 'getting_started.md'
update_refs "$file" 'docs/agent/LLM_PROVIDERS\.md' 'docs/agent/llm_providers.md'
update_refs "$file" 'agent/LLM_PROVIDERS\.md' 'agent/llm_providers.md'
update_refs "$file" 'LLM_PROVIDERS\.md' 'llm_providers.md'
done
echo ""
echo "Step 3: Update encryption/ doc references"
echo "------------------------------------------"
for file in $(find . -name "*.md" -type f -not -path "./target/*" -not -path "./.git/*" -not -path "./node_modules/*" -not -name "*.bak"); do
update_refs "$file" 'docs/encryption/ENCRYPTION-QUICK-START\.md' 'docs/encryption/encryption-quick-start.md'
update_refs "$file" 'encryption/ENCRYPTION-QUICK-START\.md' 'encryption/encryption-quick-start.md'
update_refs "$file" 'ENCRYPTION-QUICK-START\.md' 'encryption-quick-start.md'
update_refs "$file" 'docs/encryption/ENCRYPTION-SERVICES-SETUP\.md' 'docs/encryption/encryption-services-setup.md'
update_refs "$file" 'encryption/ENCRYPTION-SERVICES-SETUP\.md' 'encryption/encryption-services-setup.md'
update_refs "$file" 'ENCRYPTION-SERVICES-SETUP\.md' 'encryption-services-setup.md'
update_refs "$file" 'docs/encryption/ENCRYPTION-UNIFIED-ARCHITECTURE\.md' 'docs/encryption/encryption-unified-architecture.md'
update_refs "$file" 'encryption/ENCRYPTION-UNIFIED-ARCHITECTURE\.md' 'encryption/encryption-unified-architecture.md'
update_refs "$file" 'ENCRYPTION-UNIFIED-ARCHITECTURE\.md' 'encryption-unified-architecture.md'
done
echo ""
echo "Step 4: Check for remaining uppercase doc references"
echo "-----------------------------------------------------"
remaining=$(grep -rE "BUILD\.md|CONFIGURATION\.md|DEVELOPMENT\.md|FIELD_TYPES\.md|INSTALLATION\.md|NICKEL\.md|PRE-COMMIT-SETUP\.md|RELEASE\.md|GETTING_STARTED\.md|LLM_PROVIDERS\.md|ENCRYPTION-QUICK-START\.md|ENCRYPTION-SERVICES-SETUP\.md|ENCRYPTION-UNIFIED-ARCHITECTURE\.md" \
--include="*.md" --include="*.toml" --include="*.rs" \
--exclude-dir=target --exclude-dir=.git --exclude-dir=node_modules \
--exclude="*.bak" . 2>/dev/null | grep -v "update-docs-refs.sh" | wc -l || echo "0")
if [ "$remaining" -gt 0 ]; then
echo "⚠️ Found $remaining remaining uppercase doc references:"
grep -rE "BUILD\.md|CONFIGURATION\.md|DEVELOPMENT\.md|FIELD_TYPES\.md|INSTALLATION\.md|NICKEL\.md|PRE-COMMIT-SETUP\.md|RELEASE\.md|GETTING_STARTED\.md|LLM_PROVIDERS\.md|ENCRYPTION-QUICK-START\.md|ENCRYPTION-SERVICES-SETUP\.md|ENCRYPTION-UNIFIED-ARCHITECTURE\.md" \
--include="*.md" --include="*.toml" --include="*.rs" \
--exclude-dir=target --exclude-dir=.git --exclude-dir=node_modules \
--exclude="*.bak" . 2>/dev/null | grep -v "update-docs-refs.sh" | head -10
else
echo "✓ No remaining uppercase doc references found"
fi
echo ""
echo "Step 5: Cleanup backups (optional)"
echo "-----------------------------------"
backup_count=$(find . -name "*.bak" -type f | wc -l)
echo "Found $backup_count backup files"
echo "To remove backups: find . -name '*.bak' -type f -delete"
echo ""
echo "=== Summary ===="
echo "✓ Updated references to lowercase doc filenames"
echo "✓ Checked for remaining uppercase references"
echo ""
echo "Next steps:"
echo "1. Review changes: git diff"
echo "2. Test that links work"
echo "3. Remove backups: find . -name '*.bak' -delete"
echo "4. Commit: git add -A && git commit -m 'docs: rename files to lowercase'"