@@ -283,13 +283,13 @@ Future _runFix({
283
283
Future firebaseDeploy ({
284
284
required String token,
285
285
required String projectId,
286
+ bool appendRules = false ,
286
287
String endpoint = kDefaultEndpoint,
287
288
}) async {
288
289
final endpointUrl = Uri .parse (endpoint);
289
290
final body = jsonEncode ({
290
- 'project' : {
291
- 'path' : 'projects/$projectId ' ,
292
- },
291
+ 'project' : {'path' : 'projects/$projectId ' },
292
+ 'append_rules' : appendRules,
293
293
});
294
294
final result = await _callEndpoint (
295
295
client: http.Client (),
@@ -333,6 +333,27 @@ Future firebaseDeploy({
333
333
);
334
334
}
335
335
336
+ stdout.write ('Initializing firebase...\n ' );
337
+ await Process .run (
338
+ 'firebase' ,
339
+ ['use' , firebaseProjectId],
340
+ workingDirectory: firebaseDir,
341
+ runInShell: true ,
342
+ );
343
+ final initHostingProcess = await Process .start (
344
+ 'firebase' ,
345
+ ['init' , 'hosting' ],
346
+ workingDirectory: firebaseDir,
347
+ runInShell: true ,
348
+ );
349
+ final initHostingInputStream = Stream .periodic (
350
+ Duration (milliseconds: 100 ),
351
+ (count) => utf8.encode ('\n ' ),
352
+ );
353
+ initHostingProcess.stdin.addStream (initHostingInputStream);
354
+ // Make sure hosting is initialized before deploying.
355
+ await initHostingProcess.exitCode;
356
+
336
357
final deployProcess = await Process .start (
337
358
'firebase' ,
338
359
['deploy' , '--project' , firebaseProjectId],
0 commit comments