Copyright 2009-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Gunnar Wrobel (wrobel@pardus.de)
示例#1
0
 public function run()
 {
     $composer = new Components_Helper_Composer();
     $options = $this->_config->getOptions();
     $options['logger'] = $this->_output;
     $composer->generateComposeJson($this->_config->getComponent()->getPackageXmlPath(), $options);
 }
示例#2
0
 public function run()
 {
     $options = $this->_config->getOptions();
     if (!empty($options['no_tree'])) {
         print Horde_Yaml::dump($this->_config->getComponent()->getDependencies());
     } else {
         $this->_dependencies->listTree($this->_config->getComponent(), $options);
     }
 }
示例#3
0
文件: Composer.php 项目: horde/horde
 /**
  * Determine if this module should act. Run all required actions if it has
  * been instructed to do so.
  *
  * @param Components_Config $config The configuration.
  *
  * @return boolean True if the module performed some action.
  */
 public function handle(Components_Config $config)
 {
     $options = $config->getOptions();
     $arguments = $config->getArguments();
     if (!empty($options['composer']) || isset($arguments[0]) && $arguments[0] == 'composer') {
         $this->_dependencies->getRunnerComposer()->run();
         return true;
     }
 }
示例#4
0
 /**
  * Return the path to the template directory
  *
  * @return string The path to the template directory.
  */
 public function getTemplateDirectory()
 {
     $options = $this->_config->getOptions();
     if (!isset($options['templatedir'])) {
         return Components_Constants::getDataDirectory();
     } else {
         return $options['templatedir'];
     }
 }
示例#5
0
 /**
  * Determine if this module should act. Run all required actions if it has
  * been instructed to do so.
  *
  * @param Components_Config $config The configuration.
  *
  * @return boolean True if the module performed some action.
  */
 public function handle(Components_Config $config)
 {
     $options = $config->getOptions();
     //@todo Split into two different runners here
     if (!empty($options['cisetup'])) {
         $this->_dependencies->getRunnerCiSetup()->run();
         return true;
     }
     if (!empty($options['ciprebuild'])) {
         $this->_dependencies->getRunnerCiPrebuild()->run();
         return true;
     }
 }
示例#6
0
 public function run()
 {
     $options = $this->_config->getOptions();
     if (!empty($options['destination'])) {
         $environment = realpath($options['destination']);
         if (!$environment) {
             $environment = $options['destination'];
         }
     } else {
         throw new Components_Exception('You MUST specify the path to the installation environment with the --destination flag!');
     }
     if (empty($options['pearrc'])) {
         $options['pearrc'] = $environment . '/pear.conf';
         $this->_output->info(sprintf('Undefined path to PEAR configuration file (--pearrc). Assuming %s for this installation.', $options['pearrc']));
     }
     if (empty($options['horde_dir'])) {
         $options['horde_dir'] = $environment;
         $this->_output->info(sprintf('Undefined path to horde web root (--horde-dir). Assuming %s for this installation.', $options['horde_dir']));
     }
     if (!empty($options['instructions'])) {
         if (!file_exists($options['instructions'])) {
             throw new Components_Exception(sprintf('Instructions file "%s" is missing!', $options['instructions']));
         }
         $lines = explode("\n", file_get_contents($options['instructions']));
         $result = array();
         foreach ($lines as $line) {
             $trimmed = trim($line);
             if (empty($trimmed) || preg_match('/^#/', $trimmed)) {
                 continue;
             }
             preg_match('/(.*):(.*)/', $trimmed, $matches);
             $id = $matches[1];
             $c_options = $matches[2];
             foreach (explode(',', $c_options) as $option) {
                 $result[trim($id)][trim($option)] = true;
             }
         }
         $options['instructions'] = $result;
     }
     $target = $this->_factory->createEnvironment($environment, $options['pearrc']);
     $target->setResourceDirectories($options);
     //@todo: fix role handling
     $target->provideChannel('pear.horde.org', $options);
     $target->getPearConfig()->setChannels(array('pear.horde.org', true));
     $target->getPearConfig()->set('horde_dir', $options['horde_dir'], 'user', 'pear.horde.org');
     Components_Exception_Pear::catchError($target->getPearConfig()->store());
     $this->_installer->installTree($target, $this->_config->getComponent(), $options);
 }
示例#7
0
 /**
  * Determine the requested component.
  *
  * @param array $arguments The arguments.
  *
  * @return array Two elements: The selected component as
  *               Components_Component instance and optionally a string
  *               representing the path to the specified source component.
  */
 private function _determineComponent($arguments)
 {
     if (isset($arguments[0])) {
         if (in_array($arguments[0], $this->_actions['missing_argument'])) {
             return;
         }
         if ($this->_isPackageXml($arguments[0])) {
             $this->_config->shiftArgument();
             return array($this->_dependencies->getComponentFactory()->createSource(dirname($arguments[0])), dirname($arguments[0]));
         }
         if (!in_array($arguments[0], $this->_actions['list'])) {
             if ($this->_isDirectory($arguments[0])) {
                 $this->_config->shiftArgument();
                 return array($this->_dependencies->getComponentFactory()->createSource($arguments[0]), $arguments[0]);
             }
             $options = $this->_config->getOptions();
             if (!empty($options['allow_remote'])) {
                 $result = $this->_dependencies->getComponentFactory()->getResolver()->resolveName($arguments[0], 'pear.horde.org', $options);
                 if ($result !== false) {
                     $this->_config->shiftArgument();
                     return array($result, '');
                 }
             }
             throw new Components_Exception(sprintf(Components::ERROR_NO_ACTION_OR_COMPONENT, $arguments[0]));
         }
     }
     $cwd = getcwd();
     if ($this->_isDirectory($cwd) && $this->_containsPackageXml($cwd)) {
         return array($this->_dependencies->getComponentFactory()->createSource($cwd), $cwd);
     }
     throw new Components_Exception(Components::ERROR_NO_COMPONENT);
 }
示例#8
0
文件: Qc.php 项目: jubinpatel/horde
 /**
  * Did the user activate the given task?
  *
  * @param string $task The task name.
  *
  * @return boolean True if the task is active.
  */
 private function _doTask($task)
 {
     $arguments = $this->_config->getArguments();
     if (count($arguments) == 1 && $arguments[0] == 'qc' || in_array($task, $arguments)) {
         return true;
     }
     return false;
 }
示例#9
0
 /**
  * Create the repository root helper.
  *
  * @return Components_Helper_Root The helper.
  */
 public function createGitRoot()
 {
     if (isset($this->_first_source)) {
         return new Components_Helper_Root($this->_config->getOptions(), $this->_first_source);
     } else {
         return new Components_Helper_Root($this->_config->getOptions());
     }
 }
示例#10
0
 public function run()
 {
     $options = $this->_config->getOptions();
     $arguments = $this->_config->getArguments();
     if (count($arguments) > 1 && $arguments[0] == 'changed') {
         $log = $arguments[1];
     } else {
         throw new Components_Exception('Please provide a change log entry as additional argument!');
     }
     if (!empty($options['commit'])) {
         $options['commit'] = new Components_Helper_Commit($this->_output, $options);
     }
     $this->_config->getComponent()->changed($log, $this->_helper, $options);
     if (!empty($options['commit'])) {
         $options['commit']->commit($log);
     }
 }
示例#11
0
 public function run()
 {
     $arguments = $this->_config->getArguments();
     $options = array_merge(array('new_version' => false, 'new_api' => false, 'new_state' => false, 'new_apistate' => false), $this->_config->getOptions());
     if (!empty($options['updatexml']) || isset($arguments[0]) && $arguments[0] == 'update') {
         $action = !empty($options['action']) ? $options['action'] : 'update';
         if (!empty($options['pretend']) && $action == 'update') {
             $action = 'diff';
         }
         if (!empty($options['commit'])) {
             $options['commit'] = new Components_Helper_Commit($this->_output, $options);
         }
         $result = $this->_config->getComponent()->updatePackageXml($action, $options);
         if (!empty($options['new_version']) || !empty($options['new_api'])) {
             $this->_config->getComponent()->setVersion($options['new_version'], $options['new_api'], $options);
         }
         if (!empty($options['new_state']) || !empty($options['new_apistate'])) {
             $this->_config->getComponent()->setState($options['new_state'], $options['new_apistate'], $options);
         }
         if (!empty($options['commit'])) {
             $options['commit']->commit('Components updated the package.xml.');
         }
         if ($result === true) {
             $this->_output->ok('Successfully updated package.xml of ' . $this->_config->getComponent()->getName() . '.');
         } else {
             print $result;
         }
     }
 }
示例#12
0
文件: Fetchdocs.php 项目: horde/horde
 public function run()
 {
     $docs_origin = $this->_config->getComponent()->getDocumentOrigin();
     if ($docs_origin === null) {
         $this->_output->fail('The component does not offer a DOCS_ORIGIN file with instructions what should be fetched!');
         return;
     } else {
         $this->_output->info(sprintf('Reading instructions from %s', $docs_origin[0]));
         $options = $this->_config->getOptions();
         $helper = new Components_Helper_DocsOrigin($docs_origin, $this->_client);
         if (empty($options['pretend'])) {
             $helper->fetchDocuments($this->_output);
         } else {
             foreach ($helper->getDocuments() as $remote => $local) {
                 $this->_output->info(sprintf('Would fetch remote %s into %s!', $remote, $docs_origin[1] . '/' . $local));
             }
         }
     }
 }
示例#13
0
 public function run()
 {
     $options = $this->_config->getOptions();
     if (!empty($options['destination'])) {
         $archivedir = $options['destination'];
     } else {
         $archivedir = getcwd();
     }
     $options['logger'] = $this->_output;
     $result = $this->_config->getComponent()->placeArchive($archivedir, $options);
     if (isset($result[2])) {
         $this->_output->pear($result[2]);
     }
     if (!empty($result[1])) {
         $this->_output->fail('Generating snapshot failed with:' . "\n\n" . join("\n", $result[1]));
     } else {
         $this->_output->ok('Generated snapshot ' . $result[0]);
     }
 }
示例#14
0
文件: Help.php 项目: jubinpatel/horde
 /**
  * Determine if this module should act. Run all required actions if it has
  * been instructed to do so.
  *
  * @param Components_Config $config The configuration.
  *
  * @return boolean True if the module performed some action.
  */
 public function handle(Components_Config $config)
 {
     $arguments = $config->getArguments();
     if (isset($arguments[0]) && $arguments[0] == 'help') {
         if (isset($arguments[1])) {
             $action = $arguments[1];
         } else {
             $action = '';
         }
         $modules = $this->_dependencies->getModules();
         foreach ($modules->getModules()->listModules() as $module) {
             $element = $modules->getProvider()->getModule($module);
             if (in_array($action, $element->getActions())) {
                 $title = "ACTION \"" . $action . "\"";
                 $sub = str_repeat('-', strlen($title));
                 $help = "\n" . $title . "\n" . $sub . "\n\n";
                 $help .= Horde_String::wordwrap($element->getHelp($action), 75, "\n", true);
                 $options = $element->getContextOptionHelp();
                 if (!empty($options)) {
                     $formatter = new Horde_Argv_IndentedHelpFormatter();
                     $parser = $this->_dependencies->getParser();
                     $title = "OPTIONS for \"" . $action . "\"";
                     $sub = str_repeat('-', strlen($title));
                     $help .= "\n\n\n" . $title . "\n" . $sub . "";
                     foreach ($options as $option => $help_text) {
                         $argv_option = $parser->getOption($option);
                         $help .= "\n\n    " . $formatter->formatOptionStrings($argv_option) . "\n\n      ";
                         if (empty($help_text)) {
                             $help .= Horde_String::wordwrap($argv_option->help, 75, "\n      ", true);
                         } else {
                             $help .= Horde_String::wordwrap($help_text, 75, "\n      ", true);
                         }
                     }
                 }
                 $help .= "\n";
                 $this->_dependencies->getOutput()->help($help);
                 return true;
             }
         }
         return false;
     }
 }
示例#15
0
文件: Update.php 项目: horde/horde
 public function run()
 {
     $arguments = $this->_config->getArguments();
     $options = array_merge(array('new_version' => false, 'new_api' => false, 'new_state' => false, 'new_apistate' => false), $this->_config->getOptions());
     if (!empty($options['updatexml']) || isset($arguments[0]) && $arguments[0] == 'update') {
         $action = !empty($options['action']) ? $options['action'] : 'update';
         if (!empty($options['pretend']) && $action == 'update') {
             $action = 'diff';
         }
         if (!empty($options['commit'])) {
             $options['commit'] = new Components_Helper_Commit($this->_output, $options);
         }
         $result = $this->_config->getComponent()->updatePackageXml($action, $options);
         if (!empty($options['new_version']) || !empty($options['new_api'])) {
             $this->_config->getComponent()->setVersion($options['new_version'], $options['new_api'], $options);
             if (!empty($options['new_version']) && !empty($options['sentinel'])) {
                 $notes = new Components_Release_Notes($this->_output);
                 $notes->setComponent($this->_config->getComponent());
                 $application_version = Components_Helper_Version::pearToHordeWithBranch($options['new_version'] . '-git', $notes->getBranch());
                 $sentinel_result = $this->_config->getComponent()->currentSentinel($options['new_version'] . '-git', $application_version, $options);
                 foreach ($sentinel_result as $file) {
                     $this->_output->ok($file);
                 }
             }
         }
         if (!empty($options['new_state']) || !empty($options['new_apistate'])) {
             $this->_config->getComponent()->setState($options['new_state'], $options['new_apistate'], $options);
         }
         if (!empty($options['commit'])) {
             $options['commit']->commit('Components updated the package.xml.');
         }
         if ($result === true) {
             $this->_output->ok('Successfully updated package.xml of ' . $this->_config->getComponent()->getName() . '.');
         } else {
             print $result;
         }
     }
 }
示例#16
0
文件: Webdocs.php 项目: horde/horde
 public function run()
 {
     $this->_website_helper->update($this->_config->getComponent(), $this->_config->getOptions());
 }
示例#17
0
文件: Base.php 项目: jubinpatel/horde
 /**
  * Return the application options.
  *
  * @return array The options.
  */
 protected function getOptions()
 {
     return $this->_config->getOptions();
 }
示例#18
0
文件: CiSetup.php 项目: horde/horde
 public function run()
 {
     $options = $this->_config->getOptions();
     $templates = new Components_Helper_Templates_RecursiveDirectory($this->_config_application->getTemplateDirectory(), $options['cisetup']);
     $templates->write(array('config' => $this->_config));
 }