|
2 | 2 | declare(strict_types=1);
|
3 | 3 | namespace Narrowspark\Discovery;
|
4 | 4 |
|
| 5 | +use Closure; |
5 | 6 | use Composer\Composer;
|
6 | 7 | use Composer\DependencyResolver\Operation\InstallOperation;
|
7 | 8 | use Composer\DependencyResolver\Operation\UninstallOperation;
|
|
22 | 23 | use Composer\Plugin\PluginInterface;
|
23 | 24 | use Composer\Plugin\PreFileDownloadEvent;
|
24 | 25 | use Composer\Repository\ComposerRepository as BaseComposerRepository;
|
| 26 | +use Composer\Repository\RepositoryFactory; |
25 | 27 | use Composer\Repository\RepositoryInterface;
|
| 28 | +use Composer\Repository\RepositoryManager; |
26 | 29 | use Composer\Script\Event;
|
27 | 30 | use Composer\Script\ScriptEvents;
|
28 | 31 | use Composer\Util\ProcessExecutor;
|
|
34 | 37 | use Narrowspark\Discovery\Installer\QuestionInstallationManager;
|
35 | 38 | use Narrowspark\Discovery\Prefetcher\ParallelDownloader;
|
36 | 39 | use Narrowspark\Discovery\Prefetcher\Prefetcher;
|
| 40 | +use Narrowspark\Discovery\Prefetcher\TruncatedComposerRepository; |
37 | 41 | use RecursiveDirectoryIterator;
|
38 | 42 | use RecursiveIteratorIterator;
|
39 | 43 | use ReflectionClass;
|
@@ -253,9 +257,26 @@ public function activate(Composer $composer, IOInterface $io): void
|
253 | 257 | $this->rfs = new ParallelDownloader($this->io, $composerConfig, $rfs->getOptions(), $rfs->isTlsDisabled());
|
254 | 258 |
|
255 | 259 | $this->prefetcher = new Prefetcher($this->composer, $this->io, $this->input, $this->rfs);
|
256 |
| - |
257 | 260 | $this->prefetcher->prefetchComposerRepositories($rfs);
|
258 | 261 |
|
| 262 | + $manager = RepositoryFactory::manager($this->io, $composerConfig, $composer->getEventDispatcher(), $this->rfs); |
| 263 | + $setRepositories = Closure::bind(function (RepositoryManager $manager) { |
| 264 | + $manager->repositoryClasses = $this->repositoryClasses; |
| 265 | + $manager->setRepositoryClass('composer', TruncatedComposerRepository::class); |
| 266 | + $manager->repositories = $this->repositories; |
| 267 | + |
| 268 | + $i = 0; |
| 269 | + |
| 270 | + foreach (RepositoryFactory::defaultRepos(null, $this->config, $manager) as $repo) { |
| 271 | + $manager->repositories[$i++] = $repo; |
| 272 | + } |
| 273 | + |
| 274 | + $manager->setLocalRepository($this->getLocalRepository()); |
| 275 | + }, $composer->getRepositoryManager(), RepositoryManager::class); |
| 276 | + |
| 277 | + $setRepositories($manager); |
| 278 | + $composer->setRepositoryManager($manager); |
| 279 | + |
259 | 280 | $this->lock->add('@readme', [
|
260 | 281 | 'This file locks the discovery information of your project to a known state',
|
261 | 282 | 'This file is @generated automatically',
|
@@ -794,9 +815,9 @@ private function getErrorMessage(): ?string
|
794 | 815 | return 'You must enable the openssl extension in your "php.ini" file.';
|
795 | 816 | }
|
796 | 817 |
|
797 |
| - \preg_match_all('/\d+.\d+.\d+/m', Composer::VERSION, $matches, \PREG_SET_ORDER, 0); |
| 818 | + \preg_match('/\d+.\d+.\d+/m', Composer::VERSION, $matches); |
798 | 819 |
|
799 |
| - if ($matches !== null && \version_compare('1.6.0', $matches[0], '<=')) { |
| 820 | + if ($matches !== null && \version_compare($matches[0], '1.6.0') === -1) { |
800 | 821 | return \sprintf('Your version "%s" of Composer is too old; Please upgrade.', Composer::VERSION);
|
801 | 822 | }
|
802 | 823 |
|
|
0 commit comments