-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #67: Adds ability to disable all or certain installers #376
Changes from 13 commits
b2b3e21
4c60bc5
a0e7405
9676c9b
0881822
ee686c9
7f10a3e
d7d6704
dfa0641
94ee5b9
adc4a83
51a59b7
1aa22c1
3806135
c3c5297
4bff163
78eb8ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,30 @@ class Installer extends LibraryInstaller | |
'prestashop' => 'PrestashopInstaller' | ||
); | ||
|
||
/** | ||
* Installer constructor. | ||
* | ||
* Disables installers specified in main composer extra installer-disable | ||
* list | ||
* | ||
* @param IOInterface $io | ||
* @param \Composer\Composer $composer | ||
* @param string $type | ||
* @param \Composer\Util\Filesystem|null $filesystem | ||
* @param \Composer\Installer\BinaryInstaller|null $binaryInstaller | ||
*/ | ||
public function __construct( | ||
\Composer\IO\IOInterface $io, | ||
\Composer\Composer $composer, | ||
$type = 'library', | ||
\Composer\Util\Filesystem $filesystem = null, | ||
\Composer\Installer\BinaryInstaller $binaryInstaller = null | ||
) { | ||
parent::__construct($io, $composer, $type, $filesystem, | ||
$binaryInstaller); | ||
$this->removeDisabledInstallers(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
|
@@ -198,4 +222,44 @@ private function getIO() | |
{ | ||
return $this->io; | ||
} | ||
|
||
/** | ||
* Look for installers set to be disabled in composer's extra config and | ||
* remove them from the list of supported installers. | ||
* Uses true, "all", and "*" as global values to disable all installers. | ||
* | ||
* @return void | ||
*/ | ||
protected function removeDisabledInstallers() | ||
{ | ||
$extra = $this->composer->getPackage()->getExtra(); | ||
|
||
if (!isset($extra['installer-disable'])) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be worth to consider options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that Is your thought that this would be a global, "all installers are enabled"? Regarding an options array, what did you have in mind? I'm not at all opposed to having available options, but I'm not sure what options to include or what they would do? Or are you suggesting to have it available for future ideas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @niksamokhvalov |
||
// No installers are disabled | ||
return; | ||
} | ||
|
||
// Get installers to disable | ||
$disable = $extra['installer-disable']; | ||
|
||
// Ensure $disabled is an array | ||
if (!is_array($disable)) { | ||
$disable = array($disable); | ||
} | ||
|
||
// Check which installers should be disabled | ||
$all = array(true, "all", "*"); | ||
$intersect = array_intersect($all, $disable); | ||
if (!empty($intersect)) { | ||
// Disable all installers | ||
$this->supportedTypes = array(); | ||
} else { | ||
// Disable specified installers | ||
foreach ($disable as $key => $installer) { | ||
if (is_string($installer) && key_exists($installer, $this->supportedTypes)) { | ||
unset($this->supportedTypes[$installer]); | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are already imported, can you just use their short classname? Same for docblocks please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done