From 16ad71f4f40089f5d782b0e91ce10dd38bd8f29f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 22 Nov 2023 23:50:20 +0000 Subject: [PATCH] chore: add missing values to the Config DTO * Add `dockerfile.stages.*.extra_directories` as an optional list of strings. * Allow `php.phpstan` and `php.phpcs` to be `false` or a Collection so their configuration files can not be generated. * Add `php.phpunit` and allow it to be set to `false` so its configuration files can not be generated. * Add `database.extra_databases` * Add `php.phpstan.baseline` as an optional boolean. * Add `node.version` as a string. --- CHANGELOG.md | 9 ++- src/DataTransferObject/Config.php | 93 +++++++++++++++++++------------ 2 files changed, 66 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a304eb9..b48481a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,18 @@ # Changelog -## Unreleased +## 2023-11-22 ### Added * Add CHANGELOG.md. * Add missing validation rules to the `Configuration` DTO object. + * Add `dockerfile.stages.*.extra_directories` as an optional list of strings (used in the Drupal Commerce Kickstart example). + * Allow `php.phpstan` and `php.phpcs` to be `false` or a Collection so their configuration files can not be generated (used in the Drupal Commerce Kickstart example). + * Add `php.phpunit` and allow it to be set to `false` so its configuration files can not be generated (used in the Drupal Commerce Kickstart example). + * No further PHPUnit configuration is supported. + * Add `database.extra_databases` + * Add `php.phpstan.baseline` as an optional boolean. + * Add `node.version` as a string. * Add a test to ensure the project type is a valid type. * Add a test to ensure the web server is a valid type. * Add a `test` task to `run` script. diff --git a/src/DataTransferObject/Config.php b/src/DataTransferObject/Config.php index cb3e209..3c17f88 100644 --- a/src/DataTransferObject/Config.php +++ b/src/DataTransferObject/Config.php @@ -13,6 +13,12 @@ final class Config #[Assert\Collection( allowExtraFields: false, fields: [ + 'extra_databases' => new Assert\Optional([ + new Assert\Type('array'), + new Assert\All([ + new Assert\Type('string'), + ]), + ]), 'type' => new Assert\Required([ new Assert\Choice(choices: ['mariadb', 'mysql']), new Assert\Type('string'), @@ -55,6 +61,12 @@ final class Config new Assert\Type('string'), ]), ]), + 'extra_directories' => new Assert\Optional([ + new Assert\Type('array'), + new Assert\All([ + new Assert\Type('string'), + ]), + ]), 'extends' => new Assert\Optional([ new Assert\Type('string'), ]), @@ -161,13 +173,8 @@ final class Config #[Assert\Collection( allowExtraFields: false, fields: [ - 'type' => new Assert\Required([ - new Assert\Type('array'), - new Assert\Collection([ - 'type' => new Assert\Required([ - new Assert\Type('string'), - ]), - ]), + 'version' => new Assert\Required([ + new Assert\Type('string'), ]), ], )] @@ -182,37 +189,53 @@ final class Config new Assert\Type('string'), ]), 'phpcs' => new Assert\Optional([ - new Assert\Collection([ - 'paths' => new Assert\Required([ - new Assert\Type('array'), - new Assert\Count(['min' => 1]), - new Assert\All([ - new Assert\Type('string'), + new Assert\AtLeastOneOf( + constraints: [ + new Assert\IsFalse(), + new Assert\Collection([ + 'paths' => new Assert\Required([ + new Assert\Type('array'), + new Assert\Count(['min' => 1]), + new Assert\All([ + new Assert\Type('string'), + ]), + ]), + 'standards' => new Assert\Required([ + new Assert\Type('array'), + new Assert\Count(['min' => 1]), + new Assert\All([ + new Assert\Type('string'), + ]), + ]), ]), - ]), - 'standards' => new Assert\Required([ - new Assert\Type('array'), - new Assert\Count(['min' => 1]), - new Assert\All([ - new Assert\Type('string'), - ]), - ]), - ]), + ] + ), ]), - 'phpstan' => new Assert\Optional([ - new Assert\Collection([ - 'level' => new Assert\Required([ - new Assert\Type(['string', 'integer']), - ]), - 'paths' => new Assert\Required([ - new Assert\Type('array'), - new Assert\Count(['min' => 1]), - new Assert\All([ - new Assert\Type('string'), + 'phpstan' => new Assert\Optional( + new Assert\AtLeastOneOf( + constraints: [ + new Assert\IsFalse(), + new Assert\Collection([ + 'baseline' => new Assert\Optional([ + new Assert\Type('boolean'), + ]), + 'level' => new Assert\Required([ + new Assert\Type(['string', 'integer']), + ]), + 'paths' => new Assert\Required([ + new Assert\Type('array'), + new Assert\Count(['min' => 1]), + new Assert\All([ + new Assert\Type('string'), + ]), + ]), ]), - ]), - ]), - ]), + ] + ), + ), + 'phpunit' => new Assert\Optional( + new Assert\IsFalse(), + ), ], )] public array $php;