Open fozooni opened 1 year ago
After going through the code, it seems the base source classes do not have the functionality to call the pre_update
and post_update
commands. Not sure if it's an intended omission or the library is still in development, but there is a way to make this work, just replace from the example
$this->updater->source()
with the following
$sourceRepository = new SourceRepository($this->updater->source(), $this->updateExecutor);
if ($sourceRepository->isNewVersionAvailable()) {
// Your fetch and update code ...
$sourceRepository->preUpdateArtisanCommands();
$updated = $sourceRepository->update($release);
if ($updated) {
$sourceRepository->postUpdateArtisanCommands();
}
}
where $this->updateExecutor
can be injected as a dependency as shown below (or using app()
)
public function __construct(private readonly UpdaterManager $updater, private readonly UpdateExecutor $updateExecutor)
{
parent::__construct();
}
Don't forget the relevant imports
use Codedge\Updater\Models\UpdateExecutor;
use Codedge\Updater\SourceRepository;
use Codedge\Updater\UpdaterManager;
Thanks buddy! At that time I was very much waiting for a solution to solve my problem, but unfortunately the development was stopped. Anyway, I will check the solution you provided. I hope we can use it in future projects.
Hello dear, I just create new laravel project and install laravel-selfupdater. Everything works perfectly and I thank you for that. But non of artisan commands working in
self-updater.php
at all, I don't have any idea how can I fix this. Commands are executed directly through the console without any problems.self-updater.php
file:UpdateCommand.php
file:I think this should work correctly but it doesn't! What do you think is the problem?