protected function waitLoop(OutputInterface $output) { $start = time(); $version = $this->version->getValue(); while ($start + $this->timeout >= time()) { // todo - this line should get project name throw new Exception("todo"); $versions = Composer::getLibraryVersions($this->getCommandRunner($output), $this->project); if (in_array($version, $versions)) { return; } // Wait $this->log($output, "Version {$version} not available; checking again in 20 seconds"); // Progress bar for 20 seconds $progress = new ProgressBar($output, 20); $progress->start(); for ($i = 0; $i < 20; $i++) { $progress->advance(); sleep(1); } $progress->finish(); $output->writeln(''); } // Timeout throw new Exception("Waiting for version {$version} to be available timed out after " . $this->timeout . " seconds"); }
/** * Get best version to install * * @param OutputInterface $output * @return string * @throws InvalidArgumentException */ protected function getBestVersion(OutputInterface $output) { $this->log($output, 'Determining best version to install'); // Find all versions for the given recipe $available = Composer::getLibraryVersions($this->getCommandRunner($output), $this->getRecipe()); // Choose based on available and preference $versions = $this->getVersion()->getComposerVersions(); foreach ($versions as $version) { if (in_array($version, $available)) { return $version; } } throw new InvalidArgumentException("Could not install project from version " . $this->version->getValue()); }