diff --git a/src/init/features/frameworks/index.ts b/src/init/features/frameworks/index.ts index c78df64d59a..e47d8e8f591 100644 --- a/src/init/features/frameworks/index.ts +++ b/src/init/features/frameworks/index.ts @@ -2,12 +2,7 @@ import * as clc from "colorette"; import * as utils from "../../../utils"; import { logger } from "../../../logger"; import { promptOnce } from "../../../prompt"; -import { - DEFAULT_REGION, - ALLOWED_REGIONS, - DEFAULT_DEPLOY_METHOD, - ALLOWED_DEPLOY_METHODS, -} from "./constants"; +import { DEFAULT_REGION, ALLOWED_REGIONS } from "./constants"; import * as repo from "./repo"; import { Backend, BackendOutputOnlyFields } from "../../../gcp/frameworks"; import { Repository } from "../../../gcp/cloudbuild"; @@ -30,14 +25,14 @@ const frameworksPollerOptions: Omit { setup.frameworks = {}; - utils.logBullet("First we need a few details to create your service."); + utils.logBullet("First we need a few details to create your backend."); await promptOnce( { name: "serviceName", type: "input", default: "acme-inc-web", - message: "Create a name for your service [1-30 characters]", + message: "Create a name for your backend [1-30 characters]", }, setup.frameworks ); @@ -57,22 +52,17 @@ export async function doSetup(setup: any, projectId: string): Promise { utils.logSuccess(`Region set to ${setup.frameworks.region}.`); - logger.info(clc.bold(`\n${clc.white("===")} Deploy Setup`)); - - await promptOnce( - { - name: "deployMethod", - type: "list", - default: DEFAULT_DEPLOY_METHOD, - message: "How do you want to deploy", - choices: ALLOWED_DEPLOY_METHODS, - }, - setup.frameworks - ); - const backend: Backend | undefined = await getOrCreateBackend(projectId, setup); if (backend) { - utils.logSuccess(`Successfully created a backend: ${backend.name}`); + logger.info(); + utils.logSuccess(`Successfully created backend:\n ${backend.name}`); + logger.info(); + utils.logSuccess(`Your site is being deployed at:\n https://${backend.uri}`); + logger.info(); + utils.logSuccess( + `View the rollout status by running:\n firebase backends:get --backend=${backend.name}` + ); + logger.info(); } } @@ -94,22 +84,24 @@ export async function getOrCreateBackend( setup: any ): Promise { const location: string = setup.frameworks.region; - const deployMethod: string = setup.frameworks.deployMethod; try { return await getExistingBackend(projectId, setup, location); } catch (err: unknown) { if ((err as FirebaseError).status === 404) { - logger.info("Creating new backend."); - if (deployMethod === "github") { - const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location); - const backendDetails = toBackend(cloudBuildConnRepo); - return await createBackend( - projectId, - location, - backendDetails, - setup.frameworks.serviceName - ); - } + const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location); + logger.info(); + await promptOnce( + { + name: "branchName", + type: "input", + default: "main", + message: "Which branch do you want to deploy?", + }, + setup.frameworks + ); + const backendDetails = toBackend(cloudBuildConnRepo); + logger.info(clc.bold(`\n${clc.white("===")} Creating your backend`)); + return await createBackend(projectId, location, backendDetails, setup.frameworks.serviceName); } else { throw new FirebaseError( `Failed to get or create a backend using the given initialization details: ${err}` diff --git a/src/init/features/frameworks/repo.ts b/src/init/features/frameworks/repo.ts index 425ef154835..6991bd832f0 100644 --- a/src/init/features/frameworks/repo.ts +++ b/src/init/features/frameworks/repo.ts @@ -5,6 +5,7 @@ import { logger } from "../../../logger"; import * as poller from "../../../operation-poller"; import * as utils from "../../../utils"; import { promptOnce } from "../../../prompt"; +import * as clc from "colorette"; const gcbPollerOptions: Omit = { apiOrigin: cloudbuildOrigin, @@ -51,6 +52,7 @@ export async function linkGitHubRepository( projectId: string, location: string ): Promise { + logger.info(clc.bold(`\n${clc.white("===")} Connect a github repository`)); const connectionId = generateConnectionId(location); await getOrCreateConnection(projectId, location, connectionId); @@ -66,7 +68,8 @@ export async function linkGitHubRepository( } const repo = await getOrCreateRepository(projectId, location, connectionId, remoteUri); - logger.info(`Successfully linked GitHub repository at remote URI ${remoteUri}.`); + logger.info(); + utils.logSuccess(`Successfully linked GitHub repository at remote URI:\n ${remoteUri}`); return repo; } @@ -93,7 +96,7 @@ async function promptRepositoryURI( return await promptOnce({ type: "list", - message: "Which of the following repositories would you like to link?", + message: "Which of the following repositories would you like to deploy?", choices, }); } @@ -104,13 +107,13 @@ async function promptConnectionAuth( location: string, connectionId: string ): Promise { - logger.info(conn.installationState.message); + logger.info("First, log in to GitHub, install and authorize Cloud Build app:"); logger.info(conn.installationState.actionUri); await utils.openInBrowser(conn.installationState.actionUri); await promptOnce({ type: "input", message: - "Press any key once you have authorized the app (Cloud Build) to access your GitHub repo.", + "Press Enter once you have authorized the app (Cloud Build) to access your GitHub repo.", }); return await gcb.getConnection(projectId, location, connectionId); } diff --git a/src/test/init/frameworks/index.spec.ts b/src/test/init/frameworks/index.spec.ts index b6f758988b8..af678372607 100644 --- a/src/test/init/frameworks/index.spec.ts +++ b/src/test/init/frameworks/index.spec.ts @@ -51,6 +51,7 @@ describe("operationsConverter", () => { serviceName: backendId, existingBackend: true, deployMethod: "github", + branchName: "main", }, }; const cloudBuildConnRepo = {