Преглед на файлове

Add Composer v2 compatibility.

- Fixed typos in commands/test
Eric BELLOT преди 3 години
родител
ревизия
22d01c76be
променени са 8 файла, в които са добавени 34 реда и са изтрити 26 реда
  1. 4 1
      README.md
  2. 2 2
      composer.json
  3. 8 4
      src/BaseBuilderCommand.php
  4. 0 10
      src/BuildServicesCommand.php
  5. 14 1
      src/Builder.php
  6. 2 2
      src/MergeParamsCommand.php
  7. 3 5
      src/PhpMemcacheAdminConfigCommand.php
  8. 1 1
      tests/MergeParamsCommandTest.php

+ 4 - 1
README.md

@@ -3,10 +3,13 @@
 ## License
 
 The plugin is licensed under the General Public License version 2.0 or later,
-just like the Drupal code it embeds.
+just like the Drupal derived code it embeds in `MergeParamsCommand`.
 
 ## Changes
 
+- 0.2.0
+  - Composer 2 compatibility in addition to Composer 1
+  - PHP 8 support
 - 0.1.3 
   - `mergeDeepArray` moved from `NestedArray` to `MergeParamsCommand` to
     avoid confusion with the Drupal version.

+ 2 - 2
composer.json

@@ -26,11 +26,11 @@
   "prefer-stable": true,
   "require": {
     "php": "^7.4 || ^8",
-    "composer-plugin-api": "^1.1",
+    "composer-plugin-api": "^1.1 || ^2.0.0",
     "composer/installers": "^1.12"
   },
   "require-dev": {
-    "composer/composer": "^1",
+    "composer/composer": "^2.1",
     "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
     "drupal/coder": "^8.3.13",
     "phpstan/phpstan": "^0.12.99",

+ 8 - 4
src/BaseBuilderCommand.php

@@ -4,6 +4,8 @@ declare(strict_types=1);
 
 namespace Fgm\Drupal\Composer;
 
+require_once __DIR__ . '/../../../../vendor/autoload.php';
+
 use Composer\Command\BaseCommand;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
@@ -59,10 +61,12 @@ abstract class BaseBuilderCommand extends BaseCommand {
     $conf = $this->getComposer()->getPackage()->getExtra()[Builder::NAME] ?? [];
     $templateName = $conf['templates'][$buildName] ?? '';
     if (empty($templateName)) {
-      $output->writeln(sprintf(
-        'Could not build file %s: no such template in composer.json extra section',
-        $buildName
-      ));
+      $output->writeln(
+        sprintf(
+          'Could not build file %s: no such template in composer.json extra section',
+          $buildName
+        )
+      );
       return ["", 1];
     }
     return [$templateName, 0];

+ 0 - 10
src/BuildServicesCommand.php

@@ -30,16 +30,6 @@ class BuildServicesCommand extends BaseBuilderCommand {
    */
   protected $eventName;
 
-  /**
-   * Does this command use a template ?
-   *
-   * @return bool
-   *   Does it ?
-   */
-  protected function useTemplate() {
-    return FALSE;
-  }
-
   /**
    * Configures the current command.
    */

+ 14 - 1
src/Builder.php

@@ -1,6 +1,6 @@
 <?php
 
-declare(strict_types = 1);
+declare(strict_types=1);
 
 namespace Fgm\Drupal\Composer;
 
@@ -99,4 +99,17 @@ class Builder implements Capable, Capability, EventSubscriberInterface, PluginIn
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function deactivate(Composer $composer, IOInterface $io) {
+    parent::deactivate($composer, $io);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function uninstall(Composer $composer, IOInterface $io) {
+  }
+
 }

+ 2 - 2
src/MergeParamsCommand.php

@@ -149,8 +149,8 @@ EOT
         // PHP automatically converts array keys that are integer strings
         // (e.g., '1') to integers.
         if (is_int($key)) {
-          // When an indexed array is overrided, the new values replace
-          // all overrided values (no merge).
+          // When an indexed array is overridden, the new values replace
+          // all overridden values (no merge).
           if ($key === 0) {
             $result = [];
           }

+ 3 - 5
src/PhpMemcacheAdminConfigCommand.php

@@ -65,11 +65,9 @@ class PhpMemcacheAdminConfigCommand extends BaseBuilderCommand {
     $this
       ->setName('build:phpmemcacheadmin')
       ->setDescription('Build the PhpMemcacheAdmin configuration.')
-      ->setDefinition(
-        new InputDefinition([
-                              new InputArgument(static::ARG_FILE, InputArgument::OPTIONAL, '', static::BUILD_NAME),
-                            ])
-      )
+      ->setDefinition(new InputDefinition([
+        new InputArgument(static::ARG_FILE, InputArgument::OPTIONAL, '', static::BUILD_NAME),
+      ]))
       ->setHelp(
         <<<EOT
 The build:phpmemcacheadmin command uses the memcache section of the site parameters

+ 1 - 1
tests/MergeParamsCommandTest.php

@@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase;
 final class MergeParamsCommandTest extends TestCase {
 
   /**
-   * Test MergeParamsCommand::merge().
+   * Test MergeParamsCommand::mergeDeepArray().
    *
    * @covers \Fgm\Drupal\Composer\MergeParamsCommand::mergeDeepArray
    */