Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/Console/Commands/PresetInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()}'.");
}
}
10 changes: 9 additions & 1 deletion src/Frontend/Presets/AbstractPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/Frontend/Presets/BladeBootstrapPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
8 changes: 8 additions & 0 deletions src/Frontend/Presets/BladeTailwindPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 8 additions & 0 deletions src/Frontend/Presets/LivewireTailwindPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading