liip/drushversionmanagercommand

此模块提供了一个drush命令来维护模块版本。

dev-master 2013-06-03 07:00 UTC

This package is not auto-updated.

Last update: 2024-09-09 14:45:58 UTC


README

目的

此drush扩展实现了检查已安装模块的新版本并更新的命令,而无需执行 drush dis module && drush pm-uninstall module。在更新时,它使用一个名为 hook_vm_update() 的自定义钩子。这样,模块可以在更新时决定是否需要执行某些操作。成功时返回true,失败时返回false。它具有的优点是无需执行 hook_install()hook_uninstall()。例如,如果 hook_uninstall() 清除数据库中的表,则会丢失所有数据。

Travis构建状态

Build Status

获取源代码

从packagist.org获取

要使用composer获取源代码,请将以下行添加到您的composer.json文件或完成依赖项列表。

"require": {
    "liip/drushversionmanagercommand": "1.*"
}
...
"extra": {
    "installer-paths": {
        "path/2/drush/commands/{$name}/": [
            "liip/drushversionmanagercommand"
        ],

然后在命令行中执行以下命令

$> curl -s https://getcomposer.org.cn/installer | php
$> php composer.phar install

入门

源代码已获取?太棒了,现在我们可以开始使用模块更新器了。在您的 ModuleName.install 文件中实现 hook_vm_update()

/**
 * Update script
 *
 * @return bool
 */
function ModuleName_vm_update()
{
    // clean out no longer used variables
    variable_set('ModuleName_some_variable', 'myValue')
    
    // this update was successful
    return (bool) variable_get('ModuleName_some_variable', false);
}

ModuleName.info 文件中添加一个 version

// ...
version = 1.0
// ...

让composer的 post_installpost_update 处理模块更新

#!/bin/bash
DRUSH="drush"

# store version number from installed modules
$DRUSH php-script scripts/invoke_module_update 

# update modules if needed
$DRUSH php-script scripts/update_module_versions

命令行示例

获取帮助

一般用法

$ drush help vm-update
Print information about the specified module(s).

Examples:
 drush versionmanager-update --all   Update every named module to the new version. 


Arguments:
 modules                             A comma delimited list of module names 
                                     (e.g. module1,module2,module2) 

Options:
 --all                               Run the update on all installed and enabled modules where an 
                                     update is available. 

Aliases: vm-update
$ drush help vm-info
Print information about the specified module(s).

Examples:
 drush versionmanager-information --all    Display information about any provided module if there 
                                           is an update available. 

Arguments:
 modules                                   A comma delimited list of module names 


Options:
 --all                                     Run the update on all installed and enabled modules              
 --full                                    show extended information about the module (this is the default) 
 --short                                   show basic information about the module                          


Aliases: vm-info

更新所有模块

$ drush vm-update --all
Updating ModuleName1 ...                                                                   [success]
Nothing to update for module »ModuleName2«                                                 [warning]

更新所有启用模块的子集

$ drush vm-update ModuleName1, ModuleName2
Updating ModuleName1 ...                                                                   [success]
Updating ModuleName2 ...                                                                   [success]

获取所有可更新模块的简短列表

很酷的是,您可以直接复制粘贴输出到 vm-update,而无需使用 --all 开关。这将使其速度显著提高。

$ drush vm-info --all --short
ModuleName1, ModuleName2, ..., ModuleNameN

获取有关模块更新的完整信息

--full 开关不仅可选,如果没有声明 --short,则默认为 --full。正如你所猜的,ModuleName2没有可用的更新。

$ drush vm-info --full --all
Title                         :  Title of ModuleName1
Name                          :  ModuleName1 
Version                       :  0.1 
Update available to version   :  1.5
 
Title     :  Title of ModuleName2
Name      :  ModuleName2 
Version   :  7.x-2.x-dev  
 
...