fix(composer): detect if TopFloor is installed

master
dufraissejeremy 2 years ago
parent 3a1a8da810
commit 0de838a4df
  1. 1
      composer.json
  2. 52
      src/ParentPlugin.php
  3. 7
      src/Plugin.php

@ -20,6 +20,7 @@
},
"require": {
"composer-plugin-api": "^2.3",
"picocms/pico": "*",
"topfloor/composer-cleanup-vcs-dirs": "^1.1"
},
"replace": {

@ -0,0 +1,52 @@
<?php
/**
* SPDX-License-Identifier: EUPL-1.2
* Authors: see /README.md
*/
namespace Seacms\ComposerInstaller;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use TopFloor\ComposerCleanupVcsDirs\Plugin as TopFloorPlugin;
if (class_exists(TopFloorPlugin::class,false)){
abstract class ParentPlugin extends TopFloorPlugin
{
/**
* const to test if TopFloorPlugin
* @var bool
*/
protected const IS_TOP_FLOOR_PLUGIN = true;
}
} else {
abstract class ParentPlugin implements PluginInterface
{
/**
* const to test if TopFloorPlugin
* @var bool
*/
protected const IS_TOP_FLOOR_PLUGIN = false;
/**
* Deactivation hook.
*
* @param Composer $composer
* @param IOInterface $io
*/
public function deactivate(Composer $composer, IOInterface $io) {
}
/**
* Uninstall hook.
*
* @param Composer $composer
* @param IOInterface $io
*/
public function uninstall(Composer $composer, IOInterface $io) {
}
}
}

@ -17,7 +17,7 @@ use Composer\Repository\VcsRepository;
use Exception;
use Seacms\ComposerInstaller\Handler;
use Seacms\ComposerInstaller\NotFoundFileException;
use TopFloor\ComposerCleanupVcsDirs\Plugin as ParentPlugin;
use Seacms\ComposerInstaller\ParentPlugin;
/**
* Composer plugin to install or not packages from local path
@ -35,6 +35,7 @@ class Plugin extends ParentPlugin
* @var IOInterface
*/
protected $io;
protected $handler;
/**
* Apply plugin modifications to Composer
@ -45,6 +46,10 @@ class Plugin extends ParentPlugin
public function activate(Composer $composer, IOInterface $io) {
$this->composer = $composer;
$this->io = $io;
if (!self::IS_TOP_FLOOR_PLUGIN){
// do nothing
return ;
}
$this->handler = new Handler($composer, $io);
try {
list('config' => $config,'path' => $path) = $this->getConfigJsonFile();

Loading…
Cancel
Save