コード例 #1
0
 public function __construct(IOInterface $io, Composer $composer, $type = null)
 {
     if ($composer->getConfig()->has('composer-global-installer')) {
         $this->_isInUse = true;
         $this->_config = $composer->getConfig()->get('composer-global-installer');
         if (isset($this->_config['vendor-global-dir'])) {
             $this->_globalDir = $this->_config['vendor-global-dir'];
         }
         if (isset($this->_config['vendor-global-types'])) {
             // Bad format, use default
             // @todo throw exception
             if (is_array($this->_config['vendor-global-types'])) {
                 $this->_supportedTypes = $this->_config['vendor-global-types'];
             }
         }
         if ($composer->getConfig()->has('vendor-global-packages')) {
             // Bad format, use default
             // @todo throw exception
             if (is_array($composer->getConfig()->get('vendor-global-packages'))) {
                 $this->_globalPackages = $composer->getConfig()->get('vendor-global-packages');
             }
         }
     }
     parent::__construct($io, $composer, $type);
 }
コード例 #2
0
 public function processCopy(array $config)
 {
     $config = $this->processConfig($config);
     $project_path = \realpath($this->composer->getConfig()->get('vendor-dir') . '/../') . '/';
     $debug = $config['debug'];
     if ($debug) {
         $this->io->write('[sasedev/composer-plugin-filecopier] basepath : ' . $project_path);
     }
     $destination = $config['destination'];
     if (\strlen($destination) == 0 || \strlen($destination) != 0 && !$this->startsWith($destination, '/')) {
         $destination = $project_path . $destination;
     }
     if (false === \realpath($destination)) {
         mkdir($destination, 0755, true);
     }
     $destination = \realpath($destination);
     $source = $config['source'];
     if ($debug) {
         $this->io->write('[sasedev/composer-plugin-filecopier] init source : ' . $source);
         $this->io->write('[sasedev/composer-plugin-filecopier] init destination : ' . $destination);
     }
     $sources = \glob($source, GLOB_MARK);
     if (!empty($sources)) {
         foreach ($sources as $newsource) {
             $this->copyr($newsource, $destination, $project_path, $debug);
         }
     }
 }
コード例 #3
0
 public function changeDirectory($cwd)
 {
     $this->cwd = realpath($cwd);
     if (!$this->cwd) {
         throw new Exception($cwd . 'doesn\'t exist');
     }
     $this->vendorDir = rtrim($this->cwd . '/' . $this->composer->getConfig()->get('vendor-dir'), '/');
 }
コード例 #4
0
ファイル: Plugin.php プロジェクト: vbuilder/composer-plugin
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     $this->fs = new FileSystem();
     $this->process = new ProcessExecutor($this->io);
     $this->config = $this->composer->getConfig();
 }
コード例 #5
0
ファイル: StudioPlugin.php プロジェクト: franzliedke/studio
 /**
  * Register all managed paths with Composer.
  *
  * This function configures Composer to treat all Studio-managed paths as local path repositories, so that packages
  * therein will be symlinked directly.
  */
 public function registerStudioPackages()
 {
     $repoManager = $this->composer->getRepositoryManager();
     $composerConfig = $this->composer->getConfig();
     foreach ($this->getManagedPaths() as $path) {
         $this->io->writeError("[Studio] Loading path {$path}");
         $repoManager->prependRepository(new PathRepository(['url' => $path], $this->io, $composerConfig));
     }
 }
コード例 #6
0
 /**
  * Pre Package event behaviour for backing up preserved paths.
  *
  * @param \Composer\Script\PackageEvent $event
  */
 public function prePackage(PackageEvent $event)
 {
     $packages = $this->getPackagesFromEvent($event);
     $paths = $this->getInstallPathsFromPackages($packages);
     $preserver = new PathPreserver($paths, $this->getPreservePaths(), $this->composer->getConfig()->get('cache-dir'), $this->filesystem, $this->io);
     // Store preserver for reuse in post package.
     $this->preservers[$this->getUniqueNameFromPackages($packages)] = $preserver;
     $preserver->preserve();
 }
 /**
  * {@inheritdoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $extra = $composer->getPackage()->getExtra();
     $this->moduleContainer = new ModuleContainer($extra[static::COMPOSER_CONFIG_KEY_EXTRA]['path'], $extra[static::COMPOSER_CONFIG_KEY_EXTRA]['filename']);
     $this->finder = new Finder();
     $this->parser = new RegisterFileParser();
     $this->manipulator = new AutoloadManipulator($composer->getConfig()->get('vendor-dir'));
     $this->dumper = new AutoloadDumper($composer->getConfig()->get('vendor-dir'), new ArrayToText());
 }
コード例 #8
0
ファイル: LibraryInstaller.php プロジェクト: nickelc/composer
 /**
  * Initializes library installer.
  *
  * @param IOInterface $io
  * @param Composer    $composer
  * @param string      $type
  */
 public function __construct(IOInterface $io, Composer $composer, $type = 'library')
 {
     $this->composer = $composer;
     $this->downloadManager = $composer->getDownloadManager();
     $this->io = $io;
     $this->type = $type;
     $this->filesystem = new Filesystem();
     $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
     $this->binDir = rtrim($composer->getConfig()->get('bin-dir'), '/');
 }
コード例 #9
0
 /**
  * Initializes library installer.
  *
  * @param IOInterface          $io
  * @param Composer             $composer
  * @param string               $type
  * @param Filesystem           $filesystem
  * @param BinaryInstaller      $binaryInstaller
  */
 public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
 {
     $this->composer = $composer;
     $this->downloadManager = $composer->getDownloadManager();
     $this->io = $io;
     $this->type = $type;
     $this->filesystem = $filesystem ?: new Filesystem();
     $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
     $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
 }
コード例 #10
0
ファイル: Plugin.php プロジェクト: graurus/testgit_t37
 /**
  * {@inheritDoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $filesystem = new Filesystem();
     $composer->getInstallationManager()->addInstaller(new CoreInstaller($composer, $filesystem, new CoreInstaller\GetTypo3OrgService($io)));
     $composer->getInstallationManager()->addInstaller(new ExtensionInstaller($composer, $filesystem));
     $cache = null;
     if ($composer->getConfig()->get('cache-files-ttl') > 0) {
         $cache = new Cache($io, $composer->getConfig()->get('cache-files-dir'), 'a-z0-9_./');
     }
     $composer->getDownloadManager()->setDownloader('t3x', new Downloader\T3xDownloader($io, $composer->getConfig(), null, $cache));
 }
コード例 #11
0
 public function onPreFileDownload(PreFileDownloadEvent $event)
 {
     $url = $event->getProcessedUrl();
     $host = parse_url($url, PHP_URL_HOST);
     $protocol = parse_url($url, PHP_URL_SCHEME);
     if (in_array($host, $this->hosts, true) && ($protocol === 'http' || $protocol === 'https')) {
         $orig = $event->getRemoteFilesystem();
         $curl = new CurlRemoteFilesystem($this->curlClient, $this->io, $this->composer->getConfig(), $orig->getOptions());
         $event->setRemoteFilesystem($curl);
     }
 }
コード例 #12
0
 public function postAutoloadDump(Event $event)
 {
     // This method is called twice. Run it only once.
     if (!$this->runPostAutoloadDump) {
         return;
     }
     $this->runPostAutoloadDump = false;
     $config = $this->composer->getConfig();
     $suffix = $config->get('autoloader-suffix');
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     $autoloadFile = $vendorDir . '/autoload.php';
     if (!file_exists($autoloadFile)) {
         throw new \RuntimeException(sprintf('Could not adjust autoloader: The file %s was not found.', $autoloadFile));
     }
     if (!$suffix && !$config->get('autoloader-suffix') && is_readable($autoloadFile)) {
         $content = file_get_contents($vendorDir . '/autoload.php');
         if (preg_match('{' . self::COMPOSER_AUTOLOADER_BASE . '([^:\\s]+)::}', $content, $match)) {
             $suffix = $match[1];
         }
     }
     $contents = file_get_contents($autoloadFile);
     $constant = '';
     $values = array('AUTOLOAD_CLASS' => var_export(self::COMPOSER_AUTOLOADER_BASE . $suffix, true));
     foreach ($values as $key => $value) {
         $this->io->write('<info>Generating ' . $this->constantPrefix . $key . ' constant</info>');
         $constant .= "if (!defined('{$this->constantPrefix}{$key}')) {\n";
         $constant .= sprintf("    define('{$this->constantPrefix}{$key}', %s);\n", $value);
         $constant .= "}\n\n";
     }
     $values = array_map(function ($value) {
         return var_export($value, true);
     }, array('BASE_DIR' => Path::makeRelative(getcwd(), $vendorDir), 'BIN_DIR' => Path::makeRelative($binDir, $vendorDir), 'FILE' => Path::makeRelative(realpath(Factory::getComposerFile()), $vendorDir)));
     foreach ($values as $key => $value) {
         $this->io->write('<info>Generating ' . $this->constantPrefix . $key . ' constant</info>');
         $constant .= "if (!defined('{$this->constantPrefix}{$key}')) {\n";
         $constant .= sprintf("    define('{$this->constantPrefix}{$key}', realpath(__DIR__ . DIRECTORY_SEPARATOR . %s));\n", $value);
         $constant .= "}\n\n";
     }
     $values = array('VENDOR_DIR' => $vendorDir);
     foreach ($values as $key => $value) {
         $this->io->write('<info>Generating ' . $this->constantPrefix . $key . ' constant</info>');
         $constant .= "if (!defined('{$this->constantPrefix}{$key}')) {\n";
         $constant .= sprintf("    define('{$this->constantPrefix}{$key}', realpath(__DIR__));\n");
         $constant .= "}\n\n";
     }
     // Regex modifiers:
     // "m": \s matches newlines
     // "D": $ matches at EOF only
     // Translation: insert before the last "return" in the file
     $contents = preg_replace('/\\n(?=return [^;]+;\\s*$)/mD', "\n" . $constant, $contents);
     file_put_contents($autoloadFile, $contents);
 }
コード例 #13
0
ファイル: Plugin.php プロジェクト: opis/colibri
 /**
  * Apply plugin modifications to Composer
  *
  * @param Composer $composer
  * @param IOInterface $io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->io = $io;
     $this->composer = $composer;
     $rootDir = realpath($this->composer->getConfig()->get('vendor-dir') . '/../');
     $settings = $this->composer->getPackage()->getExtra()['application'] ?? [];
     $this->appInfo = new AppInfo($rootDir, $settings);
     $this->componentInstaller = new ComponentInstaller($this->appInfo, $io, $composer);
     $this->assetsInstaller = new AssetsInstaller($this->appInfo, $io, $composer);
     $manager = $this->composer->getInstallationManager();
     $manager->addInstaller($this->componentInstaller);
     $manager->addInstaller($this->assetsInstaller);
 }
コード例 #14
0
 public function activate(Composer $composer, IOInterface $io)
 {
     if ($package = $composer->getPackage()) {
         $this->setConfig(Config::createFromPackage($package));
     }
     $repo = new CompositeRepository(array(new WordPressCoreRepository($io, $composer->getConfig()), new WordPressThemeRepository($io, $composer->getConfig()), new WordPressPluginRepository($io, $composer->getConfig())));
     $composer->getRepositoryManager()->addRepository($repo);
     $im = $composer->getInstallationManager();
     $im->addInstaller(new CoreInstaller($io, $composer, $this));
     $im->addInstaller(new ThemeInstaller($io, $composer, $this));
     $im->addInstaller(new PluginInstaller($io, $composer, $this));
     $im->addInstaller(new MuPluginInstaller($io, $composer, $this));
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     // Retrieve the configuration variables.
     $this->config = $this->composer->getConfig();
     if (isset($this->config)) {
         if ($this->config->has('component-dir')) {
             $this->componentDir = $this->config->get('component-dir');
         }
     }
     // Get the available packages.
     $allPackages = array();
     /** @var \Composer\Package\Locker $locker */
     $locker = $this->composer->getLocker();
     if ($locker !== null && $locker->isLocked()) {
         $lockData = $locker->getLockData();
         $allPackages = $lockData['packages'];
         // Also merge in any of the development packages.
         $dev = isset($lockData['packages-dev']) ? $lockData['packages-dev'] : array();
         foreach ($dev as $package) {
             $allPackages[] = $package;
         }
     }
     // Only add those packages that we can reasonably
     // assume are components into our packages list
     /** @var \Composer\Package\RootPackageInterface $rootPackage */
     $rootPackage = $this->composer->getPackage();
     $rootExtras = $rootPackage ? $rootPackage->getExtra() : array();
     $customComponents = isset($rootExtras['component']) ? $rootExtras['component'] : array();
     foreach ($allPackages as $package) {
         $name = $package['name'];
         if (isset($customComponents[$name]) && is_array($customComponents[$name])) {
             $package['extra'] = array('component' => $customComponents[$name]);
             $this->packages[] = $package;
         } else {
             $extra = isset($package['extra']) ? $package['extra'] : array();
             if (isset($extra['component']) && is_array($extra['component'])) {
                 $this->packages[] = $package;
             }
         }
     }
     // Add the root package to the packages list.
     $root = $this->composer->getPackage();
     if ($root) {
         $dumper = new ArrayDumper();
         $package = $dumper->dump($root);
         $package['is-root'] = true;
         $this->packages[] = $package;
     }
     return true;
 }
コード例 #16
0
ファイル: Plugin.php プロジェクト: Aleksandr-Kachura/magento
 /**
  * @return ModuleManager
  */
 protected function getModuleManager()
 {
     if (null === $this->moduleManager) {
         $this->moduleManager = new ModuleManager(new InstalledPackageFileSystemRepository(rtrim($this->composer->getConfig()->get(self::VENDOR_DIR_KEY), '/') . '/installed.json', new InstalledPackageDumper()), $this->getEventManager(), $this->config, new UnInstallStrategy($this->filesystem, $this->config->getMagentoRootDir()), new InstallStrategyFactory($this->config, new ParserFactory($this->config)));
     }
     return $this->moduleManager;
 }
コード例 #17
0
ファイル: IgnoreFactory.php プロジェクト: MvegaR/ingSotfware
 /**
  * Get the installation directory of the package.
  *
  * @param Composer         $composer   The composer instance
  * @param PackageInterface $package    The package instance
  * @param string|null      $installDir The custom installation directory
  *
  * @return string The installation directory
  */
 protected static function getInstallDir(Composer $composer, PackageInterface $package, $installDir = null)
 {
     if (null === $installDir) {
         $installDir = rtrim($composer->getConfig()->get('vendor-dir'), '/') . '/' . $package->getName();
     }
     return rtrim($installDir, '/');
 }
コード例 #18
0
ファイル: Plugin.php プロジェクト: harimau99/prestissimo
 public function activate(Composer $composer, IO\IOInterface $io)
 {
     $this->composer = $composer;
     $this->config = $composer->getConfig();
     $this->io = $io;
     $this->pluginConfig = $this->setPluginConfig();
 }
コード例 #19
0
ファイル: GrumPHPPlugin.php プロジェクト: octava/geggs
 /**
  * Run the GrumPHP console to (de)init the git hooks
  *
  * @param $command
  */
 protected function runGrumPhpCommand($command)
 {
     $config = $this->composer->getConfig();
     $baseDir = $this->getObjectProtectedProperty($config, 'baseDir');
     $configFilename = !empty($config->get('extra')['grumphp']['config-default-path']) ? $config->get('extra')['grumphp']['config-default-path'] : $baseDir . DIRECTORY_SEPARATOR . 'grumphp.yml';
     if (!file_exists($configFilename)) {
         // Check executable which is running:
         if ($this->io->isVeryVerbose()) {
             $this->io->write(sprintf('<fg=red>File "%s" not found</fg=red>', $configFilename));
         }
         return;
     }
     $application = new \Octava\GeggsApplication();
     /** @var Config $config */
     $config = $application->getContainer()->get('octava_geggs.config');
     $grumPhpConfigData = Yaml::parse(file_get_contents($configFilename));
     $fileSystem = new Filesystem();
     foreach ($config->getVendorDirs() as $item) {
         $grumPhpConfigData['bin_dir'] = '../../../bin';
         $grumPhpConfigYml = Yaml::dump($grumPhpConfigData);
         $vendorConfigFilename = implode(DIRECTORY_SEPARATOR, [$item, 'vendor', 'grumphp.yml']);
         $fileSystem->dumpFile($vendorConfigFilename, $grumPhpConfigYml);
         $gitPreCommitFilename = implode(DIRECTORY_SEPARATOR, [$item, '.git', 'hooks', 'pre-commit']);
         $fileSystem->dumpFile($gitPreCommitFilename, $this->generatePreCommit($vendorConfigFilename));
         $gitCommitMsgFilename = implode(DIRECTORY_SEPARATOR, [$item, '.git', 'hooks', 'commit-msg']);
         $fileSystem->dumpFile($gitCommitMsgFilename, $this->generateCommitMsg($vendorConfigFilename));
         if ($this->io->isVeryVerbose()) {
             $this->io->write(sprintf('Config created %s', $vendorConfigFilename));
             $this->io->write(sprintf('Pre commit hook created %s', $gitPreCommitFilename));
             $this->io->write(sprintf('Commit msg hook created %s', $gitCommitMsgFilename));
         }
     }
     $this->io->write('<fg=yellow>GrumPHP is sniffing your vendors code!</fg=yellow>');
 }
コード例 #20
0
ファイル: Plugin.php プロジェクト: hirak/prestissimo
 public function activate(Composer $composer, IO\IOInterface $io)
 {
     // @codeCoverageIgnoreStart
     // guard for self-update problem
     if (__CLASS__ !== 'Hirak\\Prestissimo\\Plugin') {
         return $this->disable();
     }
     // @codeCoverageIgnoreEnd
     // load all classes
     foreach (self::$pluginClasses as $class) {
         class_exists(__NAMESPACE__ . '\\' . $class);
     }
     $this->io = $io;
     $this->config = $composer->getConfig();
     $this->package = $composer->getPackage();
     if (array_key_exists('argv', $GLOBALS)) {
         foreach ($GLOBALS['argv'] as $arg) {
             switch ($arg) {
                 case 'create-project':
                 case 'update':
                 case 'outdated':
                 case 'require':
                     $this->prefetchComposerRepositories();
                     break 2;
                 case 'install':
                     if (file_exists('composer.json') && !file_exists('composer.lock')) {
                         $this->prefetchComposerRepositories();
                     }
                     break 2;
             }
         }
     }
 }
コード例 #21
0
 /**
  * @param Composer $composer
  * @param IOInterface $io
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
     $this->filesystem = new Filesystem();
 }
コード例 #22
0
 public function onPreFileDownload(PreFileDownloadEvent $event)
 {
     $downloadReplacements = $this->composer->getConfig()->get('download-replacements');
     $searched = false;
     foreach ($downloadReplacements as $search => $replacement) {
         if (strpos($event->getProcessedUrl(), $search) === 0) {
             $searched = true;
             break;
         }
     }
     if ($searched) {
         $qiniu = new FileSystem($this->io, $this->composer->getConfig(), $event->getRemoteFilesystem() ? $event->getRemoteFilesystem()->getOptions() : array());
         $qiniu->setConfig($this->composer->getConfig());
         $event->setRemoteFilesystem($qiniu);
     }
 }
コード例 #23
0
 /**
  * @param \Composer\Composer
  * @param string
  * @param string
  */
 public function dumpFiles(Composer $composer, $paths, $targetDir = 'composer')
 {
     $installationManager = $composer->getInstallationManager();
     $localRepo = $composer->getRepositoryManager()->getLocalRepository();
     $mainPackage = $composer->getPackage();
     $config = $composer->getConfig();
     $filesystem = new Filesystem();
     $basePath = $filesystem->normalizePath(realpath(getcwd()));
     $vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
     $targetDir = $vendorPath . '/' . $targetDir;
     $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
     $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
     $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
     $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
     $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
     $autoloads = $this->parseAutoloads($packageMap, $mainPackage);
     $paths = $this->parseAutoloadsTypeFiles($paths, $mainPackage);
     $autoloads['files'] = array_merge($paths, $autoloads['files']);
     $includeFilesFilePath = $targetDir . '/autoload_files.php';
     if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
         file_put_contents($includeFilesFilePath, $includeFilesFileContents);
     } elseif (file_exists($includeFilesFilePath)) {
         unlink($includeFilesFilePath);
     }
 }
コード例 #24
0
ファイル: MergePlugin.php プロジェクト: dmyerson/d8ecs
 /**
  * Handle an event callback following an install or update command. If our
  * plugin was installed during the run then trigger an update command to
  * process any merge-patterns in the current config.
  *
  * @param Event $event
  */
 public function onPostInstallOrUpdate(Event $event)
 {
     // @codeCoverageIgnoreStart
     if ($this->state->isFirstInstall()) {
         $this->state->setFirstInstall(false);
         $this->logger->debug('<comment>' . 'Running additional update to apply merge settings' . '</comment>');
         $config = $this->composer->getConfig();
         $preferSource = $config->get('preferred-install') == 'source';
         $preferDist = $config->get('preferred-install') == 'dist';
         $installer = Installer::create($event->getIO(), Factory::create($event->getIO(), null, false));
         $installer->setPreferSource($preferSource);
         $installer->setPreferDist($preferDist);
         $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();
     }
     // @codeCoverageIgnoreEnd
 }
コード例 #25
0
 /**
  * Activate Wordpress plugin
  *
  * @param Composer    $composer Composer
  * @param IOInterface $io       IO
  *
  * @return void
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->package = $composer->getPackage();
     $this->io = $io;
     // TODO: get the project root - must be a better way to do this
     $this->projectRoot = realpath(dirname($composer->getConfig()->get('vendor-dir')));
 }
コード例 #26
0
ファイル: Command.php プロジェクト: notadd/framework
 /**
  * @param bool $reload
  *
  * @return int
  */
 protected function updateComposer($reload = false)
 {
     if ($reload) {
         $this->composer = Factory::create($this->io, null, $this->disablePluginsByDefault);
     }
     ini_set('memory_limit', '1024M');
     $this->composer->getDownloadManager()->setOutputProgress(true);
     $install = Installer::create($this->io, $this->composer);
     $config = $this->composer->getConfig();
     $preferSource = false;
     $preferDist = true;
     switch ($config->get('preferred-install')) {
         case 'source':
             $preferSource = true;
             break;
         case 'dist':
             $preferDist = true;
             break;
         case 'auto':
         default:
             break;
     }
     $optimize = $config->get('optimize-autoloader');
     $authoritative = $config->get('classmap-authoritative');
     $install->setPreferSource($preferSource);
     $install->setPreferDist($preferDist);
     $install->setDevMode(true);
     $install->setDumpAutoloader(true);
     $install->setOptimizeAutoloader(true);
     $install->setUpdate(true);
     return $install->run();
 }
コード例 #27
0
 /**
  * @inheritdoc
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->io = $io;
     //Extend download manager
     $dm = $composer->getDownloadManager();
     $executor = new ProcessExecutor($io);
     $fs = new Filesystem($executor);
     $config = $composer->getConfig();
     $dm->setDownloader('svn-export', new Downloader($io, $config, $executor, $fs));
     //Extend RepositoryManager Classes
     $rm = $composer->getRepositoryManager();
     $rm->setRepositoryClass('svn-export', 'LinearSoft\\Composer\\SvnExport\\Repository\\VcsRepository');
     $rm->setRepositoryClass('svn-export-composer', 'LinearSoft\\Composer\\SvnExport\\Repository\\ComposerRepository');
     //Load Extra Data
     $extra = $composer->getPackage()->getExtra();
     if (isset($extra['svn-export-repositories']) && is_array($extra['svn-export-repositories'])) {
         foreach ($extra['svn-export-repositories'] as $index => $repoConfig) {
             $this->validateRepositories($index, $repoConfig);
             if (isset($repoConfig['name'])) {
                 $name = $repoConfig['name'];
             } else {
                 $name = is_int($index) ? preg_replace('{^https?://}i', '', $repoConfig['url']) : $index;
             }
             if ($repoConfig['type'] === 'svn') {
                 $repoConfig['type'] = 'svn-export';
             } else {
                 $repoConfig['type'] = 'svn-export-composer';
             }
             $repo = $rm->createRepository($repoConfig['type'], $repoConfig);
             $rm->addRepository($repo);
             $this->io->write("Added SvnExport repo: {$name}");
         }
     }
 }
コード例 #28
0
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->io = $io;
     $vendor = $composer->getConfig()->get('vendor-dir', '/');
     $this->vendor = $vendor;
     $this->root = dirname($vendor);
 }
コード例 #29
0
 private function _installBower($requires, $overrides, $resolutions)
 {
     $out = [];
     $retVar = null;
     exec("bower --version 2>&1", $out, $retVar);
     if ($retVar) {
         throw new \Exception("Bower isn't installed.");
     } else {
         $bowerBin = 'bower';
     }
     $jsonFile = new JsonFile('bower.json');
     if ($jsonFile->exists()) {
         $packageJson = $jsonFile->read();
         if (!isset($packageJson['name']) || $packageJson['name'] != 'temp-composer-bower-plugin') {
             //assume we can overwrite our own temp one
             throw new \Exception("Can't install Bower dependencies as there is already a bower.json");
         }
     } else {
         $packageJson = ['name' => 'temp-composer-bower-plugin', 'description' => "This file is auto-generated by 'php-kit/composer-bower-plugin'. " . "Warning: do NOT edit this file."];
     }
     $packageJson['dependencies'] = $requires;
     if ($overrides) {
         $packageJson['overrides'] = $overrides;
     }
     if ($resolutions) {
         $packageJson['resolutions'] = $resolutions;
     }
     $jsonFile->write($packageJson);
     if (!file_exists('.bowerrc')) {
         $vd = $this->composer->getConfig()->get('vendor-dir');
         if (substr($vd, 0, strlen(getcwd())) == getcwd()) {
             //make vendor-dir relative go cwd
             $vd = substr($vd, strlen(getcwd()) + 1);
         }
         $config = ['directory' => $vd . '/bower_components'];
         file_put_contents('.bowerrc', json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
     }
     $this->write($requires ? "Installing/updating Bower packages" : "Removing Bower packages (if any)");
     $cmd = "{$bowerBin} --allow-root install";
     passthru($cmd, $retVar);
     if ($retVar) {
         throw new \RuntimeException('bower install failed');
     }
     $cmd = "{$bowerBin} --allow-root prune";
     passthru($cmd, $retVar);
     if ($retVar) {
         throw new \RuntimeException('bower prune failed');
     }
     $config = json_decode(file_get_contents('.bowerrc'), true);
     $installedBowerFiles = glob($config['directory'] . '/*/.bower.json');
     //detect actually installed versions
     $ret = [];
     foreach ($installedBowerFiles as $installedBowerFile) {
         $installedBower = json_decode(file_get_contents($installedBowerFile), true);
         $dep = $installedBower['_source'] . '#' . $installedBower['_release'];
         $ret[$installedBower['name']] = $dep;
     }
     return $ret;
 }
コード例 #30
0
ファイル: Plugin.php プロジェクト: jbzoo/composer-cleanup
 /**
  * {@inheritDoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->composer = $composer;
     $this->io = $io;
     $this->config = $composer->getConfig();
     $this->filesystem = new Filesystem();
     $this->rules = Rules::getRules();
 }