40 lines
2 KiB
Python
40 lines
2 KiB
Python
import os
|
|
import re
|
|
|
|
def fix_spacing(content):
|
|
# Procura por padrões onde Label é seguido de Input/Textarea/Select/div sem um container de espaçamento
|
|
# ou onde a div pai não tem classes de espaçamento.
|
|
|
|
# 1. Corrigir <div><Label/><Input/></div> para <div className="space-y-2"><Label/><Input/></div>
|
|
# Este regex procura divs que contenham Label e Input mas não tenham space-y
|
|
new_content = re.sub(
|
|
r'<div>\s*(<Label.*?</Label>)\s*(<(?:Input|Textarea|Select|div|RichTextEditor).+?/>|.*?</(?:Input|Textarea|Select|div|RichTextEditor)>)',
|
|
r'<div className="space-y-2">\n\1\n\2',
|
|
content,
|
|
flags=re.DOTALL
|
|
)
|
|
|
|
return new_content
|
|
|
|
def process_dashboard():
|
|
dashboard_path = r"C:\dev\gohorsejobs\frontend\src\app\dashboard"
|
|
for root, dirs, files in os.walk(dashboard_path):
|
|
for file in files:
|
|
if file.endswith('.tsx'):
|
|
path = os.path.join(root, file)
|
|
with open(path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Aplica correções conhecidas de divs sem classe
|
|
fixed = content.replace('<div>\n <Label', '<div className="space-y-2">\n <Label')
|
|
fixed = fixed.replace('<div>\r\n <Label', '<div className="space-y-2">\r\n <Label')
|
|
fixed = fixed.replace('<div>\n <Label', '<div className="space-y-2">\n <Label')
|
|
fixed = fixed.replace('<div>\r\n <Label', '<div className="space-y-2">\r\n <Label')
|
|
|
|
if fixed != content:
|
|
print(f"Ajustando espaçamento em: {path}")
|
|
with open(path, 'w', encoding='utf-8') as f:
|
|
f.write(fixed)
|
|
|
|
if __name__ == "__main__":
|
|
process_dashboard()
|