#!/bin/bash # Frontend Debranding Script for MoreMinimore # This script handles comprehensive frontend debranding and UI fixes # Usage: ./scripts/frontend-debrand.sh set -e # Exit on any error echo "🎨 Starting frontend debranding process..." # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Function to print colored output print_status() { echo -e "${BLUE}[INFO]${NC} $1" } print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } # Check if we're in the right directory if [ ! -f "package.json" ] || [ ! -d "src" ]; then print_error "Please run this script from the project root directory" exit 1 fi # Function to fix TitleBar component fix_titlebar() { print_status "Fixing TitleBar component..." if [ -f "src/app/TitleBar.tsx" ]; then # Create a backup cp src/app/TitleBar.tsx src/app/TitleBar.tsx.bak # Remove Dyad Pro related imports and components sed -i '' '/import.*DyadProSuccessDialog/d' src/app/TitleBar.tsx sed -i '' '/import.*useUserBudgetInfo/d' src/app/TitleBar.tsx sed -i '' '/import.*UserBudgetInfo/d' src/app/TitleBar.tsx # Remove Dyad Pro button and related logic sed -i '' '/const isDyadPro =/d' src/app/TitleBar.tsx sed -i '' '/const isDyadProEnabled =/d' src/app/TitleBar.tsx sed -i '' '/showDyadProSuccessDialog/d' src/app/TitleBar.tsx sed -i '' '/DyadProSuccessDialog/,/<\/DyadProSuccessDialog>/d' src/app/TitleBar.tsx sed -i '' '/{isDyadPro && {\ return {\ totalCredits: 1000,\ usedCredits: 0,\ resetDate: new Date().toISOString()\ };\ });' src/ipc/ipc_host.ts fi rm src/ipc/ipc_host.ts.bak print_success "Added missing user budget handler" fi } # Function to update preload script update_preload() { print_status "Updating preload script..." if [ -f "src/preload.ts" ]; then cp src/preload.ts src/preload.ts.bak # Add get-user-budget to preload if not present if ! grep -q "get-user-budget" src/preload.ts; then sed -i '' '/"get-system-debug-info":/a\ "get-user-budget": () => ipcRenderer.invoke("get-user-budget"),' src/preload.ts fi rm src/preload.ts.bak print_success "Updated preload script" fi } # Function to update IPC client update_ipc_client() { print_status "Updating IPC client..." if [ -f "src/ipc/ipc_client.ts" ]; then cp src/ipc/ipc_client.ts src/ipc/ipc_client.ts.bak # Add getUserBudget method if not present if ! grep -q "getUserBudget" src/ipc/ipc_client.ts; then sed -i '' '/async getSystemDebugInfo()/a\ \ async getUserBudget() {\ return this.ipcRenderer.invoke("get-user-budget");\ }' src/ipc/ipc_client.ts fi rm src/ipc/ipc_client.ts.bak print_success "Updated IPC client" fi } # Function to test compilation test_compilation() { print_status "Testing compilation..." if command -v npm &> /dev/null; then if npm run ts 2>/dev/null; then print_success "TypeScript compilation successful" else print_warning "TypeScript compilation failed. Check the errors above." fi fi } # Main execution main() { print_status "Starting frontend debranding..." fix_titlebar remove_pro_dialog fix_context_files_picker fix_token_savings fix_dyad_think update_smart_context_settings fix_remaining_references add_missing_handlers update_preload update_ipc_client test_compilation print_success "🎉 Frontend debranding completed!" echo "" echo "Summary of changes:" echo "✅ Fixed TitleBar component (removed Pro elements)" echo "✅ Removed DyadProSuccessDialog component" echo "✅ Fixed ContextFilesPicker component" echo "✅ Fixed DyadTokenSavings component" echo "✅ Fixed DyadThink component" echo "✅ Updated smart context settings" echo "✅ Fixed remaining Dyad references" echo "✅ Added missing IPC handlers" echo "✅ Updated preload script" echo "✅ Updated IPC client" echo "" echo "Next steps:" echo "1. Test the application with 'npm start'" echo "2. Verify all UI elements are properly debranded" echo "3. Test smart context functionality" echo "" print_warning "Please test the application thoroughly before committing changes." } # Run main function main "$@"