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
package/release-temp/README.md
DELETED
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
# CCM - Claude Code Manager v2.0
|
|
2
|
-
|
|
3
|
-
A TypeScript-based command-line tool to manage multiple Claude Code API provider configurations with **direct settings.json integration** and **intelligent language support**.
|
|
4
|
-
|
|
5
|
-
> **English Documentation** | [中文文档](./README_zh.md)
|
|
6
|
-
|
|
7
|
-
## ✨ New in v2.0
|
|
8
|
-
|
|
9
|
-
🌍 **Intelligent Language Support** - Auto-detects system language or guides first-run setup
|
|
10
|
-
🔧 **Direct Claude Integration** - Modifies `~/.claude/settings.json` directly, no shell variables
|
|
11
|
-
📁 **Provider Management** - Store and switch between multiple API provider configurations
|
|
12
|
-
🎯 **Interactive Menu System** - Continuous operation support with navigation options
|
|
13
|
-
⚡ **Zero-Config Experience** - Works out of the box with smart defaults
|
|
14
|
-
|
|
15
|
-
## 🚀 Quick Start
|
|
16
|
-
|
|
17
|
-
### Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Install from NPM
|
|
21
|
-
npm install -g ccman
|
|
22
|
-
|
|
23
|
-
# Or install dependencies for development
|
|
24
|
-
npm install && npm run build
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### First Run Experience
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# Start CCM (first time)
|
|
31
|
-
ccman
|
|
32
|
-
|
|
33
|
-
🌍 Welcome to CCM! / 欢迎使用 CCM!
|
|
34
|
-
|
|
35
|
-
This is your first time running CCM.
|
|
36
|
-
这是您首次运行 CCM。
|
|
37
|
-
|
|
38
|
-
? Please choose your preferred language:
|
|
39
|
-
? 请选择您偏好的语言:
|
|
40
|
-
❯ 🇨🇳 中文 (Chinese)
|
|
41
|
-
🇺🇸 English
|
|
42
|
-
🌐 Auto-detect based on system
|
|
43
|
-
|
|
44
|
-
✓ Language set to Chinese
|
|
45
|
-
✓ You can change this later with: ccman lang set <zh|en|auto>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Basic Usage
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
# Interactive main menu (recommended)
|
|
52
|
-
ccman
|
|
53
|
-
|
|
54
|
-
# List all providers
|
|
55
|
-
ccman ls
|
|
56
|
-
|
|
57
|
-
# Add provider directly
|
|
58
|
-
ccman add <id> <name> <baseUrl> [apiKey]
|
|
59
|
-
|
|
60
|
-
# Switch provider
|
|
61
|
-
ccman use <id>
|
|
62
|
-
|
|
63
|
-
# Remove provider
|
|
64
|
-
ccman rm <id>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## 🌐 Language Management
|
|
68
|
-
|
|
69
|
-
### Language Commands
|
|
70
|
-
```bash
|
|
71
|
-
ccman lang # Show current language setting
|
|
72
|
-
ccman lang set zh # Set to Chinese
|
|
73
|
-
ccman lang set en # Set to English
|
|
74
|
-
ccman lang set auto # Auto-detect based on system
|
|
75
|
-
ccman lang reset # Reset to first-run state
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Supported Languages
|
|
79
|
-
- **Chinese (zh)** - 完整中文界面
|
|
80
|
-
- **English (en)** - Full English interface
|
|
81
|
-
- **Auto-detect** - Based on system `LANG` environment variable
|
|
82
|
-
|
|
83
|
-
### Language Detection Logic
|
|
84
|
-
- English environments (`en-*`) → English interface
|
|
85
|
-
- Other environments (including `zh-*`, unset) → Chinese interface
|
|
86
|
-
- Manual override available anytime
|
|
87
|
-
|
|
88
|
-
## 📖 Commands Reference
|
|
89
|
-
|
|
90
|
-
### Core Provider Management
|
|
91
|
-
```bash
|
|
92
|
-
ccman # Interactive menu (default)
|
|
93
|
-
ccman add <id> <name> <url> [key] # Add new provider
|
|
94
|
-
ccman use <id> # Switch to provider
|
|
95
|
-
ccman ls # List all providers
|
|
96
|
-
ccman ls --current # Show current provider details
|
|
97
|
-
ccman ls --brief # Brief provider list
|
|
98
|
-
ccman rm <id> # Remove provider
|
|
99
|
-
ccman clear # Remove ALL providers (destructive)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Language Management
|
|
103
|
-
```bash
|
|
104
|
-
ccman lang # Show current language
|
|
105
|
-
ccman lang set <zh|en|auto> # Set language preference
|
|
106
|
-
ccman lang reset # Reset to first-run state
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## 🎯 Interactive Experience
|
|
110
|
-
|
|
111
|
-
### Main Menu Navigation
|
|
112
|
-
```bash
|
|
113
|
-
$ ccman
|
|
114
|
-
|
|
115
|
-
? What would you like to do?
|
|
116
|
-
❯ Switch provider
|
|
117
|
-
Add new provider
|
|
118
|
-
Update provider
|
|
119
|
-
Remove provider
|
|
120
|
-
Show detailed status
|
|
121
|
-
Exit
|
|
122
|
-
|
|
123
|
-
# After each operation:
|
|
124
|
-
? Would you like to perform another operation? (Y/n)
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Provider Addition Flow
|
|
128
|
-
```bash
|
|
129
|
-
$ ccman add
|
|
130
|
-
|
|
131
|
-
? Provider ID: my-provider
|
|
132
|
-
? Provider name: My Custom API
|
|
133
|
-
? Description: My custom Claude API
|
|
134
|
-
? Base URL: https://api.mycustom.com
|
|
135
|
-
? API Key: ****************
|
|
136
|
-
|
|
137
|
-
✓ Provider added successfully
|
|
138
|
-
? Set "My Custom API" as current provider? (Y/n)
|
|
139
|
-
✓ Provider switched successfully
|
|
140
|
-
Claude Code configuration has been updated successfully!
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## 🔧 Architecture Overview
|
|
144
|
-
|
|
145
|
-
### Direct Claude Integration
|
|
146
|
-
CCM v2.0 directly modifies your Claude Code settings file:
|
|
147
|
-
|
|
148
|
-
**Before (CCM manages)**:
|
|
149
|
-
```json
|
|
150
|
-
{
|
|
151
|
-
"env": {
|
|
152
|
-
"ANTHROPIC_AUTH_TOKEN": "old-token",
|
|
153
|
-
"ANTHROPIC_BASE_URL": "https://old-api.com"
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**After (CCM updates)**:
|
|
159
|
-
```json
|
|
160
|
-
{
|
|
161
|
-
"env": {
|
|
162
|
-
"ANTHROPIC_AUTH_TOKEN": "new-token",
|
|
163
|
-
"ANTHROPIC_BASE_URL": "https://new-api.com",
|
|
164
|
-
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
|
|
165
|
-
},
|
|
166
|
-
"permissions": {
|
|
167
|
-
"allow": [],
|
|
168
|
-
"deny": []
|
|
169
|
-
},
|
|
170
|
-
"apiKeyHelper": "echo 'new-token'"
|
|
171
|
-
}
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Provider Storage Structure
|
|
175
|
-
Providers are stored in `~/.ccman/providers/`:
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
~/.ccman/
|
|
179
|
-
├── config.json # Main CCM configuration
|
|
180
|
-
├── providers/ # Individual provider configs
|
|
181
|
-
│ ├── anthropic.json
|
|
182
|
-
│ ├── my-provider.json
|
|
183
|
-
│ └── staging.json
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Configuration Merging
|
|
187
|
-
CCM only updates Claude-specific keys, preserving your existing settings:
|
|
188
|
-
- ✅ Preserves: `mcpServers`, `model`, `customUserConfig`, etc.
|
|
189
|
-
- 🔄 Updates: `env.ANTHROPIC_*`, `permissions`, `apiKeyHelper`
|
|
190
|
-
|
|
191
|
-
## 📊 Provider Configuration
|
|
192
|
-
|
|
193
|
-
### Provider Structure
|
|
194
|
-
```json
|
|
195
|
-
{
|
|
196
|
-
"name": "Anthropic Official",
|
|
197
|
-
"description": "Official Anthropic API Configuration",
|
|
198
|
-
"config": {
|
|
199
|
-
"env": {
|
|
200
|
-
"ANTHROPIC_AUTH_TOKEN": "your-token",
|
|
201
|
-
"ANTHROPIC_BASE_URL": "https://api.anthropic.com",
|
|
202
|
-
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
|
|
203
|
-
},
|
|
204
|
-
"permissions": { "allow": [], "deny": [] },
|
|
205
|
-
"apiKeyHelper": "echo 'your-token'"
|
|
206
|
-
},
|
|
207
|
-
"metadata": {
|
|
208
|
-
"createdAt": "2025-01-15T10:30:00.000Z",
|
|
209
|
-
"updatedAt": "2025-01-15T10:30:00.000Z",
|
|
210
|
-
"usageCount": 5
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Main Configuration
|
|
216
|
-
```json
|
|
217
|
-
{
|
|
218
|
-
"currentProvider": "anthropic",
|
|
219
|
-
"claudeConfigPath": "/Users/user/.claude/settings.json",
|
|
220
|
-
"providers": {
|
|
221
|
-
"anthropic": {
|
|
222
|
-
"name": "Anthropic Official",
|
|
223
|
-
"configFile": "anthropic.json",
|
|
224
|
-
"lastUsed": "2025-01-15T10:30:00.000Z"
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
"settings": {
|
|
228
|
-
"language": "zh",
|
|
229
|
-
"firstRun": false
|
|
230
|
-
},
|
|
231
|
-
"metadata": {
|
|
232
|
-
"version": "2.0.0",
|
|
233
|
-
"createdAt": "2025-01-15T10:00:00.000Z",
|
|
234
|
-
"updatedAt": "2025-01-15T10:30:00.000Z"
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
## 💡 Usage Examples
|
|
240
|
-
|
|
241
|
-
### Complete First-Time Setup
|
|
242
|
-
```bash
|
|
243
|
-
# First run - language selection
|
|
244
|
-
ccman
|
|
245
|
-
# → Language selection wizard
|
|
246
|
-
# → No providers found, guided creation
|
|
247
|
-
# → Automatic Claude settings update
|
|
248
|
-
|
|
249
|
-
# Add additional providers
|
|
250
|
-
ccman add staging "Staging API" https://staging-api.com
|
|
251
|
-
ccman add dev "Development" https://dev-api.com
|
|
252
|
-
|
|
253
|
-
# Switch between providers
|
|
254
|
-
ccman use staging
|
|
255
|
-
ccman use dev
|
|
256
|
-
ccman use anthropic
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### Multi-Provider Workflow
|
|
260
|
-
```bash
|
|
261
|
-
# List all providers with details
|
|
262
|
-
ccman ls
|
|
263
|
-
# * Anthropic Official (anthropic) - https://api.anthropic.com
|
|
264
|
-
# Staging API (staging) - https://staging-api.com
|
|
265
|
-
# Development (dev) - https://dev-api.com
|
|
266
|
-
|
|
267
|
-
# Switch to staging for testing
|
|
268
|
-
ccman use staging
|
|
269
|
-
# ✓ Provider switched successfully
|
|
270
|
-
# ✓ Claude Code configuration has been updated successfully!
|
|
271
|
-
|
|
272
|
-
# Check current provider
|
|
273
|
-
ccman ls --current
|
|
274
|
-
# Current provider: Staging API (staging)
|
|
275
|
-
# Base URL: https://staging-api.com
|
|
276
|
-
# Usage count: 3 times
|
|
277
|
-
# Last updated: 2025-01-15 10:30:15
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Language Switching
|
|
281
|
-
```bash
|
|
282
|
-
# Check current language
|
|
283
|
-
ccman lang
|
|
284
|
-
# Current language: 中文 (Chinese)
|
|
285
|
-
|
|
286
|
-
# Switch to English
|
|
287
|
-
ccman lang set en
|
|
288
|
-
# ✓ Language switched successfully
|
|
289
|
-
# Current language: English
|
|
290
|
-
|
|
291
|
-
# Set auto-detect
|
|
292
|
-
ccman lang set auto
|
|
293
|
-
# ✓ Language switched successfully
|
|
294
|
-
# Current language: Auto-detect
|
|
295
|
-
# Auto-detected: English
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## 🛠️ Development Setup
|
|
299
|
-
|
|
300
|
-
### Development Environment
|
|
301
|
-
CCM supports isolated development environments:
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
# Set development paths
|
|
305
|
-
export CCM_CONFIG_DIR=".ccman-dev"
|
|
306
|
-
export CLAUDE_CONFIG_PATH="$HOME/.claude/settings-dev.json"
|
|
307
|
-
|
|
308
|
-
# Use development mode
|
|
309
|
-
npm run dev
|
|
310
|
-
|
|
311
|
-
# Build for production
|
|
312
|
-
npm run build
|
|
313
|
-
|
|
314
|
-
# Test built version
|
|
315
|
-
npm start
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Development Commands
|
|
319
|
-
```bash
|
|
320
|
-
npm run dev # Development mode with tsx
|
|
321
|
-
npm run build # TypeScript compilation
|
|
322
|
-
npm run start # Run built CLI
|
|
323
|
-
npm run clean # Remove dist/ directory
|
|
324
|
-
npm run lint # ESLint TypeScript files
|
|
325
|
-
npm test # Run tests (passWithNoTests)
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
## 🔍 Troubleshooting
|
|
329
|
-
|
|
330
|
-
### Provider Issues
|
|
331
|
-
```bash
|
|
332
|
-
# Provider not working?
|
|
333
|
-
ccman ls --current # Check current provider details
|
|
334
|
-
ccman use <provider-id> # Re-apply provider configuration
|
|
335
|
-
|
|
336
|
-
# Settings not applied?
|
|
337
|
-
# Check ~/.claude/settings.json for updates
|
|
338
|
-
cat ~/.claude/settings.json | grep ANTHROPIC
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
### Language Issues
|
|
342
|
-
```bash
|
|
343
|
-
# Language not switching?
|
|
344
|
-
ccman lang # Check current setting
|
|
345
|
-
ccman lang set zh # Force Chinese
|
|
346
|
-
ccman lang set en # Force English
|
|
347
|
-
|
|
348
|
-
# First-run issues?
|
|
349
|
-
ccman lang reset # Reset to first-run state
|
|
350
|
-
ccman # Restart for language selection
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
### Configuration Issues
|
|
354
|
-
```bash
|
|
355
|
-
# Corrupt configuration?
|
|
356
|
-
ccman clear # Remove all (with confirmation)
|
|
357
|
-
ccman # Fresh start
|
|
358
|
-
|
|
359
|
-
# Development isolation
|
|
360
|
-
export CCM_CONFIG_DIR=".ccman-dev" # Separate dev config
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
## 📋 Requirements
|
|
364
|
-
|
|
365
|
-
- **Node.js** >= 16.0.0
|
|
366
|
-
- **Claude Code** installed with settings.json support
|
|
367
|
-
- **Operating Systems**: Linux, macOS, Windows (WSL)
|
|
368
|
-
|
|
369
|
-
## 📄 License
|
|
370
|
-
|
|
371
|
-
MIT License - see LICENSE file for details.
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## 🚀 Migration from v1.x
|
|
376
|
-
|
|
377
|
-
CCM v2.0 uses a completely different architecture:
|
|
378
|
-
|
|
379
|
-
### v1.x (Shell Integration)
|
|
380
|
-
- Modified shell configuration files
|
|
381
|
-
- Used environment variables
|
|
382
|
-
- Complex shell integration
|
|
383
|
-
|
|
384
|
-
### v2.0 (Direct Integration)
|
|
385
|
-
- Modifies `~/.claude/settings.json` directly
|
|
386
|
-
- Provider-based configuration
|
|
387
|
-
- Language support
|
|
388
|
-
- Simplified, safer approach
|
|
389
|
-
|
|
390
|
-
**Migration**: v1.x and v2.x are incompatible. Start fresh with `ccman clear` if upgrading.
|
|
391
|
-
|
|
392
|
-
---
|
|
393
|
-
|
|
394
|
-
*CCM v2.0 - Intelligent, multilingual, and seamless Claude Code provider management.*
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ccman",
|
|
3
|
-
"version": "2.1.3",
|
|
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
|