From fef2e27b2bcc155503b7c994d9bca4a196638cb7 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Thu, 1 Jul 2021 08:31:52 -0400 Subject: [PATCH] Composer versions (#72) * [MixerApi] load MixerApi/Bake as dev dependency only * [MixerApi] load MixerApi/Bake as dev dependency only * ignore code coverage * modifying composer versions * updates composer files, use tilda operator when possible --- composer.json | 46 ++++++++++------------------------------------ src/Plugin.php | 9 ++++++++- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/composer.json b/composer.json index 4cea5f1..21efe67 100644 --- a/composer.json +++ b/composer.json @@ -7,47 +7,20 @@ "require": { "php": ">=7.2", "cakephp/cakephp": "~4.0", - "cnizzardini/cakephp-swagger-bake": "^1.0", - "friendsofcake/search": "^6.0", - "mixerapi/bake": "^0.2", - "mixerapi/collection-view": "^0.2", - "mixerapi/core": "^0.2", - "mixerapi/exception-render": "^0.2", - "mixerapi/hal-view": "^0.2", - "mixerapi/json-ld-view": "^0.2", - "mixerapi/rest": "^0.2" - }, - "require-dev": { - "phpunit/phpunit": "~8.5.0", - "cakephp/cakephp-codesniffer": "^4.2", - "phpstan/phpstan": "^0.12.32", - "phpmd/phpmd": "^2.8" + "cnizzardini/cakephp-swagger-bake": "~1.0", + "mixerapi/bake": "~0.2", + "mixerapi/collection-view": "~0.2", + "mixerapi/core": "~0.2", + "mixerapi/exception-render": "~0.2", + "mixerapi/hal-view": "~0.2", + "mixerapi/json-ld-view": "~0.2", + "mixerapi/rest": "~0.2" }, "autoload": { "psr-4": { "MixerApi\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "MixerApi\\Test\\": "tests/", - "MixerApi\\Test\\App\\": "tests/test_app/src" - } - }, - "scripts": { - "check": [ - "@test", - "@cs-check", - "@stan", - "@md" - ], - "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/", - "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/", - "stan": "phpstan analyse src/", - "test": "phpunit --colors=always", - "md": "phpmd src/ ansi phpmd.xml", - "coverage": "phpunit --coverage-html coverage-reports/" - }, "support": { "source": "https://github.com/mixerapi/mixerapi" }, @@ -58,7 +31,8 @@ } ], "suggest": { - "cnizzardini/cakephp-preloader": "An OpCache preloader for php >= 7.4 cakephp projects" + "cnizzardini/cakephp-preloader": "An OpCache preloader for php >= 7.4 cakephp projects", + "friendsofcake/search": "Search provides a simple interface to create paginate-able filters for your project" }, "prefer-stable": true, "minimum_stability": "dev" diff --git a/src/Plugin.php b/src/Plugin.php index e15fab2..8334ac3 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -5,6 +5,7 @@ use Cake\Console\CommandCollection; use Cake\Core\BasePlugin; +use Cake\Core\Exception\MissingPluginException; use Cake\Core\PluginApplicationInterface; use MixerApi\Command\InstallCommand; @@ -25,7 +26,13 @@ public function bootstrap(PluginApplicationInterface $app): void $app->addPlugin('SwaggerBake'); if (PHP_SAPI === 'cli') { - $app->addPlugin('MixerApi/Bake'); + try { + $app->addPlugin('MixerApi/Bake'); + // @codeCoverageIgnoreStart + } catch (MissingPluginException $e) { + // Do not halt if the plugin is missing + } + // @codeCoverageIgnoreEnd } parent::bootstrap($app);