From c69f196e1c84e75fc0a37e8a27b7911804fcc4a3 Mon Sep 17 00:00:00 2001 From: Vadim Date: Tue, 25 Jul 2023 17:14:51 +0200 Subject: [PATCH] Added stub `DefaultFirebaseOptions` --- .github/workflows/cd_dev.yml | 4 +-- .github/workflows/cd_prod.yml | 4 +-- .github/workflows/ci.yml | 26 +++----------- .gitignore | 1 - lib/firebase_options.dart | 68 +++++++++++++++++++++++++++++++++++ lib/main_prod.dart | 8 ++++- 6 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 lib/firebase_options.dart diff --git a/.github/workflows/cd_dev.yml b/.github/workflows/cd_dev.yml index e0e6a25..13fe25a 100644 --- a/.github/workflows/cd_dev.yml +++ b/.github/workflows/cd_dev.yml @@ -63,9 +63,9 @@ jobs: env: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} run: | - FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart + FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/lib/firebase_options.dart + rm $FIREBASE_OPTIONS_PATH echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH - cp $FIREBASE_OPTIONS_PATH ./lib - name: Install Flutter uses: subosito/flutter-action@v2 diff --git a/.github/workflows/cd_prod.yml b/.github/workflows/cd_prod.yml index 9e45644..5a2e425 100644 --- a/.github/workflows/cd_prod.yml +++ b/.github/workflows/cd_prod.yml @@ -62,9 +62,9 @@ jobs: env: FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} run: | - FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart + FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/lib/firebase_options.dart + rm $FIREBASE_OPTIONS_PATH echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH - cp $FIREBASE_OPTIONS_PATH ./lib - name: Increment build number & replace version number run: perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+)(\+)(\d+)$/$1."${{ github.event.inputs.version }}".$3.($4+1)/e' pubspec.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8956f6..9bb9b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,13 +17,6 @@ jobs: timeout-minutes: 10 steps: - - uses: shaunco/ssh-agent@git-repo-mapping - with: - ssh-private-key: | - ${{ secrets.M3_LIGHTMETER_IAP_KEY }} - repo-mappings: | - github.com/vodemn/m3_lightmeter_iap - - uses: actions/checkout@v3 with: submodules: recursive @@ -32,22 +25,11 @@ jobs: with: channel: "stable" - - name: Check flutter version - run: flutter --version - - - name: Install dependencies - run: flutter pub get - - - name: Generate intl - run: flutter pub run intl_utils:generate - - - name: Restore firebase_options.dart - env: - FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }} + - name: Prepare flutter project run: | - FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart - echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH - cp $FIREBASE_OPTIONS_PATH ./lib + flutter --version + flutter pub get + flutter pub run intl_utils:generate - name: Analyze project source run: flutter analyze lib --fatal-infos diff --git a/.gitignore b/.gitignore index ee0aebd..e6ec130 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,5 @@ keystore.properties android/app/google-services.json ios/firebase_app_id_file.json ios/Runner/GoogleService-Info.plist -lib/firebase_options.dart coverage/ \ No newline at end of file diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000..a8a32c7 --- /dev/null +++ b/lib/firebase_options.dart @@ -0,0 +1,68 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: '', + appId: '', + messagingSenderId: '', + projectId: '', + storageBucket: '', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: '', + appId: '', + messagingSenderId: '', + projectId: '', + storageBucket: '', + iosClientId: '', + iosBundleId: '', + ); +} diff --git a/lib/main_prod.dart b/lib/main_prod.dart index a47d421..fc1700a 100644 --- a/lib/main_prod.dart +++ b/lib/main_prod.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:lightmeter/application.dart'; import 'package:lightmeter/environment.dart'; @@ -5,6 +7,10 @@ import 'package:lightmeter/firebase.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - await initializeFirebase(); + try { + await initializeFirebase(); + } catch (e) { + log(e.toString()); + } runApp(const Application(Environment.prod())); }