diff --git a/bin/cli b/bin/cli new file mode 100755 index 0000000..912da3e --- /dev/null +++ b/bin/cli @@ -0,0 +1,17 @@ +#!/usr/bin/php +get('config')['console']['commands']; +foreach ($commands as $command) { + $application->add($container->get($command)); +} + +$application->run(); diff --git a/composer.json b/composer.json index 48ab71c..94ba08c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "los/basepath": "^1.0", "zendframework/zend-http": "^2.6", "symfony/css-selector": "^3.2", - "zendframework/zend-cache": "^2.7" + "zendframework/zend-cache": "^2.7", + "symfony/console": "^3.2" }, "require-dev": { "phpunit/phpunit": "^4.8", diff --git a/composer.lock b/composer.lock index 79e6dcc..804455f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "1823e15d3da7740350f42c474e6e640e", + "content-hash": "b68abdbc94f3cc9c9ca4ed861cb59a9f", "packages": [ { "name": "container-interop/container-interop", diff --git a/config/autoload/cli.global.php b/config/autoload/cli.global.php new file mode 100644 index 0000000..d61301d --- /dev/null +++ b/config/autoload/cli.global.php @@ -0,0 +1,15 @@ + [ + 'invokables' => [], + 'factories' => [ + App\Command\UpdateNightlyCacheCommand::class => App\Command\UpdateNightlyCacheCommandFactory::class, + ], + ], + 'console' => [ + 'commands' => [ + App\Command\UpdateNightlyCacheCommand::class, + ], + ], +]; diff --git a/src/App/Command/UpdateNightlyCacheCommand.php b/src/App/Command/UpdateNightlyCacheCommand.php new file mode 100644 index 0000000..acf064a --- /dev/null +++ b/src/App/Command/UpdateNightlyCacheCommand.php @@ -0,0 +1,33 @@ +ciExecutorService = $ciExecutorService; + parent::__construct(); + } + + protected function configure() + { + $this->setName('nightly:update') + ->setDescription('Updates nightly configuration cache'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->ciExecutorService->getActiveNightlyConfiguration(true); + } +} diff --git a/src/App/Command/UpdateNightlyCacheCommandFactory.php b/src/App/Command/UpdateNightlyCacheCommandFactory.php new file mode 100644 index 0000000..fd1b5c7 --- /dev/null +++ b/src/App/Command/UpdateNightlyCacheCommandFactory.php @@ -0,0 +1,16 @@ +get(CiExecutorService::class); + return new UpdateNightlyCacheCommand($ciExecutorService); + } +} diff --git a/src/App/Service/CiExecutorService.php b/src/App/Service/CiExecutorService.php index ef43e53..8e9b8f2 100644 --- a/src/App/Service/CiExecutorService.php +++ b/src/App/Service/CiExecutorService.php @@ -90,7 +90,6 @@ class CiExecutorService $config2Html = $this->getConfig2Html(); $staplerTokens = $this->getStaplerTokens($config2Html, "JCAT_TYPE"); return $this->getJcatVersions($staplerTokens['url'], $staplerTokens['token']); -// return $this->getJcatVersions($config2Html); } $cache = $this->getCache(self::JCAT_CACHE_KEY); @@ -99,7 +98,6 @@ class CiExecutorService $config2Html = $this->getConfig2Html(); $staplerTokens = $this->getStaplerTokens($config2Html, "JCAT_TYPE"); $packages =$this->getJcatVersions($staplerTokens['url'], $staplerTokens['token']); -// $packages =$this->getJcatVersions($config2Html); $cache->setItem(self::PACKAGE_CACHE_KEY, serialize($packages)); } else { $packages = unserialize($result); @@ -759,8 +757,11 @@ class CiExecutorService $cssToXpathConverter = new CssSelectorConverter(); $xpathQuery = $cssToXpathConverter->toXPath(sprintf('input[value=%s]', $fieldName)); + $xmlErrorHandling = libxml_use_internal_errors(TRUE); $domDocument = new \DOMDocument(); $domDocument->loadHTML($html); + libxml_clear_errors(); + libxml_use_internal_errors($xmlErrorHandling); $xpath = new \DOMXPath($domDocument); $element = $xpath->query($xpathQuery);