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 #4

Merged
merged 1 commit into from
Oct 12, 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
16 changes: 16 additions & 0 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
<sidebar-menu></sidebar-menu>

<main class="md:flex-1 md:overflow-x-hidden">
@if (! $assetsAreCurrent)
<div class="bg-blue-100 text-blue-900 px-4 py-3" role="alert">
<div class="flex">
<div class="py-1">
<svg class="fill-current h-6 w-6 text-blue-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z" />
</svg>
</div>
<div>
<p class="font-medium">The published Compass assets are not up-to-date with the installed version.</p>
<p class="text-sm">To update, run: <code class="ml-2">php artisan compass:publish</code></p>
</div>
</div>
</div>
@endif

<router-view :key="$route.path"></router-view>
</main>
</div>
Expand Down
20 changes: 20 additions & 0 deletions src/Compass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
}
}
1 change: 1 addition & 0 deletions src/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function __invoke()
{
return view('compass::layout', [
'compassScriptVariables' => Compass::scriptVariables(),
'assetsAreCurrent' => Compass::assetsAreCurrent(),
]);
}
}