MCPcopy Create free account
hub / github.com/lightdash/lightdash / pickInstallation

Function pickInstallation

scripts/dev-github-reconcile.cjs:94–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92 return all;
93}
94async 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
113async function orgUuid(client) {
114 if (process.env.ORG_UUID) return process.env.ORG_UUID;

Callers 1

stepInstallationFunction · 0.85

Calls 3

listInstallationsFunction · 0.85
errorMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected