mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
103 lines
3.5 KiB
Python
103 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import re
|
|
from pathlib import Path
|
|
|
|
def fix_complex_duplicates(content):
|
|
"""Fix complex duplicate className patterns including template literals"""
|
|
|
|
# Pattern 1: className="..." className={`...`}
|
|
pattern1 = r'className="([^"]*)"\s+className=\{`([^`]*)`\}'
|
|
|
|
def fix_pattern1(match):
|
|
first_class = match.group(1).strip()
|
|
second_class_template = match.group(2).strip()
|
|
|
|
# For now, just keep the template literal version as it's more complex
|
|
return f'className={{{second_class_template}}}'
|
|
|
|
|
|
# Pattern 2: className="..." className="..."
|
|
pattern2 = r'className="([^"]*)"\s+className="([^"]*)"'
|
|
|
|
|
|
def fix_pattern2(match):
|
|
first_class = match.group(1).strip()
|
|
second_class = match.group(2).strip()
|
|
|
|
# If they're the same, just keep one
|
|
if first_class == second_class:
|
|
return f'className="{first_class}"'
|
|
|
|
# Split class names and merge them
|
|
first_classes = set(first_class.split())
|
|
second_classes = set(second_class.split())
|
|
|
|
# Combine classes (second takes precedence for conflicting classes)
|
|
merged_classes = first_classes | second_classes
|
|
|
|
return f'className="{" ".join(sorted(merged_classes))}"'
|
|
|
|
content = re.sub(pattern1, fix_pattern1, content)
|
|
content = re.sub(pattern2, fix_pattern2, content)
|
|
|
|
return content
|
|
|
|
def find_files_with_remaining_duplicates():
|
|
"""Find files that still have duplicate className attributes"""
|
|
files = []
|
|
for root, dirs, filenames in os.walk('.'):
|
|
# Skip node_modules and other irrelevant directories
|
|
dirs[:] = [d for d in dirs if not d.startswith('.') and d != 'node_modules']
|
|
for filename in filenames:
|
|
if filename.endswith(('.tsx', '.ts')) and not filename.endswith('.d.ts'):
|
|
filepath = os.path.join(root, filename)
|
|
try:
|
|
with open(filepath, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
# Look for remaining duplicate patterns
|
|
if re.search(r'className="[^"]*"\s+className=\{`', content) or re.search(r'className="[^"]*"\s+className="', content):
|
|
files.append(filepath)
|
|
except:
|
|
pass
|
|
return files
|
|
|
|
def fix_file(filepath):
|
|
"""Fix remaining duplicate className attributes in a single file"""
|
|
with open(filepath, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
original_content = content
|
|
fixed_content = fix_complex_duplicates(content)
|
|
|
|
if fixed_content != original_content:
|
|
with open(filepath, 'w', encoding='utf-8') as f:
|
|
f.write(fixed_content)
|
|
print(f'Fixed remaining duplicate className attributes in: {filepath}')
|
|
return True
|
|
|
|
return False
|
|
|
|
def main():
|
|
print('=== Finding and fixing remaining duplicate className attributes ===')
|
|
|
|
files = find_files_with_remaining_duplicates()
|
|
|
|
if not files:
|
|
print('No files with remaining duplicate className attributes found.')
|
|
return
|
|
|
|
print(f'Found {len(files)} files with remaining duplicate className attributes:')
|
|
|
|
fixed_count = 0
|
|
for filepath in files:
|
|
print(f' - {filepath}')
|
|
if fix_file(filepath):
|
|
fixed_count += 1
|
|
|
|
print(f'\n=== SUMMARY ===')
|
|
print(f'Fixed remaining duplicate className attributes in {fixed_count} out of {len(files)} files')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|