mirror of
https://github.com/flarum/framework.git
synced 2024-12-15 16:53:37 +08:00
795a500adb
* feat: Queue package manager commands * adjust tests * fix: force run whynot command synchronously * chore: maximize command output box's height * chore: more user instructions on background queue * feat: track command peak memory usage * feat: exit of CLI php version doesn't match web php version * chore: install deps * chore: format and typing workflow fix Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\PackageManager\Tests\integration;
|
|
|
|
use Flarum\Testing\integration\UsesTmpDir;
|
|
|
|
class SetupComposer
|
|
{
|
|
use UsesTmpDir;
|
|
|
|
private $config;
|
|
|
|
public function __construct(array $config = null)
|
|
{
|
|
$this->config = $config;
|
|
}
|
|
|
|
public function run()
|
|
{
|
|
$composerJson = $this->tmpDir().'/composer.json';
|
|
$composerLock = $this->tmpDir().'/composer.lock';
|
|
$packages = $this->tmpDir().'/packages';
|
|
|
|
file_put_contents($composerJson, json_encode($this->getConfig(), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
|
|
|
|
if (! file_exists($packages)) {
|
|
mkdir($packages);
|
|
}
|
|
|
|
if (file_exists($composerLock)) {
|
|
unlink($composerLock);
|
|
}
|
|
}
|
|
|
|
private function getConfig(): array
|
|
{
|
|
return array_merge([
|
|
'require' => [
|
|
'flarum/core' => '1.0.0',
|
|
'flarum/tags' => '1.0.3',
|
|
'flarum/lang-english' => '*',
|
|
],
|
|
'config' => [
|
|
'preferred-install' => 'dist',
|
|
'sort-packages' => true,
|
|
],
|
|
'repositories' => [
|
|
[
|
|
'type' => 'path',
|
|
'url' => realpath($this->tmpDir()).'/packages/*',
|
|
]
|
|
]
|
|
], $this->config ?? []);
|
|
}
|
|
}
|