#!/usr/bin/env php 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 = <<setStub($stub); $phar->stopBuffering(); unset($phar); echo "$pharName created successful.\n"; // Generate sha1 sum and put it to manifest.json $newPharManifest = [ 'name' => $pharName, 'sha1' => sha1_file($pharFile), 'url' => "http://deployer.in/$pharName", 'version' => $version, ]; $manifest = json_decode(file_get_contents(__DIR__ . '/manifest.json'), true); $alreadyExistVersion = null; foreach ($manifest as $i => $old) { if ($old['version'] === $version) { $alreadyExistVersion = $i; } } if (null === $alreadyExistVersion) { $manifest[] = $newPharManifest; } else { $manifest[$alreadyExistVersion] = $newPharManifest; } file_put_contents(__DIR__ . '/manifest.json', json_encode($manifest, JSON_PRETTY_PRINT));