mirror of
https://github.com/flarum/core.git
synced 2025-08-03 15:07:53 +02:00
chore(em): port fix from 1.x
This commit is contained in:
@@ -44,7 +44,8 @@ class GlobalUpdateHandler
|
||||
|
||||
$output = $this->composer->run(
|
||||
new ArrayInput($input),
|
||||
$command->task ?? null
|
||||
$command->task ?? null,
|
||||
true
|
||||
);
|
||||
|
||||
if ($output->getExitCode() !== 0) {
|
||||
|
@@ -89,7 +89,7 @@ class MajorUpdateHandler
|
||||
$input['--dry-run'] = true;
|
||||
}
|
||||
|
||||
$output = $this->composer->run(new ArrayInput($input), $command->task ?? null);
|
||||
$output = $this->composer->run(new ArrayInput($input), $command->task ?? null, true);
|
||||
|
||||
if ($output->getExitCode() !== 0) {
|
||||
throw new MajorUpdateFailedException('*', $output->getContents(), $majorVersion);
|
||||
|
@@ -40,7 +40,8 @@ class MinorUpdateHandler
|
||||
|
||||
$output = $this->composer->run(
|
||||
new StringInput('update --prefer-dist --no-dev -a --with-all-dependencies'),
|
||||
$command->task ?? null
|
||||
$command->task ?? null,
|
||||
true
|
||||
);
|
||||
|
||||
if ($output->getExitCode() !== 0) {
|
||||
|
@@ -56,7 +56,8 @@ class RemoveExtensionHandler
|
||||
|
||||
$output = $this->composer->run(
|
||||
new StringInput("remove $extension->name"),
|
||||
$command->task ?? null
|
||||
$command->task ?? null,
|
||||
true
|
||||
);
|
||||
|
||||
if ($output->getExitCode() !== 0) {
|
||||
|
@@ -55,7 +55,8 @@ class RequireExtensionHandler
|
||||
|
||||
$output = $this->composer->run(
|
||||
new StringInput("require $packageName -W"),
|
||||
$command->task ?? null
|
||||
$command->task ?? null,
|
||||
true
|
||||
);
|
||||
|
||||
if ($output->getExitCode() !== 0) {
|
||||
|
@@ -62,7 +62,8 @@ class UpdateExtensionHandler
|
||||
|
||||
$output = $this->composer->run(
|
||||
new StringInput($input),
|
||||
$command->task ?? null
|
||||
$command->task ?? null,
|
||||
true
|
||||
);
|
||||
|
||||
if ($output->getExitCode() !== 0) {
|
||||
|
@@ -15,6 +15,7 @@ use Flarum\ExtensionManager\OutputLogger;
|
||||
use Flarum\ExtensionManager\Support\Util;
|
||||
use Flarum\ExtensionManager\Task\Task;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
@@ -28,11 +29,12 @@ class ComposerAdapter
|
||||
public function __construct(
|
||||
private readonly Application $application,
|
||||
private readonly OutputLogger $logger,
|
||||
private readonly Paths $paths
|
||||
private readonly Paths $paths,
|
||||
private readonly Filesystem $filesystem
|
||||
) {
|
||||
}
|
||||
|
||||
public function run(InputInterface $input, ?Task $task = null): ComposerOutput
|
||||
public function run(InputInterface $input, ?Task $task = null, bool $safeMode = false): ComposerOutput
|
||||
{
|
||||
$this->application->resetComposer();
|
||||
|
||||
@@ -41,7 +43,29 @@ class ComposerAdapter
|
||||
// This hack is necessary so that relative path repositories are resolved properly.
|
||||
$currDir = getcwd();
|
||||
chdir($this->paths->base);
|
||||
|
||||
if ($safeMode) {
|
||||
$temporaryVendorDir = $this->paths->base . DIRECTORY_SEPARATOR . 'temp-vendor';
|
||||
if (! $this->filesystem->isDirectory($temporaryVendorDir)) {
|
||||
$this->filesystem->makeDirectory($temporaryVendorDir);
|
||||
}
|
||||
Config::$defaultConfig['vendor-dir'] = $temporaryVendorDir;
|
||||
}
|
||||
|
||||
$exitCode = $this->application->run($input, $this->output);
|
||||
|
||||
if ($safeMode) {
|
||||
// Move the temporary vendor directory to the real vendor directory.
|
||||
if ($this->filesystem->isDirectory($temporaryVendorDir) && count($this->filesystem->allFiles($temporaryVendorDir))) {
|
||||
$vendorDir = $this->paths->vendor;
|
||||
if (file_exists($vendorDir)) {
|
||||
$this->filesystem->deleteDirectory($vendorDir);
|
||||
}
|
||||
$this->filesystem->moveDirectory($temporaryVendorDir, $vendorDir);
|
||||
}
|
||||
Config::$defaultConfig['vendor-dir'] = $this->paths->vendor;
|
||||
}
|
||||
|
||||
chdir($currDir);
|
||||
|
||||
$command = Util::readableConsoleInput($input);
|
||||
|
@@ -24,6 +24,7 @@ use Flarum\Frontend\RecompileFrontendAssets;
|
||||
use Flarum\Locale\LocaleManager;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
@@ -56,6 +57,7 @@ class ExtensionManagerServiceProvider extends AbstractServiceProvider
|
||||
$composer,
|
||||
$container->make(OutputLogger::class),
|
||||
$container->make(Paths::class),
|
||||
$container->make(Filesystem::class)
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user