Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Commit

Permalink
feat!: all packages should depend on core (invertase#3613)
Browse files Browse the repository at this point in the history
All packages now peer-depend on an explicit version of the `app` package.

BREAKING CHANGE: breaking change to mark new internal versioning requirements.
  • Loading branch information
Salakar authored May 5, 2020
1 parent 27ff0cb commit 608fc55
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
12 changes: 11 additions & 1 deletion RNFBAnalytics.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
appPackage = JSON.parse(File.read(File.join('..', 'app', 'package.json')))

firebase_sdk_version = '~> 6.13.0'
coreVersionDetected = appPackage['version']
coreVersionRequired = package['peerDependencies'][appPackage['name']]
if appPackage['sdkVersions']
firebase_sdk_version = appPackage['sdkVersions']['ios']['firebase']
else
firebase_sdk_version = '~> 6.13.0'
end
if coreVersionDetected != coreVersionRequired
Pod::UI.warn "NPM package '#{package['name']}' depends on '#{appPackage['name']}' v#{coreVersionRequired} but found v#{coreVersionDetected}, this might cause build issues or runtime crashes."
end

Pod::Spec.new do |s|
s.name = "RNFBAnalytics"
Expand Down
33 changes: 25 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io.invertase.gradle.common.PackageJson

buildscript {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
Expand All @@ -18,6 +20,27 @@ plugins {
id "io.invertase.gradle.build" version "1.4"
}

def appProject
if (findProject(':@react-native-firebase_app')) {
appProject = project(':@react-native-firebase_app')
} else if (findProject(':react-native-firebase_app')) {
appProject = project(':react-native-firebase_app')
} else {
throw new GradleException('Could not find the react-native-firebase/app package, have you installed it?')
}
def packageJson = PackageJson.getForProject(project)
def appPackageJson = PackageJson.getForProject(appProject)
def firebaseBomVersion = appPackageJson['sdkVersions'] ? appPackageJson['sdkVersions']['android']['firebase'] : "24.1.0"
def coreVersionDetected = appPackageJson['version']
def coreVersionRequired = packageJson['peerDependencies'][appPackageJson['name']]
// Only log after build completed so log warning appears at the end
if (coreVersionDetected != coreVersionRequired) {
gradle.buildFinished {
project.logger.warn("ReactNativeFirebase WARNING: NPM package '${packageJson['name']}' depends on '${appPackageJson['name']}' v${coreVersionRequired} but found v${coreVersionDetected}, this might cause build issues or runtime crashes.")
}
}


project.ext {
set('react-native', [
versions: [
Expand All @@ -31,7 +54,7 @@ project.ext {
],

firebase : [
bom: "24.1.0",
bom: firebaseBomVersion,
],
],
])
Expand Down Expand Up @@ -62,13 +85,7 @@ repositories {
}

dependencies {
if (findProject(':@react-native-firebase_app')) {
api project(':@react-native-firebase_app')
} else if (findProject(':react-native-firebase_app')) {
api project(':react-native-firebase_app')
} else {
throw new GradleException('Could not find the react-native-firebase/app package, have you installed it?')
}
api appProject
implementation platform("com.google.firebase:firebase-bom:${ReactNative.ext.getVersion("firebase", "bom")}")
implementation "com.google.firebase:firebase-analytics"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"analytics"
],
"peerDependencies": {
"@react-native-firebase/app": "*"
"@react-native-firebase/app": "6.7.1"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 608fc55

Please sign in to comment.