Skip to content

Add in requireAuth to AppHosting CLI commands #8435

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

Merged
merged 1 commit into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/commands/apphosting-backends-create.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import requireInteractive from "../requireInteractive";
import { doSetup } from "../apphosting/backend";
import { ensureApiEnabled } from "../gcp/apphosting";
Expand All @@ -18,6 +19,7 @@ export const command = new Command("apphosting:backends:create")
"specify the service account used to run the server",
"",
)
.before(requireAuth)
.before(ensureApiEnabled)
.before(requireInteractive)
.before(requireTosAcceptance(APPHOSTING_TOS_ID))
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-backends-delete.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { FirebaseError, getError } from "../error";
import { promptOnce } from "../prompt";
import * as utils from "../utils";
Expand All @@ -12,6 +13,7 @@ import * as ora from "ora";
export const command = new Command("apphosting:backends:delete <backend>")
.description("delete a Firebase App Hosting backend")
.withForce()
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (backendId: string, options: Options) => {
const projectId = needProjectId(options);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-backends-get.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { FirebaseError, getError } from "../error";
import { logWarning } from "../utils";
import * as apphosting from "../gcp/apphosting";
import { printBackendsTable } from "./apphosting-backends-list";

export const command = new Command("apphosting:backends:get <backend>")
.description("print info about a Firebase App Hosting backend")
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (backend: string, options: Options) => {
const projectId = needProjectId(options);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-backends-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { datetimeString } from "../utils";
import { FirebaseError } from "../error";
import { logger } from "../logger";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { Options } from "../options";
import * as apphosting from "../gcp/apphosting";
import * as Table from "cli-table3";
Expand All @@ -11,6 +12,7 @@ const TABLE_HEAD = ["Backend", "Repository", "URL", "Primary Region", "Updated D

export const command = new Command("apphosting:backends:list")
.description("list Firebase App Hosting backends")
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (options: Options) => {
const projectId = needProjectId(options);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-builds-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { logger } from "../logger";
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { logWarning } from "../utils";

export const command = new Command("apphosting:builds:create <backendId>")
.description("create a build for an App Hosting backend")
.option("-l, --location <location>", "specify the region of the backend")
.option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "")
.option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main")
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (backendId: string, options: Options) => {
const projectId = needProjectId(options);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-builds-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { logger } from "../logger";
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { logWarning } from "../utils";

export const command = new Command("apphosting:builds:get <backendId> <buildId>")
.description("get a build for an App Hosting backend")
.option("-l, --location <location>", "specify the region of the backend")
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (backendId: string, buildId: string, options: Options) => {
if (options.location !== undefined) {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-rollouts-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as apphosting from "../gcp/apphosting";
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { FirebaseError } from "../error";
import { createRollout } from "../apphosting/rollout";

Expand All @@ -13,6 +14,7 @@ export const command = new Command("apphosting:rollouts:create <backendId>")
)
.option("-g, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -b)")
.withForce("Skip confirmation before creating rollout")
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (backendId: string, options: Options) => {
const projectId = needProjectId(options);
Expand Down
2 changes: 2 additions & 0 deletions src/commands/apphosting-rollouts-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logger } from "../logger";
import { Command } from "../command";
import { Options } from "../options";
import { needProjectId } from "../projectUtils";
import { requireAuth } from "../requireAuth";
import { logWarning } from "../utils";

export const command = new Command("apphosting:rollouts:list <backendId>")
Expand All @@ -11,6 +12,7 @@ export const command = new Command("apphosting:rollouts:list <backendId>")
"-l, --location <location>",
"region of the rollouts (defaults to listing rollouts from all regions)",
)
.before(requireAuth)
.before(apphosting.ensureApiEnabled)
.action(async (backendId: string, options: Options) => {
if (options.location !== undefined) {
Expand Down
Loading