From 3bc3ef4ac78dc2155b847f688ac712938eac8204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Wed, 6 May 2026 16:58:47 +0800 Subject: [PATCH] =?UTF-8?q?tool(monitor):=20=E5=88=9B=E5=BB=BA=20antd=20v6?= =?UTF-8?q?=20=E5=8D=87=E7=BA=A7=E5=B0=B1=E7=BB=AA=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 定期检查 antd v6 和 pro-components v3 的 npm 发布状态; 输出详细检查报告并保存状态到 .antd-upgrade-state.json; 建议每周运行一次,当两者均就绪时提示可启动升级。 --- scripts/check-antd-upgrade.sh | 166 ++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100755 scripts/check-antd-upgrade.sh diff --git a/scripts/check-antd-upgrade.sh b/scripts/check-antd-upgrade.sh new file mode 100755 index 0000000..a577a53 --- /dev/null +++ b/scripts/check-antd-upgrade.sh @@ -0,0 +1,166 @@ +#!/usr/bin/env bash +set -euo pipefail + +CHECK_INTERVAL_DAYS=7 +STATE_FILE=".antd-upgrade-state.json" +CURRENT_ANTD="5" +TARGET_ANTD="6" +TARGET_PRO_COMPONENTS="3" + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +log_info() { echo -e "${GREEN}[INFO]${NC} $1"; } +log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } + +check_npm_version() { + local pkg=$1 + local version + version=$(npm view "$pkg" version 2>/dev/null || echo "unknown") + echo "$version" +} + +check_npm_dist_tag() { + local pkg=$1 + local tag=$2 + local version + version=$(npm view "$pkg" dist-tags."$tag" 2>/dev/null || echo "unknown") + echo "$version" +} + +get_major_version() { + local version=$1 + echo "$version" | cut -d. -f1 | sed 's/[^0-9]//g' +} + +is_pro_components_v3_ready() { + local pro_pkgs=( + "@ant-design/pro-components" + "@ant-design/pro-layout" + "@ant-design/pro-table" + "@ant-design/pro-form" + "@ant-design/pro-list" + "@ant-design/pro-descriptions" + ) + + local all_ready=true + for pkg in "${pro_pkgs[@]}"; do + local version + version=$(check_npm_version "$pkg") + local major + major=$(get_major_version "$version") + + if [[ "$major" == "$TARGET_PRO_COMPONENTS" ]]; then + log_info "$pkg: v$version ✅ (v3 已发布)" + elif [[ "$version" == "unknown" ]]; then + log_warn "$pkg: 无法获取版本信息" + all_ready=false + else + log_warn "$pkg: v$version ❌ (当前 v${major},需要 v${TARGET_PRO_COMPONENTS})" + all_ready=false + fi + done + + $all_ready +} + +check_antd_v6_compatibility() { + local antd_version + antd_version=$(check_npm_version "antd") + local major + major=$(get_major_version "$antd_version") + + if [[ "$major" == "$TARGET_ANTD" ]]; then + log_info "antd: v$antd_version ✅ (v6 已正式发布)" + return 0 + else + log_warn "antd: v$antd_version (当前 v${major},目标 v${TARGET_ANTD})" + + local next_version + next_version=$(check_npm_dist_tag "antd" "next") + if [[ "$next_version" != "unknown" ]]; then + local next_major + next_major=$(get_major_version "$next_version") + if [[ "$next_major" == "$TARGET_ANTD" ]]; then + log_info "antd@next: v$next_version (v6 预览版可用)" + fi + fi + return 1 + fi +} + +check_react_compatibility() { + local react_version + react_version=$(check_npm_version "react") + log_info "React: v$react_version" + + local react_major + react_major=$(get_major_version "$react_version") + + if [[ "$react_major" -ge 19 ]]; then + log_info "React v19+ 已发布,antd v5 存在兼容性警告,升级到 antd v6 可解决" + fi +} + +save_state() { + local antd_v="$1" + local pro_v="$2" + local ready="$3" + cat > "$STATE_FILE" <