Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show warning when manifest is outdated #729

Merged
merged 6 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a custom exception (like TelescopeAssetsNotPublishedException) that implements ProvidesSolution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it could yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what isn't clear about this error and the solution though :P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be a button to run Artisan::call('telescope:publish'), similarly to the migrate button when a table is not found.

}

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