clean install

This commit is contained in:
2024-12-10 15:08:16 +01:00
commit e14eb2d8fd
31193 changed files with 3555714 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
# PHP PSR-2 Coding Standards
# http://www.php-fig.org/psr/psr-2/
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
[*.{xml,yml}]
indent_size = 2

View File

@@ -0,0 +1,18 @@
name: composer-installers-extender
services:
php:
type: php:7.1
via: cli
xdebug: true
tooling:
composer:
service: php
description: Run composer commands
cmd:
- composer
- --ansi
php:
service: php

View File

@@ -0,0 +1,20 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- nightly
matrix:
allow_failures:
- php: 5.6
- php: 7.0
fast_finish: true
install: composer install
script:
- composer lint
- composer test

View File

@@ -0,0 +1,59 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog][] and this project adheres to the
[Semantic Versioning][] scheme.
[Keep a Changelog]: http://keepachangelog.com
[Semantic Versioning]: https://semver.org
## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
## [2.0.1] - 2021-12-15
### Changed
- Add support for composer/installers 2.x
## [2.0.0] - 2020-08-11
### Added
- Add `.editorconfig`, `.gitignore`, `.lando.yml`, `phpcs.xml` and `phpunit.xml`
files to support local development
- Add `LICENSE` and `CHANGELOG.md` files
- Add `phpunit/phpunit` and `squizlabs/php_codesniffer` as development
dependencies
- Add requirement for PHP 7.1
- Add support for Composer 2
### Changed
- Move `OomphInc\ComposerInstallersExtender\Installer` to
`OomphInc\ComposerInstallersExtender\Installers\Installer`
- Move `OomphInc\ComposerInstallersExtender\InstallerHelper` to
`OomphInc\ComposerInstallersExtender\Installers\CustomInstaller`
- Implement PSR-2 standards and PHP 7.1 syntax
- Update project `README.md` file
## [1.1.2] - 2017-03-31
### Changed
- Minor syntax update to provide compatibility with PHP 5.3
## [1.1.1] - 2016-07-05
### Changed
- Update composer/installers version requirement
## [1.1.0] - 2016-03-02
### Changed
- Update package requirements to be less restrictive
## [1.0.0] - 2016-01-07
### Added
- Initial release

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Oomph, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,99 @@
# Composer Installers Extender
The `composer-installers-extender` is a plugin for [Composer][] that allows
any package to be installed to a directory other than the default `vendor`
directory within a project on a package-by-package basis. This plugin extends
the [`composer/installers`][] plugin to allow any arbitrary package type to be
handled by their custom installer.
The [`composer/installers`][] plugin has a finite set of supported package types
and we recognize the need for any arbitrary package type to be installed to a
specific directory other than `vendor`. This plugin allows additional package
types to be handled by the [`composer/installers`][] plugin, benefiting from
their explicit install path mapping and token replacement of package properties.
## How to Install
Add `oomphinc/composer-installers-extender` as a dependency of your project:
```bash
$ composer require oomphinc/composer-installers-extender
```
This plugin requires at least PHP 7.1. If you're using a lower version of PHP
use the latest stable 1.x release:
```bash
$ composer require oomphinc/composer-installers-extender:^1.1
```
## How to Use
The [`composer/installers`][] plugin is a dependency of this plugin and will be
automatically required as well if not already required.
To support additional package types, add an array of these types in the
`extra` property in your `composer.json`:
with [`composer/installers`][] < v1.0.13:
```json
{
"extra": {
"installer-types": ["library"]
}
}
```
with [`composer/installers`][] >= v1.0.13:
```json
{
"extra": {
"installer-types": ["drupal-library"]
}
}
```
Then refer to that type when adding to `installer-paths`:
with [`composer/installers`][] < v1.0.13:
```json
{
"extra": {
"installer-types": ["library"],
"installer-paths": {
"special/package/": ["my/package"],
"path/to/libraries/{$name}/": ["type:library"]
}
}
}
```
with [`composer/installers`][] >= v1.0.13:
```json
{
"extra": {
"installer-types": ["drupal-library"],
"installer-paths": {
"special/package/": ["my/package"],
"path/to/libraries/{$name}/": ["type:drupal-library"]
}
}
}
```
By default, packages that do not specify a `type` will be considered the type
`library`. Adding support for this type allows any of these packages to be
placed in a different install path.
If a type has been added to `installer-types`, the plugin will attempt to find
an explicit installer path in the mapping. If there is no match either by name
or by type, the default installer path for all packages will be used instead.
**Please see the README for [`composer/installers`][] to see the supported syntax
for package and type matching as well as the supported replacement tokens in
the path (e.g. `{$name}`).**
## License
[MIT License][]
[Composer]: https://getcomposer.org
[`composer/installers`]: https://github.com/composer/installers
[MIT License]: LICENSE

View File

@@ -0,0 +1,55 @@
{
"name": "oomphinc/composer-installers-extender",
"description": "Extend the composer/installers plugin to accept any arbitrary package type.",
"homepage": "http://www.oomphinc.com/",
"type": "composer-plugin",
"license": "MIT",
"authors": [
{
"name": "Stephen Beemsterboer",
"email": "stephen@oomphinc.com",
"homepage": "https://github.com/balbuf"
},
{
"name": "Nathan Dentzau",
"email": "nate@oomphinc.com",
"homepage": "http://oomph.is/ndentzau"
}
],
"support": {
"issues": "https://github.com/oomphinc/composer-installers-extender/issues"
},
"require": {
"php": ">=7.1",
"composer-plugin-api": "^1.1 || ^2.0",
"composer/installers": "^1.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^2.0",
"phpunit/phpunit": "^7.2",
"squizlabs/php_codesniffer": "^3.3"
},
"autoload":{
"psr-4": {
"OomphInc\\ComposerInstallersExtender\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"OomphInc\\ComposerInstallerExtender\\Tests\\": "tests/src/"
}
},
"scripts": {
"fix": "vendor/bin/phpcbf",
"lint": "vendor/bin/phpcs",
"test": "vendor/bin/phpunit"
},
"config": {
"sort-packages": true
},
"extra": {
"class": "OomphInc\\ComposerInstallersExtender\\Plugin"
},
"minimum-stability": "dev",
"prefer-stable": true
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<ruleset name="Composer Installers Extender">
<description>
Coding standards for the Composer Installers Extender project using PSR-2
with PHP 7 syntax.
</description>
<!-- Directories to scan -->
<file>src/</file>
<!-- PHPCS argument overrides -->
<arg name="colors" />
<!-- PHP configuration overrides -->
<ini name="memory_limit" value="-1" />
<!-- Project autoloader -->
<autoload>vendor/autoload.php</autoload>
<!-- Import rules -->
<rule ref="PSR2" />
</ruleset>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
bootstrap="vendor/autoload.php">
<php>
<ini name="error_reporting" value="32767" />
<ini name="memory_limit" value="-1" />
</php>
<testsuites>
<testsuite name="unit">
<directory>./tests/src</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="tests/results/html"/>
<log type="coverage-clover" target="tests/results/coverage.xml"/>
<log type="coverage-text" target="tests/results/coverage.txt"/>
</logging>
</phpunit>

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types = 1);
namespace OomphInc\ComposerInstallersExtender\Installers;
use Composer\Installers\BaseInstaller;
/**
* Provides a custom installer class for custom installer types.
*
* By default, the parent class has no specified locations. By not providing an
* array of locations we are forcing the installer to use custom installer
* paths.
*/
class CustomInstaller extends BaseInstaller
{
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types = 1);
namespace OomphInc\ComposerInstallersExtender\Installers;
use Composer\Package\PackageInterface;
use Composer\Installer\LibraryInstaller;
use Composer\Installers\Installer as InstallerBase;
class Installer extends InstallerBase
{
/**
* A list of installer types.
*
* @var array
*/
protected $installerTypes;
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package): string
{
$installer = new CustomInstaller($package, $this->composer, $this->io);
$path = $installer->getInstallPath($package, $package->getType());
return $path ?: LibraryInstaller::getInstallPath($package);
}
/**
* {@inheritDoc}
*/
public function supports($packageType): bool
{
return in_array($packageType, $this->getInstallerTypes());
}
/**
* Get a list of custom installer types.
*
* @return array
*/
public function getInstallerTypes(): array
{
if (!$this->installerTypes) {
$extra = $this->composer->getPackage()->getExtra();
$this->installerTypes = $extra['installer-types'] ?? [];
}
return $this->installerTypes;
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types = 1);
namespace OomphInc\ComposerInstallersExtender;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use OomphInc\ComposerInstallersExtender\Installers\Installer;
class Plugin implements PluginInterface
{
/**
* {@inheritDoc}
*/
public function activate(Composer $composer, IOInterface $io): void
{
$installer = new Installer($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
}
/**
* {@inheritDoc}
*/
public function deactivate(Composer $composer, IOInterface $io): void
{
}
/**
* {@inheritDoc}
*/
public function uninstall(Composer $composer, IOInterface $io): void
{
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types = 1);
namespace OomphInc\ComposerInstallersExtender\Tests\Installers;
use PHPUnit\Framework\TestCase;
use OomphInc\ComposerInstallersExtender\Installers\CustomInstaller;
class CustomInstallerTest extends TestCase
{
public function testLocations(): void
{
$installer = (new \ReflectionClass(CustomInstaller::class))
->newInstanceWithoutConstructor();
$this->assertEmpty($installer->getLocations());
}
}

View File

@@ -0,0 +1,117 @@
<?php
declare(strict_types = 1);
namespace OomphInc\ComposerInstallersExtender\Installers;
use Composer\Composer;
use Composer\IO\IOInterface;
use PHPUnit\Framework\TestCase;
use Composer\Package\Package;
class InstallerTest extends TestCase
{
protected $composer;
protected $io;
public function setUp(): void
{
parent::setUp();
$this->composer = $this->createMock(Composer::class);
$this->composer
->method('getConfig')
->willReturn(new class {
public function get($name) {
return null;
}
});
$this->io = $this->createMock(IOInterface::class);
}
public function testGetInstallPath(): void
{
$this->composer
->method('getPackage')
->willReturn(new class {
public function getExtra()
{
return [
'installer-types' => ['custom-type'],
'installer-paths' => [
'custom/path/{$name}' => ['type:custom-type'],
],
];
}
});
$installer = new Installer($this->io, $this->composer);
$package = new Package('oomphinc/test', '1.0.0', '1.0.0');
$package->setType('custom-type');
$this->assertEquals(
'custom/path/test',
$installer->getInstallPath($package)
);
}
public function testSupports(): void
{
$installer = new class extends Installer {
public function __construct() {}
public function getInstallerTypes(): array
{
return ['custom-type'];
}
};
$this->assertTrue($installer->supports('custom-type'));
$this->assertFalse($installer->supports('oomph'));
}
/**
* @dataProvider installerTypesDataProvider
*/
public function testGetInstallerTypes($package, array $expected): void
{
$this->composer
->method('getPackage')
->willReturn($package);
$installer = new Installer($this->io, $this->composer);
$this->assertEquals($expected, $installer->getInstallerTypes());
}
public function installerTypesDataProvider(): array
{
return [
[
new class {
public function getExtra(): array
{
return [
'installer-types' => ['custom-type'],
'installer-paths' => [
'custom/path/{$name}' => ['type:custom-type'],
],
];
}
},
['custom-type'],
],
[
new class {
public function getExtra(): array
{
return [];
}
},
[],
],
];
}
}

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types = 1);
namespace OomphInc\ComposerInstallersExtender\Tests;
use Composer\Composer;
use Composer\IO\IOInterface;
use PHPUnit\Framework\TestCase;
use Composer\Installer\InstallationManager;
use OomphInc\ComposerInstallersExtender\Installers\Installer;
use OomphInc\ComposerInstallersExtender\Plugin;
class PluginTest extends TestCase
{
protected $composer;
protected $io;
public function setUp(): void
{
parent::setUp();
$this->composer = $this->createMock(Composer::class);
$this->composer
->method('getConfig')
->willReturn(new class{
public function get($name)
{
return null;
}
});
$this->io = $this->createMock(IOInterface::class);
}
public function testActive(): void
{
$installationManager = $this->createMock(InstallationManager::class);
$installationManager
->expects($this->once())
->method('addInstaller')
->with(new Installer($this->io, $this->composer));
$this->composer
->expects($this->once())
->method('getInstallationManager')
->willReturn($installationManager);
// There is no output to test from the activate method. Only test for
// method call expectations.
$plugin = new Plugin();
$plugin->activate($this->composer, $this->io);
}
}