Обновление проектов на ядре: точки расширения, версия, Core\Updater и core:* команды
Событие 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 методы с настоящей поломкой.
This commit is contained in:
1 parent
887575b375
commit
c96150b48a
25 files changed
+1904
-153
No files matched your search
@@ -0,0 +1,206 @@
|
||||
{
|
||||
"framework/Access/AccessDenied.php": "6ac2c128fdcfe884ab1ddfe32c62ebc6bac5b40022565c0faf1954c74f9180a5",
|
||||
"framework/Access/Permission.php": "1696e15c86378a8de09ddec4cedadcd35cab0e199d1816a64875e24addd20f3b",
|
||||
"framework/Access/Policy.php": "ed0a38053c239c9612926c0399f2cc69a1155b40075b93be1b2bf66f6f78655a",
|
||||
"framework/Access/Scope.php": "47a2be961faac388291367a10b5ec01f4b3b9c939627854678f14a54a3020a1d",
|
||||
"framework/Access/Viewer.php": "6130fd5e674d6480407e8a6540260e520af8f4c8b0fb87acdeec6b856c4d5486",
|
||||
"framework/Auth/Auth.php": "5dca3e8b11a941427fe43853dd56a3632656ae872645807f48cedb02b06a00e0",
|
||||
"framework/Auth/Crypto.php": "8eeab7ffea48a2e93bf31176a946f33b485e2b419a73bb669d7b8ebdec3d8ac1",
|
||||
"framework/Auth/Csrf.php": "3b6f1336ad6533a585a875411032a5efb17abc305a5efa5a4e8f547761cebb1f",
|
||||
"framework/Auth/Devices.php": "eb57d6fbf8693f8ff620b207f809f9aa889187e724d40f0a0b65d788880769f5",
|
||||
"framework/Auth/Password.php": "7d11583449e654c45b57cac7eb1a2ed41a5d18c028124c9e4f202da0b7be65c7",
|
||||
"framework/Autoload.php": "4891468f77d5c52171d7d8244d6aa02adb8ef40069d46947ad9992a9c940b4c3",
|
||||
"framework/Backup/Backup.php": "0869c786a9f95c3da522f1b518825f9e758411242c5e01438c2c2d663cf38c10",
|
||||
"framework/Backup/BackupFailedNotification.php": "822062ed6698f4677d82a2bd504d38cae332bb34e05dc4cceee180b96a5bb437",
|
||||
"framework/Backup/BackupJob.php": "806c25c195e0bc97b2f1e6013ec8e31212b7e517899043f85890d205cdfb8eef",
|
||||
"framework/Backup/BackupShipFailedNotification.php": "5cd45ce6b1a2abb27f9f6c246377d70259ebbccac12b466eabcdf66ce21bd9e8",
|
||||
"framework/Backup/Ftp.php": "aec9104c8b70c0d23c4e0382179a5df117d4c4d9c0cff78042309181e45b30d8",
|
||||
"framework/Backup/ShipBackupJob.php": "7c5335c364047aa112390687df851b20fa20db62854861f5efe5fb732587f017",
|
||||
"framework/Cache/Cache.php": "1c76084f0927fb5124c4a14a6abe2cec62d880152b48dcc729bfc35fc8933902",
|
||||
"framework/Comments/Comment.php": "3fb1ec10d80abfe4a0827a4cfd44c63b2cc1b89afb389ca9f571025f8e7eeae0",
|
||||
"framework/Console/Application.php": "fdc8d699b0471449b847d364d723b1269b5197e191ec16c1cacdfeb8c6e62ff4",
|
||||
"framework/Console/Command.php": "449e19ad971587ed34f55a2013b9eb0032388f75ccb345c230680c44ecea123c",
|
||||
"framework/Console/Commands/AppKeyCommand.php": "ad39058182e7da24283b75cf99528f31f0e6a1aa5b0015683dc1858c4aee75f4",
|
||||
"framework/Console/Commands/BackupCreateCommand.php": "6932450ceabf5ae45d72a25d33874a22365199d491d980a3a3664850e9a06f5e",
|
||||
"framework/Console/Commands/BackupListCommand.php": "08ee5b6f8de2b51f96b6f50228301a1608e6944cad50c9e9679a09e982b6c544",
|
||||
"framework/Console/Commands/BackupRestoreCommand.php": "94a80aa647f8610d7346b08347a709970292267d269e94e1b64d9781a776930d",
|
||||
"framework/Console/Commands/BackupShipCommand.php": "701b6bd17c41939152c15d0f682fbea73ff7bb4a31037a75c5e056a2b2b36b20",
|
||||
"framework/Console/Commands/CacheClearCommand.php": "82539fb29a78e9933d9aee3d8f6839b12fbe3010e349bed1684894565200ba38",
|
||||
"framework/Console/Commands/CoreBumpCommand.php": "290760072c3f9e89b2be62cf309c8957ede0cbc97f76e45e2c8015ce9424bc89",
|
||||
"framework/Console/Commands/CoreCheckCommand.php": "0f5556a9e997c96f0a3ebc13e458ce5a6ea4c115c6b74cfcb5da533db707b866",
|
||||
"framework/Console/Commands/CoreDiffCommand.php": "088353b584cfe7987098eeaa0229bc84f9ab40fc5a05548ebbd946b38ed63124",
|
||||
"framework/Console/Commands/CoreLatestCommand.php": "09b5158fcc50854a281d337056af5d3c22984fb81e66b309688a98dd5fe3e70f",
|
||||
"framework/Console/Commands/CoreSyncCommand.php": "67cd0fed029dec5364d0080db3d486d8fae6550c38a7f63317f0203aebc64d7e",
|
||||
"framework/Console/Commands/CoreVersionCommand.php": "52320c2ed0fb05e2ba7eeee6706fddc1ad67ec2d6cddd17ef9eb8148c208080e",
|
||||
"framework/Console/Commands/DownCommand.php": "a55f0e5574167497a7bea0484f617a7da8097c70e9c998581a72bc30c593891a",
|
||||
"framework/Console/Commands/FilesOrphansCommand.php": "bb770d53a4566f0cb7d8359798b8cb5f4ed54589e1d6d034d91e6d7ec2ce4e5f",
|
||||
"framework/Console/Commands/InstallCommand.php": "cfc78ddb2fead65d0635f177cbd08519351ef3528e4f8f4b1725c923143f955a",
|
||||
"framework/Console/Commands/KeyCreateCommand.php": "15dd81c9d7214109022ef1ebe223a8953b8726043f1c40ce77fb64e0aeb1b4a9",
|
||||
"framework/Console/Commands/KeyListCommand.php": "e30f6bf2fe14ec0fb2a843477b7be91c8ced917b48624cdfa94c2018f00e7a65",
|
||||
"framework/Console/Commands/KeyRevokeCommand.php": "261d201b7c70722e489f56dacf74efdf7aecca6cc1ea1db9ccbc9ab6a2660a29",
|
||||
"framework/Console/Commands/LogsPurgeCommand.php": "810a441a4ef4a87469e76c96c626e0703f04615c498792297cc244a0316220ad",
|
||||
"framework/Console/Commands/MailTestCommand.php": "4e6cc2a6e1bcae929526259f6d335a1b7aaefa6672b14f91b4f02b15c7e6b562",
|
||||
"framework/Console/Commands/MakeCommand.php": "8a889aa87635a4069e1c97d6e62bd1a4de85443d81f8dcb0717119052c63c746",
|
||||
"framework/Console/Commands/MakeCommandCommand.php": "fa974828195a62373cf9f20c6bf2e70a0eef38130c2a3d89bb1e7c40ce9a9f95",
|
||||
"framework/Console/Commands/MakeControllerCommand.php": "fcb563a13eb69c530d0ee9613f5c3e53c44a2bf70b0f26d3883f44e343e9cbf3",
|
||||
"framework/Console/Commands/MakeCrudCommand.php": "751a47073e8da3f6fdc69819aee50ee3f814206199e69011603af974b42e04f7",
|
||||
"framework/Console/Commands/MakeJobCommand.php": "ba44fd168a2f6dba0b17941be5da5c3d096b63abb8be5ffc1e7058d47e0a980d",
|
||||
"framework/Console/Commands/MakeMigrationCommand.php": "0a3c2ad579aa911b894ef34b81878e29cd537099ef7615969a0d70e7b17a769c",
|
||||
"framework/Console/Commands/MakeModelCommand.php": "1a1799317fc41c24435428d811c42226b30d365b611236cb6b2c9b7871a0d2c2",
|
||||
"framework/Console/Commands/MakeTestCommand.php": "85c692857b2e129f4767e64dedc2d4128d08fd206227e293c9f4c70bd25244b3",
|
||||
"framework/Console/Commands/MigrateCommand.php": "5b836167150f11f6a1e38b5bfe7d6de46cdc83ea2b096bd29696aae200c11eab",
|
||||
"framework/Console/Commands/MigrateFreshCommand.php": "6affe3f8044ddce6d297220efb6106beb452fe36f47ff3d1b7904bfcb1b48255",
|
||||
"framework/Console/Commands/MigrateRollbackCommand.php": "dc72a041d2ba343f8e2855bd5861fbe6a0bc490dabdc98ae917f818ddfdd7ce7",
|
||||
"framework/Console/Commands/MigrateStatusCommand.php": "b6834aca61c8ec42e44d52d63cf4534467ff732168ede53ed328bd014ebb4948",
|
||||
"framework/Console/Commands/QueuePurgeCommand.php": "4b4d0b0dccc7c029390fc600d6d038f24a3a25467c05b5ad1ee1802d423df28b",
|
||||
"framework/Console/Commands/QueueRetryCommand.php": "451a7ea8277ffa523e4023486b144d0ea9b1af65d7ae4014e240e6398a6c2c47",
|
||||
"framework/Console/Commands/QueueStatusCommand.php": "c266efbd60f9adbbb221de51cb735ea8d651e98d7aa32e4cfd8e4707f55e9acb",
|
||||
"framework/Console/Commands/RoleListCommand.php": "ddaa98e441e5a89e96cbfc4158f69c2c2a513bf4099b8228180ef40a72440f6f",
|
||||
"framework/Console/Commands/RouteListCommand.php": "a80b659baa4f268130711503c09bd7c961b7270b22c7ae44de304bbad2086f65",
|
||||
"framework/Console/Commands/ScheduleRunCommand.php": "c2081a61d16f3573847d5667face3776347044c519a728f763324ed144973a78",
|
||||
"framework/Console/Commands/SeedCommand.php": "8933a80d01485ea010091754acd04d1a23c1cbfca8ba0b91dd62afe950fff66d",
|
||||
"framework/Console/Commands/ServeCommand.php": "a6aceb0b8ac28d8be02e7f8dc08d315a54aa6061677a80adf7dfba3c6f0b8b32",
|
||||
"framework/Console/Commands/SettingsExportCommand.php": "fdd352ba0021e4ab76a68e24d125ac8fca482074df0ae8cb0c987914a283e137",
|
||||
"framework/Console/Commands/SettingsImportCommand.php": "f68b985c242a6c5263195cba71afe0c0520b33cae1e6a18516cd13d45b35204b",
|
||||
"framework/Console/Commands/StatusCommand.php": "2549c6e4ca7b4a1a7dd6afedd3e4ff5883ce1fa5050bedb403c537c2e28c1b7b",
|
||||
"framework/Console/Commands/TestCommand.php": "77532d490f44c9c1fbefcc94b418322376fd798534d5d2af5905aefed89d3e26",
|
||||
"framework/Console/Commands/TinkerCommand.php": "d134f15f8772a69aac2cb15eba89d78f622b03dd12fb967643ddd204fa63b9eb",
|
||||
"framework/Console/Commands/UpCommand.php": "5716ca653fa3a7d6e95e207c1854a3cc6aa8a718bcfda4b5115d634f4125d90d",
|
||||
"framework/Console/Commands/UserCreateCommand.php": "073b4ddca898799dc0bad3c52c3f52d33b5a59fd74e14d326f04cdfe33b7c38f",
|
||||
"framework/Console/Commands/UserDeleteCommand.php": "2ebf37654e31451c9cf53fc07de4f8497b44de4fc6a5ebf24362a8d624dce6ae",
|
||||
"framework/Console/Commands/UserListCommand.php": "f15db6058c9732e31b3551f9a58d9dc83ca2e846d93e6d9a9a5f0948c09a5822",
|
||||
"framework/Console/Commands/UserPasswordCommand.php": "5dad76885c0fed8bd729eb9229dd66346e7f14e0c1933645174f627198d60415",
|
||||
"framework/Console/Commands/WebhookListCommand.php": "51c2119666c2cf8af57a66606580748a9b28ed8c0e52c47aa7bb1dca90bbdf4d",
|
||||
"framework/Console/Commands/WebhookTestCommand.php": "925abbb8310176cb7102f619adbdb581be761ced2315eb9517019d56d5780881",
|
||||
"framework/Console/Commands/WorkerCommand.php": "6dfba8c8aa752a8420bd78a2df425214b8e632f09cd461b0a541f76849dcf94a",
|
||||
"framework/Console/Commands/WorkerRestartCommand.php": "b877813d5fe43703e12f11a0ccde3f326d75aa66d44ed70a51e3680e9e2ee266",
|
||||
"framework/Core/Updater.php": "a277935fd81f8d1eefa3851b5243c8c27e7492d62296608929295075681c5928",
|
||||
"framework/Database/Connection.php": "b349a7aa5217c98af77eddac9de7ceeef744af980eda02b989d17837a16bfe4b",
|
||||
"framework/Database/DatabaseException.php": "d43ac6cf2a17680cde24923676e0a91dfddefa645cc97c129dd44c64960e41df",
|
||||
"framework/Database/Lock.php": "b2b793af798d59b9fcc5bcdd2db09ea9645796e658a0fb6c6000539484283f3e",
|
||||
"framework/Database/Migration.php": "f8ec7b3618210683b4c3489d53e86e30f0e8054030b5e6816a39c433c799584c",
|
||||
"framework/Database/Migrator.php": "baf511603b484dd9ab0ff4004e50bcdc6c5e97f6ead8036f121150d903ed42a9",
|
||||
"framework/Database/Model/Factory.php": "0934373abb953f97db0963219ed68b6ce09a571f126a7e3ece683958c76cc9d2",
|
||||
"framework/Database/Model/Model.php": "955cece21c51820452853f2ee4bc5ff2e185a218ab3c9d68d5a58dd2bb96d181",
|
||||
"framework/Database/Model/Observers.php": "101bc685f6e4361f242bd3e6d372da9e1cafa57a3727d29256cff09b0d7da5df",
|
||||
"framework/Database/Model/Query.php": "21164bb2d369ebeb212a982c3ccb85773c0e7869408e35a69b1c5edb6fed626a",
|
||||
"framework/Database/Model/RecordNotFound.php": "065ad9b4114e2a2af7f17757fb727a21edfcb7569ac2c704a07cd4f4feb1ed80",
|
||||
"framework/Database/Model/Relations/BelongsTo.php": "6264d69ee25172c2ef3d5238e80e03fafae7460168b46a6b7bb64ba840814428",
|
||||
"framework/Database/Model/Relations/BelongsToMany.php": "a0ed99d2fe5dc28dbe6af534a7b9b834e3a7de6f2523bbffaa97613ed0e5132d",
|
||||
"framework/Database/Model/Relations/HasMany.php": "844d540049e591b3e5f31563c50e991b6b6d5dcbbab9ed29957b90303e0ef5dc",
|
||||
"framework/Database/Model/Relations/HasOne.php": "52e8050b36848be910b5f5021b35e1f42352dc6d1cd311afac28907ea30a4939",
|
||||
"framework/Database/Model/Relations/Relation.php": "c60f71943dfaaa6876ca7ee12b766a715a9413a1ba00de09e5f166dd93a05e54",
|
||||
"framework/Database/Query/Builder.php": "734082ca41280e7a1d46edc512f7d86cb0889d1d9feb4b1bfb580555a1e38f58",
|
||||
"framework/Database/Schema/Blueprint.php": "9eff0a5446ac3b1a95441608f96caf376dd8e5eb8fd803fdd0bb77b70082b7a2",
|
||||
"framework/Database/Schema/Builder.php": "2f4d7a58cc7d14b19a1d9855370d8aca5eae0ee644ef37eedc2e0aa87c73509a",
|
||||
"framework/Database/Schema/Column.php": "dc1de17ded3188aabbdb0d33a8facd7c189342abcf6d00a52f144c50cb23c88d",
|
||||
"framework/Database/Schema/Operation.php": "3d572480ff85a5faa290253dbdf8cfad6beba1451f97686ad8f655cbe5bd2f8c",
|
||||
"framework/Database/Schema/Types.php": "d0922e7a276c87baf5cc6b45e5022ce767904b36aca12f2f42b68e081e1ce267",
|
||||
"framework/Events/Events.php": "596035a2b847330f43f9327e38c6677cf410ab83828f9882d0335539aae8eab1",
|
||||
"framework/Files/Attachment.php": "4bc0b46f84f670eb18538233fee08b6d44e87cd74971046c44350ce83547c4c4",
|
||||
"framework/Files/Storage.php": "06a8f45724f4933327ed524f6c20530c74312eeeec1cf18c291f899b77cc1487",
|
||||
"framework/Files/UploadedFile.php": "ce4f09794db885cf036a13db824e175e9f8969a663dfb0087a35912d551eb08d",
|
||||
"framework/Http/Controller.php": "d16beb92a9e6578b19173ac7e785c08d0617f1277d3c375b89a28b95a4d51511",
|
||||
"framework/Http/Kernel.php": "1e91c29106c784ba6d2789ed36154514d2fae8e9b96d6d43c15f96ea81ef4736",
|
||||
"framework/Http/Middleware/ApiKey.php": "1aedc0ad51923add221f4c2ff08719bf0d17cad38bdeff67ecfd2ad4b201fe71",
|
||||
"framework/Http/Middleware/Authenticate.php": "2c4311cdf694ccaec96abac6952aa14603eed5616c2358c53a1b5e219455b762",
|
||||
"framework/Http/Middleware/Can.php": "a93d1cf8c802a1bb941d2bbb0e95919e5955c7594e0b9c23f899c30b432c36c2",
|
||||
"framework/Http/Middleware/Guest.php": "d0680fbb1657af46b8ffe67ce644c937c3872edc7e9e2985950dac14ee0d6aa1",
|
||||
"framework/Http/Middleware/Install.php": "3e6100b2e6215d7f031996d010db5d6087e373a9a487ab99d9fdf7fa5988baad",
|
||||
"framework/Http/Middleware/Signed.php": "d9831b32c9c03db241b75df9bcc220241101b8e6addd05c44680f2c8a6038d29",
|
||||
"framework/Http/Middleware/Throttle.php": "628433e187a153e171d7363888efa512a9417d9fc5d20009c27e0440e5f91007",
|
||||
"framework/Http/Middleware/VerifyCsrf.php": "f80d9ad66a10d3e65a37329f407f0e990b5bb14c80cc3500ef94cc80f5eb085b",
|
||||
"framework/Http/Request.php": "a3ec8c977ceab6ca81e42fb4058a30676740b423e15daf52cb0c7a8461dca33c",
|
||||
"framework/Http/Response.php": "095ee6119bce6d0cb400ad0d82eb1fba8b07433a20ba3c3ee3e550f08f74811b",
|
||||
"framework/Http/Route.php": "1a9ce1b7484885cb9cec3794f3a9ced4c43408f26f6e1fffbba5eabc8bc4d1cd",
|
||||
"framework/Http/Router.php": "4723acef3ef23d3f31a95ebdf722da06a698d87b91eb60fbcefbff7263d24a93",
|
||||
"framework/Install/Installer.php": "46f1a3d111a794ea1e704b6d86fd7028c6b33eb788d0d34820ed9a22bfb8e536",
|
||||
"framework/Mail/Drivers/DriverInterface.php": "d0400112eea0fd2369d4cab3f1ca23b55bb68df56c08f551a80e76ce3848b32c",
|
||||
"framework/Mail/Drivers/LogDriver.php": "c378bf1cfa512144646226d97692501b7b3b976f63c498649f36acf6126fd927",
|
||||
"framework/Mail/Drivers/MailDriver.php": "56f075682bc01b0b555282761c2ce7d5beb25e484d3719e1c0b3741d3ad0a9df",
|
||||
"framework/Mail/Drivers/MailerServiceDriver.php": "6ad6832779aa1daf5afd30a78652bebebe8b55eba6095efd503a69e60d36d77e",
|
||||
"framework/Mail/Drivers/NullDriver.php": "5fe204fb2a9c730963c89160d79b59bc097d49d57346194e3557dd69df81d093",
|
||||
"framework/Mail/Drivers/SmtpDriver.php": "28c7edb632ccec601b96fb27d4d7b792de7b404e158ece5a2f1d2fb05756554b",
|
||||
"framework/Mail/Mail.php": "ecf2ebf10a81e741feaf82d8438fc43bc8c48460f685c71c9d3b8a11655c0772",
|
||||
"framework/Mail/Message.php": "1fb4024ad014febd6b24d3fd7df4cbffb11ad73929b4c4217a9f1424afec8eff",
|
||||
"framework/Mail/Mime.php": "ff5729ec6892cf590c2e8395add7a5cfd23627accca21db2bb068d6d24b91d29",
|
||||
"framework/Mail/SendMailJob.php": "b24172951ed04b57f31f47b49105b0b6b96c5becc577af1953af0b6902e4e51a",
|
||||
"framework/Models/ApiToken.php": "8110f3d547c3abeca35c7ce0e628ffdfd5d24d5966bf7c91d4abfc201524bb5d",
|
||||
"framework/Models/AuditEntry.php": "6723320f23e9c4125e1ba739f7e3663a68d39de34c718eb7b5a26cca9dc4936e",
|
||||
"framework/Models/AuthToken.php": "952d65139aa9e2937f1b3ea48e204447b4aa1f02aae8b6e8ac8e7b894cf52ff2",
|
||||
"framework/Models/BlockedIp.php": "010f2f0ba0d499d533054a6e823c8fd135fa97bd04bd576c2fc6e4aa2133ddab",
|
||||
"framework/Models/IncomingHook.php": "befe12401828611da8d4bfe0b50cb297261a1d49032629dc99981d560cdce586",
|
||||
"framework/Models/RememberToken.php": "37a26b13af123b0284154b7744f3c4d50547e2106a0ae3a8864c5eea56d0af24",
|
||||
"framework/Models/Role.php": "5706c6605a5f62573a12e79726a187bfafe95ed4ae25590f98814e09c28ff789",
|
||||
"framework/Models/SecurityEvent.php": "3239ce406452ba347fbfe973ac5dde2620f11d844a3b7f2427cb1f698c5b1841",
|
||||
"framework/Models/Setting.php": "e952bee4f142dc66bd250c067a7c9281c1da390f29eada5102b6977fa9e82a0d",
|
||||
"framework/Models/User.php": "44d2ef0c2780d3d8d691e59f41c992941f941431fb18c128ddc9facdd992cbc2",
|
||||
"framework/Models/UserField.php": "91cb55f699d34c7b6ede7ec9fad42200bb96c953c958dac183c8e34f4bc22a63",
|
||||
"framework/Models/UserFieldValue.php": "fb6cd5da9c8ca67fd01917b38be3bde6b81964bea6f746ca49f5bd4d95dd9e26",
|
||||
"framework/Models/UserNotification.php": "f206d0f046f4a1a046b87cd5e8550bb9102cbc320de57ef99f61dcaa2daebcfc",
|
||||
"framework/Models/UserSession.php": "ca92250bda902805f81451d6d5f4e4f2c3a1ed6e0a6f337ba49ea78d1ddb6125",
|
||||
"framework/Models/Webhook.php": "40617a6dbb6992d58878ee5f573039eeaa51de548cbbafb32a7936c6c4dda460",
|
||||
"framework/Models/WebhookDelivery.php": "9c47733fd878f1afe740dbf71d6739cd63214467170340fe0103f93a1e871a3a",
|
||||
"framework/Notifications/ApiKeyExpiringNotification.php": "caa8d6580aac355098a6af1854a8e0b7e97ef04537c71f41536741ede018fb4b",
|
||||
"framework/Notifications/ExportReadyNotification.php": "df625de5845f0ab9a2ed1f80dbd5d7ea0fa8a5cca5aa0a7c49adbaa5ab0db2c0",
|
||||
"framework/Notifications/HealthAlertNotification.php": "ffcb874b663c975bc8b1a786f14ab5d9cf50fc912b995f893398d86906a77a05",
|
||||
"framework/Notifications/Notification.php": "dd93c612c7213dc89febe2e485346e485196c9faa4e4186d287c0074e640a37c",
|
||||
"framework/Notifications/Notify.php": "9abfb081f1c33589fca985e8d02fcdc018784c1ccdb86166c99280d374d6da6b",
|
||||
"framework/Notifications/WebhookDisabledNotification.php": "99171f02d1702468222bbb3f4ae3a61beb5f77d4ed26432f90fe47edbfe247df",
|
||||
"framework/Queue/HitWorker.php": "6b4d243a0dcaf81dc68c4c90e44f8421efbfafaa84047aeb86c7c6151daa6bd9",
|
||||
"framework/Queue/Job.php": "5317fbb99766e5e49937a3a0be6f456d511cd713e72bd371dcb47adcf6e9251a",
|
||||
"framework/Queue/Queue.php": "2a71204017f8e5905c7fc0b61210beebad33da7bc571f1fdda5b920ed2fbc54f",
|
||||
"framework/Queue/Scheduler.php": "969965c817e40c39eef44087e228a785db84413db4fb8c67a8c7ada6f1a1d6b8",
|
||||
"framework/Queue/Worker.php": "f0bc8dcdec47e2fc4688114995c46ab87f887c5086b86b04033155deb67e4f5e",
|
||||
"framework/RateLimit/RateLimiter.php": "aa9fb8f84b14de6a6b4f39ab6ef99166e8150d402dca95ee6bfeb9ef3cac5ad7",
|
||||
"framework/Support/Audit.php": "8eb4cae91532dac0b1a4ecc5b217344fefa1a4850ea1bf555403dc4e5e357ce3",
|
||||
"framework/Support/ClientIp.php": "d530cba12c255c6f802e94de261caf9284d93f09f420f7d9026a1e39665adc4b",
|
||||
"framework/Support/Config.php": "d15aa129a903ad36a39629fcc6db4c2b7596de0d93ab75a73c4524925daab58b",
|
||||
"framework/Support/Container.php": "a4626e3790045b0d236f03115afbce824bd242df1f1637e43af3227802647ca1",
|
||||
"framework/Support/CronExpression.php": "90041c2479c8247cfedcb273ef7747466106814bce5ad3a4fbc695f1a99648f6",
|
||||
"framework/Support/Csv.php": "f83e208eb702f3247a278846ce0e3e698d187e987036fc9c880bbe7bb139e026",
|
||||
"framework/Support/Diagnostics.php": "00e81a9f78cd617940c696e46bf990185d0c09a1cf10d62d4f11e41de83bd39d",
|
||||
"framework/Support/Env.php": "f0bcf6367f57865aa84c826f204ed38a2abd0d2d02f32e35ddf6c58ea86df2e7",
|
||||
"framework/Support/Export.php": "b0298137aa39b09e1ff2edbebadf8e375417622e845b8a4497f73ef2e11c2f8b",
|
||||
"framework/Support/ExportFile.php": "f90ef5c01ef8dc34e1965f64b06f08da8bf0a83e45dd720008e72cf73b9b5d32",
|
||||
"framework/Support/ExportJob.php": "ac465a410c55c365d92a92a5e5dc55c05384528b53d1b8529569ab06275a7fb1",
|
||||
"framework/Support/Exports.php": "a3431e65b8041575aabf51ca2ce0ab35508d55c59cb67ead3de97ca0240729f6",
|
||||
"framework/Support/Filter.php": "d0e64d46147cb664ee45f9e74d82af19b5e936ed3a69ad4d24f792f524e178d8",
|
||||
"framework/Support/Filters.php": "d706838b31dca302609e17906c6add2d0ac0231cbe2aadcc567d4da297bfdeb0",
|
||||
"framework/Support/HttpClient.php": "81856eb06c8da4cf6fe6dfe0e0a53066bc583e268a41bbfc3f95f793485c087a",
|
||||
"framework/Support/Import.php": "56d7d0cd17d15220b4a9e0762aafda326f583427e8a74fc1f7baf7a9d99b5be6",
|
||||
"framework/Support/ImportPlan.php": "990edf2878958010c35ff419b52ae62230b15a7c4501fa66836082bbc735fc68",
|
||||
"framework/Support/ImportReport.php": "9b2e3712b2be7ac3a10a5147dd8d4456117451c14edb85eb476f3773f7a4a374",
|
||||
"framework/Support/IpAllowlist.php": "bbc269f2bbeff7207809e658778ce6dcc2d674a95d82a6ef896a03d0bc2c55a7",
|
||||
"framework/Support/Logger.php": "999f986469301d8147dbcdafe615da028af1094a01d9758356dd78b31788f262",
|
||||
"framework/Support/Maintenance.php": "028920087c11bc870326ed99af8a874c0a4e58742ed8a4c32eb1ff27f91c1489",
|
||||
"framework/Support/Metrics.php": "3e39a6446611c6d86f902f78a92f38ac6a14748bb9d65470b63f1896f0bfc866",
|
||||
"framework/Support/Monitor.php": "8e0f9e6aaa63a8f9faa989d285517acdc0f77a5ddaf623d1a1472918ad575f62",
|
||||
"framework/Support/NotifyExportReadyJob.php": "fe219dcc1bb3eaef547a6cdfc40c527b5d6dc28fbac43ebf076f297bd201e29c",
|
||||
"framework/Support/Profiler.php": "1255ffc37360fd22af0eb769ff152768095b5382f3bee7c943d2e10839dbfc66",
|
||||
"framework/Support/ProtonException.php": "b85f4dd498dbf1cdf1af83d4c79613fafd14ea4951b7b3f82a530742b992e53e",
|
||||
"framework/Support/Reports.php": "cb147b6292129e6932143949180b578dec3f24bd0971f8c276c50bfdb96bac45",
|
||||
"framework/Support/RequestId.php": "f184191976974d72870ebfd673145e083249c7e6a4b111fd87681a4b66b29b11",
|
||||
"framework/Support/Settings.php": "9fb35a99c5220067e29a46e1fc20bff2b2157d9d5a1edbb19dac172e19f99115",
|
||||
"framework/Support/SignedUrl.php": "37298764bb6b596aab5bbc647a7210471983be4672bd775cf3ed74b134717970",
|
||||
"framework/Support/Str.php": "6d9cefbfecf2699974c5ddf60f87f9e6448d73d9833194fb039921dc1a6d987f",
|
||||
"framework/Support/Trash.php": "dca22d83d4a9cf4683494d4e64dcdf8edaffee86746247b51353ac70ab844cd4",
|
||||
"framework/Support/ValidationException.php": "96755090d3d7324eaa99cf51039db5364a1347712659dabc655ef03e593c6ea5",
|
||||
"framework/Support/Validator.php": "1e0609d8cdb95c114bff3b4cde72f0ff9087c6a28e033ff532503d97793c0f1a",
|
||||
"framework/Support/Widgets.php": "3306c5336e89d5e80cde2f0082df4bbd61e203e4617923218505bf9bba861bcc",
|
||||
"framework/View/View.php": "904bef1979e9deed788e40d22701cb73049984432c0967611838b15ab1da1e2c",
|
||||
"framework/View/views/bulk.php": "0d8047e1d626206800f8b82b67da099d31ffbea7d7e3882477e12254a9ca3cf3",
|
||||
"framework/View/views/errors/403.php": "7e9aa34839dbc142afb2d57e00b5354c4bd1c662fae94ae25ac766c07aa02152",
|
||||
"framework/View/views/errors/404.php": "00b623aabbbb323474dd45436808b4ff6c61ea9dae807d0af1ab1a308859867b",
|
||||
"framework/View/views/errors/500.php": "0ed68a18f12132704d5b4bf145783f9d24bf6e9aa9a75c1c7478a1e0fd846867",
|
||||
"framework/View/views/errors/503.php": "eae9cbe478e888edbe10e80bfe33752c3c52fadf7fb4460bc75699ec7ef02f4b",
|
||||
"framework/View/views/filters.php": "30ecabf48bdd7210055f768afc8a6245f26cc2da3a45599eb7cc198ac1008c79",
|
||||
"framework/View/views/history.php": "7a0c4c97b234e7714784afdfbf4ef0dced360682846ee042cd464c5cf7d5de40",
|
||||
"framework/View/views/layouts/main.php": "a069aaa5958aad48226e37bcaa2576f45524ea6de0c65ad1511d5c6d6ab79431",
|
||||
"framework/View/views/pagination.php": "715c274ea12b90717af1013f6cf9fb66d291188bc68d697c86350f8f84ae1e6d",
|
||||
"framework/View/views/profiler.php": "a1583e581a5d2ccdaee6ed6be9e873c8234d9e6f57fa32514ca333c3c6a57be6",
|
||||
"framework/View/views/sort.php": "6dcb8ea0ff3300ec2ddac2ac4aa08300642ef650e45602df6089f8f66182b38b",
|
||||
"framework/Webhooks/DeliverWebhookJob.php": "a9dbdd7646f49602f81e421966770c7d51caa34a3076b552a08ebda55f259791",
|
||||
"framework/Webhooks/Incoming.php": "769c80f15f717b839c49271b3c783aab221e51f6595c2729dc870bf402a452cd",
|
||||
"framework/Webhooks/Webhooks.php": "c1807b8606541f664b51e553339336ef6458aed71656c9641b70f2b56076fbdc"
|
||||
}
|
||||
@@ -84,6 +84,14 @@ final class Application
|
||||
Commands\WebhookListCommand::class,
|
||||
Commands\WebhookTestCommand::class,
|
||||
],
|
||||
'Обновление ядра' => [
|
||||
Commands\CoreVersionCommand::class,
|
||||
Commands\CoreBumpCommand::class,
|
||||
Commands\CoreCheckCommand::class,
|
||||
Commands\CoreDiffCommand::class,
|
||||
Commands\CoreSyncCommand::class,
|
||||
Commands\CoreLatestCommand::class,
|
||||
],
|
||||
];
|
||||
|
||||
/** @var array<int, string> Позиционные аргументы */
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Console\Commands;
|
||||
|
||||
use Rsgrinko\Proton\Console\Command;
|
||||
use Rsgrinko\Proton\Core\Updater;
|
||||
|
||||
/**
|
||||
* бампает версию ядра — руками, не хуком на каждый коммит: версия размечает
|
||||
* точку, к которой имеет смысл синхронизировать другой проект, не коммиты.
|
||||
*/
|
||||
final class CoreBumpCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'core:bump';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'бампает версию ядра (по умолчанию — патч) и дописывает docs/CHANGELOG.md';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return 'core:bump [patch|minor|major] [--note="..."] [--breaking]';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
$level = $this->arg(0, 'patch');
|
||||
|
||||
if (!in_array($level, ['patch', 'minor', 'major'], true)) {
|
||||
$this->fail('Уровень — patch, minor или major, не "' . $level . '"');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$updater = new Updater(APP_ROOT);
|
||||
$before = $updater->localVersion();
|
||||
$note = (string) $this->option('note', '');
|
||||
$after = $updater->bump($level, $note, $this->hasOption('breaking'));
|
||||
|
||||
$this->ok($before . ' → ' . $after);
|
||||
|
||||
if ($note === '') {
|
||||
$this->line('Запись в docs/CHANGELOG.md не добавлена — не передан --note');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Console\Commands;
|
||||
|
||||
use Rsgrinko\Proton\Console\Command;
|
||||
use Rsgrinko\Proton\Core\Updater;
|
||||
|
||||
/**
|
||||
* проверяет framework/ на локальные правки в обход правила «ядро не патчим».
|
||||
*/
|
||||
final class CoreCheckCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'core:check';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'сверяет framework/ со своей последней синхронизацией; --baseline фиксирует текущее состояние как доверенное';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return 'core:check [--baseline]';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
$updater = new Updater(APP_ROOT);
|
||||
|
||||
if ($this->hasOption('baseline')) {
|
||||
$updater->saveBaseline();
|
||||
$this->ok('Текущее состояние framework/ сохранено как доверенное (framework/.checksums.json)');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($updater->storedBaseline() === []) {
|
||||
$this->fail('Доверенного состояния ещё нет — сначала: php bin/proton core:check --baseline');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$changed = $updater->check();
|
||||
|
||||
if ($changed === []) {
|
||||
$this->ok('framework/ не менялся с последней синхронизации');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->fail('Локально изменены (в обход правила «не трогать ядро руками»):');
|
||||
|
||||
foreach ($changed as $path) {
|
||||
$this->line(' ' . $path);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?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;
|
||||
use Rsgrinko\Proton\Support\ProtonException;
|
||||
|
||||
/**
|
||||
* что можно взять из ядра, что требует ручного слияния, что ядро больше не
|
||||
* содержит — только смотрит, ничего не пишет.
|
||||
*/
|
||||
final class CoreDiffCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'core:diff';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'план обновления ядра: что скопировать, что мержить руками, что удалено (--path=<каталог> или --remote)';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return 'core:diff --path=<каталог с ядром рядом> | --remote';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
$updater = new Updater(APP_ROOT);
|
||||
|
||||
if ($updater->storedBaseline() === []) {
|
||||
$this->fail('Доверенного состояния ещё нет — сначала: php bin/proton core:check --baseline');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$path = $this->option('path', '');
|
||||
$temporary = null;
|
||||
|
||||
if ($path === null || $path === '') {
|
||||
if (!$this->hasOption('remote')) {
|
||||
$this->fail('Нужен --path=<каталог> или --remote');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$path = $temporary = $updater->downloadRemote(
|
||||
(string) Config::get('core.repo'),
|
||||
(string) Config::get('core.branch')
|
||||
);
|
||||
} catch (ProtonException $e) {
|
||||
$this->fail($e->getMessage());
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$report = $updater->diff($path);
|
||||
|
||||
if ($temporary !== null) {
|
||||
$updater->cleanupRemote($temporary);
|
||||
}
|
||||
|
||||
$this->printReport($report);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{version_local: string, version_core: string, safe: array<int, string>, manual: array<int, string>, removed: array<int, string>, broken: array<string, array<int, string>>} $report
|
||||
*/
|
||||
private function printReport(array $report): void
|
||||
{
|
||||
$this->line('Ядро сейчас: ' . $report['version_core'] . ' (у вас: ' . $report['version_local'] . ')');
|
||||
$this->line();
|
||||
|
||||
$this->line('Можно взять безопасно:');
|
||||
$this->printList($report['safe'], 'пусто');
|
||||
|
||||
$this->line();
|
||||
$this->line('Требуют ручного слияния:');
|
||||
$this->printList($report['manual'], 'пусто');
|
||||
|
||||
$this->line();
|
||||
$this->line('Ядро больше не содержит:');
|
||||
$this->printList($report['removed'], 'пусто');
|
||||
|
||||
if ($report['broken'] !== []) {
|
||||
$this->line();
|
||||
$this->line('Ссылки в вашем коде, которые могут сломаться после sync:');
|
||||
|
||||
foreach ($report['broken'] as $symbol => $locations) {
|
||||
$this->line(' ' . $symbol);
|
||||
|
||||
foreach ($locations as $location) {
|
||||
$this->line(' ' . $location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $items
|
||||
*/
|
||||
private function printList(array $items, string $whenEmpty): void
|
||||
{
|
||||
if ($items === []) {
|
||||
$this->line(' — (' . $whenEmpty . ')');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->line(' ' . $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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;
|
||||
use Rsgrinko\Proton\Support\ProtonException;
|
||||
|
||||
/**
|
||||
* копирует из ядра то, что безопасно копировать. Без --apply — тот же план,
|
||||
* что у core:diff, ничего не пишется: цена ошибки здесь выше, чем у migrate.
|
||||
*/
|
||||
final class CoreSyncCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'core:sync';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'копирует безопасную часть обновления ядра; без --apply — только план (--path=<каталог> или --remote)';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return 'core:sync --path=<каталог с ядром рядом> | --remote [--apply]';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
$updater = new Updater(APP_ROOT);
|
||||
|
||||
if ($updater->storedBaseline() === []) {
|
||||
$this->fail('Доверенного состояния ещё нет — сначала: php bin/proton core:check --baseline');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$path = $this->option('path', '');
|
||||
$temporary = null;
|
||||
|
||||
if ($path === null || $path === '') {
|
||||
if (!$this->hasOption('remote')) {
|
||||
$this->fail('Нужен --path=<каталог> или --remote');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$path = $temporary = $updater->downloadRemote(
|
||||
(string) Config::get('core.repo'),
|
||||
(string) Config::get('core.branch')
|
||||
);
|
||||
} catch (ProtonException $e) {
|
||||
$this->fail($e->getMessage());
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$report = $updater->diff($path);
|
||||
$apply = $this->hasOption('apply');
|
||||
|
||||
if (!$apply) {
|
||||
$this->line('Только план — для записи добавьте --apply. Что было бы скопировано:');
|
||||
$this->printList($report['safe']);
|
||||
} else {
|
||||
$copied = $updater->copyFiles($path, $report['safe']);
|
||||
$updater->markSynced($copied);
|
||||
|
||||
$this->ok('Скопировано файлов: ' . count($copied));
|
||||
$this->printList($copied);
|
||||
}
|
||||
|
||||
if ($report['manual'] !== []) {
|
||||
$this->line();
|
||||
$this->line('Требуют ручного слияния (не тронуты):');
|
||||
$this->printList($report['manual']);
|
||||
}
|
||||
|
||||
if ($report['broken'] !== []) {
|
||||
$this->line();
|
||||
$this->line('Возможно сломается в вашем коде — проверьте после слияния:');
|
||||
|
||||
foreach (array_keys($report['broken']) as $symbol) {
|
||||
$this->line(' ' . $symbol);
|
||||
}
|
||||
}
|
||||
|
||||
if ($temporary !== null) {
|
||||
$updater->cleanupRemote($temporary);
|
||||
}
|
||||
|
||||
if ($apply) {
|
||||
$this->line();
|
||||
$this->line('Дальше: php bin/proton test, затем php bin/proton core:bump, когда список ручного слияния разобран.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $items
|
||||
*/
|
||||
private function printList(array $items): void
|
||||
{
|
||||
if ($items === []) {
|
||||
$this->line(' — (пусто)');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
$this->line(' ' . $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Console\Commands;
|
||||
|
||||
use Rsgrinko\Proton\Console\Command;
|
||||
use Rsgrinko\Proton\Core\Updater;
|
||||
|
||||
/**
|
||||
* версия ядра, на которой сидит проект.
|
||||
*/
|
||||
final class CoreVersionCommand extends Command
|
||||
{
|
||||
public function name(): string
|
||||
{
|
||||
return 'core:version';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'версия ядра, на которой сидит проект (framework/VERSION)';
|
||||
}
|
||||
|
||||
public function run(): int
|
||||
{
|
||||
$this->line((new Updater(APP_ROOT))->localVersion());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,621 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rsgrinko\Proton\Core;
|
||||
|
||||
use FilesystemIterator;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use Rsgrinko\Proton\Support\HttpClient;
|
||||
use Rsgrinko\Proton\Support\ProtonException;
|
||||
|
||||
/**
|
||||
* Перенос обновлений ядра в проект: контрольные суммы вместо археологии по
|
||||
* git log (`docs/CORE_UPDATES.md`), сверка ссылок в app/config/routes/
|
||||
* resources/views перед тем, как предложить что-то удалить. Команды `core:*` —
|
||||
* тонкая обвязка ввода-вывода поверх этого класса, вся логика — здесь.
|
||||
*/
|
||||
final class Updater
|
||||
{
|
||||
/** Каталоги проекта, которые не входят в ядро, — их код может ссылаться на классы ядра */
|
||||
private const CLIENT_DIRS = ['app', 'config', 'routes', 'resources/views'];
|
||||
|
||||
private const BASELINE_FILE = 'framework/.checksums.json';
|
||||
|
||||
private const VERSION_FILE = 'framework/VERSION';
|
||||
|
||||
public function __construct(private readonly string $root)
|
||||
{
|
||||
}
|
||||
|
||||
public function localVersion(): string
|
||||
{
|
||||
return $this->readVersion($this->root);
|
||||
}
|
||||
|
||||
public function readVersion(string $projectRoot): string
|
||||
{
|
||||
$file = rtrim($projectRoot, '/') . '/' . self::VERSION_FILE;
|
||||
|
||||
return is_file($file) ? trim((string) file_get_contents($file)) : '0.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Следующая версия по правилам семвера: минор сбрасывает патч, мажор —
|
||||
* минор и патч.
|
||||
*/
|
||||
public static function nextVersion(string $version, string $level): string
|
||||
{
|
||||
[$major, $minor, $patch] = array_pad(array_map('intval', explode('.', $version)), 3, 0);
|
||||
|
||||
return match ($level) {
|
||||
'major' => ($major + 1) . '.0.0',
|
||||
'minor' => $major . '.' . ($minor + 1) . '.0',
|
||||
default => $major . '.' . $minor . '.' . ($patch + 1),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Правит VERSION и дописывает запись в docs/CHANGELOG.md — оба места
|
||||
* иначе легко разъезжаются, если делать их по отдельности.
|
||||
*/
|
||||
public function bump(string $level, string $note, bool $breaking): string
|
||||
{
|
||||
$new = self::nextVersion($this->localVersion(), $level);
|
||||
|
||||
file_put_contents($this->root . '/' . self::VERSION_FILE, $new . "\n");
|
||||
|
||||
if (trim($note) !== '') {
|
||||
$this->prependChangelog($new, trim($note), $breaking);
|
||||
}
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
private function prependChangelog(string $version, string $note, bool $breaking): void
|
||||
{
|
||||
$file = $this->root . '/docs/CHANGELOG.md';
|
||||
$body = is_file($file) ? (string) file_get_contents($file) : "# Журнал изменений ядра\n\n";
|
||||
$entry = "## {$version}\n" . ($breaking ? '- **Ломает:** ' : '- ') . $note . "\n\n";
|
||||
|
||||
// Запись — сразу после заголовка файла, свежее выше старого
|
||||
if (preg_match('/^# .+\n\n/', $body, $m) === 1) {
|
||||
$body = substr_replace($body, $entry, strlen($m[0]), 0);
|
||||
} else {
|
||||
$body = $entry . $body;
|
||||
}
|
||||
|
||||
file_put_contents($file, $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Контрольная сумма каждого файла в framework/ — CRLF нормализуется, чтобы
|
||||
* не поймать ложное отличие только из-за перевода строки.
|
||||
*
|
||||
* @return array<string, string> относительный путь ("framework/...") => sha256
|
||||
*/
|
||||
public function checksums(string $projectRoot): array
|
||||
{
|
||||
$base = rtrim($projectRoot, '/') . '/framework';
|
||||
$sums = [];
|
||||
|
||||
if (!is_dir($base)) {
|
||||
return $sums;
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($base, FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if (!$file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$relative = 'framework/' . str_replace('\\', '/', substr($file->getPathname(), strlen($base) + 1));
|
||||
|
||||
// Сам манифест и файл версии не участвуют в сверке — иначе любой
|
||||
// core:bump или core:check --baseline менял бы собственный результат
|
||||
if (in_array($relative, [self::BASELINE_FILE, self::VERSION_FILE], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = str_replace("\r\n", "\n", (string) file_get_contents($file->getPathname()));
|
||||
$sums[$relative] = hash('sha256', $content);
|
||||
}
|
||||
|
||||
ksort($sums);
|
||||
|
||||
return $sums;
|
||||
}
|
||||
|
||||
/**
|
||||
* Фиксирует нынешнее состояние framework/ как доверенное — разово, сразу
|
||||
* после того, как проект завели от ядра, или один раз сейчас задним числом.
|
||||
*/
|
||||
public function saveBaseline(): void
|
||||
{
|
||||
$sums = $this->checksums($this->root);
|
||||
|
||||
file_put_contents(
|
||||
$this->root . '/' . self::BASELINE_FILE,
|
||||
json_encode($sums, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"
|
||||
);
|
||||
}
|
||||
|
||||
/** @return array<string, string> */
|
||||
public function storedBaseline(): array
|
||||
{
|
||||
$file = $this->root . '/' . self::BASELINE_FILE;
|
||||
|
||||
if (!is_file($file)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = json_decode((string) file_get_contents($file), true);
|
||||
|
||||
return is_array($data) ? $data : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновляет доверенное состояние только для перечисленных файлов — а не
|
||||
* пересчитывает всё дерево заново. Файл из списка «требует ручного
|
||||
* слияния» не копировался и своей старой доверенной суммы лишиться не
|
||||
* должен: пересчёт всего дерева тихо принял бы его текущий (патченный)
|
||||
* вид за новую базу, и следующий диф перестал бы видеть в нём патч —
|
||||
* следующее обновление ядра тогда затёрло бы его как будто «безопасный» файл.
|
||||
*
|
||||
* @param array<int, string> $paths
|
||||
*/
|
||||
public function markSynced(array $paths): void
|
||||
{
|
||||
$baseline = $this->storedBaseline();
|
||||
$current = $this->checksums($this->root);
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (isset($current[$path])) {
|
||||
$baseline[$path] = $current[$path];
|
||||
}
|
||||
}
|
||||
|
||||
ksort($baseline);
|
||||
|
||||
file_put_contents(
|
||||
$this->root . '/' . self::BASELINE_FILE,
|
||||
json_encode($baseline, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Файлы framework/, изменившиеся с последней сохранённой базы, — без
|
||||
* похода к ядру вообще, чистая локальная проверка «ничего не поправили
|
||||
* в обход правила с последнего раза».
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function check(): array
|
||||
{
|
||||
$baseline = $this->storedBaseline();
|
||||
$current = $this->checksums($this->root);
|
||||
$changed = [];
|
||||
|
||||
foreach ($current as $path => $hash) {
|
||||
if (isset($baseline[$path]) && $baseline[$path] !== $hash) {
|
||||
$changed[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Три списка вместо одного диффа: «менялось у ядра» и «менялось у нас» —
|
||||
* два независимых вопроса, а не одна ось.
|
||||
*
|
||||
* @return array{
|
||||
* version_local: string, version_core: string,
|
||||
* safe: array<int, string>, manual: array<int, string>, removed: array<int, string>,
|
||||
* broken: array<string, array<int, string>>
|
||||
* }
|
||||
*/
|
||||
public function diff(string $corePath): array
|
||||
{
|
||||
$baseline = $this->storedBaseline();
|
||||
$local = $this->checksums($this->root);
|
||||
$core = $this->checksums($corePath);
|
||||
|
||||
$safe = [];
|
||||
$manual = [];
|
||||
|
||||
foreach ($core as $path => $hash) {
|
||||
if (!isset($local[$path])) {
|
||||
$safe[] = $path; // новый файл ядра — своего аналога нет, патчить нечего
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($local[$path] === $hash) {
|
||||
continue; // не изменилось
|
||||
}
|
||||
|
||||
$patchedLocally = isset($baseline[$path]) && $baseline[$path] !== $local[$path];
|
||||
|
||||
if ($patchedLocally) {
|
||||
$manual[] = $path;
|
||||
} else {
|
||||
$safe[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
$removed = [];
|
||||
|
||||
foreach ($local as $path => $hash) {
|
||||
if (!isset($core[$path])) {
|
||||
$removed[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'version_local' => $this->localVersion(),
|
||||
'version_core' => $this->readVersion($corePath),
|
||||
'safe' => $safe,
|
||||
'manual' => $manual,
|
||||
'removed' => $removed,
|
||||
'broken' => $this->brokenReferences($corePath),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $paths относительные, из diff()['safe']
|
||||
*
|
||||
* @return array<int, string> реально скопированные
|
||||
*/
|
||||
public function copyFiles(string $corePath, array $paths): array
|
||||
{
|
||||
$copied = [];
|
||||
|
||||
foreach ($paths as $relative) {
|
||||
$source = rtrim($corePath, '/') . '/' . $relative;
|
||||
$target = $this->root . '/' . $relative;
|
||||
|
||||
if (!is_file($source)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dir = dirname($target);
|
||||
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
|
||||
$content = str_replace("\r\n", "\n", (string) file_get_contents($source));
|
||||
file_put_contents($target, $content);
|
||||
|
||||
$copied[] = $relative;
|
||||
}
|
||||
|
||||
return $copied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ссылки в своём коде (app/, config/, routes/, resources/views/) на
|
||||
* классы ядра, которые в новом ядре либо исчезли целиком, либо потеряли
|
||||
* использованную константу/статический метод. Эвристика по тексту, не по
|
||||
* AST: не ловит вызов через интерфейс, не различает статический член от
|
||||
* обычного (`Класс::метод()` вместо `(new Класс())->метод()` — второе не
|
||||
* отслеживается вовсе, класса без единого `::`-обращения только по `new`
|
||||
* или подсказке типа в списке параметров хватает для находки «файл пропал
|
||||
* целиком», но не для «конкретный член пропал»). Не находит всё, но ловит
|
||||
* ровно то, что не поймать простым «диффом файлов»: скрытую поломку в
|
||||
* своём коде.
|
||||
*
|
||||
* @return array<string, array<int, string>> "Класс::член" (или просто
|
||||
* "Класс", если файла не стало целиком) => список "файл:строка"
|
||||
*/
|
||||
public function brokenReferences(string $corePath): array
|
||||
{
|
||||
$broken = [];
|
||||
|
||||
foreach ($this->symbolUsages() as $fqcn => $usages) {
|
||||
$file = rtrim($corePath, '/') . '/' . $this->classToPath($fqcn);
|
||||
|
||||
if (!is_file($file)) {
|
||||
$locations = array_merge(...array_values($usages));
|
||||
$broken[$fqcn] = $locations;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($usages as $member => $locations) {
|
||||
// '' — обращение к самому классу без ::член; 'class' — магическая
|
||||
// ::class, а не настоящий член, определять её негде и незачем
|
||||
if ($member === '' || $member === 'class' || $this->definesMember($corePath, $fqcn, $member)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$broken[$fqcn . '::' . $member] = $locations;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($broken);
|
||||
|
||||
return $broken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ищет член в самом классе, а не найдя — в родителе: Active Record модели
|
||||
* почти всегда зовут find()/query() не у себя, а у общего Model, и без
|
||||
* подъёма по extends всё это ложно выглядело бы «пропавшим».
|
||||
*/
|
||||
private function definesMember(string $corePath, string $fqcn, string $member, int $depth = 0): bool
|
||||
{
|
||||
if ($depth > 6 || !str_starts_with($fqcn, 'Rsgrinko\\Proton\\')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = rtrim($corePath, '/') . '/' . $this->classToPath($fqcn);
|
||||
|
||||
if (!is_file($file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$source = (string) file_get_contents($file);
|
||||
|
||||
if (preg_match('/\bconst\s+' . preg_quote($member, '/') . '\b/', $source) === 1
|
||||
|| preg_match('/\bfunction\s+' . preg_quote($member, '/') . '\s*\(/', $source) === 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (preg_match('/\bclass\s+\w+\s+extends\s+([A-Za-z0-9_\\\\]+)/', $source, $m) !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$parent = $this->resolveClassName($source, $m[1]);
|
||||
|
||||
return $parent !== null && $this->definesMember($corePath, $parent, $member, $depth + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Короткое имя класса из `extends` — в своё полное имя, тем же приёмом,
|
||||
* что и у клиентского кода: use в этом же файле, а без него — тот же
|
||||
* namespace, что у самого файла.
|
||||
*/
|
||||
private function resolveClassName(string $source, string $name): ?string
|
||||
{
|
||||
if (str_starts_with($name, '\\')) {
|
||||
return ltrim($name, '\\');
|
||||
}
|
||||
|
||||
if (str_contains($name, '\\')) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (preg_match('/^use\s+([A-Za-z0-9_\\\\]+\\\\' . preg_quote($name, '/') . ')\s*;/m', $source, $m) === 1) {
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
if (preg_match('/^namespace\s+([A-Za-z0-9_\\\\]+);/m', $source, $m) === 1) {
|
||||
return $m[1] . '\\' . $name;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function classToPath(string $fqcn): string
|
||||
{
|
||||
$inner = substr($fqcn, strlen('Rsgrinko\\Proton\\'));
|
||||
|
||||
return 'framework/' . str_replace('\\', '/', $inner) . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Разбирает свой код построчно: `use Rsgrinko\Proton\...;` даёт короткое
|
||||
* имя для класса в пределах файла, дальше `Короткое::член` резолвится
|
||||
* через эту карту. Полностью квалифицированное имя (`\Rsgrinko\Proton\...::член`)
|
||||
* учитывается и без use. Сам импорт тоже считается использованием под
|
||||
* ключом '' — иначе `new Logger()` или `function foo(User $user)` вообще
|
||||
* не попали бы в список, и «файл пропал целиком» осталось бы незамеченным
|
||||
* там, где к классу ни разу не обратились через ::.
|
||||
*
|
||||
* @return array<string, array<string, array<int, string>>> FQCN => член => ["файл:строка", ...]
|
||||
*/
|
||||
private function symbolUsages(): array
|
||||
{
|
||||
$usages = [];
|
||||
|
||||
foreach ($this->clientFiles() as $file) {
|
||||
$lines = explode("\n", (string) file_get_contents($file));
|
||||
$imports = [];
|
||||
|
||||
foreach ($lines as $number => $line) {
|
||||
if (preg_match('/^use\s+(Rsgrinko\\\\Proton\\\\[A-Za-z0-9_\\\\]+)(?:\s+as\s+([A-Za-z0-9_]+))?\s*;/', trim($line), $m) === 1) {
|
||||
$fqcn = $m[1];
|
||||
$short = ($m[2] ?? '') !== '' ? $m[2] : substr($fqcn, strrpos($fqcn, '\\') + 1);
|
||||
$imports[$short] = $fqcn;
|
||||
$usages[$fqcn][''][] = $this->relative($file) . ':' . ($number + 1);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($lines as $number => $line) {
|
||||
$location = $this->relative($file) . ':' . ($number + 1);
|
||||
|
||||
// Полностью квалифицированное имя прямо в строке
|
||||
if (preg_match_all('/Rsgrinko\\\\Proton\\\\([A-Za-z0-9_\\\\]+)::([A-Za-z_][A-Za-z0-9_]*)/', $line, $matches, PREG_SET_ORDER) > 0) {
|
||||
foreach ($matches as $match) {
|
||||
$fqcn = 'Rsgrinko\\Proton\\' . $match[1];
|
||||
$usages[$fqcn][$match[2]][] = $location;
|
||||
}
|
||||
}
|
||||
|
||||
// Короткое имя через use
|
||||
if (preg_match_all('/\b([A-Z][A-Za-z0-9_]*)::([A-Za-z_][A-Za-z0-9_]*)/', $line, $matches, PREG_SET_ORDER) > 0) {
|
||||
foreach ($matches as $match) {
|
||||
if (!isset($imports[$match[1]])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$usages[$imports[$match[1]]][$match[2]][] = $location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $usages;
|
||||
}
|
||||
|
||||
/** @return array<int, string> */
|
||||
private function clientFiles(): array
|
||||
{
|
||||
$files = [];
|
||||
|
||||
foreach (self::CLIENT_DIRS as $dir) {
|
||||
$base = $this->root . '/' . $dir;
|
||||
|
||||
if (!is_dir($base)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($base, FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->isFile() && $file->getExtension() === 'php') {
|
||||
$files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
private function relative(string $path): string
|
||||
{
|
||||
$path = str_replace('\\', '/', $path);
|
||||
$root = str_replace('\\', '/', $this->root);
|
||||
|
||||
return ltrim(str_replace($root, '', $path), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Версия ядра прямо из репозитория — обычный текстовый файл, без похода
|
||||
* в API и без авторизации.
|
||||
*/
|
||||
public function remoteVersion(string $repo, string $branch): string
|
||||
{
|
||||
$response = (new HttpClient())->get($this->rawUrl($repo, $branch, self::VERSION_FILE));
|
||||
|
||||
return $response['status'] === 200 ? trim($response['body']) : '';
|
||||
}
|
||||
|
||||
public function remoteChangelog(string $repo, string $branch): string
|
||||
{
|
||||
$response = (new HttpClient())->get($this->rawUrl($repo, $branch, 'docs/CHANGELOG.md'));
|
||||
|
||||
return $response['status'] === 200 ? $response['body'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Записи журнала новее заданной версии, самая свежая сверху — ровно то,
|
||||
* что стоит прочитать между «на чём я сижу» и «что сейчас в ядре».
|
||||
*/
|
||||
public static function changelogSince(string $changelog, string $sinceVersion): string
|
||||
{
|
||||
$out = [];
|
||||
$capture = false;
|
||||
|
||||
foreach (explode("\n", $changelog) as $line) {
|
||||
if (preg_match('/^##\s+(\d+\.\d+\.\d+)/', $line, $m) === 1) {
|
||||
$capture = version_compare($m[1], $sinceVersion) > 0;
|
||||
}
|
||||
|
||||
if ($capture) {
|
||||
$out[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
return trim(implode("\n", $out));
|
||||
}
|
||||
|
||||
/**
|
||||
* Архив ветки одним запросом вместо `git clone` — распаковывается
|
||||
* встроенным PharData, ничего доустанавливать не нужно. Каталог нужно
|
||||
* убрать самостоятельно через cleanupRemote() после использования.
|
||||
*/
|
||||
public function downloadRemote(string $repo, string $branch): string
|
||||
{
|
||||
$response = (new HttpClient(30))->get($this->archiveUrl($repo, $branch));
|
||||
|
||||
if ($response['status'] !== 200 || $response['body'] === '') {
|
||||
throw new ProtonException('Не удалось скачать архив ядра (код ' . $response['status'] . '): ' . $this->archiveUrl($repo, $branch));
|
||||
}
|
||||
|
||||
$dir = $this->root . '/var/tmp/core-sync-' . bin2hex(random_bytes(6));
|
||||
mkdir($dir, 0777, true);
|
||||
|
||||
$archive = $dir . '/core.tar.gz';
|
||||
file_put_contents($archive, $response['body']);
|
||||
|
||||
(new \PharData($archive))->extractTo($dir);
|
||||
unlink($archive);
|
||||
|
||||
// Архив распаковывается в подкаталог вида <repo>-<ветка>/
|
||||
$entries = array_values(array_diff(scandir($dir) ?: [], ['.', '..']));
|
||||
$extracted = $entries[0] ?? '';
|
||||
|
||||
if ($extracted === '' || !is_dir($dir . '/' . $extracted . '/framework')) {
|
||||
throw new ProtonException('Архив ядра распаковался, но framework/ внутри не нашёлся');
|
||||
}
|
||||
|
||||
return $dir . '/' . $extracted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Убирает временный каталог, оставшийся после downloadRemote().
|
||||
*/
|
||||
public function cleanupRemote(string $extractedPath): void
|
||||
{
|
||||
// extractedPath — это .../core-sync-XXXX/<repo>-<ветка>, чистим на
|
||||
// уровень выше, весь временный каталог целиком
|
||||
$tmp = dirname($extractedPath);
|
||||
|
||||
if (!str_contains($tmp, '/var/tmp/core-sync-') || !is_dir($tmp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($tmp, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$file->isDir() ? rmdir($file->getPathname()) : unlink($file->getPathname());
|
||||
}
|
||||
|
||||
rmdir($tmp);
|
||||
}
|
||||
|
||||
private function rawUrl(string $repo, string $branch, string $path): string
|
||||
{
|
||||
$repo = rtrim($repo, '/');
|
||||
|
||||
if (str_contains($repo, 'github.com')) {
|
||||
$ownerRepo = trim((string) parse_url($repo, PHP_URL_PATH), '/');
|
||||
|
||||
return "https://raw.githubusercontent.com/{$ownerRepo}/{$branch}/{$path}";
|
||||
}
|
||||
|
||||
// Gitea и совместимые: те же данные лежат по /raw/branch/<ветка>/<путь>
|
||||
return "{$repo}/raw/branch/{$branch}/{$path}";
|
||||
}
|
||||
|
||||
private function archiveUrl(string $repo, string $branch): string
|
||||
{
|
||||
$repo = rtrim($repo, '/');
|
||||
|
||||
return str_contains($repo, 'github.com')
|
||||
? "{$repo}/archive/refs/heads/{$branch}.tar.gz"
|
||||
: "{$repo}/archive/{$branch}.tar.gz";
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ use Rsgrinko\Proton\Http\Middleware\Install;
|
||||
use Rsgrinko\Proton\Http\Middleware\Signed;
|
||||
use Rsgrinko\Proton\Http\Middleware\Throttle;
|
||||
use Rsgrinko\Proton\Http\Middleware\VerifyCsrf;
|
||||
use Rsgrinko\Proton\Events\Events;
|
||||
use Rsgrinko\Proton\Support\Config;
|
||||
use Rsgrinko\Proton\Support\Logger;
|
||||
use Rsgrinko\Proton\Support\Maintenance;
|
||||
@@ -84,6 +85,11 @@ final class Kernel
|
||||
$response = $this->finish($this->crashed($request, $e));
|
||||
}
|
||||
|
||||
// Что-то сделать после каждого ответа, не патча Kernel, — сюда, а не в
|
||||
// прямой вызов внутри этого метода: слушатель регистрируется в
|
||||
// config/events.php, упавший слушатель не портит страницу (см. Events::fire)
|
||||
Events::fire('http.responded', ['request' => $request, 'response' => $response]);
|
||||
|
||||
// Счётчики пишутся после ответа и молча: сорванный подсчёт не повод
|
||||
// портить страницу
|
||||
try {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
@@ -27,6 +27,9 @@ final class View
|
||||
/** @var array<string, mixed> Данные, доступные всем шаблонам */
|
||||
private static array $shared = [];
|
||||
|
||||
/** @var array<string, array<int, string>> Содержимое слотов каркаса */
|
||||
private static array $slots = [];
|
||||
|
||||
/**
|
||||
* Страница внутри общего каркаса.
|
||||
*
|
||||
@@ -99,6 +102,26 @@ final class View
|
||||
self::$shared[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Кладёт разметку в именованное место каркаса (`config/services.php` или
|
||||
* `bootstrap.php` приложения) — доп. стили, свой пункт в шапке — так,
|
||||
* чтобы не переопределять весь `layouts/main.php` целиком ради одной
|
||||
* строки и не расходиться с ним при следующем обновлении ядра. Слот
|
||||
* можно заполнить несколько раз — разметка приложений накапливается.
|
||||
*/
|
||||
public static function fillSlot(string $name, string $content): void
|
||||
{
|
||||
self::$slots[$name][] = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Содержимое слота для шаблона — пусто, если никто его не заполнил.
|
||||
*/
|
||||
public static function slot(string $name): string
|
||||
{
|
||||
return implode('', self::$slots[$name] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Экранирование для вывода в HTML. Всё, что пришло от пользователя,
|
||||
* печатается только через него.
|
||||
|
||||
@@ -629,6 +629,8 @@ $theme = (!$viewer->isGuest() && $viewer->user() !== null) ? $viewer->user()->th
|
||||
.checks .item { flex-direction: column; gap: 2px; }
|
||||
}
|
||||
</style>
|
||||
<?php /* Свои стили поверх ядра — без переопределения этого файла целиком, см. View::fillSlot() */ ?>
|
||||
<?= View::slot('layout.head') ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php if (!$bare && View::isImpersonating()) { ?>
|
||||
@@ -677,6 +679,8 @@ $theme = (!$viewer->isGuest() && $viewer->user() !== null) ? $viewer->user()->th
|
||||
|
||||
<?php if (!$viewer->isGuest()) { ?>
|
||||
<div class="who">
|
||||
<?= View::slot('layout.topbar') ?>
|
||||
|
||||
<a class="muted small" href="<?= View::e(View::route('notifications')) ?>" title="Уведомления">
|
||||
Уведомления<?= $unread > 0 ? ' <span class="badge warn">' . $unread . '</span>' : '' ?>
|
||||
</a>
|
||||
|
||||
Reference in new issue
Block a user