Skip to content

Commit

Permalink
fix: Fixed bugs in Firebase and Module initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Apr 7, 2023
1 parent 3eeb32b commit 6f4d654
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
22 changes: 15 additions & 7 deletions packages/katana_cli/lib/action/firebase/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class FirebaseInitCliAction extends CliCommand with CliActionMixin {
);
_runCommandStack(
line,
"? Configure as a single-page app (rewrite all urls to /index.html)?",
"? Configure as a single-page app",
commandStack,
() {
if (useFlutter) {
Expand Down Expand Up @@ -417,8 +417,8 @@ class FirebaseInitCliAction extends CliCommand with CliActionMixin {
"eslint",
"--ext",
".js,.ts",
".",
"--fix",
".",
],
workingDirectory: "firebase/functions",
);
Expand All @@ -440,6 +440,14 @@ class FirebaseInitCliAction extends CliCommand with CliActionMixin {
gradle.android?.defaultConfig.minSdkVersion =
"configProperties[\"flutter.minSdkVersion\"]";
await gradle.save();
await command(
"Run firebase deploy",
[
firebaseCommand,
"deploy",
],
workingDirectory: "firebase",
);
}

void _runCommandStack(
Expand Down Expand Up @@ -498,9 +506,9 @@ import * as m from "@mathrunet/masamune";
//
// Functionsに追加する機能を[m.Functions.xxxx]を定義してください。
m.deploy(
exports,
["us-central1", "asia-northeast1"],
[],
exports,
["us-central1", "asia-northeast1"],
[],
);
""";
}
Expand Down Expand Up @@ -600,7 +608,7 @@ class FirestoreRulesCliCode extends CliCode {
@override
String body(String path, String baseName, String className) {
return """
rules_version = '3';
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
Expand Down Expand Up @@ -667,7 +675,7 @@ class FirebaseStorageRulesCliCode extends CliCode {
@override
String body(String path, String baseName, String className) {
return """
rules_version = '3';
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
Expand Down
10 changes: 5 additions & 5 deletions packages/katana_cli/lib/src/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class Fuctions {
}
_rawData = _rawData.replaceAll(_regExp, """
m.deploy(
exports,
[${regions.map((e) => '"$e"').join(", ")}],
[
${functions.map((e) => " m.Functions.$e").join(",")}
],
exports,
[${regions.map((e) => '"$e"').join(", ")}],
[
${functions.map((e) => " m.Functions.$e,").join("\n")}
],
);""");
final gradle = File("firebase/functions/src/index.ts");
await gradle.writeAsString(_rawData);
Expand Down

0 comments on commit 6f4d654

Please sign in to comment.