mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
feat: add serverUrl configuration support with settings.json fallback
Implement serverUrl initialization following the cliApiToken design pattern: - Environment variable HAPI_SERVER_URL (highest priority, allows temporary override) - settings.json serverUrl field (user persistent configuration) - Default value 'http://localhost:3006' (fallback) Changes: - Add serverUrl field to Settings interface (persistence.ts) - Convert serverUrl to private property with getter/setter (configuration.ts) - Create initializeServerUrl module to load from settings (serverUrlInit.ts) - Integrate serverUrl initialization in tokenInit flow (tokenInit.ts) - Skip auto-start when serverUrl is configured in settings (autoStartServer.ts)
This commit is contained in:
@@ -12,12 +12,16 @@ import { stdin as input, stdout as output } from 'node:process'
|
||||
import chalk from 'chalk'
|
||||
import { configuration } from '@/configuration'
|
||||
import { readSettings, updateSettings } from '@/persistence'
|
||||
import { initializeServerUrl } from '@/ui/serverUrlInit'
|
||||
|
||||
/**
|
||||
* Initialize CLI API token
|
||||
* Must be called before any API operations
|
||||
*/
|
||||
export async function initializeToken(): Promise<void> {
|
||||
// Initialize server URL first (env > settings.json > default)
|
||||
await initializeServerUrl()
|
||||
|
||||
// 1. Environment variable has highest priority (allows temporary override)
|
||||
if (configuration.cliApiToken) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user