diff --git a/src/Console/Commands/InstallCommand.php b/src/Console/Commands/InstallCommand.php index 029af06..4e9279c 100644 --- a/src/Console/Commands/InstallCommand.php +++ b/src/Console/Commands/InstallCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Validator; +use Symfony\Component\Finder\Finder; use Symfony\Component\Process\Process; class InstallCommand extends Command @@ -27,6 +28,7 @@ class InstallCommand extends Command private ?string $clientId; private ?string $clientSecret; private ?string $prefix; + private ?bool $darkMode; /** * Execute the console command. @@ -39,6 +41,7 @@ public function handle() $this->clientId = $this->ask('What is your Discord application\'s client id?'); $this->clientSecret = $this->ask('What is your Discord application\'s client secret?'); $this->prefix = $this->ask('What route prefix should Larascord use?', 'larascord'); + $this->darkMode = $this->confirm('Do you want to install laravel/breeze with dark mode?', true); // Validating the user's input try {$this->validateInput();} catch (\Exception $e) {$this->error($e->getMessage()); return;} @@ -46,7 +49,7 @@ public function handle() // Installing laravel/breeze $this->info('Installing Larascord...'); $this->requireComposerPackages('laravel/breeze:^1.16', '-q'); - if ($this->confirm('Do you want to install laravel/breeze with dark mode?', true)) { + if ($this->darkMode) { shell_exec('php artisan breeze:install --dark'); } else { shell_exec('php artisan breeze:install'); @@ -184,6 +187,14 @@ public function createViewFiles() { (new Filesystem())->ensureDirectoryExists(resource_path('views')); (new Filesystem())->copyDirectory(__DIR__ . '/../../resources/views', resource_path('views')); + + if (!$this->darkMode) { + $this->removeDarkClasses((new Finder()) + ->in(resource_path('views')) + ->name('*.blade.php') + ->notName('welcome.blade.php') + ); + } } /** @@ -233,4 +244,17 @@ protected function requireComposerPackages($packages) $this->output->write($output); }); } + + /** + * Remove Tailwind dark classes from the given files. + * + * @param \Symfony\Component\Finder\Finder $finder + * @return void + */ + protected function removeDarkClasses(Finder $finder) + { + foreach ($finder as $file) { + file_put_contents($file->getPathname(), preg_replace('/\sdark:[^\s"\']+/', '', $file->getContents())); + } + } } \ No newline at end of file