Skip to content

Commit

Permalink
Show alert if assets are not up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrig committed Sep 25, 2023
1 parent be3d7ac commit 31b1d4a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Command for publishing assets.
- Show alert if assets are not up-to-date

## [0.23.1] - 2023-08-22

Expand Down

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions public/vendor/butler/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"file": "assets/favicon.41d3a538.ico",
"src": "resources/images/favicon.ico"
},
"resources/css/fonts/dmsans/DMSans-Regular.ttf": {
"file": "assets/DMSans-Regular.9ae2da66.ttf",
"src": "resources/css/fonts/dmsans/DMSans-Regular.ttf"
"resources/css/fonts/dmsans/DMSans-Bold.ttf": {
"file": "assets/DMSans-Bold.3edb1342.ttf",
"src": "resources/css/fonts/dmsans/DMSans-Bold.ttf"
},
"resources/css/fonts/dmmono/DMMono-Regular.ttf": {
"file": "assets/DMMono-Regular.57f0f4b4.ttf",
"src": "resources/css/fonts/dmmono/DMMono-Regular.ttf"
},
"resources/css/fonts/dmsans/DMSans-Bold.ttf": {
"file": "assets/DMSans-Bold.3edb1342.ttf",
"src": "resources/css/fonts/dmsans/DMSans-Bold.ttf"
"resources/css/fonts/dmsans/DMSans-Regular.ttf": {
"file": "assets/DMSans-Regular.9ae2da66.ttf",
"src": "resources/css/fonts/dmsans/DMSans-Regular.ttf"
},
"resources/js/app.js": {
"file": "assets/app.0f8aee8b.js",
"src": "resources/js/app.js",
"isEntry": true
},
"resources/css/app.css": {
"file": "assets/app.dad26a4a.css",
"file": "assets/app.e652af71.css",
"src": "resources/css/app.css",
"isEntry": true
}
Expand Down
11 changes: 10 additions & 1 deletion resources/views/components/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@
<x-butler::navbar/>
</header>

<main class="p-5">{{ $slot }}</main>
<main class="p-5">
@unless(\Butler\Service\Butler::assetsAreCurrent())
<div class="mb-6 p-3 rounded text-zinc-100 bg-blue-500 dark:bg-sky-900">
The published assets are not up-to-date with the installed version. To update, run
<code class="text-sm text-zinc-200 border bg-blue-500 border-blue-400 dark:bg-sky-800 dark:border-sky-600 rounded py-1 px-2 mx-1">php artisan butler-service:assets</code>
</div>
@endunless

{{ $slot }}
</main>

<div x-cloak x-data="alert" x-bind="bind" class="flex justify-between fixed top-2 inset-x-0 mx-auto p-3 max-w-xl rounded border text-white">
<span x-text="content"></span>
Expand Down
20 changes: 20 additions & 0 deletions src/Butler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Butler\Service;

use Illuminate\Support\Facades\File;

class Butler
{
public static function assetsAreCurrent(): bool
{
$publishedManifest = public_path('vendor/butler/manifest.json');
$butlerManifest = __DIR__ . '/../public/vendor/butler/manifest.json';

throw_unless(File::exists($publishedManifest), 'Assets are not published.');

return File::get($publishedManifest) === File::get($butlerManifest);
}
}

0 comments on commit 31b1d4a

Please sign in to comment.