|
39 | 39 | use Code16\Sharp\Utils\SharpUtil; |
40 | 40 | use Code16\Sharp\Utils\Uploads\SharpUploadManager; |
41 | 41 | use Code16\Sharp\View\Components\Content; |
42 | | -use Code16\Sharp\View\Components\File; |
| 42 | +use Code16\Sharp\View\Components\File as FileComponent; |
43 | 43 | use Code16\Sharp\View\Components\Image; |
44 | 44 | use Illuminate\Auth\AuthenticationException; |
45 | 45 | use Illuminate\Auth\Notifications\ResetPassword; |
| 46 | +use Illuminate\Console\Events\CommandStarting; |
46 | 47 | use Illuminate\Contracts\Debug\ExceptionHandler; |
47 | 48 | use Illuminate\Session\TokenMismatchException; |
48 | 49 | use Illuminate\Support\Carbon; |
49 | 50 | use Illuminate\Support\Facades\Blade; |
| 51 | +use Illuminate\Support\Facades\Event; |
| 52 | +use Illuminate\Support\Facades\File; |
50 | 53 | use Illuminate\Support\ServiceProvider; |
51 | 54 | use Inertia\ServiceProvider as InertiaServiceProvider; |
52 | 55 | use Laravel\Octane\Events\RequestReceived; |
@@ -77,10 +80,12 @@ public function boot() |
77 | 80 | 'sharp-views' |
78 | 81 | ); |
79 | 82 |
|
| 83 | + $this->clearAssetsPublicDirectoryOnPublish(); |
| 84 | + |
80 | 85 | Blade::componentNamespace('Code16\\Sharp\\View\\Components', 'sharp'); |
81 | 86 | Blade::componentNamespace('Code16\\Sharp\\View\\Components\\Content', 'sharp-content'); |
82 | 87 | Blade::component(Content::class, 'sharp-content'); |
83 | | - Blade::component(File::class, 'sharp-file'); |
| 88 | + Blade::component(FileComponent::class, 'sharp-file'); |
84 | 89 | Blade::component(Image::class, 'sharp-image'); |
85 | 90 |
|
86 | 91 | $this->registerViewExceptionMapper(); |
@@ -200,6 +205,20 @@ protected function registerViewExceptionMapper(): void |
200 | 205 | }); |
201 | 206 | } |
202 | 207 |
|
| 208 | + protected function clearAssetsPublicDirectoryOnPublish(): void |
| 209 | + { |
| 210 | + Event::listen(CommandStarting::class, function (CommandStarting $event) { |
| 211 | + if ($event->command === 'vendor:publish' |
| 212 | + && $event->input->getOption('tag') |
| 213 | + && in_array('sharp-assets', $event->input->getOption('tag')) |
| 214 | + ) { |
| 215 | + if (File::exists(public_path('vendor/sharp'))) { |
| 216 | + File::deleteDirectory(public_path('vendor/sharp')); |
| 217 | + } |
| 218 | + } |
| 219 | + }); |
| 220 | + } |
| 221 | + |
203 | 222 | public function loadRoutes(): void |
204 | 223 | { |
205 | 224 | $this->loadRoutesFrom(__DIR__.'/routes/web.php'); |
|
0 commit comments