2014-09-26 07:52:42 -07:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @license Copyright 2011-2014 BitPay Inc., MIT License
|
|
|
|
* @see https://github.com/bitpay/magento-plugin/blob/master/LICENSE
|
|
|
|
*/
|
|
|
|
error_reporting(E_ALL | E_STRICT);
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
date_default_timezone_set('America/New_York'); // Main Office is in Eastern Timezone
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Various Configuration Settings
|
|
|
|
*/
|
2014-12-11 13:52:36 -08:00
|
|
|
$version = '2.1.1';
|
2014-09-26 07:52:42 -07:00
|
|
|
$vendorDir = __DIR__ . '/../vendor';
|
|
|
|
$distDir = __DIR__ . '/../build/dist';
|
|
|
|
$tmpDistDir = $distDir . '/tmp'; // Files will be placed here temporarly so we can zip/tar them.
|
2014-12-11 14:58:55 -08:00
|
|
|
$distFile = $distDir . '/Bitpay_Core-'.$version; // Without extension
|
2014-09-26 07:52:42 -07:00
|
|
|
|
|
|
|
require_once $vendorDir . '/autoload.php';
|
|
|
|
|
|
|
|
$filesystem = new \Symfony\Component\Filesystem\Filesystem();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy all required files to temp. distribution directory
|
|
|
|
*/
|
|
|
|
$finder = new \Symfony\Component\Finder\Finder();
|
|
|
|
$finder
|
|
|
|
->files()
|
|
|
|
->in($vendorDir . '/bitpay/php-client/src')
|
|
|
|
->in($vendorDir . '/symfony/config/')
|
|
|
|
->in($vendorDir . '/symfony/filesystem/')
|
|
|
|
->in($vendorDir . '/symfony/dependency-injection/')
|
|
|
|
->exclude('Tests');
|
|
|
|
foreach ($finder as $file) {
|
|
|
|
$path = $file->getRelativePathname();
|
|
|
|
$filesystem->mkdir(
|
|
|
|
sprintf(
|
|
|
|
'%s/lib/%s',
|
|
|
|
$tmpDistDir,
|
|
|
|
dirname($file->getRelativePathname())
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$filesystem->copy(
|
|
|
|
$file->getRealPath(),
|
|
|
|
sprintf(
|
|
|
|
'%s/lib/%s',
|
|
|
|
$tmpDistDir,
|
|
|
|
$file->getRelativePathname()
|
|
|
|
),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$filesystem->mirror('app/', sprintf('%s/app/', $tmpDistDir));
|
|
|
|
$filesystem->mirror('lib/', sprintf('%s/lib/', $tmpDistDir));
|
|
|
|
$filesystem->copy('LICENSE', sprintf('%s/app/code/community/Bitpay/Core/LICENSE', $tmpDistDir));
|
|
|
|
$filesystem->copy('README.md', sprintf('%s/app/code/community/Bitpay/Core/README.md', $tmpDistDir));
|
|
|
|
// All required files are in the temp. distribution directory
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Need to create the package.xml file required by Magento
|
|
|
|
*/
|
|
|
|
$xml = simplexml_load_string('<package/>');
|
2014-12-11 14:58:55 -08:00
|
|
|
$xml->addChild('name', 'Bitpay_Core');
|
2014-09-26 07:52:42 -07:00
|
|
|
$xml->addChild('version', $version);
|
|
|
|
$xml->addChild('stability', 'stable');
|
|
|
|
$xml->addChild('license', 'MIT')
|
|
|
|
->addAttribute('uri', 'https://github.com/bitpay/magento-plugin/blob/master/LICENSE');
|
|
|
|
$xml->addChild('channel', 'community');
|
|
|
|
$xml->addChild('extends');
|
|
|
|
$xml->addChild('summary');
|
|
|
|
$xml->addChild('description');
|
|
|
|
$xml->addChild('notes');
|
|
|
|
$authorsNode = $xml->addChild('authors');
|
|
|
|
$authors = array(
|
|
|
|
array(
|
2014-12-11 13:52:36 -08:00
|
|
|
'Integrations Team', // Name
|
|
|
|
'BitPayInc', // Magento Connect Username
|
2014-09-26 07:52:42 -07:00
|
|
|
'support@bitpay.com', // Email
|
|
|
|
),
|
|
|
|
);
|
|
|
|
foreach ($authors as $author) {
|
|
|
|
$authorNode = $authorsNode->addChild('author');
|
|
|
|
$authorNode->addChild('name', $author[0]);
|
|
|
|
$authorNode->addChild('user', $author[1]);
|
|
|
|
$authorNode->addChild('email', $author[2]);
|
|
|
|
}
|
|
|
|
$xml->addChild('date', date('Y-m-d'));
|
|
|
|
$xml->addChild('time', date('G:i:s'));
|
|
|
|
$xml->addChild('compatible');
|
|
|
|
$xml->addChild('dependencies');
|
|
|
|
$requiredNode = $xml->addChild('required', 'php');
|
|
|
|
$requiredNode->addAttribute('php_min', '5.4.0');
|
|
|
|
$requiredNode->addAttribute('php_max', '6.0.0');
|
|
|
|
$extensionsNode = $xml->addChild('extensions');
|
2014-12-11 13:52:36 -08:00
|
|
|
foreach (array('openssl', 'mcrypt') as $ext) {
|
2014-09-26 07:52:42 -07:00
|
|
|
$extNode = $extensionsNode->addChild('name', $ext);
|
|
|
|
$extNode->addChild('min');
|
|
|
|
$extNode->addChild('max');
|
|
|
|
}
|
|
|
|
$targetNode = $xml->addChild('contents')->addChild('target');
|
|
|
|
$targetNode->addAttribute('name', 'mage');
|
|
|
|
|
|
|
|
$finder = new \Symfony\Component\Finder\Finder();
|
|
|
|
$finder
|
|
|
|
->files()
|
|
|
|
->in($tmpDistDir);
|
|
|
|
|
|
|
|
foreach ($finder as $file) {
|
|
|
|
$node = $targetNode;
|
|
|
|
$directories = explode('/', $file->getRelativePathname());
|
|
|
|
$filename = array_pop($directories);
|
|
|
|
|
|
|
|
for ($i = 1; $i <= count($directories); $i++) {
|
|
|
|
$dir = $directories[$i - 1];
|
|
|
|
$nodes = $node->xpath('dir[@name="' . $dir . '"]');
|
|
|
|
if (count($nodes)) {
|
|
|
|
$node = array_pop($nodes);
|
|
|
|
} else {
|
|
|
|
$node = $node->addChild('dir');
|
|
|
|
$node->addAttribute('name', $dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$fileNode = $node->addChild('file');
|
|
|
|
$fileNode->addAttribute('name', $file->getBaseName());
|
|
|
|
$fileNode->addAttribute('hash', md5_file($file->getRealPath()));
|
|
|
|
}
|
|
|
|
$xml->asXml($tmpDistDir . '/package.xml');
|
|
|
|
// package.xml created, just need to tar/zip everything
|
|
|
|
|
|
|
|
$filesystem->remove($distFile.'.zip');
|
|
|
|
$filesystem->remove($distFile.'.tgz');
|
2014-10-16 11:26:51 -07:00
|
|
|
//$process = new \Symfony\Component\Process\Process(
|
|
|
|
// sprintf('cd %s; zip -r %s .', $tmpDistDir, $distFile.'.zip')
|
|
|
|
//);
|
|
|
|
//$process->run();
|
2014-09-26 07:52:42 -07:00
|
|
|
$process = new \Symfony\Component\Process\Process(
|
|
|
|
sprintf('cd %s; tar -czf %s *', $tmpDistDir, $distFile.'.tgz')
|
|
|
|
);
|
|
|
|
$process->run();
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
$filesystem->remove($tmpDistDir);
|