diff --git a/composer/helpers/v2/src/DependabotInstallationManager.php b/composer/helpers/v2/src/DependabotInstallationManager.php deleted file mode 100644 index 2e77a031457..00000000000 --- a/composer/helpers/v2/src/DependabotInstallationManager.php +++ /dev/null @@ -1,74 +0,0 @@ -getOperationType(); - // NOTE: skipping download() step - $this->$method($repo, $operation); - } - } - - public function install(InstalledRepositoryInterface $repo, InstallOperation $operation): ?PromiseInterface - { - $this->installed[] = $operation->getPackage(); - - return null; - } - - public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation): ?PromiseInterface - { - $this->updated[] = [$operation->getInitialPackage(), $operation->getTargetPackage()]; - - return null; - } - - public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation): ?PromiseInterface - { - $this->uninstalled[] = $operation->getPackage(); - - return null; - } - - /** - * @return PackageInterface[] - */ - public function getInstalledPackages(): array - { - return $this->installed; - } - - /** - * @return PackageInterface[] - */ - public function getUpdatedPackages(): array - { - return $this->updated; - } - - /** - * @return PackageInterface[] - */ - public function getUninstalledPackages(): array - { - return $this->uninstalled; - } -} diff --git a/composer/helpers/v2/src/UpdateChecker.php b/composer/helpers/v2/src/UpdateChecker.php index 963a9e42901..6ac66f30751 100644 --- a/composer/helpers/v2/src/UpdateChecker.php +++ b/composer/helpers/v2/src/UpdateChecker.php @@ -8,7 +8,6 @@ use Composer\Factory; use Composer\Installer; use Composer\Package\PackageInterface; -use Composer\Util\Filesystem; final class UpdateChecker { @@ -48,15 +47,6 @@ public static function getLatestResolvableVersion(array $args): ?string $io->loadConfiguration($config); } - $installationManager = new DependabotInstallationManager($composer->getLoop(), $io); - - $fs = new Filesystem(null); - $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs); - - $installationManager->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller)); - $installationManager->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller)); - $installationManager->addInstaller(new Installer\MetapackageInstaller($io)); - $install = new Installer( $io, $config, @@ -64,7 +54,7 @@ public static function getLatestResolvableVersion(array $args): ?string $composer->getDownloadManager(), $composer->getRepositoryManager(), $composer->getLocker(), - $installationManager, + $composer->getInstallationManager(), $composer->getEventDispatcher(), $composer->getAutoloadGenerator() ); @@ -72,6 +62,7 @@ public static function getLatestResolvableVersion(array $args): ?string // For all potential options, see UpdateCommand in composer $install ->setUpdate(true) + ->setInstall(false) ->setDevMode(true) ->setUpdateAllowTransitiveDependencies(Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS) ->setDumpAutoloader(false) @@ -86,7 +77,7 @@ public static function getLatestResolvableVersion(array $args): ?string $install->run(); - $installedPackages = $installationManager->getInstalledPackages(); + $installedPackages = $composer->getLocker()->getLockedRepository(true)->getPackages(); $updatedPackage = current(array_filter($installedPackages, static function (PackageInterface $package) use ($dependencyName): bool { return $package->getName() === $dependencyName; diff --git a/composer/helpers/v2/src/Updater.php b/composer/helpers/v2/src/Updater.php index 3b2cb7191b5..3210ade81e0 100644 --- a/composer/helpers/v2/src/Updater.php +++ b/composer/helpers/v2/src/Updater.php @@ -78,6 +78,7 @@ public static function update(array $args): array $install ->setWriteLock(true) ->setUpdate(true) + ->setInstall(false) ->setDevMode(true) ->setUpdateAllowList([$dependencyName]) ->setUpdateAllowTransitiveDependencies(Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS) diff --git a/composer/spec/dependabot/composer/file_updater/lockfile_updater_spec.rb b/composer/spec/dependabot/composer/file_updater/lockfile_updater_spec.rb index fc6d62a68bd..d0684e1cd79 100644 --- a/composer/spec/dependabot/composer/file_updater/lockfile_updater_spec.rb +++ b/composer/spec/dependabot/composer/file_updater/lockfile_updater_spec.rb @@ -311,37 +311,8 @@ let(:project_name) { "env_variable" } context "that hasn't been provided" do - it "raises a MissingEnvironmentVariable error" do - expect { updated_lockfile_content }.to raise_error do |error| - expect(error).to be_a(Dependabot::MissingEnvironmentVariable) - expect(error.message).to eq("Missing environment variable ACF_PRO_KEY") - end - end - end - - context "that has been provided" do - let(:updater) do - described_class.new( - dependency_files: files, - dependencies: [dependency], - credentials: [{ - "type" => "git_source", - "host" => "github.com", - "username" => "x-access-token", - "password" => "token" - }, { - "type" => "php_environment_variable", - "env-key" => "ACF_PRO_KEY", - "env-value" => "example_key" - }] - ) - end - - it "runs just fine (we get a 404 here because our key is wrong)" do - expect { updated_lockfile_content }.to raise_error do |error| - expect(error).to be_a(Dependabot::DependencyFileNotResolvable) - expect(error.message).to include("404") - end + it "does not attempt to download and has details of the updated item" do + expect(updated_lockfile_content).to include("\"version\":\"5.9.2\"") end end end @@ -544,11 +515,8 @@ }] end - it "raises a helpful errors" do - expect { updated_lockfile_content }.to raise_error do |error| - expect(error).to be_a Dependabot::PrivateSourceAuthenticationFailure - expect(error.source).to eq("nova.laravel.com") - end + it "does not attempt to download and has details of the updated item" do + expect(updated_lockfile_content).to include("\"version\":\"v2.0.9\"") end end end @@ -577,11 +545,8 @@ ) end - it "raises a helpful errors" do - expect { updated_lockfile_content }.to raise_error do |error| - expect(error).to be_a Dependabot::GitDependencyReferenceNotFound - expect(error.dependency).to eq("monolog/monolog") - end + it "does not attempt to install it and has details of the updated item" do + expect(updated_lockfile_content).to include("\"version\":\"v1.6.0\"") end end @@ -609,12 +574,8 @@ ) end - it "raises a helpful errors" do - expect { updated_lockfile_content }.to raise_error do |error| - expect(error).to be_a Dependabot::GitDependencyReferenceNotFound - expect(error.dependency). - to eq("monolog/monolog") - end + it "does not attempt to install it and has details of the updated item" do + expect(updated_lockfile_content).to include("\"version\":\"v1.6.0\"") end end