#!/usr/bin/env python3
import json
from pathlib import Path

root = Path(__file__).resolve().parents[1]
app = json.loads((root / 'mobile-engineer/app.json').read_text())['expo']
services = json.loads((root / 'mobile-engineer/google-services.json').read_text())
package = app['android']['package']
clients = {
    c['client_info']['android_client_info']['package_name']: c['client_info']['mobilesdk_app_id']
    for c in services.get('client', [])
}
errors = []
if app['android'].get('googleServicesFile') != './google-services.json':
    errors.append('android.googleServicesFile is not ./google-services.json')
if package not in clients:
    errors.append(f'No Firebase client exists for {package}')
if package != 'com.colorjetbd.managementsuite':
    errors.append(f'Unexpected Android package: {package}')
if errors:
    print('\n'.join(f'FAIL: {e}' for e in errors))
    raise SystemExit(1)
print(f'PASS: {package} -> {clients[package]}')
