Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ Here's the easiest:
1. Create ~/.n98-magerun/modules/ if it doesn't already exist.

mkdir -p ~/.n98-magerun/modules/
mkdir -p ~/.n98-magerun2/modules/

2. Clone the hypernode-magerun repository in there

git clone https://github.com/Hypernode/hypernode-magerun.git ~/.n98-magerun/modules/hypernode-magerun

3. It should be installed. To see that it was installed, run magerun without any arguments to see if one of the new commands is in there.
3. Link the repository for n98-magerun2

ln -s ~/.n98-magerun/modules/hypernode-magerun ~/.n98-magerun2/modules/hypernode-magerun

4. It should be installed. To see that it was installed, run magerun without any arguments to see if one of the new commands is in there.

n98-magerun.phar

Expand Down Expand Up @@ -112,6 +117,12 @@ Building a .deb for release:

Then if everything is alright, upload the new version to your repository with something like [dput](http://manpages.ubuntu.com/manpages/precise/man1/dput.1.html)

n98-magerun2 compatibility
-----------------------

Currently, only the command `hypernode:perfomance` is partially compatible with n98-magerun2.

Please contribute to make more commands available for n98-magerun2!

Credits due where credits due
--------
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"require-dev": {
"phpunit/phpunit": "~4.8",
"mikey179/vfsStream": "1.6.4",
"n98/magerun": "dev-master"
"n98/magerun": "dev-master",
"firegento/magento": "~1.9.3",
"doctrine/instantiator": "~1.0.5"
},
"autoload": {
"psr-0": {
Expand Down
12 changes: 12 additions & 0 deletions n98-magerun2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
autoloaders:
Hypernode: %module%/src

commands:
customCommands:
- Hypernode\Magento\Command\Hypernode\Performance\PerformanceCommand

passwordCracker:
rulesDirs:
- %module%/config/rules/
wordlistDirs:
- %module%/config/wordlists/
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,42 @@
namespace Hypernode\Magento\Command\Hypernode\Performance;

use Hypernode\Magento\Command\AbstractHypernodeCommand;
use N98\Util\Console\Helper\Table\Renderer\RendererFactory;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use N98\Util\Console\Helper\Table\Renderer\RendererFactory;

/**
* Class CacheWarmerCommand
* @package Hypernode\Magento\Command\Performance
*/
class PerformanceCommand extends AbstractHypernodeCommand
{

/**
* @var array
*/
protected $_options;

/**
* @var array
*/
protected $_sitemaps;

/**
* @var array
*/
protected $_batches;

/**
* @var array
*/
protected $_results;

/**
* @var bool
*/
protected $_totalTime = false;

/**
Expand All @@ -53,7 +71,6 @@ protected function configure()
->addOption('totaltime', null, InputOption::VALUE_NONE, 'Measure total time instead of TTFB. Note: TTFB labels are not adjusted.');
}


/**
* Executes command.
* @param InputInterface $input
Expand All @@ -62,11 +79,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->detectMagento($output);
if (!$this->initMagento()) {
return;
}

// setting the options - hypernode demands it
$this->_options = $input->getOptions();

Expand All @@ -77,20 +89,31 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

// get sitemaps to process
if (!$this->_options['sitemap'] && !$this->_options['silent']) {
$this->_sitemaps = $this->askSitemapsToProcess($input, $output);
if ($this->_options['sitemap']) {
$sitemapFromInput = $this->getSitemapFromInput($this->_options);
if (!$sitemapFromInput) {
$output->writeln('<error>Could not fetch specified sitemap: ' . $this->_options['sitemap'] . '</error>');
} else {
$this->_sitemaps = $sitemapFromInput;
}
} else {
if (!$this->_options['sitemap'] && $this->_options['silent']) {
$this->_sitemaps = $this->retrieveSitemaps();
$this->detectMagento($output);
if (!$this->initMagento()) {
return;
}

if (intval($this->getApplication()->getMagentoMajorVersion()) === 2) {
$output->writeln(
'<error>Use argument --sitemap to specify sitemap when using Magento 2.</error>'
);
return;
}

if ($this->_options['silent']) {
$this->_sitemaps = $this->retrieveSitemaps();
} else {
$sitemapFromInput = $this->getSitemapFromInput($this->_options);
if (!$sitemapFromInput) {
$output->writeln('<error>Could not fetch specified sitemap: ' . $this->_options['sitemap'] . '</error>');
} else {
$this->_sitemaps = $sitemapFromInput;
}
$this->_sitemaps = $this->askSitemapsToProcess($input, $output);
}

}

// prepare the requests
Expand Down Expand Up @@ -132,11 +155,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
}


}


/**
* Gets the effective URL by following the redirects.
* @todo change to curl Class
Expand Down Expand Up @@ -436,7 +456,7 @@ protected function prepareRequests(InputInterface $input, OutputInterface $outpu
$curl->get($sitemap['sitemap_url']);
if ($curl->http_status_code == '200') {
try {
$xml = new \Varien_Simplexml_Element($curl->response);
$xml = new \SimpleXMLElement($curl->response);
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . ' ' . $sitemap['sitemap_url'] . '</error>');
continue;
Expand All @@ -455,7 +475,7 @@ protected function prepareRequests(InputInterface $input, OutputInterface $outpu
} else {
if (file_exists($this->_magentoRootFolder . $sitemap['relative_path'])) {
try {
$xml = new \Varien_Simplexml_Element(file_get_contents($this->_magentoRootFolder . $sitemap['relative_path']));
$xml = new \SimpleXMLElement(file_get_contents($this->_magentoRootFolder . $sitemap['relative_path']));
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . ' ' . $sitemap['relative_path'] . '</error>');
continue;
Expand All @@ -464,7 +484,7 @@ protected function prepareRequests(InputInterface $input, OutputInterface $outpu
// converting a txt of urls to magento sitemap structure (hypernode internal)
} elseif (file_exists($sitemap['relative_path'])) {
if (end(explode('.', $sitemap['relative_path'])) == 'txt') {
$xml = new \Varien_Simplexml_Element($this->convertTxtToXml(file_get_contents($sitemap['relative_path'])));
$xml = new \SimpleXMLElement($this->convertTxtToXml(file_get_contents($sitemap['relative_path'])));
} else {
$output->writeln('<error>Only a txt url list is currently supported for absolute paths.</error>');
}
Expand Down Expand Up @@ -792,5 +812,4 @@ protected function validateUrl($url)
{
return filter_var($url, FILTER_VALIDATE_URL) ? true : false;
}

}