From d07bab533ef743e59c323f1982c8134a6496e087 Mon Sep 17 00:00:00 2001 From: Prasetyo Wicaksono Date: Sun, 17 Nov 2024 15:49:40 +0700 Subject: [PATCH] fix: swoole binary and local exec --- .github/workflows/mager-build-release.yaml | 5 ++--- bin/mager | 18 +++++------------- composer.json | 2 +- composer.lock | 14 +++++++------- src/Command/ExecCommand.php | 6 ++---- 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/.github/workflows/mager-build-release.yaml b/.github/workflows/mager-build-release.yaml index 548c5da..11eb0d3 100644 --- a/.github/workflows/mager-build-release.yaml +++ b/.github/workflows/mager-build-release.yaml @@ -43,7 +43,7 @@ jobs: - "macos-x86_64" - "macos-aarch64" php-version: - - "8.3.12" + - "8.3" runner: - "ubuntu-latest" steps: @@ -72,8 +72,7 @@ jobs: - name: Download Micro With ${{ matrix.php-version }}-${{ matrix.arch }} run: | mkdir downloads - wget https://dl.static-php.dev/static-php-cli/bulk/php-${{ matrix.php-version }}-micro-${{ matrix.arch }}.tar.gz -O downloads/php-${{ matrix.php-version }}-${{ matrix.arch }}.tar.gz - tar -xvzf downloads/php-${{ matrix.php-version }}-${{ matrix.arch }}.tar.gz --directory downloads + wget https://dl.praswicaksono.pw/php-${{ matrix.php-version }}-minimal-${{ matrix.arch }}.sfx -O downloads/micro.sfx - name: "Install Dependencies" run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist diff --git a/bin/mager b/bin/mager index 91a5cd5..77ac5ec 100755 --- a/bin/mager +++ b/bin/mager @@ -4,31 +4,23 @@ use App\Kernel; use App\ConsoleApplication; use Swoole\ExitException; +use Swoole\Runtime; if (!is_dir(dirname(__DIR__).'/vendor')) { throw new LogicException('Dependencies are missing. Try running "composer install".'); } -require dirname(__DIR__).'/vendor/autoload.php'; +Runtime::setHookFlags(SWOOLE_HOOK_ALL & ~SWOOLE_HOOK_FILE); -//if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { -// throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); -//} -// -//require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; +$loader = require dirname(__DIR__).'/vendor/autoload.php'; $app = function (array $context) { - if (\PHP_SAPI === 'micro') { - $context['APP_ENV'] = 'prod'; - $context['APP_DEBUG'] = false; - } - $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); $app = new ConsoleApplication($kernel); $app->setName('Mager Deploy'); - $app->setVersion('v0.0.8'); + $app->setVersion('v0.0.9'); return $app; }; @@ -46,7 +38,7 @@ $app = $app(...$args); $exitCode = 0; -\Co\run(function () use (&$exitCode, $app, $runtime) { +\Co\run(function () use (&$exitCode, $app, $runtime, $loader) { try { $runtime->getRunner($app)->run(); } catch (ExitException $e) { diff --git a/composer.json b/composer.json index 06abced..cc72a63 100644 --- a/composer.json +++ b/composer.json @@ -80,7 +80,7 @@ "friendsofphp/php-cs-fixer": "^3.64", "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9.5", - "swoole/ide-helper": "^5.0.0", + "swoole/ide-helper": "~5.0.0", "symfony/browser-kit": "7.1.*", "symfony/css-selector": "7.1.*", "symfony/maker-bundle": "^1.61", diff --git a/composer.lock b/composer.lock index d5db13d..a0bef47 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a456b742278f58ec5caf793c10c9f62e", + "content-hash": "cc3259bbdc0a8a8fe6549f03082c151d", "packages": [ { "name": "adbario/php-dot-notation", @@ -5777,16 +5777,16 @@ }, { "name": "swoole/ide-helper", - "version": "5.1.5", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/swoole/ide-helper.git", - "reference": "a4207701bb55fe0cea06f840d2054cbc4a90b943" + "reference": "4b6e615cb27c251b6248b8bd9501edbd02a45c18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swoole/ide-helper/zipball/a4207701bb55fe0cea06f840d2054cbc4a90b943", - "reference": "a4207701bb55fe0cea06f840d2054cbc4a90b943", + "url": "https://api.github.com/repos/swoole/ide-helper/zipball/4b6e615cb27c251b6248b8bd9501edbd02a45c18", + "reference": "4b6e615cb27c251b6248b8bd9501edbd02a45c18", "shasum": "" }, "type": "library", @@ -5803,9 +5803,9 @@ "description": "IDE help files for Swoole.", "support": { "issues": "https://github.com/swoole/ide-helper/issues", - "source": "https://github.com/swoole/ide-helper/tree/5.1.5" + "source": "https://github.com/swoole/ide-helper/tree/5.0.3" }, - "time": "2024-11-05T07:35:30+00:00" + "time": "2023-04-28T22:20:18+00:00" }, { "name": "symfony/browser-kit", diff --git a/src/Command/ExecCommand.php b/src/Command/ExecCommand.php index 09cf596..5ad5420 100644 --- a/src/Command/ExecCommand.php +++ b/src/Command/ExecCommand.php @@ -31,20 +31,18 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - $io = new SymfonyStyle($input, $output); $namespace = $input->getArgument('namespace'); $serviceName = $input->getArgument('serviceName'); $command = implode(' ', $input->getArgument('cmd')); if ($this->config->isLocal($namespace)) { - $result = runLocally(function () use ($namespace, $command) { + runLocally(function () use ($namespace, $serviceName, $command) { $cmd = <<writeln($result); return Command::SUCCESS; }