magento-plugin/scripts/package
2018-10-29 18:14:02 +01:00

75 lines
2.1 KiB
PHP
Executable File

#!/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
*/
$version = '2.1.20';
$vendorDir = __DIR__ . '/../vendor';
$distDir = __DIR__ . '/../build/dist';
$tmpDistDir = $distDir . '/tmp'; // Files will be placed here temporarly so we can zip/tar them.
$distFile = $distDir . '/Btcpay_Core-'.$version; // Without extension
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')
->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/BTCpay/Core/LICENSE', $tmpDistDir));
$filesystem->copy('README.md', sprintf('%s/app/code/community/BTCpay/Core/README.md', $tmpDistDir));
// All required files are in the temp. distribution directory
// Just need to tar/zip everything
$filesystem->remove($distFile.'.zip');
$filesystem->remove($distFile.'.tgz');
$process = new \Symfony\Component\Process\Process(
sprintf('cd %s; tar -czf %s *', $tmpDistDir, $distFile.'.tgz')
);
$process->run();
$process = new \Symfony\Component\Process\Process(
sprintf('cd %s; zip -r %s *', $tmpDistDir, $distFile.'.zip')
);
$process->run();
// Cleanup
$filesystem->remove($tmpDistDir);