@@ -78,6 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
78
78
->cleanUp ()
79
79
->updateParameters ()
80
80
->updateComposerJson ()
81
+ ->createGitIgnore ()
81
82
->checkSymfonyRequirements ()
82
83
->displayInstallationResult ()
83
84
;
@@ -348,14 +349,31 @@ private function extract()
348
349
349
350
/**
350
351
* Removes all the temporary files and directories created to
351
- * download and extract Symfony.
352
+ * download the project and removes Symfony-related files that don't make
353
+ * sense in a proprietary project.
352
354
*
353
355
* @return NewCommand
354
356
*/
355
357
private function cleanUp ()
356
358
{
357
359
$ this ->fs ->remove (dirname ($ this ->compressedFilePath ));
358
360
361
+ try {
362
+ $ licenseFile = array ($ this ->projectDir .'/LICENSE ' );
363
+ $ upgradeFiles = glob ($ this ->projectDir .'/UPGRADE*.md ' );
364
+ $ changelogFiles = glob ($ this ->projectDir .'/CHANGELOG*.md ' );
365
+
366
+ $ filesToRemove = array_merge ($ licenseFile , $ upgradeFiles , $ changelogFiles );
367
+ $ this ->fs ->remove ($ filesToRemove );
368
+
369
+ $ readmeContents = sprintf ("%s \n%s \n\nA Symfony project created on %s. \n" , $ this ->projectName , str_repeat ('= ' , strlen ($ this ->projectName )), date ('F j, Y, g:i a ' ));
370
+ $ this ->fs ->dumpFile ($ this ->projectDir .'/README.md ' , $ readmeContents );
371
+ } catch (\Exception $ e ) {
372
+ // don't throw an exception in case any of the Symfony-related files cannot
373
+ // be removed, because this is just an enhancement, not something mandatory
374
+ // for the project
375
+ }
376
+
359
377
return $ this ;
360
378
}
361
379
@@ -476,12 +494,51 @@ private function updateComposerJson()
476
494
return $ this ;
477
495
}
478
496
479
- $ ret = str_replace (
480
- '"name": "symfony/framework-standard-edition", ' ,
481
- sprintf ('"name": "%s", ' , $ this ->generateComposerProjectName ()),
482
- file_get_contents ($ filename )
497
+ $ contents = json_decode (file_get_contents ($ filename ), true );
498
+
499
+ $ contents ['name ' ] = $ this ->generateComposerProjectName ();
500
+ $ contents ['license ' ] = 'proprietary ' ;
501
+
502
+ if (isset ($ contents ['description ' ])) {
503
+ unset($ contents ['description ' ]);
504
+ }
505
+
506
+ if (isset ($ contents ['extra ' ]['branch-alias ' ])) {
507
+ unset($ contents ['extra ' ]['branch-alias ' ]);
508
+ }
509
+
510
+ file_put_contents ($ filename , json_encode ($ contents , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES )."\n" );
511
+
512
+ return $ this ;
513
+ }
514
+
515
+ /**
516
+ * Creates the appropriate .gitignore file for a Symfony project.
517
+ *
518
+ * @return NewCommand
519
+ */
520
+ private function createGitIgnore ()
521
+ {
522
+ $ gitIgnoreEntries = array (
523
+ '/app/bootstrap.php.cache ' ,
524
+ '/app/cache/* ' ,
525
+ '!app/cache/.gitkeep ' ,
526
+ '/app/config/parameters.yml ' ,
527
+ '/app/logs/* ' ,
528
+ '!app/logs/.gitkeep ' ,
529
+ '/app/phpunit.xml ' ,
530
+ '/bin/ ' ,
531
+ '/composer.phar ' ,
532
+ '/vendor/ ' ,
533
+ '/web/bundles/ ' ,
483
534
);
484
- file_put_contents ($ filename , $ ret );
535
+
536
+ try {
537
+ $ this ->fs ->dumpFile ($ this ->projectDir .'/.gitignore ' , implode ("\n" , $ gitIgnoreEntries )."\n" );
538
+ } catch (\Exception $ e ) {
539
+ // don't throw an exception in case the .gitignore file cannot be created,
540
+ // because this is just an enhancement, not something mandatory for the project
541
+ }
485
542
486
543
return $ this ;
487
544
}
0 commit comments