From a741be7226f28a62218b70b6bea5c0c19e6430c6 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 4 Aug 2025 11:13:24 +0200 Subject: [PATCH] try to rebuild assets when installing/ updating plugin --- app/Services/Helpers/PluginService.php | 26 ++++++++++++++++++++++++++ vite.config.js | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/Services/Helpers/PluginService.php b/app/Services/Helpers/PluginService.php index 027d173de..770ca5bd5 100644 --- a/app/Services/Helpers/PluginService.php +++ b/app/Services/Helpers/PluginService.php @@ -15,6 +15,7 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Composer; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Process; use Illuminate\Support\ServiceProvider; use Spatie\TemporaryDirectory\TemporaryDirectory; use ZipArchive; @@ -161,6 +162,27 @@ class PluginService } } + public function buildAssets(): bool + { + try { + $result = Process::run('yarn install'); + if ($result->failed()) { + throw new Exception('Could not install dependencies: ' . $result->errorOutput()); + } + + $result = Process::run('yarn build'); + if ($result->failed()) { + throw new Exception('Could not build assets: ' . $result->errorOutput()); + } + + return true; + } catch (Exception $exception) { + report($exception); + } + + return false; + } + public function installPlugin(Plugin $plugin): void { try { @@ -168,6 +190,8 @@ class PluginService $this->runPluginMigrations($plugin); + $this->buildAssets(); + $this->enablePlugin($plugin); } catch (Exception $exception) { report($exception); @@ -185,6 +209,8 @@ class PluginService $this->runPluginMigrations($plugin); + $this->buildAssets(); + cache()->forget("plugins.$plugin->id.update"); } catch (Exception $exception) { report($exception); diff --git a/vite.config.js b/vite.config.js index 78ee0b380..fb5e86baa 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,7 @@ import { defineConfig } from 'vite'; import tailwindcss from '@tailwindcss/vite'; import laravel, { refreshPaths } from 'laravel-vite-plugin'; -import { globSync } from "glob"; +import { globSync } from 'glob'; export default defineConfig({ plugins: [