59 lines
2.4 KiB
Dart
59 lines
2.4 KiB
Dart
// Explicit QA-only entry point. Never use this for a release build.
|
|
// flutter run -t tools/qa_auth_main.dart --dart-define=R2_WORKER_URL=http://127.0.0.1:1
|
|
// Android emulator: reverse tcp:9299 -> host 9299 and tcp:8288 -> host 8288.
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
import 'package:firebase_auth/firebase_auth.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:marionette_flutter/marionette_flutter.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:motorcycle_dash/main.dart' show MotorcycleDashApp;
|
|
import 'package:motorcycle_dash/features/records/records_service.dart';
|
|
|
|
Future<void> main() async {
|
|
if (!kDebugMode) throw StateError('QA entry requires debug mode');
|
|
const worker = String.fromEnvironment('R2_WORKER_URL');
|
|
if (worker != 'http://127.0.0.1:1') {
|
|
throw StateError('QA requires R2_WORKER_URL=http://127.0.0.1:1');
|
|
}
|
|
MarionetteBinding.ensureInitialized();
|
|
final app = await Firebase.initializeApp(
|
|
options: const FirebaseOptions(
|
|
apiKey: 'demo-key',
|
|
appId: '1:123456789:android:qa',
|
|
messagingSenderId: '123456789',
|
|
projectId: 'demo-motorsignal-qa',
|
|
),
|
|
);
|
|
if (!app.options.projectId.startsWith('demo-')) {
|
|
throw StateError('QA requires a demo-* Firebase project');
|
|
}
|
|
// Connect to isolated Auth and Firestore emulators.
|
|
// On Android emulator, use the standard 10.0.2.2 host bridge rather than device loopback.
|
|
final emulatorHost = defaultTargetPlatform == TargetPlatform.android
|
|
? const String.fromEnvironment('FIREBASE_EMULATOR_HOST', defaultValue: '10.0.2.2')
|
|
: const String.fromEnvironment('FIREBASE_EMULATOR_HOST', defaultValue: '127.0.0.1');
|
|
const authPort = int.fromEnvironment('FIREBASE_AUTH_PORT', defaultValue: 9099);
|
|
const firestorePort = int.fromEnvironment('FIRESTORE_PORT', defaultValue: 8088);
|
|
|
|
await FirebaseAuth.instance.useAuthEmulator(
|
|
emulatorHost,
|
|
authPort,
|
|
automaticHostMapping: false,
|
|
);
|
|
FirebaseFirestore.instance.useFirestoreEmulator(
|
|
emulatorHost,
|
|
firestorePort,
|
|
automaticHostMapping: false,
|
|
);
|
|
final preferences = await SharedPreferences.getInstance();
|
|
runApp(
|
|
ProviderScope(
|
|
overrides: [sharedPreferencesProvider.overrideWithValue(preferences)],
|
|
child: const MotorcycleDashApp(),
|
|
),
|
|
);
|
|
}
|