-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add installer for TastyIgniter extensions and themes (#474)
* Add installer for TastyIgniter extensions and themes * CI fix * CI fix * CI fix * Add support for TastyIgniter themes * Use appropriate replace regex
- Loading branch information
Showing
6 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ | |
"SyDES", | ||
"Sylius", | ||
"symfony", | ||
"TastyIgniter", | ||
"Thelia", | ||
"TYPO3", | ||
"WHMCS", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Composer\Installers; | ||
|
||
class IgniterInstaller extends BaseInstaller | ||
{ | ||
protected $locations = array( | ||
'extension' => 'extensions/{$vendor}/{$name}/', | ||
'theme' => 'themes/{$name}/', | ||
); | ||
|
||
/** | ||
* Format package name. | ||
* | ||
* Cut off leading 'ti-ext-' or 'ti-theme-' if present. | ||
* Strip vendor name of characters that is not alphanumeric or an underscore | ||
* | ||
*/ | ||
public function inflectPackageVars($vars) | ||
{ | ||
if ($vars['type'] === 'igniter-extension') { | ||
$vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']); | ||
$vars['name'] = preg_replace('/^ti-ext-$/', '', $vars['name']); | ||
} | ||
|
||
if ($vars['type'] === 'igniter-theme') { | ||
$vars['name'] = preg_replace('/^ti-theme-$/', '', $vars['name']); | ||
} | ||
|
||
return $vars; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace Composer\Installers\Test; | ||
|
||
use Composer\Composer; | ||
use Composer\Installers\IgniterInstaller; | ||
use Composer\Package\Package; | ||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
class IgniterInstallerTest extends BaseTestCase | ||
{ | ||
/** | ||
* @var IgniterInstaller | ||
*/ | ||
private $installer; | ||
|
||
/** | ||
* setUp | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->installer = new IgniterInstaller( | ||
new Package('NyanCat', '4.2', '4.2'), | ||
new Composer() | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider packageNameInflectionProvider | ||
* | ||
* @return void | ||
*/ | ||
public function testInflectPackageVars($type, $vendor, $name, $expectedVendor, $expectedName) | ||
{ | ||
$this->assertEquals( | ||
$this->installer->inflectPackageVars(array( | ||
'vendor' => $vendor, | ||
'name' => $name, | ||
'type' => $type, | ||
)), | ||
array('vendor' => $expectedVendor, 'name' => $expectedName, 'type' => $type) | ||
); | ||
} | ||
|
||
public function packageNameInflectionProvider() | ||
{ | ||
return array( | ||
array( | ||
'igniter-extension', | ||
'acme', | ||
'pages', | ||
'acme', | ||
'pages', | ||
), | ||
array( | ||
'igniter-extension', | ||
'acme', | ||
'ti-ext-pages', | ||
'acme', | ||
'pages', | ||
), | ||
// tests vendor name containing a hyphen | ||
array( | ||
'igniter-extension', | ||
'foo-bar-co', | ||
'blog', | ||
'foobarco', | ||
'blog', | ||
), | ||
// tests that exactly one '-theme' is cut off | ||
array( | ||
'igniter-theme', | ||
'acme', | ||
'ti-theme-theme', | ||
'acme', | ||
'theme', | ||
), | ||
// tests that names without '-theme' suffix stay valid | ||
array( | ||
'igniter-theme', | ||
'acme', | ||
'someothertheme', | ||
'acme', | ||
'someothertheme', | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters