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 */ 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}"); } } }