-
Notifications
You must be signed in to change notification settings - Fork 541
Expand file tree
/
Copy pathInstallsLivewireStack.php
More file actions
114 lines (94 loc) · 4.66 KB
/
InstallsLivewireStack.php
File metadata and controls
114 lines (94 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace Laravel\Breeze\Console;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;
trait InstallsLivewireStack
{
/**
* Install the Livewire Breeze stack.
*
* @return int|null
*/
protected function installLivewireStack($functional = false)
{
// NPM Packages...
$this->updateNodePackages(function ($packages) {
return [
'@tailwindcss/forms' => '^0.5.2',
'@tailwindcss/vite' => '^4.0.0',
'tailwindcss' => '^4.0.0',
] + $packages;
});
// Install Livewire...
if (! $this->requireComposerPackages(['livewire/livewire:^3.4', 'livewire/volt:^1.0'])) {
return 1;
}
// Install Volt...
(new Process([$this->phpBinary(), 'artisan', 'volt:install'], base_path()))
->setTimeout(null)
->run();
// Controllers
(new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers/Auth'));
(new Filesystem)->copy(
__DIR__.'/../../stubs/default/app/Http/Controllers/Auth/VerifyEmailController.php',
app_path('Http/Controllers/Auth/VerifyEmailController.php'),
);
// Views...
(new Filesystem)->ensureDirectoryExists(resource_path('views'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/resources/views', resource_path('views'));
// Livewire Components...
(new Filesystem)->ensureDirectoryExists(resource_path('views/livewire'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/'
.($functional ? 'livewire-functional' : 'livewire')
.'/resources/views/livewire', resource_path('views/livewire'));
// Views Components...
(new Filesystem)->ensureDirectoryExists(resource_path('views/components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/resources/views/components', resource_path('views/components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/resources/views/components', resource_path('views/components'));
// Views Layouts...
(new Filesystem)->ensureDirectoryExists(resource_path('views/layouts'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/resources/views/layouts', resource_path('views/layouts'));
// Components...
(new Filesystem)->ensureDirectoryExists(app_path('View/Components'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/default/app/View/Components', app_path('View/Components'));
// Actions...
(new Filesystem)->ensureDirectoryExists(app_path('Livewire/Actions'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/app/Livewire/Actions', app_path('Livewire/Actions'));
// Forms...
(new Filesystem)->ensureDirectoryExists(app_path('Livewire/Forms'));
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/livewire-common/app/Livewire/Forms', app_path('Livewire/Forms'));
// Dark mode...
if (! $this->option('dark')) {
$this->removeDarkClasses((new Finder)
->in(resource_path('views'))
->name('*.blade.php')
->notPath('livewire/welcome/navigation.blade.php')
->notName('welcome.blade.php')
);
}
// Tests...
if (! $this->installTests()) {
return 1;
}
// Routes...
copy(__DIR__.'/../../stubs/livewire-common/routes/web.php', base_path('routes/web.php'));
copy(__DIR__.'/../../stubs/livewire-common/routes/auth.php', base_path('routes/auth.php'));
// Tailwind / Vite...
copy(__DIR__.'/../../stubs/default/vite.config.js', base_path('vite.config.js'));
copy(__DIR__.'/../../stubs/default/resources/css/app.css', resource_path('css/app.css'));
$this->components->info('Installing and building Node dependencies.');
if (file_exists(base_path('pnpm-lock.yaml'))) {
$this->runCommands(['pnpm install', 'pnpm run build']);
} elseif (file_exists(base_path('yarn.lock'))) {
$this->runCommands(['yarn install', 'yarn run build']);
} elseif (file_exists(base_path('bun.lockb'))) {
$this->runCommands(['bun install', 'bun run build']);
} elseif (file_exists(base_path('deno.lock'))) {
$this->runCommands(['deno install', 'deno task build']);
} else {
$this->runCommands(['npm install', 'npm run build']);
}
$this->components->info('Livewire scaffolding installed successfully.');
}
}