Skip to content
Snippets Groups Projects
Commit 5f3088fa authored by jurgenhaas's avatar jurgenhaas
Browse files

docker/l3d#58 Move project settings out of composer.json

parent e9f3a18e
No related branches found
No related tags found
No related merge requests found
ahoyapi: v2
commands:
me:
cmd:
- ahoy.yml
usage: Ahoy plugin commands
......@@ -32,7 +32,7 @@
"require": {
"php": ">=7.2",
"composer-plugin-api": "^1||^2",
"lakedrops/composer-json-utils": "^1.4.0",
"lakedrops/composer-json-utils": "^1.7||dev-master",
"symfony/yaml": "^3.4||^4.4||^5.0"
},
"require-dev": {
......@@ -47,14 +47,6 @@
}
},
"extra": {
"class": "LakeDrops\\Ahoy\\Plugin",
"lakedrops": {
"ahoy": {
"me": {
"usage": "Ahoy plugin commands",
"imports": ["ahoy.yml"]
}
}
}
"class": "LakeDrops\\Ahoy\\Plugin"
}
}
......@@ -13,34 +13,44 @@ use Symfony\Component\Yaml\Yaml;
*/
class Handler extends BaseHandler {
/**
* {@inheritdoc}
*/
public function configId(): string {
return 'ahoy';
}
/**
* Update ahoy scripts of all LakeDrops plugins.
*/
public function updateScripts() {
$this->init();
// We only do the fancy stuff for developers.
if (!$this->isDevMode()) {
return;
}
$ahoy = [
'ahoyapi' => 'v2',
'commands' => [],
];
$settings = new Utils($this->composer);
foreach ($settings->getSubSubSection('extra', 'lakedrops', 'ahoy') as $command => $commands) {
$ahoy['commands'][$command] = $commands;
if (file_exists('.ahoy.yml')) {
$ahoy = Yaml::parseFile('.ahoy.yml');
}
else {
$ahoy = [
'ahoyapi' => 'v2',
'commands' => [],
];
}
$installationManager = $this->composer->getInstallationManager();
foreach ($this->composer->getRepositoryManager()->getLocalRepository()->search('lakedrops/*') as $pkg) {
foreach ($this->composer->getRepositoryManager()->getLocalRepository()->search('*') as $pkg) {
$pluginRoot = $installationManager->getInstallPath($this->getPackage($pkg['name']));
$pluginSettings = new Utils($this->composer, $pluginRoot);
foreach ($pluginSettings->getSubSubSection('extra', 'lakedrops', 'ahoy') as $command => $commands) {
$ahoy['commands'][$command] = $commands;
foreach ($commands['imports'] as $key => $import) {
$ahoy['commands'][$command]['imports'][$key] = './vendor/' . $pkg['name'] . '/' . $import;
if (file_exists($pluginRoot . '/.ahoy.yml')) {
$pluginAhoy = Yaml::parseFile($pluginRoot . '/.ahoy.yml');
foreach ($pluginAhoy['commands'] as $command => $commands) {
$ahoy['commands'][$command] = $commands;
foreach ($commands['imports'] as $key => $import) {
$ahoy['commands'][$command]['imports'][$key] = './vendor/' . $pkg['name'] . '/' . $import;
}
}
}
}
......
......@@ -14,7 +14,7 @@ class Plugin extends BasePlugin {
/**
* {@inheritdoc}
*/
public function getHandlerClass() {
public function getHandlerClass(): string {
return Handler::class;
}
......@@ -44,7 +44,7 @@ class Plugin extends BasePlugin {
* @param \Composer\Script\Event $event
* The event that triggered the plugin.
*/
public function updateScripts(Event $event) {
public function updateScripts(Event $event): void {
/** @var Handler $handler */
$handler = $this->handler;
$handler
......
......@@ -11,7 +11,7 @@ class UpdateCommand extends BaseCommand {
/**
* {@inheritdoc}
*/
protected function configure() {
protected function configure(): void {
parent::configure();
$this
->setName('lakedrops:ahoy')
......@@ -21,18 +21,19 @@ class UpdateCommand extends BaseCommand {
/**
* {@inheritdoc}
*/
public function getHandlerClass() {
public function getHandlerClass(): string {
return Handler::class;
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
protected function execute(InputInterface $input, OutputInterface $output): int {
parent::execute($input, $output);
/** @var Handler $handler */
$handler = $this->handler;
$handler->updateScripts();
return 0;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment