@@ -5,36 +5,48 @@ import * as experiments from "../experiments";
55import { prettify } from "./graphqlError" ;
66import { DeploymentMetadata } from "./types" ;
77
8- export async function build ( options : Options , configDir : string , dryRun ?: boolean ) : Promise < DeploymentMetadata > {
9- var args : { configDir : string , projectId ?: string } = { configDir }
8+ export async function build (
9+ options : Options ,
10+ configDir : string ,
11+ dryRun ?: boolean ,
12+ ) : Promise < DeploymentMetadata > {
13+ const args : { configDir : string ; projectId ?: string } = { configDir } ;
1014 if ( experiments . isEnabled ( "fdcconnectorevolution" ) && options . projectId ) {
11- process . env [ "DATA_CONNECT_PREVIEW" ] = "conn_evolution"
12- args . projectId = options . projectId
15+ process . env [ "DATA_CONNECT_PREVIEW" ] = "conn_evolution" ;
16+ args . projectId = options . projectId ;
1317 }
1418 const buildResult = await DataConnectEmulator . build ( args ) ;
1519 if ( buildResult ?. errors ?. length ) {
16- if ( buildResult . errors . filter ( e => ! e . warningLevel ) ) {
20+ if ( buildResult . errors . filter ( ( w ) => ! w . warningLevel ) . length ) {
1721 // Throw immediately if there are any build errors in the GraphQL schema or connectors.
1822 throw new FirebaseError (
1923 `There are errors in your schema and connector files:\n${ buildResult . errors . map ( prettify ) . join ( "\n" ) } ` ,
2024 ) ;
21- } else {
22- for ( let e of buildResult . errors ) {
23- if ( options . interactive ) {
24- if ( dryRun || options . force ) {
25- // TODO: Log messages in output.
26- } else {
27- // TODO: Prompt messages and error if rejected.
28- // Interactive default to accept, required default to reject.
29- }
30- } else if ( options . nonInteractive ) {
31- }
25+ }
26+ const interactiveAcks = buildResult . errors . filter (
27+ ( w ) => w . warningLevel && w . warningLevel === "INTERACTIVE_ACK" ,
28+ ) ;
29+ const requiredAcks = buildResult . errors . filter (
30+ ( w ) => w . warningLevel && w . warningLevel === "REQUIRE_ACK" ,
31+ ) ;
32+ if ( requiredAcks . length ) {
33+ if ( options . nonInteractive && ! options . force ) {
34+ throw new FirebaseError (
35+ `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" ) } ` ,
36+ ) ;
37+ } else if ( options . interactive && ! options . force && ! dryRun ) {
38+ // TODO: Prompt message and error if rejected. Default to reject.
39+ } else {
40+ // TODO: Log messages in output.
41+ }
42+ }
43+ if ( interactiveAcks . length ) {
44+ if ( options . interactive && ! options . force && ! dryRun ) {
45+ // TODO: Prompt message and error if rejected. Default to accept.
46+ } else {
47+ // TODO: Log messages in output.
3248 }
3349 }
3450 }
3551 return buildResult ?. metadata ?? { } ;
3652}
37-
38- async function prompt ( options : Options ) : Promise < boolean > {
39- return true ;
40- }
0 commit comments