Skip to content

Commit

Permalink
- [dependencies][android] remove all Firebase SDKs in favour of Fireb…
Browse files Browse the repository at this point in the history
…ase BoM

- [android] upgrade to Android X
- [android] upgrade gradle wrapper to v5.4.1
- [android][ios][tests] remove manual packages & enable auto-linking
- [tests][internal] upgrade tests project to RN 60
- [ios] temporarily remove framework support in pods - broken in RN 60 - see facebook/react-native#25349
- [linting] switch to use rn community linting rules
  • Loading branch information
Salakar committed Jul 30, 2019
1 parent e4b0d2b commit fc8ef9b
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 35 deletions.
2 changes: 1 addition & 1 deletion RNFBApp.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m}"
s.dependency 'React'
s.dependency 'Firebase/Core', '~> 6.5.0'
s.static_framework = true
s.static_framework = false
end
19 changes: 7 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}

Expand All @@ -15,7 +15,7 @@ plugins {
project.ext {
set('react-native', [
versions: [
android : [
android : [
minSdk : 16,
targetSdk : 28,
compileSdk: 28,
Expand All @@ -24,13 +24,8 @@ project.ext {
buildTools: "28.0.3"
],

googlePlayServices: [
base: "16.1.0",
],

firebase : [
core : "16.0.9",
common: "17.0.0"
firebase: [
bom: "21.1.0",
],
],
])
Expand Down Expand Up @@ -62,9 +57,9 @@ repositories {
}

dependencies {
implementation "com.google.firebase:firebase-core:${ReactNative.ext.getVersion("firebase", "core")}"
implementation "com.google.firebase:firebase-common:${ReactNative.ext.getVersion("firebase", "common")}"
implementation "com.google.android.gms:play-services-base:${ReactNative.ext.getVersion("googlePlayServices", "base")}"
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-core"
implementation "com.google.firebase:firebase-common"
}

apply from: file("./firebase-json.gradle")
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
4 changes: 2 additions & 2 deletions firebase_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
begin
$firebase_json_config = JSON.parse(File.read(firebase_json))['react-native']
Pod::UI.puts "Using firebase.json from '#{firebase_json}'"
Pod::UI.puts $firebase_json_config
# Pod::UI.puts $firebase_json_config
rescue => error
Pod::UI.warn "An error occurred parsing the firebase.json located at '#{firebase_json}':"
Pod::UI.warn error
Expand All @@ -69,4 +69,4 @@ def self.get_value_or_default(key, default)
end
end
PATH = nil
end
end
2 changes: 1 addition & 1 deletion ios/RNFBApp.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m}"
s.dependency 'React'
s.dependency 'Firebase/Core', '~> 6.5.0'
s.static_framework = true
s.static_framework = false
end
8 changes: 6 additions & 2 deletions lib/internal/FirebaseModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default class FirebaseModule {
}

get firebaseJson() {
if (firebaseJson) return firebaseJson;
if (firebaseJson) {
return firebaseJson;
}
firebaseJson = JSON.parse(getAppModule().FIREBASE_RAW_JSON);
return firebaseJson;
}
Expand All @@ -48,7 +50,9 @@ export default class FirebaseModule {
}

get native() {
if (this._nativeModule) return this._nativeModule;
if (this._nativeModule) {
return this._nativeModule;
}
this._nativeModule = getNativeModule(this);
return this._nativeModule;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const KNOWN_NAMESPACES = [
'invites',
'indexing',
'storage',
'links',
'dynamicLinks',
'messaging',
'mlKitLanguage',
'mlKitVision',
Expand Down
20 changes: 12 additions & 8 deletions lib/internal/registry/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export function initializeNativeApps() {
* @param name
*/
export function getApp(name = DEFAULT_APP_NAME) {
if (!initializedNativeApps) initializeNativeApps();
if (!initializedNativeApps) {
initializeNativeApps();
}
const app = APP_REGISTRY[name];

if (!app) {
Expand All @@ -90,7 +92,9 @@ export function getApp(name = DEFAULT_APP_NAME) {
* Gets all app instances, used for `firebase.apps`
*/
export function getApps() {
if (!initializedNativeApps) initializeNativeApps();
if (!initializedNativeApps) {
initializeNativeApps();
}
return Object.values(APP_REGISTRY);
}

Expand Down Expand Up @@ -132,33 +136,33 @@ export function initializeApp(options = {}, configOrName) {
}

if (!isString(options.apiKey)) {
return Promise.reject(new Error(`Missing or invalid FirebaseOptions property 'apiKey'.`));
return Promise.reject(new Error("Missing or invalid FirebaseOptions property 'apiKey'."));
}

if (!isString(options.appId)) {
return Promise.reject(new Error(`Missing or invalid FirebaseOptions property 'appId'.`));
return Promise.reject(new Error("Missing or invalid FirebaseOptions property 'appId'."));
}

// TODO - make required only if database module exists - init app on native ios&android needs changing also
if (!isString(options.databaseURL)) {
return Promise.reject(new Error(`Missing or invalid FirebaseOptions property 'databaseURL'.`));
return Promise.reject(new Error("Missing or invalid FirebaseOptions property 'databaseURL'."));
}

// TODO - make required only if messaging/notifications module exists - init app on native ios&android needs changing also
if (!isString(options.messagingSenderId)) {
return Promise.reject(
new Error(`Missing or invalid FirebaseOptions property 'messagingSenderId'.`),
new Error("Missing or invalid FirebaseOptions property 'messagingSenderId'."),
);
}

if (!isString(options.projectId)) {
return Promise.reject(new Error(`Missing or invalid FirebaseOptions property 'projectId'.`));
return Promise.reject(new Error("Missing or invalid FirebaseOptions property 'projectId'."));
}

// TODO - make required only if database module exists - init app on native ios&android needs changing also
if (!isString(options.storageBucket)) {
return Promise.reject(
new Error(`Missing or invalid FirebaseOptions property 'storageBucket'.`),
new Error("Missing or invalid FirebaseOptions property 'storageBucket'."),
);
}

Expand Down
18 changes: 12 additions & 6 deletions lib/internal/registry/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ function getOrCreateModuleForApp(app, moduleNamespace) {
return MODULE_GETTER_FOR_APP[app.name][moduleNamespace];
}

if (!MODULE_GETTER_FOR_APP[app.name]) MODULE_GETTER_FOR_APP[app.name] = {};
if (!MODULE_GETTER_FOR_APP[app.name]) {
MODULE_GETTER_FOR_APP[app.name] = {};
}

const { hasCustomUrlOrRegionSupport, hasMultiAppSupport, ModuleClass } = NAMESPACE_REGISTRY[
moduleNamespace
Expand Down Expand Up @@ -126,7 +128,9 @@ function getOrCreateModuleForApp(app, moduleNamespace) {
* @returns {*}
*/
function getOrCreateModuleForRoot(moduleNamespace) {
if (MODULE_GETTER_FOR_ROOT[moduleNamespace]) return MODULE_GETTER_FOR_ROOT[moduleNamespace];
if (MODULE_GETTER_FOR_ROOT[moduleNamespace]) {
return MODULE_GETTER_FOR_ROOT[moduleNamespace];
}

const { statics, hasMultiAppSupport, ModuleClass } = NAMESPACE_REGISTRY[moduleNamespace];

Expand All @@ -139,7 +143,7 @@ function getOrCreateModuleForRoot(moduleNamespace) {
[
`"firebase.${moduleNamespace}(app)" arg expects a FirebaseApp instance or undefined.`,
'',
`Ensure the arg provided is a Firebase app instance; or no args to use the default Firebase app.`,
'Ensure the arg provided is a Firebase app instance; or no args to use the default Firebase app.',
].join('\r\n'),
);
}
Expand Down Expand Up @@ -253,7 +257,9 @@ export function createFirebaseRoot() {
* @returns {*}
*/
export function getFirebaseRoot() {
if (FIREBASE_ROOT) return FIREBASE_ROOT;
if (FIREBASE_ROOT) {
return FIREBASE_ROOT;
}
return createFirebaseRoot();
}

Expand All @@ -278,8 +284,8 @@ export function createModuleNamespace(options = {}) {
`You've attempted to require '@react-native-firebase/${namespace}' version '${version}', ` +
`however, the '@react-native-firebase/app' module is of a different version (${SDK_VERSION}).`,
'',
`All React Native Firebase modules must be of the same version. Please ensure they match up ` +
`in your package.json file and re-run yarn/npm install.`,
'All React Native Firebase modules must be of the same version. Please ensure they match up ' +
'in your package.json file and re-run yarn/npm install.',
].join('\n'),
);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/internal/registry/nativeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function nativeModuleMethodWrapped(namespace, method, argToPrepend) {
*/
function nativeModuleWrapped(namespace, NativeModule, argToPrepend) {
const native = {};
if (!NativeModule) return NativeModule;
if (!NativeModule) {
return NativeModule;
}

const properties = Object.keys(NativeModule);

Expand Down

0 comments on commit fc8ef9b

Please sign in to comment.