@liuzijian625/code-cli 1.0.4 → 1.0.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/lib/config.js +18 -7
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -51,11 +51,17 @@ 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
|
+
config.apiKey = preset.key;
|
|
61
|
+
config.baseUrl = preset.url;
|
|
62
|
+
fs.writeFileSync(claudeFile, JSON.stringify(config, null, 2));
|
|
57
63
|
} else {
|
|
58
|
-
// Linux/macOS: 修改 settings.json
|
|
64
|
+
// Linux/macOS: 修改 ~/.claude/settings.json
|
|
59
65
|
const claudeDir = path.join(os.homedir(), '.claude');
|
|
60
66
|
const settingsFile = path.join(claudeDir, 'settings.json');
|
|
61
67
|
|
|
@@ -124,9 +130,14 @@ async function clearCodex() {
|
|
|
124
130
|
|
|
125
131
|
async function clearClaude() {
|
|
126
132
|
if (isWindows) {
|
|
127
|
-
// Windows:
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
// Windows: 修改 ~/.claude.json
|
|
134
|
+
const claudeFile = path.join(os.homedir(), '.claude.json');
|
|
135
|
+
if (fs.existsSync(claudeFile)) {
|
|
136
|
+
let config = JSON.parse(fs.readFileSync(claudeFile, 'utf-8'));
|
|
137
|
+
delete config.apiKey;
|
|
138
|
+
delete config.baseUrl;
|
|
139
|
+
fs.writeFileSync(claudeFile, JSON.stringify(config, null, 2));
|
|
140
|
+
}
|
|
130
141
|
} else {
|
|
131
142
|
const claudeDir = path.join(os.homedir(), '.claude');
|
|
132
143
|
const settingsFile = path.join(claudeDir, 'settings.json');
|