shalvah / upgrader
为您的软件包创建自动升级。
0.6.0
2024-02-20 11:51 UTC
Requires
- php: >=8.0
- illuminate/support: >=8.0
- nikic/php-parser: ^5.0
Requires (Dev)
- dms/phpunit-arraysubset-asserts: ^0.2.0
- pestphp/pest: ^1.21
- phpstan/phpstan: ^1.0
- spatie/ray: ^1.33
README
当您在配置文件中修改了您的PHP库的新版本时?使用此工具为用户提供自动升级流程。在 Scribe 中实现自动升级,只需运行 php artisan scribe:upgrade
。
为 Upgrader
提供您的新的配置文件样本和用户旧配置文件的路径,它将确定新版本中添加或删除了哪些内容。您还可以指示它移动/重命名某些字段或忽略其他字段。
// Create a CLI `upgrade` command, where you call Upgrader // Relative path to the config file in the user's project $userOldConfigFile = 'config/my_library.php'; // Absolute path to a sample of the new config in your project $sampleNewConfigFile = __DIR__ . '/../../config/my_library.php'; $upgrader = Upgrader::ofConfigFile($userOldConfigFile, $sampleNewConfigFile) ->move('path', 'static.path') ->dontTouch('ip_addresses'); // If this is a dry run, print the expected changes if ($this->option('dry-run')) { $changes = $upgrader->dryRun(); if (empty($changes)) { $this->info("No changes needed! Looks like you're all set."); return; } $this->info('The following changes will be made to your config file:'); foreach ($changes as $change) { $this->info($change["description"]); } return; } // Otherwise, run the upgrade 🚀 $upgrader->upgrade();
Upgrader
- 包含 "dry run" 功能,以便您可以审查预期的更改。
- 将用户的旧配置文件备份到
{$file}.bak
,以便您在需要时恢复。 - 支持点符号表示法作为键
Upgrader 目前处于早期阶段 (0.x),计划增加更多稳健的功能和文档。请在此处了解我是如何构建它的 here。
安装
需要 PHP 8+。
composer require shalvah/upgrader