1919use Symfony \Component \Console \Exception \RuntimeException ;
2020use Symfony \Component \Console \Input \InputArgument ;
2121use Symfony \Component \Console \Input \InputInterface ;
22+ use Symfony \Component \Console \Input \InputOption ;
2223use Symfony \Component \Console \Output \OutputInterface ;
2324use Symfony \Flex \Configurator ;
2425use Symfony \Flex \Downloader ;
@@ -57,6 +58,7 @@ protected function configure()
5758 ->setAliases (['recipes:update ' ])
5859 ->setDescription ('Updates an already-installed recipe to the latest version. ' )
5960 ->addArgument ('package ' , InputArgument::OPTIONAL , 'Recipe that should be updated. ' )
61+ ->addOption ('next ' , null , InputOption::VALUE_NONE , 'Update recipe of next outdated package. ' )
6062 ;
6163 }
6264
@@ -81,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8183 $ packageName = $ input ->getArgument ('package ' );
8284 $ symfonyLock = $ this ->flex ->getLock ();
8385 if (!$ packageName ) {
84- $ packageName = $ this ->askForPackage ($ io , $ symfonyLock );
86+ $ packageName = $ this ->getNextOrAskForPackage ($ io , $ symfonyLock, $ input -> getOption ( ' next ' ) );
8587
8688 if (null === $ packageName ) {
8789 $ io ->writeError ('All packages appear to be up-to-date! ' );
@@ -353,7 +355,7 @@ private function generateChangelog(Recipe $originalRecipe): ?array
353355 return $ lines ;
354356 }
355357
356- private function askForPackage (IOInterface $ io , Lock $ symfonyLock ): ?string
358+ private function getNextOrAskForPackage (IOInterface $ io , Lock $ symfonyLock, bool $ next = false ): ?string
357359 {
358360 $ installedRepo = $ this ->getComposer ()->getRepositoryManager ()->getLocalRepository ();
359361
@@ -373,6 +375,10 @@ private function askForPackage(IOInterface $io, Lock $symfonyLock): ?string
373375 $ lockRef = $ symfonyLock ->get ($ name )['recipe ' ]['ref ' ] ?? null ;
374376
375377 if (null !== $ lockRef && $ recipe ->getRef () !== $ lockRef && !$ recipe ->isAuto ()) {
378+ if ($ next ) {
379+ return $ name ;
380+ }
381+
376382 $ outdatedRecipes [] = $ name ;
377383 }
378384 }
0 commit comments