@liuzijian625/code-cli 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/lib/config.js +23 -35
  2. package/package.json +8 -2
package/lib/config.js CHANGED
@@ -48,32 +48,25 @@ async function applyCodex(preset) {
48
48
  fs.writeFileSync(authFile, JSON.stringify(auth, null, 2));
49
49
  }
50
50
 
51
- // Claude Code 配置
51
+ // Claude Code 配置(全平台统一使用 settings.json)
52
52
  async function applyClaude(preset) {
53
- if (isWindows) {
54
- // Windows: 设置用户环境变量
55
- await execAsync(`powershell -Command "[System.Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', '${preset.url}', [System.EnvironmentVariableTarget]::User)"`);
56
- await execAsync(`powershell -Command "[System.Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', '${preset.key}', [System.EnvironmentVariableTarget]::User)"`);
57
- } else {
58
- // Linux/macOS: 修改 settings.json
59
- const claudeDir = path.join(os.homedir(), '.claude');
60
- const settingsFile = path.join(claudeDir, 'settings.json');
53
+ const claudeDir = path.join(os.homedir(), '.claude');
54
+ const settingsFile = path.join(claudeDir, 'settings.json');
61
55
 
62
- if (!fs.existsSync(claudeDir)) {
63
- fs.mkdirSync(claudeDir, { recursive: true });
64
- }
56
+ if (!fs.existsSync(claudeDir)) {
57
+ fs.mkdirSync(claudeDir, { recursive: true });
58
+ }
65
59
 
66
- let settings = {};
67
- if (fs.existsSync(settingsFile)) {
68
- settings = JSON.parse(fs.readFileSync(settingsFile, 'utf-8'));
69
- }
60
+ let settings = {};
61
+ if (fs.existsSync(settingsFile)) {
62
+ settings = JSON.parse(fs.readFileSync(settingsFile, 'utf-8'));
63
+ }
70
64
 
71
- if (!settings.env) settings.env = {};
72
- settings.env.ANTHROPIC_BASE_URL = preset.url;
73
- settings.env.ANTHROPIC_AUTH_TOKEN = preset.key;
65
+ if (!settings.env) settings.env = {};
66
+ settings.env.ANTHROPIC_BASE_URL = preset.url;
67
+ settings.env.ANTHROPIC_AUTH_TOKEN = preset.key;
74
68
 
75
- fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
76
- }
69
+ fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
77
70
  }
78
71
 
79
72
  // Gemini CLI 配置
@@ -123,21 +116,16 @@ async function clearCodex() {
123
116
  }
124
117
 
125
118
  async function clearClaude() {
126
- if (isWindows) {
127
- await execAsync(`powershell -Command "[System.Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', $null, [System.EnvironmentVariableTarget]::User)"`);
128
- await execAsync(`powershell -Command "[System.Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', $null, [System.EnvironmentVariableTarget]::User)"`);
129
- } else {
130
- const claudeDir = path.join(os.homedir(), '.claude');
131
- const settingsFile = path.join(claudeDir, 'settings.json');
132
-
133
- if (fs.existsSync(settingsFile)) {
134
- let settings = JSON.parse(fs.readFileSync(settingsFile, 'utf-8'));
135
- if (settings.env) {
136
- delete settings.env.ANTHROPIC_BASE_URL;
137
- delete settings.env.ANTHROPIC_AUTH_TOKEN;
138
- }
139
- fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
119
+ const claudeDir = path.join(os.homedir(), '.claude');
120
+ const settingsFile = path.join(claudeDir, 'settings.json');
121
+
122
+ if (fs.existsSync(settingsFile)) {
123
+ let settings = JSON.parse(fs.readFileSync(settingsFile, 'utf-8'));
124
+ if (settings.env) {
125
+ delete settings.env.ANTHROPIC_BASE_URL;
126
+ delete settings.env.ANTHROPIC_AUTH_TOKEN;
140
127
  }
128
+ fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
141
129
  }
142
130
  }
143
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liuzijian625/code-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "AI CLI 配置管理工具 - 管理 Codex、Claude Code、Gemini CLI 的配置",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -9,7 +9,13 @@
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
- "keywords": ["cli", "codex", "claude", "gemini", "config"],
12
+ "keywords": [
13
+ "cli",
14
+ "codex",
15
+ "claude",
16
+ "gemini",
17
+ "config"
18
+ ],
13
19
  "author": "",
14
20
  "license": "ISC",
15
21
  "type": "module",