#66 added a build command to RoboFile.php

This commit is contained in:
Laurent Szyster
2015-08-14 12:01:08 +02:00
parent 3b00e453a5
commit 0b0539dc83

View File

@@ -88,7 +88,7 @@ class RoboFile extends \Robo\Tasks {
}
function testAll() {
$this->loadEnv();
$this->loadEnv();
$this->_exec('vendor/bin/codecept build');
$this
->taskexec('phantomjs --webdriver=4444')
@@ -104,6 +104,53 @@ class RoboFile extends \Robo\Tasks {
$this->_exec('vendor/bin/codecept run unit --debug');
}
function zip() {
$rootPath = realpath('wysija-newsletters');
$zip = new ZipArchive();
$zip->open('mailpoet.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$directory = new \RecursiveDirectoryIterator(
$rootPath, \FilesystemIterator::FOLLOW_SYMLINKS
);
$filter = new \RecursiveCallbackFilterIterator(
$directory, function ($current, $key, $iterator) {
return ($current->getFilename()[0] !== '.');
}
);
$files = new \RecursiveIteratorIterator($filter);
foreach ($files as $name => $file) {
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
$zip->close();
}
function build() {
$this->_exec('mkdir wysija-newsletters');
$this->_exec('mkdir wysija-newsletters/vendor');
$this->_exec('cp index.php wysija-newsletters/index.php');
$this->_exec('cp mailpoet.php wysija-newsletters/mailpoet.php');
$this->_exec('cp package.json wysija-newsletters/package.json');
$this->_exec('cp composer.* wysija-newsletters/');
$this->taskCopyDir(array(
'assets' => 'wysija-newsletters/assets',
'lang' => 'wysija-newsletters/lang',
'lib' => 'wysija-newsletters/lib',
'views' => 'wysija-newsletters/views'
))->run();
chdir('./wysija-newsletters');
$this->taskExecStack()
->stopOnFail()
// ->exec('cd wysija-newsletters') does not work as intended
->exec('./composer.phar install --no-dev')
->run();
chdir('..');
$this->_exec('rm wysija-newsletters/package.json');
$this->_exec('rm wysija-newsletters/composer.*');
$this->zip();
$this->taskDeleteDir('wysija-newsletters')->run();
}
protected function loadEnv() {
$dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();