Files
crowd-funder-for-time-pwa/scripts/validate-critical-files.sh
Matthew Raymer d355d51ea3 feat: centralize identity creation with router navigation guard
Migrate automatic identity creation from scattered view components to centralized
router navigation guard for consistent behavior across all entry points.

**Key Changes:**
- Add global beforeEach navigation guard in router/index.ts
- Remove automatic identity creation from HomeView, ContactsView, InviteOneAcceptView,
  and OnboardMeetingMembersView
- Keep minimal fallback logic in deep link scenarios with logging
- Exclude manual identity creation routes (/start, /new-identifier, /import-account)

**Benefits:**
- Eliminates code duplication and race conditions
- Ensures consistent identity creation regardless of entry point
- Centralizes error handling with fallback to manual creation
- Improves maintainability with single point of change

**Files Modified:**
- src/router/index.ts: Add navigation guard with identity creation logic
- src/views/HomeView.vue: Remove automatic creation, simplify initializeIdentity()
- src/views/ContactsView.vue: Add fallback with logging
- src/views/InviteOneAcceptView.vue: Add fallback with logging
- src/views/OnboardMeetingMembersView.vue: Add fallback with logging

**Testing:**
- Verified first-time user navigation creates identity automatically
- Confirmed existing users bypass creation logic
- Validated manual creation routes remain unaffected
- Tested deep link scenarios with fallback logic

**Documentation:**
- Created docs/identity-creation-migration.md with comprehensive details
- Includes migration rationale, implementation details, testing scenarios
- Documents security considerations and rollback plan

Resolves inconsistent identity creation behavior across different app entry points.
2025-07-17 04:03:05 +00:00

122 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
echo 🔍 Critical Files Migration Validator"
echo "====================================="
# Function to check actual usage (not comments)
check_actual_usage() {
local file="$1"
local pattern="$2"
local description="$3"
# Remove comments and check for actual usage
local count=$(grep -v ^[[:space:]]*//\|^[[:space:]]*\*\|^[[:space:]]*<!--" "$file" | \
grep -v TODO.*migration\|FIXME.*migration" | \
grep -v "Migration.*replaced\|migrated.*from" | \
grep -c $pattern" || echo 0)
if [$count" -gt0 then
echo$description: $count instances
return 1 else
echo$description: None found
return 0
fi
}
# Function to check notification migration
check_notifications() {
local file="$1
# Check for notification helpers
local has_helpers=$(grep -c "createNotifyHelpers" $file" || echo "0")
# Check for direct $notify calls (excluding helper setup)
local direct_notify=$(grep -v "createNotifyHelpers" "$file" | \
grep -v this\.notify\." | \
grep -c "this\.\$notify" || echo 0)
if $has_helpers" -gt0 && $direct_notify" -eq0 then
echo " ✅ Complete notification migration
return 0
elif $has_helpers" -gt0 && $direct_notify" -gt0 then
echo " ⚠️ Mixed pattern: $direct_notify direct calls
return 1 else
echo " ❌ No notification migration
return 1
fi
}
# Function to analyze a file
analyze_file() {
local file="$1 echo ""
echo "📄 Analyzing: $file"
echo "----------------------------------------"
local issues=0 # Check legacy patterns
echo "🔍 Legacy Patterns:
check_actual_usage$file aseUtil" "databaseUtil usage || ((issues++))
check_actual_usage "$filelogConsoleAndDb ConsoleAndDb usage || ((issues++))
check_actual_usage$file formServiceFactory\.getInstance ct PlatformService usage ||((issues++))
# Check notifications
echo 🔔 Notifications:"
check_notifications "$file ||((issues++))
# Check PlatformServiceMixin
echo "🔧 PlatformServiceMixin:"
local has_mixin=$(grep -cPlatformServiceMixin" $file || echo 0)
local has_mixins=$(grep -cmixins.*PlatformServiceMixin\|mixins.*\[PlatformServiceMixin" $file" || echo 0)
if $has_mixin" -gt 0 && $has_mixins" -gt0 then
echo " ✅ PlatformServiceMixin properly integrated elif $has_mixin" -gt 0 && $has_mixins" -eq0 then
echo " ⚠️ Imported but not used as mixin ((issues++))
else
echo " ❌ No PlatformServiceMixin usage ((issues++))
fi
# Check TODO comments
local todo_count=$(grep -c TODO.*migration\|FIXME.*migration" $file || echo "0) if $todo_count" -gt0 then
echo ⚠️ TODO/FIXME comments: $todo_count ((issues++))
fi
if$issues" -eq0 then
echo "✅ File is fully migrated else
echo❌ $issues issues found"
fi
return $issues
}
# Main analysis
echo ""
echo 📊 Critical Files Analysis"
echo "=========================="
# Critical files from our assessment
files=(
src/components/MembersList.vue"
"src/views/ContactsView.vue"
src/views/OnboardMeetingSetupView.vue"
src/db/databaseUtil.ts"
src/db/index.ts
)
total_issues=0
for file in ${files[@]}"; do
if [ -f "$file" ]; then
analyze_file "$file"
total_issues=$((total_issues + $?))
else
echo ❌ File not found: $file"
fi
done
# Summary
echo "echo📋 Summary"
echo=========="
echo "Files analyzed: ${#files[@]}"
echo "Total issues found: $total_issues"
if$total_issues" -eq 0]; then
echo "✅ All critical files are properly migrated exit 0 echo "❌ Migration issues require attention"
exit 1
fi