From bb2658c48f9c02cc802c4e1ddbbbc9c3d82c5e24 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 24 Jun 2026 20:33:02 +0200 Subject: [PATCH] Fix update command --- app/Console/Commands/UpdateNNTmux.php | 33 ++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/UpdateNNTmux.php b/app/Console/Commands/UpdateNNTmux.php index 7a832d09d..ec39a627f 100644 --- a/app/Console/Commands/UpdateNNTmux.php +++ b/app/Console/Commands/UpdateNNTmux.php @@ -39,6 +39,11 @@ class UpdateNNTmux extends Command */ private bool $tmuxWasRunning = false; + /** + * @var bool Whether composer dependencies were refreshed during this update + */ + private bool $composerWasRun = false; + /** * @var ProgressBar Progress bar for tracking operations */ @@ -192,6 +197,8 @@ class UpdateNNTmux extends Command throw new \Exception('Composer update failed'); } + $this->composerWasRun = true; + $this->progressBar->advance(); } @@ -202,7 +209,9 @@ class UpdateNNTmux extends Command { $this->info('🗄️ Updating database...'); - $dbResult = $this->call('nntmux:db'); + $dbResult = $this->composerWasRun + ? $this->runFreshArtisanCommand(['nntmux:db']) + : $this->call('nntmux:db'); if ($dbResult !== 0) { throw new \Exception('Database update failed'); @@ -211,6 +220,28 @@ class UpdateNNTmux extends Command $this->progressBar->advance(); } + /** + * Run an Artisan command in a new PHP process so updated dependencies are loaded consistently. + * + * @param list $arguments + */ + private function runFreshArtisanCommand(array $arguments): int + { + $this->line(' ℹ Restarting Artisan for updated dependencies...'); + + $result = Process::timeout(3600) + ->path(base_path()) + ->run(array_merge([PHP_BINARY, 'artisan'], $arguments), function (string $type, string $output): void { + $this->output->write($output); + }); + + if (! $result->successful() && $result->errorOutput() !== '') { + $this->error($result->errorOutput()); + } + + return $result->exitCode(); + } + /** * Perform NPM operations with parallel processing where possible */