mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 08:45:04 +01:00
54 lines
1.1 KiB
PHP
Executable File
54 lines
1.1 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
$pharName = "deployer.phar";
|
|
$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);
|
|
}
|
|
|
|
// Add bin/dep file
|
|
$depContent = file_get_contents(__DIR__ . '/bin/dep');
|
|
$depContent = str_replace("#!/usr/bin/env php\n", '', $depContent);
|
|
$phar->addFromString('bin/dep', $depContent);
|
|
|
|
$stub = <<<STUB
|
|
#!/usr/bin/env php
|
|
<?php
|
|
Phar::mapPhar('{$pharName}');
|
|
require 'phar://{$pharName}/bin/dep';
|
|
__HALT_COMPILER();
|
|
STUB;
|
|
|
|
$phar->setStub($stub);
|
|
$phar->stopBuffering();
|
|
unset($phar);
|
|
|
|
echo "$pharName created successful.\n";
|