diff --git a/src/Console/Commands/PresetInstall.php b/src/Console/Commands/PresetInstall.php index 37a0b8b3..31db91e9 100644 --- a/src/Console/Commands/PresetInstall.php +++ b/src/Console/Commands/PresetInstall.php @@ -9,11 +9,13 @@ use TeamTeaTime\Forum\Frontend\Presets\PresetRegistry; use function Laravel\Prompts\{ + alert, confirm, error, info, note, select, + warning, }; class PresetInstall extends Command implements PromptsForMissingInput @@ -77,21 +79,38 @@ public function handle(Filesystem $filesystem) $preset->publish($filesystem); - info("Preset '{$name}' has been copied to your application's resource directory."); + info("Done! Preset '{$name}' has been copied to your application's resource directory."); + + alert("IMPORTANT: Please read the info below as it details manual steps required for the preset to work!"); $requiredPackages = $preset->getRequiredPackages(); if (count($requiredPackages) > 0) { info("This preset requires the following NPM packages:"); foreach ($requiredPackages as $package) { - $this->line(" $package"); + $this->line(" $package"); } info("You can install them with:"); note("npm i " . implode(' ', $requiredPackages)); + + if (in_array("tailwindcss", $requiredPackages) && !file_exists(base_path("tailwind.config.js"))) { + warning("This preset requires Tailwind, but it looks like your app doesn't have a Tailwind configuration. You should set it up either by following the guide at https://tailwindcss.com/docs/guides/laravel or by installing a Laravel starter kit that includes it, such as Laravel Breeze: https://laravel.com/docs/11.x/starter-kits#breeze-and-blade"); + } + } + + $viteInput = $preset->getViteInput(); + + if (count($viteInput) > 0) { + info("This preset requires the following lines need to be added to the Laravel input array in your vite.config.js file:"); + foreach ($viteInput as $input) { + $this->line(" '$input',"); + } + + info("After adding these lines, don't forget to build for production:"); + note("npm run build"); } - info("Finished!"); info("To activate this preset, make sure the package config is published to your app and set the forum.frontend.preset value to '{$preset->getName()}'."); } } diff --git a/src/Frontend/Presets/AbstractPreset.php b/src/Frontend/Presets/AbstractPreset.php index 617194ff..48f771a6 100644 --- a/src/Frontend/Presets/AbstractPreset.php +++ b/src/Frontend/Presets/AbstractPreset.php @@ -25,6 +25,14 @@ public static function getRequiredPackages(): array return []; } + /** + * Returns lines that should be added to the input array in vite.config.js. + */ + public static function getViteInput(): array + { + return []; + } + /** * Registers any components required by the preset. */ @@ -52,7 +60,7 @@ public function getViewsPath(): string return $this->getDestinationPath() . '/views'; } - public function publish(FileSystem $filesystem): void + public function publish(Filesystem $filesystem): void { $destinationPath = $this->getDestinationPath(); $filesystem->ensureDirectoryExists($destinationPath); diff --git a/src/Frontend/Presets/BladeBootstrapPreset.php b/src/Frontend/Presets/BladeBootstrapPreset.php index a534beb9..a119092d 100644 --- a/src/Frontend/Presets/BladeBootstrapPreset.php +++ b/src/Frontend/Presets/BladeBootstrapPreset.php @@ -21,6 +21,14 @@ public static function getRequiredStack(): FrontendStack return FrontendStack::BLADE; } + public static function getViteInput(): array + { + return [ + 'resources/forum/blade-bootstrap/css/forum.css', + 'resources/forum/blade-bootstrap/js/forum.js', + ]; + } + public static function getRequiredPackages(): array { return [ diff --git a/src/Frontend/Presets/BladeTailwindPreset.php b/src/Frontend/Presets/BladeTailwindPreset.php index 85009231..33afea04 100644 --- a/src/Frontend/Presets/BladeTailwindPreset.php +++ b/src/Frontend/Presets/BladeTailwindPreset.php @@ -38,6 +38,14 @@ public static function getRequiredPackages(): array ]; } + public static function getViteInput(): array + { + return [ + 'resources/forum/blade-tailwind/css/forum.css', + 'resources/forum/blade-tailwind/js/forum.js', + ]; + } + public function register(): void { $this->bladeComponentNamespace("TeamTeaTime\\Forum\\Frontend\\Presets\\BladeTailwind\\Components"); diff --git a/src/Frontend/Presets/LivewireTailwindPreset.php b/src/Frontend/Presets/LivewireTailwindPreset.php index 145c4abf..32d48f05 100644 --- a/src/Frontend/Presets/LivewireTailwindPreset.php +++ b/src/Frontend/Presets/LivewireTailwindPreset.php @@ -46,6 +46,14 @@ public static function getRequiredPackages(): array ]; } + public static function getViteInput(): array + { + return [ + 'resources/forum/livewire-tailwind/css/forum.css', + 'resources/forum/livewire-tailwind/js/forum.js', + ]; + } + public function register(): void { $this->bladeComponentNamespace("TeamTeaTime\\Forum\\Frontend\\Presets\\LivewireTailwind\\Components\\Blade");