From 9436026a5bf738c48f5c5961abbddce9ca1883ff Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 22 Nov 2023 18:18:27 -0800 Subject: [PATCH] Fix tiny bug where list command failed when given no backend resources. --- src/commands/frameworks-backends-list.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/commands/frameworks-backends-list.ts b/src/commands/frameworks-backends-list.ts index 0c3420a7941..253c7d00dad 100644 --- a/src/commands/frameworks-backends-list.ts +++ b/src/commands/frameworks-backends-list.ts @@ -8,14 +8,7 @@ import { bold } from "colorette"; const Table = require("cli-table"); const COLUMN_LENGTH = 20; -const TABLE_HEAD = [ - "Backend Id", - "Repository Name", - "Location", - "URL", - "Created Date", - "Updated Date", -]; +const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"]; export const command = new Command("backends:list") .description("List backends of a Firebase project.") .option("-l, --location ", "App Backend location", "-") @@ -27,11 +20,11 @@ export const command = new Command("backends:list") style: { head: ["green"] }, }); table.colWidths = COLUMN_LENGTH; - const backendsList: gcp.ListBackendsResponse[] = []; + const backendsList: gcp.Backend[] = []; try { const backendsPerRegion = await gcp.listBackends(projectId, location); - backendsList.push(backendsPerRegion); - populateTable(backendsPerRegion, location, table); + backendsList.push(...backendsPerRegion.backends); + populateTable(backendsList, table); logger.info(); logger.info(`Backends for project ${bold(projectId)}`); @@ -47,8 +40,8 @@ export const command = new Command("backends:list") return backendsList; }); -function populateTable(backendsLists: gcp.ListBackendsResponse, location: string, table: any) { - for (const backend of backendsLists.backends) { +function populateTable(backends: gcp.Backend[], table: any) { + for (const backend of backends) { const [location, , backendId] = backend.name.split("/").slice(3, 6); const entry = [ backendId,