(options: {
flags: CliFlags;
stateDir: string;
cwd: string;
env?: EnvMap;
fetchImpl?: typeof fetch;
})
| 17 | }; |
| 18 | |
| 19 | export async function resolveCloudConnectProfile(options: { |
| 20 | flags: CliFlags; |
| 21 | stateDir: string; |
| 22 | cwd: string; |
| 23 | env?: EnvMap; |
| 24 | fetchImpl?: typeof fetch; |
| 25 | }): Promise<{ flags: CliFlags; remoteConfigPath: string }> { |
| 26 | const auth = await resolveCloudAccessForConnect({ |
| 27 | stateDir: options.stateDir, |
| 28 | flags: options.flags, |
| 29 | env: options.env, |
| 30 | io: { |
| 31 | env: options.env, |
| 32 | fetch: options.fetchImpl, |
| 33 | }, |
| 34 | }); |
| 35 | const profile = await fetchConnectionProfile({ |
| 36 | cloudBaseUrl: auth.cloudBaseUrl, |
| 37 | accessToken: auth.accessToken, |
| 38 | fetchImpl: options.fetchImpl, |
| 39 | }); |
| 40 | const clientId = buildCloudClientId({ |
| 41 | stateDir: options.stateDir, |
| 42 | cloudBaseUrl: auth.cloudBaseUrl, |
| 43 | daemonBaseUrl: typeof profile.daemonBaseUrl === 'string' ? profile.daemonBaseUrl : '', |
| 44 | session: options.flags.session, |
| 45 | }); |
| 46 | return persistAndResolveGeneratedProfile({ |
| 47 | stateDir: options.stateDir, |
| 48 | provider: 'cloud', |
| 49 | profile: { |
| 50 | ...profile, |
| 51 | leaseProvider: profile.leaseProvider ?? 'cloud', |
| 52 | clientId: profile.clientId ?? clientId, |
| 53 | runId: profile.runId ?? `cloud-${clientId}`, |
| 54 | }, |
| 55 | cwd: options.cwd, |
| 56 | env: options.env, |
| 57 | flags: options.flags, |
| 58 | extraFlags: { |
| 59 | daemonAuthToken: auth.accessToken, |
| 60 | }, |
| 61 | }); |
| 62 | } |
| 63 | |
| 64 | async function fetchConnectionProfile(options: { |
| 65 | cloudBaseUrl: string; |
no test coverage detected