|
1
|
export function getComponentName(name: string) { |
|
2
|
return name |
|
3
|
.replace(/[-_]+/g, " ") |
|
4
|
.replace(/[^\w\s]/g, "") |
|
5
|
.replace( |
|
6
|
/\s+(.)(\w*)/g, |
|
7
|
(_$1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}` |
|
8
|
) |
|
9
|
.replace(/\w/, (s) => s.toUpperCase()) |
|
10
|
} |
|
11
|
|
|
12
|
function getFileName(name: string) { |
|
13
|
return `${name.replace("$", "").replace("/", "-")}.tsx` |
|
14
|
} |
|
15
|
|
|
16
|
function getTestName(name: string) { |
|
17
|
return `${name.replace("$", "").replace("/", "-")}.spec.tsx` |
|
18
|
} |
|
19
|
|
|
20
|
const FIXED_FRAMES = ["Flags", "Brands"] |
|
21
|
|
|
22
|
function isFixedIcon(name: string, frame_name: string) { |
|
23
|
if (FIXED_FRAMES.includes(frame_name)) { |
|
24
|
if (frame_name === "Brands" && name.includes("-ex")) { |
|
25
|
return false |
|
26
|
} |
|
27
|
|
|
28
|
return true |
|
29
|
} |
|
30
|
|
|
31
|
return false |
|
32
|
} |
|
33
|
|
|
34
|
export function getIconData(name: string, frame_name: string) { |
|
35
|
const componentName = getComponentName(name) |
|
36
|
const fileName = getFileName(name) |
|
37
|
const testName = getTestName(name) |
|
38
|
|
|
39
|
const fixed = isFixedIcon(name, frame_name) |
|
40
|
|
|
41
|
return { |
|
42
|
componentName, |
|
43
|
testName, |
|
44
|
fileName, |
|
45
|
fixed, |
|
46
|
} |
|
47
|
} |