/**
  * Retrieve map
  *
  * @return array
  */
 protected function getMap()
 {
     if ($this->map == null) {
         $this->map = [];
         $extra = $this->package->getExtra();
         if (array_key_exists('map', $extra)) {
             $this->map = $extra['map'];
         }
     }
     return $this->map;
 }
 /**
  * @param PackageInterface $package
  *
  * @return string
  * @throws Exception
  */
 private function getPackageName(PackageInterface $package)
 {
     if (is_array($package->getExtra()) && isset($package->getExtra()['installer-name'])) {
         return $package->getExtra()['installer-name'];
     }
     $name = explode('/', $package->getPrettyName());
     $packageName = $name[1];
     if (count(explode('-', $packageName)) < 2) {
         throw new Exception('Bundle names should be like "vendor/NAME-bundle"');
     }
     $packageName = str_replace('-bundle', '', $packageName);
     return str_replace(' ', '', ucwords(str_replace('-', ' ', $packageName)));
 }
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     /**
      * Set install path from root
      */
     $path = $this->getRootInstallPath();
     /**
      * Set install path via package
      */
     if (!$path && $package->getExtra()) {
         $path = $this->getInstallPathFromExtra($package->getExtra());
     }
     $this->recordInstallPath($package, $path);
     return $path;
 }
 public static function getPackageInstallPath(PackageInterface $package, Composer $composer)
 {
     $prettyName = $package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
     } else {
         $vendor = '';
         $name = $prettyName;
     }
     $availableVars = compact('name', 'vendor');
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         $availableVars['name'] = $extra['installer-name'];
     }
     if ($composer->getPackage()) {
         $extra = $composer->getPackage()->getExtra();
         if (!empty($extra['installer-paths'])) {
             $customPath = self::mapCustomInstallPaths($extra['installer-paths'], $prettyName);
             if (false !== $customPath) {
                 return self::templatePath($customPath, $availableVars);
             }
         }
     }
     return NULL;
 }
Example #5
0
 /**
  * {@inheritDoc}
  */
 public function getInstallPath(PackageInterface $package)
 {
     $installationDir = false;
     $prettyName = $package->getPrettyName();
     if ($this->composer->getPackage()) {
         $topExtra = $this->composer->getPackage()->getExtra();
         if (!empty($topExtra['wordpress-install-dir'])) {
             $installationDir = $topExtra['wordpress-install-dir'];
             if (is_array($installationDir)) {
                 $installationDir = empty($installationDir[$prettyName]) ? false : $installationDir[$prettyName];
             }
         }
     }
     $extra = $package->getExtra();
     if (!$installationDir && !empty($extra['wordpress-install-dir'])) {
         $installationDir = $extra['wordpress-install-dir'];
     }
     if (!$installationDir) {
         $installationDir = 'wordpress';
     }
     if (!empty(self::$_installedPaths[$installationDir]) && $prettyName !== self::$_installedPaths[$installationDir]) {
         throw new \InvalidArgumentException('Two packages cannot share the same directory!');
     }
     self::$_installedPaths[$installationDir] = $prettyName;
     return $installationDir;
 }
 /**
  * Return the install path based on package type.
  *
  * @param  PackageInterface $package
  * @param  string           $frameworkType
  * @return string
  */
 public function getInstallPath(PackageInterface $package, $frameworkType = '')
 {
     $type = $this->package->getType();
     $prettyName = $this->package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
     } else {
         $vendor = '';
         $name = $prettyName;
     }
     $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         $availableVars['name'] = $extra['installer-name'];
     }
     if ($this->composer->getPackage()) {
         $extra = $this->composer->getPackage()->getExtra();
         if (!empty($extra['installer-paths'])) {
             $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
             if ($customPath !== false) {
                 return $this->templatePath($customPath, $availableVars);
             }
         }
     }
     $packageType = substr($type, strlen($frameworkType) + 1);
     $locations = $this->getLocations();
     if (!isset($locations[$packageType])) {
         throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
     }
     return $this->templatePath($locations[$packageType], $availableVars);
 }
 /**
  * Provides installation path for package. Kudos go to
  * https://github.com/johnpbloch/wordpress-core-installer
  *
  * @param PackageInterface $package Installed package.
  *
  * @todo refactor
  *
  * @return string
  * @since 0.1.0
  */
 public function getInstallPath(PackageInterface $package)
 {
     $prettyName = $package->getPrettyName();
     DebugPrinter::log('Getting install path for `%s` package', array($prettyName));
     if (isset($this->installDirCache[$prettyName])) {
         return $this->installDirCache[$prettyName];
     }
     $installDir = null;
     if ($this->composer->getPackage()) {
         $rootExtra = $this->composer->getPackage()->getExtra();
         if (!empty($rootExtra['opencart-install-dir'])) {
             $installDir = $rootExtra['opencart-install-dir'];
         }
     }
     if (!$installDir) {
         $extra = $package->getExtra();
         if (!empty($extra['opencart-install-dir'])) {
             $installDir = $extra['opencart-install-dir'];
         }
     }
     if (is_array($installDir)) {
         if (isset($installDir[$prettyName])) {
             $this->installDirCache[$prettyName] = $installDir[$prettyName];
             return $installDir[$prettyName];
         }
         $this->installDirCache[$prettyName] = $this->defaultInstallDir;
         return $this->defaultInstallDir;
     }
     $installDir = $installDir ? $installDir : $this->defaultInstallDir;
     DebugPrinter::log('Computed install dir for package `%s`: `%s`', array($prettyName, $installDir));
     $this->installDirCache[$prettyName] = $installDir;
     return $installDir;
 }
Example #8
0
 function run(PackageInterface $package, $isMain = true)
 {
     $extra = $package->getExtra();
     if (!isset($extra['bower'])) {
         return;
     }
     if (isset($extra['bower']['dependencies']) and is_array($extra['bower']['dependencies'])) {
         foreach ($extra['bower']['dependencies'] as $package => $version) {
             $this->installPackage($package, $version);
         }
     }
     if (isset($extra['bower']['files']) and is_array($extra['bower']['files'])) {
         foreach ($extra['bower']['files'] as $file) {
             $path = getcwd() . "/" . $file;
             if (is_file($path)) {
                 $bower = json_decode(file_get_contents($path));
                 if (isset($bower->dependencies)) {
                     foreach ($bower->dependencies as $package => $version) {
                         $this->installPackage($package, $version);
                     }
                 }
             } elseif ($isMain) {
                 throw new \OutOfRangeException("File {$file} defined in composer section extra.bower.files does not exist on path: {$path}");
             }
         }
     }
 }
 function it_should_locate_config_file_on_empty_composer_configuration(Filesystem $filesystem, PackageInterface $package)
 {
     $package->getExtra()->willReturn(array());
     $filesystem->exists($this->pathArgument('/composer/grumphp.yml'))->willReturn(true);
     $filesystem->isAbsolutePath($this->pathArgument('/composer/grumphp.yml'))->willReturn(true);
     $this->locate('/composer', $package)->shouldMatch($this->pathRegex('/composer/grumphp.yml'));
 }
Example #10
0
 /**
  * {@inheritDoc}
  *
  * @throws \RuntimeException
  */
 public function getPackageBasePath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         return 'plugins/' . $extra['installer-name'];
     }
     $primaryNS = null;
     $autoLoad = $package->getAutoload();
     foreach ($autoLoad as $type => $pathMap) {
         if ($type !== 'psr-4') {
             continue;
         }
         $count = count($pathMap);
         if ($count === 1) {
             $primaryNS = key($pathMap);
             break;
         }
         $matches = preg_grep('#^(\\./)?src/?$#', $pathMap);
         if ($matches) {
             $primaryNS = key($matches);
             break;
         }
         foreach (['', '.'] as $path) {
             $key = array_search($path, $pathMap, true);
             if ($key !== false) {
                 $primaryNS = $key;
             }
         }
         break;
     }
     if (!$primaryNS) {
         throw new \RuntimeException('Unable to get CakePHP plugin name.');
     }
     return 'plugins/' . trim(str_replace('\\', '/', $primaryNS), '/');
 }
 /**
  * @param PackageInterface $package
  *
  * @return string
  */
 public function getPackageBasePath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     print_r($extra);
     // get dependency glue packages
     return parent::getPackageBasePath($package);
 }
 /**
  * Gets the destination Component directory.
  *
  * @param PackageInterface $package
  * @return string
  *   The path to where the final Component should be installed.
  */
 public function getComponentPath(PackageInterface $package)
 {
     // Parse the pretty name for the vendor and package name.
     $name = $prettyName = $package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
         unset($vendor);
     }
     // First look for an override in root package's extra, then try the package's extra
     $rootPackage = $this->composer->getPackage();
     $rootExtras = $rootPackage ? $rootPackage->getExtra() : array();
     $customComponents = isset($rootExtras['component']) ? $rootExtras['component'] : array();
     if (isset($customComponents[$prettyName]) && is_array($customComponents[$prettyName])) {
         $component = $customComponents[$prettyName];
     } else {
         $extra = $package->getExtra();
         $component = isset($extra['component']) ? $extra['component'] : array();
     }
     // Allow the component to define its own name.
     if (isset($component['name'])) {
         $name = $component['name'];
     }
     // Find where the package should be located.
     return $this->getComponentDir() . DIRECTORY_SEPARATOR . $name;
 }
 /**
  * {@inheritDoc}
  */
 protected function getPackageBasePath(PackageInterface $package)
 {
     $ssp_path = '.';
     $ssp_pack = $this->composer->getRepositoryManager()->getLocalRepository()->findPackage('simplesamlphp/simplesamlphp', '*');
     if ($ssp_pack !== null) {
         $ssp_path = $this->composer->getInstallationManager()->getInstallPath($ssp_pack);
     }
     $name = $package->getPrettyName();
     if (!preg_match('@^.*/simplesamlphp-module-(.+)$@', $name, $matches)) {
         throw new \InvalidArgumentException('Unable to install module ' . $name . ', package name must be on the form "VENDOR/simplesamlphp-module-MODULENAME".');
     }
     $moduleDir = $matches[1];
     if (!preg_match('@^[a-z0-9_.-]*$@', $moduleDir)) {
         throw new \InvalidArgumentException('Unable to install module ' . $name . ', module name must only contain characters from a-z, 0-9, "_", "." and "-".');
     }
     if ($moduleDir[0] === '.') {
         throw new \InvalidArgumentException('Unable to install module ' . $name . ', module name cannot start with ".".');
     }
     /* Composer packages are supposed to only contain lowercase letters, but historically many modules have had names in mixed case.
      * We must provide a way to handle those. Here we allow the module directory to be overridden with a mixed case name.
      */
     $extraData = $package->getExtra();
     if (isset($extraData['ssp-mixedcase-module-name'])) {
         $mixedCaseModuleName = $extraData['ssp-mixedcase-module-name'];
         if (!is_string($mixedCaseModuleName)) {
             throw new \InvalidArgumentException('Unable to install module ' . $name . ', "ssp-mixedcase-module-name" must be a string.');
         }
         if (mb_strtolower($mixedCaseModuleName, 'utf-8') !== $moduleDir) {
             throw new \InvalidArgumentException('Unable to install module ' . $name . ', "ssp-mixedcase-module-name" must match the package name except that it can contain uppercase letters.');
         }
         $moduleDir = $mixedCaseModuleName;
     }
     return $ssp_path . '/modules/' . $moduleDir;
 }
 /**
  * Extract the theme/plugin name from the package extra info
  *
  * @param PackageInterface $package
  * @throws \InvalidArgumentException
  *
  * @return string
  */
 protected function extractName(PackageInterface $package)
 {
     $extraData = $package->getExtra();
     if (!array_key_exists('ladybug_name', $extraData)) {
         throw new \InvalidArgumentException('Unable to install theme/plugin, ladybug addons must ' . 'include the name in the extra field of composer.json');
     }
     return $extraData['ladybug_name'];
 }
 /**
  * Retrieves a value from the package extra "contao" section.
  *
  * @param PackageInterface $package The package to extract the section from.
  *
  * @param string           $key     The key to obtain from the extra section.
  *
  * @return mixed|null
  */
 private function getContaoExtra(PackageInterface $package, $key)
 {
     $extras = $package->getExtra();
     if (!isset($extras['contao']) || !isset($extras['contao'][$key])) {
         return null;
     }
     return $extras['contao'][$key];
 }
 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     $this->initGingerBackend();
     $extra = $package->getExtra();
     $uninstallPluginCommand = new Cqrs\UninstallPluginCommand(array('plugin_name' => $package->getName(), 'plugin_type' => $package->getType(), 'plugin_namespace' => $extra['plugin-namespace'], 'plugin_version' => $package->getVersion()));
     $this->getServiceManager()->get('malocher.cqrs.gate')->getBus()->invokeCommand($uninstallPluginCommand);
     parent::uninstall($repo, $package);
 }
Example #17
0
 public function getInstallPath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (!array_key_exists('fine-module', $extra) || !array_key_exists('name', $extra['fine-module']) || strlen($extra['fine-module']['name']) == 0) {
         throw new \InvalidArgumentException('Unable to install fine module. ' . 'Module name not set in composer.json[extra][fine-module][name]');
     }
     return "module/{$extra['fine-module']['name']}";
 }
 public function getInstallPath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (!$extra['install-name']) {
         throw new \InvalidArgumentException(sprintf('The "%s" application is not set "installer-name" field.' . PHP_EOL . 'Using the following config within your package composer.json will allow this:' . PHP_EOL . '{' . PHP_EOL . '    "name": "vendor/name",' . PHP_EOL . '    "type": "thinksns-app",' . PHP_EOL . '    "extra": {' . PHP_EOL . '        "installer-name": "Demo-Name"' . PHP_EOL . '    }' . PHP_EOL . '}' . PHP_EOL), $package->getName());
     }
     return 'apps/' . $extra['install-name'];
 }
Example #19
0
 /**
  * Add installer-name for CakePHP >= 3.0.0
  *
  * @param PackageInterface $package
  * @param string $frameworkType
  * @return string
  */
 public function getInstallPath(PackageInterface $package, $frameworkType = '')
 {
     $extra = $package->getExtra();
     if (empty($extra['installer-name']) && $this->matchesCakeVersion('>=', '3.0.0')) {
         $this->setInstallerName($package);
     }
     return parent::getInstallPath($package, $frameworkType);
 }
Example #20
0
 /**
  * Get the theme or plugin name from the package extra info
  *
  * @param PackageInterface $package
  * @throws \InvalidArgumentException
  *
  * @return string
  */
 protected function getExtraName(PackageInterface $package)
 {
     $extraData = $package->getExtra();
     if (!array_key_exists('name', $extraData)) {
         throw new \InvalidArgumentException('Unable to install theme or plugin, it must include the name in the extra field of composer.json.');
     }
     return $extraData['name'];
 }
 /**
  * @param PackageInterface $package
  *
  * @return mixed
  */
 public function getPackagePath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (isset($extra["path"])) {
         return $extra["path"];
     }
     return null;
 }
Example #22
0
 /**
  * {@inheritDoc}
  */
 public function update(PackageInterface $initial, PackageInterface $target)
 {
     $extra = $target->getExtra();
     if (empty($extra['class'])) {
         throw new \UnexpectedValueException('Error while installing ' . $target->getPrettyName() . ', composer-installer packages should have a class defined in their extra key to be usable.');
     }
     parent::update($initial, $target);
     $this->registerInstaller($target);
 }
Example #23
0
 /** {@inheritDoc} */
 public function getInstallPath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     $name = isset($extra['phpcs-standard']) ? $extra['phpcs-standard'] : $package->getPrettyName();
     $path = isset($extra['phpcs-path']) ? $extra['phpcs-path'] : 'squizlabs/php_codesniffer/CodeSniffer/Standards';
     // package name must denote a single directoy only
     $name = str_replace(array('/', '\\'), '-', $name);
     return $this->vendorDir . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $name;
 }
Example #24
0
 /**
  * {@inheritDoc}
  */
 public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
 {
     $extra = $target->getExtra();
     if (empty($extra['class'])) {
         throw new \UnexpectedValueException('Error while installing ' . $target->getPrettyName() . ', composer-plugin packages should have a class defined in their extra key to be usable.');
     }
     parent::update($repo, $initial, $target);
     $this->composer->getPluginManager()->registerPackage($target, true);
 }
Example #25
0
 /**
  * @param PackageInterface $package
  * @param                  $defaultPath
  *
  * @return string
  */
 private function useConfigPathFromComposer(PackageInterface $package, $defaultPath)
 {
     $extra = $package->getExtra();
     if (!isset($extra['grumphp']['config-default-path'])) {
         return $defaultPath;
     }
     $composerDefaultPath = $extra['grumphp']['config-default-path'];
     return $this->locateConfigFileWithDistSupport($composerDefaultPath);
 }
Example #26
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);
     }
 }
Example #27
0
 function run(PackageInterface $package, $isMain = true)
 {
     $extra = $package->getExtra();
     if (isset($extra['grunt']) and is_array($extra['grunt'])) {
         foreach ($extra['grunt'] as $dir => $task) {
             $this->runTask($dir, $task);
         }
     }
 }
 /**
  * @inheritDoc
  */
 protected function getPackageBasePath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     $targetPath = isset($extra['target_dir']) && strlen($extra['target_dir']) ? $extra['target_dir'] : '';
     $targetPath = 'web/' . ($targetPath ? $targetPath . '/' : '');
     if ($targetPath && !file_exists($targetPath)) {
         mkdir($targetPath, 0777, true);
     }
     return $targetPath . $package->getPrettyName();
 }
 public function getPackageBasePath(PackageInterface $package)
 {
     $ext = self::EXTENSION_NAME_KEY;
     $extra = $package->getExtra();
     if (!is_null($extra) && isset($extra[$ext])) {
         return $extra[$ext];
     } else {
         throw new \InvalidArgumentException('could not find extension name in manifest');
     }
 }
Example #30
0
 /**
  * {@inheritDoc}
  */
 protected function addIgnorePatterns(IgnoreManager $manager, PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (!empty($extra['bower-asset-ignore'])) {
         $manager->doAddPattern('!bower.json');
         foreach ($extra['bower-asset-ignore'] as $pattern) {
             $manager->addPattern($pattern);
         }
     }
 }