Событие http.responded и слоты каркаса (layout.head/layout.topbar) — чтобы частым нуждам проекта не приходилось патчить framework/ напрямую. Версия ядра (framework/VERSION, мажор.минор.патч) и core:bump — вручную, не хуком на каждый коммит: версия размечает точку для синхронизации, а не сами коммиты. Core\Updater поверх контрольных сумм (framework/.checksums.json) вместо археологии по git log: core:check/diff/sync — что взять безопасно, что мержить руками, что ядро удалило и не сломает ли это app/config/routes/ resources/views. core:latest и --remote у diff/sync — версия, changelog и файлы ядра прямо с GitHub/Gitea через HttpClient, без git clone. На живой симуляции переноса поймал и починил два реальных бага: markSynced() не давал недомерженному патчу тихо стать новой доверенной базой, а brokenReferences() не путает магическую ::class и унаследованные от Model методы с настоящей поломкой.
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace Rsgrinko\Proton\Console\Commands;
|
||
|
||
use Rsgrinko\Proton\Console\Command;
|
||
use Rsgrinko\Proton\Core\Updater;
|
||
use Rsgrinko\Proton\Support\Config;
|
||
|
||
/**
|
||
* версия и changelog ядра прямо из репозитория — два GET-запроса, без
|
||
* авторизации и без похода в API (см. docs/CORE_UPDATES.md).
|
||
*/
|
||
final class CoreLatestCommand extends Command
|
||
{
|
||
public function name(): string
|
||
{
|
||
return 'core:latest';
|
||
}
|
||
|
||
public function description(): string
|
||
{
|
||
return 'версия и changelog ядра из PROTON_CORE_REPO — с чем сравнить свою';
|
||
}
|
||
|
||
public function run(): int
|
||
{
|
||
$repo = (string) Config::get('core.repo');
|
||
$branch = (string) Config::get('core.branch');
|
||
|
||
$updater = new Updater(APP_ROOT);
|
||
$local = $updater->localVersion();
|
||
$remote = $updater->remoteVersion($repo, $branch);
|
||
|
||
if ($remote === '') {
|
||
$this->fail('Не удалось прочитать версию ядра из ' . $repo . '@' . $branch);
|
||
|
||
return 1;
|
||
}
|
||
|
||
$this->line('У вас: ' . $local);
|
||
$this->line('В ' . $repo . '@' . $branch . ': ' . $remote);
|
||
|
||
$cmp = version_compare($remote, $local);
|
||
|
||
if ($cmp <= 0) {
|
||
$this->ok('Вы на актуальной версии или свежее.');
|
||
|
||
return 0;
|
||
}
|
||
|
||
$this->line();
|
||
$changelog = Updater::changelogSince($updater->remoteChangelog($repo, $branch), $local);
|
||
|
||
if ($changelog !== '') {
|
||
$this->line($changelog);
|
||
} else {
|
||
$this->line('Отстаёте, но docs/CHANGELOG.md в ядре не прочитать или в нём нет записей новее вашей версии.');
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
}
|