Gets library being installed

@param PackageEvent $event
@return Library|null
772425
public function getLibrary(PackageEvent $event)
    {
        // Ensure package is the valid type
        $package = $this->getOperationPackage($event);
        if (!$package) {
            return null;
        }

        // Get appropriate installer and query install path
        $installer = $event->getComposer()->getInstallationManager()->getInstaller($package->getType());
        $path = $installer->getInstallPath($package);

        // Build module
        return new Library($this->getProjectPath(), $path);
    }
871190
public static function installDrafter(Event $event)
    {
        $io = $event->getIO();
        $composer = $event->getComposer();
        $config = $composer->getConfig();

        $extra = $composer->getPackage()->getExtra();

        if (!isset($extra['drafter-installer-tag'])) {
            $io->writeError('  <error>Please configure drafter-installer in your composer.json:</error>');
            $io->writeError('
  "extra": {
      "drafter-installer-tag": "v3.1.1"
  }
            ');

            return;
        }

        $tag = $extra['drafter-installer-tag'];
        $binDir = $config->get('bin-dir');
        $targetDir = $config->get('vendor-dir') . '/apiaryio/drafter';
        $binSource = $binDir . '/drafter';
        $binTarget = $targetDir . '/bin/drafter';

        $fs = new Filesystem();
        if ($fs->exists($binTarget) && $fs->exists($binSource)) {
            $io->write('  - Installing <info>drafter</info> (<comment>'.$tag.'</comment>)');
            $io->write(sprintf('    Loading from cache', $targetDir));

            return;
        }

        $downloadManager = $composer->getDownloadManager();

        try {
            $package = self::createComposerInMemoryPackage($targetDir, $tag);
            $downloadManager->download($package, $targetDir);

            if (self::getMake() === null) {
                $io->writeError('No knowledge on how to build for your OS');

                return;
            }

            $io->write('    Fetching submodules');
            $process = new Process('git submodule update --init --checkout --recursive');
            $process->setWorkingDirectory($targetDir);
            $process->setTimeout(null);
            $process->run(function ($type, $buffer) use ($io) {
                if (!$io->isVerbose()) {
                    return;
                }
                echo $buffer;
            });

            $io->write('    Compiling drafter (grab a coffee | -v for output)');
            $process = new Process(self::getMake());
            $process->setWorkingDirectory($targetDir);
            $process->setTimeout(null);
            $process->run(function ($type, $buffer) use ($io) {
                if (!$io->isVerbose()) {
                    return;
                }
                echo $buffer;
            });

            $fs->symlink($binTarget, $binSource);

            $process = new Process('chmod +x drafter');
            $process->setWorkingDirectory($binDir);
            $process->run(function ($type, $buffer) use ($io) {
                if (!$io->isVerbose()) {
                    return;
                }
                echo $buffer;
            });

            $io->write('');
        } catch (\Exception $e) {
            $io->writeError($e->getMessage());
        }
    }
94416
public function onPostPackageEvent(PackageEvent $event) {
    $package = $this->getBltPackage($event->getOperation());
    if ($package) {
      // By explicitly setting the blt package, the onPostCmdEvent() will
      // process the update automatically.
      $this->bltPackage = $package;
    }
  }
1113469
public function getAggregatePackageContaining($packageName)
    {
        foreach ($this->packages as $packageNode) {
            if ($packageNode->replaces($packageName)) {
                return $packageNode;
            }
        }

        return null;
    }
1308579
public static function notifyPackage(PackageEvent $event)
    {
        self::addJobByOperationType(
            $event->getOperation(),
            function ($package) {
                return new InstalledPackageNotify($package);
            },
            function ($package) {
                return new RemovedPackageNotify($package);
            },
            function ($package) {
                return new UpdatedPackageNotify($package);
            }
        );
    }
1072793
protected static function packagesInstall($installerInfo, $event) {
		
		// mark if this is an interactive call or not
		self::$isInteractive = $event->getIO()->isInteractive();
		
		// initialize a bunch of stuff like config and console
		self::init();
		
		// reorder packages so the starterkit is first if it's being installed as a package
		if (isset($installerInfo["packages"])) {
			
			$packages = $installerInfo["packages"];
			$packages = array_merge(array_filter($packages, "self::includeStarterKit"), array_filter($packages, "self::excludeStarterKit"));
			
			foreach ($packages as $package) {
				
				// set-up package info
				$extra     = $package["extra"];
				$type      = $package["type"];
				$name      = $package["name"];
				$pathBase  = $package["pathBase"];
				$pathDist  = $package["pathDist"];
				
				// make sure that it has the name-spaced section of data to be parsed. if it exists parse it
				if (!empty($extra)) {
					self::parseComposerExtraList($extra, $name, $pathDist);
				}
				
				// see if the package has a listener
				self::scanForListener($pathBase);
				
				// address other specific needs based on type
				if ($type == "patternlab-patternengine") {
					self::scanForPatternEngineRule($pathBase);
				} else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) {
					$dir = str_replace(Config::getOption("baseDir"), "", $pathBase);
					$dir = ($dir[strlen($dir)-1] == DIRECTORY_SEPARATOR) ? rtrim($dir, DIRECTORY_SEPARATOR) : $dir;
					Config::updateConfigOption("styleguideKit",$name);
					Config::updateConfigOption("styleguideKitPath",$dir);
				}
				
			}
			
		}
		
		// make sure user is prompted to install starterkit
		if (!empty($installerInfo["suggestedStarterKits"])) {
			self::promptStarterKitInstall($installerInfo["suggestedStarterKits"]);
		}
		
		// override any configs that have been set-up
		if (!empty($installerInfo["configOverrides"])) {
			foreach ($installerInfo["configOverrides"] as $option => $value) {
				Config::updateConfigOption($option,$value, true); // forces the update
			}
		}
		
		if ($installerInfo["projectInstall"]) {
			
			Console::writeLine("");
			Console::writeLine("<h1><fire3>Thank you for installing...</fire3></h1>", false, true);
			Console::writeLine("<fire1>(                               (             </fire1>");
			Console::writeLine("<fire2>)\ )        )   )               )\ )         )</fire2>");
			Console::writeLine("<fire3>(()/(   ) ( /(( /(  (  (        (()/(    ) ( /(</fire3>");
			Console::writeLine("<fire4>/(_)| /( )\())\())))\ )(   (    /(_))( /( )\())</fire4>");
			Console::writeLine("<fire5>(</fire5><cool>_</cool><fire5>)) )(_)|</fire5><cool>_</cool><fire5>))(</fire5><cool>_</cool><fire5>))//((_|()\  )\ )(</fire5><cool>_</cool><fire5>))  )(_)|(_)\</fire5>");
			Console::writeLine("<cool>| _ </cool><fire6>((</fire6><cool>_</cool><fire6>)</fire6><cool>_| |_| |_</cool><fire6>(</fire6><cool>_</cool><fire6>))  ((</fire6><cool>_</cool><fire6>)</fire6><cool>_</cool><fire6>(</fire6><cool>_</cool><fire6>/(</fire6><cool>| |  </cool><fire6>((</fire6><cool>_</cool><fire6>)</fire6><cool>_| |</cool><fire6>(</fire6><cool>_</cool><fire6>)</fire6>");
			Console::writeLine("<cool>|  _/ _` |  _|  _/ -_)| '_| ' \</cool><fire6>))</fire6><cool> |__/ _` | '_ \  </cool>");
			Console::writeLine("<cool>|_| \__,_|\__|\__\___||_| |_||_||____\__,_|_.__/  </cool>", false, true);

		}
		
	}
355498
public function activateWordPressPlugin(PackageEvent $event)
    {
        if (! $this->isWordPressPlugin($this->getPackage($event))) {
            return;
        }
        
        static::$plugin->getInstanceOf(PluginInteractor::class)->activate(
            $event->getComposer(),
            $event->getIO(),
            preg_replace('/^wpackagist-plugin\//', '', $this->getPackageName($event))
        );
    }
1067729
public function autoRequirePackagesPreUpdate(Event $event)
    {   
        $companyPackages = [];
        $packages = $this->composer->getPackage()->getRequires();
        foreach($packages as $packageName => $package) {
            if($this->startsWith($packageName, $this->vendorName)) {
                $companyPackages[$packageName] = $package;
            }
        }
        $repository = $this->composer->getRepositoryManager();
        foreach($companyPackages as $packageName => $package) {
            if($repository->findPackage($packageName, '*')) {
                unset($companyPackages[$packageName]);
            }
        }
        foreach($companyPackages as $packageName => $package) {
            $name = explode('/', $packageName)[1];
            $url = 'git@github.com:' . $this->vendorName . '/'. $this->vendorName . '.' . $name . '.git';
            $repository->addRepository($repository->createRepository('vcs', ['url' => $url], $packageName)); 
        }
    }
239074
public function cleanWordPressInstallation(PackageEvent $event)
    {
        if ($this->getPackageName($event) != 'johnpbloch/wordpress') {
            return;
        }
        
        static::$plugin->getInstanceOf(WordPressInstallationCleaner::class)->clean($event->getComposer(), $event->getIO());
    }
710660
public function onPostCmdEvent(\Composer\Script\Event $event)
    {
        if (!empty($this->unsupportedPackages)) {
            $this->io->write(
                '<error>You are using Drupal packages that are not supported by the Drupal Security Team!</error>'
            );
            foreach ($this->unsupportedPackages as $package_name => $package) {
                $extra = $package->getExtra();
                $this->io->write(
                    "  - <comment>$package_name:{$package->getVersion()}</comment>: {$extra['drupal']['security-coverage']['message']}"
                );
            }
            $this->io->write(
                '<comment>See https://www.drupal.org/security-advisory-policy for more information.</comment>'
            );
        }
    }
669784
private function runFirstInstall(ScriptEvent $event)
    {
        $installer    = Installer::create(
            $event->getIO(),
            // Create a new Composer instance to ensure full processing of the merged files.
            Factory::create($event->getIO(), null, false)
        );

        $installer->setPreferSource($this->isPreferredInstall('source'));
        $installer->setPreferDist($this->isPreferredInstall('dist'));
        $installer->setDevMode($event->isDevMode());
        $installer->setDumpAutoloader($this->state->shouldDumpAutoloader());
        $installer->setOptimizeAutoloader($this->state->shouldOptimizeAutoloader());

        if ($this->state->forceUpdate()) {
            // Force update mode so that new packages are processed rather than just telling
            // the user that composer.json and composer.lock don't match.
            $installer->setUpdate(true);
        }

        $installer->run();
    }
241940
protected static function getOptions($event)
    {
        $extra = $event->getComposer()->getPackage()->getExtra();

        return array_merge(
            array(
                'npm'   => false,
                'bower' => false
            ),
            isset($extra['dependency-tools']) ? $extra['dependency-tools'] : array()
        );
    }
1028046
public static function packageInConfig(PackageEvent $event)
    {
        self::addJobByOperationType(
            $event->getOperation(),
            function ($package) {
                return new AddConfig($package);
            },
            function ($package) {
                return new RemoveConfig($package);
            }
        );
    }
510188
public static function postAutoloadDump(Event $event)
    {
        $composer = $event->getComposer();
        $config = $composer->getConfig();

        $vendorDir = realpath($config->get('vendor-dir'));

        $packages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
        $pluginsDir = dirname($vendorDir) . DIRECTORY_SEPARATOR . 'plugins';

        $plugins = static::determinePlugins($packages, $pluginsDir, $vendorDir);

        $configFile = static::configFile($vendorDir);
        static::writeConfigFile($configFile, $plugins);
    }
535131
public function checkCoreDependencies(InstallerEvent $event)
    {
        $options = new Options($this->composer->getPackage()->getExtra());
        $installedCorePackages = array();
        foreach ($event->getInstalledRepo()->getPackages() as $package) {
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                $installedCorePackages[$package->getName()] = $package;
            }
        }

        $operations = array_filter($event->getOperations(), function (OperationInterface $o) {
            return in_array($o->getJobType(), array('install', 'uninstall'));
        });

        foreach ($operations as $operation) {
            $p = $operation->getPackage();
            if ($package->getType() === $options->getMagentoCorePackageType()) {
                switch ($operation->getJobType()) {
                    case "uninstall":
                        unset($installedCorePackages[$p->getName()]);
                        break;
                    case "install":
                        $installedCorePackages[$p->getName()] = $p;
                        break;
                }
            }
        }

        if (count($installedCorePackages) > 1) {
            throw new \RuntimeException("Cannot use more than 1 core package");
        }
    }
1039021
protected static function installModule(PackageEvent $event, PackageInterface $module)
    {
        $destDir = self::getModuleDestinationDir($event, $module);

        $fs = new Filesystem();
        $fs->mirror(
            static::getInstallPath($event, $module),
            $destDir
        );
    }
244739
public static function packageInRouting(PackageEvent $event)
    {
        self::addJobByOperationType(
            $event->getOperation(),
            function ($package) {
                return new AddRouting($package);
            },
            function ($package) {
                return new RemoveRouting($package);
            }
        );
    }