From 80c7ad45b3e481c85ebe21eae758e07fa0d69be3 Mon Sep 17 00:00:00 2001 From: Devansh Date: Tue, 5 Apr 2022 14:01:22 +0530 Subject: [PATCH] Bagisto Publish Added --- .github/workflows/ci.yml | 2 +- .../src/Console/Commands/BagistoPublish.php | 55 ++++++++++++++++--- .../Core/src/Console/Commands/Install.php | 4 +- public/installer/Seeder.php | 2 +- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 604b5c062..e36754c60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: run: set -e && php artisan db:seed --env=testing - name: Vendor Publish - run: set -e && php artisan vendor:publish --all --force --env=testing + run: set -e && php artisan bagisto:publish --force --env=testing - name: Execute Unit Tests run: set -e && vendor/bin/codecept run unit diff --git a/packages/Webkul/Core/src/Console/Commands/BagistoPublish.php b/packages/Webkul/Core/src/Console/Commands/BagistoPublish.php index 28a7d33ef..f1e1de18e 100644 --- a/packages/Webkul/Core/src/Console/Commands/BagistoPublish.php +++ b/packages/Webkul/Core/src/Console/Commands/BagistoPublish.php @@ -20,6 +20,22 @@ class BagistoPublish extends Command */ protected $description = 'Publish the available assets'; + /** + * List of Bagisto's providers. + * + * @var array + */ + protected $providers = [ + 'Admin' => "Webkul\Admin\Providers\AdminServiceProvider", + 'Booking Product' => "Webkul\BookingProduct\Providers\BookingProductServiceProvider", + 'Core' => "Webkul\Core\Providers\CoreServiceProvider", + 'Product' => "Webkul\Product\Providers\ProductServiceProvider", + 'Shop' => "Webkul\Shop\Providers\ShopServiceProvider", + 'Social' => "Webkul\SocialLogin\Providers\SocialLoginServiceProvider", + 'UI' => "Webkul\Ui\Providers\UiServiceProvider", + 'Velocity' => "Webkul\Velocity\Providers\VelocityServiceProvider", + ]; + /** * Execute the console command. * @@ -27,16 +43,37 @@ class BagistoPublish extends Command */ public function handle() { - $this->callSilent('vendor:publish', [ - '--tag' => 'canvas-config', - '--force' => $this->option('force'), - ]); + $this->publishAllPackages(); + } - $this->callSilent('vendor:publish', [ - '--tag' => 'canvas-assets', - '--force' => true, - ]); + /** + * Publish all packages. + * + * @return void + */ + public function publishAllPackages(): void + { + collect($this->providers)->each(function ($provider, $name) { + $this->publishPackage($provider, $name); + }); + } - $this->info('Publishing complete.'); + /** + * Publish package. + * + * @param string $provider + * @return void + */ + public function publishPackage(string $provider, string $name): void + { + $this->line(''); + $this->line('-----------------------------------------'); + $this->info('Publishing ' . $name); + $this->line('-----------------------------------------'); + + $this->call('vendor:publish', [ + '--provider' => $provider, + '--force' => $this->option('force'), + ]); } } diff --git a/packages/Webkul/Core/src/Console/Commands/Install.php b/packages/Webkul/Core/src/Console/Commands/Install.php index 6ecb34119..9c351f01f 100644 --- a/packages/Webkul/Core/src/Console/Commands/Install.php +++ b/packages/Webkul/Core/src/Console/Commands/Install.php @@ -53,9 +53,9 @@ class Install extends Command $result = $this->call('db:seed'); $this->info($result); - // running `php artisan vendor:publish --all` + // running `php artisan bagisto:publish --force` $this->warn('Step: Publishing assets and configurations...'); - $result = $this->call('vendor:publish', ['--all' => true, '--force' => true]); + $result = $this->call('bagisto:publish', ['--force' => true]); $this->info($result); // running `php artisan storage:link` diff --git a/public/installer/Seeder.php b/public/installer/Seeder.php index aeb1b2bd6..3120f093c 100755 --- a/public/installer/Seeder.php +++ b/public/installer/Seeder.php @@ -14,7 +14,7 @@ $commands = [ ], 'publish' => [ 'key' => 'publish_results', - 'command' => 'cd ../.. && '. $phpbin .' artisan vendor:publish --all --force 2>&1' + 'command' => 'cd ../.. && '. $phpbin .' artisan bagisto:publish --force 2>&1' ], 'storage_link' => [ 'key' => 'storage_link_results',