feat: add initial node support

Refs: #5
This commit is contained in:
Oliver Davies 2023-03-12 12:23:25 +00:00
parent a179f1b0ee
commit b4b289748a
7 changed files with 68 additions and 2 deletions

View file

@ -101,6 +101,11 @@ final class BuildConfigurationCommand extends Command
$this->filesToGenerate->push(['php/docker-entrypoint-php', 'tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php']);
}
if (self::isNode(Arr::get($configurationData, 'language'))) {
$this->filesToGenerate->push(['node/.yarnrc', '.yarnrc']);
$this->filesToGenerate->push(['node/Dockerfile', 'Dockerfile']);
}
if (self::isCaddy(Arr::get($configurationData, 'web.type'))) {
$this->filesystem->mkdir("{$this->outputDir}/tools/docker/images/web/root/etc/caddy");
$this->filesToGenerate->push(['web/caddy/Caddyfile', 'tools/docker/images/web/root/etc/caddy/Caddyfile']);
@ -166,6 +171,15 @@ final class BuildConfigurationCommand extends Command
return strtoupper($webServer) === WebServer::NGINX->name;
}
private static function isNode(?string $language): bool
{
if (is_null($language)) {
return false;
}
return strtoupper($language) === Language::NODE->name;
}
private static function isPhp(?string $language): bool
{
if (is_null($language)) {

View file

@ -6,5 +6,6 @@ namespace OliverDaviesLtd\BuildConfigs\Enum;
enum Language
{
case NODE;
case PHP;
}

View file

@ -28,13 +28,20 @@ final class ConfigurationValidator implements ValidatorInterface
'language' => [
new Assert\NotNull(),
new Assert\Type('string'),
new Assert\Choice(['node', 'php']),
new Assert\Choice([
'node',
'php',
]),
],
'type' => [
new Assert\NotNull(),
new Assert\Type('string'),
new Assert\Choice(['drupal-project', 'fractal', 'php-library']),
new Assert\Choice([
'drupal-project',
'fractal',
'php-library',
]),
],
'project_root' => [
@ -53,6 +60,8 @@ final class ConfigurationValidator implements ValidatorInterface
// TODO: this should be a boolean if present.
'justfile' => new Assert\Optional(),
'node' => new Assert\Optional(),
'php' => new Assert\Optional(),
'web' => new Assert\Optional(),