Skip to content

Commit

Permalink
Better formatting of prompts/logs and better messaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
rosalyntan committed Dec 18, 2024
1 parent e132424 commit 681121b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/dataconnect/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export async function build(
(w) => w.extensions?.warningLevel && w.extensions?.warningLevel === "REQUIRE_ACK",
);
const choices = [
{ name: "Accept all changes and proceed", value: "proceed" },
{ name: "Acknowledge all changes and proceed", value: "proceed" },
{ name: "Reject changes and abort", value: "abort" },
];
if (requiredAcks.length) {
utils.logLabeledWarning(
"dataconnect",
`There are changes in your schema or connectors that may break your existing applications. These changes require explicit acknowledgement to deploy:\n` +
`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"),
);
if (options.nonInteractive && !options.force) {
Expand All @@ -47,7 +47,7 @@ export async function build(
);
} else if (!options.nonInteractive && !options.force && !dryRun) {
const result = await promptOnce({

Check warning on line 49 in src/dataconnect/build.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
message: "Would you like to proceed with these changes?",
message: "Would you like to proceed with these breaking changes?",
type: "list",
choices,
default: "abort",
Expand Down
5 changes: 3 additions & 2 deletions src/dataconnect/graphqlError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as clc from "colorette";
import { GraphqlError } from "./types";

export function prettify(err: GraphqlError): string {

Check warning on line 4 in src/dataconnect/graphqlError.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
Expand All @@ -16,9 +17,9 @@ export function prettifyWithWorkaround(err: GraphqlError): string {
if (!err.extensions?.workarounds?.length) {
return prettify(err);
}
let prettified = prettify(err);
let prettified = `\n${clc.bold("Issue:")} ${prettify(err)}`;
for (const w of err.extensions.workarounds) {
prettified += `\nWorkaround: ${w.Description}\nReason: ${w.Reason}`;
prettified += `\n${clc.bold("Workaround:")} ${w.Description}\n${clc.bold("Reason:")} ${w.Reason}`;
}
return prettified;
}
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface BaseOptions {
account?: string;
json: boolean;
nonInteractive: boolean;
interactive: boolean; // deprecated, use nonInteractive instead
interactive: boolean;
debug: boolean;

rc: RC;
Expand Down

0 comments on commit 681121b

Please sign in to comment.