kylekatarnls/update-helper

更新助手

安装次数: 41,803,843

依赖者: 9

建议者: 0

安全: 0

星标: 1,528

关注者: 4

分支: 10

开放问题: 0

类型:composer-plugin

1.2.1 2020-04-07 20:44 UTC

This package is auto-updated.

Last update: 2024-09-03 17:13:37 UTC


README

允许您向您的库用户显示更新/升级说明。

用法

...
"require": {
    "kylekatarnls/update-helper": "^1"
},
"require-dev": {
    "composer/composer": "^1.2",
},
"extra": {
    "update-helper": "MyNamesapace\\MyUpdateHelper"
},
"scripts": {
    "post-autoload-dump": [
        "UpdateHelper\\UpdateHelper::check"
    ]
},
...
namespace MyNamesapace;

use UpdateHelper\UpdateHelper;
use UpdateHelper\UpdateHelperInterface;

class MyUpdateHelper implements UpdateHelperInterface
{
    public function check(UpdateHelper $helper)
    {
        $helper->write("You're using an obsolete version of my-super-package, consider upgrading to version 2 or greater.");

        if ($helper->hasAsDependency('laravel/framework') && $helper->isDependencyLesserThan('laravel/framework', '5.0.0')) {
            $helper->write("You're using a very old version or Laravel we don't support, please consider upgrading at least to 5.0.0.");
        }

        if ($helper->isInteractive()) {
            if ($helper->getIo()->askConfirmation('Do you want us to upgrade it for you?')) {
                $helper->setDependencyVersions(array(
                    'my-vendor/my-super-package' => '^2.0.0',
                    'laravel/framework' => '^5.0.0', // Skip it if not installed
                ))->update();
            }
        }
    }
}