( authConfig: AuthConfig, configPath: string | undefined, )
| 120 | } |
| 121 | |
| 122 | export async function initializeWithOnboarding( |
| 123 | authConfig: AuthConfig, |
| 124 | configPath: string | undefined, |
| 125 | ) { |
| 126 | const firstTime = await isFirstTime(); |
| 127 | |
| 128 | if (configPath !== undefined) { |
| 129 | // throw an early error is configPath is invalid or has errors |
| 130 | try { |
| 131 | await loadConfiguration( |
| 132 | authConfig, |
| 133 | configPath, |
| 134 | getApiClient(undefined), |
| 135 | [], |
| 136 | false, |
| 137 | ); |
| 138 | } catch (errorMessage) { |
| 139 | throw new Error( |
| 140 | `Failed to load config from "${configPath}": ${errorMessage}`, |
| 141 | ); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | if (!firstTime) return; |
| 146 | |
| 147 | const wasOnboarded = await runOnboardingFlow(configPath); |
| 148 | if (wasOnboarded) { |
| 149 | await markOnboardingComplete(); |
| 150 | } |
| 151 | } |
no test coverage detected