You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iTi-System/scripts/iti-system.cmd

78 lines
1.6 KiB
Batchfile

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@echo off
setlocal enabledelayedexpansion
set "SCRIPT_DIR=%~dp0"
set "ROOT_DIR=%SCRIPT_DIR%.."
pushd "%ROOT_DIR%" >nul
set "ROOT_DIR=%CD%"
set "PROJECT_VENV=%ROOT_DIR%\.venv"
if defined VIRTUAL_ENV (
if /I not "%VIRTUAL_ENV%"=="%PROJECT_VENV%" (
if /I not "%VIRTUAL_ENV%"=="%PROJECT_VENV%\" set "VIRTUAL_ENV="
)
)
set "COMMAND=%~1"
if "%COMMAND%"=="" set "COMMAND=help"
shift /1
if "%COMMAND%"=="help" goto help
if "%COMMAND%"=="-h" goto help
if "%COMMAND%"=="--help" goto help
if "%COMMAND%"=="install" goto install
if "%COMMAND%"=="test" goto test
if "%COMMAND%"=="release" goto release
echo 未知命令:%COMMAND% 1>&2
echo. 1>&2
goto help_error
:help
echo iTi-System 开发脚本
echo.
echo 用法:
echo iti-system.cmd ^<命令^> [参数]
echo.
echo 常用命令:
echo help 显示帮助
echo install 安装开发依赖uv sync --extra dev
echo test 运行测试uv run pytest -q
echo release [版本] 发布系统包:测试、改版本、提交、打 tag、推送
popd >nul
exit /b 0
:help_error
call :help
exit /b 2
:install
uv sync --extra dev
goto end
:test
uv run pytest -q
goto end
:release
set "SHELL_CMD="
where sh >nul 2>nul && set "SHELL_CMD=sh"
if not defined SHELL_CMD (
where bash >nul 2>nul && set "SHELL_CMD=bash"
)
if not defined SHELL_CMD (
echo 找不到 sh 或 bash无法运行 release 脚本 1>&2
exit /b 1
)
if "%~1"=="" (
"%SHELL_CMD%" scripts/release.sh
) else (
"%SHELL_CMD%" scripts/release.sh %*
)
goto end
:end
set "EXIT_CODE=%ERRORLEVEL%"
popd >nul
exit /b %EXIT_CODE%