@rathnasgala/cli 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/package.json +1 -1
- package/src/commands/init.js +25 -7
package/README.md
CHANGED
|
@@ -34,6 +34,9 @@ It signs you in to Gala and to GitHub if you are not already, creates the reposi
|
|
|
34
34
|
publication, and leaves a working checkout in the folder. When it finishes it prints the address
|
|
35
35
|
your publication will live at.
|
|
36
36
|
|
|
37
|
+
On the first run, it opens GitHub's Gala App installation page. Choose the account Gala may use,
|
|
38
|
+
finish the installation, and return to the terminal; the same command resumes automatically.
|
|
39
|
+
|
|
37
40
|
If the Gala GitHub App has not been given access to the new repository, it says so and links to the
|
|
38
41
|
one page that grants it — GitHub has no way for an app to grant itself access, so that click is
|
|
39
42
|
unavoidable. Everything else is automatic.
|
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -160,14 +160,32 @@ async function createPublication({ terminal, api, capability, name, github, inst
|
|
|
160
160
|
throw new Error(`Gala still cannot reach the repository for ${name}.`);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export async function publicationAccount({
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
export async function publicationAccount({
|
|
164
|
+
terminal,
|
|
165
|
+
api,
|
|
166
|
+
capability,
|
|
167
|
+
pause = (milliseconds) => new Promise((resolve) => { setTimeout(resolve, milliseconds); })
|
|
168
|
+
}) {
|
|
169
|
+
let state = await api.githubInstallationAccounts({ capability });
|
|
170
|
+
let accounts = Array.isArray(state?.accounts) ? state.accounts : [];
|
|
166
171
|
if (accounts.length === 0) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
);
|
|
172
|
+
const url = state?.installationUrl ?? GITHUB_APP_INSTALLATION_URL;
|
|
173
|
+
terminal.blank();
|
|
174
|
+
terminal.step('Connect Gala to a GitHub account');
|
|
175
|
+
terminal.note('GitHub will ask which account and repositories Gala may use');
|
|
176
|
+
terminal.openUrl(url);
|
|
177
|
+
if (!await terminal.waitForEnter('Once the Gala GitHub App is installed')) {
|
|
178
|
+
throw new Error(`Install or request the Gala GitHub App at ${url}, then run this again.`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (let attempt = 0; attempt < 5 && accounts.length === 0; attempt += 1) {
|
|
182
|
+
if (attempt > 0) await pause(1000);
|
|
183
|
+
state = await api.githubInstallationAccounts({ capability });
|
|
184
|
+
accounts = Array.isArray(state?.accounts) ? state.accounts : [];
|
|
185
|
+
}
|
|
186
|
+
if (accounts.length === 0) {
|
|
187
|
+
throw new Error(`Gala still cannot see a GitHub App installation. Check ${url}, then run this again.`);
|
|
188
|
+
}
|
|
171
189
|
}
|
|
172
190
|
const personal = accounts.find((account) => account?.organization === false);
|
|
173
191
|
if (personal) return personal;
|