diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php index 6b292db..235b9ad 100644 --- a/resources/views/layout.blade.php +++ b/resources/views/layout.blade.php @@ -22,6 +22,22 @@ + @if (! $assetsAreCurrent) + + + + + + + + + The published Compass assets are not up-to-date with the installed version. + To update, run: php artisan compass:publish + + + + @endif + diff --git a/src/Compass.php b/src/Compass.php index 02311d7..1677d78 100644 --- a/src/Compass.php +++ b/src/Compass.php @@ -5,6 +5,7 @@ use Illuminate\Support\Str; use Illuminate\Routing\Route; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Route as RouteFacade; final class Compass @@ -140,4 +141,23 @@ public static function ignoreMigrations() return new static; } + + /** + * Check if assets are up-to-date. + * + * src: https://github.com/laravel/telescope/pull/729 + * + * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException + * @return bool + */ + public static function assetsAreCurrent() + { + $publishedPath = public_path('vendor/compass/mix-manifest.json'); + + if (! File::exists($publishedPath)) { + throw new \RuntimeException('The Compass assets are not published. Please run: php artisan compass:publish'); + } + + return File::get($publishedPath) === File::get(__DIR__.'/../public/mix-manifest.json'); + } } diff --git a/src/Http/Controllers/HomeController.php b/src/Http/Controllers/HomeController.php index 1fd8c6e..41e6892 100644 --- a/src/Http/Controllers/HomeController.php +++ b/src/Http/Controllers/HomeController.php @@ -15,6 +15,7 @@ public function __invoke() { return view('compass::layout', [ 'compassScriptVariables' => Compass::scriptVariables(), + 'assetsAreCurrent' => Compass::assetsAreCurrent(), ]); } }
The published Compass assets are not up-to-date with the installed version.
To update, run: php artisan compass:publish
php artisan compass:publish