- Add module for generating component documentation.
- - Add module for an initial empty PEAR template
-
- Allow filtering (see http://github.com/horde/horde/commit/404e8d1ea7c0bf99373aec2ce7f2534a442149b3)
Potentially check with git if the file is relevant or not.
if (!is_dir($arguments[0])) {
throw new Components_Exception(sprintf('%s specifies no directory!', $arguments[0]));
}
-
- if (!file_exists($arguments[0] . '/package.xml')) {
- throw new Components_Exception(sprintf('There is no package.xml at %s!', $arguments[0]));
- }
}
}
\ No newline at end of file
* @return array An array of arguments.
*/
public function getArguments();
+
+ /**
+ * Return the first argument - the package directory - provided by the
+ * configuration handlers.
+ *
+ * @return string The package directory.
+ */
+ public function getPackageDirectory();
}
\ No newline at end of file
}
/**
+ * Return the first argument - the package directory - provided by the
+ * configuration handlers.
+ *
+ * @return string The package directory.
+ */
+ public function getPackageDirectory()
+ {
+ $arguments = $this->getArguments();
+ return $arguments[0];
+ }
+
+ /**
* Add an option group from the provided module to the parser.
*
* @param Horde_Argv_Parser $parser The parser.
}
return $arguments;
}
+
+ /**
+ * Return the first argument - the package directory - provided by the
+ * configuration handlers.
+ *
+ * @return string The package directory.
+ */
+ public function getPackageDirectory()
+ {
+ $arguments = $this->getArguments();
+ return $arguments[0];
+ }
}
\ No newline at end of file
{
$this->_dependencies = $dependencies;
}
+
+ /**
+ * Validate that there is a package.xml file in the provided directory.
+ *
+ * @param string $directory The package directory.
+ *
+ * @return NULL
+ */
+ protected function requirePackageXml($directory)
+ {
+ if (!file_exists($directory . '/package.xml')) {
+ throw new Components_Exception(sprintf('There is no package.xml at %s!', $directory));
+ }
+ }
}
\ No newline at end of file
$options = $config->getOptions();
//@todo Split into two different runners here
if (!empty($options['cisetup'])) {
+ $this->requirePackageXml($config->getPackageDirectory());
$this->_dependencies->getRunnerCiSetup()->run();
}
if (!empty($options['ciprebuild'])) {
+ $this->requirePackageXml($config->getPackageDirectory());
$this->_dependencies->getRunnerCiPrebuild()->run();
}
}
{
$options = $config->getOptions();
if (!empty($options['list_deps'])) {
+ $this->requirePackageXml($config->getPackageDirectory());
$this->_dependencies->getRunnerDependencies()->run();
}
}
{
$options = $config->getOptions();
if (!empty($options['devpackage'])) {
+ $this->requirePackageXml($config->getPackageDirectory());
$this->_dependencies->getRunnerDevPackage()->run();
}
}
{
$options = $config->getOptions();
if (!empty($options['distribute'])) {
+ $this->requirePackageXml($config->getPackageDirectory());
$this->_dependencies->getRunnerDistribute()->run();
}
}
{
$options = $config->getOptions();
if (!empty($options['install'])) {
+ $this->requirePackageXml($config->getPackageDirectory());
$this->_dependencies->getRunnerInstaller()->run();
}
}
}
/**
+ * Create a new PEAR Package representation.
+ *
+ * @param string $package_xml_dir Path to the parent directory of the package.xml file.
+ * @param Components_Pear_InstallLocation $environment The PEAR environment.
+ *
+ * @return PEAR_PackageFile
+ */
+ public function createPackageFile(
+ $package_xml_dir
+ )
+ {
+ $environment = $this->_dependencies->getInstance('Components_Pear_InstallLocation');
+ $pkg = new PEAR_PackageFile_v2_rw();
+ $pkg->setPackage('REPLACE');
+ $pkg->setDescription('REPLACE');
+ $pkg->setSummary('REPLACE');
+ $pkg->setReleaseVersion('0.0.1');
+ $pkg->setApiVersion('0.0.1');
+ $pkg->setReleaseStability('alpha');
+ $pkg->setApiStability('alpha');
+ $pkg->setChannel('pear.horde.org');
+ $pkg->addMaintainer(
+ 'lead',
+ 'chuck',
+ 'Chuck Hagenbuch',
+ 'chuck@horde.org'
+ );
+ $pkg->addMaintainer(
+ 'lead',
+ 'jan',
+ 'Jan Schneider',
+ 'jan@horde.org'
+ );
+ $pkg->setLicense('REPLACE', 'REPLACE');
+ $pkg->setNotes('* Initial release.');
+ $pkg->clearContents();
+ $pkg->clearDeps();
+ $pkg->setPhpDep('5.2.0');
+ $pkg->setPearinstallerDep('1.9.0');
+ $pkg->setPackageType('php');
+ new PEAR_Validate();
+ $package_file = $pkg->getDefaultGenerator()
+ ->toPackageFile($package_xml_dir, 0);
+ if ($package_file instanceOf PEAR_Error) {
+ throw new Components_Exception($package_file->getMessage());
+ };
+ return $package_file;
+ }
+
+ /**
* Return a writeable PEAR Package representation.
*
* @param string $package_xml_path Path to the package.xml file.
$contents = $package->getContents();
$files = $contents['dir']['file'];
+ $horde_role = false;
foreach ($files as $file) {
$components = explode('/', $file['attribs']['name'], 2);
);
break;
case 'js':
+ $horde_role = true;
case 'locale':
$package->addInstallAs(
$file['attribs']['name'], $file['attribs']['name']
break;
}
}
+
+ if ($horde_role) {
+ $roles = $package->getUsesrole();
+ if (!empty($roles)) {
+ if (isset($roles['role'])) {
+ $roles = array($roles);
+ }
+ foreach ($roles as $role) {
+ if (isset($role['role']) && $role['role'] == 'horde') {
+ $horde_role = false;
+ break;
+ }
+ }
+ }
+ if ($horde_role) {
+ $package->addUsesrole(
+ 'horde', 'Role', 'pear.horde.org'
+ );
+ }
+ }
+
return $package;
}
$arguments = $this->_config->getArguments();
$options = $this->_config->getOptions();
+ if (!file_exists($arguments[0] . '/package.xml')) {
+ $this->_factory->createPackageFile($arguments[0]);
+ }
+
if (isset($options['pearrc'])) {
$package = $this->_factory->createPackageForInstallLocation(
$arguments[0] . '/package.xml',
/**
* @scenario
*/
- public function thePOptionFailsWithoutAValidPackage()
- {
- $this->given('the default Components setup')
- ->when(
- 'calling the package with the packagexml option and the path',
- dirname(dirname(dirname(dirname(__FILE__)))) . '/fixture'
- )
- ->then('the call will fail with', 'There is no package.xml at');
- }
-
- /**
- * @scenario
- */
public function thePOptionProvidesAnUpdatedPackageXml()
{
$this->given('the default Components setup')