ccman 2.1.3 → 2.1.5
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/LICENSE +21 -0
- package/README.md +201 -301
- package/README_en.md +294 -0
- package/dist/cli.js +213 -33
- package/dist/cli.js.map +1 -1
- package/dist/config/default-providers.d.ts +34 -0
- package/dist/config/default-providers.d.ts.map +1 -0
- package/dist/config/default-providers.js +96 -0
- package/dist/config/default-providers.js.map +1 -0
- package/dist/config/static-env.d.ts +1 -1
- package/dist/config/static-env.js +1 -1
- package/dist/core/ClaudeConfigManager.d.ts +1 -1
- package/dist/core/ClaudeConfigManager.d.ts.map +1 -1
- package/dist/core/ClaudeConfigManager.js +2 -4
- package/dist/core/ClaudeConfigManager.js.map +1 -1
- package/package.json +24 -3
- package/.editorconfig +0 -15
- package/.env.development +0 -3
- package/.env.production +0 -3
- package/.eslintrc.js +0 -28
- package/.github/workflows/release.yml +0 -99
- package/.prettierrc +0 -10
- package/CLAUDE.md +0 -279
- package/README_zh.md +0 -394
- package/dev-test.sh +0 -40
- package/docs/npm-publish-guide.md +0 -71
- package/docs/release-guide.md +0 -144
- package/docs/scripts-guide.md +0 -221
- package/docs/version-management.md +0 -64
- package/jest.config.js +0 -22
- package/release-temp/README.md +0 -394
- package/release-temp/package.json +0 -61
- package/scripts/build-env.js +0 -75
- package/scripts/modules/check-uncommitted.sh +0 -109
- package/scripts/modules/create-tag.sh +0 -279
- package/scripts/modules/monitor-release.sh +0 -296
- package/scripts/modules/version-bump.sh +0 -262
- package/scripts/publish-local.sh +0 -91
- package/scripts/quick-release.sh +0 -100
- package/scripts/release.sh +0 -430
- package/scripts/smart-release-v3.sh +0 -283
- package/scripts/smart-release.sh +0 -322
- package/src/cli.ts +0 -598
- package/src/commands/lang.ts +0 -105
- package/src/core/CCMConfigManager.ts +0 -259
- package/src/core/ClaudeConfigManager.ts +0 -141
- package/src/i18n/LanguageManager.ts +0 -169
- package/src/i18n/messages.ts +0 -233
- package/src/index.ts +0 -4
- package/src/providers/ProviderManager.ts +0 -412
- package/src/types/index.ts +0 -101
- package/src/utils/env-config.ts +0 -53
- package/src/utils/version.ts +0 -16
- package/tsconfig.json +0 -25
|
@@ -1,279 +0,0 @@
|
|
|
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(静默模式,只返回tag名称)
|
|
47
|
-
create_tag() {
|
|
48
|
-
local version=$1
|
|
49
|
-
local tag_name="v$version"
|
|
50
|
-
local force_flag=""
|
|
51
|
-
|
|
52
|
-
# 静默检查tag是否存在
|
|
53
|
-
if check_tag_exists "$tag_name"; then
|
|
54
|
-
# 静默删除现有tag
|
|
55
|
-
git tag -d "$tag_name" >/dev/null 2>&1
|
|
56
|
-
force_flag="--force"
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
# 静默创建tag
|
|
60
|
-
local tag_message="Release v$version
|
|
61
|
-
|
|
62
|
-
📦 发布版本 v$version
|
|
63
|
-
⏰ $(date '+%Y-%m-%d %H:%M:%S')
|
|
64
|
-
|
|
65
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
66
|
-
|
|
67
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
68
|
-
|
|
69
|
-
git tag -a "$tag_name" -m "$tag_message" >/dev/null 2>&1
|
|
70
|
-
|
|
71
|
-
# 只输出tag名称
|
|
72
|
-
echo "$tag_name"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
# 创建tag(交互模式,带打印信息)
|
|
76
|
-
create_tag_interactive() {
|
|
77
|
-
local version=$1
|
|
78
|
-
local tag_name="v$version"
|
|
79
|
-
|
|
80
|
-
print_info "检查tag: $tag_name"
|
|
81
|
-
|
|
82
|
-
if check_tag_exists "$tag_name"; then
|
|
83
|
-
print_warning "tag $tag_name 已存在"
|
|
84
|
-
read -p "是否要重新创建此tag? (y/N): " -n 1 -r
|
|
85
|
-
echo
|
|
86
|
-
|
|
87
|
-
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
88
|
-
print_info "删除现有tag: $tag_name"
|
|
89
|
-
git tag -d "$tag_name"
|
|
90
|
-
else
|
|
91
|
-
print_info "跳过tag创建,使用现有tag"
|
|
92
|
-
echo "$tag_name" # 返回tag名称
|
|
93
|
-
return 0
|
|
94
|
-
fi
|
|
95
|
-
fi
|
|
96
|
-
|
|
97
|
-
# 创建tag
|
|
98
|
-
print_info "创建tag: $tag_name"
|
|
99
|
-
local tag_message="Release v$version
|
|
100
|
-
|
|
101
|
-
📦 发布版本 v$version
|
|
102
|
-
⏰ $(date '+%Y-%m-%d %H:%M:%S')
|
|
103
|
-
|
|
104
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
105
|
-
|
|
106
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
107
|
-
|
|
108
|
-
git tag -a "$tag_name" -m "$tag_message"
|
|
109
|
-
print_success "tag $tag_name 创建成功"
|
|
110
|
-
|
|
111
|
-
echo "$tag_name" # 返回tag名称
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
# 提交更改(如果有的话)
|
|
115
|
-
commit_changes() {
|
|
116
|
-
local version=$1
|
|
117
|
-
local tag_name=$2
|
|
118
|
-
|
|
119
|
-
print_info "检查是否需要提交更改..."
|
|
120
|
-
|
|
121
|
-
# 检查是否有暂存的更改
|
|
122
|
-
if ! git diff-index --quiet --cached HEAD --; then
|
|
123
|
-
print_info "发现暂存的更改,创建提交..."
|
|
124
|
-
|
|
125
|
-
local commit_message="chore: 发布版本 v$version
|
|
126
|
-
|
|
127
|
-
🏷️ tag: $tag_name
|
|
128
|
-
⏰ $(date '+%Y-%m-%d %H:%M:%S')
|
|
129
|
-
|
|
130
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
131
|
-
|
|
132
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
133
|
-
|
|
134
|
-
git commit -m "$commit_message"
|
|
135
|
-
print_success "更改已提交"
|
|
136
|
-
return 0
|
|
137
|
-
else
|
|
138
|
-
print_info "没有暂存的更改需要提交"
|
|
139
|
-
return 1
|
|
140
|
-
fi
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
# 推送tag和提交到远程(静默模式)
|
|
144
|
-
push_to_remote_quiet() {
|
|
145
|
-
local tag_name=$1
|
|
146
|
-
local has_commit=$2
|
|
147
|
-
|
|
148
|
-
# 推送提交(如果有)
|
|
149
|
-
if [ "$has_commit" = "true" ]; then
|
|
150
|
-
local current_branch=$(git branch --show-current)
|
|
151
|
-
git push origin "$current_branch" >/dev/null 2>&1
|
|
152
|
-
fi
|
|
153
|
-
|
|
154
|
-
# 推送tag
|
|
155
|
-
git push origin "$tag_name" >/dev/null 2>&1 || git push origin "$tag_name" --force >/dev/null 2>&1
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
# 推送tag和提交到远程(交互模式)
|
|
159
|
-
push_to_remote() {
|
|
160
|
-
local tag_name=$1
|
|
161
|
-
local has_commit=$2
|
|
162
|
-
|
|
163
|
-
print_info "推送到远程仓库..."
|
|
164
|
-
|
|
165
|
-
# 推送提交(如果有)
|
|
166
|
-
if [ "$has_commit" = "true" ]; then
|
|
167
|
-
local current_branch=$(git branch --show-current)
|
|
168
|
-
print_info "推送分支: $current_branch"
|
|
169
|
-
git push origin "$current_branch"
|
|
170
|
-
fi
|
|
171
|
-
|
|
172
|
-
# 推送tag
|
|
173
|
-
print_info "推送tag: $tag_name"
|
|
174
|
-
git push origin "$tag_name" 2>/dev/null || git push origin "$tag_name" --force
|
|
175
|
-
|
|
176
|
-
print_success "推送完成,GitHub Actions 已触发"
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
# 静默创建tag并推送(供其他脚本调用)
|
|
180
|
-
create_tag_quietly() {
|
|
181
|
-
# 获取当前版本
|
|
182
|
-
local version=$(get_current_version)
|
|
183
|
-
local tag_name="v$version"
|
|
184
|
-
|
|
185
|
-
# 检查tag是否已存在
|
|
186
|
-
if check_tag_exists "$tag_name"; then
|
|
187
|
-
# 如果tag存在,删除并重新创建
|
|
188
|
-
git tag -d "$tag_name" >/dev/null 2>&1
|
|
189
|
-
git push origin --delete "$tag_name" >/dev/null 2>&1
|
|
190
|
-
fi
|
|
191
|
-
|
|
192
|
-
# 创建tag
|
|
193
|
-
local tag_message="Release v$version
|
|
194
|
-
|
|
195
|
-
🏷️ CCM版本: v$version
|
|
196
|
-
⏰ 发布时间: $(date '+%Y-%m-%d %H:%M:%S')
|
|
197
|
-
|
|
198
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
199
|
-
|
|
200
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
201
|
-
|
|
202
|
-
git tag -a "$tag_name" -m "$tag_message" >/dev/null 2>&1
|
|
203
|
-
|
|
204
|
-
# 静默推送(始终推送当前分支和tag)
|
|
205
|
-
push_to_remote_quiet "$tag_name" "true"
|
|
206
|
-
|
|
207
|
-
# 输出tag名称
|
|
208
|
-
echo "$tag_name"
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
# 主函数: 创建tag并提交(交互模式)
|
|
212
|
-
create_tag_and_commit() {
|
|
213
|
-
echo "🏷️ CCM Tag创建器"
|
|
214
|
-
echo "================"
|
|
215
|
-
|
|
216
|
-
# 获取当前版本
|
|
217
|
-
local version=$(get_current_version)
|
|
218
|
-
print_info "当前版本: v$version"
|
|
219
|
-
echo ""
|
|
220
|
-
|
|
221
|
-
# 确认操作
|
|
222
|
-
read -p "确认为版本 v$version 创建tag并推送? (Y/n): " -n 1 -r
|
|
223
|
-
echo
|
|
224
|
-
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
|
225
|
-
print_warning "操作已取消"
|
|
226
|
-
exit 0
|
|
227
|
-
fi
|
|
228
|
-
|
|
229
|
-
# 创建tag(显示交互信息)
|
|
230
|
-
print_info "检查tag: v$version"
|
|
231
|
-
if check_tag_exists "v$version"; then
|
|
232
|
-
print_warning "tag v$version 已存在"
|
|
233
|
-
read -p "是否要重新创建此tag? (y/N): " -n 1 -r
|
|
234
|
-
echo
|
|
235
|
-
|
|
236
|
-
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
237
|
-
print_info "删除现有tag: v$version"
|
|
238
|
-
git tag -d "v$version"
|
|
239
|
-
else
|
|
240
|
-
print_info "跳过tag创建,使用现有tag"
|
|
241
|
-
fi
|
|
242
|
-
fi
|
|
243
|
-
|
|
244
|
-
print_info "创建tag: v$version"
|
|
245
|
-
local tag_name=$(create_tag "$version")
|
|
246
|
-
print_success "tag $tag_name 创建成功"
|
|
247
|
-
|
|
248
|
-
# 提交更改(如果有)
|
|
249
|
-
local has_commit="false"
|
|
250
|
-
if commit_changes "$version" "$tag_name"; then
|
|
251
|
-
has_commit="true"
|
|
252
|
-
fi
|
|
253
|
-
|
|
254
|
-
# 推送到远程
|
|
255
|
-
push_to_remote "$tag_name" "$has_commit"
|
|
256
|
-
|
|
257
|
-
echo ""
|
|
258
|
-
print_success "🎉 Tag创建和推送完成!"
|
|
259
|
-
print_info "📊 相关信息:"
|
|
260
|
-
echo " 版本: v$version"
|
|
261
|
-
echo " Tag: $tag_name"
|
|
262
|
-
echo " GitHub Actions: https://github.com/2ue/ccm/actions"
|
|
263
|
-
echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/$tag_name"
|
|
264
|
-
|
|
265
|
-
# 输出tag名称供其他脚本使用
|
|
266
|
-
echo ""
|
|
267
|
-
echo "TAG_NAME=$tag_name" # 环境变量格式输出
|
|
268
|
-
echo "$tag_name" # 直接输出
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
# 如果直接运行此脚本
|
|
272
|
-
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
|
273
|
-
# 检查是否为静默调用
|
|
274
|
-
if [ "$1" = "--quiet" ]; then
|
|
275
|
-
create_tag_quietly
|
|
276
|
-
else
|
|
277
|
-
create_tag_and_commit "$@"
|
|
278
|
-
fi
|
|
279
|
-
fi
|
|
@@ -1,296 +0,0 @@
|
|
|
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" ] && ! echo "$api_response" | grep -q '"message"'; 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
|
-
echo # 换行
|
|
84
|
-
if [ "$run_conclusion" = "success" ]; then
|
|
85
|
-
print_success "GitHub Actions 构建成功! ✨"
|
|
86
|
-
return 0
|
|
87
|
-
else
|
|
88
|
-
print_error "GitHub Actions 构建失败: $run_conclusion ❌"
|
|
89
|
-
return 1
|
|
90
|
-
fi
|
|
91
|
-
;;
|
|
92
|
-
"in_progress")
|
|
93
|
-
echo -ne "\r${CYAN}🔄 GitHub Actions 运行中... (${attempt}/${max_attempts}) - 状态: $run_status${NC}"
|
|
94
|
-
;;
|
|
95
|
-
"queued")
|
|
96
|
-
echo -ne "\r${YELLOW}⏳ GitHub Actions 排队中... (${attempt}/${max_attempts})${NC}"
|
|
97
|
-
;;
|
|
98
|
-
*)
|
|
99
|
-
echo -ne "\r${YELLOW}⏳ 等待 GitHub Actions 启动... (${attempt}/${max_attempts})${NC}"
|
|
100
|
-
;;
|
|
101
|
-
esac
|
|
102
|
-
else
|
|
103
|
-
echo -ne "\r${YELLOW}⏳ 连接 GitHub API... (${attempt}/${max_attempts})${NC}"
|
|
104
|
-
fi
|
|
105
|
-
|
|
106
|
-
sleep $CHECK_INTERVAL
|
|
107
|
-
((attempt++))
|
|
108
|
-
done
|
|
109
|
-
|
|
110
|
-
echo # 换行
|
|
111
|
-
print_warning "GitHub Actions 检查超时 (${MAX_WAIT_MINUTES}分钟)"
|
|
112
|
-
return 2
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
# 检查NPM包发布状态
|
|
116
|
-
check_npm_package() {
|
|
117
|
-
local version=$1
|
|
118
|
-
local max_attempts=$((MAX_WAIT_MINUTES * 60 / CHECK_INTERVAL))
|
|
119
|
-
local attempt=0
|
|
120
|
-
|
|
121
|
-
print_check "监控 NPM 包发布状态..."
|
|
122
|
-
|
|
123
|
-
while [ $attempt -lt $max_attempts ]; do
|
|
124
|
-
# 检查NPM包版本
|
|
125
|
-
local npm_response=$(curl -s "https://registry.npmjs.org/${PACKAGE_NAME}" 2>/dev/null || echo "")
|
|
126
|
-
|
|
127
|
-
if [ -n "$npm_response" ]; then
|
|
128
|
-
# 检查是否包含目标版本
|
|
129
|
-
if echo "$npm_response" | grep -q "\"$version\""; then
|
|
130
|
-
print_success "NPM 包 v$version 发布成功! 📦"
|
|
131
|
-
return 0
|
|
132
|
-
fi
|
|
133
|
-
fi
|
|
134
|
-
|
|
135
|
-
echo -ne "\r${CYAN}📦 等待 NPM 包发布... (${attempt}/${max_attempts})${NC}"
|
|
136
|
-
sleep $CHECK_INTERVAL
|
|
137
|
-
((attempt++))
|
|
138
|
-
done
|
|
139
|
-
|
|
140
|
-
echo # 换行
|
|
141
|
-
print_warning "NPM 包检查超时 (${MAX_WAIT_MINUTES}分钟)"
|
|
142
|
-
return 2
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
# 检查GitHub Release状态
|
|
146
|
-
check_github_release() {
|
|
147
|
-
local version=$1
|
|
148
|
-
local tag_name="v$version"
|
|
149
|
-
local max_attempts=$((MAX_WAIT_MINUTES * 60 / CHECK_INTERVAL))
|
|
150
|
-
local attempt=0
|
|
151
|
-
|
|
152
|
-
print_check "监控 GitHub Release 状态..."
|
|
153
|
-
|
|
154
|
-
while [ $attempt -lt $max_attempts ]; do
|
|
155
|
-
# 检查GitHub Release
|
|
156
|
-
local release_response=$(curl -s "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/tags/${tag_name}" 2>/dev/null || echo "")
|
|
157
|
-
|
|
158
|
-
if [ -n "$release_response" ] && ! echo "$release_response" | grep -q '"message":"Not Found"'; then
|
|
159
|
-
# 检查release状态
|
|
160
|
-
local release_draft=$(echo "$release_response" | grep -o '"draft":[^,}]*' | cut -d':' -f2 | tr -d ' ' 2>/dev/null || echo "true")
|
|
161
|
-
|
|
162
|
-
# 调试输出
|
|
163
|
-
# echo "[DEBUG] release_draft = '$release_draft'" >&2
|
|
164
|
-
|
|
165
|
-
if [ "$release_draft" = "false" ]; then
|
|
166
|
-
echo # 换行
|
|
167
|
-
print_success "GitHub Release v$version 创建成功! 🎉"
|
|
168
|
-
return 0
|
|
169
|
-
else
|
|
170
|
-
echo -ne "\r${YELLOW}📝 GitHub Release 为草稿状态... (${attempt}/${max_attempts})${NC}"
|
|
171
|
-
fi
|
|
172
|
-
else
|
|
173
|
-
echo -ne "\r${CYAN}🎯 等待 GitHub Release 创建... (${attempt}/${max_attempts})${NC}"
|
|
174
|
-
fi
|
|
175
|
-
|
|
176
|
-
sleep $CHECK_INTERVAL
|
|
177
|
-
((attempt++))
|
|
178
|
-
done
|
|
179
|
-
|
|
180
|
-
echo # 换行
|
|
181
|
-
print_warning "GitHub Release 检查超时 (${MAX_WAIT_MINUTES}分钟)"
|
|
182
|
-
return 2
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
# 状态图标映射函数
|
|
186
|
-
get_status_icon() {
|
|
187
|
-
case $1 in
|
|
188
|
-
0) echo "✅" ;;
|
|
189
|
-
1) echo "❌" ;;
|
|
190
|
-
2) echo "⏳" ;;
|
|
191
|
-
*) echo "❓" ;;
|
|
192
|
-
esac
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
# 生成发布总结
|
|
196
|
-
generate_summary() {
|
|
197
|
-
local version=$1
|
|
198
|
-
local actions_status=$2
|
|
199
|
-
local npm_status=$3
|
|
200
|
-
local release_status=$4
|
|
201
|
-
|
|
202
|
-
echo ""
|
|
203
|
-
echo "📋 发布监控总结"
|
|
204
|
-
echo "================"
|
|
205
|
-
|
|
206
|
-
echo " 版本: v$version"
|
|
207
|
-
echo " GitHub Actions: $(get_status_icon $actions_status)"
|
|
208
|
-
echo " NPM 包发布: $(get_status_icon $npm_status)"
|
|
209
|
-
echo " GitHub Release: $(get_status_icon $release_status)"
|
|
210
|
-
echo ""
|
|
211
|
-
|
|
212
|
-
# 整体状态判断
|
|
213
|
-
if [ $actions_status -eq 0 ] && [ $npm_status -eq 0 ] && [ $release_status -eq 0 ]; then
|
|
214
|
-
print_success "🎉 发布完全成功!所有组件都已正常发布"
|
|
215
|
-
return 0
|
|
216
|
-
elif [ $actions_status -eq 1 ]; then
|
|
217
|
-
print_error "❌ 发布失败:GitHub Actions 构建失败"
|
|
218
|
-
return 1
|
|
219
|
-
elif [ $actions_status -eq 2 ] || [ $npm_status -eq 2 ] || [ $release_status -eq 2 ]; then
|
|
220
|
-
print_warning "⏳ 发布可能仍在进行中,建议稍后手动检查"
|
|
221
|
-
return 2
|
|
222
|
-
else
|
|
223
|
-
print_warning "⚠️ 发布部分成功,请检查失败的组件"
|
|
224
|
-
return 3
|
|
225
|
-
fi
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
# 主函数: 监控发布状态(只监控NPM和Release)
|
|
229
|
-
monitor_release() {
|
|
230
|
-
local version=$(get_version_info)
|
|
231
|
-
local commit_id=$(get_latest_commit)
|
|
232
|
-
|
|
233
|
-
echo "📊 CCM 发布状态监控器"
|
|
234
|
-
echo "===================="
|
|
235
|
-
print_info "版本: v$version"
|
|
236
|
-
print_info "提交: ${commit_id:0:8}"
|
|
237
|
-
print_info "超时: ${MAX_WAIT_MINUTES} 分钟"
|
|
238
|
-
echo ""
|
|
239
|
-
|
|
240
|
-
# 显示监控链接(只显示需要的)
|
|
241
|
-
print_info "📊 监控链接:"
|
|
242
|
-
echo " 🔗 NPM Package: https://www.npmjs.com/package/${PACKAGE_NAME}"
|
|
243
|
-
echo " 🔗 NPM Version: https://www.npmjs.com/package/${PACKAGE_NAME}/v/${version}"
|
|
244
|
-
echo " 🔗 GitHub Release: https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/tag/v${version}"
|
|
245
|
-
echo ""
|
|
246
|
-
|
|
247
|
-
# 检查curl是否可用
|
|
248
|
-
if ! command -v curl &> /dev/null; then
|
|
249
|
-
print_error "curl 未安装,无法进行状态检查"
|
|
250
|
-
print_info "请手动访问上述链接检查发布状态"
|
|
251
|
-
return 1
|
|
252
|
-
fi
|
|
253
|
-
|
|
254
|
-
print_info "开始监控发布状态... (最长等待 ${MAX_WAIT_MINUTES} 分钟)"
|
|
255
|
-
echo ""
|
|
256
|
-
|
|
257
|
-
# 检查NPM包发布
|
|
258
|
-
check_npm_package "$version"
|
|
259
|
-
local npm_status=$?
|
|
260
|
-
|
|
261
|
-
# 检查GitHub Release
|
|
262
|
-
check_github_release "$version"
|
|
263
|
-
local release_status=$?
|
|
264
|
-
|
|
265
|
-
# 生成总结报告
|
|
266
|
-
echo ""
|
|
267
|
-
echo "📋 发布监控总结"
|
|
268
|
-
echo "================"
|
|
269
|
-
echo " 版本: v$version"
|
|
270
|
-
echo " NPM 包发布: $(get_status_icon $npm_status)"
|
|
271
|
-
echo " GitHub Release: $(get_status_icon $release_status)"
|
|
272
|
-
echo ""
|
|
273
|
-
|
|
274
|
-
# 结果判断
|
|
275
|
-
if [ $npm_status -eq 0 ] && [ $release_status -eq 0 ]; then
|
|
276
|
-
print_success "🎉 发布完成!NPM包和GitHub Release都已正常发布"
|
|
277
|
-
return 0
|
|
278
|
-
elif [ $npm_status -eq 2 ] || [ $release_status -eq 2 ]; then
|
|
279
|
-
print_warning "⚠️ 发布监控超时 (${MAX_WAIT_MINUTES}分钟),请手动检查:"
|
|
280
|
-
if [ $npm_status -eq 2 ]; then
|
|
281
|
-
echo " • NPM包状态: https://www.npmjs.com/package/${PACKAGE_NAME}/v/${version}"
|
|
282
|
-
fi
|
|
283
|
-
if [ $release_status -eq 2 ]; then
|
|
284
|
-
echo " • GitHub Release: https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/tag/v${version}"
|
|
285
|
-
fi
|
|
286
|
-
return 2
|
|
287
|
-
else
|
|
288
|
-
print_warning "⚠️ 发布部分失败,请手动检查上述链接"
|
|
289
|
-
return 1
|
|
290
|
-
fi
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
# 如果直接运行此脚本
|
|
294
|
-
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
|
295
|
-
monitor_release "$@"
|
|
296
|
-
fi
|