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
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ccman",
|
|
3
|
-
"version": "2.1.2",
|
|
4
|
-
"description": "Claude Code Manager - A TypeScript tool to manage Claude Code API configurations",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"packageManager": "pnpm@7.33.7",
|
|
7
|
-
"bin": {
|
|
8
|
-
"ccman": "./dist/cli.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"prebuild": "NODE_ENV=production node scripts/build-env.js",
|
|
12
|
-
"prebuild:dev": "NODE_ENV=development node scripts/build-env.js",
|
|
13
|
-
"build": "pnpm prebuild && tsc",
|
|
14
|
-
"build:dev": "pnpm prebuild:dev && tsc",
|
|
15
|
-
"dev": "pnpm prebuild:dev && tsx src/cli.ts",
|
|
16
|
-
"lint": "eslint src/**/*.ts",
|
|
17
|
-
"clean": "rm -rf dist",
|
|
18
|
-
"release": "./scripts/release.sh",
|
|
19
|
-
"release:smart": "./scripts/smart-release-v3.sh",
|
|
20
|
-
"release:patch": "./scripts/quick-release.sh patch",
|
|
21
|
-
"release:minor": "./scripts/quick-release.sh minor",
|
|
22
|
-
"release:major": "./scripts/quick-release.sh major",
|
|
23
|
-
"release:interactive": "./scripts/quick-release.sh",
|
|
24
|
-
"publish:local": "./scripts/publish-local.sh",
|
|
25
|
-
"prepublishOnly": "pnpm run clean && pnpm run build && pnpm run lint"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"claude",
|
|
29
|
-
"claude-code",
|
|
30
|
-
"api",
|
|
31
|
-
"config",
|
|
32
|
-
"manager",
|
|
33
|
-
"cli",
|
|
34
|
-
"typescript"
|
|
35
|
-
],
|
|
36
|
-
"author": "",
|
|
37
|
-
"license": "MIT",
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"chalk": "^4.1.2",
|
|
40
|
-
"commander": "^11.0.0",
|
|
41
|
-
"fs-extra": "^11.0.0",
|
|
42
|
-
"inquirer": "^8.2.6"
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@types/fs-extra": "^11.0.0",
|
|
46
|
-
"@types/inquirer": "^9.0.0",
|
|
47
|
-
"@types/jest": "^29.0.0",
|
|
48
|
-
"@types/node": "^20.0.0",
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
50
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
51
|
-
"eslint": "^8.0.0",
|
|
52
|
-
"jest": "^29.0.0",
|
|
53
|
-
"prettier": "^3.0.0",
|
|
54
|
-
"ts-jest": "^29.0.0",
|
|
55
|
-
"tsx": "^4.0.0",
|
|
56
|
-
"typescript": "^5.0.0"
|
|
57
|
-
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=16.0.0"
|
|
60
|
-
}
|
|
61
|
-
}
|
package/scripts/build-env.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 构建时环境配置生成器
|
|
8
|
-
* 根据NODE_ENV加载对应的.env文件并生成静态配置
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
function main() {
|
|
12
|
-
const nodeEnv = process.env.NODE_ENV || 'production';
|
|
13
|
-
const envFile = `.env.${nodeEnv}`;
|
|
14
|
-
const envPath = path.join(__dirname, '..', envFile);
|
|
15
|
-
|
|
16
|
-
console.log(`🔧 Building environment config for: ${nodeEnv}`);
|
|
17
|
-
console.log(`📂 Loading env file: ${envFile}`);
|
|
18
|
-
|
|
19
|
-
// 检查环境文件是否存在
|
|
20
|
-
if (!fs.existsSync(envPath)) {
|
|
21
|
-
console.error(`❌ Environment file not found: ${envFile}`);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 读取并解析环境文件
|
|
26
|
-
const envContent = fs.readFileSync(envPath, 'utf8');
|
|
27
|
-
const envVars = {};
|
|
28
|
-
|
|
29
|
-
envContent.split('\n').forEach(line => {
|
|
30
|
-
line = line.trim();
|
|
31
|
-
if (line && !line.startsWith('#')) {
|
|
32
|
-
const [key, ...valueParts] = line.split('=');
|
|
33
|
-
if (key && valueParts.length > 0) {
|
|
34
|
-
envVars[key.trim()] = valueParts.join('=').trim();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
console.log(`✅ Loaded ${Object.keys(envVars).length} environment variables`);
|
|
40
|
-
|
|
41
|
-
// 生成静态配置文件
|
|
42
|
-
const staticEnvContent = `/**
|
|
43
|
-
* 静态环境配置
|
|
44
|
-
* 此文件由 scripts/build-env.js 在编译时自动生成
|
|
45
|
-
* ⚠️ 请勿手动修改此文件
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export const STATIC_ENV = {
|
|
49
|
-
NODE_ENV: '${nodeEnv}',
|
|
50
|
-
BUILD_TIME: '${new Date().toISOString()}',
|
|
51
|
-
${Object.entries(envVars).map(([key, value]) => `${key}: '${value}'`).join(',\n ')}
|
|
52
|
-
} as const;
|
|
53
|
-
|
|
54
|
-
export const CCM_CONFIG_DIR = STATIC_ENV.CCM_CONFIG_DIR;
|
|
55
|
-
export const CLAUDE_CONFIG_PATH = STATIC_ENV.CLAUDE_CONFIG_PATH;
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
// 确保目录存在
|
|
59
|
-
const staticEnvDir = path.join(__dirname, '..', 'src', 'config');
|
|
60
|
-
if (!fs.existsSync(staticEnvDir)) {
|
|
61
|
-
fs.mkdirSync(staticEnvDir, { recursive: true });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 写入静态配置文件
|
|
65
|
-
const staticEnvPath = path.join(staticEnvDir, 'static-env.ts');
|
|
66
|
-
fs.writeFileSync(staticEnvPath, staticEnvContent);
|
|
67
|
-
|
|
68
|
-
console.log(`📝 Generated static config: src/config/static-env.ts`);
|
|
69
|
-
console.log(`🎯 Environment: ${nodeEnv}`);
|
|
70
|
-
console.log(`📋 Variables: ${Object.keys(envVars).join(', ')}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (require.main === module) {
|
|
74
|
-
main();
|
|
75
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
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
|
|
@@ -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
|