-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-app.js
43 lines (33 loc) · 1.32 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
import { execSync } from 'node:child_process'
import { cpSync, renameSync, rmSync } from 'node:fs'
// Enhances source files inside /app with a fresh RN project template.
const appName = 'ReactigationApp'
console.log('⌛ Initializing a fresh RN project...')
execSync(`bunx @react-native-community/cli init ${appName} --skip-git-init true --install-pods true`, {
// Write output to cnosole.
stdio: 'inherit',
})
cpSync('app/component', `${appName}/component`, { recursive: true })
cpSync('app/App.tsx', `${appName}/App.tsx`)
cpSync('app/logo.png', `${appName}/logo.png`)
rmSync('app', { recursive: true })
renameSync(appName, 'app')
const output = execSync('bun pm pack', {
encoding: 'utf-8',
})
const tgzFileName = output.match(/[\w.-]+\.tgz/)[0]
execSync(`bun install ../${tgzFileName}`, {
cwd: './app',
})
console.log('⌛ Updating pods for new architecture.')
execSync('RCT_NEW_ARCH_ENABLED=1 pod update', {
cwd: './app/ios',
})
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('🌪️ 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.')