-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-app.js
51 lines (41 loc) · 1.61 KB
/
create-app.js
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
#!/usr/bin/env node
import { cpSync, renameSync, rmSync } from 'fs'
import { join } from 'path'
import { execSync } from 'child_process'
// Enhances source files inside /app with a fresh RN project template.
const appTemp = 'app-temp'
console.log('⌛ Initializing a fresh RN project...')
// Renaming native folder leads to iOS build issues in some versions.
renameSync('app', appTemp)
execSync('npx react-native init app --skip-git-init true --install-pods false', {
// Write output to console.
stdio: 'inherit',
})
cpSync(`${appTemp}/App.tsx`, 'app/App.tsx')
cpSync(`${appTemp}/Expandable.tsx`, 'app/Expandable.tsx')
cpSync(`${appTemp}/global.d.ts`, 'app/global.d.ts')
cpSync('logo.png', 'app/logo.png')
rmSync(appTemp, { recursive: true })
// Run build to ensure distributed files for plugin exist.
execSync('bun run build', {
stdio: 'inherit',
})
// Install this package locally, avoiding symlinks.
execSync('npm install $(npm pack .. | tail -1)', {
cwd: join(process.cwd(), 'app'),
stdio: 'inherit',
})
// Additional dependency.
execSync('bun install react-native-cols mobx', {
cwd: join(process.cwd(), 'app'),
stdio: 'inherit',
})
console.log('')
console.log('🍞 React Native App created inside /app.')
console.log('🛠️ To run the example with the plugin included:')
console.log('🐚 cd app')
console.log('🐚 npm run ios / npm run android')
console.log('🐚 cd ios & pod install, as automatic pod installation currently fails.')
console.log('🌪️ To copy over the changes from the plugin source run:')
console.log('🐚 npm run watch')
console.log('🛠️ This will copy changes over to the app.')