From c738d9f7585b32c5bcd365c7b6e533ff641342f5 Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Tue, 16 May 2023 14:10:00 +0200 Subject: [PATCH] chore: fix cyclic dependencies in the project (#10914) * chore: fix cyclic dependencies in the project * chore: fix cyclic dependencies in the project * chore: fix cyclic dependencies in the project * chore: fix cyclic dependencies in the project --- .../firebase_app_check_web/pubspec.yaml | 1 - .../firebase_auth_web/pubspec.yaml | 2 - .../firebase_core_web/pubspec.yaml | 1 - .../firebase_core_web_exceptions_test.dart | 7 ++- .../test/firebase_core_web_test.dart | 8 +-- packages/firebase_ui_auth/pubspec.yaml | 33 ------------ packages/firebase_ui_oauth/pubspec.yaml | 35 ------------ .../firebase_ui_oauth/pubspec_overrides.yaml | 4 +- .../test/flutterfire_ui_oauth_test.dart | 54 ++++++++++++++++++- .../firebase_ui_oauth_google/pubspec.yaml | 35 ------------ 10 files changed, 60 insertions(+), 120 deletions(-) diff --git a/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml b/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml index f23510b4c626..04d5a0021116 100644 --- a/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml +++ b/packages/firebase_app_check/firebase_app_check_web/pubspec.yaml @@ -20,7 +20,6 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 - firebase_app_check: ^0.1.4 firebase_core_platform_interface: ^4.8.0 flutter_test: sdk: flutter diff --git a/packages/firebase_auth/firebase_auth_web/pubspec.yaml b/packages/firebase_auth/firebase_auth_web/pubspec.yaml index c8855dccd410..8119d9f3b3af 100644 --- a/packages/firebase_auth/firebase_auth_web/pubspec.yaml +++ b/packages/firebase_auth/firebase_auth_web/pubspec.yaml @@ -21,8 +21,6 @@ dependencies: meta: ^1.8.0 dev_dependencies: - firebase_auth: ^4.6.0 - firebase_core_platform_interface: ^4.8.0 flutter_test: sdk: flutter diff --git a/packages/firebase_core/firebase_core_web/pubspec.yaml b/packages/firebase_core/firebase_core_web/pubspec.yaml index 2bdccf676099..8aa4eecbd42f 100644 --- a/packages/firebase_core/firebase_core_web/pubspec.yaml +++ b/packages/firebase_core/firebase_core_web/pubspec.yaml @@ -18,7 +18,6 @@ dependencies: meta: ^1.8.0 dev_dependencies: - firebase_core: ^2.12.0 flutter_test: sdk: flutter diff --git a/packages/firebase_core/firebase_core_web/test/firebase_core_web_exceptions_test.dart b/packages/firebase_core/firebase_core_web/test/firebase_core_web_exceptions_test.dart index d161521f1ab0..a287da969348 100644 --- a/packages/firebase_core/firebase_core_web/test/firebase_core_web_exceptions_test.dart +++ b/packages/firebase_core/firebase_core_web/test/firebase_core_web_exceptions_test.dart @@ -6,7 +6,6 @@ @TestOn('browser') import 'dart:js' as js; -import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -24,7 +23,7 @@ void main() { 'should throw exception if no default app is available & no options are provided', () async { await expectLater( - Firebase.initializeApp, + FirebasePlatform.instance.initializeApp, throwsAssertionError, ); }); @@ -39,7 +38,7 @@ void main() { test('should throw exception if no options are provided with a named app', () async { await expectLater( - () => Firebase.initializeApp(name: 'foo'), + () => FirebasePlatform.instance.initializeApp(name: 'foo'), throwsAssertionError, ); }); @@ -67,7 +66,7 @@ void main() { }); await expectLater( - () => Firebase.app('foo'), + () => FirebasePlatform.instance.app('foo'), throwsA(noAppExists('foo')), ); }); diff --git a/packages/firebase_core/firebase_core_web/test/firebase_core_web_test.dart b/packages/firebase_core/firebase_core_web/test/firebase_core_web_test.dart index 974b883e2a5f..15897ace5ea0 100644 --- a/packages/firebase_core/firebase_core_web/test/firebase_core_web_test.dart +++ b/packages/firebase_core/firebase_core_web/test/firebase_core_web_test.dart @@ -5,7 +5,6 @@ @TestOn('browser') import 'dart:js' as js; -import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -37,7 +36,7 @@ void main() { test('.apps', () { (js.context['firebase_core'] as js.JsObject)['getApps'] = js.allowInterop(js.JsArray.new); - final List apps = Firebase.apps; + final List apps = FirebasePlatform.instance.apps; expect(apps, hasLength(0)); }); @@ -55,7 +54,7 @@ void main() { }); }); - final FirebaseApp app = Firebase.app('foo'); + final FirebaseAppPlatform app = FirebasePlatform.instance.app('foo'); expect(app.name, equals('foo')); @@ -98,7 +97,8 @@ void main() { }); }); - final FirebaseApp app = await Firebase.initializeApp( + final FirebaseAppPlatform app = + await FirebasePlatform.instance.initializeApp( name: 'foo', options: const FirebaseOptions( apiKey: 'abc', diff --git a/packages/firebase_ui_auth/pubspec.yaml b/packages/firebase_ui_auth/pubspec.yaml index 22ca4619b604..f42290baf843 100644 --- a/packages/firebase_ui_auth/pubspec.yaml +++ b/packages/firebase_ui_auth/pubspec.yaml @@ -27,10 +27,6 @@ dev_dependencies: flutter_lints: ^2.0.0 mockito: ^5.2.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter. - false_secrets: - '/example/**/google-services.json' - '/example/**/firebase_options.dart' @@ -38,32 +34,3 @@ false_secrets: - 'example/lib/config.dart' flutter: -# To add assets to your package, add an assets section, like this: -# assets: -# - images/a_dot_burr.jpeg -# - images/a_dot_ham.jpeg -# -# For details regarding assets in packages, see -# https://flutter.dev/assets-and-images/#from-packages -# -# An image asset can refer to one or more resolution-specific "variants", see -# https://flutter.dev/assets-and-images/#resolution-aware. -# To add custom fonts to your package, add a fonts section here, -# in this "flutter" section. Each entry in this list should have a -# "family" key with the font family name, and a "fonts" key with a -# list giving the asset and other descriptors for the font. For -# example: -# fonts: -# - family: Schyler -# fonts: -# - asset: fonts/Schyler-Regular.ttf -# - asset: fonts/Schyler-Italic.ttf -# style: italic -# - family: Trajan Pro -# fonts: -# - asset: fonts/TrajanPro.ttf -# - asset: fonts/TrajanPro_Bold.ttf -# weight: 700 -# -# For details regarding fonts in packages, see -# https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/firebase_ui_oauth/pubspec.yaml b/packages/firebase_ui_oauth/pubspec.yaml index 4f878750f883..1a59c5c2a21e 100644 --- a/packages/firebase_ui_oauth/pubspec.yaml +++ b/packages/firebase_ui_oauth/pubspec.yaml @@ -20,9 +20,6 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 - firebase_ui_oauth_google: ^1.2.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec false_secrets: - '/example/**/google-services.json' @@ -30,36 +27,4 @@ false_secrets: - '/example/**/GoogleService-Info.plist' - '/example/lib/config.dart' -# The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/firebase_ui_oauth/pubspec_overrides.yaml b/packages/firebase_ui_oauth/pubspec_overrides.yaml index 749a85d686ca..06207f3349f1 100644 --- a/packages/firebase_ui_oauth/pubspec_overrides.yaml +++ b/packages/firebase_ui_oauth/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: _flutterfire_internals,firebase_auth,firebase_auth_platform_interface,firebase_auth_web,firebase_core,firebase_core_platform_interface,firebase_core_web,firebase_dynamic_links,firebase_dynamic_links_platform_interface,firebase_ui_auth,firebase_ui_localizations,firebase_ui_oauth_google,firebase_ui_shared +# melos_managed_dependency_overrides: _flutterfire_internals,firebase_auth,firebase_auth_platform_interface,firebase_auth_web,firebase_core,firebase_core_platform_interface,firebase_core_web,firebase_dynamic_links,firebase_dynamic_links_platform_interface,firebase_ui_auth,firebase_ui_localizations,firebase_ui_shared dependency_overrides: _flutterfire_internals: path: ../_flutterfire_internals @@ -22,7 +22,5 @@ dependency_overrides: path: ../firebase_ui_auth firebase_ui_localizations: path: ../firebase_ui_localizations - firebase_ui_oauth_google: - path: ../firebase_ui_oauth_google firebase_ui_shared: path: ../firebase_ui_shared diff --git a/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart b/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart index f0bf8eb586ec..f661e0e0dce6 100644 --- a/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart +++ b/packages/firebase_ui_oauth/test/flutterfire_ui_oauth_test.dart @@ -4,11 +4,10 @@ import 'package:firebase_auth/firebase_auth.dart' show FirebaseAuth; import 'package:firebase_ui_auth/firebase_ui_auth.dart'; +import 'package:firebase_ui_oauth/firebase_ui_oauth.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:firebase_ui_oauth/firebase_ui_oauth.dart'; -import 'package:firebase_ui_oauth_google/firebase_ui_oauth_google.dart'; class FakeAssetBundle extends Fake implements AssetBundle { final String svgStr = ''''''; @@ -17,6 +16,57 @@ class FakeAssetBundle extends Fake implements AssetBundle { Future loadString(String key, {bool cache = true}) async => svgStr; } +// Duplicated from packages/firebase_ui_oauth_google/lib/src/theme.dart +// to prevent circular dependency +const _googleBlue = Color(0xff4285f4); +const _googleWhite = Color(0xffffffff); +const _googleDark = Color(0xff757575); + +const _backgroundColor = ThemedColor(_googleBlue, _googleWhite); +const _color = ThemedColor(_googleWhite, _googleDark); +const _iconBackgroundColor = ThemedColor(_googleWhite, _googleWhite); + +const _iconSvg = ''' + + + + + + + + + + + + + + +'''; + +const _iconSrc = ThemedIconSrc(_iconSvg, _iconSvg); + +class GoogleProviderButtonStyle extends ThemedOAuthProviderButtonStyle { + const GoogleProviderButtonStyle(); + + @override + ThemedColor get backgroundColor => _backgroundColor; + + @override + ThemedColor get color => _color; + + @override + ThemedIconSrc get iconSrc => _iconSrc; + + @override + ThemedColor get iconBackgroundColor => _iconBackgroundColor; + + @override + double get iconPadding => 1; + + @override + String get assetsPackage => 'firebase_ui_oauth_google'; +} + class FakeOAuthProvider extends OAuthProvider { @override ProviderArgs get desktopSignInArgs => throw UnimplementedError(); diff --git a/packages/firebase_ui_oauth_google/pubspec.yaml b/packages/firebase_ui_oauth_google/pubspec.yaml index a5e8e51deabf..72ebfa6ffddf 100644 --- a/packages/firebase_ui_oauth_google/pubspec.yaml +++ b/packages/firebase_ui_oauth_google/pubspec.yaml @@ -19,44 +19,9 @@ dev_dependencies: sdk: flutter flutter_lints: ^2.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - false_secrets: - '/example/**/google-services.json' - '/example/**/firebase_options.dart' - '/example/**/GoogleService-Info.plist' -# The following section is specific to Flutter packages. flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages