8000 Adds option to check EOL via about command by domgraziano · Pull Request #37861 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Adds option to check EOL via about command #37861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix coding standard
  • Loading branch information
Domenico Graziano authored and Domenico Graziano committed Aug 17, 2020
commit 38dd8afbb29d41f4343da552c061776033887446
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Command;

use \RuntimeException;
use RuntimeException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Helper\TableSeparator;
Expand Down Expand Up @@ -69,8 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$kernel = $this->getApplication()->getKernel();

if ($input->getOption('eolCheck')) {
if(self::isExpired(Kernel::END_OF_MAINTENANCE) && self::isExpired(Kernel::END_OF_LIFE)) {
throw new RuntimeException(sprintf('Symfony %s is not maintained anymore, see https://symfony.com/releases to upgrade', Kernel::VERSION));
if (self::isExpired(Kernel::END_OF_MAINTENANCE) && self::isExpired(Kernel::END_OF_LIFE)) {
throw new RuntimeException(sprintf('Symfony "%s" is not maintained anymore, see https://symfony.com/releases to upgrade.', Kernel::VERSION));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return 1 instead of throwing an exception. Also, I would check for end of maintenance, not end of life. People should upgrade as soon as possible, not as late as possible :)
The option name could be named --is-maintained.

Copy link
Contributor
@noniagriconomie noniagriconomie Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use:

// configure() ...
$this
       ->setDescription('Displays information about the current project')
       ->addOption('is-maintained', null, InputOption::VALUE_NONE, 'Outputs the state of the Symfony kernel project version. Usefull for CI.')
...

and then

        /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
    	$io = new SymfonyStyle($input, $output);

    	if (false !== $input->getOption('is-maintained')) {
    		if (self::isExpired(Kernel::END_OF_MAINTENANCE)) {
    			$io->error(\sprintf('Symfony version %s is not maintained anymore. Please consider upgrading.', Kernel:: VERSION));

    			return Command::FAILURE;
    		} else {
				$io->success(\sprintf('Symfony version %s is maintained. EOM %s.', Kernel:: VERSION, self::daysBeforeExpiration(Kernel::END_OF_MAINTENANCE)));

    			return Command::SUCCESS;
    		}
    	}

      // actual code ...
    }

Copy link
Author
@domgraziano domgraziano Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, I opted for 1 as I am not really sure when those constants where introduced and where available. Also I consider this an added option, therefore I only need the exit and carry on with the normal output of the command in case of success (which is already returning 1)

}
}

Expand Down
0