/**
  * Returns the installation path of a package
  *
  * @param  PackageInterface $package
  *
  * @return string
  */
 public function getInstallPath(PackageInterface $package)
 {
     if ($package->isDev()) {
         return $this->symlinkInstaller->getInstallPath($package);
     }
     return $this->defaultInstaller->getInstallPath($package);
 }
 /**
  * Returns the installation path of a package
  *
  * @param  PackageInterface $package
  *
  * @return string
  */
 public function getInstallPath(PackageInterface $package)
 {
     if ($this->solver->isSharedPackage($package)) {
         return $this->symlinkInstaller->getInstallPath($package);
     }
     return $this->defaultInstaller->getInstallPath($package);
 }
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $type = $package->getType();
     $prettyName = $package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
     } else {
         $vendor = '';
         $name = $prettyName;
     }
     $availableVars = compact('name', 'vendor', 'type');
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         $availableVars['name'] = $extra['installer-name'];
     }
     if ($this->composer->getPackage()) {
         $pkg_extra = $this->composer->getPackage()->getExtra();
         if (!empty($pkg_extra['installer-paths'])) {
             $customPath = $this->mapCustomInstallPaths($pkg_extra['installer-paths'], $prettyName, $type);
             if ($customPath !== false) {
                 return $this->templatePath($customPath, $availableVars);
             }
         }
     }
     if (empty($extra['installer-path'])) {
         return parent::getInstallPath($package);
     }
     return $this->templatePath($extra['installer-path'], $availableVars);
 }
 public function getInstallPath(PackageInterface $package)
 {
     $packageName = $package->getPrettyName();
     $packageExtra = $this->composer->getPackage()->getExtra();
     if (false === array_key_exists('wordpress-install-dir', $packageExtra)) {
         return parent::getInstallPath($package);
     }
     $installDirs = $packageExtra['wordpress-install-dir'];
     if (false === is_array($installDirs)) {
         throw new InvalidPackageException(['Installation directory must be a key value array of packages and install directories.'], [], [$installDirs]);
     }
     if (false === array_key_exists($packageName, $installDirs)) {
         throw new InvalidPackageException(['Installation directory must be a key value array of packages and install directories.'], [], [$installDirs]);
     }
     $packageInstallDir = $installDirs[$packageName];
     $installDirCount = 0;
     foreach ($installDirs as $installDir) {
         if ($installDir === $packageInstallDir) {
             $installDirCount++;
         }
     }
     if ($installDirCount > 1) {
         throw new InvalidPackageException(['Two packages cannot have the same install directory'], [], $installDirs);
     }
     return $installDirs[$packageName];
 }
 public function getInstallPath(PackageInterface $package)
 {
     $installer = new InstallerHelper($package, $this->composer, $this->io);
     $path = $installer->getInstallPath($package, $package->getType());
     // if the path is false, use the default installer path instead
     return $path !== false ? $path : LibraryInstaller::getInstallPath($package);
 }
예제 #6
0
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $type = $package->getType();
     if (!$this->supports($type)) {
         throw new \InvalidArgumentException("Package type '{$type}' is not supported at this time.");
     }
     if ($type === 'projek-ci-module') {
         return parent::getInstallPath($package);
     }
     $prettyName = $package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
     } else {
         $vendor = '';
         $name = $prettyName;
     }
     $extra = ($pkg = $this->composer->getPackage()) ? $pkg->getExtra() : array();
     $appdir = !empty($extra['codeigniter-application-dir']) ? $extra['codeigniter-application-dir'] : 'application';
     $install_paths = $this->package_install_paths;
     if (!empty($extra['codeigniter-module-dir'])) {
         $moduleDir = $extra['codeigniter-module-dir'];
         $install_paths['codeigniter-module'] = $moduleDir . '/{name}/';
     }
     if (!empty($extra['codeigniter-subclass-prefix'])) {
         $this->package_subclass_prefix = $extra['codeigniter-subclass-prefix'];
     }
     $vars = array('{name}' => $name, '{vendor}' => $vendor, '{type}' => $type, '{application}' => $appdir);
     return str_replace(array_keys($vars), array_values($vars), $install_paths[$type]);
 }
예제 #7
0
 public function getInstallPath(PackageInterface $package)
 {
     $type = $package->getType();
     if ($this->supports($type)) {
         $directory = $this->getDirectory($type, $package);
         if (!empty($directory)) {
             return $directory;
         }
     }
     $names = $package->getNames();
     if ($this->composer->getPackage()) {
         $extra = $this->composer->getPackage()->getExtra();
         if (!empty($extra['installer-paths'])) {
             foreach ($extra['installer-paths'] as $path => $packageNames) {
                 foreach ($packageNames as $packageName) {
                     if (in_array(strtolower($packageName), $names)) {
                         return $path;
                     }
                 }
             }
         }
     }
     /*
      * In case, the user didn't provide a custom path
      * use the default one, by calling the parent::getInstallPath function
      */
     return parent::getInstallPath($package);
 }
예제 #8
0
 /**
  * Overridden to take into account the root package
  *
  * @see \Composer\Installer\LibraryInstaller::getInstallPath()
  */
 public function getInstallPath(PackageInterface $package)
 {
     if ($package instanceof RootPackageInterface) {
         return '.';
     }
     return parent::getInstallPath($package);
 }
 /**
  * {@inheritdoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $drupalLibraries = ['enyo/dropzone'];
     if (in_array($package->getPrettyName(), $drupalLibraries)) {
         return getcwd() . '/docroot/libraries/' . explode('/', $package->getPrettyName())[1];
     }
     return parent::getInstallPath($package);
 }
예제 #10
0
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (array_key_exists("install-path", $extra)) {
         return $extra["install-path"];
     } else {
         return parent::getInstallPath($package);
     }
 }
 /**
  *
  * @param PackageInterface $package        	
  *
  * @return string a path relative to the root of the composer.json that is being installed.
  */
 public function getInstallPath(PackageInterface $package)
 {
     // custom install path only when it is the keeko/keeko package
     if ($this->root->getName() == 'keeko/keeko') {
         return 'packages/' . $package->getName();
     }
     // ... anyway return the default
     return parent::getInstallPath($package);
 }
예제 #12
0
 public function getInstallPath(PackageInterface $package)
 {
     $strDest = parent::getInstallPath($package);
     $parts = explode('_', $package->getName());
     if ('qcubed/plugin' === $parts[0]) {
         $strDest = ($this->vendorDir ? $this->vendorDir . '/' : '') . 'qcubed/plugin/' . $parts[1];
     }
     return $strDest;
 }
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     if (empty($this->drupalLibraryMap[$package->getPrettyName()])) {
         $path = parent::getInstallPath($package);
     } else {
         $path = $this->drupalLibrariesPath . $this->drupalLibraryMap[$package->getPrettyName()];
     }
     return $path;
 }
 /**
  * Determines the install path for git hooks,
  *
  * The installation path is the standard git hooks directory documented here:
  * https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
  *
  * @param PackageInterface $package
  *
  * @return string a path relative to the root of the composer.json that is being installed.
  */
 public function getInstallPath(PackageInterface $package)
 {
     if (!$this->supports($package->getType())) {
         throw new \InvalidArgumentException('Unable to install package, git-hook packages only ' . 'support "git-hook", "library" type packages.');
     }
     // Allow to LibraryInstaller to resolve the installPath for other packages.
     if ($package->getType() !== 'git-hook') {
         return parent::getInstallPath($package);
     }
     return $this->getGitHooksPath();
 }
예제 #15
0
 /**
  * {@inheritdoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     switch ($package->getType()) {
         case self::TYPE_MOODLE_SOURCE:
             $basePath = $this->getMoodleDir();
             break;
         default:
             $basePath = parent::getInstallPath($package);
     }
     return $basePath;
 }
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $configuration = $this->getPluginConfiguration();
     $pattern = $configuration->getPattern($package);
     if ($pattern) {
         $basePath = $this->buildPath($pattern, $this->getPackageReplacementTokens($package));
         $targetDir = $package->getTargetDir();
         return $basePath . ($targetDir ? '/' . $targetDir : '');
     } else {
         return parent::getInstallPath($package);
     }
 }
 public function getInstallPath(PackageInterface $package)
 {
     $path = PackageUtils::getPackageInstallPath($package, $this->composer);
     if (!empty($path)) {
         return $path;
     }
     /*
      * In case, the user didn't provide a custom path
      * use the default one, by calling the parent::getInstallPath function
      */
     return parent::getInstallPath($package);
 }
예제 #18
0
 /**
  * See {@link Composer\Installer\InstallerInterface::getInstallPath()} for details.
  *
  * @param PackageInterface $package The package that will be installed.
  * @return string The installation path.
  */
 public function getInstallPath(PackageInterface $package)
 {
     $path = $this->getInstallPathFromRoot($package);
     if ($path !== null) {
         return $path;
     }
     $path = $this->getInstallpathFromPackage($package);
     if ($path !== null) {
         return $path;
     }
     // No path configured, use default behavior as fallback.
     return parent::getInstallPath($package);
 }
예제 #19
0
 public function testGetInstallPathWithTargetDir()
 {
     $library = new LibraryInstaller($this->vendorDir, $this->binDir, $this->dm, $this->repository, $this->io);
     $package = $this->createPackageMock();
     $package->expects($this->once())->method('getTargetDir')->will($this->returnValue('Some/Namespace'));
     $package->expects($this->any())->method('getPrettyName')->will($this->returnValue('foo/bar'));
     $this->assertEquals($this->vendorDir . '/' . $package->getPrettyName() . '/Some/Namespace', $library->getInstallPath($package));
 }
예제 #20
0
 /**
  * @inheritdoc
  * @override
  */
 public function getInstallPath(PackageInterface $package)
 {
     $this->packages[$package->getName()] = $package->getExtra();
     return parent::getInstallPath($package);
 }
예제 #21
0
파일: Installer.php 프로젝트: vv-team/foodo
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     if (!is_null($this->modmanRootDir) && true === $this->modmanRootDir->isDir()) {
         $targetDir = $package->getTargetDir();
         if (!$targetDir) {
             list($vendor, $targetDir) = explode('/', $package->getPrettyName());
         }
         $installPath = $this->modmanRootDir . '/' . $targetDir;
     } else {
         $installPath = parent::getInstallPath($package);
     }
     // Make install path absolute. This is needed in the symlink deploy strategies.
     if (DIRECTORY_SEPARATOR !== $installPath[0] && $installPath[1] !== ':') {
         $installPath = getcwd() . "/{$installPath}";
     }
     return $installPath;
 }
예제 #22
0
 public function dropNewFiles(PackageInterface $package)
 {
     //Gather all information for dropin directives
     $info = array();
     //Composer doesn't care about uppercase and so shouldn't we
     $info['package'] = strtolower($package->getName());
     $info['vendor'] = substr($info['package'], 0, strpos($info['package'], '/'));
     $info['type'] = $package->getType();
     #Locate absolute urls
     $projectDir = getcwd();
     #Get directives from composer.json
     $extra = $this->composer->getPackage()->getExtra();
     if (isset($extra['dropin-paths'])) {
         $paths = self::getPaths($extra['dropin-paths']);
     } else {
         //Stop here if dropin-paths is not defined.
         return;
     }
     $dest = self::installPath($info);
     //If dropin has nothing to do with this package just end it now
     if (!$dest) {
         return;
     } else {
         $dest = "{$projectDir}/{$dest}";
         //Update to full path
     }
     //Compatibility with composer/installers
     if (class_exists('\\Composer\\Installers\\Installer')) {
         $installer = new Installer($this->io, $this->composer);
     } else {
         //System default
         $installer = new LibraryInstaller($this->io, $this->composer);
     }
     try {
         $src = realpath($installer->getInstallPath($package));
     } catch (\InvalidArgumentException $e) {
         // We will end up here if composer/installers doesn't recognise the type
         // In this case it's the default installation folder in vendor
         $vendorDir = $this->composer->getConfig()->get('vendor-dir');
         $vendorDir = realpath($vendorDir);
         $src = "{$vendorDir}/{$info['package']}";
     }
     $installFiles = self::getFilesToInstall($info);
     $this->io->write("    Moving dropin files...\n");
     if ($installFiles == "*") {
         self::rmove($src, $dest);
     } else {
         foreach ($installFiles as $file) {
             self::move("{$src}/{$file}", $dest);
         }
     }
 }
 public function getInstallPath(PackageInterface $package)
 {
     $names = $package->getNames();
     if ($this->composer->getPackage()) {
         $extra = $this->composer->getPackage()->getExtra();
         if (!empty($extra['installer-paths'])) {
             foreach ($extra['installer-paths'] as $path => $packageNames) {
                 foreach ($packageNames as $packageName) {
                     if (in_array(strtolower($packageName), $names)) {
                         if ($matched = preg_match_all("/\\{(.*?)\\}/is", $path, $matches, PREG_PATTERN_ORDER)) {
                             $packageParts = explode('/', $packageName);
                             foreach ($matches[1] as $pattern) {
                                 $patternParts = explode('|', $pattern);
                                 $flags = array();
                                 if (count($patternParts) > 1) {
                                     $flags = str_split($patternParts[1]);
                                 }
                                 switch ($patternParts[0]) {
                                     case '$package':
                                         $value = $packageName;
                                         break;
                                     case '$name':
                                         if (count($packageParts) > 1) {
                                             $value = $packageParts[1];
                                         } else {
                                             $value = 'undefined';
                                         }
                                         break;
                                     case '$vendor':
                                         if (count($packageParts) > 1) {
                                             $value = $packageParts[0];
                                         } else {
                                             $value = 'undefined';
                                         }
                                         break;
                                 }
                                 foreach ($flags as $flag) {
                                     switch ($flag) {
                                         case 'F':
                                             $value = ucfirst($value);
                                             break;
                                         case 'P':
                                             $value = preg_replace_callback('/[_\\-]([a-zA-Z])/', function ($matches) {
                                                 return strtoupper($matches[1]);
                                             }, $value);
                                             break;
                                     }
                                 }
                                 $path = str_replace('{' . $pattern . '}', $value, $path);
                             }
                         }
                         return $path;
                     }
                 }
             }
         }
     }
     /*
      * In case, the user didn't provide a custom path
      * use the default one, by calling the parent::getInstallPath function
      */
     return parent::getInstallPath($package);
 }
예제 #24
0
 /**
  * @depends testInstallerCreationShouldNotCreateVendorDirectory
  * @depends testInstallerCreationShouldNotCreateBinDirectory
  */
 public function testEnsureBinariesInstalled()
 {
     $binaryInstallerMock = $this->getMockBuilder('Composer\\Installer\\BinaryInstaller')->disableOriginalConstructor()->getMock();
     $library = new LibraryInstaller($this->io, $this->composer, 'library', null, $binaryInstallerMock);
     $package = $this->createPackageMock();
     $binaryInstallerMock->expects($this->never())->method('removeBinaries')->with($package);
     $binaryInstallerMock->expects($this->once())->method('installBinaries')->with($package, $library->getInstallPath($package), false);
     $library->ensureBinariesPresence($package);
 }