From 8df57a6aa0f8d8928dc78be14f5d5834be0d7ed4 Mon Sep 17 00:00:00 2001 From: Vladislav Stoitsov Date: Tue, 2 Aug 2022 17:40:24 +0300 Subject: [PATCH] v0.1.0 First release --- composer.json | 13 +++++++-- config/blade-crawler-detect.php | 6 ---- database/factories/ModelFactory.php | 19 ------------ ...create_blade_crawler_detect_table.php.stub | 19 ------------ resources/views/.gitkeep | 0 src/LaravelBladeCrawlerDetect.php | 7 ----- ...ravelBladeCrawlerDetectServiceProvider.php | 29 ++++++++++++------- tests/ExampleTest.php | 8 +++-- 8 files changed, 34 insertions(+), 67 deletions(-) delete mode 100644 config/blade-crawler-detect.php delete mode 100644 database/factories/ModelFactory.php delete mode 100644 database/migrations/create_blade_crawler_detect_table.php.stub delete mode 100644 resources/views/.gitkeep delete mode 100755 src/LaravelBladeCrawlerDetect.php diff --git a/composer.json b/composer.json index a5d45e9..dcc61a8 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,9 @@ ], "require": { "php": "^8.1", - "spatie/laravel-package-tools": "^1.9.2", - "illuminate/contracts": "^9.0" + "illuminate/contracts": "^9.0", + "jaybizzle/crawler-detect": "^1.2", + "spatie/laravel-package-tools": "^1.9.2" }, "require-dev": { "laravel/pint": "^1.0", @@ -43,7 +44,13 @@ "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", - "format": "vendor/bin/pint" + "format": "vendor/bin/pint", + "post-autoload-dump": [ + "@php artisan view:clear" + ], + "post-update-cmd": [ + "@php artisan view:clear" + ] }, "config": { "sort-packages": true, diff --git a/config/blade-crawler-detect.php b/config/blade-crawler-detect.php deleted file mode 100644 index 4290f8c..0000000 --- a/config/blade-crawler-detect.php +++ /dev/null @@ -1,6 +0,0 @@ -id(); - - // add fields - - $table->timestamps(); - }); - } -}; diff --git a/resources/views/.gitkeep b/resources/views/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/LaravelBladeCrawlerDetect.php b/src/LaravelBladeCrawlerDetect.php deleted file mode 100755 index 0db529e..0000000 --- a/src/LaravelBladeCrawlerDetect.php +++ /dev/null @@ -1,7 +0,0 @@ -app->singleton('CrawlerDetect', function () { + return new \Jaybizzle\CrawlerDetect\CrawlerDetect(); + }); + } + + public function packageBooted() + { + Blade::if('user', function () { + return !app(CrawlerDetect::class)->isCrawler(); + }); + } + public function configurePackage(Package $package): void { - /* - * This class is a Package Service Provider - * - * More info: https://github.com/spatie/laravel-package-tools - */ $package - ->name('laravel-blade-crawler-detect') - ->hasConfigFile() - ->hasViews() - ->hasMigration('create_laravel-blade-crawler-detect_table') - ->hasCommand(LaravelBladeCrawlerDetectCommand::class); + ->name('laravel-blade-crawler-detect'); } } diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index 5d36321..7a8ef04 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -1,5 +1,9 @@ toBeTrue(); +use Illuminate\Support\Facades\Blade; + +it('if directive is compiled', function () { + $bladeSnippet = '@user test @enduser'; + $expectedCode = ' test '; + $this->assertEquals($expectedCode, Blade::compileString($bladeSnippet)); });