You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

  1. #!/usr/bin/env php
  2. <?php
  3. $phar_file = 'logchecker.phar';
  4. if (file_exists($phar_file)) {
  5. unlink($phar_file);
  6. }
  7. $phar = new Phar(__DIR__.'/../'.$phar_file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $phar_file);
  8. $phar->startBuffering();
  9. $base_dir = realpath(__DIR__.'/../');
  10. $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath(__DIR__.'/../src'), RecursiveDirectoryIterator::SKIP_DOTS));
  11. foreach ($it as $entry) {
  12. $phar->addFile($entry->getPathName(), str_replace($base_dir, '', $entry->getPathName()));
  13. }
  14. $vendor = [
  15. 'composer',
  16. 'symfony'
  17. ];
  18. foreach ($vendor as $dir) {
  19. $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath(__DIR__.'/../vendor/'.$dir), RecursiveDirectoryIterator::SKIP_DOTS));
  20. foreach ($it as $entry) {
  21. $phar->addFile($entry->getPathName(), str_replace($base_dir, '', $entry->getPathName()));
  22. }
  23. }
  24. $phar->addFile(realpath(__DIR__.'/../vendor/autoload.php'), 'vendor/autoload.php');
  25. $phar->addFile(realpath(__DIR__.'/../composer.json'), 'composer.json');
  26. $phar->addFile(realpath(__DIR__.'/../LICENSE.md'), 'LICENSE.md');
  27. $phar->addFile(realpath(__DIR__.'/../README.md'), 'README.md');
  28. $bin_file = file_get_contents(__DIR__.'/logchecker');
  29. $bin_file = preg_replace('{^#!/usr/bin/env php\s*}', '', $bin_file);
  30. $phar->addFromString('bin/logchecker', $bin_file);
  31. $stub = <<<PHP
  32. #!/usr/bin/env php
  33. <?php
  34. Phar::mapPhar('{$phar_file}');
  35. require 'phar://{$phar_file}/bin/logchecker';
  36. __HALT_COMPILER();
  37. PHP;
  38. $phar->setStub($stub);
  39. $phar->stopBuffering();
  40. //$phar->compress(Phar::GZ);
  41. echo "{$phar_file} generated...";