@@ -29,8 +29,6 @@ import {getNpmVersionIfAvailable} from '../../tools/npm';
2929import { getYarnVersionIfAvailable } from '../../tools/yarn' ;
3030import { createHash } from 'crypto' ;
3131import createGitRepository from './createGitRepository' ;
32- import deepmerge from 'deepmerge' ;
33- import semver from 'semver' ;
3432
3533const DEFAULT_VERSION = 'latest' ;
3634
@@ -114,7 +112,6 @@ async function createFromTemplate({
114112 skipInstall,
115113 packageName,
116114 installCocoaPods,
117- version,
118115} : TemplateOptions ) {
119116 logger . debug ( 'Initializing new project' ) ;
120117 logger . log ( banner ) ;
@@ -178,15 +175,6 @@ async function createFromTemplate({
178175 packageName,
179176 } ) ;
180177
181- const coerceRnVersion = semver . valid ( semver . coerce ( version ) ) ;
182-
183- if (
184- version === 'latest' ||
185- ( coerceRnVersion && semver . satisfies ( coerceRnVersion , '>=0.73.0' ) )
186- ) {
187- createDefaultConfigFile ( projectDirectory , loader ) ;
188- }
189-
190178 const { postInitScript} = templateConfig ;
191179 if ( postInitScript ) {
192180 loader . info ( 'Executing post init script ' ) ;
@@ -289,62 +277,6 @@ function createTemplateUri(options: Options, version: string): string {
289277 return options . template || `${ platform } @${ version } ` ;
290278}
291279
292- //remove quotes from object keys to match the linter rules of the template
293- function sanitizeConfigFile ( fileContent : string ) {
294- return fileContent . replace ( / " ( [ ^ " ] + ) " : / g, '$1:' ) ;
295- }
296-
297- /*
298- Starting from 0.73, react-native.config.js is created by CLI during the init process.
299- It contains automaticPodsInstallation flag set to true by default.
300- This flag is used by CLI to determine whether to install CocoaPods dependencies when running ios commands or not.
301- It's created by CLI rather than being a part of a template to avoid displaying this file in the Upgrade Helper,
302- as it might bring confusion for existing projects where this change might not be applicable.
303- For more details, see https://github.com/react-native-community/cli/blob/main/docs/projects.md#projectiosautomaticpodsinstallation
304- */
305- function createDefaultConfigFile ( directory : string , loader : Loader ) {
306- const cliConfigContent = {
307- project : {
308- ios : {
309- automaticPodsInstallation : true ,
310- } ,
311- } ,
312- } ;
313- const configFileContent = `module.exports = ${ JSON . stringify (
314- cliConfigContent ,
315- null ,
316- 2 ,
317- ) } `;
318- const filepath = 'react-native.config.js' ;
319- try {
320- if ( ! doesDirectoryExist ( path . join ( directory , filepath ) ) ) {
321- fs . writeFileSync ( filepath , sanitizeConfigFile ( configFileContent ) , {
322- encoding : 'utf-8' ,
323- } ) ;
324- } else {
325- const existingConfigFile = require ( path . join ( directory , filepath ) ) ;
326-
327- const mergedConfig = deepmerge ( existingConfigFile , cliConfigContent ) ;
328- const output = `module.exports = ${ JSON . stringify (
329- mergedConfig ,
330- null ,
331- 2 ,
332- ) } ;`;
333-
334- fs . writeFileSync ( filepath , sanitizeConfigFile ( output ) , {
335- encoding : 'utf-8' ,
336- } ) ;
337- }
338- loader . succeed ( ) ;
339- } catch {
340- loader . warn (
341- `Could not create custom ${ chalk . bold (
342- 'react-native.config.js' ,
343- ) } file. You can create it manually in your project's root folder with the following content: \n\n${ configFileContent } `,
344- ) ;
345- }
346- }
347-
348280async function createProject (
349281 projectName : string ,
350282 directory : string ,
0 commit comments