From 20b8490587834e77b69de07819159e47fbbd04a4 Mon Sep 17 00:00:00 2001 From: hairyf Date: Thu, 21 May 2026 15:19:12 +0800 Subject: [PATCH] feat: support brief config file name api.config.ts --- packages/core/src/cli/index.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/core/src/cli/index.ts b/packages/core/src/cli/index.ts index cc580c4..9fe98e5 100644 --- a/packages/core/src/cli/index.ts +++ b/packages/core/src/cli/index.ts @@ -52,16 +52,30 @@ const main = defineCommand({ } const cliOptions = parser.options(options) - const { config } = await loadConfig({ + + const loadConfigOptions = { name: 'genapi', - configFile: 'genapi.config', merger: (defaults: any, ...sources: any[]) => { const merged = merge(defaults, ...sources) return merge(cliOptions, merged) }, + } + + let result = await loadConfig({ + ...loadConfigOptions, + configFile: 'api.config', }) - if (!config) { + if (!result._configFile) { + result = await loadConfig({ + ...loadConfigOptions, + configFile: 'genapi.config', + }) + } + + const { config } = result + + if (!config || !result._configFile) { console.error('Error: genapi config file not found') console.log('\nTip: run "genapi init" to create config file\n') process.exit(1)