@@ -4,6 +4,7 @@ import https from 'https';
4
4
import { spawn } from '../utils/spawn' ;
5
5
import sortObjectKeys from '../utils/sortObjectKeys' ;
6
6
import type { TemplateConfiguration } from '../template' ;
7
+ import dedent from 'dedent' ;
7
8
8
9
const FILES_TO_DELETE = [
9
10
'__tests__' ,
@@ -35,20 +36,24 @@ const PACKAGES_TO_REMOVE = [
35
36
'typescript' ,
36
37
] ;
37
38
38
- const PACKAGES_TO_ADD_WEB = {
39
+ const PACKAGES_TO_ADD_EXPO_WEB = {
39
40
'@expo/metro-runtime' : '~3.2.1' ,
40
41
'react-dom' : '18.2.0' ,
41
42
'react-native-web' : '~0.18.10' ,
42
43
} ;
43
44
45
+ const PACKAGES_TO_ADD_DEV_EXPO_NATIVE = {
46
+ 'expo-dev-client' : '~5.0.3' ,
47
+ } ;
48
+
44
49
export default async function generateExampleApp ( {
45
50
config,
46
51
destination,
47
52
reactNativeVersion = 'latest' ,
48
53
} : {
49
54
config : TemplateConfiguration ;
50
55
destination : string ;
51
- reactNativeVersion ? : string ;
56
+ reactNativeVersion : string | undefined ;
52
57
} ) {
53
58
const directory = path . join ( destination , 'example' ) ;
54
59
@@ -219,14 +224,39 @@ export default async function generateExampleApp({
219
224
bundledNativeModules = { } ;
220
225
}
221
226
222
- Object . entries ( PACKAGES_TO_ADD_WEB ) . forEach ( ( [ name , version ] ) => {
223
- dependencies [ name ] = bundledNativeModules [ name ] || version ;
224
- } ) ;
227
+ if ( config . project . native ) {
228
+ Object . entries ( PACKAGES_TO_ADD_DEV_EXPO_NATIVE ) . forEach (
229
+ ( [ name , version ] ) => {
230
+ devDependencies [ name ] = bundledNativeModules [ name ] || version ;
231
+ }
232
+ ) ;
233
+
234
+ scripts . start = 'expo start --dev-client' ;
235
+ scripts . android = 'expo run:android' ;
236
+ scripts . ios = 'expo run:ios' ;
237
+
238
+ delete scripts . web ;
225
239
226
- scripts . web = 'expo start --web' ;
240
+ await fs . writeFile (
241
+ path . join ( directory , '.gitignore' ) ,
242
+ dedent `
243
+ # These folders are generated with prebuild (CNG)
244
+ android/
245
+ ios/
246
+ `
247
+ ) ;
248
+ } else {
249
+ Object . entries ( PACKAGES_TO_ADD_EXPO_WEB ) . forEach ( ( [ name , version ] ) => {
250
+ dependencies [ name ] = bundledNativeModules [ name ] || version ;
251
+ } ) ;
252
+
253
+ scripts . web = 'expo start --web' ;
254
+ }
227
255
228
256
const app = await fs . readJSON ( path . join ( directory , 'app.json' ) ) ;
229
257
258
+ app . expo . name = `${ config . project . name } Example` ;
259
+ app . expo . slug = `${ config . project . slug } -example` ;
230
260
app . expo . android = app . expo . android || { } ;
231
261
app . expo . android . package = `${ config . project . package } .example` ;
232
262
app . expo . ios = app . expo . ios || { } ;
0 commit comments