diff --git a/src/dataconnect/build.ts b/src/dataconnect/build.ts index 8f9bde7f7d3..7146d68737e 100644 --- a/src/dataconnect/build.ts +++ b/src/dataconnect/build.ts @@ -39,7 +39,7 @@ export async function build( utils.logLabeledWarning( "dataconnect", `There are changes in your schema or connectors that may break your existing applications. These changes require explicit acknowledgement to proceed. You may either reject the changes and update your sources with the suggested workaround(s), if any, or acknowledge these changes and proceed with the deployment:\n` + - requiredAcks.map(prettifyWithWorkaround).join("\n"), + prettifyWithWorkaround(requiredAcks), ); if (options.nonInteractive && !options.force) { throw new FirebaseError( diff --git a/src/dataconnect/graphqlError.ts b/src/dataconnect/graphqlError.ts index 03948c6f58e..6d3ae683fe9 100644 --- a/src/dataconnect/graphqlError.ts +++ b/src/dataconnect/graphqlError.ts @@ -1,5 +1,5 @@ -import * as clc from "colorette"; import { GraphqlError } from "./types"; +const Table = require("cli-table"); export function prettify(err: GraphqlError): string { const message = err.message; @@ -13,13 +13,24 @@ export function prettify(err: GraphqlError): string { return header.length ? `${header}: ${message}` : message; } -export function prettifyWithWorkaround(err: GraphqlError): string { - if (!err.extensions?.workarounds?.length) { - return prettify(err); - } - let prettified = `\n${clc.bold("Issue:")} ${prettify(err)}`; - for (const w of err.extensions.workarounds) { - prettified += `\n${clc.bold("Workaround:")} ${w.Description}\n${clc.bold("Reason:")} ${w.Reason}`; +export function prettifyWithWorkaround(errs: GraphqlError[]): string { + const table = new Table({ + head: ["Issue", "Workaround", "Reason"], + style: { head: ["yellow"] }, + }); + for (const e of errs) { + if (!e.extensions?.workarounds?.length) { + table.push([prettify(e), "", ""]); + } else { + const workarounds = e.extensions.workarounds; + for (let i = 0; i < workarounds.length; i++) { + if (i === 0) { + table.push([prettify(e), workarounds[i].Description, workarounds[i].Reason]); + } else { + table.push(["", workarounds[i].Description, workarounds[i].Reason]); + } + } + } } - return prettified; + return table.toString(); }