diff --git a/jackit b/jackit index 8139ab1..ba1aef9 100755 --- a/jackit +++ b/jackit @@ -8,7 +8,8 @@ use Symfony\Component\Console\Application; define('IS_PHAR', str_starts_with(__DIR__, 'phar:///')); define('ROOT_DIR', IS_PHAR ? getcwd() : __DIR__); -define('CONFIG_FILE', __DIR__ . '/config/jacked-server.php'); + +const CONFIG_FILE = __DIR__ . '/config/jacked-server.php'; const MONITOR_CHANNEL = 'jacked-monitor'; $application = new Application; diff --git a/src/Commands/CompilePharCommand.php b/src/Commands/CompilePharCommand.php index 3fc5c0c..e9edbc8 100644 --- a/src/Commands/CompilePharCommand.php +++ b/src/Commands/CompilePharCommand.php @@ -28,8 +28,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int { try { $pharFile = $input->getArgument('output'); + // $excludeDirs = ['tests', 'logs', 'docs']; - // clean up if (file_exists($pharFile)) { unlink($pharFile); } @@ -38,30 +38,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int unlink($pharFile . '.gz'); } - // create phar $phar = new Phar($pharFile); - - // start buffering. Mandatory to modify stub to add shebang $phar->startBuffering(); - - // Create the default stub from jackit.php entrypoint - $defaultStub = $phar->createDefaultStub('jackit'); - - // Add the rest of the apps files $phar->buildFromDirectory(ROOT_DIR); // @phpstan-ignore-line - - // Customize the stub to add the shebang + $defaultStub = $phar->createDefaultStub('jackit'); $stub = "#!/usr/bin/env php \n" . $defaultStub; - - // Add the stub $phar->setStub($stub); - $phar->stopBuffering(); - - // plus - compressing it into gzip // $phar->compressFiles(Phar::GZ); // commented to avoid a known bug. - # Make the file executable chmod($pharFile, 0770); $output->writeln('' . $pharFile . ' successfully created'); diff --git a/src/Services/Traits/HttpSupport.php b/src/Services/Traits/HttpSupport.php index dc99d93..5a5de0c 100644 --- a/src/Services/Traits/HttpSupport.php +++ b/src/Services/Traits/HttpSupport.php @@ -156,6 +156,16 @@ protected function executeRequest(array $requestOptions, string $content, Respon 'requestOptions' => $requestOptions, 'content' => $content, ]); + + if ( + IS_PHAR + && !file_exists(Arr::get($requestOptions, 'SCRIPT_FILENAME')) + && Arr::get($requestOptions, 'REQUEST_URI') === '/' + ) { + $response->write('
-- Jacked Server --
'); + goto end_of_try; + } + $this->logger->info($this->logPrefix . 'Request Time: {time}', [ 'time' => Carbon::now()->format('Y-m-d H:i:s'), ]); @@ -169,6 +179,8 @@ protected function executeRequest(array $requestOptions, string $content, Respon $result = $client->requestStream($requestOptions, $content, function ($data) use ($response) { $response->write($data); }); + + end_of_try: } catch (Exception $e) { $error = $e->getMessage();