Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • spip-league/composer-installer
1 résultat
Afficher les modifications
Affichage de
avec 115 ajouts et 103 suppressions
...@@ -4,9 +4,5 @@ namespace SpipLeague\Composer\Extensions; ...@@ -4,9 +4,5 @@ namespace SpipLeague\Composer\Extensions;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <jamees@rezo.net>
*/ */
class InvalidSpecificationException extends \DomainException class InvalidSpecificationException extends \DomainException {}
{
}
...@@ -13,18 +13,22 @@ use SpipLeague\Composer\SpipPaths; ...@@ -13,18 +13,22 @@ use SpipLeague\Composer\SpipPaths;
* Déduites du contenu du fichier `./plugins-dist.json` * Déduites du contenu du fichier `./plugins-dist.json`
* *
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class Specification implements SpecificationInterface class Specification implements SpecificationInterface
{ {
private string $prefix; private string $prefix;
private string $path; private string $path;
private string $source; private string $source;
private string $branch; private string $branch;
private string $tag; private string $tag;
/** @var array<int,array{name:string,version:string,source?:array{url?:string}}>|null */ /**
* @var array<int,array{name:string,version:string,source?:array{url?:string}}>|null
*/
private static ?array $packages = \null; private static ?array $packages = \null;
protected ?RemoteUrlsInterface $changer = null; protected ?RemoteUrlsInterface $changer = null;
...@@ -83,12 +87,10 @@ class Specification implements SpecificationInterface ...@@ -83,12 +87,10 @@ class Specification implements SpecificationInterface
* *
* Limitation: l'extension DOIT être composerisée et être * Limitation: l'extension DOIT être composerisée et être
* distribuée dans un dépôt composer accessible. * distribuée dans un dépôt composer accessible.
*
* @throws InvalidSpecificationException if a composer.lock error occurs or vendorName is missing.
*/ */
public static function createFromComposer(Composer $composer, string $vendorName): self public static function createFromComposer(Composer $composer, string $vendorName): self
{ {
if (\is_null(self::$packages)) { if (self::$packages === null) {
$lockFile = Factory::getLockFile(Factory::getComposerFile()); $lockFile = Factory::getLockFile(Factory::getComposerFile());
/** @var array{packages?:array<int,array{name:string,version:string,source?:array{url?:string}}>} $lockFileContent */ /** @var array{packages?:array<int,array{name:string,version:string,source?:array{url?:string}}>} $lockFileContent */
$lockFileContent = \json_decode(\file_get_contents($lockFile) ?: 'null', \true); $lockFileContent = \json_decode(\file_get_contents($lockFile) ?: 'null', \true);
...@@ -101,12 +103,13 @@ class Specification implements SpecificationInterface ...@@ -101,12 +103,13 @@ class Specification implements SpecificationInterface
} }
$tag = $branch = \null; $tag = $branch = \null;
$links = $composer->getPackage()->getRequires(); $links = $composer->getPackage()
->getRequires();
$require = $links[$vendorName] ?? null; $require = $links[$vendorName] ?? null;
if ($require) { if ($require) {
$prefix = (string) \preg_replace(',^[^/]+/,', '', $vendorName); $prefix = (string) \preg_replace(',^[^/]+/,', '', $vendorName);
$search = \array_filter(self::$packages, fn ($package) => $vendorName === $package['name']); $search = \array_filter(self::$packages, fn($package) => $vendorName === $package['name']);
$sourceUrl = ''; $sourceUrl = '';
if (\count($search) > 0) { if (\count($search) > 0) {
$package = \array_shift($search); $package = \array_shift($search);
...@@ -178,7 +181,7 @@ class Specification implements SpecificationInterface ...@@ -178,7 +181,7 @@ class Specification implements SpecificationInterface
*/ */
public function computeVendorName(): string public function computeVendorName(): string
{ {
if (\is_null($this->changer)) { if ($this->changer === null) {
return ''; return '';
} }
......
...@@ -6,8 +6,6 @@ namespace SpipLeague\Composer\Extensions; ...@@ -6,8 +6,6 @@ namespace SpipLeague\Composer\Extensions;
* Spécifiations d'installation d'un "plugins-dist" en SPIP4.4. * Spécifiations d'installation d'un "plugins-dist" en SPIP4.4.
* *
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
interface SpecificationInterface extends \JsonSerializable interface SpecificationInterface extends \JsonSerializable
{ {
......
...@@ -8,8 +8,6 @@ use SpipLeague\Composer\Git\RemoteUrlsInterface; ...@@ -8,8 +8,6 @@ use SpipLeague\Composer\Git\RemoteUrlsInterface;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class Factory class Factory
{ {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace SpipLeague\Composer\Git; namespace SpipLeague\Composer\Git;
use Composer\IO\IOInterface;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
/** /**
...@@ -11,12 +10,10 @@ use Composer\Util\ProcessExecutor; ...@@ -11,12 +10,10 @@ use Composer\Util\ProcessExecutor;
*/ */
class RemoteUrls implements RemoteUrlsInterface class RemoteUrls implements RemoteUrlsInterface
{ {
/** @var string[] */ /**
private array $matching = [ * @var string[]
'github.com', */
'gitlab.com', private array $matching = ['github.com', 'gitlab.com', 'git.spip.net'];
'git.spip.net',
];
private ?ProcessExecutor $processor; private ?ProcessExecutor $processor;
......
...@@ -10,7 +10,9 @@ use Composer\Util\Filesystem; ...@@ -10,7 +10,9 @@ use Composer\Util\Filesystem;
*/ */
class PluginsClearCache class PluginsClearCache
{ {
/** @var string[] */ /**
* @var string[]
*/
private static array $files = [ private static array $files = [
'%spip.dirs.tmp%/plugin_xml_cache.gz', '%spip.dirs.tmp%/plugin_xml_cache.gz',
'%spip.dirs.cache%/charger_pipelines.php', '%spip.dirs.cache%/charger_pipelines.php',
...@@ -25,21 +27,21 @@ class PluginsClearCache ...@@ -25,21 +27,21 @@ class PluginsClearCache
/** /**
* To delete the cache files dedicated of the activated plugins * To delete the cache files dedicated of the activated plugins
*
* @param $event
*
* @return void
*/ */
public static function clearCache(Event $event) public static function clearCache(Event $event)
{ {
$event->getIO()->write('Clearing the plugins cache ...'); $event->getIO()
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir') . '/'; ->write('Clearing the plugins cache ...');
$vendorDir = $event->getComposer()
->getConfig()
->get('vendor-dir') . '/';
$fs = new Filesystem($event->getComposer()->getLoop()->getProcessExecutor()); $fs = new Filesystem($event->getComposer()->getLoop()->getProcessExecutor());
foreach (self::$files as $file) { foreach (self::$files as $file) {
$fs->remove($vendorDir . '../' . SpipPaths::interpolate($file)); $fs->remove($vendorDir . '../' . SpipPaths::interpolate($file));
} }
$event->getIO()->write('Done.'); $event->getIO()
->write('Done.');
} }
} }
...@@ -18,27 +18,30 @@ class Security ...@@ -18,27 +18,30 @@ class Security
public static function copySafetyScreen(Event $event): void public static function copySafetyScreen(Event $event): void
{ {
$search = array_filter( $search = array_filter(
$event->getComposer()->getPackage()->getRequires(), $event->getComposer()
function (Link $link) { ->getPackage()
return $link->getTarget() === 'spip/security'; ->getRequires(),
}, fn(Link $link) => $link->getTarget() === 'spip/security',
); );
if (empty($search)) { if (empty($search)) {
$event->getIO()->warning('spip/security is not installed.'); $event->getIO()
->warning('spip/security is not installed.');
return; return;
} }
$event->getIO()->write('Updating the safety screen ...'); $event->getIO()
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir'); ->write('Updating the safety screen ...');
$vendorDir = $event->getComposer()
->getConfig()
->get('vendor-dir');
try { try {
\copy( \copy($vendorDir . '/spip/security/ecran_securite.php', $vendorDir . '/../config/ecran_securite.php');
$vendorDir . '/spip/security/ecran_securite.php', $event->getIO()
$vendorDir . '/../config/ecran_securite.php', ->write('Done.');
);
$event->getIO()->write('Done.');
} catch (\Throwable $th) { } catch (\Throwable $th) {
$event->getIO()->error($th->getMessage()); $event->getIO()
->error($th->getMessage());
} }
} }
} }
...@@ -7,22 +7,20 @@ use Composer\Package\PackageInterface; ...@@ -7,22 +7,20 @@ use Composer\Package\PackageInterface;
class SpipInstaller extends LibraryInstaller class SpipInstaller extends LibraryInstaller
{ {
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package) public function getInstallPath(PackageInterface $package)
{ {
if ('spip-ecrire' === $package->getType()) { if ($package->getType() === 'spip-ecrire') {
return './' . SpipPaths::BACK_OFFICE; return './' . SpipPaths::BACK_OFFICE;
} }
if ('spip-prive' === $package->getType()) { if ($package->getType() === 'spip-prive') {
return './' . SpipPaths::PRIVATE_TEMPLATE; return './' . SpipPaths::PRIVATE_TEMPLATE;
} }
if ('spip-plugin' === $package->getType()) { if ($package->getType() === 'spip-plugin') {
/** @var array{spip?:array{extensions?:string[],template?:string,private_template?:string,back_office?:string}} */ /** @var array{spip?:array{extensions?:string[],template?:string,private_template?:string,back_office?:string}} */
$extra = $this->composer->getPackage()->getExtra(); $extra = $this->composer->getPackage()
->getExtra();
$template = $extra['spip']['template'] ?? ''; $template = $extra['spip']['template'] ?? '';
$extensions = $extra['spip']['extensions'] ?? []; $extensions = $extra['spip']['extensions'] ?? [];
$name = $package->getName(); $name = $package->getName();
...@@ -38,10 +36,7 @@ class SpipInstaller extends LibraryInstaller ...@@ -38,10 +36,7 @@ class SpipInstaller extends LibraryInstaller
return './' . SpipPaths::PLUGINS . '/' . $name; return './' . SpipPaths::PLUGINS . '/' . $name;
} }
if (in_array($package->getType(), [ if (in_array($package->getType(), ['spip-lang', 'spip-theme'])) {
'spip-lang',
'spip-theme',
])) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'Unable to install this package as its type is not supported for now.' . 'Unable to install this package as its type is not supported for now.' .
' Wait for a future SPIP version for using it.', ' Wait for a future SPIP version for using it.',
...@@ -51,9 +46,6 @@ class SpipInstaller extends LibraryInstaller ...@@ -51,9 +46,6 @@ class SpipInstaller extends LibraryInstaller
return parent::getInstallPath($package); return parent::getInstallPath($package);
} }
/**
* {@inheritDoc}
*/
public function supports(string $packageType) public function supports(string $packageType)
{ {
return in_array($packageType, [ return in_array($packageType, [
......
...@@ -17,16 +17,13 @@ class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface, ...@@ -17,16 +17,13 @@ class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface,
public function activate(Composer $composer, IOInterface $io) public function activate(Composer $composer, IOInterface $io)
{ {
$installer = new SpipInstaller($io, $composer); $installer = new SpipInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer); $composer->getInstallationManager()
->addInstaller($installer);
} }
public function deactivate(Composer $composer, IOInterface $io) public function deactivate(Composer $composer, IOInterface $io) {}
{
}
public function uninstall(Composer $composer, IOInterface $io) public function uninstall(Composer $composer, IOInterface $io) {}
{
}
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
...@@ -82,7 +79,7 @@ class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface, ...@@ -82,7 +79,7 @@ class SpipInstallerPlugin implements PluginInterface, EventSubscriberInterface,
public function getCapabilities() public function getCapabilities()
{ {
return [ return [
'Composer\Plugin\Capability\CommandProvider' => 'SpipLeague\Composer\CommandProvider', \Composer\Plugin\Capability\CommandProvider::class => \SpipLeague\Composer\CommandProvider::class,
]; ];
} }
} }
...@@ -5,24 +5,37 @@ namespace SpipLeague\Composer; ...@@ -5,24 +5,37 @@ namespace SpipLeague\Composer;
class SpipPaths class SpipPaths
{ {
public const CHMOD = 0777; public const CHMOD = 0777;
public const UMASK = 0000; public const UMASK = 0000;
public const PLUGINS = 'plugins'; public const PLUGINS = 'plugins';
public const EXTENSIONS = 'plugins-dist'; public const EXTENSIONS = 'plugins-dist';
public const TEMPLATE = 'squelettes-dist'; public const TEMPLATE = 'squelettes-dist';
public const PRIVATE_TEMPLATE = 'prive'; public const PRIVATE_TEMPLATE = 'prive';
public const BACK_OFFICE = 'ecrire'; public const BACK_OFFICE = 'ecrire';
public const TMP = 'tmp'; public const TMP = 'tmp';
public const ETC = 'config'; public const ETC = 'config';
public const VAR = 'local'; public const VAR = 'local';
public const DOC = 'IMG'; public const DOC = 'IMG';
public const LOCAL_COMPOSER = 'composer.local.json'; public const LOCAL_COMPOSER = 'composer.local.json';
public const LOCAL_PLUGINS_DIST = 'plugins-dist.json'; public const LOCAL_PLUGINS_DIST = 'plugins-dist.json';
public const DIR_CACHE = '%spip.dirs.tmp%/cache'; public const DIR_CACHE = '%spip.dirs.tmp%/cache';
public const DIR_LOG = '%spip.dirs.tmp%/log'; public const DIR_LOG = '%spip.dirs.tmp%/log';
public const DIR_ASSETS_CSS = '%spip.dirs.var%/cache-css'; public const DIR_ASSETS_CSS = '%spip.dirs.var%/cache-css';
public const DIR_ASSETS_JS = '%spip.dirs.var%/cache-js'; public const DIR_ASSETS_JS = '%spip.dirs.var%/cache-js';
public const WHEELS_CACHE = '%spip.dirs.cache%/wheels'; public const WHEELS_CACHE = '%spip.dirs.cache%/wheels';
......
...@@ -17,18 +17,18 @@ use SpipLeague\Composer\Switch\Operation\RemoveSpecification; ...@@ -17,18 +17,18 @@ use SpipLeague\Composer\Switch\Operation\RemoveSpecification;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class Analyzer class Analyzer
{ {
private Filesystem $filesystem; private Filesystem $filesystem;
private CollectionInterface $distribution; private CollectionInterface $distribution;
private Composer $composer; private Composer $composer;
public function __construct( public function __construct(
CollectionInterface $distribution, CollectionInterface $distribution,
Composer $composer Composer $composer,
) { ) {
$this->distribution = $distribution; $this->distribution = $distribution;
$this->composer = $composer; $this->composer = $composer;
...@@ -42,7 +42,8 @@ class Analyzer ...@@ -42,7 +42,8 @@ class Analyzer
{ {
$extensions = []; $extensions = [];
/** @var array{spip?:array{extensions?:mixed}} $extra */ /** @var array{spip?:array{extensions?:mixed}} $extra */
$extra = $this->composer->getPackage()->getExtra(); $extra = $this->composer->getPackage()
->getExtra();
if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) { if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) {
$extensions = $extra['spip']['extensions']; $extensions = $extra['spip']['extensions'];
} }
...@@ -75,7 +76,8 @@ class Analyzer ...@@ -75,7 +76,8 @@ class Analyzer
public function back(): \Generator public function back(): \Generator
{ {
$extensions = $this->getExtensions(); $extensions = $this->getExtensions();
$requires = $this->composer->getPackage()->getRequires(); $requires = $this->composer->getPackage()
->getRequires();
$vendorNames = \array_keys($requires); $vendorNames = \array_keys($requires);
$vendorDirs = []; $vendorDirs = [];
......
...@@ -8,6 +8,7 @@ use SpipLeague\Composer\Extensions\CollectionInterface; ...@@ -8,6 +8,7 @@ use SpipLeague\Composer\Extensions\CollectionInterface;
class AddToRequire implements OperationInterface class AddToRequire implements OperationInterface
{ {
private string $vendorName; private string $vendorName;
private string $constraint; private string $constraint;
public function __construct(string $vendorName, string $constraint) public function __construct(string $vendorName, string $constraint)
...@@ -33,8 +34,6 @@ class AddToRequire implements OperationInterface ...@@ -33,8 +34,6 @@ class AddToRequire implements OperationInterface
} }
/** /**
* {@inheritDoc}
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function mark(CollectionInterface $distribution, Composer $composer): ?self public function mark(CollectionInterface $distribution, Composer $composer): ?self
...@@ -44,7 +43,9 @@ class AddToRequire implements OperationInterface ...@@ -44,7 +43,9 @@ class AddToRequire implements OperationInterface
public function do(CollectionInterface $distribution, Composer $composer): string public function do(CollectionInterface $distribution, Composer $composer): string
{ {
$composer->getConfig()->getConfigSource()->addLink('require', $this->vendorName, $this->constraint); $composer->getConfig()
->getConfigSource()
->addLink('require', $this->vendorName, $this->constraint);
return 'require ' . $this->vendorName . ':' . $this->constraint . ' added.'; return 'require ' . $this->vendorName . ':' . $this->constraint . ' added.';
} }
......
...@@ -34,7 +34,8 @@ class AddToSpipExtraExtensions implements OperationInterface ...@@ -34,7 +34,8 @@ class AddToSpipExtraExtensions implements OperationInterface
{ {
$extensions = []; $extensions = [];
/** @var array{spip?:array{extensions?:mixed}} $extra */ /** @var array{spip?:array{extensions?:mixed}} $extra */
$extra = $composer->getPackage()->getExtra(); $extra = $composer->getPackage()
->getExtra();
if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) { if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) {
$extensions = $extra['spip']['extensions']; $extensions = $extra['spip']['extensions'];
} }
...@@ -46,7 +47,8 @@ class AddToSpipExtraExtensions implements OperationInterface ...@@ -46,7 +47,8 @@ class AddToSpipExtraExtensions implements OperationInterface
{ {
$extensions = []; $extensions = [];
/** @var array{spip?:array{extensions?:mixed}} $extra */ /** @var array{spip?:array{extensions?:mixed}} $extra */
$extra = $composer->getPackage()->getExtra(); $extra = $composer->getPackage()
->getExtra();
if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) { if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) {
$extensions = $extra['spip']['extensions']; $extensions = $extra['spip']['extensions'];
} }
...@@ -55,7 +57,9 @@ class AddToSpipExtraExtensions implements OperationInterface ...@@ -55,7 +57,9 @@ class AddToSpipExtraExtensions implements OperationInterface
} }
$extensions[] = $this->vendorName; $extensions[] = $this->vendorName;
$composer->getConfig()->getConfigSource()->addProperty('extra.spip.extensions', $extensions); $composer->getConfig()
->getConfigSource()
->addProperty('extra.spip.extensions', $extensions);
return 'extensions ' . $this->vendorName . ' added'; return 'extensions ' . $this->vendorName . ' added';
} }
......
...@@ -7,8 +7,6 @@ use SpipLeague\Composer\Extensions\CollectionInterface; ...@@ -7,8 +7,6 @@ use SpipLeague\Composer\Extensions\CollectionInterface;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <jamees@rezo.net>
*/ */
interface OperationInterface interface OperationInterface
{ {
......
...@@ -8,13 +8,13 @@ use SpipLeague\Composer\Extensions\CollectionInterface; ...@@ -8,13 +8,13 @@ use SpipLeague\Composer\Extensions\CollectionInterface;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class RemoveDirectory implements OperationInterface class RemoveDirectory implements OperationInterface
{ {
private Filesystem $filesystem; private Filesystem $filesystem;
private string $directory; private string $directory;
private bool $ifEmpty; private bool $ifEmpty;
public function __construct(Filesystem $filesystem, string $directory, bool $ifEmpty = false) public function __construct(Filesystem $filesystem, string $directory, bool $ifEmpty = false)
......
...@@ -7,8 +7,6 @@ use SpipLeague\Composer\Extensions\CollectionInterface; ...@@ -7,8 +7,6 @@ use SpipLeague\Composer\Extensions\CollectionInterface;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class RemoveFromRequire implements OperationInterface class RemoveFromRequire implements OperationInterface
{ {
...@@ -42,7 +40,9 @@ class RemoveFromRequire implements OperationInterface ...@@ -42,7 +40,9 @@ class RemoveFromRequire implements OperationInterface
public function do(CollectionInterface $distribution, Composer $composer): string public function do(CollectionInterface $distribution, Composer $composer): string
{ {
$composer->getConfig()->getConfigSource()->removeLink('require', $this->vendorName); $composer->getConfig()
->getConfigSource()
->removeLink('require', $this->vendorName);
return 'require ' . $this->vendorName . ' removed'; return 'require ' . $this->vendorName . ' removed';
} }
......
...@@ -7,8 +7,6 @@ use SpipLeague\Composer\Extensions\CollectionInterface; ...@@ -7,8 +7,6 @@ use SpipLeague\Composer\Extensions\CollectionInterface;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class RemoveFromSpipExtraExtensions implements OperationInterface class RemoveFromSpipExtraExtensions implements OperationInterface
{ {
...@@ -39,7 +37,8 @@ class RemoveFromSpipExtraExtensions implements OperationInterface ...@@ -39,7 +37,8 @@ class RemoveFromSpipExtraExtensions implements OperationInterface
{ {
$extensions = []; $extensions = [];
/** @var array{spip?:array{extensions?:mixed}} $extra */ /** @var array{spip?:array{extensions?:mixed}} $extra */
$extra = $composer->getPackage()->getExtra(); $extra = $composer->getPackage()
->getExtra();
if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) { if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) {
$extensions = $extra['spip']['extensions']; $extensions = $extra['spip']['extensions'];
} }
...@@ -51,7 +50,8 @@ class RemoveFromSpipExtraExtensions implements OperationInterface ...@@ -51,7 +50,8 @@ class RemoveFromSpipExtraExtensions implements OperationInterface
{ {
$extensions = []; $extensions = [];
/** @var array{spip?:array{extensions?:mixed}} $extra */ /** @var array{spip?:array{extensions?:mixed}} $extra */
$extra = $composer->getPackage()->getExtra(); $extra = $composer->getPackage()
->getExtra();
if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) { if (isset($extra['spip']['extensions']) && \is_array($extra['spip']['extensions'])) {
$extensions = $extra['spip']['extensions']; $extensions = $extra['spip']['extensions'];
} }
...@@ -59,7 +59,9 @@ class RemoveFromSpipExtraExtensions implements OperationInterface ...@@ -59,7 +59,9 @@ class RemoveFromSpipExtraExtensions implements OperationInterface
return 'nothing to do'; return 'nothing to do';
} }
$composer->getConfig()->getConfigSource()->addProperty('extra.spip.extensions', \array_diff($extensions, [$this->vendorName])); $composer->getConfig()
->getConfigSource()
->addProperty('extra.spip.extensions', \array_diff($extensions, [$this->vendorName]));
return 'extensions ' . $this->vendorName . ' removed'; return 'extensions ' . $this->vendorName . ' removed';
} }
......
...@@ -22,7 +22,6 @@ class RemoveSpecification implements OperationInterface ...@@ -22,7 +22,6 @@ class RemoveSpecification implements OperationInterface
return 'RemoveSpecification ' . $this->prefix; return 'RemoveSpecification ' . $this->prefix;
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
......
...@@ -8,15 +8,16 @@ use SpipLeague\Composer\Switch\Operation\OperationInterface; ...@@ -8,15 +8,16 @@ use SpipLeague\Composer\Switch\Operation\OperationInterface;
/** /**
* @since 0.7.0 * @since 0.7.0
*
* @author JamesRezo <james@rezo.net>
*/ */
class Switcher class Switcher
{ {
private CollectionInterface $distribution; private CollectionInterface $distribution;
private Composer $composer; private Composer $composer;
/** @var array<string,OperationInterface[]> */ /**
* @var array<string,OperationInterface[]>
*/
private array $operations = [ private array $operations = [
'distribution' => [], 'distribution' => [],
'extensions' => [], 'extensions' => [],
...@@ -33,7 +34,7 @@ class Switcher ...@@ -33,7 +34,7 @@ class Switcher
public function to(OperationInterface $operation): void public function to(OperationInterface $operation): void
{ {
$operation = $operation->mark($this->distribution, $this->composer); $operation = $operation->mark($this->distribution, $this->composer);
if (!\is_null($operation)) { if ($operation !== null) {
$this->operations[$operation->getType()][] = $operation; $this->operations[$operation->getType()][] = $operation;
} }
} }
......
...@@ -10,16 +10,22 @@ class WheelsClearCache ...@@ -10,16 +10,22 @@ class WheelsClearCache
{ {
public static function clearCache(Event $event): void public static function clearCache(Event $event): void
{ {
$event->getIO()->write('Clearing the Textwheel cache ...'); $event->getIO()
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir') . '/'; ->write('Clearing the Textwheel cache ...');
$vendorDir = $event->getComposer()
->getConfig()
->get('vendor-dir') . '/';
$fs = new Filesystem($event->getComposer()->getLoop()->getProcessExecutor()); $fs = new Filesystem($event->getComposer()->getLoop()->getProcessExecutor());
$sffs = new SymfonyFilesystem; $sffs = new SymfonyFilesystem();
$fs->emptyDirectory( $fs->emptyDirectory($vendorDir . '../' . SpipPaths::interpolate(SpipPaths::WHEELS_CACHE));
$vendorDir . '../' . SpipPaths::interpolate(SpipPaths::WHEELS_CACHE) $sffs->chmod(
$vendorDir . '../' . SpipPaths::interpolate(SpipPaths::WHEELS_CACHE),
SpipPaths::CHMOD,
SpipPaths::UMASK,
); );
$sffs->chmod($vendorDir . '../' .SpipPaths::interpolate(SpipPaths::WHEELS_CACHE), SpipPaths::CHMOD, SpipPaths::UMASK);
$event->getIO()->write('Done.'); $event->getIO()
->write('Done.');
} }
} }