(params: { cwd?: string })
| 14 | import { initializeDirenv } from './init-direnv' |
| 15 | |
| 16 | export async function initializeApp(params: { cwd?: string }): Promise<void> { |
| 17 | if (params.cwd) { |
| 18 | process.chdir(params.cwd) |
| 19 | } |
| 20 | const baseCwd = process.cwd() |
| 21 | setProjectRoot(baseCwd) |
| 22 | |
| 23 | // Initialize analytics before direnv, because direnv uses the logger |
| 24 | // which calls trackEvent — analytics must be ready first. |
| 25 | try { |
| 26 | initAnalytics() |
| 27 | } catch (error) { |
| 28 | console.debug('Failed to initialize analytics:', error) |
| 29 | } |
| 30 | |
| 31 | // Initialize direnv environment before anything else |
| 32 | initializeDirenv() |
| 33 | |
| 34 | enableMapSet() |
| 35 | initializeThemeStore() |
| 36 | enableManualThemeRefresh() |
| 37 | initTimestampFormatter() |
| 38 | |
| 39 | // Compute the hardware-based fingerprint in the background so it's ready |
| 40 | // by the time the user finishes reading the login prompt. |
| 41 | void getFingerprintId() |
| 42 | |
| 43 | // Refresh ChatGPT OAuth credentials in the background if they exist |
| 44 | if (CHATGPT_OAUTH_ENABLED) { |
| 45 | const chatGptCredentials = getChatGptOAuthCredentials() |
| 46 | if (chatGptCredentials) { |
| 47 | getValidChatGptOAuthCredentials().catch(() => { |
| 48 | // Best-effort background refresh. |
| 49 | }) |
| 50 | } |
| 51 | } |
| 52 | } |
no test coverage detected