@liuzijian625/code-cli 1.0.4 → 1.0.6
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/lib/config.js +21 -7
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -51,11 +51,18 @@ async function applyCodex(preset) {
|
|
|
51
51
|
// Claude Code 配置
|
|
52
52
|
async function applyClaude(preset) {
|
|
53
53
|
if (isWindows) {
|
|
54
|
-
// Windows:
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
// Windows: 修改 ~/.claude.json
|
|
55
|
+
const claudeFile = path.join(os.homedir(), '.claude.json');
|
|
56
|
+
let config = {};
|
|
57
|
+
if (fs.existsSync(claudeFile)) {
|
|
58
|
+
config = JSON.parse(fs.readFileSync(claudeFile, 'utf-8'));
|
|
59
|
+
}
|
|
60
|
+
if (!config.env) config.env = {};
|
|
61
|
+
config.env.ANTHROPIC_BASE_URL = preset.url;
|
|
62
|
+
config.env.ANTHROPIC_AUTH_TOKEN = preset.key;
|
|
63
|
+
fs.writeFileSync(claudeFile, JSON.stringify(config, null, 2));
|
|
57
64
|
} else {
|
|
58
|
-
// Linux/macOS: 修改 settings.json
|
|
65
|
+
// Linux/macOS: 修改 ~/.claude/settings.json
|
|
59
66
|
const claudeDir = path.join(os.homedir(), '.claude');
|
|
60
67
|
const settingsFile = path.join(claudeDir, 'settings.json');
|
|
61
68
|
|
|
@@ -124,9 +131,16 @@ async function clearCodex() {
|
|
|
124
131
|
|
|
125
132
|
async function clearClaude() {
|
|
126
133
|
if (isWindows) {
|
|
127
|
-
// Windows:
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
// Windows: 修改 ~/.claude.json
|
|
135
|
+
const claudeFile = path.join(os.homedir(), '.claude.json');
|
|
136
|
+
if (fs.existsSync(claudeFile)) {
|
|
137
|
+
let config = JSON.parse(fs.readFileSync(claudeFile, 'utf-8'));
|
|
138
|
+
if (config.env) {
|
|
139
|
+
delete config.env.ANTHROPIC_BASE_URL;
|
|
140
|
+
delete config.env.ANTHROPIC_AUTH_TOKEN;
|
|
141
|
+
}
|
|
142
|
+
fs.writeFileSync(claudeFile, JSON.stringify(config, null, 2));
|
|
143
|
+
}
|
|
130
144
|
} else {
|
|
131
145
|
const claudeDir = path.join(os.homedir(), '.claude');
|
|
132
146
|
const settingsFile = path.join(claudeDir, 'settings.json');
|