* Resolve the endpoint the summary should report, using the SAME precedence * `runConfigure` uses to pick (and persist) the endpoint: * --endpoint-url > TESTSPRITE_API_URL env > existing profile apiUrl > prod default. * Reporting a flat prod default would falsely claim a prod target after
(opts: InitOptions, deps: InitDeps)
| 35 | * is written, so the persisted apiUrl is reflected faithfully. |
| 36 | */ |
| 37 | function resolveReportedEndpoint(opts: InitOptions, deps: InitDeps): string { |
| 38 | const env = deps.env ?? process.env; |
| 39 | const envApiUrl = env.TESTSPRITE_API_URL?.trim() || undefined; |
| 40 | let existing: string | undefined; |
| 41 | try { |
| 42 | existing = readProfile(opts.profile, { path: deps.credentialsPath })?.apiUrl; |
| 43 | } catch { |
| 44 | existing = undefined; |
| 45 | } |
| 46 | return opts.endpointUrl ?? envApiUrl ?? existing ?? DEFAULT_API_URL; |
| 47 | } |
| 48 | |
| 49 | // --------------------------------------------------------------------------- |
| 50 | // Types |
no test coverage detected