pumpkinai-config 1.0.3 → 1.0.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/claude-au.js +237 -0
- package/package.json +3 -2
package/claude-au.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code 自动更新禁用工具
|
|
5
|
+
* 功能:
|
|
6
|
+
* 1. 在 ~/.claude/settings.json 中添加禁用自动更新的配置
|
|
7
|
+
* 2. 安装指定版本的 @anthropic-ai/claude-code@2.0.25
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const os = require('os');
|
|
13
|
+
const { execSync } = require('child_process');
|
|
14
|
+
|
|
15
|
+
// 颜色输出
|
|
16
|
+
const colors = {
|
|
17
|
+
red: '\x1b[31m',
|
|
18
|
+
green: '\x1b[32m',
|
|
19
|
+
yellow: '\x1b[33m',
|
|
20
|
+
blue: '\x1b[34m',
|
|
21
|
+
magenta: '\x1b[35m',
|
|
22
|
+
cyan: '\x1b[36m',
|
|
23
|
+
reset: '\x1b[0m'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function log(message, color = 'reset') {
|
|
27
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 检测操作系统
|
|
31
|
+
function getOS() {
|
|
32
|
+
const platform = os.platform();
|
|
33
|
+
if (platform === 'win32') return 'windows';
|
|
34
|
+
if (platform === 'darwin') return 'mac';
|
|
35
|
+
return 'linux';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 获取用户 home 目录
|
|
39
|
+
function getHomeDir() {
|
|
40
|
+
let homeDir;
|
|
41
|
+
if (process.platform !== 'win32' && process.env.SUDO_USER) {
|
|
42
|
+
// Linux/Mac 使用 sudo 时,获取实际用户的 home 目录
|
|
43
|
+
const actualUser = process.env.SUDO_USER;
|
|
44
|
+
homeDir = process.platform === 'darwin' ? `/Users/${actualUser}` : `/home/${actualUser}`;
|
|
45
|
+
} else {
|
|
46
|
+
homeDir = os.homedir();
|
|
47
|
+
}
|
|
48
|
+
return homeDir;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 更新 settings.json 配置(添加而不是覆盖)
|
|
52
|
+
function updateClaudeSettings() {
|
|
53
|
+
log('\n[配置] 更新 Claude settings.json...', 'cyan');
|
|
54
|
+
|
|
55
|
+
const homeDir = getHomeDir();
|
|
56
|
+
const claudeDir = path.join(homeDir, '.claude');
|
|
57
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
// 确保 .claude 目录存在
|
|
61
|
+
if (!fs.existsSync(claudeDir)) {
|
|
62
|
+
fs.mkdirSync(claudeDir, { recursive: true });
|
|
63
|
+
log(`[成功] 创建目录: ${claudeDir}`, 'green');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 读取现有配置
|
|
67
|
+
let settings = {};
|
|
68
|
+
if (fs.existsSync(settingsPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const content = fs.readFileSync(settingsPath, 'utf8');
|
|
71
|
+
settings = JSON.parse(content);
|
|
72
|
+
log('[提示] 读取现有配置文件', 'yellow');
|
|
73
|
+
} catch (error) {
|
|
74
|
+
log('[警告] 无法解析现有配置文件,将创建新配置', 'yellow');
|
|
75
|
+
settings = {};
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
log('[提示] 配置文件不存在,将创建新文件', 'yellow');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 添加或更新自动更新配置
|
|
82
|
+
settings.autoUpdaterStatus = "disabled";
|
|
83
|
+
settings.autoUpdates = false;
|
|
84
|
+
|
|
85
|
+
// 写入配置文件
|
|
86
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf8');
|
|
87
|
+
log(`[成功] 更新配置文件: ${settingsPath}`, 'green');
|
|
88
|
+
log('[成功] 已添加配置:', 'green');
|
|
89
|
+
log(' - autoUpdaterStatus: "disabled"', 'green');
|
|
90
|
+
log(' - autoUpdates: false', 'green');
|
|
91
|
+
|
|
92
|
+
// 如果是通过 sudo 运行的,修改文件所有者
|
|
93
|
+
if (process.platform !== 'win32' && process.env.SUDO_USER) {
|
|
94
|
+
const actualUser = process.env.SUDO_USER;
|
|
95
|
+
const group = process.platform === 'darwin' ? 'staff' : actualUser;
|
|
96
|
+
try {
|
|
97
|
+
execSync(`chown -R ${actualUser}:${group} ${claudeDir}`);
|
|
98
|
+
log(`[成功] 设置文件所有者为: ${actualUser}`, 'green');
|
|
99
|
+
} catch (error) {
|
|
100
|
+
log(`[警告] 无法设置文件所有者: ${error.message}`, 'yellow');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return true;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
log(`[错误] 更新配置文件失败: ${error.message}`, 'red');
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 安装指定版本的 claude-code
|
|
112
|
+
function installClaudeVersion() {
|
|
113
|
+
const osType = getOS();
|
|
114
|
+
const targetVersion = '2.0.25';
|
|
115
|
+
let command;
|
|
116
|
+
|
|
117
|
+
log('\n[安装] 安装 @anthropic-ai/claude-code@2.0.25...', 'cyan');
|
|
118
|
+
|
|
119
|
+
if (osType === 'windows') {
|
|
120
|
+
command = `npm install -g @anthropic-ai/claude-code@${targetVersion} --registry https://registry.npmmirror.com`;
|
|
121
|
+
} else {
|
|
122
|
+
// 检查是否已经是 root 用户(通过 sudo 运行或直接 root)
|
|
123
|
+
const isRoot = process.getuid && process.getuid() === 0;
|
|
124
|
+
if (isRoot) {
|
|
125
|
+
command = `npm install -g @anthropic-ai/claude-code@${targetVersion} --registry https://registry.npmmirror.com`;
|
|
126
|
+
} else {
|
|
127
|
+
command = `sudo npm install -g @anthropic-ai/claude-code@${targetVersion} --registry https://registry.npmmirror.com`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
log(`[执行] ${command}`, 'yellow');
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
execSync(command, { stdio: 'inherit' });
|
|
135
|
+
log(`[成功] @anthropic-ai/claude-code@${targetVersion} 安装成功`, 'green');
|
|
136
|
+
return true;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
log(`[错误] @anthropic-ai/claude-code@${targetVersion} 安装失败`, 'red');
|
|
139
|
+
log('\n[错误详情]', 'red');
|
|
140
|
+
|
|
141
|
+
if (error.message) {
|
|
142
|
+
log(`错误信息: ${error.message}`, 'red');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (error.status !== undefined) {
|
|
146
|
+
log(`退出码: ${error.status}`, 'red');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
log('\n[提示] 你可以手动安装:', 'yellow');
|
|
150
|
+
log(` ${command}`, 'yellow');
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 显示完成信息
|
|
156
|
+
function showCompletionInfo() {
|
|
157
|
+
const homeDir = getHomeDir();
|
|
158
|
+
const settingsPath = path.join(homeDir, '.claude', 'settings.json');
|
|
159
|
+
|
|
160
|
+
log('\n', 'reset');
|
|
161
|
+
log('╔' + '═'.repeat(68) + '╗', 'yellow');
|
|
162
|
+
log('║' + ' '.repeat(15) + '配置完成 - 自动更新已禁用' + ' '.repeat(15) + '║', 'yellow');
|
|
163
|
+
log('╚' + '═'.repeat(68) + '╝', 'yellow');
|
|
164
|
+
|
|
165
|
+
log('\n ┌─ 已完成操作', 'cyan');
|
|
166
|
+
log(' │', 'cyan');
|
|
167
|
+
log(' │ ✓ 禁用 Claude Code 自动更新', 'green');
|
|
168
|
+
log(' │ ✓ 安装 @anthropic-ai/claude-code@2.0.25', 'green');
|
|
169
|
+
log(' │', 'cyan');
|
|
170
|
+
log(' └─────────────────────────────────────────────', 'cyan');
|
|
171
|
+
|
|
172
|
+
log('\n ┌─ 配置文件路径', 'cyan');
|
|
173
|
+
log(' │', 'cyan');
|
|
174
|
+
log(` │ ${settingsPath}`, 'yellow');
|
|
175
|
+
log(' │', 'cyan');
|
|
176
|
+
log(' └─────────────────────────────────────────────', 'cyan');
|
|
177
|
+
|
|
178
|
+
log('\n ┌─ 已添加的配置', 'cyan');
|
|
179
|
+
log(' │', 'cyan');
|
|
180
|
+
log(' │ "autoUpdaterStatus": "disabled"', 'yellow');
|
|
181
|
+
log(' │ "autoUpdates": false', 'yellow');
|
|
182
|
+
log(' │', 'cyan');
|
|
183
|
+
log(' └─────────────────────────────────────────────', 'cyan');
|
|
184
|
+
|
|
185
|
+
log('\n', 'reset');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 主函数
|
|
189
|
+
async function main() {
|
|
190
|
+
console.clear();
|
|
191
|
+
|
|
192
|
+
// ASCII Logo
|
|
193
|
+
log('\n', 'reset');
|
|
194
|
+
console.log(' \x1b[38;5;39m██████╗\x1b[38;5;75m██╗ \x1b[38;5;111m█████╗ \x1b[38;5;147m██╗ ██╗\x1b[38;5;183m██████╗ \x1b[38;5;219m███████╗\x1b[0m');
|
|
195
|
+
console.log(' \x1b[38;5;39m██╔════╝\x1b[38;5;75m██║ \x1b[38;5;111m██╔══██╗\x1b[38;5;147m██║ ██║\x1b[38;5;183m██╔══██╗\x1b[38;5;219m██╔════╝\x1b[0m');
|
|
196
|
+
console.log(' \x1b[38;5;45m██║ \x1b[38;5;81m██║ \x1b[38;5;117m███████║\x1b[38;5;153m██║ ██║\x1b[38;5;189m██║ ██║\x1b[38;5;225m█████╗ \x1b[0m');
|
|
197
|
+
console.log(' \x1b[38;5;75m██║ \x1b[38;5;111m██║ \x1b[38;5;147m██╔══██║\x1b[38;5;183m██║ ██║\x1b[38;5;219m██║ ██║\x1b[38;5;225m██╔══╝ \x1b[0m');
|
|
198
|
+
console.log(' \x1b[38;5;111m╚██████╗\x1b[38;5;147m███████╗\x1b[38;5;183m██║ ██║\x1b[38;5;219m╚██████╔╝\x1b[38;5;225m██████╔╝\x1b[38;5;231m███████╗\x1b[0m');
|
|
199
|
+
console.log(' \x1b[38;5;147m╚═════╝\x1b[38;5;183m╚══════╝\x1b[38;5;219m╚═╝ ╚═╝\x1b[38;5;225m ╚═════╝ \x1b[38;5;231m╚═════╝ ╚══════╝\x1b[0m');
|
|
200
|
+
log('\n Claude Code Auto-Update Disabler', 'magenta');
|
|
201
|
+
log(' ' + '='.repeat(50), 'cyan');
|
|
202
|
+
log('', 'reset');
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
// 1. 更新 settings.json 配置
|
|
206
|
+
const configSuccess = updateClaudeSettings();
|
|
207
|
+
if (!configSuccess) {
|
|
208
|
+
log('\n[错误] 配置更新失败', 'red');
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 2. 安装指定版本的 claude-code
|
|
213
|
+
const installSuccess = installClaudeVersion();
|
|
214
|
+
if (!installSuccess) {
|
|
215
|
+
log('\n[警告] 安装失败,但配置已更新', 'yellow');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// 3. 显示完成信息
|
|
219
|
+
showCompletionInfo();
|
|
220
|
+
|
|
221
|
+
} catch (error) {
|
|
222
|
+
log(`\n[错误] 执行过程中出现错误: ${error.message}`, 'red');
|
|
223
|
+
process.exit(1);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 如果直接运行此脚本
|
|
228
|
+
if (require.main === module) {
|
|
229
|
+
main();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 导出函数供其他模块使用
|
|
233
|
+
module.exports = {
|
|
234
|
+
main,
|
|
235
|
+
updateClaudeSettings,
|
|
236
|
+
installClaudeVersion
|
|
237
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pumpkinai-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "PumpkinAI 一键安装配置工具 - 支持 Codex 和 Claude Code",
|
|
5
5
|
"main": "codex-setup.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"codex-config": "./codex-setup.js",
|
|
8
|
-
"claude-config": "./claude-setup.js"
|
|
8
|
+
"claude-config": "./claude-setup.js",
|
|
9
|
+
"claude-au": "./claude-au.js"
|
|
9
10
|
},
|
|
10
11
|
"scripts": {
|
|
11
12
|
"test": "node codex-setup.js",
|