ccman 2.1.2 → 2.1.4
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 +308 -258
- package/README_en.md +444 -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 +5 -1
- package/dist/core/ClaudeConfigManager.d.ts.map +1 -1
- package/dist/core/ClaudeConfigManager.js +19 -3
- package/dist/core/ClaudeConfigManager.js.map +1 -1
- package/dist/providers/ProviderManager.d.ts.map +1 -1
- package/dist/providers/ProviderManager.js +7 -8
- package/dist/providers/ProviderManager.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.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 -276
- 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 -123
- 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 -414
- package/src/types/index.ts +0 -100
- package/src/utils/env-config.ts +0 -53
- package/src/utils/version.ts +0 -16
- package/tsconfig.json +0 -25
package/scripts/quick-release.sh
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# CCM Quick Release Script
|
|
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}"; exit 1; }
|
|
18
|
-
print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
|
|
19
|
-
|
|
20
|
-
# 快速检查
|
|
21
|
-
[ ! -f "package.json" ] && print_error "package.json 未找到"
|
|
22
|
-
[ ! -d ".git" ] && print_error "不在 Git 仓库中"
|
|
23
|
-
git diff-index --quiet HEAD -- || print_error "工作目录有未提交更改"
|
|
24
|
-
|
|
25
|
-
# 获取当前版本和升级类型
|
|
26
|
-
current_version=$(node -p "require('./package.json').version")
|
|
27
|
-
version_type=${1:-""}
|
|
28
|
-
|
|
29
|
-
echo "🚀 CCM 快速发布"
|
|
30
|
-
echo "当前版本: $current_version"
|
|
31
|
-
|
|
32
|
-
# 如果没有提供版本类型,让用户选择
|
|
33
|
-
if [ -z "$version_type" ]; then
|
|
34
|
-
echo ""
|
|
35
|
-
print_info "选择版本类型:"
|
|
36
|
-
echo "1) patch (修订版本): $current_version → $(pnpm version patch --dry-run 2>/dev/null | cut -d'v' -f2 || echo '计算中...')"
|
|
37
|
-
echo "2) minor (次版本): $current_version → $(pnpm version minor --dry-run 2>/dev/null | cut -d'v' -f2 || echo '计算中...')"
|
|
38
|
-
echo "3) major (主版本): $current_version → $(pnpm version major --dry-run 2>/dev/null | cut -d'v' -f2 || echo '计算中...')"
|
|
39
|
-
echo ""
|
|
40
|
-
|
|
41
|
-
read -p "请选择 (1-3, 回车默认选择 patch): " choice
|
|
42
|
-
|
|
43
|
-
case ${choice:-1} in
|
|
44
|
-
1|"") version_type="patch" ;;
|
|
45
|
-
2) version_type="minor" ;;
|
|
46
|
-
3) version_type="major" ;;
|
|
47
|
-
*) print_error "无效选择" ;;
|
|
48
|
-
esac
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
print_info "升级类型: $version_type"
|
|
52
|
-
|
|
53
|
-
# 确认发布
|
|
54
|
-
echo ""
|
|
55
|
-
read -p "确认发布? (y/N): " -n 1 -r
|
|
56
|
-
echo
|
|
57
|
-
[[ ! $REPLY =~ ^[Yy]$ ]] && { print_warning "取消发布"; exit 0; }
|
|
58
|
-
|
|
59
|
-
# 执行发布流程
|
|
60
|
-
print_success "开始发布流程..."
|
|
61
|
-
|
|
62
|
-
# 1. 构建和测试
|
|
63
|
-
print_info "运行构建和代码检查..."
|
|
64
|
-
pnpm run build
|
|
65
|
-
pnpm run lint
|
|
66
|
-
|
|
67
|
-
# 2. 更新版本
|
|
68
|
-
print_info "更新版本号..."
|
|
69
|
-
new_version=$(pnpm version $version_type --no-git-tag-version)
|
|
70
|
-
new_version=${new_version#v}
|
|
71
|
-
|
|
72
|
-
print_success "版本已更新: $current_version → $new_version"
|
|
73
|
-
|
|
74
|
-
# 3. 提交和打标签
|
|
75
|
-
print_info "创建提交和标签..."
|
|
76
|
-
git add .
|
|
77
|
-
git commit -m "chore: 发布版本 v$new_version
|
|
78
|
-
|
|
79
|
-
🚀 快速发布 $version_type 版本
|
|
80
|
-
⏰ $(date '+%Y-%m-%d %H:%M:%S')
|
|
81
|
-
|
|
82
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
83
|
-
|
|
84
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
85
|
-
|
|
86
|
-
git tag -a "v$new_version" -m "Release v$new_version"
|
|
87
|
-
|
|
88
|
-
# 4. 推送
|
|
89
|
-
print_info "推送到远程仓库..."
|
|
90
|
-
git push origin $(git branch --show-current)
|
|
91
|
-
git push origin "v$new_version"
|
|
92
|
-
|
|
93
|
-
print_success "发布完成!版本 v$new_version 已推送"
|
|
94
|
-
echo ""
|
|
95
|
-
print_info "🔗 相关链接:"
|
|
96
|
-
echo " GitHub Actions: https://github.com/2ue/ccm/actions"
|
|
97
|
-
echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/v$new_version"
|
|
98
|
-
echo ""
|
|
99
|
-
print_info "📦 NPM 包将在 GitHub Actions 完成后发布:"
|
|
100
|
-
echo " https://www.npmjs.com/package/ccman"
|
package/scripts/release.sh
DELETED
|
@@ -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 "$@"
|