@@ -4,6 +4,7 @@ import https from 'https';
44import { spawn } from '../utils/spawn' ;
55import sortObjectKeys from '../utils/sortObjectKeys' ;
66import type { TemplateConfiguration } from '../template' ;
7+ import dedent from 'dedent' ;
78
89const FILES_TO_DELETE = [
910 '__tests__' ,
@@ -35,20 +36,24 @@ const PACKAGES_TO_REMOVE = [
3536 'typescript' ,
3637] ;
3738
38- const PACKAGES_TO_ADD_WEB = {
39+ const PACKAGES_TO_ADD_EXPO_WEB = {
3940 '@expo/metro-runtime' : '~3.2.1' ,
4041 'react-dom' : '18.2.0' ,
4142 'react-native-web' : '~0.18.10' ,
4243} ;
4344
45+ const PACKAGES_TO_ADD_DEV_EXPO_NATIVE = {
46+ 'expo-dev-client' : '~5.0.3' ,
47+ } ;
48+
4449export default async function generateExampleApp ( {
4550 config,
4651 destination,
4752 reactNativeVersion = 'latest' ,
4853} : {
4954 config : TemplateConfiguration ;
5055 destination : string ;
51- reactNativeVersion ? : string ;
56+ reactNativeVersion : string | undefined ;
5257} ) {
5358 const directory = path . join ( destination , 'example' ) ;
5459
@@ -219,14 +224,39 @@ export default async function generateExampleApp({
219224 bundledNativeModules = { } ;
220225 }
221226
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 ;
225239
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+ }
227255
228256 const app = await fs . readJSON ( path . join ( directory , 'app.json' ) ) ;
229257
258+ app . expo . name = `${ config . project . name } Example` ;
259+ app . expo . slug = `${ config . project . slug } -example` ;
230260 app . expo . android = app . expo . android || { } ;
231261 app . expo . android . package = `${ config . project . package } .example` ;
232262 app . expo . ios = app . expo . ios || { } ;
0 commit comments