diff --git a/src/commands/apphosting-backends-create.ts b/src/commands/apphosting-backends-create.ts index 440870fe853..3c7492c503d 100644 --- a/src/commands/apphosting-backends-create.ts +++ b/src/commands/apphosting-backends-create.ts @@ -6,6 +6,7 @@ import { doSetup } from "../apphosting/backend"; import { ensureApiEnabled } from "../gcp/apphosting"; import { APPHOSTING_TOS_ID } from "../gcp/firedata"; import { requireTosAcceptance } from "../requireTosAcceptance"; +import { logWarning } from "../utils"; export const command = new Command("apphosting:backends:create") .description("create a Firebase App Hosting backend") @@ -13,7 +14,7 @@ export const command = new Command("apphosting:backends:create") "-a, --app ", "specify an existing Firebase web app's ID to associate your App Hosting backend with", ) - .option("-l, --location ", "specify the location of the backend", "") + .option("-l, --location ", "specify the location of the backend") .option( "-s, --service-account ", "specify the service account used to run the server", @@ -23,9 +24,15 @@ export const command = new Command("apphosting:backends:create") .before(requireInteractive) .before(requireTosAcceptance(APPHOSTING_TOS_ID)) .action(async (options: Options) => { + if (options.location !== undefined) { + logWarning( + "--location is being removed in the next major release. " + + "The CLI will prompt for a Primary Region where appropriate.", + ); + } const projectId = needProjectId(options); const webAppId = options.app; - const location = options.location; + const location = options.location as string; const serviceAccount = options.serviceAccount; await doSetup( diff --git a/src/commands/apphosting-backends-delete.ts b/src/commands/apphosting-backends-delete.ts index d6caed07346..624427ec468 100644 --- a/src/commands/apphosting-backends-delete.ts +++ b/src/commands/apphosting-backends-delete.ts @@ -15,12 +15,15 @@ import * as ora from "ora"; export const command = new Command("apphosting:backends:delete ") .description("delete a Firebase App Hosting backend") - .option("-l, --location ", "specify the location of the backend", "-") + .option("-l, --location ", "specify the location of the backend") .withForce() .before(apphosting.ensureApiEnabled) .action(async (backendId: string, options: Options) => { const projectId = needProjectId(options); - let location = options.location as string; + if (options.location !== undefined) { + utils.logWarning("--location is being removed in the next major release."); + } + let location = (options.location as string) ?? "-"; let backend: apphosting.Backend; if (location === "-" || location === "") { backend = await getBackendForAmbiguousLocation( diff --git a/src/commands/apphosting-backends-get.ts b/src/commands/apphosting-backends-get.ts index c4f5f1dd083..b905f5ae2ce 100644 --- a/src/commands/apphosting-backends-get.ts +++ b/src/commands/apphosting-backends-get.ts @@ -8,11 +8,14 @@ import { printBackendsTable } from "./apphosting-backends-list"; export const command = new Command("apphosting:backends:get ") .description("print info about a Firebase App Hosting backend") - .option("-l, --location ", "backend location", "-") + .option("-l, --location ", "backend location") .before(apphosting.ensureApiEnabled) .action(async (backend: string, options: Options) => { const projectId = needProjectId(options); - const location = options.location as string; + if (options.location !== undefined) { + logWarning("--location is being removed in the next major release."); + } + const location = (options.location as string) ?? "-"; let backendsList: apphosting.Backend[] = []; try { diff --git a/src/commands/apphosting-backends-list.ts b/src/commands/apphosting-backends-list.ts index 3bfa44b9733..24953b97d8c 100644 --- a/src/commands/apphosting-backends-list.ts +++ b/src/commands/apphosting-backends-list.ts @@ -6,16 +6,20 @@ import { needProjectId } from "../projectUtils"; import { Options } from "../options"; import * as apphosting from "../gcp/apphosting"; import * as Table from "cli-table3"; +import { logWarning } from "../utils"; const TABLE_HEAD = ["Backend", "Repository", "URL", "Location", "Updated Date"]; export const command = new Command("apphosting:backends:list") .description("list Firebase App Hosting backends") - .option("-l, --location ", "list backends in the specified location", "-") + .option("-l, --location ", "list backends in the specified location") .before(apphosting.ensureApiEnabled) .action(async (options: Options) => { + if (options.location !== undefined) { + logWarning("--location is being removed in the next major release."); + } const projectId = needProjectId(options); - const location = options.location as string; + const location = (options.location as string) ?? "-"; let backendRes: apphosting.ListBackendsResponse; try { backendRes = await apphosting.listBackends(projectId, location); diff --git a/src/commands/apphosting-builds-create.ts b/src/commands/apphosting-builds-create.ts index 2050917c92f..8d8fcec874d 100644 --- a/src/commands/apphosting-builds-create.ts +++ b/src/commands/apphosting-builds-create.ts @@ -3,16 +3,20 @@ import { logger } from "../logger"; import { Command } from "../command"; import { Options } from "../options"; import { needProjectId } from "../projectUtils"; +import { logWarning } from "../utils"; export const command = new Command("apphosting:builds:create ") .description("create a build for an App Hosting backend") - .option("-l, --location ", "specify the region of the backend", "us-central1") + .option("-l, --location ", "specify the region of the backend") .option("-i, --id ", "id of the build (defaults to autogenerating a random id)", "") .option("-b, --branch ", "repository branch to deploy (defaults to 'main')", "main") .before(apphosting.ensureApiEnabled) .action(async (backendId: string, options: Options) => { const projectId = needProjectId(options); - const location = options.location as string; + if (options.location !== undefined) { + logWarning("--location is being removed in the next major release."); + } + const location = (options.location as string) ?? "us-central1"; const buildId = (options.buildId as string) || (await apphosting.getNextRolloutId(projectId, location, backendId)); diff --git a/src/commands/apphosting-builds-get.ts b/src/commands/apphosting-builds-get.ts index 1889b50029c..7ea57fc32b2 100644 --- a/src/commands/apphosting-builds-get.ts +++ b/src/commands/apphosting-builds-get.ts @@ -3,12 +3,17 @@ import { logger } from "../logger"; import { Command } from "../command"; import { Options } from "../options"; import { needProjectId } from "../projectUtils"; +import { logWarning } from "../utils"; export const command = new Command("apphosting:builds:get ") .description("get a build for an App Hosting backend") - .option("-l, --location ", "specify the region of the backend", "us-central1") + .option("-l, --location ", "specify the region of the backend") .before(apphosting.ensureApiEnabled) .action(async (backendId: string, buildId: string, options: Options) => { + if (options.location !== undefined) { + logWarning("--location is being removed in the next major release."); + } + options.location = options.location ?? "us-central"; const projectId = needProjectId(options); const location = options.location as string; const build = await apphosting.getBuild(projectId, location, backendId, buildId); diff --git a/src/commands/apphosting-rollouts-create.ts b/src/commands/apphosting-rollouts-create.ts index 5b827aa0f2b..ab03b13464b 100644 --- a/src/commands/apphosting-rollouts-create.ts +++ b/src/commands/apphosting-rollouts-create.ts @@ -4,10 +4,11 @@ import { Options } from "../options"; import { needProjectId } from "../projectUtils"; import { FirebaseError } from "../error"; import { createRollout } from "../apphosting/rollout"; +import { logWarning } from "../utils"; export const command = new Command("apphosting:rollouts:create ") .description("create a rollout using a build for an App Hosting backend") - .option("-l, --location ", "specify the region of the backend", "-") + .option("-l, --location ", "specify the region of the backend") .option( "-b, --git-branch ", "repository branch to deploy (mutually exclusive with -g)", @@ -17,7 +18,10 @@ export const command = new Command("apphosting:rollouts:create ") .before(apphosting.ensureApiEnabled) .action(async (backendId: string, options: Options) => { const projectId = needProjectId(options); - const location = options.location as string; + if (options.location !== undefined) { + logWarning("--location is being removed in the next major release."); + } + const location = (options.location as string) ?? "-"; const branch = options.gitBranch as string | undefined; const commit = options.gitCommit as string | undefined; diff --git a/src/commands/apphosting-rollouts-list.ts b/src/commands/apphosting-rollouts-list.ts index 5e3ac8c5350..2b5c1bd7a40 100644 --- a/src/commands/apphosting-rollouts-list.ts +++ b/src/commands/apphosting-rollouts-list.ts @@ -3,18 +3,21 @@ import { logger } from "../logger"; import { Command } from "../command"; import { Options } from "../options"; import { needProjectId } from "../projectUtils"; +import { logWarning } from "../utils"; export const command = new Command("apphosting:rollouts:list ") .description("list rollouts of an App Hosting backend") .option( "-l, --location ", "region of the rollouts (defaults to listing rollouts from all regions)", - "-", ) .before(apphosting.ensureApiEnabled) .action(async (backendId: string, options: Options) => { + if (options.location !== undefined) { + logWarning("--location is being removed in the next major release."); + } const projectId = needProjectId(options); - const location = options.location as string; + const location = (options.location as string) ?? "-"; const rollouts = await apphosting.listRollouts(projectId, location, backendId); if (rollouts.unreachable) { logger.error(