@@ -5,6 +5,7 @@ import dedent from 'dedent';
55import kleur from 'kleur' ;
66import yargs from 'yargs' ;
77import ora from 'ora' ;
8+ import assert from 'node:assert' ;
89import validateNpmPackage from 'validate-npm-package-name' ;
910import githubUsername from 'github-username' ;
1011import prompts , { type PromptObject } from './utils/prompts' ;
@@ -790,8 +791,23 @@ async function create(_argv: yargs.Arguments<any>) {
790791 examplePackageJson . dependencies [ 'react-native' ] ;
791792 }
792793
793- if ( arch !== 'legacy' && example === 'vanilla' ) {
794- addCodegenBuildScript ( folder , options . project . name ) ;
794+ if ( example === 'vanilla' ) {
795+ // React Native doesn't provide the community CLI as a dependency.
796+ // We have to get read the version from the example app and put to the root package json
797+ const exampleCommunityCLIVersion =
798+ examplePackageJson . devDependencies [ '@react-native-community/cli' ] ;
799+ assert (
800+ exampleCommunityCLIVersion !== undefined ,
801+ "The generated example app doesn't have community CLI installed"
802+ ) ;
803+
804+ rootPackageJson . devDependencies = rootPackageJson . devDependencies || { } ;
805+ rootPackageJson . devDependencies [ '@react-native-community/cli' ] =
806+ exampleCommunityCLIVersion ;
807+
808+ if ( arch !== 'legacy' ) {
809+ addCodegenBuildScript ( folder , options . project . name ) ;
810+ }
795811 }
796812 }
797813
0 commit comments