From 33d804a34eef356c58bb9c79c4bad26054389c5a Mon Sep 17 00:00:00 2001 From: Roberto B Date: Sat, 10 Apr 2021 10:09:33 +0200 Subject: [PATCH 1/3] checkDebugEnv Check Debug and env following : https://laravel.com/docs/8.x/configuration#debug-mode --- src/Lens/Traits/ConfigLens.php | 26 ++++++++++++++++++++++++++ tests/ConsistencyTest.php | 19 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/Lens/Traits/ConfigLens.php b/src/Lens/Traits/ConfigLens.php index 8620fab..a0e48de 100644 --- a/src/Lens/Traits/ConfigLens.php +++ b/src/Lens/Traits/ConfigLens.php @@ -28,6 +28,31 @@ public function getConfigsDatabaseFromEnv(ResultLens $results = null) return $results; } + public function checkDebugEnv(ResultLens $results = null) + { + if (is_null($results)) { + $results = new ResultLens(); + } + $debug = config("app.debug"); + $env = config("app.env"); + $results->add( + "ENV", + $env + ); + $results->add( + "DEBUG", + $debug + ); + if ($debug && $env === "production") { + $this->checksBag->addWarningAndHint( + "Check config ENV and DEBUG", + "You have DEBUG mode in Production.", + "Change you APP_DEBUG env parameter to false for Production environments" + ); + } + return $results; + } + public function getConfigsDatabase(ResultLens $results = null) { if (is_null($results)) { @@ -70,6 +95,7 @@ public function getConfigs() config($value) ); } + $results = $this->checkDebugEnv($results); $results = $this->getConfigsDatabase($results); return $results; } diff --git a/tests/ConsistencyTest.php b/tests/ConsistencyTest.php index 7b7ee83..2b07d71 100644 --- a/tests/ConsistencyTest.php +++ b/tests/ConsistencyTest.php @@ -3,6 +3,7 @@ namespace HiFolks\LaraLens\Tests; use HiFolks\LaraLens\Lens\LaraLens; +use Illuminate\Support\Facades\Config; use Orchestra\Testbench\TestCase; use HiFolks\LaraLens\LaraLensServiceProvider; use Illuminate\Support\Facades\Http; @@ -21,7 +22,23 @@ public function test_config_array() $l = new LaraLens(); $a = $l->getConfigs(); $this->assertIsArray($a->toArray()); - $this->assertCount(12, $a->toArray()); + $this->assertCount(14, $a->toArray()); + $arrayChecks = $l->checksBag->toArray(); + + $this->assertCount(0, $arrayChecks, "test check config length 0"); + + $l = new LaraLens(); + $a = $l->getConfigs(); + config(['app.debug' => true]); + config(['app.env' => "production"]); + $l = new LaraLens(); + $a = $l->getConfigs(); + $arrayChecks = $l->checksBag->toArray(); + + // 2 = 1 for the warning , 1 for the hint + $this->assertCount(2, $arrayChecks); + + } /** @test */ From 3b9e30b269de4ee971be322a3463ce6a5827f0d7 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Sat, 10 Apr 2021 14:03:01 +0200 Subject: [PATCH 2/3] v0.2.3 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee93df8..78e0b27 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.2.3 - WIP +### Add +- Check DEBUG and ENV configuration for production (if production avoid having debug on); +- Check Storage Links and sohw the user a waring if some directory links are missing + +### Change +- improve tests and checks script for Workflows + ## 0.2.2 - 2020-11-05 ### Add - Add configuration parameters (config/lara-lens.php) for managing webview: LARALENS_PREFIX, LARALENS_MIDDLEWARE, LARALENS_WEB_ENABLED, thanks to @yogendra-revanna, @JexPY, @Zuruckt; From c93d9c31044963297da6404d8c8dc9f59e3544cb Mon Sep 17 00:00:00 2001 From: Roberto B Date: Sat, 10 Apr 2021 22:02:44 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78e0b27..75d5768 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 0.2.3 - WIP +## 0.2.3 - 2021-04-10 ### Add - Check DEBUG and ENV configuration for production (if production avoid having debug on); - Check Storage Links and sohw the user a waring if some directory links are missing