()
| 92 | return all; |
| 93 | } |
| 94 | async function pickInstallation() { |
| 95 | const list = await listInstallations(); |
| 96 | if (!list.length) throw new Error('App has no installations — install the dev GitHub App on your account first'); |
| 97 | const want = (process.env.GH_ACCOUNT || '').trim(); |
| 98 | if (want) { |
| 99 | const chosen = list.find((i) => i.account && i.account.login === want); |
| 100 | if (!chosen) { |
| 101 | const accts = list.map((i) => i.account && i.account.login).filter(Boolean).join(', '); |
| 102 | throw new Error(`GH_ACCOUNT='${want}' has no installation of this App. Available: ${accts}`); |
| 103 | } |
| 104 | return chosen; |
| 105 | } |
| 106 | // No account configured: the shared dev App has many installs, so guessing is unsafe. |
| 107 | if (list.length === 1) return list[0]; |
| 108 | const accts = list.map((i) => `${i.account && i.account.login}(${i.repository_selection})`).join(', '); |
| 109 | console.error(`WARN: GH_ACCOUNT not set and ${list.length} installations exist — guessing. Set githubAccount in ~/.lightdash/dev-secrets.local.json (or GH_ACCOUNT). Candidates: ${accts}`); |
| 110 | return list.find((i) => i.repository_selection === 'all') || list[0]; |
| 111 | } |
| 112 | |
| 113 | async function orgUuid(client) { |
| 114 | if (process.env.ORG_UUID) return process.env.ORG_UUID; |
no test coverage detected