/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { if (substr($package->getPrettyName(), 0, 23) != 'phpdocumentor/template-') { throw new \InvalidArgumentException('Unable to install template, phpdocumentor templates should always start their package name with "phpdocumentor/template."'); } return 'data/templates/' . substr($package->getPrettyName(), 23); }
/** * {@inheritdoc} */ public function getInstallPath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 18); if ('societycms/module-' !== $prefix) { throw new \InvalidArgumentException('Unable to install module, societycms modules ' . 'should always start their package name with ' . '"societycms/module-"'); } return 'modules/' . ucfirst(substr($package->getPrettyName(), 18)); }
/** * {@inheritDoc} */ public function getPackageBasePath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 9); if ('ckeditor/' !== $prefix) { throw new \InvalidArgumentException('Unable to install template, CKEditor Plugin templates ' . 'should always start their package name with ' . '"ckeditor/"'); } return 'vendor/ckeditor/ckeditor/' . substr($package->getPrettyName(), 9); }
private static function assertBarberryPlugin(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 16); if ('barberry/plugin-' !== $prefix) { throw new \InvalidArgumentException('Unable to install plugin, barberry plugins ' . 'should always start their package name with ' . '"barberry/plugin-"'); } return ucfirst(substr($package->getPrettyName(), 16)); }
/** * {@inheritDoc} **/ public function getInstallPath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 18); if ('canvashack/plugin-' !== $prefix) { throw new \InvalidArgumentException('Unable to install plugin, CanvasHack plugins should always start their package name with "canvashack/plugin-"'); } return 'hacks/' . substr($package->getPrettyName(), 18); }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 14); if ('zepluf/plugin-' !== $prefix) { throw new \InvalidArgumentException('Unable to install plugin ' . $package->getPrettyName() . ', ZePLUF plugin package names should always begin with "zepluf/plugin-"'); } return 'app/plugins/' . $package->getTargetDir(); }
/** * {@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); }
/** * {@inheritDoc} */ public function getPackageBasePath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 24); if ('phpdocumentor/template1-' !== $prefix) { throw new \InvalidArgumentException('Unable to install template, phpdocumentor templates ' . 'should always start their package name with ' . '"phpdocumentor/template-"'); } return 'data/templates/' . substr($package->getPrettyName(), 24); }
public function getPackageBasePath(PackageInterface $package) { if (strpos($package->getPrettyName(), '/simpleid-') === false) { throw new \InvalidArgumentException('SimpleID modules have package names containing simpleid-'); } $subdir = substr($package->getPrettyName(), strpos($package->getPrettyName(), '/simpleid-') + 10); return 'site/' . $subdir; }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { $parts = explode('/', $package->getPrettyName()); if (count($parts) !== 2) { throw new \InvalidArgumentException('The package name is incorrect for ' . $package->getPrettyName()); } return 'modules/' . $parts[0] . '/' . $parts['1']; }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 17); if ('getherbie/plugin-' !== $prefix) { throw new \InvalidArgumentException('Unable to install herbie plugin. The package name should always start with "getherbie/plugin-"'); } $basePath = 'site/plugins/' . substr($package->getPrettyName(), 17); return $basePath; }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { $needed_prefix = 'factorial-io/'; $prefix = substr($package->getPrettyName(), 0, strlen($needed_prefix)); if ($needed_prefix !== $prefix) { throw new \InvalidArgumentException('Unable to install factorial-tool. It' . 'should always start its package name with ' . '"' . $needed_prefix . '"'); } return '_tools/' . substr($package->getPrettyName(), strlen($needed_prefix)); }
/** * @inheritdoc */ public function getInstallPath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 11); var_dump($prefix); if ('kickou/yii2-' !== $prefix) { throw new \InvalidArgumentException('Unable to install template, phpdocumentor templates ' . 'should always start their package name with ' . '"kickou/yii2-"'); } return 'modules/' . substr($package->getPrettyName(), 11); }
/** * Retrieve the pattern for the given package. * * @param \Composer\Package\PackageInterface $package * * @return string */ public function getPattern(PackageInterface $package) { if (isset($this->packages[$package->getName()])) { return $this->packages[$package->getName()]; } elseif (isset($this->packages[$package->getPrettyName()])) { return $this->packages[$package->getPrettyName()]; } elseif (isset($this->types[$package->getType()])) { return $this->types[$package->getType()]; } }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { $strip = 'myadmin/template-'; $cut = strlen($strip) - 1; $prefix = substr($package->getPrettyName(), 0, $cut); if ($strip !== $prefix) { throw new \InvalidArgumentException("Unable to install template, myadmin templates should always start their package name with '{$strip}'"); } return 'public_html/templates/' . substr($package->getPrettyName(), $cut); }
/** * {@inheritDoc} */ public function getPackageBasePath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 9); if ('phalcana/' !== $prefix) { throw new \InvalidArgumentException('Unable to install module, phalcana modules ' . 'should always start their package name with ' . '"phalcana/"'); } if ($package->getType() == 'phalcana-core') { return 'system'; } else { return 'modules/' . substr($package->getPrettyName(), 9); } }
/** * getPackageBasePath. * * @param PackageInterface $package * * @return string */ protected function getPackageBasePath(PackageInterface $package) { if (isset($this->paths[$package->getType()]) && ($path = $this->paths[$package->getType()])) { @(list($vendor, $name) = explode('/', $package->getPrettyName())); $path = strtr($path, array('{vendor}' => $vendor, '{name}' => $name)); return rtrim($path, '/'); } if (($extra = $package->getExtra()) && isset($extra['courier-path'])) { return rtrim($extra['courier-path'], '/'); } return ($this->vendorDir ? $this->vendorDir . '/' : '') . $package->getPrettyName(); }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { if (substr($package->getPrettyName(), 0, 13) !== 'arcavias/ext-') { throw new \InvalidArgumentException('Unable to install extension, arcavias extensions ' . 'should always start their package name with ' . '"arcavias/ext-"'); } $extra = $this->composer->getPackage()->getExtra(); $extname = substr($package->getPrettyName(), 13); if (isset($extra['ext-path'])) { return $extra['ext-path'] . DIRECTORY_SEPARATOR . $extname; } return 'ext' . DIRECTORY_SEPARATOR . $extname; }
/** * @inheritdoc */ public function getInstallPath(PackageInterface $package) { $prefix = substr($package->getPrettyName(), 0, 15); if ('fbarrento/yii2-' !== $prefix) { throw new \InvalidArgumentException('Unable to install template, phpdocumentor templates ' . 'should always start their package name with ' . '"kickou/yii2-"'); } $themePrefix = substr($package->getPrettyName(), 0, 21); if ('fbarrento/yii2-theme-' === $themePrefix) { return 'themes/' . substr($package->getPrettyName(), 21); } else { return 'modules/' . substr($package->getPrettyName(), 15); } }
/** * Returns the installation path which is defined in the root package. * * Returns null if the root package does not define a path for the * provided package. * * @param PackageInterface $package * @return string|null */ protected function getInstallPathFromRoot(PackageInterface $package) { $rootPackageConfig = $this->composer->getPackage()->getExtra(); if (isset($rootPackageConfig['installation-paths'][$package->getPrettyName()])) { return $rootPackageConfig['installation-paths'][$package->getPrettyName()]; } // The attribute "installer-paths" is checked to guarantee backwards compatibility // with version 0.1.1. if (isset($rootPackageConfig['installer-paths'][$package->getPrettyName()])) { return $rootPackageConfig['installer-paths'][$package->getPrettyName()]; } // No path defined in the root package. return null; }
/** * 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} */ public function getPackageBasePath(PackageInterface $package) { $themes = __DIR__ . '/../../../../themes/'; $prefix = $package->getPrettyName(); $prefix = preg_replace('/[^\\w]+/', '_', $prefix); return $themes . $prefix; }
/** * {@inheritdoc} */ public function getInstallPath(PackageInterface $package) { $this->initializeVendorDir(); $targetDir = $package->getTargetDir(); list(, $name) = explode('/', $package->getPrettyName(), 2); return ($this->vendorDir ? $this->vendorDir . '/' : '') . $name . ($targetDir ? '/' . $targetDir : ''); }
/** * {@inheritDoc} */ public function getInstallPath(PackageInterface $package) { $prettyName = explode('/', $package->getPrettyName()); $devName = $prettyName[0]; $themeName = $prettyName[1]; return 'theme/' . $devName . '/' . $themeName . '/'; }
/** * {@inheritDoc} */ public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { if (!$this->_isValidName($target->getPrettyName())) { throw new \InvalidArgumentException('Invalid package name `' . $target->getPrettyName() . '`. ' . 'Name should be of the format `vendor/xyz_name`, where xyz is a valid Joomla extension type (' . implode(', ', $this->_package_prefixes) . ').'); } parent::update($repo, $initial, $target); if (!$this->_application->update($this->getInstallPath($target))) { // Get all error messages that were stored in the message queue $descriptions = $this->_getApplicationMessages(); $error = 'Error while updating ' . $target->getPrettyName(); if (count($descriptions)) { $error .= ':' . PHP_EOL . implode(PHP_EOL, $descriptions); } throw new \RuntimeException($error); } }
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]; }
/** * {@inheritDoc} */ public function update(PackageInterface $initial, PackageInterface $target, $path) { if (!$target->getSourceReference()) { throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information'); } $name = $target->getName(); if ($initial->getPrettyVersion() == $target->getPrettyVersion()) { if ($target->getSourceType() === 'svn') { $from = $initial->getSourceReference(); $to = $target->getSourceReference(); } else { $from = substr($initial->getSourceReference(), 0, 7); $to = substr($target->getSourceReference(), 0, 7); } $name .= ' ' . $initial->getPrettyVersion(); } else { $from = VersionParser::formatVersion($initial); $to = VersionParser::formatVersion($target); } $this->io->write(" - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)"); $this->cleanChanges($initial, $path, true); $urls = $target->getSourceUrls(); while ($url = array_shift($urls)) { try { if (Filesystem::isLocalPath($url)) { $url = realpath($url); } $this->doUpdate($initial, $target, $path, $url); break; } catch (\Exception $e) { if ($this->io->isDebug()) { $this->io->write('Failed: [' . get_class($e) . '] ' . $e->getMessage()); } elseif (count($urls)) { $this->io->write(' Failed, trying the next URL'); } else { // in case of failed update, try to reapply the changes before aborting $this->reapplyChanges($path); throw $e; } } } $this->reapplyChanges($path); // print the commit logs if in verbose mode if ($this->io->isVerbose()) { $message = 'Pulling in changes:'; $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path); if (!trim($logs)) { $message = 'Rolling back changes:'; $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path); } if (trim($logs)) { $logs = implode("\n", array_map(function ($line) { return ' ' . $line; }, explode("\n", $logs))); $this->io->write(' ' . $message); $this->io->write($logs); } } $this->io->write(''); }
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; }
/** * {@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; }
protected function getPackageBasePath(PackageInterface $package) { if (!$this->supports($package->getType())) { throw new \InvalidArgumentException("Package type [{$type}] is not supported"); } return self::$allowedTypes[$package->getType()] . '/' . $package->getPrettyName(); }