diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index b0477a7..08cedda 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,7 +2,6 @@ name: PHP package checks on: push: - branches: [main, master] pull_request: branches: [main, master] workflow_dispatch: @@ -17,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.2', '8.5'] + php: ['8.4.1', '8.5'] steps: - name: Checkout uses: actions/checkout@v7 @@ -32,19 +31,16 @@ jobs: coverage: none - name: Validate Composer manifest and lock - run: composer validate --no-check-publish --no-interaction + run: composer validate --strict --no-check-publish --no-interaction - name: Install locked dependencies run: composer install --prefer-dist --no-interaction --no-progress --no-scripts + - name: Audit locked dependencies + run: composer audit --locked --no-interaction + - name: Check PHP syntax - run: find . -path './vendor' -prune -o -path './.git' -prune -o -name '*.php' -type f -print0 | xargs -0 -n1 php -l - - - name: Run declared tests - shell: bash - run: | - if php -r '$composer = json_decode(file_get_contents("composer.json"), true); exit(isset($composer["scripts"]["test"]) ? 0 : 1);'; then - composer test --no-interaction - else - echo 'No test script is declared for this package.' - fi + run: composer lint + + - name: Run tests + run: composer test --no-interaction diff --git a/CHANGELOG.md b/CHANGELOG.md index f8443cc..9824c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,10 +23,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- -## [Unreleased] +## [2.0.0] - Unreleased -### Planned -- Additional built-in commands -- Command scheduling improvements -- Interactive commands +### Breaking +- Require PHP 8.4.1+, Triangle Engine 9, Localzet Console 2.2, and Symfony Console/Process 8.1. +- Migrate command discovery to the Engine 9 plugin APIs and support Localzet Console 2's Illuminate command bridge. + +### Added +- Compatibility checks for Engine 9 command discovery and Symfony/Illuminate command execution. +- English and Russian installation, usage, command, and upgrade guides. diff --git a/Console.php b/Console.php index 252000d..e1f538d 100644 --- a/Console.php +++ b/Console.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify @@ -68,11 +69,18 @@ public function __construct(protected array $config = [], bool $installInternalC 'phar_stub' => 'master', 'signature_algorithm' => Phar::SHA256, 'private_key_file' => '', - 'php_version' => 8.3, + 'php_version' => 8.4, 'php_ini' => 'memory_limit = 256M', 'bin_filename' => 'triangle', ]]); + } + + $this->config['name'] = 'Triangle Console'; + $this->config['version'] = InstalledVersions::getPrettyVersion('triangle/console'); + + parent::__construct($this->config, $installInternalCommands); + if (Config::isLoaded()) { $this->loadFromConfig(config('command', [])); // Грузим команды из /app/command/*.php @@ -98,10 +106,6 @@ public function __construct(protected array $config = [], bool $installInternalC $this->loadFromConfig($config['command'] ?? []); }); } - $this->config['name'] = 'Triangle Console'; - $this->config['version'] = InstalledVersions::getPrettyVersion('triangle/console'); - - parent::__construct($this->config, $installInternalCommands); } /** @@ -134,7 +138,7 @@ protected function loadFromConfig(array $config): void $name = $properties['defaultName'] ?? null; if (!$name) throw new RuntimeException("У команды $class_name нет defaultName"); - $this->add(new $class_name(config('console', []))); + $this->addCommand(new $class_name(config('console', []))); } } diff --git a/README.md b/README.md index 8d301b0..bd49a98 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,120 @@ -

- -

- -

- - Скачивания - - - Коммиты - - - Версия - - - Версия PHP - - - Лицензия - -

+# Triangle Console + +Triangle Console adds Triangle Engine integration and project commands to [Localzet Console](https://github.com/localzet/Console). It loads commands from the application and enabled plugins, and includes helpers for creating applications, plugins, commands, controllers, middleware and models. It also provides PHAR and self-contained binary build commands. + +> This compatibility line requires PHP 8.4.1 or newer, Triangle Engine 9, and Localzet Console 2.2. It is not compatible with the Engine 8 / Localzet Console 1 dependency line. + +## Install + +```sh +composer require triangle/console:^2.0 +``` + +The package uses the Triangle Engine runtime. Install it in a Triangle application, then register `Triangle\Console\Console` as the command application: + +```php +run(); +``` + +When Engine configuration has been loaded, the component reads `config/command.php`, discovers application commands under `app/command`, and reads command entries from enabled plugin configuration. A command listed in `config/command.php` must expose a Symfony-compatible `defaultName`: + +```php +writeln('OK'); + + return self::SUCCESS; + } +} +``` + +## Laravel Console commands + +Localzet Console 2.2 supports Illuminate Console commands. Triangle Console exposes that integration through the inherited `useIlluminate()` and `addIlluminateCommand()` methods: + +```php +use Illuminate\Container\Container; +use Triangle\Console\Console; + +$console = (new Console([], false))->useIlluminate(new Container()); +$console->addIlluminateCommand(new App\Console\Commands\ReportCommand()); +$console->run(); +``` + +Pass a Laravel application/container configured for your command dependencies when required. `false` disables automatic internal commands for this explicitly composed console instance. + +## Built-in commands + +The component registers its commands along with Localzet Console's internal commands. Common Triangle commands include: + +| Command | Purpose | +| --- | --- | +| `make:command ` | Generate an application command | +| `make:controller ` | Generate a controller | +| `make:middleware ` | Generate middleware | +| `make:model ` | Generate a model | +| `app:create ` | Create an application scaffold | +| `plugin:create ` | Create a plugin scaffold | +| `build:phar` | Package the configured project as a PHAR | +| `build:bin [php-version]` | Package the project with the configured PHP micro runtime | + +Run `php your-entrypoint.php list` to see the commands available in the current application. Build commands use settings from `config/console.php`; the binary PHP version is a major/minor value such as `8.4`. Binary packaging does not make PHP source impossible to extract or reverse engineer; protect secrets outside the package and review the license terms for distributed artifacts. + +## Compatibility and upgrade + +This release line targets PHP `^8.4.1`, Triangle Engine `^9.0`, Localzet Console `^2.2`, Symfony Console `^8.1`, and Symfony Process `^8.1`. Engine 9 plugin discovery and Localzet Console 2 command integration are exercised by the package test suite. + +Projects on the previous dependency line must upgrade PHP and Engine together, then resolve the new locked dependencies: + +```sh +composer require triangle/engine:^9 localzet/console:^2.2 triangle/console --with-all-dependencies +``` + +Review application commands and plugins after the Engine 9 migration. Do not combine this package line with Engine 8 or Localzet Console 1 in the same Composer dependency graph. + +## Development + +```sh +composer install +composer run check +composer audit --locked +``` + +`composer run check` runs PHP syntax validation and the compatibility smoke tests for Engine 9 command discovery, built-in command registration, Symfony command execution, and Illuminate command execution. + +## License + +AGPL-3.0-or-later. See [LICENSE](LICENSE). + +--- + +Русская версия: [README.ru.md](README.ru.md). diff --git a/README.ru.md b/README.ru.md new file mode 100644 index 0000000..5373744 --- /dev/null +++ b/README.ru.md @@ -0,0 +1,120 @@ +# Triangle Console + +Triangle Console связывает [Localzet Console](https://github.com/localzet/Console) с Triangle Engine и добавляет команды для работы с проектом. Компонент загружает команды приложения и включённых плагинов, создаёт заготовки приложений, плагинов, команд, контроллеров, middleware и моделей, а также собирает PHAR и автономные бинарные пакеты. + +> Эта линия совместимости требует PHP 8.4.1 или новее, Triangle Engine 9 и Localzet Console 2.2. Она несовместима с зависимостями линии Engine 8 / Localzet Console 1. + +## Установка + +```sh +composer require triangle/console:^2.0 +``` + +Компонент работает в приложении на Triangle Engine. Подключите автозагрузчик Composer и запустите `Triangle\Console\Console`: + +```php +run(); +``` + +Если конфигурация Engine уже загружена, компонент читает `config/command.php`, ищет команды приложения в `app/command` и команды включённых плагинов в их конфигурации. Команда из `config/command.php` должна объявлять имя, совместимое с Symfony Console: + +```php +writeln('OK'); + + return self::SUCCESS; + } +} +``` + +## Команды Laravel Console + +Localzet Console 2.2 поддерживает команды Illuminate Console. Triangle Console предоставляет унаследованные методы `useIlluminate()` и `addIlluminateCommand()`: + +```php +use Illuminate\Container\Container; +use Triangle\Console\Console; + +$console = (new Console([], false))->useIlluminate(new Container()); +$console->addIlluminateCommand(new App\Console\Commands\ReportCommand()); +$console->run(); +``` + +Если командам нужны зависимости приложения, передайте настроенный Laravel container/application. Параметр `false` отключает автоматическую регистрацию встроенных команд в этой вручную собранной консоли. + +## Встроенные команды + +Компонент регистрирует свои команды вместе со встроенными командами Localzet Console. Основные команды Triangle: + +| Команда | Назначение | +| --- | --- | +| `make:command ` | Создать команду приложения | +| `make:controller ` | Создать контроллер | +| `make:middleware ` | Создать middleware | +| `make:model ` | Создать модель | +| `app:create ` | Создать структуру приложения | +| `plugin:create ` | Создать структуру плагина | +| `build:phar` | Упаковать проект в PHAR | +| `build:bin [php-version]` | Упаковать проект вместе с PHP micro runtime | + +Список команд текущего приложения можно посмотреть через `php <точка-входа> list`. Параметры сборки читаются из `config/console.php`; версия PHP для бинарной сборки задаётся значением major/minor, например `8.4`. Бинарная упаковка не исключает извлечение или анализ PHP-кода. Не храните секреты в пакете и заранее проверьте условия лицензии для распространяемых артефактов. + +## Совместимость и обновление + +Эта линия требует PHP `^8.4.1`, Triangle Engine `^9.0`, Localzet Console `^2.2`, Symfony Console `^8.1` и Symfony Process `^8.1`. Набор проверок компонента проверяет обнаружение команд через Engine 9 и регистрацию команд Localzet Console 2. + +Для проекта на предыдущей линии обновите PHP и Engine, затем разрешите новые версии зависимостей: + +```sh +composer require triangle/engine:^9 localzet/console:^2.2 triangle/console --with-all-dependencies +``` + +После перехода на Engine 9 проверьте команды приложения и плагины. Не смешивайте эту линию с Engine 8 или Localzet Console 1 в одном графе зависимостей Composer. + +## Разработка + +```sh +composer install +composer run check +composer audit --locked +``` + +`composer run check` проверяет синтаксис PHP и запускает smoke-тесты обнаружения команд Engine 9, регистрации встроенных команд, исполнения Symfony-команды и исполнения Illuminate-команды. + +## Лицензия + +AGPL-3.0-or-later. См. [LICENSE](LICENSE). + +--- + +English version: [README.md](README.md). diff --git a/composer.json b/composer.json index b2f9c91..9d5360a 100644 --- a/composer.json +++ b/composer.json @@ -27,19 +27,27 @@ } }, "require": { - "php": "^8.2", - "localzet/console": "^1.1", - "triangle/engine": "^8.1", - "symfony/console": "^7.1", - "symfony/process": "^7.1" + "php": "^8.4.1", + "localzet/console": "^2.2", + "triangle/engine": "^9.0", + "symfony/console": "^8.1", + "symfony/process": "^8.1" }, "suggest": { "ext-zip": "For build bin", "ext-openssl": "For build phar (Phar::OPENSSL)" }, + "scripts": { + "lint": "find . -path './vendor' -prune -o -path './.git' -prune -o -name '*.php' -type f -print0 | xargs -0 -n1 php -l", + "test": "php tests/run.php", + "check": [ + "@lint", + "@test" + ] + }, "config": { "platform": { - "php": "8.2.0" + "php": "8.4.1" } } } diff --git a/src/Commands/AppCreateCommand.php b/src/Commands/AppCreateCommand.php index b390da4..61b7640 100644 --- a/src/Commands/AppCreateCommand.php +++ b/src/Commands/AppCreateCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/BuildBinCommand.php b/src/Commands/BuildBinCommand.php index 6a48938..4e620fa 100644 --- a/src/Commands/BuildBinCommand.php +++ b/src/Commands/BuildBinCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify @@ -39,7 +40,7 @@ class BuildBinCommand extends BuildPharCommand protected static string $defaultName = 'build:bin'; protected static string $defaultDescription = 'Упаковать проект в BIN'; - protected float $php_version = 8.3; + protected float $php_version = 8.4; protected string $php_ini = 'memory_limit = 256M'; protected string $bin_filename = 'localzet'; @@ -217,4 +218,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::SUCCESS; } -} \ No newline at end of file +} diff --git a/src/Commands/BuildPharCommand.php b/src/Commands/BuildPharCommand.php index feb4779..6f7f229 100644 --- a/src/Commands/BuildPharCommand.php +++ b/src/Commands/BuildPharCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/DisableCommand.php b/src/Commands/DisableCommand.php index c911bd5..1e95cec 100644 --- a/src/Commands/DisableCommand.php +++ b/src/Commands/DisableCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/EnableCommand.php b/src/Commands/EnableCommand.php index 1aaa779..edc660d 100644 --- a/src/Commands/EnableCommand.php +++ b/src/Commands/EnableCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify @@ -76,6 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int is_file("$directory/php-8.0") => "$directory/php-8.0", is_file("$directory/php-8.1") => "$directory/php-8.1", is_file("$directory/php-8.2") => "$directory/php-8.2", + is_file("$directory/php-8.5") => "$directory/php-8.5", + is_file("$directory/php-8.4") => "$directory/php-8.4", is_file("$directory/php-8.3") => "$directory/php-8.3", default => "php", }; diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index ad6d2d0..b537508 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/MakeBootstrapCommand.php b/src/Commands/MakeBootstrapCommand.php index d260293..d9d4e80 100644 --- a/src/Commands/MakeBootstrapCommand.php +++ b/src/Commands/MakeBootstrapCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/MakeCommandCommand.php b/src/Commands/MakeCommandCommand.php index fc62833..50c51bc 100644 --- a/src/Commands/MakeCommandCommand.php +++ b/src/Commands/MakeCommandCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/MakeControllerCommand.php b/src/Commands/MakeControllerCommand.php index 69c14c6..129c1f5 100644 --- a/src/Commands/MakeControllerCommand.php +++ b/src/Commands/MakeControllerCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/MakeMiddlewareCommand.php b/src/Commands/MakeMiddlewareCommand.php index ce214b7..0560162 100644 --- a/src/Commands/MakeMiddlewareCommand.php +++ b/src/Commands/MakeMiddlewareCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/MakeModelCommand.php b/src/Commands/MakeModelCommand.php index 6fe67d4..c230893 100644 --- a/src/Commands/MakeModelCommand.php +++ b/src/Commands/MakeModelCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginCreateCommand.php b/src/Commands/PluginCreateCommand.php index d5ab9c0..fdc1edd 100644 --- a/src/Commands/PluginCreateCommand.php +++ b/src/Commands/PluginCreateCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginDisableCommand.php b/src/Commands/PluginDisableCommand.php index 002ee2d..f59c363 100644 --- a/src/Commands/PluginDisableCommand.php +++ b/src/Commands/PluginDisableCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginEnableCommand.php b/src/Commands/PluginEnableCommand.php index 99cf91f..999e16f 100644 --- a/src/Commands/PluginEnableCommand.php +++ b/src/Commands/PluginEnableCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginExportCommand.php b/src/Commands/PluginExportCommand.php index c04a4eb..3f2b0e6 100644 --- a/src/Commands/PluginExportCommand.php +++ b/src/Commands/PluginExportCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginInstallCommand.php b/src/Commands/PluginInstallCommand.php index 969d3d4..e0664b5 100644 --- a/src/Commands/PluginInstallCommand.php +++ b/src/Commands/PluginInstallCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginUninstallCommand.php b/src/Commands/PluginUninstallCommand.php index 401094f..946a370 100644 --- a/src/Commands/PluginUninstallCommand.php +++ b/src/Commands/PluginUninstallCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/PluginUpdateCommand.php b/src/Commands/PluginUpdateCommand.php index b6190c6..a141c5d 100644 --- a/src/Commands/PluginUpdateCommand.php +++ b/src/Commands/PluginUpdateCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/RouteListCommand.php b/src/Commands/RouteListCommand.php index 74d2115..627b8aa 100644 --- a/src/Commands/RouteListCommand.php +++ b/src/Commands/RouteListCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Commands/UpdateCommand.php b/src/Commands/UpdateCommand.php index 958becb..26af767 100644 --- a/src/Commands/UpdateCommand.php +++ b/src/Commands/UpdateCommand.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/src/Config/console.php b/src/Config/console.php index eb2c3a8..7492ee5 100644 --- a/src/Config/console.php +++ b/src/Config/console.php @@ -27,9 +27,9 @@ 'private_key_file' => '', // Для Phar::OPENSSL // Для бинарной сборки: - 'php_version' => 8.3, + 'php_version' => 8.4, 'php_ini' => 'memory_limit = 256M', 'bin_filename' => 'triangle', ], -]; \ No newline at end of file +]; diff --git a/src/Install.php b/src/Install.php index 86d07e2..44a9b42 100644 --- a/src/Install.php +++ b/src/Install.php @@ -5,7 +5,8 @@ * @link https://github.com/Triangle-org/Console * * @author Ivan Zorin - * @copyright Copyright (c) 2023-2024 Triangle Framework Team + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later * @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0 * * This program is free software: you can redistribute it and/or modify diff --git a/tests/run.php b/tests/run.php new file mode 100644 index 0000000..1ec18af --- /dev/null +++ b/tests/run.php @@ -0,0 +1,112 @@ + + * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved. + * SPDX-License-Identifier: AGPL-3.0-or-later + * @license AGPL-3.0-or-later + */ + +namespace { + require dirname(__DIR__) . '/vendor/autoload.php'; +} + +namespace Triangle\Console\Tests { + use Illuminate\Console\Command as IlluminateCommand; + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Output\OutputInterface; + use localzet\Console\Commands\Command; + + class FrameworkCommand extends Command + { + protected static string $defaultName = 'triangle:test'; + protected static string $defaultDescription = 'Exercise framework command registration'; + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $output->writeln('framework-command-ok'); + return self::SUCCESS; + } + } + + class IlluminateSmokeCommand extends IlluminateCommand + { + protected $signature = 'triangle:illuminate'; + protected $description = 'Exercise Laravel command registration'; + + public function handle(): int + { + $this->getOutput()->writeln('illuminate-command-ok'); + return self::SUCCESS; + } + } +} + +namespace { + use Illuminate\Container\Container; + use Symfony\Component\Console\Command\Command as SymfonyCommand; + use Symfony\Component\Console\Input\ArrayInput; + use Symfony\Component\Console\Output\BufferedOutput; + use Triangle\Console; + use Triangle\Engine\Config; + use Triangle\Engine\Path; + use Triangle\Console\Tests\FrameworkCommand; + use Triangle\Console\Tests\IlluminateSmokeCommand; + + $container = new class extends Container { + public function runningUnitTests(): bool + { + return false; + } + }; + $directory = sys_get_temp_dir() . '/triangle-console-' . bin2hex(random_bytes(8)); + $configDirectory = $directory . '/config'; + $appDirectory = $directory . '/app'; + mkdir($configDirectory, 0700, true); + mkdir($appDirectory, 0700, true); + + file_put_contents( + $configDirectory . '/command.php', + 'setAutoExit(false); + if (!$console->has('triangle:test') || !$console->has('build:bin')) { + throw new RuntimeException('Triangle commands were not registered with Localzet Console.'); + } + + $frameworkOutput = new BufferedOutput(); + $frameworkStatus = $console->run(new ArrayInput(['command' => 'triangle:test']), $frameworkOutput); + if ($frameworkStatus !== SymfonyCommand::SUCCESS || !str_contains($frameworkOutput->fetch(), 'framework-command-ok')) { + throw new RuntimeException('Triangle framework command did not run through Symfony Console.'); + } + + $laravelConsole = (new Console([], false))->useIlluminate($container); + $laravelConsole->setAutoExit(false); + $laravelConsole->addIlluminateCommand(new IlluminateSmokeCommand()); + $laravelOutput = new BufferedOutput(); + $laravelStatus = $laravelConsole->run(new ArrayInput(['command' => 'triangle:illuminate']), $laravelOutput); + if ($laravelStatus !== SymfonyCommand::SUCCESS || !str_contains($laravelOutput->fetch(), 'illuminate-command-ok')) { + throw new RuntimeException('Illuminate command did not run through Triangle Console.'); + } + + echo "ENGINE9_CONSOLE_COMMANDS=ok\n"; + echo "ILLUMINATE_CONSOLE_COMMANDS=ok\n"; + } finally { + foreach (new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS), + RecursiveIteratorIterator::CHILD_FIRST + ) as $entry) { + $entry->isDir() ? rmdir($entry->getPathname()) : unlink($entry->getPathname()); + } + rmdir($directory); + } +}