Skip to content

Commit

Permalink
Workaround for botched composer.json files on d.o. #67
Browse files Browse the repository at this point in the history
Workaround for botched composer.json files on d.o.
  • Loading branch information
Natshah authored Jan 21, 2024
2 parents a98ccd6 + 16b64fe commit 47d89d5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Commands/RefactorComposerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,18 @@ public function generate($savePath, $drupalPath) {
if (!isset($pluginConfig['version'])) {
$pluginConfig['version'] = "0.0.0";
}
// Try to save botched drupal module composer files that might have been
// downloaded via git e.g.
// https://git.drupalcode.org/project/jquery_ui_accordion/-/blob/77d899f0b4f860435088c3ab18fb6d25b2fde39c/composer.json
// Check if in the related folder a .info.yml file with the expected name
// exists - if so use it as name as it should match drupal.org naming.
if (
!isset($pluginConfig['name'])
&& ($moduleName = basename(dirname($file)))
&& file_exists(dirname($file) . DIRECTORY_SEPARATOR . $moduleName . '.info.yml')
) {
$pluginConfig['name'] = 'drupal/' . $moduleName;
}
$pluginConfig = JsonFile::encode($pluginConfig);
$pluginPackage = $loader->load($pluginConfig);
$pluginPackageRequires = $pluginPackage->getRequires();
Expand All @@ -465,6 +477,18 @@ public function generate($savePath, $drupalPath) {
if (!isset($pluginConfig['version'])) {
$pluginConfig['version'] = "0.0.0";
}
// Try to save botched drupal theme composer files that might have been
// downloaded via git e.g.
// https://git.drupalcode.org/project/jquery_ui_accordion/-/blob/77d899f0b4f860435088c3ab18fb6d25b2fde39c/composer.json
// Check if in the related folder a .info.yml file with the expected name
// exists - if so use it as name as it should match drupal.org naming.
if (
!isset($pluginConfig['name'])
&& ($moduleName = basename(dirname($file)))
&& file_exists(dirname($file) . DIRECTORY_SEPARATOR . $moduleName . '.info.yml')
) {
$pluginConfig['name'] = 'drupal/' . $moduleName;
}
$pluginConfig = JsonFile::encode($pluginConfig);
$pluginPackage = $loader->load($pluginConfig);
$pluginPackageRequires = $pluginPackage->getRequires();
Expand Down

0 comments on commit 47d89d5

Please sign in to comment.