ccman 0.0.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccman",
3
- "version": "0.0.4",
3
+ "version": "1.0.1",
4
4
  "description": "Claude Code Manager - A TypeScript tool to manage Claude Code API configurations",
5
5
  "main": "dist/index.js",
6
6
  "packageManager": "pnpm@8.15.1",
@@ -15,6 +15,7 @@
15
15
  "lint": "eslint src/**/*.ts",
16
16
  "clean": "rm -rf dist",
17
17
  "release": "./scripts/release.sh",
18
+ "release:smart": "./scripts/smart-release-v3.sh",
18
19
  "release:patch": "./scripts/quick-release.sh patch",
19
20
  "release:minor": "./scripts/quick-release.sh minor",
20
21
  "release:major": "./scripts/quick-release.sh major",
@@ -36,11 +37,13 @@
36
37
  "dependencies": {
37
38
  "commander": "^11.0.0",
38
39
  "chalk": "^4.1.2",
39
- "inquirer": "^8.2.6"
40
+ "inquirer": "^8.2.6",
41
+ "fs-extra": "^11.0.0"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@types/node": "^20.0.0",
43
45
  "@types/inquirer": "^9.0.0",
46
+ "@types/fs-extra": "^11.0.0",
44
47
  "typescript": "^5.0.0",
45
48
  "tsx": "^4.0.0",
46
49
  "eslint": "^8.0.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccman",
3
- "version": "0.0.4",
3
+ "version": "1.0.1",
4
4
  "description": "Claude Code Manager - A TypeScript tool to manage Claude Code API configurations",
5
5
  "main": "dist/index.js",
6
6
  "packageManager": "pnpm@8.15.1",
@@ -15,6 +15,7 @@
15
15
  "lint": "eslint src/**/*.ts",
16
16
  "clean": "rm -rf dist",
17
17
  "release": "./scripts/release.sh",
18
+ "release:smart": "./scripts/smart-release-v3.sh",
18
19
  "release:patch": "./scripts/quick-release.sh patch",
19
20
  "release:minor": "./scripts/quick-release.sh minor",
20
21
  "release:major": "./scripts/quick-release.sh major",
@@ -36,11 +37,13 @@
36
37
  "dependencies": {
37
38
  "commander": "^11.0.0",
38
39
  "chalk": "^4.1.2",
39
- "inquirer": "^8.2.6"
40
+ "inquirer": "^8.2.6",
41
+ "fs-extra": "^11.0.0"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@types/node": "^20.0.0",
43
45
  "@types/inquirer": "^9.0.0",
46
+ "@types/fs-extra": "^11.0.0",
44
47
  "typescript": "^5.0.0",
45
48
  "tsx": "^4.0.0",
46
49
  "eslint": "^8.0.0",
@@ -0,0 +1,109 @@
1
+ #!/bin/bash
2
+
3
+ # 脚本1: 检查未提交代码处理模块
4
+ # 功能: 检查工作目录状态,提供智能处理选项
5
+
6
+ set -e
7
+
8
+ # 颜色定义
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ RED='\033[0;31m'
12
+ BLUE='\033[0;34m'
13
+ NC='\033[0m'
14
+
15
+ print_success() { echo -e "${GREEN}✅ $1${NC}"; }
16
+ print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
17
+ print_error() { echo -e "${RED}❌ $1${NC}"; }
18
+ print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
19
+
20
+ # 主函数: 检查并处理未提交代码
21
+ check_uncommitted_changes() {
22
+ print_info "检查工作目录状态..."
23
+
24
+ # 检查是否有未提交的更改
25
+ if git diff-index --quiet HEAD --; then
26
+ print_success "工作目录干净,可以继续"
27
+ return 0
28
+ fi
29
+
30
+ # 发现未提交更改
31
+ print_warning "发现未提交的更改:"
32
+ echo ""
33
+ git status --short
34
+ echo ""
35
+
36
+ # 提供处理选项
37
+ echo "请选择处理方式:"
38
+ echo "1) 提交所有更改并继续"
39
+ echo "2) 暂存所有更改并继续"
40
+ echo "3) 取消操作,手动处理"
41
+ echo ""
42
+
43
+ # 获取用户选择
44
+ read -p "请选择 (1-3): " choice
45
+
46
+ case $choice in
47
+ 1)
48
+ handle_commit_changes
49
+ ;;
50
+ 2)
51
+ handle_stage_changes
52
+ ;;
53
+ 3)
54
+ handle_cancel
55
+ ;;
56
+ *)
57
+ print_error "无效选择,操作已取消"
58
+ exit 1
59
+ ;;
60
+ esac
61
+ }
62
+
63
+ # 处理提交更改
64
+ handle_commit_changes() {
65
+ read -p "请输入提交信息 (回车使用默认): " commit_msg
66
+
67
+ # 使用默认提交信息如果为空
68
+ if [ -z "$commit_msg" ]; then
69
+ commit_msg="chore: 发布前提交未完成更改
70
+
71
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
72
+
73
+ Co-Authored-By: Claude <noreply@anthropic.com>"
74
+ fi
75
+
76
+ print_info "提交所有更改..."
77
+ git add .
78
+ git commit -m "$commit_msg"
79
+ print_success "所有更改已提交"
80
+ }
81
+
82
+ # 处理暂存更改
83
+ handle_stage_changes() {
84
+ print_info "暂存所有更改..."
85
+ git add .
86
+ print_success "所有更改已暂存"
87
+ print_warning "注意: 暂存的更改将在后续提交中包含"
88
+ }
89
+
90
+ # 处理取消操作
91
+ handle_cancel() {
92
+ print_info "操作已取消"
93
+ echo "请手动处理未提交的更改:"
94
+ echo " git add <files> # 暂存特定文件"
95
+ echo " git commit -m '...' # 提交更改"
96
+ echo " git stash # 暂时保存更改"
97
+ echo ""
98
+ echo "处理完成后重新运行发布脚本"
99
+ exit 0
100
+ }
101
+
102
+ # 如果直接运行此脚本
103
+ if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
104
+ echo "🔍 CCM 代码状态检查器"
105
+ echo "====================="
106
+ check_uncommitted_changes
107
+ echo ""
108
+ print_success "代码状态检查完成,可以继续后续操作"
109
+ fi
@@ -0,0 +1,236 @@
1
+ #!/bin/bash
2
+
3
+ # 脚本3: 创建tag和提交模块
4
+ # 功能: 根据package.json版本号创建tag并提交(不进行版本升级)
5
+
6
+ set -e
7
+
8
+ # 颜色定义
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ RED='\033[0;31m'
12
+ BLUE='\033[0;34m'
13
+ NC='\033[0m'
14
+
15
+ print_success() { echo -e "${GREEN}✅ $1${NC}"; }
16
+ print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
17
+ print_error() { echo -e "${RED}❌ $1${NC}"; }
18
+ print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
19
+
20
+ # 获取当前版本号
21
+ get_current_version() {
22
+ if [ ! -f "package.json" ]; then
23
+ print_error "package.json 未找到"
24
+ exit 1
25
+ fi
26
+
27
+ local version=$(node -p "require('./package.json').version" 2>/dev/null || echo "")
28
+ if [ -z "$version" ]; then
29
+ print_error "无法读取package.json中的版本号"
30
+ exit 1
31
+ fi
32
+
33
+ echo "$version"
34
+ }
35
+
36
+ # 检查tag是否已存在
37
+ check_tag_exists() {
38
+ local tag_name=$1
39
+ if git tag -l | grep -q "^$tag_name$"; then
40
+ return 0 # tag存在
41
+ else
42
+ return 1 # tag不存在
43
+ fi
44
+ }
45
+
46
+ # 创建tag
47
+ create_tag() {
48
+ local version=$1
49
+ local tag_name="v$version"
50
+ local force_flag=""
51
+
52
+ print_info "检查tag: $tag_name"
53
+
54
+ if check_tag_exists "$tag_name"; then
55
+ print_warning "tag $tag_name 已存在"
56
+ read -p "是否要重新创建此tag? (y/N): " -n 1 -r
57
+ echo
58
+
59
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
60
+ print_info "删除现有tag: $tag_name"
61
+ git tag -d "$tag_name"
62
+ force_flag="--force"
63
+ else
64
+ print_info "跳过tag创建,使用现有tag"
65
+ echo "$tag_name" # 返回tag名称
66
+ return 0
67
+ fi
68
+ fi
69
+
70
+ # 创建tag
71
+ print_info "创建tag: $tag_name"
72
+ local tag_message="Release v$version
73
+
74
+ 📦 发布版本 v$version
75
+ ⏰ $(date '+%Y-%m-%d %H:%M:%S')
76
+
77
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
78
+
79
+ Co-Authored-By: Claude <noreply@anthropic.com>"
80
+
81
+ git tag -a "$tag_name" -m "$tag_message"
82
+ print_success "tag $tag_name 创建成功"
83
+
84
+ echo "$tag_name" # 返回tag名称
85
+ }
86
+
87
+ # 提交更改(如果有的话)
88
+ commit_changes() {
89
+ local version=$1
90
+ local tag_name=$2
91
+
92
+ print_info "检查是否需要提交更改..."
93
+
94
+ # 检查是否有暂存的更改
95
+ if ! git diff-index --quiet --cached HEAD --; then
96
+ print_info "发现暂存的更改,创建提交..."
97
+
98
+ local commit_message="chore: 发布版本 v$version
99
+
100
+ 🏷️ tag: $tag_name
101
+ ⏰ $(date '+%Y-%m-%d %H:%M:%S')
102
+
103
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
104
+
105
+ Co-Authored-By: Claude <noreply@anthropic.com>"
106
+
107
+ git commit -m "$commit_message"
108
+ print_success "更改已提交"
109
+ return 0
110
+ else
111
+ print_info "没有暂存的更改需要提交"
112
+ return 1
113
+ fi
114
+ }
115
+
116
+ # 推送tag和提交到远程(静默模式)
117
+ push_to_remote_quiet() {
118
+ local tag_name=$1
119
+ local has_commit=$2
120
+
121
+ # 推送提交(如果有)
122
+ if [ "$has_commit" = "true" ]; then
123
+ local current_branch=$(git branch --show-current)
124
+ git push origin "$current_branch" 2>/dev/null
125
+ fi
126
+
127
+ # 推送tag
128
+ git push origin "$tag_name" 2>/dev/null || git push origin "$tag_name" --force 2>/dev/null
129
+ }
130
+
131
+ # 推送tag和提交到远程(交互模式)
132
+ push_to_remote() {
133
+ local tag_name=$1
134
+ local has_commit=$2
135
+
136
+ print_info "推送到远程仓库..."
137
+
138
+ # 推送提交(如果有)
139
+ if [ "$has_commit" = "true" ]; then
140
+ local current_branch=$(git branch --show-current)
141
+ print_info "推送分支: $current_branch"
142
+ git push origin "$current_branch"
143
+ fi
144
+
145
+ # 推送tag
146
+ print_info "推送tag: $tag_name"
147
+ git push origin "$tag_name" 2>/dev/null || git push origin "$tag_name" --force
148
+
149
+ print_success "推送完成,GitHub Actions 已触发"
150
+ }
151
+
152
+ # 静默创建tag并推送(供其他脚本调用)
153
+ create_tag_quietly() {
154
+ # 获取当前版本
155
+ local version=$(get_current_version)
156
+ local tag_name="v$version"
157
+
158
+ # 检查tag是否已存在
159
+ if check_tag_exists "$tag_name"; then
160
+ # 如果tag存在,删除并重新创建
161
+ git tag -d "$tag_name" 2>/dev/null
162
+ git push origin --delete "$tag_name" 2>/dev/null
163
+ fi
164
+
165
+ # 创建tag
166
+ local tag_message="Release v$version
167
+
168
+ 🏷️ CCM版本: v$version
169
+ ⏰ 发布时间: $(date '+%Y-%m-%d %H:%M:%S')
170
+
171
+ 🤖 Generated with [Claude Code](https://claude.ai/code)
172
+
173
+ Co-Authored-By: Claude <noreply@anthropic.com>"
174
+
175
+ git tag -a "$tag_name" -m "$tag_message" 2>/dev/null
176
+
177
+ # 静默推送
178
+ push_to_remote_quiet "$tag_name" "false"
179
+
180
+ # 输出tag名称
181
+ echo "$tag_name"
182
+ }
183
+
184
+ # 主函数: 创建tag并提交(交互模式)
185
+ create_tag_and_commit() {
186
+ echo "🏷️ CCM Tag创建器"
187
+ echo "================"
188
+
189
+ # 获取当前版本
190
+ local version=$(get_current_version)
191
+ print_info "当前版本: v$version"
192
+ echo ""
193
+
194
+ # 确认操作
195
+ read -p "确认为版本 v$version 创建tag并推送? (Y/n): " -n 1 -r
196
+ echo
197
+ if [[ $REPLY =~ ^[Nn]$ ]]; then
198
+ print_warning "操作已取消"
199
+ exit 0
200
+ fi
201
+
202
+ # 创建tag
203
+ local tag_name=$(create_tag "$version")
204
+
205
+ # 提交更改(如果有)
206
+ local has_commit="false"
207
+ if commit_changes "$version" "$tag_name"; then
208
+ has_commit="true"
209
+ fi
210
+
211
+ # 推送到远程
212
+ push_to_remote "$tag_name" "$has_commit"
213
+
214
+ echo ""
215
+ print_success "🎉 Tag创建和推送完成!"
216
+ print_info "📊 相关信息:"
217
+ echo " 版本: v$version"
218
+ echo " Tag: $tag_name"
219
+ echo " GitHub Actions: https://github.com/2ue/ccm/actions"
220
+ echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/$tag_name"
221
+
222
+ # 输出tag名称供其他脚本使用
223
+ echo ""
224
+ echo "TAG_NAME=$tag_name" # 环境变量格式输出
225
+ echo "$tag_name" # 直接输出
226
+ }
227
+
228
+ # 如果直接运行此脚本
229
+ if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
230
+ # 检查是否为静默调用
231
+ if [ "$1" = "--quiet" ]; then
232
+ create_tag_quietly
233
+ else
234
+ create_tag_and_commit "$@"
235
+ fi
236
+ fi
@@ -0,0 +1,268 @@
1
+ #!/bin/bash
2
+
3
+ # 脚本4: 发布状态监控模块
4
+ # 功能: 监控GitHub Actions、NPM发布、GitHub Release状态
5
+
6
+ set -e
7
+
8
+ # 颜色定义
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ RED='\033[0;31m'
12
+ BLUE='\033[0;34m'
13
+ CYAN='\033[0;36m'
14
+ NC='\033[0m'
15
+
16
+ print_success() { echo -e "${GREEN}✅ $1${NC}"; }
17
+ print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
18
+ print_error() { echo -e "${RED}❌ $1${NC}"; }
19
+ print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
20
+ print_check() { echo -e "${CYAN}🔍 $1${NC}"; }
21
+
22
+ # 配置
23
+ REPO_OWNER="2ue"
24
+ REPO_NAME="ccm"
25
+ PACKAGE_NAME="ccman"
26
+ MAX_WAIT_MINUTES=5
27
+ CHECK_INTERVAL=15 # 秒
28
+
29
+ # 获取版本信息
30
+ get_version_info() {
31
+ if [ ! -f "package.json" ]; then
32
+ print_error "package.json 未找到"
33
+ exit 1
34
+ fi
35
+
36
+ local version=$(node -p "require('./package.json').version" 2>/dev/null || echo "")
37
+ if [ -z "$version" ]; then
38
+ print_error "无法读取版本号"
39
+ exit 1
40
+ fi
41
+
42
+ echo "$version"
43
+ }
44
+
45
+ # 获取最新commit ID
46
+ get_latest_commit() {
47
+ git rev-parse HEAD 2>/dev/null || echo "unknown"
48
+ }
49
+
50
+ # 输出监控链接
51
+ show_monitoring_links() {
52
+ local version=$1
53
+ local commit_id=$2
54
+ local tag_name="v$version"
55
+
56
+ print_info "📊 监控链接:"
57
+ echo " 🔗 GitHub Actions: https://github.com/${REPO_OWNER}/${REPO_NAME}/actions"
58
+ echo " 🔗 GitHub Actions (Commit): https://github.com/${REPO_OWNER}/${REPO_NAME}/commit/${commit_id}/checks"
59
+ echo " 🔗 NPM Package: https://www.npmjs.com/package/${PACKAGE_NAME}"
60
+ echo " 🔗 NPM Version: https://www.npmjs.com/package/${PACKAGE_NAME}/v/${version}"
61
+ echo " 🔗 GitHub Releases: https://github.com/${REPO_OWNER}/${REPO_NAME}/releases"
62
+ echo " 🔗 GitHub Release: https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/tag/${tag_name}"
63
+ echo ""
64
+ }
65
+
66
+ # 检查GitHub Actions状态
67
+ check_github_actions() {
68
+ local max_attempts=$((MAX_WAIT_MINUTES * 60 / CHECK_INTERVAL))
69
+ local attempt=0
70
+
71
+ print_check "监控 GitHub Actions 状态..."
72
+
73
+ while [ $attempt -lt $max_attempts ]; do
74
+ # 检查最新的workflow运行状态
75
+ local api_response=$(curl -s "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runs?per_page=1" 2>/dev/null || echo "")
76
+
77
+ if [ -n "$api_response" ]; then
78
+ local run_status=$(echo "$api_response" | grep -o '"status":"[^"]*"' | head -1 | cut -d'"' -f4 2>/dev/null || echo "unknown")
79
+ local run_conclusion=$(echo "$api_response" | grep -o '"conclusion":"[^"]*"' | head -1 | cut -d'"' -f4 2>/dev/null || echo "null")
80
+
81
+ case "$run_status" in
82
+ "completed")
83
+ if [ "$run_conclusion" = "success" ]; then
84
+ print_success "GitHub Actions 构建成功! ✨"
85
+ return 0
86
+ else
87
+ print_error "GitHub Actions 构建失败: $run_conclusion ❌"
88
+ return 1
89
+ fi
90
+ ;;
91
+ "in_progress")
92
+ echo -ne "\r${CYAN}🔄 GitHub Actions 运行中... (${attempt}/${max_attempts}) - 状态: $run_status${NC}"
93
+ ;;
94
+ "queued")
95
+ echo -ne "\r${YELLOW}⏳ GitHub Actions 排队中... (${attempt}/${max_attempts})${NC}"
96
+ ;;
97
+ *)
98
+ echo -ne "\r${YELLOW}⏳ 等待 GitHub Actions 启动... (${attempt}/${max_attempts})${NC}"
99
+ ;;
100
+ esac
101
+ else
102
+ echo -ne "\r${YELLOW}⏳ 连接 GitHub API... (${attempt}/${max_attempts})${NC}"
103
+ fi
104
+
105
+ sleep $CHECK_INTERVAL
106
+ ((attempt++))
107
+ done
108
+
109
+ echo # 换行
110
+ print_warning "GitHub Actions 检查超时 (${MAX_WAIT_MINUTES}分钟)"
111
+ return 2
112
+ }
113
+
114
+ # 检查NPM包发布状态
115
+ check_npm_package() {
116
+ local version=$1
117
+ local max_attempts=$((MAX_WAIT_MINUTES * 60 / CHECK_INTERVAL))
118
+ local attempt=0
119
+
120
+ print_check "监控 NPM 包发布状态..."
121
+
122
+ while [ $attempt -lt $max_attempts ]; do
123
+ # 检查NPM包版本
124
+ local npm_response=$(curl -s "https://registry.npmjs.org/${PACKAGE_NAME}" 2>/dev/null || echo "")
125
+
126
+ if [ -n "$npm_response" ]; then
127
+ # 检查是否包含目标版本
128
+ if echo "$npm_response" | grep -q "\"$version\""; then
129
+ print_success "NPM 包 v$version 发布成功! 📦"
130
+ return 0
131
+ fi
132
+ fi
133
+
134
+ echo -ne "\r${CYAN}📦 等待 NPM 包发布... (${attempt}/${max_attempts})${NC}"
135
+ sleep $CHECK_INTERVAL
136
+ ((attempt++))
137
+ done
138
+
139
+ echo # 换行
140
+ print_warning "NPM 包检查超时 (${MAX_WAIT_MINUTES}分钟)"
141
+ return 2
142
+ }
143
+
144
+ # 检查GitHub Release状态
145
+ check_github_release() {
146
+ local version=$1
147
+ local tag_name="v$version"
148
+ local max_attempts=$((MAX_WAIT_MINUTES * 60 / CHECK_INTERVAL))
149
+ local attempt=0
150
+
151
+ print_check "监控 GitHub Release 状态..."
152
+
153
+ while [ $attempt -lt $max_attempts ]; do
154
+ # 检查GitHub Release
155
+ local release_response=$(curl -s "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/tags/${tag_name}" 2>/dev/null || echo "")
156
+
157
+ if [ -n "$release_response" ] && ! echo "$release_response" | grep -q '"message":"Not Found"'; then
158
+ # 检查release状态
159
+ local release_draft=$(echo "$release_response" | grep -o '"draft":[^,}]*' | cut -d':' -f2 2>/dev/null || echo "true")
160
+
161
+ if [ "$release_draft" = "false" ]; then
162
+ print_success "GitHub Release v$version 创建成功! 🎉"
163
+ return 0
164
+ else
165
+ echo -ne "\r${YELLOW}📝 GitHub Release 为草稿状态... (${attempt}/${max_attempts})${NC}"
166
+ fi
167
+ else
168
+ echo -ne "\r${CYAN}🎯 等待 GitHub Release 创建... (${attempt}/${max_attempts})${NC}"
169
+ fi
170
+
171
+ sleep $CHECK_INTERVAL
172
+ ((attempt++))
173
+ done
174
+
175
+ echo # 换行
176
+ print_warning "GitHub Release 检查超时 (${MAX_WAIT_MINUTES}分钟)"
177
+ return 2
178
+ }
179
+
180
+ # 状态图标映射函数
181
+ get_status_icon() {
182
+ case $1 in
183
+ 0) echo "✅" ;;
184
+ 1) echo "❌" ;;
185
+ 2) echo "⏳" ;;
186
+ *) echo "❓" ;;
187
+ esac
188
+ }
189
+
190
+ # 生成发布总结
191
+ generate_summary() {
192
+ local version=$1
193
+ local actions_status=$2
194
+ local npm_status=$3
195
+ local release_status=$4
196
+
197
+ echo ""
198
+ echo "📋 发布监控总结"
199
+ echo "================"
200
+
201
+ echo " 版本: v$version"
202
+ echo " GitHub Actions: $(get_status_icon $actions_status)"
203
+ echo " NPM 包发布: $(get_status_icon $npm_status)"
204
+ echo " GitHub Release: $(get_status_icon $release_status)"
205
+ echo ""
206
+
207
+ # 整体状态判断
208
+ if [ $actions_status -eq 0 ] && [ $npm_status -eq 0 ] && [ $release_status -eq 0 ]; then
209
+ print_success "🎉 发布完全成功!所有组件都已正常发布"
210
+ return 0
211
+ elif [ $actions_status -eq 1 ]; then
212
+ print_error "❌ 发布失败:GitHub Actions 构建失败"
213
+ return 1
214
+ elif [ $actions_status -eq 2 ] || [ $npm_status -eq 2 ] || [ $release_status -eq 2 ]; then
215
+ print_warning "⏳ 发布可能仍在进行中,建议稍后手动检查"
216
+ return 2
217
+ else
218
+ print_warning "⚠️ 发布部分成功,请检查失败的组件"
219
+ return 3
220
+ fi
221
+ }
222
+
223
+ # 主函数: 监控发布状态
224
+ monitor_release() {
225
+ local version=$(get_version_info)
226
+ local commit_id=$(get_latest_commit)
227
+
228
+ echo "📊 CCM 发布状态监控器"
229
+ echo "===================="
230
+ print_info "版本: v$version"
231
+ print_info "提交: ${commit_id:0:8}"
232
+ print_info "超时: ${MAX_WAIT_MINUTES} 分钟"
233
+ echo ""
234
+
235
+ # 显示监控链接
236
+ show_monitoring_links "$version" "$commit_id"
237
+
238
+ # 检查curl是否可用
239
+ if ! command -v curl &> /dev/null; then
240
+ print_error "curl 未安装,无法进行状态检查"
241
+ print_info "请手动访问上述链接检查发布状态"
242
+ return 1
243
+ fi
244
+
245
+ # 并行监控各个状态
246
+ print_info "开始监控发布状态... (最长等待 ${MAX_WAIT_MINUTES} 分钟)"
247
+ echo ""
248
+
249
+ # 检查GitHub Actions
250
+ check_github_actions
251
+ local actions_status=$?
252
+
253
+ # 检查NPM包发布
254
+ check_npm_package "$version"
255
+ local npm_status=$?
256
+
257
+ # 检查GitHub Release
258
+ check_github_release "$version"
259
+ local release_status=$?
260
+
261
+ # 生成总结报告
262
+ generate_summary "$version" $actions_status $npm_status $release_status
263
+ }
264
+
265
+ # 如果直接运行此脚本
266
+ if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
267
+ monitor_release "$@"
268
+ fi