Skip to content

Commit 203a367

Browse files
committed
Update use of log to be consistent in framework init.
1 parent 59828e9 commit 203a367

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/init/features/frameworks/index.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import * as clc from "colorette";
2-
import * as utils from "../../../utils";
32
import * as repo from "./repo";
43
import * as poller from "../../../operation-poller";
54
import * as gcp from "../../../gcp/frameworks";
5+
import { logBullet, logSuccess } from "../../../utils";
66
import { frameworksOrigin } from "../../../api";
77
import { Backend, BackendOutputOnlyFields } from "../../../gcp/frameworks";
88
import { Repository } from "../../../gcp/cloudbuild";
99
import { API_VERSION } from "../../../gcp/frameworks";
1010
import { FirebaseError } from "../../../error";
11-
import { logger } from "../../../logger";
1211
import { promptOnce } from "../../../prompt";
1312
import { DEFAULT_REGION, ALLOWED_REGIONS } from "./constants";
1413

@@ -25,7 +24,7 @@ const frameworksPollerOptions: Omit<poller.OperationPollerOptions, "operationRes
2524
export async function doSetup(setup: any, projectId: string): Promise<void> {
2625
setup.frameworks = {};
2726

28-
utils.logBullet("First we need a few details to create your backend.");
27+
logBullet("First we need a few details to create your backend.");
2928

3029
await promptOnce(
3130
{
@@ -50,20 +49,16 @@ export async function doSetup(setup: any, projectId: string): Promise<void> {
5049
setup.frameworks
5150
);
5251

53-
utils.logSuccess(`Region set to ${setup.frameworks.region}.`);
52+
logSuccess(`Region set to ${setup.frameworks.region}.\n`);
5453

5554
const backend: Backend | undefined = await getOrCreateBackend(projectId, setup);
5655

5756
if (backend) {
58-
logger.info();
59-
utils.logSuccess(`Successfully created backend:\n ${backend.name}`);
60-
logger.info();
61-
utils.logSuccess(`Your site is being deployed at:\n https://${backend.uri}`);
62-
logger.info();
63-
utils.logSuccess(
64-
`View the rollout status by running:\n firebase backends:get --backend=${backend.name}`
57+
logSuccess(`Successfully created backend:\n ${backend.name}`);
58+
logSuccess(`Your site is being deployed at:\n https://${backend.uri}\n`);
59+
logSuccess(
60+
`View the rollout status by running:\n firebase backends:get --backend=${backend.name}\n`
6561
);
66-
logger.info();
6762
}
6863
}
6964

@@ -91,7 +86,6 @@ export async function getOrCreateBackend(
9186
} catch (err: unknown) {
9287
if ((err as FirebaseError).status === 404) {
9388
const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location);
94-
logger.info();
9589
await promptOnce(
9690
{
9791
name: "branchName",
@@ -102,7 +96,7 @@ export async function getOrCreateBackend(
10296
setup.frameworks
10397
);
10498
const backendDetails = toBackend(cloudBuildConnRepo);
105-
logger.info(clc.bold(`\n${clc.white("===")} Creating your backend`));
99+
logBullet(clc.bold(`${clc.white("===")} Creating your backend`));
106100
return await createBackend(projectId, location, backendDetails, setup.frameworks.serviceName);
107101
} else {
108102
throw new FirebaseError(
@@ -133,7 +127,7 @@ async function getExistingBackend(
133127
setup.frameworks
134128
);
135129
if (setup.frameworks.existingBackend) {
136-
logger.info("Using the existing backend.");
130+
logBullet("Using the existing backend.");
137131
return backend;
138132
}
139133
await promptOnce(

src/init/features/frameworks/repo.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function linkGitHubRepository(
8080
projectId: string,
8181
location: string
8282
): Promise<gcb.Repository> {
83-
logger.info(clc.bold(`\n${clc.yellow("===")} Connect a GitHub repository`));
83+
utils.logBullet(clc.bold(`${clc.yellow("===")} Connect a GitHub repository`));
8484
const existingConns = await listFrameworksConnections(projectId);
8585
if (existingConns.length < 1) {
8686
const grantSuccess = await promptSecretManagerAdminGrant(projectId);
@@ -165,24 +165,25 @@ async function promptRepositoryUri(
165165
async function promptSecretManagerAdminGrant(projectId: string): Promise<Boolean> {
166166
const projectNumber = await getProjectNumber({ projectId });
167167
const cbsaEmail = gcb.serviceAgentEmail(projectNumber);
168-
logger.info(
168+
utils.logBullet(
169169
"To create a new GitHub connection, Secret Manager Admin role (roles/secretmanager.admin) is required on the Cloud Build Service Agent."
170170
);
171171
const grant = await promptOnce({
172172
type: "confirm",
173173
message: "Grant the required role to the Cloud Build Service Agent?",
174174
});
175175
if (!grant) {
176-
logger.info(
176+
utils.logBullet(
177177
"You, or your project administrator, should run the following command to grant the required role:\n\n" +
178+
"You, or your project adminstrator, can run the following command to grant the required role manually:\n\n" +
178179
`\tgcloud projects add-iam-policy-binding ${projectId} \\\n` +
179180
`\t --member="serviceAccount:${cbsaEmail} \\\n` +
180181
`\t --role="roles/secretmanager.admin\n`
181182
);
182183
return false;
183184
}
184185
await rm.addServiceAccountToRoles(projectId, cbsaEmail, ["roles/secretmanager.admin"], true);
185-
logger.info("Successfully granted the required role to the Cloud Build Service Agent!");
186+
utils.logSuccess("Successfully granted the required role to the Cloud Build Service Agent!");
186187
return true;
187188
}
188189

0 commit comments

Comments
 (0)