|
12 | 12 | namespace Symfony\Flex\Command;
|
13 | 13 |
|
14 | 14 | use Composer\Command\BaseCommand;
|
15 |
| -use Composer\Config\JsonConfigSource; |
16 |
| -use Composer\Factory; |
17 | 15 | use Composer\Installer;
|
18 |
| -use Composer\Json\JsonFile; |
19 |
| -use Composer\Package\Locker; |
20 | 16 | use Composer\Package\Version\VersionParser;
|
21 |
| -use Composer\Plugin\PluginInterface; |
22 | 17 | use Symfony\Component\Console\Input\InputArgument;
|
23 | 18 | use Symfony\Component\Console\Input\InputInterface;
|
24 | 19 | use Symfony\Component\Console\Input\InputOption;
|
@@ -55,10 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
55 | 50 | $composer = $this->getComposer();
|
56 | 51 | $packages = $this->resolver->resolve($input->getArgument('packages'), true);
|
57 | 52 | $io = $this->getIO();
|
58 |
| - $json = new JsonFile(Factory::getComposerFile()); |
59 |
| - $manipulator = new JsonConfigSource($json); |
60 |
| - $locker = $composer->getLocker(); |
61 |
| - $lockData = $locker->getLockData(); |
| 53 | + $lockData = $composer->getLocker()->getLockData(); |
62 | 54 | $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
|
63 | 55 | $versionParser = new VersionParser();
|
64 | 56 | $dryRun = $input->hasOption('dry-run') && $input->getOption('dry-run');
|
@@ -97,40 +89,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
97 | 89 | $io->writeError(sprintf('<info>Unpacked %s dependencies</>', $pkg->getName()));
|
98 | 90 | }
|
99 | 91 |
|
100 |
| - foreach ($result->getUnpacked() as $package) { |
101 |
| - $manipulator->removeLink('require-dev', $package->getName()); |
102 |
| - foreach ($lockData['packages-dev'] as $i => $pkg) { |
103 |
| - if ($package->getName() === $pkg['name']) { |
104 |
| - unset($lockData['packages-dev'][$i]); |
105 |
| - } |
106 |
| - } |
107 |
| - $manipulator->removeLink('require', $package->getName()); |
108 |
| - foreach ($lockData['packages'] as $i => $pkg) { |
109 |
| - if ($package->getName() === $pkg['name']) { |
110 |
| - unset($lockData['packages'][$i]); |
111 |
| - } |
112 |
| - } |
113 |
| - } |
114 |
| - $lockData['packages'] = array_values($lockData['packages']); |
115 |
| - $lockData['packages-dev'] = array_values($lockData['packages-dev']); |
116 |
| - $lockData['content-hash'] = $locker->getContentHash(file_get_contents($json->getPath())); |
117 |
| - $lockFile = new JsonFile(substr($json->getPath(), 0, -4).'lock', null, $io); |
118 |
| - |
119 |
| - if (!$dryRun) { |
120 |
| - $lockFile->write($lockData); |
121 |
| - } |
| 92 | + $unpacker->updateLock($result, $io); |
122 | 93 |
|
123 | 94 | if ($input->hasOption('no-install') && $input->getOption('no-install')) {
|
124 | 95 | return 0;
|
125 | 96 | }
|
126 | 97 |
|
127 |
| - // force removal of files under vendor/ |
128 |
| - if (version_compare('2.0.0', PluginInterface::PLUGIN_API_VERSION, '>')) { |
129 |
| - $locker = new Locker($io, $lockFile, $composer->getRepositoryManager(), $composer->getInstallationManager(), file_get_contents($json->getPath())); |
130 |
| - } else { |
131 |
| - $locker = new Locker($io, $lockFile, $composer->getInstallationManager(), file_get_contents($json->getPath())); |
132 |
| - } |
133 |
| - $composer->setLocker($locker); |
134 | 98 | $install = Installer::create($io, $composer);
|
135 | 99 | $install
|
136 | 100 | ->setDryRun($dryRun)
|
|
0 commit comments