Skip to content

Commit

Permalink
Merge pull request #729 from barryvdh/feat-update-warning
Browse files Browse the repository at this point in the history
Show warning when manifest is outdated
  • Loading branch information
taylorotwell committed Sep 13, 2019
2 parents ad74ce0 + 9b4f09d commit 39f256b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@
</div>

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

<router-view></router-view>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function index()
return view('telescope::layout', [
'cssFile' => Telescope::$useDarkTheme ? 'app-dark.css' : 'app.css',
'telescopeScriptVariables' => Telescope::scriptVariables(),
'assetsAreCurrent' => Telescope::assetsAreCurrent(),
]);
}
}
18 changes: 18 additions & 0 deletions src/Telescope.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Log\Events\MessageLogged;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Laravel\Telescope\Contracts\EntriesRepository;
use Laravel\Telescope\Contracts\TerminableRepository;
Expand Down Expand Up @@ -701,4 +702,21 @@ public static function ignoreMigrations()

return new static;
}

/**
* Check if assets are up-to-date.
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
* @return bool
*/
public static function assetsAreCurrent()
{
$publishedPath = public_path('vendor/telescope/mix-manifest.json');

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

return File::get($publishedPath) === File::get(__DIR__.'/../public/mix-manifest.json');
}
}

0 comments on commit 39f256b

Please sign in to comment.