Skip to content

Commit

Permalink
Fix warningLevel structure and output log statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
rosalyntan committed Dec 14, 2024
1 parent 3ee2f24 commit 2f4f1ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/dataconnect/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DataConnectEmulator } from "../emulator/dataconnectEmulator";
import { Options } from "../options";
import { FirebaseError } from "../error";
import * as experiments from "../experiments";
import * as utils from "../utils";
import { prettify } from "./graphqlError";
import { DeploymentMetadata } from "./types";

Expand All @@ -17,34 +18,34 @@ export async function build(
}
const buildResult = await DataConnectEmulator.build(args);
if (buildResult?.errors?.length) {
if (buildResult.errors.filter((w) => !w.warningLevel).length) {
if (buildResult.errors.filter((w) => !w.extensions?.warningLevel).length) {
// Throw immediately if there are any build errors in the GraphQL schema or connectors.
throw new FirebaseError(
`There are errors in your schema and connector files:\n${buildResult.errors.map(prettify).join("\n")}`,
);
}
const interactiveAcks = buildResult.errors.filter(
(w) => w.warningLevel && w.warningLevel === "INTERACTIVE_ACK",
(w) => w.extensions?.warningLevel && w.extensions?.warningLevel === "INTERACTIVE_ACK",
);
const requiredAcks = buildResult.errors.filter(
(w) => w.warningLevel && w.warningLevel === "REQUIRE_ACK",
(w) => w.extensions?.warningLevel && w.extensions?.warningLevel === "REQUIRE_ACK",
);
if (requiredAcks.length) {
if (options.nonInteractive && !options.force) {
throw new FirebaseError(
`There are changes in your schema or connectors that may break your existing applications. These changes require explicit acknowledgement to deploy:\n${requiredAcks.map(prettify).join("\n")}`,
);
} else if (options.interactive && !options.force && !dryRun) {
} else if (!options.nonInteractive && !options.force && !dryRun) {
// TODO: Prompt message and error if rejected. Default to reject.
} else {
// TODO: Log messages in output.
utils.logLabeledBullet("dataconnect", requiredAcks.map(prettify).join("\n"));
}
}
if (interactiveAcks.length) {
if (options.interactive && !options.force && !dryRun) {
if (!options.nonInteractive && !options.force && !dryRun) {
// TODO: Prompt message and error if rejected. Default to accept.
} else {
// TODO: Log messages in output.
utils.logLabeledBullet("dataconnect", interactiveAcks.map(prettify).join("\n"));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/dataconnect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export interface Workaround {

export interface GraphqlError {
message: string;
warningLevel?: WarningLevel;
workarounds?: Workaround[];
locations?: {
line: number;
column: number;
}[];
extensions?: {
file?: string;
warningLevel?: WarningLevel;
workarounds?: Workaround[];
[key: string]: any;

Check warning on line 92 in src/dataconnect/types.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
};
}
Expand Down
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;
interactive: boolean; // deprecated, use nonInteractive instead
debug: boolean;

rc: RC;
Expand Down

0 comments on commit 2f4f1ce

Please sign in to comment.