Skip to content
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

[CLI] Improve "update:check-requirements" command #1025

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 15 additions & 1 deletion classes/Commands/CheckRequirementsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Exception;
use PrestaShop\Module\AutoUpgrade\Exceptions\DistributionApiException;
use PrestaShop\Module\AutoUpgrade\Exceptions\UpgradeException;
use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeConfiguration;
use PrestaShop\Module\AutoUpgrade\Services\DistributionApiService;
use PrestaShop\Module\AutoUpgrade\Services\PhpVersionResolverService;
use PrestaShop\Module\AutoUpgrade\Task\ExitCode;
Expand All @@ -43,7 +44,7 @@
class CheckRequirementsCommand extends AbstractCommand
{
/** @var string */
protected static $defaultName = 'update:check';
protected static $defaultName = 'update:check-requirements';
const MODULE_CONFIG_DIR = 'autoupgrade';
/** @var UpgradeSelfCheck */
private $upgradeSelfCheck;
Expand All @@ -58,6 +59,8 @@ protected function configure(): void
->setDescription('Check all prerequisites for an update.')
->setHelp('This command allows you to check the prerequisites necessary for the proper functioning of an update.')
->addOption('config-file-path', null, InputOption::VALUE_REQUIRED, 'Configuration file location for update.')
->addOption('zip', null, InputOption::VALUE_REQUIRED, 'Sets the archive zip file for a local update.')
->addOption('xml', null, InputOption::VALUE_REQUIRED, 'Sets the archive xml file for a local update.')
->addArgument('admin-dir', InputArgument::REQUIRED, 'The admin directory name.');
}

Expand All @@ -70,6 +73,17 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
$this->setupEnvironment($input, $output);
$this->output = $output;

$options = [
UpgradeConfiguration::ARCHIVE_ZIP => 'zip',
UpgradeConfiguration::ARCHIVE_XML => 'xml',
];
foreach ($options as $configKey => $optionName) {
$optionValue = $input->getOption($optionName);
if ($optionValue !== null) {
$this->consoleInputConfiguration[$configKey] = $optionValue;
}
}

$configPath = $input->getOption('config-file-path');
$exitCode = $this->loadConfiguration($configPath);
if ($exitCode !== ExitCode::SUCCESS) {
Expand Down
6 changes: 6 additions & 0 deletions classes/Task/Miscellaneous/UpdateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public function run(): int
}
}

// If no channel is specified, and there is a configuration relating to archive files, we deduce that the channel is local
$archiveFilesConfExist = isset($config[UpgradeConfiguration::ARCHIVE_XML]) || isset($config[UpgradeConfiguration::ARCHIVE_ZIP]);
if (!isset($config[UpgradeConfiguration::CHANNEL]) && $archiveFilesConfExist) {
$config[UpgradeConfiguration::CHANNEL] = UpgradeConfiguration::CHANNEL_LOCAL;
}

$isLocal = $config[UpgradeConfiguration::CHANNEL] === UpgradeConfiguration::CHANNEL_LOCAL;

$error = $this->container->getConfigurationValidator()->validate($config);
Expand Down