( options: any, ghAccessToken: string, )
| 449 | } |
| 450 | |
| 451 | async 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 | |
| 506 | async function promptForBuildScript( |
| 507 | useWebFrameworks: boolean | undefined, |
no test coverage detected
searching dependent graphs…