2014-07-07 08:38:35 +04:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2015-01-28 16:24:56 +03:00
|
|
|
require __DIR__ . '/vendor/autoload.php';
|
2014-07-07 08:38:35 +04:00
|
|
|
|
2015-02-05 17:25:17 +03:00
|
|
|
$opt = getopt('v::');
|
|
|
|
|
|
|
|
$version = 'dev-master';
|
|
|
|
if (array_key_exists('v', $opt)) {
|
|
|
|
$version = $opt['v'];
|
|
|
|
if (!preg_match('/^\d+\.\d+\.\d+(-[\d\w\.]+)?$/i', $version)) {
|
|
|
|
die("Version number must follow semantic versioning.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 13:47:18 +04:00
|
|
|
$pharName = "deployer.phar";
|
2014-07-07 08:38:35 +04:00
|
|
|
$pharFile = __DIR__ . '/' . $pharName;
|
|
|
|
|
|
|
|
if (file_exists($pharFile)) {
|
|
|
|
unlink($pharFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
$phar = new \Phar($pharFile, 0, $pharName);
|
|
|
|
$phar->setSignatureAlgorithm(\Phar::SHA1);
|
|
|
|
|
|
|
|
$phar->startBuffering();
|
|
|
|
|
|
|
|
$finder = new Symfony\Component\Finder\Finder();
|
|
|
|
$finder->files()
|
|
|
|
->ignoreVCS(true)
|
|
|
|
->name('*.php')
|
|
|
|
->name('*.json')
|
|
|
|
->exclude('phpunit')
|
|
|
|
->exclude('Tests')
|
|
|
|
->exclude('test')
|
|
|
|
->exclude('tests')
|
|
|
|
->in(__DIR__);
|
|
|
|
|
|
|
|
foreach ($finder as $fileInfo) {
|
|
|
|
$file = str_replace(__DIR__, '', $fileInfo->getRealPath());
|
|
|
|
|
|
|
|
echo "Add file: " . $file . "\n";
|
|
|
|
|
|
|
|
$phar->addFile($fileInfo->getRealPath(), $file);
|
|
|
|
}
|
|
|
|
|
2014-07-07 11:08:04 +04:00
|
|
|
// Add bin/dep file
|
2015-01-28 16:24:56 +03:00
|
|
|
$depContent = file_get_contents(__DIR__ . '/bin/dep');
|
2014-07-07 11:08:04 +04:00
|
|
|
$depContent = str_replace("#!/usr/bin/env php\n", '', $depContent);
|
2015-02-05 17:25:17 +03:00
|
|
|
$depContent = str_replace("'master'", "'$version'", $depContent);
|
2014-07-07 11:08:04 +04:00
|
|
|
$phar->addFromString('bin/dep', $depContent);
|
|
|
|
|
2014-07-08 17:23:25 +04:00
|
|
|
$stub = <<<STUB
|
2014-07-07 08:38:35 +04:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2014-07-08 17:16:31 +04:00
|
|
|
Phar::mapPhar('{$pharName}');
|
|
|
|
require 'phar://{$pharName}/bin/dep';
|
2014-07-07 08:38:35 +04:00
|
|
|
__HALT_COMPILER();
|
2014-07-08 17:23:25 +04:00
|
|
|
STUB;
|
2014-07-07 08:38:35 +04:00
|
|
|
|
|
|
|
$phar->setStub($stub);
|
2015-02-24 15:38:55 +03:00
|
|
|
$phar->compressFiles(Phar::GZ);
|
2014-07-07 08:38:35 +04:00
|
|
|
$phar->stopBuffering();
|
2014-07-07 09:23:33 +04:00
|
|
|
unset($phar);
|
2014-07-07 08:38:35 +04:00
|
|
|
|
2014-07-08 17:00:17 +04:00
|
|
|
echo "$pharName created successful.\n";
|