forked from jpudysz/react-native-unistyles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-components.js
More file actions
42 lines (39 loc) · 1.28 KB
/
build-components.js
File metadata and controls
42 lines (39 loc) · 1.28 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
const fs = require('node:fs')
const REACT_NATIVE_COMPONENT_NAMES = [
'ActivityIndicator',
'View',
'Text',
'Image',
'ImageBackground',
'KeyboardAvoidingView',
'Pressable',
'ScrollView',
'FlatList',
'SectionList',
'Switch',
'TextInput',
'RefreshControl',
'TouchableHighlight',
'TouchableOpacity',
'VirtualizedList',
'Animated',
'NativeView',
'NativeText'
]
fs.rmSync('./components', { recursive: true, force: true })
fs.mkdirSync('./components')
fs.mkdirSync('./components/native')
REACT_NATIVE_COMPONENT_NAMES.forEach(componentName => {
fs.mkdirSync(`./components/native/${componentName}`)
const hasNativeFile = fs.existsSync(`./src/components/native/${componentName}.native.tsx`)
const packageJson = [
'{',
` "main": "../../../lib/commonjs/components/native/${componentName}.js",`,
` "module": "../../../lib/module/components/native/${componentName}.js",`,
` "browser": "../../../lib/module/components/native/${componentName}.js",`,
` "react-native": "../../../src/components/native/${componentName}.${hasNativeFile ? 'native.' : ''}tsx"`,
'}',
''
].join('\n')
fs.writeFileSync(`./components/native/${componentName}/package.json`, packageJson)
})