Skip to content

Commit

Permalink
fix: 修复 ESLint 配置导出方式,确保正确导出配置对象
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Dec 26, 2024
1 parent 20283e1 commit 055fe76
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
6 changes: 5 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import antfu, { imports, javascript, jsdoc, node, typescript } from '@antfu/eslint-config';

export default antfu(
/** @type {import('eslint-flat-config-utils').FlatConfigComposer} */
const config = antfu(
{
type: 'app',
stylistic: {
indent: 4,
quotes: 'single',
semi: true,
// @ts-ignore
braceStyle: '1tbs',
},
markdown: false,
Expand Down Expand Up @@ -40,3 +42,5 @@ export default antfu(
},
},
);

export default config;
22 changes: 22 additions & 0 deletions packages/lib/core/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function createAgentUserConfig(): AgentUserConfig {
);
}

function fixApiBase(base: string): string {
return base.replace(/\/+$/, '');
}

export const ENV_KEY_MAPPER: Record<string, AgentUserConfigKey> = {
CHAT_MODEL: 'OPENAI_CHAT_MODEL',
API_KEY: 'OPENAI_API_KEY',
Expand Down Expand Up @@ -121,6 +125,7 @@ class Environment extends EnvironmentConfig {
]);
ConfigMerger.merge(this.USER_CONFIG, source);
this.migrateOldEnv(source);
this.fixAgentUserConfigApiBase();
this.USER_CONFIG.DEFINE_KEYS = [];
this.I18N = loadI18n(this.LANGUAGE.toLowerCase());
}
Expand Down Expand Up @@ -195,6 +200,23 @@ class Environment extends EnvironmentConfig {
this.USER_CONFIG.AZURE_API_VERSION = url.searchParams.get('api-version') || '2024-06-01';
}
}

private fixAgentUserConfigApiBase() {
const keys: AgentUserConfigKey[] = [
'OPENAI_API_BASE',
'GOOGLE_API_BASE',
'MISTRAL_API_BASE',
'COHERE_API_BASE',
'ANTHROPIC_API_BASE',
];
for (const key of keys) {
const base = this.USER_CONFIG[key];
if (this.USER_CONFIG[key] && typeof base === 'string') {
this.USER_CONFIG[key] = fixApiBase(base) as any;
}
}
this.TELEGRAM_API_DOMAIN = fixApiBase(this.TELEGRAM_API_DOMAIN);
}
}

export const ENV = new Environment();
5 changes: 1 addition & 4 deletions packages/lib/core/src/telegram/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ class APIClientBase {
constructor(token: string, baseURL?: string) {
this.token = token;
if (baseURL) {
this.baseURL = baseURL;
}
while (this.baseURL.endsWith('/')) {
this.baseURL = this.baseURL.slice(0, -1);
this.baseURL = baseURL.replace(/\/+$/, '');
}
this.request = this.request.bind(this);
this.requestJSON = this.requestJSON.bind(this);
Expand Down
1 change: 0 additions & 1 deletion wrangler-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ main = './dist/index.js' # 先使用vite编译 然后再使用编译产物部
#main = './packages/apps/workers-next/dist/index.js'
#main = './packages/apps/workers-next/src/index.ts'
workers_dev = true
compatibility_flags = ["nodejs_compat_v2"]
# 这里的 id 为必填项 请填写你的 kv namespace id
# preview_id 只在调试时使用,不需要请删除
kv_namespaces = [
Expand Down

0 comments on commit 055fe76

Please sign in to comment.