Skip to content
Snippets Groups Projects

Issue #3409491 add composer dependencies in conversion script

1 file
+ 14
32
Compare changes
  • Side-by-side
  • Inline
@@ -124,36 +124,18 @@ class ConverterCommand extends Command {
* @param \Composer\Script\Event $event
* The Composer event.
*/
public static function doConvert(): void {
print_r($event->getFlags());
return;
$count_arg = count($args);
if (!($count_arg === 3 || $count_arg === 4)) {
throw new \Exception("This scripts 3 required arguments: a directory that is a core clone and the branch and to convert either package_manager or automatic_updates.\nIt has 1 optional arguments: the branch of this module to use which defaults to 3.0.x");
}
$core_dir = $args[0];
$core_branch = $args[1];
if (!is_dir($core_dir)) {
throw new \Exception("$core_dir is not a directory.");
}
$package_manager_only = match($args[2]) {
'package_manager' => TRUE,
'automatic_updates' => FALSE,
default => throw new \UnexpectedValueException("The 3nd argument must be package_manager or automatic_updates"),
};
private function doConvert(): void {
$contrib_branch = $count_arg === 3 ? '3.0.x' : $args[3];
$old_machine_name = 'automatic_updates';
$new_machine_name = 'auto_updates';
static::switchToBranches($core_dir, $core_branch, $contrib_branch);
static::switchToBranches($this->core_dir, $this->core_branch, $this->contrib_branch);
self::info('Switched branches');
$fs = new Filesystem();
self::updateComposer();
$core_module_path = static::getCoreModulePath($core_dir);
$package_manager_core_path = $core_dir . "/core/modules/package_manager";
$core_module_path = static::getCoreModulePath($this->core_dir);
$package_manager_core_path = $this->core_dir . "/core/modules/package_manager";
// Remove old module.
$fs->remove($core_module_path);
self::info('Removed old core module');
@@ -181,10 +163,10 @@ class ConverterCommand extends Command {
}
self::info('Replacements done.');
static::removeLines($core_dir);
static::removeLines($this->core_dir);
self::info('Remove unneeded lines');
self::moveScripts($core_dir, $core_module_path, $package_manager_only);
self::moveScripts($this->core_dir, $core_module_path, $this->package_manager_only);
self::info('Moved scripts');
// Remove unneeded.
@@ -223,32 +205,32 @@ class ConverterCommand extends Command {
$fs->rename("$core_module_path/package_manager", $package_manager_core_path);
self::info('Move package manager');
static::copyGenericTest($package_manager_core_path, $core_dir);
static::copyGenericTest($package_manager_core_path, $this->core_dir);
// Run phpcbf because removing code from merge request may result in unused
// use statements or multiple empty lines.
system("composer phpcbf $package_manager_core_path");
if ($package_manager_only) {
if ($this->package_manager_only) {
$fs->remove($core_module_path);
}
else {
static::copyGenericTest($core_module_path, $core_dir);
static::copyGenericTest($core_module_path, $this->core_dir);
system("composer phpcbf $core_module_path");
}
static::addWordsToDictionary($core_dir, self::getContribDir() . "/dictionary.txt");
static::addWordsToDictionary($this->core_dir, self::getContribDir() . "/dictionary.txt");
self::info("Added to dictionary");
chdir($core_dir);
chdir($this->core_dir);
if (self::RUN_CHECKS) {
static::runCoreChecks($core_dir);
static::runCoreChecks($this->core_dir);
self::info('Ran core checks');
}
else {
self::info('⚠️Skipped core checks');
}
static::doMakeCommit($core_dir);
static::doMakeCommit($this->core_dir);
self::info('Make commit');
self::info("Done. Probably good but you should check before you push. These are the files present in the contrib module absent in core:");
print shell_exec(sprintf("tree %s/package_manager > /tmp/contrib.txt && tree %s/core/modules/package_manager > /tmp/core.txt && diff /tmp/contrib.txt /tmp/core.txt", self::getContribDir(), $core_dir));
Loading