mirror of
https://github.com/opdavies/build-configs.git
synced 2025-03-13 05:26:56 +00:00
refactor: extract helpers
This commit is contained in:
parent
ddb1bcd58d
commit
5ea7d312a6
|
@ -1,9 +1,10 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"twig/twig": "^3.5",
|
"illuminate/support": "^9.50",
|
||||||
"symfony/console": "^6.2",
|
"symfony/console": "^6.2",
|
||||||
|
"symfony/filesystem": "^6.2",
|
||||||
"symfony/yaml": "^6.2",
|
"symfony/yaml": "^6.2",
|
||||||
"symfony/filesystem": "^6.2"
|
"twig/twig": "^3.5"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"humbug/box": "^4.2",
|
"humbug/box": "^4.2",
|
||||||
|
@ -14,5 +15,8 @@
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"OliverDaviesLtd\\BuildConfigs\\": "src/"
|
"OliverDaviesLtd\\BuildConfigs\\": "src/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"sort-packages": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2704
composer.lock
generated
2704
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OliverDaviesLtd\BuildConfigs\Console\Command;
|
namespace OliverDaviesLtd\BuildConfigs\Console\Command;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use OliverDaviesLtd\BuildConfigs\Enum\Language;
|
use OliverDaviesLtd\BuildConfigs\Enum\Language;
|
||||||
|
use OliverDaviesLtd\BuildConfigs\Enum\WebServer;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
@ -55,7 +57,7 @@ final class BuildConfigurationCommand extends Command
|
||||||
$this->filesystem->dumpFile("{$outputDir}/docker-compose.yaml", $this->twig->render('docker-compose.yaml.twig', $configurationData));
|
$this->filesystem->dumpFile("{$outputDir}/docker-compose.yaml", $this->twig->render('docker-compose.yaml.twig', $configurationData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strtoupper($configurationData['language']) === Language::PHP) {
|
if (self::isPhp(Arr::get($configurationData, 'language'))) {
|
||||||
$this->filesystem->dumpFile("{$outputDir}/phpcs.xml.dist", $this->twig->render('php/phpcs.xml.twig', $configurationData));
|
$this->filesystem->dumpFile("{$outputDir}/phpcs.xml.dist", $this->twig->render('php/phpcs.xml.twig', $configurationData));
|
||||||
$this->filesystem->dumpFile("{$outputDir}/phpstan.neon.dist", $this->twig->render('php/phpstan.neon.twig', $configurationData));
|
$this->filesystem->dumpFile("{$outputDir}/phpstan.neon.dist", $this->twig->render('php/phpstan.neon.twig', $configurationData));
|
||||||
$this->filesystem->dumpFile("{$outputDir}/phpunit.xml.dist", $this->twig->render('php/phpunit.xml.twig', $configurationData));
|
$this->filesystem->dumpFile("{$outputDir}/phpunit.xml.dist", $this->twig->render('php/phpunit.xml.twig', $configurationData));
|
||||||
|
@ -64,11 +66,21 @@ final class BuildConfigurationCommand extends Command
|
||||||
$this->filesystem->dumpFile("{$outputDir}/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php", $this->twig->render('php/docker-entrypoint-php.twig', $configurationData));
|
$this->filesystem->dumpFile("{$outputDir}/tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php", $this->twig->render('php/docker-entrypoint-php.twig', $configurationData));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($configurationData['web']['type']) && $configurationData['web']['type'] === 'nginx') {
|
if (self::isNginx(Arr::get($configurationData, 'web.type'))) {
|
||||||
$this->filesystem->mkdir("{$outputDir}/tools/docker/images/nginx/root/etc/nginx/conf.d");
|
$this->filesystem->mkdir("{$outputDir}/tools/docker/images/nginx/root/etc/nginx/conf.d");
|
||||||
$this->filesystem->dumpFile("{$outputDir}/tools/docker/images/nginx/root/etc/nginx/conf.d/default.conf", $this->twig->render('default.conf', $configurationData));
|
$this->filesystem->dumpFile("{$outputDir}/tools/docker/images/nginx/root/etc/nginx/conf.d/default.conf", $this->twig->render('default.conf', $configurationData));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function isNginx(?string $webServer): bool
|
||||||
|
{
|
||||||
|
return strtoupper($webServer) == WebServer::NGINX;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function isPhp(?string $language): bool
|
||||||
|
{
|
||||||
|
return strtoupper($language) == Language::PHP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/Enum/WebServer.php
Normal file
10
src/Enum/WebServer.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace OliverDaviesLtd\BuildConfigs\Enum;
|
||||||
|
|
||||||
|
enum WebServer
|
||||||
|
{
|
||||||
|
case NGINX;
|
||||||
|
}
|
Loading…
Reference in a new issue