MCPcopy Create free account
hub / github.com/firebase/firebase-tools / promptForRepo

Function promptForRepo

src/init/features/hosting/github.ts:451–504  ·  view source on GitHub ↗
(
  options: any,
  ghAccessToken: string,
)

Source from the content-addressed store, hash-verified

449}
450
451async function promptForRepo(
452 options: any,
453 ghAccessToken: string,
454): Promise<{ repo: string; key: string; keyId: string }> {
455 let key = "";
456 let keyId = "";
457 const repo =
458 options.repo ||
459 (await input({
460 default: defaultGithubRepo(), // TODO look at github origin
461 message:
462 "For which GitHub repository would you like to set up a GitHub workflow? (format: user/repository)",
463 validate: async (repo: string) => {
464 try {
465 const { body } = await githubApiClient.get<{ key: string; key_id: string }>(
466 `/repos/${repo}/actions/secrets/public-key`,
467 {
468 headers: { Authorization: `token ${ghAccessToken}`, "User-Agent": "Firebase CLI" },
469 queryParams: { type: "owner" },
470 },
471 );
472 key = body.key;
473 keyId = body.key_id;
474 } catch (e: any) {
475 if ([403, 404].includes(e.status)) {
476 logger.info();
477 logger.info();
478 logWarning(
479 "The provided authorization cannot be used with this repository. If this repository is in an organization, did you remember to grant access?",
480 "error",
481 );
482 logger.info();
483 logLabeledBullet(
484 "Action required",
485 `Visit this URL to ensure access has been granted to the appropriate organization(s) for the Firebase CLI GitHub OAuth App:`,
486 );
487 logger.info(
488 bold(
489 underline(
490 `https://github.com/settings/connections/applications/${githubClientId()}`,
491 ),
492 ),
493 );
494 logger.info();
495 }
496 return false;
497 }
498 return true;
499 },
500 }));
501 options.repo = repo;
502
503 return { repo, key, keyId };
504}
505
506async function promptForBuildScript(
507 useWebFrameworks: boolean | undefined,

Callers 1

initGitHubFunction · 0.85

Calls 5

inputFunction · 0.90
logWarningFunction · 0.90
logLabeledBulletFunction · 0.90
githubClientIdFunction · 0.90
defaultGithubRepoFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…