From 04ad3e1eb985e7e2a8d551824ce12972e6904524 Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Fri, 18 Aug 2023 17:46:03 +0530 Subject: [PATCH] ACMS-1925: Add starter kit validation and used json validator library. --- acms/schema.json | 33 +++ acms/starterkit.schema.yml | 33 --- composer.json | 1 + composer.lock | 322 ++++++++++++------------ src/Cli.php | 4 +- src/Validation/StarterKitValidation.php | 60 +---- tests/unit/CliTest.php | 4 +- 7 files changed, 212 insertions(+), 245 deletions(-) create mode 100644 acms/schema.json delete mode 100644 acms/starterkit.schema.yml diff --git a/acms/schema.json b/acms/schema.json new file mode 100644 index 00000000..6ddc84e9 --- /dev/null +++ b/acms/schema.json @@ -0,0 +1,33 @@ +{ + "type": "array", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "modules": { + "type": "array", + "properties": { + "require": { + "type": "array" + }, + "install": { + "type": "array" + } + } + }, + "themes": { + "type": "array", + "properties": { + "require": { + "type": "array" + }, + "install": { + "type": "array" + } + } + } + } +} diff --git a/acms/starterkit.schema.yml b/acms/starterkit.schema.yml deleted file mode 100644 index 97c37093..00000000 --- a/acms/starterkit.schema.yml +++ /dev/null @@ -1,33 +0,0 @@ -starterkit: - name: - type: strings - is_required: TRUE - description: - type: strings - is_required: TRUE - modules: - type: arrays - is_required: FALSE - next_level_validation: TRUE - require: - type: arrays - is_required: FALSE - install: - type: arrays - is_required: FALSE - themes: - type: arrays - is_required: FALSE - next_level_validation: TRUE - require: - type: arrays - is_required: FALSE - install: - type: arrays - is_required: FALSE - admin: - type: strings - is_required: FALSE - default: - type: strings - is_required: FALSE diff --git a/composer.json b/composer.json index 03aaaa3c..d1576946 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "require": { "acquia/drupal-environment-detector": "^1.4", "composer/composer": "^2.2", + "justinrainbow/json-schema": "^5.2", "stecman/symfony-console-completion": "^0.11.0 || ^0.12.1", "symfony/config": "^4.4 || ^5 || ^6", "symfony/console": "^4.4 || ^5 || ^6", diff --git a/composer.lock b/composer.lock index 40a1f286..4db81532 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7a04ff8133a485032d5fcbad91a1671f", + "content-hash": "3b530a1a4b552466b342395f10e5a151", "packages": [ { "name": "acquia/drupal-environment-detector", @@ -137,22 +137,22 @@ }, { "name": "composer/class-map-generator", - "version": "1.0.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/composer/class-map-generator.git", - "reference": "1e1cb2b791facb2dfe32932a7718cf2571187513" + "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/1e1cb2b791facb2dfe32932a7718cf2571187513", - "reference": "1e1cb2b791facb2dfe32932a7718cf2571187513", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/953cc4ea32e0c31f2185549c7d216d7921f03da9", + "reference": "953cc4ea32e0c31f2185549c7d216d7921f03da9", "shasum": "" }, "require": { - "composer/pcre": "^2 || ^3", + "composer/pcre": "^2.1 || ^3.1", "php": "^7.2 || ^8.0", - "symfony/finder": "^4.4 || ^5.3 || ^6" + "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" }, "require-dev": { "phpstan/phpstan": "^1.6", @@ -190,7 +190,7 @@ ], "support": { "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.0.0" + "source": "https://github.com/composer/class-map-generator/tree/1.1.0" }, "funding": [ { @@ -206,7 +206,7 @@ "type": "tidelift" } ], - "time": "2022-06-19T11:31:27+00:00" + "time": "2023-06-30T13:58:57+00:00" }, { "name": "composer/composer", @@ -1208,16 +1208,16 @@ }, { "name": "symfony/config", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "a5e00dec161b08c946a2c16eed02adbeedf827ae" + "reference": "b47ca238b03e7b0d7880ffd1cf06e8d637ca1467" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a5e00dec161b08c946a2c16eed02adbeedf827ae", - "reference": "a5e00dec161b08c946a2c16eed02adbeedf827ae", + "url": "https://api.github.com/repos/symfony/config/zipball/b47ca238b03e7b0d7880ffd1cf06e8d637ca1467", + "reference": "b47ca238b03e7b0d7880ffd1cf06e8d637ca1467", "shasum": "" }, "require": { @@ -1263,7 +1263,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v6.3.0" + "source": "https://github.com/symfony/config/tree/v6.3.2" }, "funding": [ { @@ -1279,20 +1279,20 @@ "type": "tidelift" } ], - "time": "2023-04-25T10:46:17+00:00" + "time": "2023-07-19T20:22:16+00:00" }, { "name": "symfony/console", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7" + "reference": "aa5d64ad3f63f2e48964fc81ee45cb318a723898" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7", - "reference": "8788808b07cf0bdd6e4b7fdd23d8ddb1470c83b7", + "url": "https://api.github.com/repos/symfony/console/zipball/aa5d64ad3f63f2e48964fc81ee45cb318a723898", + "reference": "aa5d64ad3f63f2e48964fc81ee45cb318a723898", "shasum": "" }, "require": { @@ -1353,7 +1353,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.3.0" + "source": "https://github.com/symfony/console/tree/v6.3.2" }, "funding": [ { @@ -1369,20 +1369,20 @@ "type": "tidelift" } ], - "time": "2023-05-29T12:49:39+00:00" + "time": "2023-07-19T20:17:28+00:00" }, { "name": "symfony/dependency-injection", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "ebf5f9c5bb5c21d75ab74995ce5e26c3fbbda44d" + "reference": "474cfbc46aba85a1ca11a27db684480d0db64ba7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ebf5f9c5bb5c21d75ab74995ce5e26c3fbbda44d", - "reference": "ebf5f9c5bb5c21d75ab74995ce5e26c3fbbda44d", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/474cfbc46aba85a1ca11a27db684480d0db64ba7", + "reference": "474cfbc46aba85a1ca11a27db684480d0db64ba7", "shasum": "" }, "require": { @@ -1434,7 +1434,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v6.3.0" + "source": "https://github.com/symfony/dependency-injection/tree/v6.3.2" }, "funding": [ { @@ -1450,7 +1450,7 @@ "type": "tidelift" } ], - "time": "2023-05-30T17:12:32+00:00" + "time": "2023-07-19T20:17:28+00:00" }, { "name": "symfony/deprecation-contracts", @@ -1521,16 +1521,16 @@ }, { "name": "symfony/error-handler", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/error-handler.git", - "reference": "99d2d814a6351461af350ead4d963bd67451236f" + "reference": "85fd65ed295c4078367c784e8a5a6cee30348b7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/error-handler/zipball/99d2d814a6351461af350ead4d963bd67451236f", - "reference": "99d2d814a6351461af350ead4d963bd67451236f", + "url": "https://api.github.com/repos/symfony/error-handler/zipball/85fd65ed295c4078367c784e8a5a6cee30348b7a", + "reference": "85fd65ed295c4078367c784e8a5a6cee30348b7a", "shasum": "" }, "require": { @@ -1575,7 +1575,7 @@ "description": "Provides tools to manage errors and ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/error-handler/tree/v6.3.0" + "source": "https://github.com/symfony/error-handler/tree/v6.3.2" }, "funding": [ { @@ -1591,20 +1591,20 @@ "type": "tidelift" } ], - "time": "2023-05-10T12:03:13+00:00" + "time": "2023-07-16T17:05:46+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "3af8ac1a3f98f6dbc55e10ae59c9e44bfc38dfaa" + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/3af8ac1a3f98f6dbc55e10ae59c9e44bfc38dfaa", - "reference": "3af8ac1a3f98f6dbc55e10ae59c9e44bfc38dfaa", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e", "shasum": "" }, "require": { @@ -1655,7 +1655,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2" }, "funding": [ { @@ -1671,7 +1671,7 @@ "type": "tidelift" } ], - "time": "2023-04-21T14:41:17+00:00" + "time": "2023-07-06T06:56:43+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -1751,16 +1751,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.3.0", + "version": "v6.3.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "97b698e1d77d356304def77a8d0cd73090b359ea" + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/97b698e1d77d356304def77a8d0cd73090b359ea", - "reference": "97b698e1d77d356304def77a8d0cd73090b359ea", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", "shasum": "" }, "require": { @@ -1794,7 +1794,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.3.0" + "source": "https://github.com/symfony/filesystem/tree/v6.3.1" }, "funding": [ { @@ -1810,20 +1810,20 @@ "type": "tidelift" } ], - "time": "2023-05-30T17:12:32+00:00" + "time": "2023-06-01T08:30:39+00:00" }, { "name": "symfony/finder", - "version": "v6.3.0", + "version": "v6.3.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2" + "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/d9b01ba073c44cef617c7907ce2419f8d00d75e2", - "reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2", + "url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e", "shasum": "" }, "require": { @@ -1858,7 +1858,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.3.0" + "source": "https://github.com/symfony/finder/tree/v6.3.3" }, "funding": [ { @@ -1874,20 +1874,20 @@ "type": "tidelift" } ], - "time": "2023-04-02T01:25:41+00:00" + "time": "2023-07-31T08:31:44+00:00" }, { "name": "symfony/http-client", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "b2f892c91e4e02a939edddeb7ef452522d10a424" + "reference": "15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/b2f892c91e4e02a939edddeb7ef452522d10a424", - "reference": "b2f892c91e4e02a939edddeb7ef452522d10a424", + "url": "https://api.github.com/repos/symfony/http-client/zipball/15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00", + "reference": "15f9f4bad62bfcbe48b5dedd866f04a08fc7ff00", "shasum": "" }, "require": { @@ -1950,7 +1950,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v6.3.0" + "source": "https://github.com/symfony/http-client/tree/v6.3.2" }, "funding": [ { @@ -1966,7 +1966,7 @@ "type": "tidelift" } ], - "time": "2023-05-12T08:49:48+00:00" + "time": "2023-07-05T08:41:27+00:00" }, { "name": "symfony/http-client-contracts", @@ -2048,16 +2048,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "718a97ed430d34e5c568ea2c44eab708c6efbefb" + "reference": "43ed99d30f5f466ffa00bdac3f5f7aa9cd7617c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/718a97ed430d34e5c568ea2c44eab708c6efbefb", - "reference": "718a97ed430d34e5c568ea2c44eab708c6efbefb", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/43ed99d30f5f466ffa00bdac3f5f7aa9cd7617c3", + "reference": "43ed99d30f5f466ffa00bdac3f5f7aa9cd7617c3", "shasum": "" }, "require": { @@ -2105,7 +2105,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.3.0" + "source": "https://github.com/symfony/http-foundation/tree/v6.3.2" }, "funding": [ { @@ -2121,20 +2121,20 @@ "type": "tidelift" } ], - "time": "2023-05-19T12:46:45+00:00" + "time": "2023-07-23T21:58:39+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.3.0", + "version": "v6.3.3", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "241973f3dd900620b1ca052fe409144f11aea748" + "reference": "d3b567f0addf695e10b0c6d57564a9bea2e058ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/241973f3dd900620b1ca052fe409144f11aea748", - "reference": "241973f3dd900620b1ca052fe409144f11aea748", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/d3b567f0addf695e10b0c6d57564a9bea2e058ee", + "reference": "d3b567f0addf695e10b0c6d57564a9bea2e058ee", "shasum": "" }, "require": { @@ -2218,7 +2218,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.3.0" + "source": "https://github.com/symfony/http-kernel/tree/v6.3.3" }, "funding": [ { @@ -2234,7 +2234,7 @@ "type": "tidelift" } ], - "time": "2023-05-30T19:03:32+00:00" + "time": "2023-07-31T10:33:00+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2886,16 +2886,16 @@ }, { "name": "symfony/process", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628" + "reference": "c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/8741e3ed7fe2e91ec099e02446fb86667a0f1628", - "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628", + "url": "https://api.github.com/repos/symfony/process/zipball/c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d", + "reference": "c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d", "shasum": "" }, "require": { @@ -2927,7 +2927,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.3.0" + "source": "https://github.com/symfony/process/tree/v6.3.2" }, "funding": [ { @@ -2943,7 +2943,7 @@ "type": "tidelift" } ], - "time": "2023-05-19T08:06:44+00:00" + "time": "2023-07-12T16:00:22+00:00" }, { "name": "symfony/service-contracts", @@ -3029,16 +3029,16 @@ }, { "name": "symfony/string", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "f2e190ee75ff0f5eced645ec0be5c66fac81f51f" + "reference": "53d1a83225002635bca3482fcbf963001313fb68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/f2e190ee75ff0f5eced645ec0be5c66fac81f51f", - "reference": "f2e190ee75ff0f5eced645ec0be5c66fac81f51f", + "url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68", + "reference": "53d1a83225002635bca3482fcbf963001313fb68", "shasum": "" }, "require": { @@ -3095,7 +3095,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.0" + "source": "https://github.com/symfony/string/tree/v6.3.2" }, "funding": [ { @@ -3111,24 +3111,25 @@ "type": "tidelift" } ], - "time": "2023-03-21T21:06:29+00:00" + "time": "2023-07-05T08:41:27+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.3.0", + "version": "v6.3.3", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "6acdcd5c122074ee9f7b051e4fb177025c277a0e" + "reference": "77fb4f2927f6991a9843633925d111147449ee7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/6acdcd5c122074ee9f7b051e4fb177025c277a0e", - "reference": "6acdcd5c122074ee9f7b051e4fb177025c277a0e", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/77fb4f2927f6991a9843633925d111147449ee7a", + "reference": "77fb4f2927f6991a9843633925d111147449ee7a", "shasum": "" }, "require": { "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { @@ -3137,6 +3138,7 @@ "require-dev": { "ext-iconv": "*", "symfony/console": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", "symfony/process": "^5.4|^6.0", "symfony/uid": "^5.4|^6.0", "twig/twig": "^2.13|^3.0.4" @@ -3177,7 +3179,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.3.0" + "source": "https://github.com/symfony/var-dumper/tree/v6.3.3" }, "funding": [ { @@ -3193,20 +3195,20 @@ "type": "tidelift" } ], - "time": "2023-05-25T13:09:35+00:00" + "time": "2023-07-31T07:08:24+00:00" }, { "name": "symfony/var-exporter", - "version": "v6.3.0", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "db5416d04269f2827d8c54331ba4cfa42620d350" + "reference": "3400949782c0cb5b3e73aa64cfd71dde000beccc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/db5416d04269f2827d8c54331ba4cfa42620d350", - "reference": "db5416d04269f2827d8c54331ba4cfa42620d350", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/3400949782c0cb5b3e73aa64cfd71dde000beccc", + "reference": "3400949782c0cb5b3e73aa64cfd71dde000beccc", "shasum": "" }, "require": { @@ -3251,7 +3253,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v6.3.0" + "source": "https://github.com/symfony/var-exporter/tree/v6.3.2" }, "funding": [ { @@ -3267,24 +3269,25 @@ "type": "tidelift" } ], - "time": "2023-04-21T08:48:44+00:00" + "time": "2023-07-26T17:39:03+00:00" }, { "name": "symfony/yaml", - "version": "v6.3.0", + "version": "v6.3.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "a9a8337aa641ef2aa39c3e028f9107ec391e5927" + "reference": "e23292e8c07c85b971b44c1c4b87af52133e2add" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/a9a8337aa641ef2aa39c3e028f9107ec391e5927", - "reference": "a9a8337aa641ef2aa39c3e028f9107ec391e5927", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e23292e8c07c85b971b44c1c4b87af52133e2add", + "reference": "e23292e8c07c85b971b44c1c4b87af52133e2add", "shasum": "" }, "require": { "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -3322,7 +3325,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.3.0" + "source": "https://github.com/symfony/yaml/tree/v6.3.3" }, "funding": [ { @@ -3338,7 +3341,7 @@ "type": "tidelift" } ], - "time": "2023-04-28T13:28:14+00:00" + "time": "2023-07-31T07:08:24+00:00" } ], "packages-dev": [ @@ -3595,16 +3598,16 @@ }, { "name": "drupal/coder", - "version": "8.3.20", + "version": "8.3.21", "source": { "type": "git", "url": "https://github.com/pfrenssen/coder.git", - "reference": "88055e40931a56074b6510a631d3403794c91625" + "reference": "a0b76c6c8ea277b07d58fa75dcacf102a203ad51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pfrenssen/coder/zipball/88055e40931a56074b6510a631d3403794c91625", - "reference": "88055e40931a56074b6510a631d3403794c91625", + "url": "https://api.github.com/repos/pfrenssen/coder/zipball/a0b76c6c8ea277b07d58fa75dcacf102a203ad51", + "reference": "a0b76c6c8ea277b07d58fa75dcacf102a203ad51", "shasum": "" }, "require": { @@ -3642,7 +3645,7 @@ "issues": "https://www.drupal.org/project/issues/coder", "source": "https://www.drupal.org/project/coder" }, - "time": "2023-06-15T07:16:09+00:00" + "time": "2023-07-17T15:36:49+00:00" }, { "name": "ergebnis/composer-normalize", @@ -3973,16 +3976,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.5", + "version": "v4.17.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e" + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/11e2663a5bc9db5d714eedb4277ee300403b4a9e", - "reference": "11e2663a5bc9db5d714eedb4277ee300403b4a9e", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", "shasum": "" }, "require": { @@ -4023,9 +4026,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.5" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" }, - "time": "2023-05-19T20:20:00+00:00" + "time": "2023-08-13T19:53:39+00:00" }, { "name": "phar-io/manifest", @@ -4312,16 +4315,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.2", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "shasum": "" }, "require": { @@ -4364,9 +4367,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" }, - "time": "2023-05-30T18:13:47+00:00" + "time": "2023-08-12T11:01:26+00:00" }, { "name": "phpro/grumphp-shim", @@ -4549,16 +4552,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.22.0", + "version": "1.23.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c" + "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ec58baf7b3c7f1c81b3b00617c953249fb8cf30c", - "reference": "ec58baf7b3c7f1c81b3b00617c953249fb8cf30c", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", + "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", "shasum": "" }, "require": { @@ -4590,22 +4593,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" }, - "time": "2023-06-01T12:35:21+00:00" + "time": "2023-08-03T16:32:59+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.21", + "version": "1.10.29", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5" + "reference": "ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1", + "reference": "ee5d8f2d3977fb09e55603eee6fb53bdd76ee9c1", "shasum": "" }, "require": { @@ -4654,20 +4657,20 @@ "type": "tidelift" } ], - "time": "2023-06-21T20:07:58+00:00" + "time": "2023-08-14T13:24:11+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.26", + "version": "9.2.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1" + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", - "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", + "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", "shasum": "" }, "require": { @@ -4723,7 +4726,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.26" + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" }, "funding": [ { @@ -4731,7 +4735,7 @@ "type": "github" } ], - "time": "2023-03-06T12:58:08+00:00" + "time": "2023-07-26T13:44:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4976,16 +4980,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.9", + "version": "9.6.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a9aceaf20a682aeacf28d582654a1670d8826778" + "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a9aceaf20a682aeacf28d582654a1670d8826778", - "reference": "a9aceaf20a682aeacf28d582654a1670d8826778", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a6d351645c3fe5a30f5e86be6577d946af65a328", + "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328", "shasum": "" }, "require": { @@ -5059,7 +5063,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.9" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.10" }, "funding": [ { @@ -5075,7 +5079,7 @@ "type": "tidelift" } ], - "time": "2023-06-11T06:13:56+00:00" + "time": "2023-07-10T04:04:23+00:00" }, { "name": "sebastian/cli-parser", @@ -5583,16 +5587,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -5635,7 +5639,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -5643,7 +5647,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -6043,16 +6047,16 @@ }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.16", + "version": "v2.11.17", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "dc5582dc5a93a235557af73e523c389aac9a8e88" + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/dc5582dc5a93a235557af73e523c389aac9a8e88", - "reference": "dc5582dc5a93a235557af73e523c389aac9a8e88", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3b71162a6bf0cde2bff1752e40a1788d8273d049", + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049", "shasum": "" }, "require": { @@ -6097,36 +6101,36 @@ "source": "https://github.com/sirbrillig/phpcs-variable-analysis", "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" }, - "time": "2023-03-31T16:46:32+00:00" + "time": "2023-08-05T23:46:11+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.13.0", + "version": "8.13.4", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "4166003e9ca097a67951ab434f321c90eb621c3e" + "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/4166003e9ca097a67951ab434f321c90eb621c3e", - "reference": "4166003e9ca097a67951ab434f321c90eb621c3e", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/4b2af2fb17773656d02fbfb5d18024ebd19fe322", + "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.22.0", + "phpstan/phpdoc-parser": "^1.23.0", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.21", + "phpstan/phpstan": "1.10.26", "phpstan/phpstan-deprecation-rules": "1.1.3", "phpstan/phpstan-phpunit": "1.3.13", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.2" + "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.6" }, "type": "phpcodesniffer-standard", "extra": { @@ -6150,7 +6154,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.13.0" + "source": "https://github.com/slevomat/coding-standard/tree/8.13.4" }, "funding": [ { @@ -6162,7 +6166,7 @@ "type": "tidelift" } ], - "time": "2023-06-23T08:32:09+00:00" + "time": "2023-07-25T10:28:55+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/src/Cli.php b/src/Cli.php index ff7e8cfc..763a51ad 100644 --- a/src/Cli.php +++ b/src/Cli.php @@ -143,8 +143,8 @@ public function getStarterKits(): array { } // Send each starterkit for validation. - $schema = $this->getAcquiaCmsFile($this->projectDirectory . '/acms/starterkit.schema.yml'); - $this->starterKitValidation->validateStarterKits($schema['starterkit'], $starterkits); + $schema = $this->getAcquiaCmsFile($this->projectDirectory . '/acms/schema.json'); + $this->starterKitValidation->validateStarterKits($schema, $starterkits); // Return starterkit list. return $starterkits; diff --git a/src/Validation/StarterKitValidation.php b/src/Validation/StarterKitValidation.php index b05ec704..f346e082 100644 --- a/src/Validation/StarterKitValidation.php +++ b/src/Validation/StarterKitValidation.php @@ -2,7 +2,7 @@ namespace AcquiaCMS\Cli\Validation; -use AcquiaCMS\Cli\Exception\AcmsCliException; +use JsonSchema\Validator; use Symfony\Component\Console\Output\OutputInterface; /** @@ -38,56 +38,18 @@ public function validateStarterKits(array $schema, array &$starterkits): void { } /** - * Validates array for starter-kit. + * Validates starter-kit. */ - public function validateArray($schema, $starterkit, $key): void { - if ($schema['is_required'] ? - ((!isset($starterkit) || empty($starterkit)) && !is_array($starterkit)) : - (empty($starterkit) || !is_array($starterkit))) { - $required = $schema['is_required'] ? 'is mandatory and ' : ''; - throw new AcmsCliException($this->arrayfield . ' => ' . $key . ' field ' . $required . 'should be in array format, in ' . $this->starterKitName . ' starterkit.'); - } - } - - /** - * Validates string for starter-kit. - */ - public function validateString($schema, $starterkit, $key): void { - if ($schema['is_required'] ? - ((!isset($starterkit) || empty($starterkit)) && !is_string($starterkit)) : - (empty($starterkit) || !is_string($starterkit))) { - $required = $schema['is_required'] ? 'is mandatory and ' : ''; - throw new AcmsCliException($key . ' field ' . $required . 'should be in string format, in starterkit.'); - } - } - - /** - * Validates each key value for starter-kit. - */ - public function validateStarterKit(array $schema, $starterkit): void { - foreach ($schema as $key => $value) { - if ($schema[$key]['type'] == 'arrays' && isset($schema[$key]['next_level_validation'])) { - unset($schema[$key]['type']); - unset($schema[$key]['is_required']); - unset($schema[$key]['next_level_validation']); - $this->validateArray($schema[$key], $starterkit[$key], $key); - $this->validateStarterKit($schema[$key], $starterkit[$key]); - } - else { - switch ($schema[$key]['type']) { - case 'arrays': - $this->validateArray($schema[$key], $starterkit[$key], $key); - break; - - case 'strings': - $this->arrayfield = ''; - $this->validateString($schema[$key], $starterkit[$key], $key); - break; - - case 'default': - throw new AcmsCliException('starterkit is not defined properly kindly fix your acms.yml file.'); - } + public function validateStarterKit(array $schema, array $starterkit): void { + $validator = new Validator(); + $validator->validate($starterkit, $schema); + if (!$validator->isValid()) { + $errors = []; + foreach ($validator->getErrors() as $key => $error) { + $errors[] = "Property " . $error['property'] . " " . $error['constraint'] . " " . $error['message']; + $this->output->writeln("" . $errors[$key] . ""); } + exit; } } diff --git a/tests/unit/CliTest.php b/tests/unit/CliTest.php index 8049aee5..ec877a21 100644 --- a/tests/unit/CliTest.php +++ b/tests/unit/CliTest.php @@ -75,8 +75,8 @@ public function testExecute() :void { * Tests starter-kit validation. */ public function testValidateStarterKit(): void { - $starterKits = $this->getAcmsFileContents()['starter_kits']; - $schema = $this->acquiaCli->getAcquiaCmsFile($this->projectDirectory . '/acms/starterkit.schema.yml'); + $starterKits = $this->getAcmsFileContents(); + $schema = $this->acquiaCli->getAcquiaCmsFile($this->projectDirectory . '/acms/schema.json'); $this->starterKitValidation->validateStarterKits($schema, $starterKits); $this->assertIsArray($starterKits); }