Skip to content
Snippets Groups Projects

Add a core-convert job

Merged Adam G-H requested to merge issue/automatic_updates-3414168:3414168-add-a-new into 3.0.x
Compare and Show latest version
2 files
+ 17
5
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -4,6 +4,7 @@ declare(strict_types = 1);
namespace Drupal\automatic_updates\Development;
use Composer\InstalledVersions;
use Composer\Script\Event;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -81,11 +82,12 @@ class ConverterCommand extends Command {
private bool $gitlabci;
private readonly string $projectRoot;
/**
* {@inheritdoc}
*/
protected function configure() {
$this->addArgument('core_dir', InputArgument::REQUIRED, 'The path to the root of Drupal Core');
$this->addArgument('core_branch', InputArgument::OPTIONAL, 'The core merge request branch');
$this->addArgument('contrib_branch', InputArgument::OPTIONAL, 'The contrib branch to switch to', '3.0.x');
$this->addOption('package_manager_only', NULL, InputOption::VALUE_NONE, 'Only convert package manager');
@@ -99,7 +101,17 @@ class ConverterCommand extends Command {
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$this->core_dir = realpath($input->getArgument('core_dir'));
// Automatically detect the Drupal root; it's the directory that immediately
// contains Drupal core.
$drupal_root = InstalledVersions::getInstallPath('drupal/core');
$drupal_root = realpath($drupal_root);
$this->core_dir = dirname($drupal_root);
// We can ask Composer where the project root is; it may not be the same
// as the Drupal root.
$root_package = InstalledVersions::getRootPackage();
$this->projectRoot = realpath($root_package['install_path']);
$this->core_branch = $input->getArgument('core_branch');
$this->contrib_branch = $input->getArgument('contrib_branch');
$this->package_manager_only = $input->getOption('package_manager_only');
@@ -181,12 +193,12 @@ class ConverterCommand extends Command {
static::executeCommand("composer require $package_name:$version --no-update --working-dir={$this->core_dir}/core");
}
// Run composer update for just this packages.
static::executeCommand("composer update " . implode(' ', array_keys($require_section)));
static::executeCommand("composer update --working-dir={$this->projectRoot} " . implode(' ', array_keys($require_section)));
$require_dev_section = $this->getContribModuleComposerJsonSection('require-dev');
foreach ($require_dev_section as $package_name => $version) {
$version = $core_symfony_version_update($package_name, $version);
static::executeCommand("composer require --dev $package_name:$version");
static::executeCommand("composer require --dev --working-dir={$this->projectRoot} $package_name:$version");
}
$this->doConvert();
return Command::SUCCESS;
Loading