-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.py
More file actions
39 lines (30 loc) · 1.45 KB
/
run.py
File metadata and controls
39 lines (30 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import codegen
from codegen import Codebase
from codegen.sdk.enums import ProgrammingLanguage
@codegen.function("fragment_to_shorthand")
def run(codebase: Codebase):
print("🔍 Starting Fragment syntax conversion...")
for file in codebase.files:
print(f"📁 Processing: {file.filepath}")
fragments_found = False
# Convert Fragment components to shorthand
for element in file.jsx_elements:
if element.name == "Fragment":
print(f"🔄 Converting Fragment in {file.filepath}")
element.set_name("") # Convert to <> syntax
fragments_found = True
# Clean up Fragment imports if we found and converted any
if fragments_found:
for import_stmt in file.import_statements:
for imp in import_stmt.imports:
if imp.name == "Fragment":
print(f"🧹 Removing Fragment import from {file.filepath}")
imp.remove()
if fragments_found:
print(f"✨ Completed conversion in {file.filepath}")
codebase.commit()
if __name__ == "__main__":
print("🎯 Starting Fragment to shorthand conversion...")
codebase = Codebase.from_repo("RocketChat/Rocket.Chat", commit="a4f2102af1c2e875c60cafebd0163105bdaca678", programming_language=ProgrammingLanguage.TYPESCRIPT)
run(codebase)
print("✅ Done! All Fragments converted to shorthand syntax!")