显然,仅使用composer是不可能的。对于安装WP-CLI的推荐方式来说,这似乎有点愚蠢,因为以后没有直接的更新方法。我最终安装了GIT,然后重新安装(例如。git clone https://github.com/wp-cli/wp-cli.git d:\\wp-cli
) wp cli的。之后,发布了composer update --no-dev
安装依赖项。现在在将来更新wp cli I rungit pull origin
来自d:\\wp cli,后跟composer update --no-dev
.
如果这是错误的,请告诉我!:)
编辑--
因此,我意识到上面的命令正在更新为主分支中的最新提交。我找不到任何自动更新到最新分支的方法,所以我编写了以下批处理文件。它从wp cli repo查询所有标记,遍历它们以找到最新的标记(因为它们是按alpha排序的),然后克隆或重置(如果本地repo已经存在)到该标记。然后通过composer更新依赖项。
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
SET WPCLI_INSTALL_DRIVE=D:
SET WPCLI_INSTALL_DIR=WP-CLI
SET LATEST_WPCLI_MAJOR=-1
SET LATEST_WPCLI_MINOR=0
SET LATEST_WPCLI_REV=0
echo.
echo COMMIT_ID - TAG_NAME ^=^> VERSION_DETECTION [*] (* ^= Marked as latest)
for /f "tokens=1*" %%A in (\'git ls-remote --tags https://github.com/wp-cli/wp-cli.git\') do (
SET "TAG_LINE=%%A"
IF NOT "%%B"=="" (
SET "TAG_LINE=!TAG_LINE! - %%B"
for /f "tokens=2 delims=v" %%C in ("%%B") do (
echo "%%C"|find /i ".">nul
IF NOT ERRORLEVEL 1 (
for /f "tokens=1-3 delims=." %%D in ("%%C") do (
SET "TAG_LINE=!TAG_LINE! ^=^> v%%D.%%E.%%F"
SET LATEST_WPCLI_FOUND=0
IF /I %%D GTR !LATEST_WPCLI_MAJOR! (
SET LATEST_WPCLI_FOUND=1
) ELSE (
IF /I %%D GEQ !LATEST_WPCLI_MAJOR! (
IF /I %%E GTR !LATEST_WPCLI_MINOR! (
SET LATEST_WPCLI_FOUND=1
) ELSE (
IF /I %%E GEQ !LATEST_WPCLI_MINOR! (
IF /I %%F GTR !LATEST_WPCLI_REV! (
SET LATEST_WPCLI_FOUND=1
)
)
)
)
)
IF "!LATEST_WPCLI_FOUND!"=="1" (
SET "TAG_LINE=!TAG_LINE! *"
SET LATEST_WPCLI_MAJOR=%%D
SET LATEST_WPCLI_MINOR=%%E
SET LATEST_WPCLI_REV=%%F
)
)
)
)
)
echo !TAG_LINE!
)
echo.
echo.
IF NOT "%LATEST_WPCLI_MAJOR%"=="-1" (
echo Latest detected tag: v%LATEST_WPCLI_MAJOR%.%LATEST_WPCLI_MINOR%.%LATEST_WPCLI_REV%
echo.
IF EXIST "%WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%\\bin\\wp.bat" (
echo Current WP-CLI Version:
call "%WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%\\bin\\wp.bat" cli version
) ELSE (
echo Current "%WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%\\bin\\wp.bat" not found to display current version.
)
echo.
choice /m "Continue installing/updating?"
IF ERRORLEVEL 2 exit /b 0
IF EXIST "%WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%\\.gitignore" (
CHDIR /D "%WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%"
git reset --hard "v%LATEST_WPCLI_MAJOR%.%LATEST_WPCLI_MINOR%.%LATEST_WPCLI_REV%"
) ELSE (
git clone --branch "v%LATEST_WPCLI_MAJOR%.%LATEST_WPCLI_MINOR%.%LATEST_WPCLI_REV%" https://github.com/wp-cli/wp-cli.git %WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%
CHDIR /D "%WPCLI_INSTALL_DRIVE%\\%WPCLI_INSTALL_DIR%"
)
IF EXIST "composer.json" call composer update --no-dev
) ELSE (
echo Latest version not found.
)
pause