From 36405049107ffe3961de54f9523f439ef74a27d9 Mon Sep 17 00:00:00 2001 From: Giorgio Azzinnaro Date: Mon, 11 Nov 2024 14:33:55 +0100 Subject: [PATCH] chore: use kReleaseMode to set prod config --- assets/env/local.json | 5 +++++ assets/env/supabase.json | 5 +++++ env/dev.json | 5 ----- env/local.json | 5 ----- ios/Podfile.lock | 2 +- lib/presentation/screens/auth.dart | 1 + lib/util/config.dart | 8 +++++--- pubspec.yaml | 2 +- supabase/config/{supabase_dev.json => supabase.json} | 0 9 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 assets/env/local.json create mode 100644 assets/env/supabase.json delete mode 100644 env/dev.json delete mode 100644 env/local.json rename supabase/config/{supabase_dev.json => supabase.json} (100%) diff --git a/assets/env/local.json b/assets/env/local.json new file mode 100644 index 0000000..dd7d1e3 --- /dev/null +++ b/assets/env/local.json @@ -0,0 +1,5 @@ +{ + "supabaseConfigPath": "supabase/config/localhost.json", + "socialAuthWebClientId": "655087059227-32trs4upje1r6itvs3p1c1fs0m98m8ol.apps.googleusercontent.com", + "socialAuthIosClientId": "655087059227-o10vdnfsvnkl9ct8isg8db3j74s0rfur.apps.googleusercontent.com" +} diff --git a/assets/env/supabase.json b/assets/env/supabase.json new file mode 100644 index 0000000..d9bf19f --- /dev/null +++ b/assets/env/supabase.json @@ -0,0 +1,5 @@ +{ + "supabaseConfigPath": "supabase/config/supabase.json", + "socialAuthWebClientId": "655087059227-32trs4upje1r6itvs3p1c1fs0m98m8ol.apps.googleusercontent.com", + "socialAuthIosClientId": "655087059227-o10vdnfsvnkl9ct8isg8db3j74s0rfur.apps.googleusercontent.com" +} diff --git a/env/dev.json b/env/dev.json deleted file mode 100644 index 2c36e7a..0000000 --- a/env/dev.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "supabaseConfigPath": "supabase/config/supabase_dev.json", - "socialAuthWebClientId": "655087059227-32trs4upje1r6itvs3p1c1fs0m98m8ol.apps.googleusercontent.com", - "socialAuthIosClientId": "655087059227-o10vdnfsvnkl9ct8isg8db3j74s0rfur.apps.googleusercontent.com" -} \ No newline at end of file diff --git a/env/local.json b/env/local.json deleted file mode 100644 index 4b59005..0000000 --- a/env/local.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "supabaseConfigPath": "supabase/config/localhost.json", - "socialAuthWebClientId": "655087059227-32trs4upje1r6itvs3p1c1fs0m98m8ol.apps.googleusercontent.com", - "socialAuthIosClientId": "655087059227-o10vdnfsvnkl9ct8isg8db3j74s0rfur.apps.googleusercontent.com" -} \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock index af2bec0..cb43eeb 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -126,4 +126,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 569636ff5edb32636892b1c748f656de700236ae -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/lib/presentation/screens/auth.dart b/lib/presentation/screens/auth.dart index 052f9a3..fc53e09 100644 --- a/lib/presentation/screens/auth.dart +++ b/lib/presentation/screens/auth.dart @@ -15,6 +15,7 @@ class AuthScreen extends StatelessWidget { onSuccess(session) => HomeScreenRoute().go(context); final config = ConfigService().config; + return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context)!.appName), diff --git a/lib/util/config.dart b/lib/util/config.dart index 9e4b14a..f099daa 100644 --- a/lib/util/config.dart +++ b/lib/util/config.dart @@ -1,6 +1,8 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:convert'; + +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; part 'config.freezed.dart'; part 'config.g.dart'; @@ -16,8 +18,8 @@ class ConfigService { } Future initialize() async { - const env = String.fromEnvironment('ENV', defaultValue: 'local'); - final envConfigFile = await rootBundle.loadString('env/$env.json'); + const env = kReleaseMode ? 'supabase' : 'local'; + final envConfigFile = await rootBundle.loadString('assets/env/$env.json'); final config = Config.fromJson(json.decode(envConfigFile) as Map); this.config = config; diff --git a/pubspec.yaml b/pubspec.yaml index 65c990a..ea980ff 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -162,7 +162,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/ - - env/ + - assets/env/ - supabase/config/ # An image asset can refer to one or more resolution-specific "variants", see diff --git a/supabase/config/supabase_dev.json b/supabase/config/supabase.json similarity index 100% rename from supabase/config/supabase_dev.json rename to supabase/config/supabase.json