mirror of
https://github.com/flarum/core.git
synced 2025-08-16 05:14:20 +02:00
chore(package-manager): last tweaks before beta tag
chore: fix workflow errors chore: fix workflow errors chore: avoid updating an extension that wasn't directly required chore: prevent job overlap chore: reorganize code, separate state from view fix: update checking ui display chore: minor improvements Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
namespace Flarum\PackageManager\Command;
|
||||
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Foundation\ValidationException;
|
||||
use Flarum\PackageManager\Composer\ComposerAdapter;
|
||||
use Flarum\PackageManager\Exception\ComposerUpdateFailedException;
|
||||
use Flarum\PackageManager\Exception\ExtensionNotInstalledException;
|
||||
@@ -46,18 +48,25 @@ class UpdateExtensionHandler
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* @var Paths
|
||||
*/
|
||||
protected $paths;
|
||||
|
||||
public function __construct(
|
||||
ComposerAdapter $composer,
|
||||
ExtensionManager $extensions,
|
||||
UpdateExtensionValidator $validator,
|
||||
LastUpdateCheck $lastUpdateCheck,
|
||||
Dispatcher $events
|
||||
Dispatcher $events,
|
||||
Paths $paths
|
||||
) {
|
||||
$this->composer = $composer;
|
||||
$this->extensions = $extensions;
|
||||
$this->validator = $validator;
|
||||
$this->lastUpdateCheck = $lastUpdateCheck;
|
||||
$this->events = $events;
|
||||
$this->paths = $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,6 +85,17 @@ class UpdateExtensionHandler
|
||||
throw new ExtensionNotInstalledException($command->extensionId);
|
||||
}
|
||||
|
||||
$rootComposer = json_decode(file_get_contents("{$this->paths->base}/composer.json"), true);
|
||||
|
||||
// If this was installed as a requirement for another extension,
|
||||
// don't update it directly.
|
||||
// @TODO communicate this in the UI.
|
||||
if (! isset($rootComposer['require'][$extension->name]) && ! empty($extension->getExtensionDependencyIds())) {
|
||||
throw new ValidationException([
|
||||
'message' => "Cannot update $extension->name. It was installed as a requirement for other extensions: ".implode(', ', $extension->getExtensionDependencyIds()).'. Update those extensions instead.'
|
||||
]);
|
||||
}
|
||||
|
||||
$output = $this->composer->run(
|
||||
new StringInput("require $extension->name:*"),
|
||||
$command->task ?? null
|
||||
|
@@ -12,6 +12,7 @@ namespace Flarum\PackageManager\Job;
|
||||
use Flarum\Bus\Dispatcher;
|
||||
use Flarum\PackageManager\Command\BusinessCommandInterface;
|
||||
use Flarum\Queue\AbstractJob;
|
||||
use Illuminate\Queue\Middleware\WithoutOverlapping;
|
||||
use Throwable;
|
||||
|
||||
class ComposerCommandJob extends AbstractJob
|
||||
@@ -62,4 +63,11 @@ class ComposerCommandJob extends AbstractJob
|
||||
|
||||
$this->fail($exception);
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
{
|
||||
return [
|
||||
new WithoutOverlapping(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user