@@ -97,7 +97,6 @@ class Flex implements PluginInterface, EventSubscriberInterface
9797 'remove ' => false ,
9898 'unpack ' => true ,
9999 ];
100- private $ shouldUpdateComposerLock = false ;
101100 private $ filter ;
102101
103102 public function activate (Composer $ composer , IOInterface $ io )
@@ -357,7 +356,7 @@ public function update(Event $event, $operations = [])
357356 $ contents = file_get_contents ($ file );
358357 $ json = JsonFile::parseJson ($ contents );
359358
360- if (!isset ($ json ['flex-require ' ]) && !isset ($ json ['flex-require ' ])) {
359+ if (!isset ($ json ['flex-require ' ]) && !isset ($ json ['flex-require-dev ' ])) {
361360 $ this ->unpack ($ event );
362361
363362 return ;
@@ -427,10 +426,11 @@ public function install(Event $event)
427426 $ this ->io ->writeError (sprintf ('<info>Symfony operations: %d recipe%s (%s)</> ' , \count ($ recipes ), \count ($ recipes ) > 1 ? 's ' : '' , $ this ->downloader ->getSessionId ()));
428427 $ installContribs = $ this ->composer ->getPackage ()->getExtra ()['symfony ' ]['allow-contrib ' ] ?? false ;
429428 $ manifest = null ;
429+ $ originalComposerJsonHash = $ this ->getComposerJsonHash ();
430430 foreach ($ recipes as $ recipe ) {
431431 if ('install ' === $ recipe ->getJob () && !$ installContribs && $ recipe ->isContrib ()) {
432432 $ warning = $ this ->io ->isInteractive () ? 'WARNING ' : 'IGNORING ' ;
433- $ this ->io ->writeError (sprintf (' - <warning> %s </> %s ' , $ warning , $ this -> formatOrigin ( $ recipe ->getOrigin () )));
433+ $ this ->io ->writeError (sprintf (' - <warning> %s </> %s ' , $ warning , $ recipe ->getFormattedOrigin ( )));
434434 $ question = sprintf (' The recipe for this package comes from the "contrib" repository, which is open to community contributions.
435435 Review the recipe at %s
436436
@@ -468,13 +468,12 @@ function ($value) {
468468 $ manipulator = new JsonManipulator (file_get_contents ($ json ->getPath ()));
469469 $ manipulator ->addSubNode ('extra ' , 'symfony.allow-contrib ' , true );
470470 file_put_contents ($ json ->getPath (), $ manipulator ->getContents ());
471- $ this ->shouldUpdateComposerLock = true ;
472471 }
473472 }
474473
475474 switch ($ recipe ->getJob ()) {
476475 case 'install ' :
477- $ this ->io ->writeError (sprintf (' - Configuring %s ' , $ this -> formatOrigin ( $ recipe ->getOrigin () )));
476+ $ this ->io ->writeError (sprintf (' - Configuring %s ' , $ recipe ->getFormattedOrigin ( )));
478477 $ this ->configurator ->install ($ recipe , $ this ->lock , [
479478 'force ' => $ event instanceof UpdateEvent && $ event ->force (),
480479 ]);
@@ -491,7 +490,7 @@ function ($value) {
491490 case 'update ' :
492491 break ;
493492 case 'uninstall ' :
494- $ this ->io ->writeError (sprintf (' - Unconfiguring %s ' , $ this -> formatOrigin ( $ recipe ->getOrigin () )));
493+ $ this ->io ->writeError (sprintf (' - Unconfiguring %s ' , $ recipe ->getFormattedOrigin ( )));
495494 $ this ->configurator ->unconfigure ($ recipe , $ this ->lock );
496495 break ;
497496 }
@@ -512,7 +511,7 @@ function ($value) {
512511 $ this ->synchronizePackageJson ($ rootDir );
513512 $ this ->lock ->write ();
514513
515- if ($ this ->shouldUpdateComposerLock ) {
514+ if ($ this ->getComposerJsonHash () !== $ originalComposerJsonHash ) {
516515 $ this ->updateComposerLock ();
517516 }
518517 }
@@ -808,16 +807,6 @@ private function initOptions(): Options
808807 return new Options ($ options , $ this ->io );
809808 }
810809
811- private function formatOrigin (string $ origin ): string
812- {
813- // symfony/translation:3.3@github.com/symfony/recipes:branch
814- if (!preg_match ('/^([^:]++):([^@]++)@(.+)$/ ' , $ origin , $ matches )) {
815- return $ origin ;
816- }
817-
818- return sprintf ('<info>%s</> (<comment>>=%s</>): From %s ' , $ matches [1 ], $ matches [2 ], 'auto-generated recipe ' === $ matches [3 ] ? '<comment> ' .$ matches [3 ].'</> ' : $ matches [3 ]);
819- }
820-
821810 private function shouldRecordOperation (PackageEvent $ event ): bool
822811 {
823812 $ operation = $ event ->getOperation ();
@@ -981,4 +970,9 @@ public static function getSubscribedEvents(): array
981970
982971 return $ events ;
983972 }
973+
974+ private function getComposerJsonHash (): string
975+ {
976+ return md5_file (Factory::getComposerFile ());
977+ }
984978}
0 commit comments