Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
helhum committed Oct 7, 2019
1 parent 3fd75bf commit 6525703
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 222 deletions.

This file was deleted.

61 changes: 27 additions & 34 deletions Classes/Console/Command/Upgrade/UpgradeAllCommand.php
Expand Up @@ -24,37 +24,11 @@

class UpgradeAllCommand extends Command
{
use EnsureExtensionCompatibilityTrait;

const OPT_ARGUMENTS = 'arguments';

/**
* @var UpgradeHandling
*/
private $upgradeHandling;

/**
* @var OutputInterface
*/
private $output;

/**
* @param UpgradeHandling|null $upgradeHandling
*/
public function __construct(
string $name = null,
UpgradeHandling $upgradeHandling = null
) {
parent::__construct($name);

$this->upgradeHandling = $upgradeHandling ?? new UpgradeHandling();
}

protected function configure()
{
$this->setDescription('Execute all upgrade wizards that are scheduled for execution');
$this->addOption(
self::OPT_ARGUMENTS,
'arguments',
'a',
InputOption::VALUE_REQUIRED,
'Arguments for the wizard prefixed with the identifier, e.g. <code>compatibility7Extension[install]=0</code>; multiple arguments separated with comma',
Expand All @@ -64,31 +38,50 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;

if (!$this->ensureExtensionCompatibility()) {
$upgradeHandling = new UpgradeHandling();
// @deprecated, should be changed to StyleInterface
$consoleOutput = new ConsoleOutput($output, $input);
if (!$this->ensureExtensionCompatibility($upgradeHandling, $output)) {
return 1;
}

$arguments = $input->getArgument(self::ARG_ARGUMENTS);
$arguments = $input->getOption('arguments');
$verbose = $output->isVerbose();

$output->writeln(PHP_EOL . '<i>Initiating TYPO3 upgrade</i>' . PHP_EOL);

$messages = [];
$results = $this->upgradeHandling->executeAll($arguments, $this->output, $messages);
$results = $upgradeHandling->executeAll($arguments, $consoleOutput, $messages);

$output->outputLine(PHP_EOL . PHP_EOL . '<i>Successfully upgraded TYPO3 to version %s</i>', [TYPO3_version]);
$output->writeln(sprintf(PHP_EOL . PHP_EOL . '<i>Successfully upgraded TYPO3 to version %s</i>', TYPO3_version));

if ($verbose) {
$output->writeln('');
$output->writeln('<comment>Upgrade report:</comment>');
(new UpgradeWizardResultRenderer())->render($results, new ConsoleOutput($output, $input));
(new UpgradeWizardResultRenderer())->render($results, $consoleOutput);
}

$output->writeln('');
foreach ($messages as $message) {
$output->writeln($message);
}

return 0;
}

private function ensureExtensionCompatibility(UpgradeHandling $upgradeHandling, OutputInterface $output): bool
{
$messages = $upgradeHandling->ensureExtensionCompatibility();
if (!empty($messages)) {
$output->writeln('<error>Incompatible extensions found, aborting.</error>');

foreach ($messages as $message) {
$output->writeln($message);
}

return false;
}

return true;
}
}
Expand Up @@ -23,26 +23,6 @@

class UpgradeCheckExtensionCompatibilityCommand extends Command
{
const ARG_EXTENSION_KEY = 'extensionKeys';
const OPT_CONFIG_ONLY = 'configOnly';

/**
* @var UpgradeHandling
*/
private $upgradeHandling;

/**
* @param UpgradeHandling|null $upgradeHandling
*/
public function __construct(
string $name = null,
UpgradeHandling $upgradeHandling = null
) {
parent::__construct($name);

$this->upgradeHandling = $upgradeHandling ?? new UpgradeHandling();
}

protected function configure()
{
$this->setDescription('Checks for broken extensions');
Expand All @@ -53,12 +33,12 @@ protected function configure()
EOH
);
$this->addArgument(
self::ARG_EXTENSION_KEY,
'extensionKeys',
InputArgument::REQUIRED,
'Extension key for extension to check'
);
$this->addOption(
self::OPT_CONFIG_ONLY,
'configOnly',
'c',
InputOption::VALUE_NONE,
''
Expand All @@ -67,9 +47,9 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$extensionKey = $input->getArgument(self::ARG_EXTENSION_KEY);
$configOnly = $input->getOption(self::OPT_CONFIG_ONLY);
$extensionKey = $input->getArgument('extensionKeys');
$configOnly = $input->getOption('configOnly');

$output->writeln(\json_encode($this->upgradeHandling->isCompatible($extensionKey, $configOnly)));
$output->writeln(\json_encode((new UpgradeHandling())->isCompatible($extensionKey, $configOnly)));
}
}
Expand Up @@ -24,26 +24,6 @@

class UpgradeCheckExtensionConstraintsCommand extends Command
{
const ARG_EXTENSION_KEYS = 'extensionKeys';
const OPT_TYPO3_VERSION = 'typo3-version';

/**
* @var UpgradeHandling
*/
private $upgradeHandling;

/**
* @param UpgradeHandling|null $upgradeHandling
*/
public function __construct(
string $name = null,
UpgradeHandling $upgradeHandling = null
) {
parent::__construct($name);

$this->upgradeHandling = $upgradeHandling ?? new UpgradeHandling();
}

protected function configure()
{
$this->setDescription('Check TYPO3 version constraints of extensions');
Expand All @@ -55,13 +35,13 @@ protected function configure()
EOH
);
$this->addArgument(
self::ARG_EXTENSION_KEYS,
'extensionKeys',
InputArgument::OPTIONAL,
'Extension keys to check. Separate multiple extension keys with comma',
''
);
$this->addOption(
self::OPT_TYPO3_VERSION,
'typo3-version',
null,
InputOption::VALUE_REQUIRED,
'TYPO3 version to check against. Defaults to current TYPO3 version',
Expand All @@ -71,16 +51,16 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$extensionKeys = explode(',', $input->getArgument(self::ARG_EXTENSION_KEYS));
$typo3Version = $input->getOption(self::OPT_TYPO3_VERSION);

$extensionKeys = explode(',', $input->getArgument('extensionKeys'));
$typo3Version = $input->getOption('typo3-version');
$upgradeHandling = new UpgradeHandling();
if (empty($extensionKeys)) {
$failedPackageMessages = $this->upgradeHandling->matchAllExtensionConstraints($typo3Version);
$failedPackageMessages = $upgradeHandling->matchAllExtensionConstraints($typo3Version);
} else {
$failedPackageMessages = [];
foreach ($extensionKeys as $extensionKey) {
try {
if (!empty($result = $this->upgradeHandling->matchExtensionConstraints($extensionKey, $typo3Version))) {
if (!empty($result = $upgradeHandling->matchExtensionConstraints($extensionKey, $typo3Version))) {
$failedPackageMessages[$extensionKey] = $result;
}
} catch (UnknownPackageException $e) {
Expand All @@ -99,8 +79,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
'<info>All third party extensions claim to be compatible with TYPO3 version %s</info>',
$typo3Version
));
} else {
return 1;

return 0;
}

return 1;
}
}
63 changes: 27 additions & 36 deletions Classes/Console/Command/Upgrade/UpgradeListCommand.php
Expand Up @@ -15,6 +15,7 @@
*/

use Helhum\Typo3Console\Install\Upgrade\UpgradeHandling;
use Helhum\Typo3Console\Install\Upgrade\UpgradeWizardListRenderer;
use Helhum\Typo3Console\Mvc\Cli\ConsoleOutput;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -23,37 +24,11 @@

class UpgradeListCommand extends Command
{
use EnsureExtensionCompatibilityTrait;

const OPT_ALL = 'all';

/**
* @var UpgradeHandling
*/
private $upgradeHandling;

/**
* @var OutputInterface
*/
private $output;

/**
* @param UpgradeHandling|null $upgradeHandling
*/
public function __construct(
string $name = null,
UpgradeHandling $upgradeHandling = null
) {
parent::__construct($name);

$this->upgradeHandling = $upgradeHandling ?? new UpgradeHandling();
}

protected function configure()
{
$this->setDescription('List upgrade wizards');
$this->addOption(
self::OPT_ALL,
'all',
'a',
InputOption::VALUE_NONE,
'If set, all wizards will be listed, even the once marked as ready or done'
Expand All @@ -62,26 +37,42 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;

if (!$this->ensureExtensionCompatibility()) {
$upgradeHandling = new UpgradeHandling();
if (!$this->ensureExtensionCompatibility($upgradeHandling, $output)) {
return 1;
}

$all = $input->getOption(self::OPT_ALL);
$verbose = $output->isVerbose();

$wizards = $this->upgradeHandling->executeInSubProcess('listWizards', []);
$all = $input->getOption('all');
$wizards = $upgradeHandling->executeInSubProcess('listWizards');

$listRenderer = new UpgradeWizardListRenderer();
// @deprecated usage of ConsoleOutput will be removed with 6.0
$consoleOutput = new ConsoleOutput($output, $input);

$output->writeln('<comment>Wizards scheduled for execution:</comment>');
$listRenderer->render($wizards['scheduled'], $consoleOutput, $verbose);
$listRenderer->render($wizards['scheduled'], $consoleOutput, $output->isVerbose());

if ($all) {
$output->writeln(PHP_EOL . '<comment>Wizards marked as done:</comment>');
$listRenderer->render($wizards['done'], $consoleOutput, $verbose);
$listRenderer->render($wizards['done'], $consoleOutput, $output->isVerbose());
}

return 0;
}

private function ensureExtensionCompatibility(UpgradeHandling $upgradeHandling, OutputInterface $output): bool
{
$messages = $upgradeHandling->ensureExtensionCompatibility();
if (!empty($messages)) {
$output->writeln('<error>Incompatible extensions found, aborting.</error>');

foreach ($messages as $message) {
$output->writeln($message);
}

return false;
}

return true;
}
}

0 comments on commit 6525703

Please sign in to comment.