We're currently getting a lot of issues where people forgot to update their Horizon assets. Technically it should be possible for us to implement a Composer hook in the composer.json command that runs php artisan horizon:assets so updated assets get published.
It may be similarly prudent to specifically mention appropriate upgrade steps in the docs at
https://laravel.com/docs/5.8/horizon#installation
@drbyte I was thinking to do that first but if we can automate this then this is unnecessary.
True, but docs also help with troubleshooting when automation goes awry. :)
Yeah, true. You can send in a PR if you want :)
Done
What do you think about something like this? https://github.com/laravel/telescope/pull/729
Eg. show a warning when the assets are out-of-date. Still requires a manual step but at least people are warned.
I don't think composer hooks work for non-root projects.
Hmm I'm not sure if something like that should make its way into the actual UI.
I don't think composer hooks work for non-root projects.
Yeah I'm not sure either. I need to look into this but bit swamped atm.
Yeah the alternative is not publishing it, but loading the assets through a controller, example: https://github.com/fruitcake/laravel-telescope-toolbar/blob/master/src/Http/Controllers/ToolbarController.php#L67-L86
Hmm I'm not sure if something like that should make its way into the actual UI.
Why shouldn't it make the way into the UI? It's only visible when it's outdated and a relatively simple check to prevent common errors.
Because you're displaying an implementation detail in an app. Imo the app shouldn't have any knowledge about how the ui is build. This is a slippery slope imo.
I personally don't find it bad for the UI to help with this. But of course, if this can be avoided altogether that would be the best solution.
Maybe adding a command similar to php artisan package:discover but that takes care of re publishing all packages assets. It would only work out of the box for new Laravel installs.
I still think we can solve this with Composer hooks.
https://getcomposer.org/doc/articles/scripts.md
Note: Only scripts defined in the root package's composer.json are executed. If a dependency of the root package specifies its own scripts, Composer does not execute those additional scripts.
I was more thinking of setting a hook on the composer.json of the app itself. Like a note in the docs to add it to your composer.json
Yeah you can do that, but it will publish for all updates (not just this one). Not that it matters much.
@barryvdh you can filter by service provider or tag
Oh yeah I mean you can just put php artisan horizon:assets in there:
"scripts": {
"post-update-cmd": [
"@php artisan horizon:assets"
]
}
But it will publish on each composer update, not just for when Horizon updates (but it also doesn't changes much when its not updated).
ah yeah. Gotcha. I indeed think it's not that big of a deal if you're not overriding anything. If you're overriding the templates you probably don't want to add it.
So, no interest in adding a warning like in Telescope?
@driesvints Did you find any downsides from automatically publishing the assets when updating the package? I'm one of them constantly forgetting doing so manually and first notices in production and has to redeploy.
Perhaps the post-package-update script could be useful? Apparently, it only fires when the package itself is updated?
I've been doing this the same way Livewire suggests it, by hooking post-autoload-dump:
"@php artisan vendor:publish --force --tag=livewire:assets --ansi"
@drbyte yeah I saw that as well. Might be a good solution.
I've opted for the suggestion by @drbyte to note this in the docs of Horizon and Telescope: https://github.com/laravel/docs/pull/6230
Most helpful comment
I've been doing this the same way Livewire suggests it, by hooking
post-autoload-dump:"@php artisan vendor:publish --force --tag=livewire:assets --ansi"