sekura 0.5.1 → 0.5.2
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/dist/steps.js +44 -22
- package/dist/ui.js +6 -2
- package/package.json +1 -1
package/dist/steps.js
CHANGED
|
@@ -222,6 +222,8 @@ export function sayInstallWarnings(list) {
|
|
|
222
222
|
}
|
|
223
223
|
export const repositoriesOf = (list) => (list.installations ?? []).flatMap((i) => i.repositories);
|
|
224
224
|
export const installLink = (s, list) => s.account?.links?.installGithubApp ?? list?.installUrl ?? s.account?.links?.start ?? link('/app/start');
|
|
225
|
+
/** The GitHub accounts the App is installed on, as GitHub names them. */
|
|
226
|
+
const accountsOf = (list) => [...new Set((list.installations ?? []).map((i) => i.account).filter((a) => !!a))];
|
|
225
227
|
export async function ensureApp(s, flags = {}) {
|
|
226
228
|
const interactive = isInteractive(flags);
|
|
227
229
|
const want = flags.want ?? null;
|
|
@@ -234,7 +236,7 @@ export async function ensureApp(s, flags = {}) {
|
|
|
234
236
|
const covered = () => (want ? repos.some((r) => same(r.fullName, want)) : repos.length > 0);
|
|
235
237
|
const url = installLink(s, list);
|
|
236
238
|
if (covered() && !flags.add)
|
|
237
|
-
return { installed: true, found: true, repositories: repos, link: url };
|
|
239
|
+
return { installed: true, found: true, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
238
240
|
const onGithub = /^https:\/\/github\.com\//.test(url);
|
|
239
241
|
say(repos.length
|
|
240
242
|
? want && !covered() ? `${dot} ${want} is not one Sekura can scan yet: the Sekura GitHub App needs access to it.` : `${dot} To give Sekura more repositories, change the Sekura GitHub App's access.`
|
|
@@ -242,7 +244,7 @@ export async function ensureApp(s, flags = {}) {
|
|
|
242
244
|
if (!interactive) {
|
|
243
245
|
say(` Install it and choose repositories at ${url}`);
|
|
244
246
|
if (flags.soft || covered())
|
|
245
|
-
return { installed: repos.length > 0, found: covered(), repositories: repos, link: url };
|
|
247
|
+
return { installed: repos.length > 0, found: covered(), repositories: repos, link: url, accounts: accountsOf(list) };
|
|
246
248
|
throw new Exit(EXIT.accountNotReady, `Sekura cannot scan ${want ?? 'any repository'} yet. Install the Sekura GitHub App at the link above, then run the command again.`, { installUrl: url });
|
|
247
249
|
}
|
|
248
250
|
if (!flags.add) {
|
|
@@ -254,7 +256,7 @@ export async function ensureApp(s, flags = {}) {
|
|
|
254
256
|
],
|
|
255
257
|
});
|
|
256
258
|
if (!go)
|
|
257
|
-
return { installed: repos.length > 0, found: false, repositories: repos, link: url };
|
|
259
|
+
return { installed: repos.length > 0, found: false, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
258
260
|
}
|
|
259
261
|
const opened = openLink(url, { browser: flags.browser });
|
|
260
262
|
say(opened.opened ? ` Opened ${url}` : ` Open ${url}`);
|
|
@@ -270,7 +272,7 @@ export async function ensureApp(s, flags = {}) {
|
|
|
270
272
|
say(found
|
|
271
273
|
? `${tick} ${want ? `Sekura can scan ${want}` : before.size ? 'Sekura can scan more repositories now' : 'The Sekura GitHub App is installed'}`
|
|
272
274
|
: `${dot} Not there yet; you can finish the install later with npx sekura@latest repos --add`);
|
|
273
|
-
return { installed: repos.length > 0, found, repositories: repos, link: url };
|
|
275
|
+
return { installed: repos.length > 0, found, repositories: repos, link: url, accounts: accountsOf(list) };
|
|
274
276
|
}
|
|
275
277
|
export async function ensureRepository(s, flags = {}) {
|
|
276
278
|
const interactive = isInteractive(flags);
|
|
@@ -308,23 +310,43 @@ export async function ensureRepository(s, flags = {}) {
|
|
|
308
310
|
return null;
|
|
309
311
|
throw new Exit(EXIT.error, `Name the repository: Sekura can scan ${scannable.length}, and this folder is not one of them. Run npx sekura@latest repos to list them.`);
|
|
310
312
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
313
|
+
// Always asked, even with one repository (Sudhir, 29 November 2026: "why
|
|
314
|
+
// did it pick nagiclaw?"). With one, the CLI used to choose it and print a
|
|
315
|
+
// tick: the person saw a repository they had not named, from an account
|
|
316
|
+
// they had forgotten the App was on, with no way to pick another. Nothing
|
|
317
|
+
// about which repository is scanned happens without the person choosing it,
|
|
318
|
+
// and the list always offers giving Sekura another one.
|
|
319
|
+
let repos = app.repositories;
|
|
320
|
+
let accounts = app.accounts ?? [];
|
|
321
|
+
for (;;) {
|
|
322
|
+
// Say where the list comes from: an installation the person made long
|
|
323
|
+
// ago, or one on another account they collaborate on, otherwise looks
|
|
324
|
+
// like Sekura found repositories by itself (29 November 2026: the App was
|
|
325
|
+
// still on sekura-ai, and findsekura saw sekura-ai/nagiclaw).
|
|
326
|
+
if (accounts.length)
|
|
327
|
+
say(`${dot} The Sekura GitHub App is installed on ${accounts.join(', ')}; these are the repositories it can reach.`);
|
|
328
|
+
const hereNow = find(here) ? repos.find((r) => same(r.fullName, here)) : undefined;
|
|
329
|
+
const savedNow = repos.find((r) => same(r.fullName, defaultRepository() ?? ''));
|
|
330
|
+
const first = hereNow ?? savedNow;
|
|
331
|
+
const ordered = first ? [first, ...repos.filter((r) => r !== first)] : repos;
|
|
332
|
+
const picked = await select({
|
|
333
|
+
message: 'Which repository should Sekura scan?',
|
|
334
|
+
pageSize: 12,
|
|
335
|
+
choices: [
|
|
336
|
+
...ordered.map((r) => ({
|
|
337
|
+
name: `${r.fullName}${r === hereNow ? ' (this folder)' : r === savedNow ? ' (your default)' : ''}${r.private ? ' (private)' : ''}`,
|
|
338
|
+
value: r.fullName,
|
|
339
|
+
disabled: r.empty ? '(empty, nothing to scan)' : false,
|
|
340
|
+
})),
|
|
341
|
+
{ name: 'Another repository: give Sekura access on GitHub', value: ADD_REPOSITORY },
|
|
342
|
+
{ name: 'Skip for now', value: '' },
|
|
343
|
+
],
|
|
344
|
+
});
|
|
345
|
+
if (picked !== ADD_REPOSITORY)
|
|
346
|
+
return picked ? keep(picked) : null;
|
|
347
|
+
const again = await ensureApp(s, { ...flags, add: true });
|
|
348
|
+
repos = again.repositories;
|
|
349
|
+
accounts = again.accounts ?? accounts;
|
|
314
350
|
}
|
|
315
|
-
const first = hereRepo ?? saved;
|
|
316
|
-
const ordered = first ? [first, ...app.repositories.filter((r) => r !== first)] : app.repositories;
|
|
317
|
-
const picked = await select({
|
|
318
|
-
message: 'Which repository?',
|
|
319
|
-
pageSize: 12,
|
|
320
|
-
choices: [
|
|
321
|
-
...ordered.map((r) => ({
|
|
322
|
-
name: `${r.fullName}${r === hereRepo ? ' (this folder)' : r === saved ? ' (your default)' : ''}${r.private ? ' (private)' : ''}`,
|
|
323
|
-
value: r.fullName,
|
|
324
|
-
disabled: r.empty ? '(empty, nothing to scan)' : false,
|
|
325
|
-
})),
|
|
326
|
-
{ name: 'Skip for now', value: '' },
|
|
327
|
-
],
|
|
328
|
-
});
|
|
329
|
-
return picked ? keep(picked) : null;
|
|
330
351
|
}
|
|
352
|
+
const ADD_REPOSITORY = '\u0000add';
|
package/dist/ui.js
CHANGED
|
@@ -117,15 +117,19 @@ export async function waitFor(message, check, opts = {}) {
|
|
|
117
117
|
* A question that fits is asked as it is; a longer one is printed above,
|
|
118
118
|
* wrapped by us, and the prompt itself is the short form.
|
|
119
119
|
*/
|
|
120
|
+
/** "(y/n)" in lower case, both letters (Sudhir, 29 November 2026: "keep both
|
|
121
|
+
* small case"). The library writes the default in capitals, "(Y/n)"; Enter
|
|
122
|
+
* still takes the default. Dim, as the library draws it. */
|
|
123
|
+
const YES_NO = { style: { defaultAnswer: (text) => `\x1b[2m(${text.toLowerCase()})\x1b[22m` } };
|
|
120
124
|
export async function ask(message, opts) {
|
|
121
125
|
const { confirm } = await import('@inquirer/prompts');
|
|
122
126
|
const cols = Math.max(40, process.stderr.columns || process.stdout.columns || 80);
|
|
123
127
|
// "? " before it and " (Y/n) " after it.
|
|
124
128
|
if (message.length + 10 <= cols)
|
|
125
|
-
return confirm({ message, default: opts.default });
|
|
129
|
+
return confirm({ message, default: opts.default, theme: YES_NO });
|
|
126
130
|
for (const line of wrapWords(message, cols - 4))
|
|
127
131
|
say(` ${line}`);
|
|
128
|
-
return confirm({ message: opts.short, default: opts.default });
|
|
132
|
+
return confirm({ message: opts.short, default: opts.default, theme: YES_NO });
|
|
129
133
|
}
|
|
130
134
|
/** Plain word wrap at `width` characters; a single longer word keeps its own line. */
|
|
131
135
|
export function wrapWords(text, width) {
|
package/package.json
CHANGED