comparison src/Console/InstallsBladeStack.php @ 0:90e38de8f2ba

Initial Commit
author luka
date Wed, 13 Aug 2025 22:17:20 -0400
parents
children a2a3059de103
comparison
equal deleted inserted replaced
-1:000000000000 0:90e38de8f2ba
1 <?php
2
3 namespace Wizard\Auth\Console;
4
5 use Illuminate\Filesystem\Filesystem;
6 use Symfony\Component\Finder\Finder;
7
8 trait InstallsBladeStack
9 {
10 /**
11 * Install the Blade Breeze stack.
12 *
13 * @return int|null
14 */
15 protected function installBladeStack()
16 {
17 // NPM Packages...
18 $this->updateNodePackages(function ($packages) {
19 return [
20 "@popperjs/core" => "^2.11.8",
21 "bootstrap" => "^5.3.0",
22 ] + $packages;
23 });
24
25 // Controllers...
26 (new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers'));
27 (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Controllers', app_path('Http/Controllers'));
28
29 // Requests...
30 (new Filesystem)->ensureDirectoryExists(app_path('Http/Requests'));
31 (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/Http/Requests', app_path('Http/Requests'));
32
33 // Views...
34 (new Filesystem)->ensureDirectoryExists(resource_path('views'));
35 (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/resources/views', resource_path('views'));
36
37 if (! $this->option('dark')) {
38 $this->removeDarkClasses((new Finder)
39 ->in(resource_path('views'))
40 ->name('*.blade.php')
41 ->notPath('livewire/welcome/navigation.blade.php')
42 ->notName('welcome.blade.php')
43 );
44 }
45
46 // Components...
47 (new Filesystem)->ensureDirectoryExists(app_path('View/Components'));
48 (new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/View/Components', app_path('View/Components'));
49
50 // Tests...
51 if (! $this->installTests()) {
52 return 1;
53 }
54
55 // Routes...
56 copy(__DIR__.'/../../stubs/default/routes/web.php', base_path('routes/web.php'));
57 copy(__DIR__.'/../../stubs/default/routes/auth.php', base_path('routes/auth.php'));
58
59 // "Dashboard" Route...
60 $this->replaceInFile('/home', '/dashboard', resource_path('views/welcome.blade.php'));
61 $this->replaceInFile('Home', 'Dashboard', resource_path('views/welcome.blade.php'));
62
63 // Tailwind / Vite...
64 copy(__DIR__.'/../../stubs/default/tailwind.config.js', base_path('tailwind.config.js'));
65 copy(__DIR__.'/../../stubs/default/postcss.config.js', base_path('postcss.config.js'));
66 copy(__DIR__.'/../../stubs/default/vite.config.js', base_path('vite.config.js'));
67 copy(__DIR__.'/../../stubs/default/resources/css/app.css', resource_path('css/app.css'));
68 copy(__DIR__.'/../../stubs/default/resources/js/app.js', resource_path('js/app.js'));
69
70 $this->components->info('Installing and building Node dependencies.');
71
72 if (file_exists(base_path('pnpm-lock.yaml'))) {
73 $this->runCommands(['pnpm install', 'pnpm run build']);
74 } elseif (file_exists(base_path('yarn.lock'))) {
75 $this->runCommands(['yarn install', 'yarn run build']);
76 } elseif (file_exists(base_path('bun.lock')) || file_exists(base_path('bun.lockb'))) {
77 $this->runCommands(['bun install', 'bun run build']);
78 } elseif (file_exists(base_path('deno.lock'))) {
79 $this->runCommands(['deno install', 'deno task build']);
80 } else {
81 $this->runCommands(['npm install', 'npm run build']);
82 }
83
84 $this->line('');
85 $this->components->info('Breeze scaffolding installed successfully.');
86 }
87 }