forked from agency-black/BlackTube
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate_icons_v2.py
More file actions
112 lines (105 loc) · 3.35 KB
/
migrate_icons_v2.py
File metadata and controls
112 lines (105 loc) · 3.35 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import os
import re
mapping = {
'bars': 'menu',
'arrow-left': 'arrow-left',
'arrow-right': 'arrow-right',
'search': 'search',
'clone': 'square-stack',
'filter': 'filter',
'rss': 'rss',
'user-check': 'user-check',
'fire': 'flame',
'users': 'users',
'bookmark': 'bookmark',
'history': 'history',
'sliders-h': 'sliders-horizontal',
'info-circle': 'info',
'circle-user': 'user-circle',
'thumbs-up': 'thumbs-up',
'thumbs-down': 'thumbs-down',
'play': 'play',
'pause': 'pause',
'forward': 'fast-forward',
'backward': 'rewind',
'step-forward': 'skip-forward',
'step-backward': 'skip-back',
'trash': 'trash-2',
'edit': 'edit-3',
'plus': 'plus',
'times': 'x',
'times-circle': 'x-circle',
'exclamation-circle': 'alert-circle',
'check': 'check',
'chevron-right': 'chevron-right',
'angle-down': 'chevron-down',
'angle-up': 'chevron-up',
'ellipsis-v': 'more-vertical',
'ellipsis-h': 'more-horizontal',
'external-link-alt': 'external-link',
'globe': 'globe',
'lock': 'lock',
'key': 'key',
'keyboard': 'keyboard',
'language': 'languages',
'palette': 'palette',
'shield': 'shield',
'wifi': 'wifi',
'video': 'video',
'clapperboard': 'clapperboard',
'film': 'film',
'images': 'image',
'database': 'database',
'server': 'server',
'network-wired': 'network',
'heart': 'heart',
'clock': 'clock',
'clock-rotate-left': 'history',
'share-alt': 'share-2',
'download': 'download',
'file-download': 'file-down',
'file-video': 'file-video',
'file-image': 'file-image',
'comment': 'message-square',
'comment-dots': 'message-square-more',
'newspaper': 'newspaper',
'podcast': 'podcast',
'tower-broadcast': 'tower-control',
'satellite-dish': 'satellite',
'trophy': 'trophy',
'gamepad': 'gamepad-2',
'flask': 'flask-conical',
'volume-high': 'volume-2',
'volume-low': 'volume-1',
'volume-mute': 'volume-x',
'expand': 'maximize',
'compress': 'minimize',
'thumbtack': 'pin',
'magnifying-glass': 'search',
'list': 'list'
}
def migrate_file(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# 1. Replace icon props in custom components like FtIconButton, FtButton, FtSelect, etc.
def replace_icon_prop(match):
full_tag = match.group(0)
icon_match = re.search(r":icon=\"\[\s*['\"]fa[sr]b?['\"]\s*,\s*['\"]([^'\"]+)['\"]\s*\]\"", full_tag)
if icon_match:
fa_name = icon_match.group(1)
lucide_name = mapping.get(fa_name, fa_name)
return full_tag.replace(icon_match.group(0), f':icon="\'{lucide_name}\'"')
return full_tag
# Target components that use the icon prop
content = re.sub(r"<FtIconButton[^>]+>", replace_icon_prop, content)
content = re.sub(r"<FtButton[^>]+>", replace_icon_prop, content)
content = re.sub(r"<FtSelect[^>]+>", replace_icon_prop, content)
content = re.sub(r"<FtChannelBubble[^>]+>", replace_icon_prop, content)
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
root_dir = 'src/renderer'
for root, dirs, files in os.walk(root_dir):
for file in files:
if file.endswith('.vue'):
migrate_file(os.path.join(root, file))
print("Step 2 Migration complete!")