@tkpdx01/ccc 1.3.2 → 1.3.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.
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/commands/import.js +13 -12
package/index.js
CHANGED
package/package.json
CHANGED
package/src/commands/import.js
CHANGED
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
getProfiles,
|
|
10
10
|
getProfilePath,
|
|
11
11
|
setDefaultProfile,
|
|
12
|
-
profileExists
|
|
12
|
+
profileExists,
|
|
13
|
+
createProfileFromTemplate
|
|
13
14
|
} from '../profiles.js';
|
|
14
15
|
import { parseCCSwitchSQL, parseAllApiHubJSON, detectFileFormat } from '../parsers.js';
|
|
15
|
-
import { extractFromText, getDomainName, sanitizeProfileName
|
|
16
|
+
import { extractFromText, getDomainName, sanitizeProfileName } from '../utils.js';
|
|
16
17
|
|
|
17
18
|
// 生成唯一的 profile 名称(如果重复则加后缀 token2, token3...)
|
|
18
19
|
function getUniqueProfileName(baseName, usedNames) {
|
|
@@ -191,9 +192,14 @@ export function importCommand(program) {
|
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
//
|
|
195
|
-
const
|
|
196
|
-
|
|
195
|
+
// 从 provider 中提取 API 凭证
|
|
196
|
+
const config = provider.settingsConfig || {};
|
|
197
|
+
const env = config.env || {};
|
|
198
|
+
const apiKey = env.ANTHROPIC_AUTH_TOKEN || env.ANTHROPIC_API_KEY || config.apiKey || '';
|
|
199
|
+
const apiUrl = env.ANTHROPIC_BASE_URL || config.apiUrl || provider.websiteUrl || '';
|
|
200
|
+
|
|
201
|
+
// 使用主配置模板创建完整的 profile(确保有 env 对象)
|
|
202
|
+
createProfileFromTemplate(profileName, apiUrl, apiKey);
|
|
197
203
|
console.log(chalk.green(`✓ ${profileName}`));
|
|
198
204
|
imported++;
|
|
199
205
|
}
|
|
@@ -318,12 +324,6 @@ export async function interactiveImport() {
|
|
|
318
324
|
const finalApiUrl = apiUrl || 'https://api.anthropic.com';
|
|
319
325
|
const finalApiKey = apiKey || tokens[0] || '';
|
|
320
326
|
|
|
321
|
-
// 影子配置只存储 API 凭证
|
|
322
|
-
const settings = {
|
|
323
|
-
ANTHROPIC_AUTH_TOKEN: finalApiKey,
|
|
324
|
-
ANTHROPIC_BASE_URL: finalApiUrl
|
|
325
|
-
};
|
|
326
|
-
|
|
327
327
|
ensureDirs();
|
|
328
328
|
const profilePath = getProfilePath(profileName);
|
|
329
329
|
|
|
@@ -343,7 +343,8 @@ export async function interactiveImport() {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
// 使用主配置模板创建完整的 profile(确保有 env 对象)
|
|
347
|
+
createProfileFromTemplate(profileName, finalApiUrl, finalApiKey);
|
|
347
348
|
console.log(chalk.green(`\n✓ Profile "${profileName}" 已保存到 ${profilePath}`));
|
|
348
349
|
|
|
349
350
|
// 如果是第一个 profile,设为默认
|