Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that dependent APIs are enabled during Backend creation flow. #6595

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/init/features/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { FirebaseError } from "../../../error";
import { promptOnce } from "../../../prompt";
import { DEFAULT_REGION, ALLOWED_REGIONS } from "./constants";
import { ensure } from "../../../ensureApiEnabled";

const frameworksPollerOptions: Omit<poller.OperationPollerOptions, "operationResourceName"> = {
apiOrigin: frameworksOrigin,
Expand All @@ -21,12 +22,19 @@
/**
* Setup new frameworks project.
*/
export async function doSetup(setup: any, projectId: string): Promise<void> {

Check warning on line 25 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
setup.frameworks = {};

Check warning on line 26 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .frameworks on an `any` value

await Promise.all([
ensure(projectId, "cloudbuild.googleapis.com", "frameworks", true),
ensure(projectId, "secretmanager.googleapis.com", "frameworks", true),
ensure(projectId, "run.googleapis.com", "frameworks", true),
ensure(projectId, "artifactregistry.googleapis.com", "frameworks", true),
]);

logBullet("First we need a few details to create your backend.");

const location = await promptOnce({

Check warning on line 37 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
name: "region",
type: "list",
default: DEFAULT_REGION,
Expand All @@ -36,10 +44,10 @@
choices: ALLOWED_REGIONS,
});

logSuccess(`Region set to ${location}.\n`);

Check warning on line 47 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression

let backendId: string;
while (true) {

Check warning on line 50 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected constant condition
backendId = await promptOnce({
name: "backendId",
type: "input",
Expand All @@ -47,14 +55,14 @@
message: "Create a name for your backend [1-30 characters]",
});
try {
await gcp.getBackend(projectId, location, backendId);

Check warning on line 58 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string`
} catch (err: any) {

Check warning on line 59 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err.status === 404) {

Check warning on line 60 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value
break;
}
throw new FirebaseError(
`Failed to check if backend with id ${backendId} already exists in ${location}`,

Check warning on line 64 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "any" of template literal expression
{ original: err }

Check warning on line 65 in src/init/features/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
);
}
logWarning(`Backend with id ${backendId} already exists in ${location}`);
Expand Down
Loading