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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +201 -301
  3. package/README_en.md +294 -0
  4. package/dist/cli.js +213 -33
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config/default-providers.d.ts +34 -0
  7. package/dist/config/default-providers.d.ts.map +1 -0
  8. package/dist/config/default-providers.js +96 -0
  9. package/dist/config/default-providers.js.map +1 -0
  10. package/dist/config/static-env.d.ts +1 -1
  11. package/dist/config/static-env.js +1 -1
  12. package/dist/core/ClaudeConfigManager.d.ts +1 -1
  13. package/dist/core/ClaudeConfigManager.d.ts.map +1 -1
  14. package/dist/core/ClaudeConfigManager.js +2 -4
  15. package/dist/core/ClaudeConfigManager.js.map +1 -1
  16. package/package.json +24 -3
  17. package/.editorconfig +0 -15
  18. package/.env.development +0 -3
  19. package/.env.production +0 -3
  20. package/.eslintrc.js +0 -28
  21. package/.github/workflows/release.yml +0 -99
  22. package/.prettierrc +0 -10
  23. package/CLAUDE.md +0 -279
  24. package/README_zh.md +0 -394
  25. package/dev-test.sh +0 -40
  26. package/docs/npm-publish-guide.md +0 -71
  27. package/docs/release-guide.md +0 -144
  28. package/docs/scripts-guide.md +0 -221
  29. package/docs/version-management.md +0 -64
  30. package/jest.config.js +0 -22
  31. package/release-temp/README.md +0 -394
  32. package/release-temp/package.json +0 -61
  33. package/scripts/build-env.js +0 -75
  34. package/scripts/modules/check-uncommitted.sh +0 -109
  35. package/scripts/modules/create-tag.sh +0 -279
  36. package/scripts/modules/monitor-release.sh +0 -296
  37. package/scripts/modules/version-bump.sh +0 -262
  38. package/scripts/publish-local.sh +0 -91
  39. package/scripts/quick-release.sh +0 -100
  40. package/scripts/release.sh +0 -430
  41. package/scripts/smart-release-v3.sh +0 -283
  42. package/scripts/smart-release.sh +0 -322
  43. package/src/cli.ts +0 -598
  44. package/src/commands/lang.ts +0 -105
  45. package/src/core/CCMConfigManager.ts +0 -259
  46. package/src/core/ClaudeConfigManager.ts +0 -141
  47. package/src/i18n/LanguageManager.ts +0 -169
  48. package/src/i18n/messages.ts +0 -233
  49. package/src/index.ts +0 -4
  50. package/src/providers/ProviderManager.ts +0 -412
  51. package/src/types/index.ts +0 -101
  52. package/src/utils/env-config.ts +0 -53
  53. package/src/utils/version.ts +0 -16
  54. package/tsconfig.json +0 -25
@@ -1,430 +0,0 @@
1
- #!/bin/bash
2
-
3
- # CCM Release Script
4
- # 自动化版本管理和发布流程
5
-
6
- set -e # 遇到错误立即退出
7
-
8
- # 颜色输出
9
- RED='\033[0;31m'
10
- GREEN='\033[0;32m'
11
- YELLOW='\033[1;33m'
12
- BLUE='\033[0;34m'
13
- NC='\033[0m' # No Color
14
-
15
- # 打印彩色消息
16
- print_message() {
17
- local color=$1
18
- local message=$2
19
- echo -e "${color}${message}${NC}"
20
- }
21
-
22
- print_success() {
23
- print_message $GREEN "✅ $1"
24
- }
25
-
26
- print_warning() {
27
- print_message $YELLOW "⚠️ $1"
28
- }
29
-
30
- print_error() {
31
- print_message $RED "❌ $1"
32
- }
33
-
34
- print_info() {
35
- print_message $BLUE "ℹ️ $1"
36
- }
37
-
38
- # 检查必要的工具
39
- check_prerequisites() {
40
- print_info "检查前置条件..."
41
-
42
- if ! command -v git &> /dev/null; then
43
- print_error "Git 未安装"
44
- exit 1
45
- fi
46
-
47
- if ! command -v node &> /dev/null; then
48
- print_error "Node.js 未安装"
49
- exit 1
50
- fi
51
-
52
- if ! command -v pnpm &> /dev/null; then
53
- print_error "pnpm 未安装,请运行: npm install -g pnpm"
54
- exit 1
55
- fi
56
-
57
- # 检查是否在 git 仓库中
58
- if ! git rev-parse --git-dir > /dev/null 2>&1; then
59
- print_error "当前目录不是 Git 仓库"
60
- exit 1
61
- fi
62
-
63
- print_success "前置条件检查通过"
64
- }
65
-
66
- # 检查工作目录状态
67
- check_working_directory() {
68
- print_info "检查工作目录状态..."
69
-
70
- # 检查是否有未提交的更改
71
- if ! git diff-index --quiet HEAD --; then
72
- print_error "工作目录有未提交的更改,请先提交或暂存"
73
- git status --short
74
- exit 1
75
- fi
76
-
77
- # 检查当前分支
78
- current_branch=$(git branch --show-current)
79
- if [ "$current_branch" != "main" ] && [ "$current_branch" != "master" ]; then
80
- print_warning "当前不在主分支 ($current_branch),是否继续?"
81
- read -p "继续 (y/N): " -n 1 -r
82
- echo
83
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
84
- exit 1
85
- fi
86
- fi
87
-
88
- print_success "工作目录状态正常"
89
- }
90
-
91
- # 获取当前版本
92
- get_current_version() {
93
- current_version=$(node -p "require('./package.json').version")
94
- print_info "当前版本: $current_version"
95
- }
96
-
97
- # 选择版本类型
98
- select_version_type() {
99
- print_info "当前版本: $current_version"
100
-
101
- # 获取建议的版本类型(基于 git 历史分析)
102
- local suggested_type="patch"
103
- local commits=$(git log --oneline -10 2>/dev/null | tr '[:upper:]' '[:lower:]' || echo "")
104
-
105
- if [[ $commits == *"breaking"* ]] || [[ $commits == *"major"* ]]; then
106
- suggested_type="major"
107
- elif [[ $commits == *"feat"* ]] || [[ $commits == *"feature"* ]] || [[ $commits == *"add"* ]]; then
108
- suggested_type="minor"
109
- fi
110
-
111
- # 计算各种版本预览
112
- local patch_version=$(pnpm version patch --dry-run 2>/dev/null | cut -d'v' -f2 2>/dev/null || echo "计算失败")
113
- local minor_version=$(pnpm version minor --dry-run 2>/dev/null | cut -d'v' -f2 2>/dev/null || echo "计算失败")
114
- local major_version=$(pnpm version major --dry-run 2>/dev/null | cut -d'v' -f2 2>/dev/null || echo "计算失败")
115
- local beta_version=$(pnpm version prerelease --preid=beta --dry-run 2>/dev/null | cut -d'v' -f2 2>/dev/null || echo "计算失败")
116
-
117
- echo ""
118
- print_info "📦 版本升级选项:"
119
- echo ""
120
-
121
- local marker1=" "
122
- local marker2=" "
123
- local marker3=" "
124
- local marker4=" "
125
-
126
- # 标记建议的选项
127
- case $suggested_type in
128
- "patch") marker1="✨ [推荐] " ;;
129
- "minor") marker2="✨ [推荐] " ;;
130
- "major") marker3="✨ [推荐] " ;;
131
- esac
132
-
133
- echo "${marker1}1) 🔧 patch (修订版本) $current_version → $patch_version"
134
- echo " └─ 适用于:bug 修复、小改进"
135
- echo ""
136
- echo "${marker2}2) ✨ minor (次版本) $current_version → $minor_version"
137
- echo " └─ 适用于:新功能、向后兼容的改动"
138
- echo ""
139
- echo "${marker3}3) 🚀 major (主版本) $current_version → $major_version"
140
- echo " └─ 适用于:破坏性更改、重大重构"
141
- echo ""
142
- echo "${marker4}4) 🧪 prerelease (预发布) $current_version → $beta_version"
143
- echo " └─ 适用于:测试版本、预发布"
144
- echo ""
145
- echo " 5) 📝 custom (自定义版本)"
146
- echo " └─ 手动输入版本号"
147
- echo ""
148
-
149
- # 显示建议原因
150
- case $suggested_type in
151
- "major")
152
- print_warning "💡 检测到破坏性更改提交,建议使用主版本升级"
153
- ;;
154
- "minor")
155
- print_warning "💡 检测到新功能提交,建议使用次版本升级"
156
- ;;
157
- "patch")
158
- print_info "💡 建议使用修订版本升级"
159
- ;;
160
- esac
161
-
162
- echo ""
163
- read -p "请选择版本类型 (1-5, 回车默认选择推荐项): " version_choice
164
-
165
- # 如果用户直接回车,使用推荐的选项
166
- if [[ -z "$version_choice" ]]; then
167
- case $suggested_type in
168
- "patch") version_choice=1 ;;
169
- "minor") version_choice=2 ;;
170
- "major") version_choice=3 ;;
171
- esac
172
- print_info "使用推荐选项: $suggested_type"
173
- fi
174
-
175
- case $version_choice in
176
- 1)
177
- version_type="patch"
178
- print_success "选择: 修订版本 ($current_version → $patch_version)"
179
- ;;
180
- 2)
181
- version_type="minor"
182
- print_success "选择: 次版本 ($current_version → $minor_version)"
183
- ;;
184
- 3)
185
- version_type="major"
186
- print_success "选择: 主版本 ($current_version → $major_version)"
187
- ;;
188
- 4)
189
- version_type="prerelease"
190
- version_args="--preid=beta"
191
- print_success "选择: 预发布版本 ($current_version → $beta_version)"
192
- ;;
193
- 5)
194
- echo ""
195
- read -p "输入自定义版本号 (格式: x.y.z 或 x.y.z-tag): " custom_version
196
- if [[ ! $custom_version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[0-9]+)?)?$ ]]; then
197
- print_error "版本号格式不正确,应为 x.y.z 或 x.y.z-tag 格式"
198
- exit 1
199
- fi
200
- version_type="$custom_version"
201
- print_success "选择: 自定义版本 ($current_version → $custom_version)"
202
- ;;
203
- *)
204
- print_error "无效选择,请重新运行脚本"
205
- exit 1
206
- ;;
207
- esac
208
-
209
- echo ""
210
- read -p "确认进行版本升级? (Y/n): " -n 1 -r
211
- echo
212
- if [[ $REPLY =~ ^[Nn]$ ]]; then
213
- print_warning "已取消版本升级"
214
- exit 0
215
- fi
216
- }
217
-
218
- # 创建发布分支
219
- create_release_branch() {
220
- # 获取新版本号用于分支名
221
- if [ "$version_type" = "patch" ] || [ "$version_type" = "minor" ] || [ "$version_type" = "major" ] || [ "$version_type" = "prerelease" ]; then
222
- new_version=$(pnpm version $version_type --dry-run $version_args | cut -d'v' -f2)
223
- else
224
- new_version="$version_type"
225
- fi
226
-
227
- release_branch="release/v$new_version"
228
-
229
- print_info "创建发布分支: $release_branch"
230
-
231
- # 确保从最新的主分支创建
232
- git fetch origin
233
- git checkout main 2>/dev/null || git checkout master 2>/dev/null
234
- git pull origin $(git branch --show-current)
235
-
236
- # 创建并切换到发布分支
237
- git checkout -b "$release_branch"
238
-
239
- print_success "发布分支创建成功: $release_branch"
240
- }
241
-
242
- # 更新版本号
243
- update_version() {
244
- print_info "更新版本号..."
245
-
246
- # 更新 package.json 中的版本
247
- if [ "$version_type" = "patch" ] || [ "$version_type" = "minor" ] || [ "$version_type" = "major" ] || [ "$version_type" = "prerelease" ]; then
248
- new_version=$(pnpm version $version_type --no-git-tag-version $version_args)
249
- new_version=${new_version#v} # 移除前面的 v
250
- else
251
- # 自定义版本
252
- pnpm version $version_type --no-git-tag-version
253
- new_version="$version_type"
254
- fi
255
-
256
- print_success "版本已更新到: $new_version"
257
- }
258
-
259
- # 运行构建和测试
260
- run_build_and_test() {
261
- print_info "运行构建和测试..."
262
-
263
- # 安装依赖
264
- pnpm install
265
-
266
- # 运行 lint
267
- if pnpm run lint > /dev/null 2>&1; then
268
- print_success "代码检查通过"
269
- else
270
- print_error "代码检查失败"
271
- exit 1
272
- fi
273
-
274
- # 运行构建
275
- pnpm run build
276
- print_success "构建成功"
277
-
278
- # 运行测试(如果存在)
279
- if pnpm run test > /dev/null 2>&1; then
280
- print_success "测试通过"
281
- else
282
- print_warning "测试脚本不存在或失败,跳过测试"
283
- fi
284
- }
285
-
286
- # 生成更新日志
287
- generate_changelog() {
288
- print_info "生成提交信息..."
289
-
290
- # 获取自上次版本以来的提交
291
- last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
292
-
293
- if [ -n "$last_tag" ]; then
294
- commits=$(git log $last_tag..HEAD --oneline --pretty=format:"- %s (%h)")
295
- if [ -n "$commits" ]; then
296
- changelog="自 $last_tag 以来的更改:\n$commits"
297
- else
298
- changelog="版本升级到 v$new_version"
299
- fi
300
- else
301
- changelog="初始版本 v$new_version"
302
- fi
303
-
304
- commit_message="chore: 发布版本 v$new_version
305
-
306
- $changelog
307
-
308
- 🚀 通过 release script 自动生成"
309
- }
310
-
311
- # 提交更改
312
- commit_changes() {
313
- print_info "提交版本更改..."
314
-
315
- # 添加更改的文件
316
- git add package.json package-lock.json 2>/dev/null || git add package.json
317
- git add src/cli.ts # CLI 中的版本号可能需要更新
318
-
319
- # 提交
320
- git commit -m "$commit_message"
321
-
322
- print_success "版本更改已提交"
323
- }
324
-
325
- # 创建并推送标签
326
- create_and_push_tag() {
327
- tag_name="v$new_version"
328
-
329
- print_info "创建标签: $tag_name"
330
-
331
- # 创建带注释的标签
332
- tag_message="CCM (Claude Code Manager) v$new_version
333
-
334
- 📦 发布版本 v$new_version
335
-
336
- $changelog
337
-
338
- ---
339
- 🤖 通过 release script 自动生成
340
- ⏰ 发布时间: $(date '+%Y-%m-%d %H:%M:%S')
341
- 🔗 GitHub: https://github.com/2ue/ccm"
342
-
343
- git tag -a "$tag_name" -m "$tag_message"
344
-
345
- print_success "标签创建成功: $tag_name"
346
- }
347
-
348
- # 推送到远程仓库
349
- push_to_remote() {
350
- print_info "推送到远程仓库..."
351
-
352
- # 推送分支
353
- git push origin "$release_branch"
354
- print_success "发布分支已推送"
355
-
356
- # 推送标签
357
- git push origin "$tag_name"
358
- print_success "标签已推送"
359
-
360
- print_info "GitHub Actions 将自动开始构建和发布流程"
361
- print_info "查看进度: https://github.com/2ue/ccm/actions"
362
- }
363
-
364
- # 清理和完成
365
- cleanup_and_finish() {
366
- print_info "清理工作..."
367
-
368
- # 切回主分支
369
- main_branch=$(git branch --show-current | grep -E "^(main|master)$" || echo "main")
370
- git checkout $main_branch 2>/dev/null || git checkout master 2>/dev/null
371
-
372
- # 询问是否删除发布分支
373
- print_info "发布分支 $release_branch 已完成使命"
374
- read -p "删除本地发布分支? (Y/n): " -n 1 -r
375
- echo
376
- if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
377
- git branch -D "$release_branch"
378
- print_success "本地发布分支已删除"
379
- fi
380
- }
381
-
382
- # 显示发布总结
383
- show_release_summary() {
384
- echo ""
385
- print_success "🎉 发布流程完成!"
386
- echo ""
387
- print_info "📋 发布总结:"
388
- echo " 版本: v$new_version"
389
- echo " 标签: $tag_name"
390
- echo " 分支: $release_branch"
391
- echo ""
392
- print_info "🔗 相关链接:"
393
- echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/$tag_name"
394
- echo " GitHub Actions: https://github.com/2ue/ccm/actions"
395
- echo " NPM 包 (稍后发布): https://www.npmjs.com/package/ccman"
396
- echo ""
397
- print_info "📦 安装命令 (发布完成后):"
398
- echo " npm install -g ccman@$new_version"
399
- echo ""
400
- }
401
-
402
- # 主函数
403
- main() {
404
- print_info "🚀 CCM Release Script v1.0"
405
- print_info "==============================="
406
- echo ""
407
-
408
- # 执行发布流程
409
- check_prerequisites
410
- check_working_directory
411
- get_current_version
412
- select_version_type
413
- create_release_branch
414
- update_version
415
- run_build_and_test
416
- generate_changelog
417
- commit_changes
418
- create_and_push_tag
419
- push_to_remote
420
- cleanup_and_finish
421
- show_release_summary
422
-
423
- print_success "发布脚本执行完成!请查看 GitHub Actions 进行最终发布。"
424
- }
425
-
426
- # 错误处理
427
- trap 'print_error "发布过程中出现错误,请检查输出信息"; exit 1' ERR
428
-
429
- # 运行主函数
430
- main "$@"
@@ -1,283 +0,0 @@
1
- #!/bin/bash
2
-
3
- # CCM 智能发布脚本 v3.0 (模块化重构版)
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
- PURPLE='\033[0;35m'
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}"; exit 1; }
19
- print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
20
- print_step() { echo -e "${PURPLE}🔸 $1${NC}"; }
21
-
22
- # 脚本路径配置
23
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24
- MODULE_DIR="$SCRIPT_DIR/modules"
25
-
26
- # 检查模块脚本是否存在
27
- check_modules() {
28
- local modules=(
29
- "check-uncommitted.sh"
30
- "version-bump.sh"
31
- "create-tag.sh"
32
- "monitor-release.sh"
33
- )
34
-
35
- for module in "${modules[@]}"; do
36
- if [ ! -f "$MODULE_DIR/$module" ]; then
37
- print_error "模块脚本不存在: $MODULE_DIR/$module"
38
- fi
39
-
40
- if [ ! -x "$MODULE_DIR/$module" ]; then
41
- chmod +x "$MODULE_DIR/$module"
42
- fi
43
- done
44
- }
45
-
46
- # 显示帮助信息
47
- show_help() {
48
- echo "🚀 CCM 智能发布脚本 v3.0"
49
- echo "========================="
50
- echo ""
51
- echo "用法: $0 [选项]"
52
- echo ""
53
- echo "选项:"
54
- echo " --skip-version 跳过版本升级,直接使用当前版本"
55
- echo " --version-type 指定版本类型 (patch|minor|major)"
56
- echo " --no-monitor 跳过发布状态监控"
57
- echo " -h, --help 显示此帮助信息"
58
- echo ""
59
- echo "示例:"
60
- echo " $0 # 完整智能发布流程"
61
- echo " $0 --skip-version # 跳过版本升级"
62
- echo " $0 --version-type minor # 直接使用minor升级"
63
- echo " $0 --no-monitor # 不监控发布状态"
64
- echo ""
65
- }
66
-
67
- # 解析命令行参数
68
- parse_arguments() {
69
- SKIP_VERSION=false
70
- VERSION_TYPE=""
71
- NO_MONITOR=false
72
-
73
- while [[ $# -gt 0 ]]; do
74
- case $1 in
75
- --skip-version)
76
- SKIP_VERSION=true
77
- shift
78
- ;;
79
- --version-type)
80
- VERSION_TYPE="$2"
81
- shift 2
82
- ;;
83
- --no-monitor)
84
- NO_MONITOR=true
85
- shift
86
- ;;
87
- -h|--help)
88
- show_help
89
- exit 0
90
- ;;
91
- *)
92
- print_error "未知参数: $1"
93
- ;;
94
- esac
95
- done
96
- }
97
-
98
- # 步骤1: 检查未提交代码
99
- step_check_uncommitted() {
100
- print_step "步骤 1/4: 检查工作目录状态"
101
- echo ""
102
-
103
- # 调用模块脚本
104
- source "$MODULE_DIR/check-uncommitted.sh"
105
- check_uncommitted_changes
106
-
107
- echo ""
108
- print_success "步骤1完成: 工作目录状态正常"
109
- }
110
-
111
- # 步骤2: 版本升级
112
- step_version_bump() {
113
- print_step "步骤 2/4: 版本管理"
114
- echo ""
115
-
116
- if [ "$SKIP_VERSION" = true ]; then
117
- print_info "跳过版本升级,使用当前版本"
118
- local current_version=$(node -p "require('./package.json').version")
119
- print_info "当前版本: v$current_version"
120
- NEW_VERSION="$current_version"
121
- else
122
- print_info "启动版本升级流程..."
123
- # 如果指定了版本类型,静默调用
124
- if [ -n "$VERSION_TYPE" ]; then
125
- # 使用source方式调用,然后直接调用静默函数
126
- source "$MODULE_DIR/version-bump.sh"
127
- NEW_VERSION=$(execute_version_bump_quiet "$VERSION_TYPE" "$(get_current_version)")
128
- if [ -z "$NEW_VERSION" ]; then
129
- print_error "版本升级失败"
130
- fi
131
- else
132
- # 没有指定版本类型,调用交互模式
133
- "$MODULE_DIR/version-bump.sh"
134
- local version_result=$?
135
- if [ $version_result -eq 0 ]; then
136
- NEW_VERSION=$(node -p "require('./package.json').version")
137
- else
138
- print_error "版本升级失败"
139
- fi
140
- fi
141
- print_success "版本升级成功: v$NEW_VERSION"
142
- fi
143
-
144
- echo ""
145
- print_success "步骤2完成: 版本为 v$NEW_VERSION"
146
- }
147
-
148
- # 步骤3: 创建tag和提交
149
- step_create_tag() {
150
- print_step "步骤 3/4: 创建tag和提交"
151
- echo ""
152
-
153
- print_info "将为版本 v$NEW_VERSION 创建tag并提交..."
154
- echo ""
155
-
156
- # 静默调用tag创建模块,避免颜色代码泄露
157
- TAG_NAME=$("$MODULE_DIR/create-tag.sh" --quiet)
158
- if [ -z "$TAG_NAME" ]; then
159
- print_error "tag创建失败"
160
- fi
161
-
162
- echo ""
163
- print_success "步骤3完成: tag $TAG_NAME 已创建并推送"
164
- print_info "GitHub Actions 已自动触发"
165
- }
166
-
167
- # 步骤4: 监控发布状态
168
- step_monitor_release() {
169
- print_step "步骤 4/4: 监控发布状态"
170
- echo ""
171
-
172
- if [ "$NO_MONITOR" = true ]; then
173
- print_info "跳过发布状态监控"
174
- print_info "请手动检查:"
175
- echo " 🔗 GitHub Actions: https://github.com/2ue/ccm/actions"
176
- echo " 🔗 NPM Package: https://www.npmjs.com/package/ccman"
177
- echo " 🔗 GitHub Release: https://github.com/2ue/ccm/releases/tag/v$NEW_VERSION"
178
- return 0
179
- fi
180
-
181
- # 给GitHub Actions一些时间启动
182
- print_info "等待 GitHub Actions 启动... (10秒)"
183
- sleep 10
184
-
185
- # 直接执行监控模块
186
- "$MODULE_DIR/monitor-release.sh"
187
- local monitor_status=$?
188
-
189
- echo ""
190
- case $monitor_status in
191
- 0)
192
- print_success "步骤4完成: 发布监控成功,所有组件已发布"
193
- ;;
194
- 1)
195
- print_error "步骤4失败: 发布过程中出现错误"
196
- ;;
197
- 2)
198
- print_warning "步骤4部分完成: 发布可能仍在进行中"
199
- ;;
200
- *)
201
- print_warning "步骤4完成: 发布状态需要手动确认"
202
- ;;
203
- esac
204
-
205
- return $monitor_status
206
- }
207
-
208
- # 显示最终总结
209
- show_final_summary() {
210
- local status=$1
211
-
212
- echo ""
213
- echo "🎊 智能发布流程总结"
214
- echo "==================="
215
- echo ""
216
- print_info "📦 版本信息:"
217
- echo " 版本: v$NEW_VERSION"
218
- echo " Tag: $TAG_NAME"
219
- echo ""
220
- print_info "🔗 相关链接:"
221
- echo " 安装命令: npm install -g ccman@$NEW_VERSION"
222
- echo " NPM页面: https://www.npmjs.com/package/ccman/v/$NEW_VERSION"
223
- echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/v$NEW_VERSION"
224
- echo ""
225
-
226
- case $status in
227
- 0)
228
- print_success "🎉 智能发布完全成功!"
229
- ;;
230
- 1)
231
- print_error "❌ 发布过程中出现错误,请检查上述链接"
232
- ;;
233
- *)
234
- print_warning "⚠️ 发布可能仍在进行中,请稍后检查"
235
- ;;
236
- esac
237
- }
238
-
239
- # 主函数
240
- main() {
241
- echo "🚀 CCM 智能发布脚本 v3.0 (模块化架构)"
242
- echo "======================================="
243
- echo ""
244
- print_info "使用模块化架构,四个独立步骤:"
245
- echo " 1. 检查工作目录状态"
246
- echo " 2. 版本管理"
247
- echo " 3. 创建tag和提交"
248
- echo " 4. 监控发布状态"
249
- echo ""
250
-
251
- # 检查环境
252
- check_modules
253
-
254
- # 确认开始
255
- if [ "$SKIP_VERSION" != true ] && [ -z "$VERSION_TYPE" ] && [ "$NO_MONITOR" != true ]; then
256
- read -p "开始智能发布流程? (Y/n): " -n 1 -r
257
- echo
258
- if [[ $REPLY =~ ^[Nn]$ ]]; then
259
- print_warning "发布已取消"
260
- exit 0
261
- fi
262
- echo ""
263
- fi
264
-
265
- # 执行四个步骤
266
- step_check_uncommitted
267
- step_version_bump
268
- step_create_tag
269
- step_monitor_release
270
- local final_status=$?
271
-
272
- # 显示最终总结
273
- show_final_summary $final_status
274
-
275
- exit $final_status
276
- }
277
-
278
- # 错误处理
279
- trap 'print_error "智能发布过程中出现错误"' ERR
280
-
281
- # 解析参数并运行
282
- parse_arguments "$@"
283
- main