Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -1,10 +0,0 @@
; top-most EditorConfig file
root = true
; Unix-style newlines
[*]
end_of_line = LF
[*.php]
indent_style = space
indent_size = 4

View file

@ -1,3 +0,0 @@
vendor/
composer.lock
.idea/

View file

@ -1,14 +0,0 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
before_script:
- curl -s http://getcomposer.org/installer | php -- --quiet
- php composer.phar install --dev
script: phpunit

View file

@ -1,19 +0,0 @@
Copyright (c) 2012 Kyle Robinson Young
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

@ -1,191 +0,0 @@
# A Multi-Framework [Composer](http://getcomposer.org) Library Installer
[![Build Status](http://img.shields.io/travis/composer/installers.svg)](http://travis-ci.org/composer/installers)
This is for PHP package authors to require in their `composer.json`. It will
install their package to the correct location based on the specified package
type.
The goal of `installers` is to be a simple package type to install path map.
Users can also customize the install path per package and package authors can
modify the package name upon installing.
`installers` isn't intended on replacing all custom installers. If your
package requires special installation handling then by all means, create a
custom installer to handle it.
**Natively Supported Frameworks**:
The following frameworks natively work with Composer and will be
installed to the default `vendor` directory. `composer/installers`
is not needed to install packages with these frameworks:
* Aura
* Symfony2
* Yii
* Yii2
**Current Supported Package Types**:
> Stable types are marked as **bold**, this means that installation paths
> for those type will not be changed. Any adjustment for those types would
> require creation of brand new type that will cover required changes.
| Framework | Types
| --------- | -----
| Aimeos | `aimeos-extension`
| Asgard | `asgard-module`<br>`asgard-theme`
| AGL | `agl-module`
| AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
| Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
| CakePHP 2+ | **`cakephp-plugin`**
| Chef | `chef-cookbook`<br>`chef-role`
| CCFramework | `ccframework-ship`<br>`ccframework-theme`
| CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
| concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
| Craft | `craft-plugin`
| Croogo | `croogo-plugin`<br>`croogo-theme`
| DokuWiki | `dokuwiki-plugin`<br>`dokuwiki-template`
| Dolibarr | `dolibarr-module`
| Drupal | <b>`drupal-module`<br>`drupal-theme`</b><br>`drupal-library`<br>`drupal-profile`<br>`drupal-drush`
| Elgg | `elgg-plugin`
| FuelPHP v1.x | `fuel-module`<br>`fuel-package`<br/>`fuel-theme`
| FuelPHP v2.x | `fuelphp-component`
| Grav | `grav-plugin`<br>`grav-theme`
| Hurad | `hurad-plugin`<br>`hurad-theme`
| Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
| Kirby | **`kirby-plugin`**
| Kohana | **`kohana-module`**
| Laravel | `laravel-library`
| Lithium | **`lithium-library`<br>`lithium-source`**
| Magento | `magento-library`<br>`magento-skin`<br>`magento-theme`
| Mako | `mako-package`
| MODX Evo | `modxevo-snippet`<br>`modxevo-plugin`<br>`modxevo-module`<br>`modxevo-template`<br>`modxevo-lib`
| MediaWiki | `mediawiki-extension`
| October | **`october-module`<br>`october-plugin`<br>`october-theme`**
| OXID | `oxid-module`<br>`oxid-theme`<br>`oxid-out`
| MODULEWork | `modulework-module`
| Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types)
| Piwik | `piwik-plugin`
| phpBB | `phpbb-extension`<br>`phpbb-style`<br>`phpbb-language`
| Pimcore | `pimcore-plugin`
| PPI | **`ppi-module`**
| Puppet | `puppet-module`
| REDAXO | `redaxo-addon`
| Roundcube | `roundcube-plugin`
| shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
| SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
| SMF | `smf-module`<br>`smf-theme`
| symfony1 | **`symfony1-plugin`**
| Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
| TYPO3 Flow | `typo3-flow-package`<br>`typo3-flow-framework`<br>`typo3-flow-plugin`<br>`typo3-flow-site`<br>`typo3-flow-boilerplate`<br>`typo3-flow-build`
| TYPO3 CMS | `typo3-cms-extension`
| Wolf CMS | `wolfcms-plugin`
| WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
| Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
| Zikula | `zikula-module`<br>`zikula-theme`
| Prestashop | `prestashop-module`<br>`prestashop-theme`
## Example `composer.json` File
This is an example for a CakePHP plugin. The only important parts to set in your
composer.json file are `"type": "cakephp-plugin"` which describes what your
package is and `"require": { "composer/installers": "~1.0" }` which tells composer
to load the custom installers.
```json
{
"name": "you/ftp",
"type": "cakephp-plugin",
"require": {
"composer/installers": "~1.0"
}
}
```
This would install your package to the `Plugin/Ftp/` folder of a CakePHP app
when a user runs `php composer.phar install`.
So submit your packages to [packagist.org](http://packagist.org)!
## Custom Install Paths
If you are consuming a package that uses the `composer/installers` you can
override the install path with the following extra in your `composer.json`:
```json
{
"extra": {
"installer-paths": {
"your/custom/path/{$name}/": ["shama/ftp", "vendor/package"]
}
}
}
```
A package type can have a custom installation path with a `type:` prefix.
``` json
{
"extra": {
"installer-paths": {
"your/custom/path/{$name}/": ["type:wordpress-plugin"]
}
}
}
```
This would use your custom path for each of the listed packages. The available
variables to use in your paths are: `{$name}`, `{$vendor}`, `{$type}`.
## Custom Install Names
If you're a package author and need your package to be named differently when
installed consider using the `installer-name` extra.
For example you have a package named `shama/cakephp-ftp` with the type
`cakephp-plugin`. Installing with `composer/installers` would install to the
path `Plugin/CakephpFtp`. Due to the strict naming conventions, you as a
package author actually need the package to be named and installed to
`Plugin/Ftp`. Using the following config within your **package** `composer.json`
will allow this:
```json
{
"name": "shama/cakephp-ftp",
"type": "cakephp-plugin",
"extra": {
"installer-name": "Ftp"
}
}
```
Please note the name entered into `installer-name` will be the final and will
not be inflected.
## Contribute!
* [Fork and clone](https://help.github.com/articles/fork-a-repo).
* Run the command `php composer.phar install --dev` to install the dev
dependencies. See [Composer](https://github.com/composer/composer#installation--usage).
* Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de).
* Create a branch, commit, push and send us a
[pull request](https://help.github.com/articles/using-pull-requests).
To ensure a consistent code base, you should make sure the code follows the
[Coding Standards](http://symfony.com/doc/2.0/contributing/code/standards.html)
which we borrowed from Symfony.
If you would like to help, please take a look at the list of
[issues](https://github.com/composer/installers/issues).
### Should we allow dynamic package types or paths? No.
What are they? The ability for a package author to determine where a package
will be installed either through setting the path directly in their
`composer.json` or through a dynamic package type: `"type":
"framework-install-here"`.
It has been proposed many times. Even implemented once early on and then
removed. `installers` won't do this because it would allow a single package
author to wipe out entire folders without the user's consent. That user would
then come here to yell at us.

View file

@ -1,77 +0,0 @@
{
"name": "composer/installers",
"type": "composer-installer",
"license": "MIT",
"description": "A multi-framework Composer library installer",
"keywords": [
"installer",
"Aimeos",
"AGL",
"AnnotateCms",
"Bitrix",
"CakePHP",
"Chef",
"CodeIgniter",
"concrete5",
"Craft",
"Croogo",
"DokuWiki",
"Dolibarr",
"Drupal",
"Elgg",
"FuelPHP",
"Grav",
"Hurad",
"Joomla",
"Kohana",
"Laravel",
"Lithium",
"Magento",
"Mako",
"MODX Evo",
"MediaWiki",
"OXID",
"MODULEWork",
"Moodle",
"Piwik",
"phpBB",
"PPI",
"Puppet",
"Roundcube",
"shopware",
"SilverStripe",
"SMF",
"symfony",
"Thelia",
"TYPO3",
"WolfCMS",
"WordPress",
"Zend",
"Zikula"
],
"homepage": "http://composer.github.com/installers/",
"authors": [
{
"name": "Kyle Robinson Young",
"email": "kyle@dontkry.com",
"homepage": "https://github.com/shama"
}
],
"autoload": {
"psr-0": { "Composer\\Installers\\": "src/" }
},
"extra": {
"class": "Composer\\Installers\\Installer",
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"replace": {
"shama/baton": "*",
"roundcube/plugin-installer": "*"
},
"require-dev": {
"composer/composer": "1.0.*@dev",
"phpunit/phpunit": "4.1.*"
}
}

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="Installers Test Suite">
<directory>tests/Composer/Installers</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/Composer/Installers</directory>
</whitelist>
</filter>
</phpunit>

View file

@ -1,21 +0,0 @@
<?php
namespace Composer\Installers;
class AglInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'More/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
{
$vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) {
return strtoupper($matches[1]);
}, $vars['name']);
return $vars;
}
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class AimeosInstaller extends BaseInstaller
{
protected $locations = array(
'extension' => 'ext/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class AnnotateCmsInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'addons/modules/{$name}/',
'component' => 'addons/components/{$name}/',
'service' => 'addons/services/{$name}/',
);
}

View file

@ -1,45 +0,0 @@
<?php
namespace Composer\Installers;
class AsgardInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'Modules/{$name}/',
'theme' => 'Themes/{$name}/'
);
/**
* Format package name.
*
* For package type asgard-module, cut off a trailing '-plugin' if present.
*
* For package type asgard-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'asgard-module') {
return $this->inflectPluginVars($vars);
}
if ($vars['type'] === 'asgard-theme') {
return $this->inflectThemeVars($vars);
}
return $vars;
}
protected function inflectPluginVars($vars)
{
$vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name']));
return $vars;
}
protected function inflectThemeVars($vars)
{
$vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name']));
return $vars;
}
}

View file

@ -1,131 +0,0 @@
<?php
namespace Composer\Installers;
use Composer\Composer;
use Composer\Package\PackageInterface;
abstract class BaseInstaller
{
protected $locations = array();
protected $composer;
protected $package;
/**
* Initializes base installer.
*
* @param PackageInterface $package
* @param Composer $composer
*/
public function __construct(PackageInterface $package = null, Composer $composer = null)
{
$this->composer = $composer;
$this->package = $package;
}
/**
* Return the install path based on package type.
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
{
$type = $this->package->getType();
$prettyName = $this->package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
} else {
$vendor = '';
$name = $prettyName;
}
$availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
$extra = $package->getExtra();
if (!empty($extra['installer-name'])) {
$availableVars['name'] = $extra['installer-name'];
}
if ($this->composer->getPackage()) {
$extra = $this->composer->getPackage()->getExtra();
if (!empty($extra['installer-paths'])) {
$customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
if ($customPath !== false) {
return $this->templatePath($customPath, $availableVars);
}
}
}
$packageType = substr($type, strlen($frameworkType) + 1);
$locations = $this->getLocations();
if (!isset($locations[$packageType])) {
throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
}
return $this->templatePath($locations[$packageType], $availableVars);
}
/**
* For an installer to override to modify the vars per installer.
*
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
{
return $vars;
}
/**
* Gets the installer's locations
*
* @return array
*/
public function getLocations()
{
return $this->locations;
}
/**
* Replace vars in a path
*
* @param string $path
* @param array $vars
* @return string
*/
protected function templatePath($path, array $vars = array())
{
if (strpos($path, '{') !== false) {
extract($vars);
preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches);
if (!empty($matches[1])) {
foreach ($matches[1] as $var) {
$path = str_replace('{$' . $var . '}', $$var, $path);
}
}
}
return $path;
}
/**
* Search through a passed paths array for a custom install path.
*
* @param array $paths
* @param string $name
* @param string $type
* @return string
*/
protected function mapCustomInstallPaths(array $paths, $name, $type)
{
foreach ($paths as $path => $names) {
if (in_array($name, $names) || in_array('type:' . $type, $names)) {
return $path;
}
}
return false;
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class BitrixInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'local/modules/{$name}/',
'component' => 'local/components/{$name}/',
'theme' => 'local/templates/{$name}/'
);
}

View file

@ -1,78 +0,0 @@
<?php
namespace Composer\Installers;
use Composer\DependencyResolver\Pool;
use Composer\Package\PackageInterface;
use Composer\Package\LinkConstraint\MultiConstraint;
use Composer\Package\LinkConstraint\VersionConstraint;
class CakePHPInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'Plugin/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
{
if ($this->matchesCakeVersion('>=', '3.0.0')) {
return $vars;
}
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array('-', '_'), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}
$vars['name'] = implode('/', $nameParts);
return $vars;
}
/**
* Change the default plugin location when cakephp >= 3.0
*/
public function getLocations()
{
if ($this->matchesCakeVersion('>=', '3.0.0')) {
$this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
}
return $this->locations;
}
/**
* Check if CakePHP version matches against a version
*
* @param string $matcher
* @param string $version
* @return bool
*/
protected function matchesCakeVersion($matcher, $version)
{
$repositoryManager = $this->composer->getRepositoryManager();
if ($repositoryManager) {
$repos = $repositoryManager->getLocalRepository();
if (!$repos) {
return false;
}
$cake3 = new MultiConstraint(array(
new VersionConstraint($matcher, $version),
new VersionConstraint('!=', '9999999-dev'),
));
$pool = new Pool('dev');
$pool->addRepository($repos);
$packages = $pool->whatProvides('cakephp/cakephp');
foreach ($packages as $package) {
$installed = new VersionConstraint('=', $package->getVersion());
if ($cake3->matches($installed)) {
return true;
break;
}
}
}
return false;
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class ChefInstaller extends BaseInstaller
{
protected $locations = array(
'cookbook' => 'Chef/{$vendor}/{$name}/',
'role' => 'Chef/roles/{$name}/',
);
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class ClanCatsFrameworkInstaller extends BaseInstaller
{
protected $locations = array(
'ship' => 'CCF/orbit/{$name}/',
'theme' => 'CCF/app/themes/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class CodeIgniterInstaller extends BaseInstaller
{
protected $locations = array(
'library' => 'application/libraries/{$name}/',
'third-party' => 'application/third_party/{$name}/',
'module' => 'application/modules/{$name}/',
);
}

View file

@ -1,12 +0,0 @@
<?php
namespace Composer\Installers;
class Concrete5Installer extends BaseInstaller
{
protected $locations = array(
'block' => 'blocks/{$name}/',
'package' => 'packages/{$name}/',
'theme' => 'themes/{$name}/',
'update' => 'updates/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class CraftInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'craft/plugins/{$name}/',
);
}

View file

@ -1,21 +0,0 @@
<?php
namespace Composer\Installers;
class CroogoInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'Plugin/{$name}/',
'theme' => 'View/Themed/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
{
$vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name']));
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}

View file

@ -1,50 +0,0 @@
<?php
namespace Composer\Installers;
class DokuWikiInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'lib/plugins/{$name}/',
'template' => 'lib/tpl/{$name}/',
);
/**
* Format package name.
*
* For package type dokuwiki-plugin, cut off a trailing '-plugin',
* or leading dokuwiki_ if present.
*
* For package type dokuwiki-template, cut off a trailing '-template' if present.
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'dokuwiki-plugin') {
return $this->inflectPluginVars($vars);
}
if ($vars['type'] === 'dokuwiki-template') {
return $this->inflectTemplateVars($vars);
}
return $vars;
}
protected function inflectPluginVars($vars)
{
$vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
return $vars;
}
protected function inflectTemplateVars($vars)
{
$vars['name'] = preg_replace('/-template$/', '', $vars['name']);
$vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']);
return $vars;
}
}

View file

@ -1,16 +0,0 @@
<?php
namespace Composer\Installers;
/**
* Class DolibarrInstaller
*
* @package Composer\Installers
* @author Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*/
class DolibarrInstaller extends BaseInstaller
{
//TODO: Add support for scripts and themes
protected $locations = array(
'module' => 'htdocs/custom/{$name}/',
);
}

View file

@ -1,14 +0,0 @@
<?php
namespace Composer\Installers;
class DrupalInstaller extends BaseInstaller
{
protected $locations = array(
'core' => 'core/',
'module' => 'modules/{$name}/',
'theme' => 'themes/{$name}/',
'library' => 'libraries/{$name}/',
'profile' => 'profiles/{$name}/',
'drush' => 'drush/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class ElggInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'mod/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class FuelInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'fuel/app/modules/{$name}/',
'package' => 'fuel/packages/{$name}/',
'theme' => 'fuel/app/themes/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class FuelphpInstaller extends BaseInstaller
{
protected $locations = array(
'component' => 'components/{$name}/',
);
}

View file

@ -1,30 +0,0 @@
<?php
namespace Composer\Installers;
class GravInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'user/plugins/{$name}/',
'theme' => 'user/themes/{$name}/',
);
/**
* Format package name
*
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
{
$restrictedWords = implode('|', array_keys($this->locations));
$vars['name'] = strtolower($vars['name']);
$vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
'$1',
$vars['name']
);
return $vars;
}
}

View file

@ -1,25 +0,0 @@
<?php
namespace Composer\Installers;
class HuradInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'plugins/{$name}/',
'theme' => 'plugins/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
{
$nameParts = explode('/', $vars['name']);
foreach ($nameParts as &$value) {
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
$value = str_replace(array('-', '_'), ' ', $value);
$value = str_replace(' ', '', ucwords($value));
}
$vars['name'] = implode('/', $nameParts);
return $vars;
}
}

View file

@ -1,163 +0,0 @@
<?php
namespace Composer\Installers;
use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
class Installer extends LibraryInstaller
{
/**
* Package types to installer class map
*
* @var array
*/
private $supportedTypes = array(
'aimeos' => 'AimeosInstaller',
'asgard' => 'AsgardInstaller',
'agl' => 'AglInstaller',
'annotatecms' => 'AnnotateCmsInstaller',
'bitrix' => 'BitrixInstaller',
'cakephp' => 'CakePHPInstaller',
'chef' => 'ChefInstaller',
'ccframework' => 'ClanCatsFrameworkInstaller',
'codeigniter' => 'CodeIgniterInstaller',
'concrete5' => 'Concrete5Installer',
'craft' => 'CraftInstaller',
'croogo' => 'CroogoInstaller',
'dokuwiki' => 'DokuWikiInstaller',
'dolibarr' => 'DolibarrInstaller',
'drupal' => 'DrupalInstaller',
'elgg' => 'ElggInstaller',
'fuel' => 'FuelInstaller',
'fuelphp' => 'FuelphpInstaller',
'grav' => 'GravInstaller',
'hurad' => 'HuradInstaller',
'joomla' => 'JoomlaInstaller',
'kirby' => 'KirbyInstaller',
'kohana' => 'KohanaInstaller',
'laravel' => 'LaravelInstaller',
'lithium' => 'LithiumInstaller',
'magento' => 'MagentoInstaller',
'mako' => 'MakoInstaller',
'mediawiki' => 'MediaWikiInstaller',
'microweber' => 'MicroweberInstaller',
'modulework' => 'MODULEWorkInstaller',
'modxevo' => 'MODXEvoInstaller',
'moodle' => 'MoodleInstaller',
'october' => 'OctoberInstaller',
'oxid' => 'OxidInstaller',
'phpbb' => 'PhpBBInstaller',
'pimcore' => 'PimcoreInstaller',
'piwik' => 'PiwikInstaller',
'ppi' => 'PPIInstaller',
'puppet' => 'PuppetInstaller',
'redaxo' => 'RedaxoInstaller',
'roundcube' => 'RoundcubeInstaller',
'shopware' => 'ShopwareInstaller',
'silverstripe' => 'SilverStripeInstaller',
'smf' => 'SMFInstaller',
'symfony1' => 'Symfony1Installer',
'thelia' => 'TheliaInstaller',
'tusk' => 'TuskInstaller',
'typo3-cms' => 'TYPO3CmsInstaller',
'typo3-flow' => 'TYPO3FlowInstaller',
'whmcs' => 'WHMCSInstaller',
'wolfcms' => 'WolfCMSInstaller',
'wordpress' => 'WordPressInstaller',
'zend' => 'ZendInstaller',
'zikula' => 'ZikulaInstaller',
'prestashop' => 'PrestashopInstaller',
);
/**
* {@inheritDoc}
*/
public function getInstallPath(PackageInterface $package)
{
$type = $package->getType();
$frameworkType = $this->findFrameworkType($type);
if ($frameworkType === false) {
throw new \InvalidArgumentException(
'Sorry the package type of this package is not yet supported.'
);
}
$class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
$installer = new $class($package, $this->composer);
return $installer->getInstallPath($package, $frameworkType);
}
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
throw new \InvalidArgumentException('Package is not installed: '.$package);
}
$repo->removePackage($package);
$installPath = $this->getInstallPath($package);
$this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
}
/**
* {@inheritDoc}
*/
public function supports($packageType)
{
$frameworkType = $this->findFrameworkType($packageType);
if ($frameworkType === false) {
return false;
}
$locationPattern = $this->getLocationPattern($frameworkType);
return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1;
}
/**
* Finds a supported framework type if it exists and returns it
*
* @param string $type
* @return string
*/
protected function findFrameworkType($type)
{
$frameworkType = false;
krsort($this->supportedTypes);
foreach ($this->supportedTypes as $key => $val) {
if ($key === substr($type, 0, strlen($key))) {
$frameworkType = substr($type, 0, strlen($key));
break;
}
}
return $frameworkType;
}
/**
* Get the second part of the regular expression to check for support of a
* package type
*
* @param string $frameworkType
* @return string
*/
protected function getLocationPattern($frameworkType)
{
$pattern = false;
if (!empty($this->supportedTypes[$frameworkType])) {
$frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType];
/** @var BaseInstaller $framework */
$framework = new $frameworkClass(null, $this->composer);
$locations = array_keys($framework->getLocations());
$pattern = $locations ? '(' . implode('|', $locations) . ')' : false;
}
return $pattern ? : '(\w+)';
}
}

View file

@ -1,15 +0,0 @@
<?php
namespace Composer\Installers;
class JoomlaInstaller extends BaseInstaller
{
protected $locations = array(
'component' => 'components/{$name}/',
'module' => 'modules/{$name}/',
'template' => 'templates/{$name}/',
'plugin' => 'plugins/{$name}/',
'library' => 'libraries/{$name}/',
);
// TODO: Add inflector for mod_ and com_ names
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class KirbyInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'site/plugins/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class KohanaInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class LaravelInstaller extends BaseInstaller
{
protected $locations = array(
'library' => 'libraries/{$name}/',
);
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class LithiumInstaller extends BaseInstaller
{
protected $locations = array(
'library' => 'libraries/{$name}/',
'source' => 'libraries/_source/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class MODULEWorkInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
);
}

View file

@ -1,16 +0,0 @@
<?php
namespace Composer\Installers;
/**
* An installer to handle MODX Evolution specifics when installing packages.
*/
class MODXEvoInstaller extends BaseInstaller
{
protected $locations = array(
'snippet' => 'assets/snippets/{$name}/',
'plugin' => 'assets/plugins/{$name}/',
'module' => 'assets/modules/{$name}/',
'template' => 'assets/templates/{$name}/',
'lib' => 'assets/lib/{$name}/'
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class MagentoInstaller extends BaseInstaller
{
protected $locations = array(
'theme' => 'app/design/frontend/{$name}/',
'skin' => 'skin/frontend/default/{$name}/',
'library' => 'lib/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class MakoInstaller extends BaseInstaller
{
protected $locations = array(
'package' => 'app/packages/{$name}/',
);
}

View file

@ -1,50 +0,0 @@
<?php
namespace Composer\Installers;
class MediaWikiInstaller extends BaseInstaller
{
protected $locations = array(
'extension' => 'extensions/{$name}/',
'skin' => 'skins/{$name}/',
);
/**
* Format package name.
*
* For package type mediawiki-extension, cut off a trailing '-extension' if present and transform
* to CamelCase keeping existing uppercase chars.
*
* For package type mediawiki-skin, cut off a trailing '-skin' if present.
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'mediawiki-extension') {
return $this->inflectExtensionVars($vars);
}
if ($vars['type'] === 'mediawiki-skin') {
return $this->inflectSkinVars($vars);
}
return $vars;
}
protected function inflectExtensionVars($vars)
{
$vars['name'] = preg_replace('/-extension$/', '', $vars['name']);
$vars['name'] = str_replace('-', ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
protected function inflectSkinVars($vars)
{
$vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
return $vars;
}
}

View file

@ -1,111 +0,0 @@
<?php
namespace Composer\Installers;
class MicroweberInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'userfiles/modules/{$name}/',
'module-skin' => 'userfiles/modules/{$name}/templates/',
'template' => 'userfiles/templates/{$name}/',
'element' => 'userfiles/elements/{$name}/',
'vendor' => 'vendor/{$name}/',
'components' => 'components/{$name}/'
);
/**
* Format package name.
*
* For package type microweber-module, cut off a trailing '-module' if present
*
* For package type microweber-template, cut off a trailing '-template' if present.
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'microweber-template') {
return $this->inflectTemplateVars($vars);
}
if ($vars['type'] === 'microweber-templates') {
return $this->inflectTemplatesVars($vars);
}
if ($vars['type'] === 'microweber-core') {
return $this->inflectCoreVars($vars);
}
if ($vars['type'] === 'microweber-adapter') {
return $this->inflectCoreVars($vars);
}
if ($vars['type'] === 'microweber-module') {
return $this->inflectModuleVars($vars);
}
if ($vars['type'] === 'microweber-modules') {
return $this->inflectModulesVars($vars);
}
if ($vars['type'] === 'microweber-skin') {
return $this->inflectSkinVars($vars);
}
if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') {
return $this->inflectElementVars($vars);
}
return $vars;
}
protected function inflectTemplateVars($vars)
{
$vars['name'] = preg_replace('/-template$/', '', $vars['name']);
$vars['name'] = preg_replace('/template-$/', '', $vars['name']);
return $vars;
}
protected function inflectTemplatesVars($vars)
{
$vars['name'] = preg_replace('/-templates$/', '', $vars['name']);
$vars['name'] = preg_replace('/templates-$/', '', $vars['name']);
return $vars;
}
protected function inflectCoreVars($vars)
{
$vars['name'] = preg_replace('/-providers$/', '', $vars['name']);
$vars['name'] = preg_replace('/-provider$/', '', $vars['name']);
$vars['name'] = preg_replace('/-adapter$/', '', $vars['name']);
return $vars;
}
protected function inflectModuleVars($vars)
{
$vars['name'] = preg_replace('/-module$/', '', $vars['name']);
$vars['name'] = preg_replace('/module-$/', '', $vars['name']);
return $vars;
}
protected function inflectModulesVars($vars)
{
$vars['name'] = preg_replace('/-modules$/', '', $vars['name']);
$vars['name'] = preg_replace('/modules-$/', '', $vars['name']);
return $vars;
}
protected function inflectSkinVars($vars)
{
$vars['name'] = preg_replace('/-skin$/', '', $vars['name']);
$vars['name'] = preg_replace('/skin-$/', '', $vars['name']);
return $vars;
}
protected function inflectElementVars($vars)
{
$vars['name'] = preg_replace('/-elements$/', '', $vars['name']);
$vars['name'] = preg_replace('/elements-$/', '', $vars['name']);
$vars['name'] = preg_replace('/-element$/', '', $vars['name']);
$vars['name'] = preg_replace('/element-$/', '', $vars['name']);
return $vars;
}
}

View file

@ -1,47 +0,0 @@
<?php
namespace Composer\Installers;
class MoodleInstaller extends BaseInstaller
{
protected $locations = array(
'mod' => 'mod/{$name}/',
'admin_report' => 'admin/report/{$name}/',
'tool' => 'admin/tool/{$name}/',
'assignment' => 'mod/assignment/type/{$name}/',
'assignsubmission' => 'mod/assign/submission/{$name}/',
'assignfeedback' => 'mod/assign/feedback/{$name}/',
'auth' => 'auth/{$name}/',
'availability' => 'availability/condition/{$name}/',
'block' => 'blocks/{$name}/',
'calendartype' => 'calendar/type/{$name}/',
'format' => 'course/format/{$name}/',
'coursereport' => 'course/report/{$name}/',
'datafield' => 'mod/data/field/{$name}/',
'datapreset' => 'mod/data/preset/{$name}/',
'editor' => 'lib/editor/{$name}/',
'enrol' => 'enrol/{$name}/',
'filter' => 'filter/{$name}/',
'gradeexport' => 'grade/export/{$name}/',
'gradeimport' => 'grade/import/{$name}/',
'gradereport' => 'grade/report/{$name}/',
'gradingform' => 'grade/grading/form/{$name}/',
'local' => 'local/{$name}/',
'message' => 'message/output/{$name}/',
'plagiarism' => 'plagiarism/{$name}/',
'portfolio' => 'portfolio/{$name}/',
'qbehaviour' => 'question/behaviour/{$name}/',
'qformat' => 'question/format/{$name}/',
'qtype' => 'question/type/{$name}/',
'quizaccess' => 'mod/quiz/accessrule/{$name}/',
'quiz' => 'mod/quiz/report/{$name}/',
'report' => 'report/{$name}/',
'repository' => 'repository/{$name}/',
'scormreport' => 'mod/scorm/report/{$name}/',
'theme' => 'theme/{$name}/',
'profilefield' => 'user/profile/field/{$name}/',
'webservice' => 'webservice/{$name}/',
'workshopallocation' => 'mod/workshop/allocation/{$name}/',
'workshopeval' => 'mod/workshop/eval/{$name}/',
'workshopform' => 'mod/workshop/form/{$name}/'
);
}

View file

@ -1,46 +0,0 @@
<?php
namespace Composer\Installers;
class OctoberInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
'plugin' => 'plugins/{$vendor}/{$name}/',
'theme' => 'themes/{$name}/'
);
/**
* Format package name.
*
* For package type october-plugin, cut off a trailing '-plugin' if present.
*
* For package type october-theme, cut off a trailing '-theme' if present.
*
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'october-plugin') {
return $this->inflectPluginVars($vars);
}
if ($vars['type'] === 'october-theme') {
return $this->inflectThemeVars($vars);
}
return $vars;
}
protected function inflectPluginVars($vars)
{
$vars['name'] = preg_replace('/-plugin$/', '', $vars['name']);
return $vars;
}
protected function inflectThemeVars($vars)
{
$vars['name'] = preg_replace('/-theme$/', '', $vars['name']);
return $vars;
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class OxidInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
'theme' => 'application/views/{$name}/',
'out' => 'out/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class PPIInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class PhpBBInstaller extends BaseInstaller
{
protected $locations = array(
'extension' => 'ext/{$vendor}/{$name}/',
'language' => 'language/{$name}/',
'style' => 'styles/{$name}/',
);
}

View file

@ -1,21 +0,0 @@
<?php
namespace Composer\Installers;
class PimcoreInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}

View file

@ -1,32 +0,0 @@
<?php
namespace Composer\Installers;
/**
* Class PiwikInstaller
*
* @package Composer\Installers
*/
class PiwikInstaller extends BaseInstaller
{
/**
* @var array
*/
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Format package name to CamelCase
* @param array $vars
*
* @return array
*/
public function inflectPackageVars($vars)
{
$vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name']));
$vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']);
$vars['name'] = str_replace(' ', '', ucwords($vars['name']));
return $vars;
}
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class PrestashopInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
'theme' => 'themes/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class PuppetInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$name}/',
);
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class RedaxoInstaller extends BaseInstaller
{
protected $locations = array(
'addon' => 'redaxo/include/addons/{$name}/',
'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/'
);
}

View file

@ -1,22 +0,0 @@
<?php
namespace Composer\Installers;
class RoundcubeInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Lowercase name and changes the name to a underscores
*
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
{
$vars['name'] = strtolower(str_replace('-', '_', $vars['name']));
return $vars;
}
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class SMFInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'Sources/{$name}/',
'theme' => 'Themes/{$name}/',
);
}

View file

@ -1,58 +0,0 @@
<?php
namespace Composer\Installers;
/**
* Plugin/theme installer for shopware
* @author Benjamin Boit
*/
class ShopwareInstaller extends BaseInstaller
{
protected $locations = array(
'backend-plugin' => 'engine/Shopware/Plugins/Local/Backend/{$name}/',
'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/',
'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/',
'theme' => 'templates/{$name}/'
);
/**
* Transforms the names
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
{
if ($vars['type'] === 'shopware-theme') {
return $this->correctThemeName($vars);
} else {
return $this->correctPluginName($vars);
}
}
/**
* Changes the name to a camelcased combination of vendor and name
* @param array $vars
* @return array
*/
private function correctPluginName($vars)
{
$camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
return strtoupper($matches[0][1]);
}, $vars['name']);
$vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName);
return $vars;
}
/**
* Changes the name to a underscore separated name
* @param array $vars
* @return array
*/
private function correctThemeName($vars)
{
$vars['name'] = str_replace('-', '_', $vars['name']);
return $vars;
}
}

View file

@ -1,36 +0,0 @@
<?php
namespace Composer\Installers;
use Composer\Package\PackageInterface;
class SilverStripeInstaller extends BaseInstaller
{
protected $locations = array(
'module' => '{$name}/',
'theme' => 'themes/{$name}/',
);
/**
* Return the install path based on package type.
*
* Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework
* must be installed to 'sapphire' and not 'framework' if the version is <3.0.0
*
* @param PackageInterface $package
* @param string $frameworkType
* @return string
*/
public function getInstallPath(PackageInterface $package, $frameworkType = '')
{
if (
$package->getName() == 'silverstripe/framework'
&& preg_match('/^\d+\.\d+\.\d+/', $package->getVersion())
&& version_compare($package->getVersion(), '2.999.999') < 0
) {
return $this->templatePath($this->locations['module'], array('name' => 'sapphire'));
} else {
return parent::getInstallPath($package, $frameworkType);
}
}
}

View file

@ -1,26 +0,0 @@
<?php
namespace Composer\Installers;
/**
* Plugin installer for symfony 1.x
*
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
class Symfony1Installer extends BaseInstaller
{
protected $locations = array(
'plugin' => 'plugins/{$name}/',
);
/**
* Format package name to CamelCase
*/
public function inflectPackageVars($vars)
{
$vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
return strtoupper($matches[0][1]);
}, $vars['name']);
return $vars;
}
}

View file

@ -1,14 +0,0 @@
<?php
namespace Composer\Installers;
/**
* Extension installer for TYPO3 CMS
*
* @author Sascha Egerer <sascha.egerer@dkd.de>
*/
class TYPO3CmsInstaller extends BaseInstaller
{
protected $locations = array(
'extension' => 'typo3conf/ext/{$name}/',
);
}

View file

@ -1,38 +0,0 @@
<?php
namespace Composer\Installers;
/**
* An installer to handle TYPO3 Flow specifics when installing packages.
*/
class TYPO3FlowInstaller extends BaseInstaller
{
protected $locations = array(
'package' => 'Packages/Application/{$name}/',
'framework' => 'Packages/Framework/{$name}/',
'plugin' => 'Packages/Plugins/{$name}/',
'site' => 'Packages/Sites/{$name}/',
'boilerplate' => 'Packages/Boilerplates/{$name}/',
'build' => 'Build/{$name}/',
);
/**
* Modify the package name to be a TYPO3 Flow style key.
*
* @param array $vars
* @return array
*/
public function inflectPackageVars($vars)
{
$autoload = $this->package->getAutoload();
if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) {
$namespace = key($autoload['psr-0']);
$vars['name'] = str_replace('\\', '.', $namespace);
}
if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) {
$namespace = key($autoload['psr-4']);
$vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.');
}
return $vars;
}
}

View file

@ -1,12 +0,0 @@
<?php
namespace Composer\Installers;
class TheliaInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'local/modules/{$name}/',
'frontoffice-template' => 'templates/frontOffice/{$name}/',
'backoffice-template' => 'templates/backOffice/{$name}/',
'email-template' => 'templates/email/{$name}/',
);
}

View file

@ -1,14 +0,0 @@
<?php
namespace Composer\Installers;
/**
* Composer installer for 3rd party Tusk utilities
* @author Drew Ewing <drew@phenocode.com>
*/
class TuskInstaller extends BaseInstaller
{
protected $locations = array(
'task' => '.tusk/tasks/{$name}/',
'command' => '.tusk/commands/{$name}/',
'asset' => 'assets/tusk/{$name}/',
);
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class WHMCSInstaller extends BaseInstaller
{
protected $locations = array(
'gateway' => 'modules/gateways/{$name}/',
);
}

View file

@ -1,9 +0,0 @@
<?php
namespace Composer\Installers;
class WolfCMSInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'wolf/plugins/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class WordPressInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'wp-content/plugins/{$name}/',
'theme' => 'wp-content/themes/{$name}/',
'muplugin' => 'wp-content/mu-plugins/{$name}/',
);
}

View file

@ -1,11 +0,0 @@
<?php
namespace Composer\Installers;
class ZendInstaller extends BaseInstaller
{
protected $locations = array(
'library' => 'library/{$name}/',
'extra' => 'extras/library/{$name}/',
'module' => 'module/{$name}/',
);
}

View file

@ -1,10 +0,0 @@
<?php
namespace Composer\Installers;
class ZikulaInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'modules/{$vendor}-{$name}/',
'theme' => 'themes/{$vendor}-{$name}/'
);
}

View file

@ -1,13 +0,0 @@
<?php
function includeIfExists($file)
{
if (file_exists($file)) {
return include $file;
}
}
if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL);
}
return $loader;

View file

@ -1,61 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\AsgardInstaller;
use Composer\Package\Package;
use Composer\Composer;
class AsgardInstallerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var OctoberInstaller
*/
private $installer;
public function setUp()
{
$this->installer = new AsgardInstaller(
new Package('NyanCat', '4.2', '4.2'),
new Composer()
);
}
/**
* @dataProvider packageNameInflectionProvider
*/
public function testInflectPackageVars($type, $name, $expected)
{
$this->assertEquals(
$this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
array('name' => $expected, 'type' => $type)
);
}
public function packageNameInflectionProvider()
{
return array(
array(
'asgard-module',
'asgard-module',
'Asgard'
),
array(
'asgard-module',
'blog',
'Blog'
),
// tests that exactly one '-theme' is cut off
array(
'asgard-theme',
'some-theme-theme',
'Some-theme',
),
// tests that names without '-theme' suffix stay valid
array(
'asgard-theme',
'someothertheme',
'Someothertheme',
),
);
}
}

View file

@ -1,115 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\CakePHPInstaller;
use Composer\Repository\RepositoryManager;
use Composer\Repository\InstalledArrayRepository;
use Composer\Package\Package;
use Composer\Package\RootPackage;
use Composer\Package\Link;
use Composer\Package\Version\VersionParser;
use Composer\Composer;
use Composer\Config;
class CakePHPInstallerTest extends TestCase
{
private $composer;
private $io;
/**
* setUp
*
* @return void
*/
public function setUp()
{
$this->package = new Package('CamelCased', '1.0', '1.0');
$this->io = $this->getMock('Composer\IO\PackageInterface');
$this->composer = new Composer();
$this->composer->setConfig(new Config(false));
}
/**
* testInflectPackageVars
*
* @return void
*/
public function testInflectPackageVars()
{
$installer = new CakePHPInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
$this->assertEquals($result, array('name' => 'CamelCased'));
$installer = new CakePHPInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'with-dash'));
$this->assertEquals($result, array('name' => 'WithDash'));
$installer = new CakePHPInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
$this->assertEquals($result, array('name' => 'WithUnderscore'));
$installer = new CakePHPInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'cake/acl'));
$this->assertEquals($result, array('name' => 'Cake/Acl'));
$installer = new CakePHPInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit'));
$this->assertEquals($result, array('name' => 'Cake/DebugKit'));
}
/**
* Test getLocations returning appropriate values based on CakePHP version
*
*/
public function testGetLocations() {
$package = new RootPackage('CamelCased', '1.0', '1.0');
$composer = $this->composer;
$rm = new RepositoryManager(
$this->getMock('Composer\IO\IOInterface'),
$this->getMock('Composer\Config')
);
$composer->setRepositoryManager($rm);
$installer = new CakePHPInstaller($package, $composer);
// 2.0 < cakephp < 3.0
$this->setCakephpVersion($rm, '2.0.0');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
$this->setCakephpVersion($rm, '2.5.9');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
$this->setCakephpVersion($rm, '~2.5');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
// special handling for 2.x versions when 3.x is still in development
$this->setCakephpVersion($rm, 'dev-master');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
$this->setCakephpVersion($rm, '>=2.5');
$result = $installer->getLocations();
$this->assertContains('Plugin/', $result['plugin']);
// cakephp >= 3.0
$this->setCakephpVersion($rm, '3.0.*-dev');
$result = $installer->getLocations();
$this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']);
$this->setCakephpVersion($rm, '~8.8');
$result = $installer->getLocations();
$this->assertEquals('vendor/{$vendor}/{$name}/', $result['plugin']);
}
protected function setCakephpVersion($rm, $version) {
$parser = new VersionParser();
list(, $version) = explode(' ', $parser->parseConstraints($version));
$installed = new InstalledArrayRepository();
$package = new Package('cakephp/cakephp', $version, $version);
$installed->addPackage($package);
$rm->setLocalRepository($installed);
}
}

View file

@ -1,89 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\DokuWikiInstaller;
use Composer\Package\Package;
use Composer\Composer;
class DokuWikiInstallerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var DokuWikiInstaller
*/
private $installer;
public function setUp()
{
$this->installer = new DokuWikiInstaller(
new Package('NyanCat', '4.2', '4.2'),
new Composer()
);
}
/**
* @dataProvider packageNameInflectionProvider
*/
public function testInflectPackageVars($type, $name, $expected)
{
$this->assertEquals(
$this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
array('name' => $expected, 'type'=>$type)
);
}
public function packageNameInflectionProvider()
{
return array(
array(
'dokuwiki-plugin',
'dokuwiki-test-plugin',
'test',
),
array(
'dokuwiki-plugin',
'test-plugin',
'test',
),
array(
'dokuwiki-plugin',
'dokuwiki_test',
'test',
),
array(
'dokuwiki-plugin',
'test',
'test',
),
array(
'dokuwiki-plugin',
'test-template',
'test-template',
),
array(
'dokuwiki-template',
'dokuwiki-test-template',
'test',
),
array(
'dokuwiki-template',
'test-template',
'test',
),
array(
'dokuwiki-template',
'dokuwiki_test',
'test',
),
array(
'dokuwiki-template',
'test',
'test',
),
array(
'dokuwiki-template',
'test-plugin',
'test-plugin',
),
);
}
}

View file

@ -1,63 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Composer;
use Composer\Installers\GravInstaller;
class GravInstallerTest extends TestCase
{
/* @var \Composer\Composer */
protected $composer;
public function setUp()
{
$this->composer = new Composer();
}
public function testInflectPackageVars()
{
$package = $this->getPackage('vendor/name', '0.0.0');
$installer = new GravInstaller($package, $this->composer);
$packageVars = $this->getPackageVars($package);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test')));
$this->assertEquals('test', $result['name']);
foreach ($installer->getLocations() as $name => $location) {
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test")));
$this->assertEquals('test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name")));
$this->assertEquals('test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test")));
$this->assertEquals('test-test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name")));
$this->assertEquals('test-test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test")));
$this->assertEquals('test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name")));
$this->assertEquals('test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test")));
$this->assertEquals('test-test', $result['name']);
$result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name")));
$this->assertEquals('test-test', $result['name']);
}
}
/**
* @param $package \Composer\Package\PackageInterface
*/
public function getPackageVars($package)
{
$type = $package->getType();
$prettyName = $package->getPrettyName();
if (strpos($prettyName, '/') !== false) {
list($vendor, $name) = explode('/', $prettyName);
} else {
$vendor = '';
$name = $prettyName;
}
return compact('name', 'vendor', 'type');
}
}

View file

@ -1,422 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\Installer;
use Composer\Util\Filesystem;
use Composer\Package\Package;
use Composer\Package\RootPackage;
use Composer\Composer;
use Composer\Config;
class InstallerTest extends TestCase
{
private $composer;
private $config;
private $vendorDir;
private $binDir;
private $dm;
private $repository;
private $io;
private $fs;
/**
* setUp
*
* @return void
*/
public function setUp()
{
$this->fs = new Filesystem;
$this->composer = new Composer();
$this->config = new Config();
$this->composer->setConfig($this->config);
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin';
$this->ensureDirectoryExistsAndClear($this->binDir);
$this->config->merge(array(
'config' => array(
'vendor-dir' => $this->vendorDir,
'bin-dir' => $this->binDir,
),
));
$this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
->disableOriginalConstructor()
->getMock();
$this->composer->setDownloadManager($this->dm);
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
$this->io = $this->getMock('Composer\IO\IOInterface');
}
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
$this->fs->removeDirectory($this->vendorDir);
$this->fs->removeDirectory($this->binDir);
}
/**
* testSupports
*
* @return void
*
* @dataProvider dataForTestSupport
*/
public function testSupports($type, $expected)
{
$installer = new Installer($this->io, $this->composer);
$this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type));
}
/**
* dataForTestSupport
*/
public function dataForTestSupport()
{
return array(
array('agl-module', true),
array('aimeos-extension', true),
array('annotatecms-module', true),
array('annotatecms-component', true),
array('annotatecms-service', true),
array('bitrix-module', true),
array('bitrix-component', true),
array('bitrix-theme', true),
array('cakephp', false),
array('cakephp-', false),
array('cakephp-app', false),
array('cakephp-plugin', true),
array('chef-cookbook', true),
array('chef-role', true),
array('codeigniter-app', false),
array('codeigniter-library', true),
array('codeigniter-third-party', true),
array('codeigniter-module', true),
array('concrete5-block', true),
array('concrete5-package', true),
array('concrete5-theme', true),
array('concrete5-update', true),
array('craft-plugin', true),
array('croogo-plugin', true),
array('croogo-theme', true),
array('dokuwiki-plugin', true),
array('dokuwiki-template', true),
array('drupal-module', true),
array('dolibarr-module', true),
array('elgg-plugin', true),
array('fuel-module', true),
array('fuel-package', true),
array('fuel-theme', true),
array('fuelphp-component', true),
array('hurad-plugin', true),
array('hurad-theme', true),
array('joomla-library', true),
array('kirby-plugin', true),
array('kohana-module', true),
array('laravel-library', true),
array('lithium-library', true),
array('magento-library', true),
array('mako-package', true),
array('modxevo-snippet', true),
array('modxevo-plugin', true),
array('modxevo-module', true),
array('modxevo-template', true),
array('modxevo-lib', true),
array('mediawiki-extension', true),
array('mediawiki-skin', true),
array('microweber-module', true),
array('modulework-module', true),
array('moodle-mod', true),
array('october-module', true),
array('october-plugin', true),
array('piwik-plugin', true),
array('phpbb-extension', true),
array('pimcore-plugin', true),
array('ppi-module', true),
array('prestashop-module', true),
array('prestashop-theme', true),
array('puppet-module', true),
array('redaxo-addon', true),
array('redaxo-bestyle-plugin', true),
array('roundcube-plugin', true),
array('shopware-backend-plugin', true),
array('shopware-core-plugin', true),
array('shopware-frontend-plugin', true),
array('shopware-theme', true),
array('silverstripe-module', true),
array('silverstripe-theme', true),
array('smf-module', true),
array('smf-theme', true),
array('symfony1-plugin', true),
array('thelia-module', true),
array('thelia-frontoffice-template', true),
array('thelia-backoffice-template', true),
array('thelia-email-template', true),
array('tusk-task', true),
array('tusk-asset', true),
array('typo3-flow-plugin', true),
array('typo3-cms-extension', true),
array('whmcs-gateway', true),
array('wolfcms-plugin', true),
array('wordpress-plugin', true),
array('wordpress-core', false),
array('zend-library', true),
array('zikula-module', true),
array('zikula-theme', true),
);
}
/**
* testInstallPath
*
* @dataProvider dataForTestInstallPath
*/
public function testInstallPath($type, $path, $name, $version = '1.0.0')
{
$installer = new Installer($this->io, $this->composer);
$package = new Package($name, $version, $version);
$package->setType($type);
$result = $installer->getInstallPath($package);
$this->assertEquals($path, $result);
}
/**
* dataFormTestInstallPath
*/
public function dataForTestInstallPath()
{
return array(
array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'),
array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
array('bitrix-module', 'local/modules/my_module/', 'author/my_module'),
array('bitrix-component', 'local/components/my_component/', 'author/my_component'),
array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'),
array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'),
array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'),
array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'),
array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'),
array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'),
array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'),
array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'),
array('concrete5-theme', 'themes/concrete5_theme/', 'remo/concrete5_theme'),
array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'),
array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'),
array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'),
array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'),
array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'),
array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'),
array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'),
array('drupal-module', 'modules/my_module/', 'shama/my_module'),
array('drupal-theme', 'themes/my_module/', 'shama/my_module'),
array('drupal-profile', 'profiles/my_module/', 'shama/my_module'),
array('drupal-drush', 'drush/my_module/', 'shama/my_module'),
array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'),
array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'),
array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'),
array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'),
array('fuelphp-component', 'components/demo/', 'fuelphp/demo'),
array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'),
array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'),
array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'),
array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'),
array('kohana-module', 'modules/my_package/', 'shama/my_package'),
array('laravel-library', 'libraries/my_package/', 'shama/my_package'),
array('lithium-library', 'libraries/li3_test/', 'user/li3_test'),
array('magento-library', 'lib/foo/', 'test/foo'),
array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'),
array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'),
array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'),
array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'),
array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'),
array('mako-package', 'app/packages/my_package/', 'shama/my_package'),
array('mediawiki-extension', 'extensions/APC/', 'author/APC'),
array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'),
array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'),
array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'),
array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'),
array('mediawiki-skin', 'skins/someskin/', 'author/someskin'),
array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'),
array('modulework-module', 'modules/my_package/', 'shama/my_package'),
array('moodle-mod', 'mod/my_package/', 'shama/my_package'),
array('october-module', 'modules/my_plugin/', 'shama/my_plugin'),
array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
array('prestashop-module', 'modules/a-module/', 'vendor/a-module'),
array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'),
array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
array('phpbb-style', 'styles/foo/', 'test/foo'),
array('phpbb-language', 'language/foo/', 'test/foo'),
array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'),
array('ppi-module', 'modules/foo/', 'test/foo'),
array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'),
array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'),
array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'),
array('roundcube-plugin', 'plugins/base/', 'test/base'),
array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'),
array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'),
array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'),
array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'),
array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'),
array('silverstripe-module', 'my_module/', 'shama/my_module'),
array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'),
array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'),
array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'),
array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'),
array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'),
array('smf-module', 'Sources/my_module/', 'shama/my_module'),
array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'),
array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'),
array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'),
array('thelia-module', 'local/modules/my_module/', 'shama/my_module'),
array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'),
array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'),
array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'),
array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'),
array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'),
array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'),
array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'),
array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'),
array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'),
array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'),
array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'),
array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'),
array('zikula-module', 'modules/my-test_module/', 'my/test_module'),
array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'),
);
}
/**
* testGetCakePHPInstallPathException
*
* @return void
*
* @expectedException \InvalidArgumentException
*/
public function testGetCakePHPInstallPathException()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('shama/ftp', '1.0.0', '1.0.0');
$package->setType('cakephp-whoops');
$result = $installer->getInstallPath($package);
}
/**
* testCustomInstallPath
*/
public function testCustomInstallPath()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('shama/ftp', '1.0.0', '1.0.0');
$package->setType('cakephp-plugin');
$consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
$this->composer->setPackage($consumerPackage);
$consumerPackage->setExtra(array(
'installer-paths' => array(
'my/custom/path/{$name}/' => array(
'shama/ftp',
'foo/bar',
),
),
));
$result = $installer->getInstallPath($package);
$this->assertEquals('my/custom/path/Ftp/', $result);
}
/**
* testCustomInstallerName
*/
public function testCustomInstallerName()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0');
$package->setType('cakephp-plugin');
$package->setExtra(array(
'installer-name' => 'FTP',
));
$result = $installer->getInstallPath($package);
$this->assertEquals('Plugin/FTP/', $result);
}
/**
* testCustomTypePath
*/
public function testCustomTypePath()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0');
$package->setType('wordpress-plugin');
$consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0');
$this->composer->setPackage($consumerPackage);
$consumerPackage->setExtra(array(
'installer-paths' => array(
'my/custom/path/{$name}/' => array(
'type:wordpress-plugin'
),
),
));
$result = $installer->getInstallPath($package);
$this->assertEquals('my/custom/path/my_plugin/', $result);
}
/**
* testNoVendorName
*/
public function testNoVendorName()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0');
$package->setType('symfony1-plugin');
$result = $installer->getInstallPath($package);
$this->assertEquals('plugins/sfPhpunitPlugin/', $result);
}
/**
* testTypo3Inflection
*/
public function testTypo3Inflection()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('typo3/fluid', '1.0.0', '1.0.0');
$package->setAutoload(array(
'psr-0' => array(
'TYPO3\\Fluid' => 'Classes',
),
));
$package->setType('typo3-flow-package');
$result = $installer->getInstallPath($package);
$this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
}
public function testUninstallAndDeletePackageFromLocalRepo()
{
$package = new Package('foo', '1.0.0', '1.0.0');
$installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer));
$installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo'));
$repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
$repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true));
$repo->expects($this->once())->method('removePackage')->with($package);
$installer->uninstall($repo, $package);
}
}

View file

@ -1,66 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\MediaWikiInstaller;
use Composer\Package\Package;
use Composer\Composer;
class MediaWikiInstallerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var MediaWikiInstaller
*/
private $installer;
public function setUp()
{
$this->installer = new MediaWikiInstaller(
new Package('NyanCat', '4.2', '4.2'),
new Composer()
);
}
/**
* @dataProvider packageNameInflectionProvider
*/
public function testInflectPackageVars($type, $name, $expected)
{
$this->assertEquals(
$this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
array('name' => $expected, 'type'=>$type)
);
}
public function packageNameInflectionProvider()
{
return array(
array(
'mediawiki-extension',
'sub-page-list',
'SubPageList',
),
array(
'mediawiki-extension',
'sub-page-list-extension',
'SubPageList',
),
array(
'mediawiki-extension',
'semantic-mediawiki',
'SemanticMediawiki',
),
// tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions
array(
'mediawiki-skin',
'some-skin-skin',
'some-skin',
),
// tests that names without '-skin' suffix stay valid
array(
'mediawiki-skin',
'someotherskin',
'someotherskin',
),
);
}
}

View file

@ -1,66 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\OctoberInstaller;
use Composer\Package\Package;
use Composer\Composer;
class OctoberInstallerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var OctoberInstaller
*/
private $installer;
public function setUp()
{
$this->installer = new OctoberInstaller(
new Package('NyanCat', '4.2', '4.2'),
new Composer()
);
}
/**
* @dataProvider packageNameInflectionProvider
*/
public function testInflectPackageVars($type, $name, $expected)
{
$this->assertEquals(
$this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)),
array('name' => $expected, 'type' => $type)
);
}
public function packageNameInflectionProvider()
{
return array(
array(
'october-plugin',
'subpagelist',
'subpagelist',
),
array(
'october-plugin',
'subpagelist-plugin',
'subpagelist',
),
array(
'october-plugin',
'semanticoctober',
'semanticoctober',
),
// tests that exactly one '-theme' is cut off
array(
'october-theme',
'some-theme-theme',
'some-theme',
),
// tests that names without '-theme' suffix stay valid
array(
'october-theme',
'someothertheme',
'someothertheme',
),
);
}
}

View file

@ -1,44 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Installers\PimcoreInstaller;
use Composer\Package\Package;
use Composer\Composer;
class PimcoreInstallerTest extends TestCase
{
private $composer;
private $io;
/**
* setUp
*
* @return void
*/
public function setUp()
{
$this->package = new Package('CamelCased', '1.0', '1.0');
$this->io = $this->getMock('Composer\IO\PackageInterface');
$this->composer = new Composer();
}
/**
* testInflectPackageVars
*
* @return void
*/
public function testInflectPackageVars()
{
$installer = new PimcoreInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'CamelCased'));
$this->assertEquals($result, array('name' => 'CamelCased'));
$installer = new PimcoreInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'with-dash'));
$this->assertEquals($result, array('name' => 'WithDash'));
$installer = new PimcoreInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'with_underscore'));
$this->assertEquals($result, array('name' => 'WithUnderscore'));
}
}

View file

@ -1,63 +0,0 @@
<?php
namespace Composer\Installers\Test;
use Composer\Composer;
use Composer\Installers\PiwikInstaller;
use Composer\Package\Package;
use Composer\Package\PackageInterface;
/**
* Class PiwikInstallerTest
*
* @package Composer\Installers\Test
*/
class PiwikInstallerTest extends TestCase
{
/**
* @varComposer
*/
private $composer;
/**
* @var PackageInterface
*/
private $io;
/**
* @var Package
*/
private $package;
/**
* setUp
*
* @return void
*/
public function setUp()
{
$this->package = new Package('VisitSummary', '1.0', '1.0');
$this->io = $this->getMock('Composer\IO\PackageInterface');
$this->composer = new Composer();
}
/**
* testInflectPackageVars
*
* @return void
*/
public function testInflectPackageVars()
{
$installer = new PiwikInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'VisitSummary'));
$this->assertEquals($result, array('name' => 'VisitSummary'));
$installer = new PiwikInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'visit-summary'));
$this->assertEquals($result, array('name' => 'VisitSummary'));
$installer = new PiwikInstaller($this->package, $this->composer);
$result = $installer->inflectPackageVars(array('name' => 'visit_summary'));
$this->assertEquals($result, array('name' => 'VisitSummary'));
}
}

View file

@ -1,64 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Installers\Test;
use Composer\Package\Version\VersionParser;
use Composer\Package\Package;
use Composer\Package\AliasPackage;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Util\Filesystem;
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
private static $parser;
protected static function getVersionParser()
{
if (!self::$parser) {
self::$parser = new VersionParser();
}
return self::$parser;
}
protected function getVersionConstraint($operator, $version)
{
return new VersionConstraint(
$operator,
self::getVersionParser()->normalize($version)
);
}
protected function getPackage($name, $version)
{
$normVersion = self::getVersionParser()->normalize($version);
return new Package($name, $normVersion, $version);
}
protected function getAliasPackage($package, $version)
{
$normVersion = self::getVersionParser()->normalize($version);
return new AliasPackage($package, $normVersion, $version);
}
protected function ensureDirectoryExistsAndClear($directory)
{
$fs = new Filesystem();
if (is_dir($directory)) {
$fs->removeDirectory($directory);
}
mkdir($directory, 0777, true);
}
}

View file

@ -1,4 +0,0 @@
<?php
$loader = require __DIR__ . '/../src/bootstrap.php';
$loader->add('Composer\Installers\Test', __DIR__);