From d093c1387d5d189ebae1d6a68e88108bbc0110e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilsen=20Hern=C3=A1ndez?= <13445515+wilsenhc@users.noreply.github.com> Date: Tue, 27 Sep 2022 22:28:30 -0400 Subject: [PATCH] [3.x] Add Vite helper for tenancy (#956) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add Vite helper for tenancy * Move Vite bundler to an Optional Feature * Rename to foundation vite * Add ViteBundlerTest * Add missing end of file * Update tests * remove unnecessary end() call Co-authored-by: Samuel Ć tancl --- assets/config.php | 1 + src/Features/ViteBundler.php | 21 ++++++++++++++++++++ src/TenancyServiceProvider.php | 1 + src/Vite.php | 20 +++++++++++++++++++ tests/Features/ViteBundlerTest.php | 32 ++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 src/Features/ViteBundler.php create mode 100644 src/Vite.php create mode 100644 tests/Features/ViteBundlerTest.php diff --git a/assets/config.php b/assets/config.php index 891bc64c..b12cd6c4 100644 --- a/assets/config.php +++ b/assets/config.php @@ -168,6 +168,7 @@ return [ // Stancl\Tenancy\Features\UniversalRoutes::class, // Stancl\Tenancy\Features\TenantConfig::class, // https://tenancyforlaravel.com/docs/v3/features/tenant-config // Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancyforlaravel.com/docs/v3/features/cross-domain-redirect + // Stancl\Tenancy\Features\ViteBundler::class, ], /** diff --git a/src/Features/ViteBundler.php b/src/Features/ViteBundler.php new file mode 100644 index 00000000..76b96a48 --- /dev/null +++ b/src/Features/ViteBundler.php @@ -0,0 +1,21 @@ +app->singleton(FoundationVite::class, StanclVite::class); + } +} diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index 4faaccf3..dec8c72e 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -65,6 +65,7 @@ class TenancyServiceProvider extends ServiceProvider $this->app->singleton(Commands\Rollback::class, function ($app) { return new Commands\Rollback($app['migrator']); }); + $this->app->singleton(Commands\Seed::class, function ($app) { return new Commands\Seed($app['db']); }); diff --git a/src/Vite.php b/src/Vite.php new file mode 100644 index 00000000..2598a2e4 --- /dev/null +++ b/src/Vite.php @@ -0,0 +1,20 @@ +toBeInstanceOf(FoundationVite::class); + + expect($vite)->not->toBeInstanceOf(StanclVite::class); + + config([ + 'tenancy.features' => [ViteBundler::class], + ]); + + $tenant = Tenant::create(); + + tenancy()->initialize($tenant); + + app()->forgetInstance(\Illuminate\Foundation\Vite::class); + + $vite = app(\Illuminate\Foundation\Vite::class); + + expect($vite)->toBeInstanceOf(StanclVite::class); +});