Initial commit

This commit is contained in:
root
2026-05-09 17:28:23 +02:00
commit 9d73f82529
5575 changed files with 281989 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
class BuildTheme extends Command
{
#[\Override]
protected $signature = 'build:theme';
#[\Override]
protected $description = 'Build a selected theme assets';
public function handle(): int
{
$themes = $this->getAvailableThemes();
if ($themes->isEmpty()) {
$this->error('No themes found in resources/themes/');
return Command::FAILURE;
}
$selectedTheme = $this->choice(
'Which theme would you like to build?',
$themes->all(),
0,
);
$themeName = is_array($selectedTheme) ? ($selectedTheme[0] ?? '') : $selectedTheme;
$this->info('Building ' . $themeName . ' theme...');
$this->runBuildCommand($themeName);
return Command::SUCCESS;
}
/**
* @return Collection<int, string>
*/
private function getAvailableThemes(): Collection
{
$themesPath = resource_path('themes');
if (! File::exists($themesPath)) {
return collect();
}
return collect(File::directories($themesPath))
->map(fn ($path) => basename((string) $path))
->sort();
}
private function runBuildCommand(string $theme): void
{
$command = escapeshellcmd("npm run build:{$theme}");
$output = [];
$returnCode = 0;
exec($command, $output, $returnCode);
foreach ($output as $line) {
$this->line($line);
}
if ($returnCode === 0) {
$this->info("Theme {$theme} built successfully!");
} else {
$this->error("Failed to build theme {$theme}");
}
}
}