Display CMS Optimierungen 03-06-2026
This commit is contained in:
parent
6c6d683b9a
commit
bebfa63e87
17 changed files with 925 additions and 133 deletions
84
app/Console/Commands/PublishFluxAssets.php
Normal file
84
app/Console/Commands/PublishFluxAssets.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use RuntimeException;
|
||||
|
||||
class PublishFluxAssets extends Command
|
||||
{
|
||||
protected $signature = 'flux:publish-assets {--force : Overwrite existing published Flux assets}';
|
||||
|
||||
protected $description = 'Publish Flux JavaScript assets to public/flux for static delivery (like livewire:publish --assets)';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$sourceDir = $this->resolveSourceDirectory();
|
||||
$targetDir = public_path('flux');
|
||||
|
||||
if (! File::isDirectory($targetDir)) {
|
||||
File::makeDirectory($targetDir, 0755, true);
|
||||
}
|
||||
|
||||
$files = [
|
||||
'flux.js',
|
||||
'flux.min.js',
|
||||
'editor.js',
|
||||
'editor.min.js',
|
||||
'editor.css',
|
||||
];
|
||||
|
||||
$published = 0;
|
||||
|
||||
foreach ($files as $file) {
|
||||
$source = $sourceDir.'/'.$file;
|
||||
|
||||
if (! is_file($source)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$target = $targetDir.'/'.$file;
|
||||
|
||||
if (is_file($target) && ! $this->option('force') && hash_file('sha256', $source) === hash_file('sha256', $target)) {
|
||||
$this->line(" <comment>•</comment> {$file} (unverändert)");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
File::copy($source, $target);
|
||||
$this->line(" <info>✓</info> {$file}");
|
||||
$published++;
|
||||
}
|
||||
|
||||
if ($published === 0) {
|
||||
$this->info('Flux-Assets sind bereits aktuell.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$this->newLine();
|
||||
$this->info("{$published} Flux-Asset(s) nach public/flux/ veröffentlicht.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function resolveSourceDirectory(): string
|
||||
{
|
||||
$proDist = base_path('vendor/livewire/flux-pro/dist');
|
||||
|
||||
if (is_dir($proDist)) {
|
||||
return $proDist;
|
||||
}
|
||||
|
||||
$freeDist = base_path('vendor/livewire/flux/dist');
|
||||
|
||||
if (is_dir($freeDist)) {
|
||||
return $freeDist;
|
||||
}
|
||||
|
||||
throw new RuntimeException('Flux vendor assets not found. Run composer install first.');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue