@@ -5,6 +5,7 @@ import path from 'path';
55import type { TemplateConfiguration } from '../template' ;
66import sortObjectKeys from '../utils/sortObjectKeys' ;
77import { spawn } from '../utils/spawn' ;
8+ import dedent from 'dedent' ;
89
910const FILES_TO_DELETE = [
1011 '__tests__' ,
@@ -37,20 +38,24 @@ const PACKAGES_TO_REMOVE = [
3738 'react-native-safe-area-context' ,
3839] ;
3940
40- const PACKAGES_TO_ADD_WEB = {
41+ const PACKAGES_TO_ADD_EXPO_WEB = {
4142 '@expo/metro-runtime' : '~5.0.4' ,
4243 'react-dom' : '19.1.0' ,
4344 'react-native-web' : '~0.21.1' ,
4445} ;
4546
47+ const PACKAGES_TO_ADD_DEV_EXPO_NATIVE = {
48+ 'expo-dev-client' : '~5.0.3' ,
49+ } ;
50+
4651export default async function generateExampleApp ( {
4752 config,
4853 root,
4954 reactNativeVersion = 'latest' ,
5055} : {
5156 config : TemplateConfiguration ;
5257 root : string ;
53- reactNativeVersion ? : string ;
58+ reactNativeVersion : string | undefined ;
5459} ) {
5560 const directory = path . join ( root , 'example' ) ;
5661
@@ -252,14 +257,39 @@ export default async function generateExampleApp({
252257 bundledNativeModules = { } ;
253258 }
254259
255- Object . entries ( PACKAGES_TO_ADD_WEB ) . forEach ( ( [ name , version ] ) => {
256- dependencies [ name ] = bundledNativeModules [ name ] || version ;
257- } ) ;
260+ if ( config . project . native ) {
261+ Object . entries ( PACKAGES_TO_ADD_DEV_EXPO_NATIVE ) . forEach (
262+ ( [ name , version ] ) => {
263+ devDependencies [ name ] = bundledNativeModules [ name ] || version ;
264+ }
265+ ) ;
266+
267+ scripts . start = 'expo start --dev-client' ;
268+ scripts . android = 'expo run:android' ;
269+ scripts . ios = 'expo run:ios' ;
258270
259- scripts . web = 'expo start --web' ;
271+ delete scripts . web ;
272+
273+ await fs . writeFile (
274+ path . join ( directory , '.gitignore' ) ,
275+ dedent `
276+ # These folders are generated with prebuild (CNG)
277+ android/
278+ ios/
279+ `
280+ ) ;
281+ } else {
282+ Object . entries ( PACKAGES_TO_ADD_EXPO_WEB ) . forEach ( ( [ name , version ] ) => {
283+ dependencies [ name ] = bundledNativeModules [ name ] || version ;
284+ } ) ;
285+
286+ scripts . web = 'expo start --web' ;
287+ }
260288
261289 const app = await fs . readJSON ( path . join ( directory , 'app.json' ) ) ;
262290
291+ app . expo . name = `${ config . project . name } Example` ;
292+ app . expo . slug = `${ config . project . slug } -example` ;
263293 app . expo . android = app . expo . android || { } ;
264294 app . expo . android . package = `${ config . project . package } .example` ;
265295 app . expo . ios = app . expo . ios || { } ;
0 commit comments