Skip to content

Commit

Permalink
Merge pull request #783 from andresayej/4.x
Browse files Browse the repository at this point in the history
[4.x] Show warning when manifest is outdated
  • Loading branch information
taylorotwell authored Mar 6, 2020
2 parents 34c01c7 + d33b0b3 commit e86b16e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
6 changes: 6 additions & 0 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
</div>

<div class="col-10">
@if (! $assetsAreCurrent)
<div class="alert alert-warning">
The published Horizon assets are not up-to-date with the installed version. To update, run:<br/><code>php artisan horizon:publish</code>
</div>
@endif

<router-view></router-view>
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions src/Horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Closure;
use Exception;
use Illuminate\Support\Facades\File;
use RuntimeException;

class Horizon
{
Expand Down Expand Up @@ -169,4 +171,22 @@ public static function routeSmsNotificationsTo($number)

return new static;
}

/**
* Determine if Horizon's published assets are up-to-date.
*
* @return bool
*
* @throws \RuntimeException
*/
public static function assetsAreCurrent()
{
$publishedPath = public_path('vendor/horizon/mix-manifest.json');

if (! File::exists($publishedPath)) {
throw new RuntimeException('Horizon assets are not published. Please run: php artisan horizon:publish');
}

return File::get($publishedPath) === File::get(__DIR__.'/../public/mix-manifest.json');
}
}
3 changes: 2 additions & 1 deletion src/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ class HomeController extends Controller
/**
* Single page application catch-all route.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
return view('horizon::layout', [
'cssFile' => Horizon::$useDarkTheme ? 'app-dark.css' : 'app.css',
'horizonScriptVariables' => Horizon::scriptVariables(),
'assetsAreCurrent' => Horizon::assetsAreCurrent(),
]);
}
}

0 comments on commit e86b16e

Please sign in to comment.