File tree 4 files changed +39
-7
lines changed
4 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,26 @@ describe("handleBuildErrors", () => {
126
126
dryRun : false ,
127
127
expectErr : false ,
128
128
} ,
129
+ {
130
+ desc : "Required force evolution error, force=false" ,
131
+ graphqlErr : [
132
+ { message : "inaccessible error" , extensions : { warningLevel : "REQUIRE_FORCE" } } ,
133
+ ] ,
134
+ nonInteractive : false ,
135
+ force : false ,
136
+ dryRun : false ,
137
+ expectErr : true ,
138
+ } ,
139
+ {
140
+ desc : "Required force evolution error, force=true" ,
141
+ graphqlErr : [
142
+ { message : "inaccessible error" , extensions : { warningLevel : "REQUIRE_FORCE" } } ,
143
+ ] ,
144
+ nonInteractive : false ,
145
+ force : true ,
146
+ dryRun : false ,
147
+ expectErr : false ,
148
+ } ,
129
149
] ;
130
150
for ( const c of cases ) {
131
151
it ( c . desc , async ( ) => {
Original file line number Diff line number Diff line change @@ -41,6 +41,17 @@ export async function handleBuildErrors(
41
41
`There are errors in your schema and connector files:\n${ errors . map ( prettify ) . join ( "\n" ) } ` ,
42
42
) ;
43
43
}
44
+
45
+ const requiredForces = errors . filter ( ( w ) => w . extensions ?. warningLevel === "REQUIRE_FORCE" ) ;
46
+ if ( requiredForces . length && ! force ) {
47
+ utils . logLabeledError (
48
+ "dataconnect" ,
49
+ `There are changes in your schema or connectors that will result in broken behavior:\n` +
50
+ prettifyWithWorkaround ( requiredForces ) ,
51
+ ) ;
52
+ throw new FirebaseError ( "Rerun this command with --force to deploy these changes." ) ;
53
+ }
54
+
44
55
const interactiveAcks = errors . filter ( ( w ) => w . extensions ?. warningLevel === "INTERACTIVE_ACK" ) ;
45
56
const requiredAcks = errors . filter ( ( w ) => w . extensions ?. warningLevel === "REQUIRE_ACK" ) ;
46
57
const choices = [
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ export function prettifyWithWorkaround(errs: GraphqlError[]): string {
17
17
const table = new Table ( {
18
18
head : [ "Issue" , "Workaround" , "Reason" ] ,
19
19
style : { head : [ "yellow" ] } ,
20
+ colWidths : [ 50 , 50 , 50 ] ,
21
+ wordWrap : true ,
20
22
} ) ;
21
23
for ( const e of errs ) {
22
24
if ( ! e . extensions ?. workarounds ?. length ) {
@@ -25,9 +27,9 @@ export function prettifyWithWorkaround(errs: GraphqlError[]): string {
25
27
const workarounds = e . extensions . workarounds ;
26
28
for ( let i = 0 ; i < workarounds . length ; i ++ ) {
27
29
if ( i === 0 ) {
28
- table . push ( [ prettify ( e ) , workarounds [ i ] . Description , workarounds [ i ] . Reason ] ) ;
30
+ table . push ( [ prettify ( e ) , workarounds [ i ] . description , workarounds [ i ] . reason ] ) ;
29
31
} else {
30
- table . push ( [ "" , workarounds [ i ] . Description , workarounds [ i ] . Reason ] ) ;
32
+ table . push ( [ "" , workarounds [ i ] . description , workarounds [ i ] . reason ] ) ;
31
33
}
32
34
}
33
35
}
Original file line number Diff line number Diff line change @@ -71,13 +71,12 @@ export interface Diff {
71
71
destructive : boolean ;
72
72
}
73
73
74
- export type WarningLevel = "INTERACTIVE_ACK" | "REQUIRE_ACK" ;
74
+ export type WarningLevel = "INTERACTIVE_ACK" | "REQUIRE_ACK" | "REQUIRE_FORCE" ;
75
75
76
76
export interface Workaround {
77
- // TODO: Make these lower-case after fixing the emulator, to match the style convention.
78
- Description : string ;
79
- Reason : string ;
80
- ReplaceWith : string ;
77
+ description : string ;
78
+ reason : string ;
79
+ replaceWith : string ;
81
80
}
82
81
83
82
export interface GraphqlError {
You can’t perform that action at this time.
0 commit comments