← All changes
|
vendor/composer/installers/src/Composer/Installers/Installer.php
+41
-51
3.0.0
→
trunk
View file →
| @@ -5,8 +5,9 @@ | ||
| 5 | 5 | use Composer\Composer; |
| 6 | 6 | use Composer\Installer\BinaryInstaller; |
| 7 | 7 | use Composer\Installer\LibraryInstaller; |
| 8 | 8 | use Composer\IO\IOInterface; |
| 9 | +use Composer\Package\Package; | |
| 9 | 10 | use Composer\Package\PackageInterface; |
| 10 | 11 | use Composer\Repository\InstalledRepositoryInterface; |
| 11 | 12 | use Composer\Util\Filesystem; |
| 12 | 13 | use React\Promise\PromiseInterface; |
| @@ -12,21 +13,21 @@ | ||
| 12 | 13 | use React\Promise\PromiseInterface; |
| 13 | 14 | |
| 14 | 15 | class Installer extends LibraryInstaller |
| 15 | 16 | { |
| 16 | - | |
| 17 | 17 | /** |
| 18 | 18 | * Package types to installer class map |
| 19 | 19 | * |
| 20 | - * @var array | |
| 20 | + * @var array<string, string> | |
| 21 | 21 | */ |
| 22 | 22 | private $supportedTypes = array( |
| 23 | - 'aimeos' => 'AimeosInstaller', | |
| 23 | + 'akaunting' => 'AkauntingInstaller', | |
| 24 | 24 | 'asgard' => 'AsgardInstaller', |
| 25 | 25 | 'attogram' => 'AttogramInstaller', |
| 26 | 26 | 'agl' => 'AglInstaller', |
| 27 | 27 | 'annotatecms' => 'AnnotateCmsInstaller', |
| 28 | 28 | 'bitrix' => 'BitrixInstaller', |
| 29 | + 'botble' => 'BotbleInstaller', | |
| 29 | 30 | 'bonefish' => 'BonefishInstaller', |
| 30 | 31 | 'cakephp' => 'CakePHPInstaller', |
| 31 | 32 | 'chef' => 'ChefInstaller', |
| 32 | 33 | 'civicrm' => 'CiviCrmInstaller', |
| @@ -33,9 +34,9 @@ | ||
| 33 | 34 | 'ccframework' => 'ClanCatsFrameworkInstaller', |
| 34 | 35 | 'cockpit' => 'CockpitInstaller', |
| 35 | 36 | 'codeigniter' => 'CodeIgniterInstaller', |
| 36 | 37 | 'concrete5' => 'Concrete5Installer', |
| 37 | - 'craft' => 'CraftInstaller', | |
| 38 | + 'concretecms' => 'ConcreteCMSInstaller', | |
| 38 | 39 | 'croogo' => 'CroogoInstaller', |
| 39 | 40 | 'dframe' => 'DframeInstaller', |
| 40 | 41 | 'dokuwiki' => 'DokuWikiInstaller', |
| 41 | 42 | 'dolibarr' => 'DolibarrInstaller', |
| @@ -45,8 +46,9 @@ | ||
| 45 | 46 | 'eliasis' => 'EliasisInstaller', |
| 46 | 47 | 'ee3' => 'ExpressionEngineInstaller', |
| 47 | 48 | 'ee2' => 'ExpressionEngineInstaller', |
| 48 | 49 | 'ezplatform' => 'EzPlatformInstaller', |
| 50 | + 'fork' => 'ForkCMSInstaller', | |
| 49 | 51 | 'fuel' => 'FuelInstaller', |
| 50 | 52 | 'fuelphp' => 'FuelphpInstaller', |
| 51 | 53 | 'grav' => 'GravInstaller', |
| 52 | 54 | 'hurad' => 'HuradInstaller', |
| @@ -52,15 +54,13 @@ | ||
| 52 | 54 | 'hurad' => 'HuradInstaller', |
| 53 | 55 | 'tastyigniter' => 'TastyIgniterInstaller', |
| 54 | 56 | 'imagecms' => 'ImageCMSInstaller', |
| 55 | 57 | 'itop' => 'ItopInstaller', |
| 56 | - 'joomla' => 'JoomlaInstaller', | |
| 57 | 58 | 'kanboard' => 'KanboardInstaller', |
| 58 | - 'kirby' => 'KirbyInstaller', | |
| 59 | 59 | 'known' => 'KnownInstaller', |
| 60 | 60 | 'kodicms' => 'KodiCMSInstaller', |
| 61 | 61 | 'kohana' => 'KohanaInstaller', |
| 62 | - 'lms' => 'LanManagementSystemInstaller', | |
| 62 | + 'lms' => 'LanManagementSystemInstaller', | |
| 63 | 63 | 'laravel' => 'LaravelInstaller', |
| 64 | 64 | 'lavalite' => 'LavaLiteInstaller', |
| 65 | 65 | 'lithium' => 'LithiumInstaller', |
| 66 | 66 | 'magento' => 'MagentoInstaller', |
| @@ -66,8 +66,9 @@ | ||
| 66 | 66 | 'magento' => 'MagentoInstaller', |
| 67 | 67 | 'majima' => 'MajimaInstaller', |
| 68 | 68 | 'mantisbt' => 'MantisBTInstaller', |
| 69 | 69 | 'mako' => 'MakoInstaller', |
| 70 | + 'matomo' => 'MatomoInstaller', | |
| 70 | 71 | 'maya' => 'MayaInstaller', |
| 71 | 72 | 'mautic' => 'MauticInstaller', |
| 72 | 73 | 'mediawiki' => 'MediaWikiInstaller', |
| 73 | 74 | 'miaoxing' => 'MiaoxingInstaller', |
| @@ -81,9 +82,8 @@ | ||
| 81 | 82 | 'oxid' => 'OxidInstaller', |
| 82 | 83 | 'osclass' => 'OsclassInstaller', |
| 83 | 84 | 'pxcms' => 'PxcmsInstaller', |
| 84 | 85 | 'phpbb' => 'PhpBBInstaller', |
| 85 | - 'pimcore' => 'PimcoreInstaller', | |
| 86 | 86 | 'piwik' => 'PiwikInstaller', |
| 87 | 87 | 'plentymarkets'=> 'PlentymarketsInstaller', |
| 88 | 88 | 'ppi' => 'PPIInstaller', |
| 89 | 89 | 'puppet' => 'PuppetInstaller', |
| @@ -102,14 +102,11 @@ | ||
| 102 | 102 | 'smf' => 'SMFInstaller', |
| 103 | 103 | 'starbug' => 'StarbugInstaller', |
| 104 | 104 | 'sydes' => 'SyDESInstaller', |
| 105 | 105 | 'sylius' => 'SyliusInstaller', |
| 106 | - 'symfony1' => 'Symfony1Installer', | |
| 107 | 106 | 'tao' => 'TaoInstaller', |
| 108 | 107 | 'thelia' => 'TheliaInstaller', |
| 109 | 108 | 'tusk' => 'TuskInstaller', |
| 110 | - 'typo3-cms' => 'TYPO3CmsInstaller', | |
| 111 | - 'typo3-flow' => 'TYPO3FlowInstaller', | |
| 112 | 109 | 'userfrosting' => 'UserFrostingInstaller', |
| 113 | 110 | 'vanilla' => 'VanillaInstaller', |
| 114 | 111 | 'whmcs' => 'WHMCSInstaller', |
| 115 | 112 | 'winter' => 'WinterInstaller', |
| @@ -121,28 +118,19 @@ | ||
| 121 | 118 | 'prestashop' => 'PrestashopInstaller' |
| 122 | 119 | ); |
| 123 | 120 | |
| 124 | 121 | /** |
| 125 | - * Installer constructor. | |
| 126 | - * | |
| 127 | 122 | * Disables installers specified in main composer extra installer-disable |
| 128 | 123 | * list |
| 129 | - * | |
| 130 | - * @param IOInterface $io | |
| 131 | - * @param Composer $composer | |
| 132 | - * @param string $type | |
| 133 | - * @param Filesystem|null $filesystem | |
| 134 | - * @param BinaryInstaller|null $binaryInstaller | |
| 135 | 124 | */ |
| 136 | 125 | public function __construct( |
| 137 | 126 | IOInterface $io, |
| 138 | 127 | Composer $composer, |
| 139 | - $type = 'library', | |
| 140 | - Filesystem $filesystem = null, | |
| 141 | - BinaryInstaller $binaryInstaller = null | |
| 128 | + string $type = 'library', | |
| 129 | + ?Filesystem $filesystem = null, | |
| 130 | + ?BinaryInstaller $binaryInstaller = null | |
| 142 | 131 | ) { |
| 143 | - parent::__construct($io, $composer, $type, $filesystem, | |
| 144 | - $binaryInstaller); | |
| 132 | + parent::__construct($io, $composer, $type, $filesystem, $binaryInstaller); | |
| 145 | 133 | $this->removeDisabledInstallers(); |
| 146 | 134 | } |
| 147 | 135 | |
| 148 | 136 | /** |
| @@ -159,11 +147,19 @@ | ||
| 159 | 147 | ); |
| 160 | 148 | } |
| 161 | 149 | |
| 162 | 150 | $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; |
| 151 | + /** | |
| 152 | + * @var BaseInstaller | |
| 153 | + */ | |
| 163 | 154 | $installer = new $class($package, $this->composer, $this->getIO()); |
| 164 | 155 | |
| 165 | - return $installer->getInstallPath($package, $frameworkType); | |
| 156 | + $path = $installer->getInstallPath($package, $frameworkType); | |
| 157 | + if (!$this->filesystem->isAbsolutePath($path)) { | |
| 158 | + $path = getcwd() . '/' . $path; | |
| 159 | + } | |
| 160 | + | |
| 161 | + return $path; | |
| 166 | 162 | } |
| 167 | 163 | |
| 168 | 164 | public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) |
| 169 | 165 | { |
| @@ -187,8 +183,10 @@ | ||
| 187 | 183 | } |
| 188 | 184 | |
| 189 | 185 | /** |
| 190 | 186 | * {@inheritDoc} |
| 187 | + * | |
| 188 | + * @param string $packageType | |
| 191 | 189 | */ |
| 192 | 190 | public function supports($packageType) |
| 193 | 191 | { |
| 194 | 192 | $frameworkType = $this->findFrameworkType($packageType); |
| @@ -204,12 +202,11 @@ | ||
| 204 | 202 | |
| 205 | 203 | /** |
| 206 | 204 | * Finds a supported framework type if it exists and returns it |
| 207 | 205 | * |
| 208 | - * @param string $type | |
| 209 | 206 | * @return string|false |
| 210 | 207 | */ |
| 211 | - protected function findFrameworkType($type) | |
| 208 | + protected function findFrameworkType(string $type) | |
| 212 | 209 | { |
| 213 | 210 | krsort($this->supportedTypes); |
| 214 | 211 | |
| 215 | 212 | foreach ($this->supportedTypes as $key => $val) { |
| @@ -223,32 +220,26 @@ | ||
| 223 | 220 | |
| 224 | 221 | /** |
| 225 | 222 | * Get the second part of the regular expression to check for support of a |
| 226 | 223 | * package type |
| 227 | - * | |
| 228 | - * @param string $frameworkType | |
| 229 | - * @return string | |
| 230 | 224 | */ |
| 231 | - protected function getLocationPattern($frameworkType) | |
| 225 | + protected function getLocationPattern(string $frameworkType): string | |
| 232 | 226 | { |
| 233 | - $pattern = false; | |
| 227 | + $pattern = null; | |
| 234 | 228 | if (!empty($this->supportedTypes[$frameworkType])) { |
| 235 | 229 | $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; |
| 236 | 230 | /** @var BaseInstaller $framework */ |
| 237 | - $framework = new $frameworkClass(null, $this->composer, $this->getIO()); | |
| 238 | - $locations = array_keys($framework->getLocations()); | |
| 239 | - $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; | |
| 231 | + $framework = new $frameworkClass(new Package('dummy/pkg', '1.0.0.0', '1.0.0'), $this->composer, $this->getIO()); | |
| 232 | + $locations = array_keys($framework->getLocations($frameworkType)); | |
| 233 | + if ($locations) { | |
| 234 | + $pattern = '(' . implode('|', $locations) . ')'; | |
| 235 | + } | |
| 240 | 236 | } |
| 241 | 237 | |
| 242 | - return $pattern ? : '(\w+)'; | |
| 238 | + return $pattern ?: '(\w+)'; | |
| 243 | 239 | } |
| 244 | 240 | |
| 245 | - /** | |
| 246 | - * Get I/O object | |
| 247 | - * | |
| 248 | - * @return IOInterface | |
| 249 | - */ | |
| 250 | - private function getIO() | |
| 241 | + private function getIO(): IOInterface | |
| 251 | 242 | { |
| 252 | 243 | return $this->io; |
| 253 | 244 | } |
| 254 | 245 | |
| @@ -259,12 +250,10 @@ | ||
| 259 | 250 | * Globals: |
| 260 | 251 | * - true, "all", and "*" - disable all installers. |
| 261 | 252 | * - false - enable all installers (useful with |
| 262 | 253 | * wikimedia/composer-merge-plugin or similar) |
| 263 | - * | |
| 264 | - * @return void | |
| 265 | 254 | */ |
| 266 | - protected function removeDisabledInstallers() | |
| 255 | + protected function removeDisabledInstallers(): void | |
| 267 | 256 | { |
| 268 | 257 | $extra = $this->composer->getPackage()->getExtra(); |
| 269 | 258 | |
| 270 | 259 | if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) { |
| @@ -285,14 +274,15 @@ | ||
| 285 | 274 | $intersect = array_intersect($all, $disable); |
| 286 | 275 | if (!empty($intersect)) { |
| 287 | 276 | // Disable all installers |
| 288 | 277 | $this->supportedTypes = array(); |
| 289 | - } else { | |
| 290 | - // Disable specified installers | |
| 291 | - foreach ($disable as $key => $installer) { | |
| 292 | - if (is_string($installer) && key_exists($installer, $this->supportedTypes)) { | |
| 293 | - unset($this->supportedTypes[$installer]); | |
| 294 | - } | |
| 278 | + return; | |
| 279 | + } | |
| 280 | + | |
| 281 | + // Disable specified installers | |
| 282 | + foreach ($disable as $key => $installer) { | |
| 283 | + if (is_string($installer) && key_exists($installer, $this->supportedTypes)) { | |
| 284 | + unset($this->supportedTypes[$installer]); | |
| 295 | 285 | } |
| 296 | 286 | } |
| 297 | 287 | } |
| 298 | 288 | } |