pumpkinai-config 1.5.1 → 1.5.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/claude-ide.js +38 -15
  2. package/package.json +1 -1
package/claude-ide.js CHANGED
@@ -65,6 +65,12 @@ function getSettingsPaths() {
65
65
  }
66
66
  }
67
67
 
68
+ // 检查 IDE 是否安装(检查配置目录是否存在)
69
+ function checkIDEInstalled(settingsPath) {
70
+ const dir = path.dirname(settingsPath);
71
+ return fs.existsSync(dir);
72
+ }
73
+
68
74
  // 读取 JSON 文件(带注释处理)
69
75
  function readJsonFile(filePath) {
70
76
  try {
@@ -130,24 +136,24 @@ function configureIDESettings(settingsPath, ideName, apiKey) {
130
136
  }
131
137
  ];
132
138
 
133
- // 获取或创建 claude.env 数组
134
- if (!settings['claude.env']) {
135
- settings['claude.env'] = [];
139
+ // 获取或创建 claudeCode.environmentVariables 数组
140
+ if (!settings['claudeCode.environmentVariables']) {
141
+ settings['claudeCode.environmentVariables'] = [];
136
142
  }
137
143
 
138
144
  // 更新环境变量
139
145
  for (const envVar of envVarsToAdd) {
140
- const existingIndex = settings['claude.env'].findIndex(
146
+ const existingIndex = settings['claudeCode.environmentVariables'].findIndex(
141
147
  item => item.name === envVar.name
142
148
  );
143
149
 
144
150
  if (existingIndex >= 0) {
145
151
  // 更新已存在的环境变量
146
- settings['claude.env'][existingIndex] = envVar;
152
+ settings['claudeCode.environmentVariables'][existingIndex] = envVar;
147
153
  log(`[更新] ${envVar.name}`, 'yellow');
148
154
  } else {
149
155
  // 添加新的环境变量
150
- settings['claude.env'].push(envVar);
156
+ settings['claudeCode.environmentVariables'].push(envVar);
151
157
  log(`[添加] ${envVar.name}`, 'green');
152
158
  }
153
159
  }
@@ -202,9 +208,23 @@ async function main() {
202
208
  // 获取配置文件路径
203
209
  const paths = getSettingsPaths();
204
210
 
205
- log('[信息] 检测到的配置文件路径:', 'cyan');
206
- log(` VSCode: ${paths.vscode}`, 'reset');
207
- log(` Cursor: ${paths.cursor}`, 'reset');
211
+ // 检查哪些 IDE 已安装
212
+ const vscodeInstalled = checkIDEInstalled(paths.vscode);
213
+ const cursorInstalled = checkIDEInstalled(paths.cursor);
214
+
215
+ if (!vscodeInstalled && !cursorInstalled) {
216
+ log('[错误] 未检测到 VSCode 或 Cursor 安装', 'red');
217
+ log(' 请先安装 VSCode 或 Cursor', 'yellow');
218
+ process.exit(1);
219
+ }
220
+
221
+ log('[信息] 检测到的 IDE:', 'cyan');
222
+ if (vscodeInstalled) {
223
+ log(` VSCode: ${paths.vscode}`, 'green');
224
+ }
225
+ if (cursorInstalled) {
226
+ log(` Cursor: ${paths.cursor}`, 'green');
227
+ }
208
228
 
209
229
  // 显示粘贴提示
210
230
  if (process.platform === 'win32') {
@@ -222,14 +242,17 @@ async function main() {
222
242
 
223
243
  const configuredIDEs = [];
224
244
 
225
- // 配置 VSCode
226
- if (configureIDESettings(paths.vscode, 'VSCode', apiKey)) {
227
- configuredIDEs.push('VSCode');
245
+ // 只配置已安装的 IDE
246
+ if (vscodeInstalled) {
247
+ if (configureIDESettings(paths.vscode, 'VSCode', apiKey)) {
248
+ configuredIDEs.push('VSCode');
249
+ }
228
250
  }
229
251
 
230
- // 配置 Cursor
231
- if (configureIDESettings(paths.cursor, 'Cursor', apiKey)) {
232
- configuredIDEs.push('Cursor');
252
+ if (cursorInstalled) {
253
+ if (configureIDESettings(paths.cursor, 'Cursor', apiKey)) {
254
+ configuredIDEs.push('Cursor');
255
+ }
233
256
  }
234
257
 
235
258
  if (configuredIDEs.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumpkinai-config",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "PumpkinAI 一键安装配置工具 - 支持 Codex 和 Claude Code",
5
5
  "main": "codex-setup.js",
6
6
  "bin": {