Fix update command

This commit is contained in:
DariusIII
2026-06-24 20:33:02 +02:00
parent cf138fae03
commit bb2658c48f
+32 -1
View File
@@ -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<string> $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
*/