@react-native-firebase/app-distribution 21.6.2 → 21.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [21.7.1](https://github.com/invertase/react-native-firebase/compare/v21.7.0...v21.7.1) (2025-01-20)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/app-distribution
9
+
10
+ ## [21.7.0](https://github.com/invertase/react-native-firebase/compare/v21.6.2...v21.7.0) (2025-01-16)
11
+
12
+ ### Features
13
+
14
+ - **app-distribution:** add Android app distribution plugin and configuration ([9b5c405](https://github.com/invertase/react-native-firebase/commit/9b5c405b2933c84daad561117a3eebacc65cbb7e))
15
+
6
16
  ## [21.6.2](https://github.com/invertase/react-native-firebase/compare/v21.6.1...v21.6.2) (2025-01-02)
7
17
 
8
18
  **Note:** Version bump only for package @react-native-firebase/app-distribution
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build');
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '21.6.2';
2
+ module.exports = '21.7.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/app-distribution",
3
- "version": "21.6.2",
3
+ "version": "21.7.1",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - App Distribution",
6
6
  "main": "lib/index.js",
@@ -8,7 +8,9 @@
8
8
  "scripts": {
9
9
  "build": "genversion --semi lib/version.js",
10
10
  "build:clean": "rimraf android/build && rimraf ios/build",
11
- "prepare": "yarn run build"
11
+ "build:plugin": "rimraf plugin/build && tsc --build plugin",
12
+ "lint:plugin": "eslint plugin/src/*",
13
+ "prepare": "yarn run build && yarn run build:plugin"
12
14
  },
13
15
  "repository": {
14
16
  "type": "git",
@@ -22,10 +24,19 @@
22
24
  "app-distribution"
23
25
  ],
24
26
  "peerDependencies": {
25
- "@react-native-firebase/app": "21.6.2"
27
+ "@react-native-firebase/app": "21.7.1",
28
+ "expo": ">=47.0.0"
29
+ },
30
+ "devDependencies": {
31
+ "expo": "^50.0.21"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "expo": {
35
+ "optional": true
36
+ }
26
37
  },
27
38
  "publishConfig": {
28
39
  "access": "public"
29
40
  },
30
- "gitHead": "f3c82a58ca9a7287f7b8478addf73d842e3d196b"
41
+ "gitHead": "a11363f77efa34b41cab2bc92ed9a700b814fd8d"
31
42
  }
@@ -0,0 +1 @@
1
+ Please see the `packages/app/plugin/__tests__/README.md`.
@@ -0,0 +1,167 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`App distribution Plugin Android Tests applies app distribution classpath to project build.gradle 1`] = `
4
+ "// Top-level build file where you can add configuration options common to all sub-projects/modules.
5
+
6
+ buildscript {
7
+ ext {
8
+ buildToolsVersion = "29.0.3"
9
+ minSdkVersion = 21
10
+ compileSdkVersion = 30
11
+ targetSdkVersion = 30
12
+ }
13
+ repositories {
14
+ google()
15
+ jcenter()
16
+ }
17
+ dependencies {
18
+ classpath 'com.google.firebase:firebase-appdistribution-gradle:5.0.0'
19
+ classpath("com.android.tools.build:gradle:4.1.0")
20
+
21
+ // NOTE: Do not place your application dependencies here; they belong
22
+ // in the individual module build.gradle files
23
+ }
24
+ }
25
+
26
+ allprojects {
27
+ repositories {
28
+ mavenLocal()
29
+ maven {
30
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
31
+ url("$rootDir/../node_modules/react-native/android")
32
+ }
33
+ maven {
34
+ // Android JSC is installed from npm
35
+ url("$rootDir/../node_modules/jsc-android/dist")
36
+ }
37
+
38
+ google()
39
+ jcenter()
40
+ maven { url 'https://www.jitpack.io' }
41
+ }
42
+ }
43
+ "
44
+ `;
45
+
46
+ exports[`App distribution Plugin Android Tests applies app distribution plugin to app/build.gradle 1`] = `
47
+ "/* Example build.gradle file from https://github.com/expo/expo/blob/6ab0274b5cb9a9c223e0d453787a522b438b4fcb/templates/expo-template-bare-minimum/android/app/build.gradle */
48
+
49
+ apply plugin: "com.android.application"
50
+
51
+ import com.android.build.OutputFile
52
+
53
+
54
+ project.ext.react = [
55
+ enableHermes: false
56
+ ]
57
+
58
+ apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
59
+ apply from: "../../node_modules/react-native/react.gradle"
60
+ apply from: "../../node_modules/expo-constants/scripts/get-app-config-android.gradle"
61
+ apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"
62
+
63
+ def enableSeparateBuildPerCPUArchitecture = false
64
+
65
+ def enableProguardInReleaseBuilds = false
66
+
67
+ def jscFlavor = 'org.webkit:android-jsc:+'
68
+
69
+ def enableHermes = project.ext.react.get("enableHermes", false);
70
+
71
+ android {
72
+ compileSdkVersion rootProject.ext.compileSdkVersion
73
+
74
+ compileOptions {
75
+ sourceCompatibility JavaVersion.VERSION_1_8
76
+ targetCompatibility JavaVersion.VERSION_1_8
77
+ }
78
+
79
+ defaultConfig {
80
+ applicationId "com.helloworld"
81
+ minSdkVersion rootProject.ext.minSdkVersion
82
+ targetSdkVersion rootProject.ext.targetSdkVersion
83
+ versionCode 1
84
+ versionName "1.0"
85
+ }
86
+ splits {
87
+ abi {
88
+ reset()
89
+ enable enableSeparateBuildPerCPUArchitecture
90
+ universalApk false // If true, also generate a universal APK
91
+ include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
92
+ }
93
+ }
94
+ signingConfigs {
95
+ debug {
96
+ storeFile file('debug.keystore')
97
+ storePassword 'android'
98
+ keyAlias 'androiddebugkey'
99
+ keyPassword 'android'
100
+ }
101
+ }
102
+ buildTypes {
103
+ debug {
104
+ signingConfig signingConfigs.debug
105
+ }
106
+ release {
107
+ // Caution! In production, you need to generate your own keystore file.
108
+ // see https://reactnative.dev/docs/signed-apk-android.
109
+ signingConfig signingConfigs.debug
110
+ minifyEnabled enableProguardInReleaseBuilds
111
+ proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
112
+ }
113
+ }
114
+
115
+ // applicationVariants are e.g. debug, release
116
+ applicationVariants.all { variant ->
117
+ variant.outputs.each { output ->
118
+ // For each separate APK per architecture, set a unique version code as described here:
119
+ // https://developer.android.com/studio/build/configure-apk-splits.html
120
+ def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
121
+ def abi = output.getFilter(OutputFile.ABI)
122
+ if (abi != null) { // null for the universal-debug, universal-release variants
123
+ output.versionCodeOverride =
124
+ versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
125
+ }
126
+
127
+ }
128
+ }
129
+ }
130
+
131
+ dependencies {
132
+ implementation fileTree(dir: "libs", include: ["*.jar"])
133
+ //noinspection GradleDynamicVersion
134
+ implementation "com.facebook.react:react-native:+" // From node_modules
135
+ implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
136
+ debugImplementation("com.facebook.flipper:flipper:\${FLIPPER_VERSION}") {
137
+ exclude group:'com.facebook.fbjni'
138
+ }
139
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:\${FLIPPER_VERSION}") {
140
+ exclude group:'com.facebook.flipper'
141
+ exclude group:'com.squareup.okhttp3', module:'okhttp'
142
+ }
143
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:\${FLIPPER_VERSION}") {
144
+ exclude group:'com.facebook.flipper'
145
+ }
146
+ addUnimodulesDependencies()
147
+
148
+ if (enableHermes) {
149
+ def hermesPath = "../../node_modules/hermes-engine/android/";
150
+ debugImplementation files(hermesPath + "hermes-debug.aar")
151
+ releaseImplementation files(hermesPath + "hermes-release.aar")
152
+ } else {
153
+ implementation jscFlavor
154
+ }
155
+ }
156
+
157
+ // Run this once to be able to run the application with BUCK
158
+ // puts all compile dependencies into folder libs for BUCK to use
159
+ task copyDownloadableDepsToLibs(type: Copy) {
160
+ from configurations.compile
161
+ into 'libs'
162
+ }
163
+
164
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
165
+
166
+ apply plugin: 'com.google.firebase.appdistribution'"
167
+ `;
@@ -0,0 +1,32 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import { beforeAll, describe, expect, it } from '@jest/globals';
4
+
5
+ import { applyPlugin } from '../src/android/applyPlugin';
6
+ import { setBuildscriptDependency } from '../src/android/buildscriptDependency';
7
+
8
+ describe('App distribution Plugin Android Tests', function () {
9
+ let appBuildGradle: string;
10
+ let projectBuildGradle: string;
11
+
12
+ beforeAll(async function () {
13
+ projectBuildGradle = await fs.readFile(
14
+ path.resolve(__dirname, './fixtures/project_build.gradle'),
15
+ { encoding: 'utf-8' },
16
+ );
17
+
18
+ appBuildGradle = await fs.readFile(path.resolve(__dirname, './fixtures/app_build.gradle'), {
19
+ encoding: 'utf-8',
20
+ });
21
+ });
22
+
23
+ it('applies app distribution classpath to project build.gradle', async function () {
24
+ const result = setBuildscriptDependency(projectBuildGradle);
25
+ expect(result).toMatchSnapshot();
26
+ });
27
+
28
+ it('applies app distribution plugin to app/build.gradle', async function () {
29
+ const result = applyPlugin(appBuildGradle);
30
+ expect(result).toMatchSnapshot();
31
+ });
32
+ });
@@ -0,0 +1,118 @@
1
+ /* Example build.gradle file from https://github.com/expo/expo/blob/6ab0274b5cb9a9c223e0d453787a522b438b4fcb/templates/expo-template-bare-minimum/android/app/build.gradle */
2
+
3
+ apply plugin: "com.android.application"
4
+
5
+ import com.android.build.OutputFile
6
+
7
+
8
+ project.ext.react = [
9
+ enableHermes: false
10
+ ]
11
+
12
+ apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
13
+ apply from: "../../node_modules/react-native/react.gradle"
14
+ apply from: "../../node_modules/expo-constants/scripts/get-app-config-android.gradle"
15
+ apply from: "../../node_modules/expo-updates/scripts/create-manifest-android.gradle"
16
+
17
+ def enableSeparateBuildPerCPUArchitecture = false
18
+
19
+ def enableProguardInReleaseBuilds = false
20
+
21
+ def jscFlavor = 'org.webkit:android-jsc:+'
22
+
23
+ def enableHermes = project.ext.react.get("enableHermes", false);
24
+
25
+ android {
26
+ compileSdkVersion rootProject.ext.compileSdkVersion
27
+
28
+ compileOptions {
29
+ sourceCompatibility JavaVersion.VERSION_1_8
30
+ targetCompatibility JavaVersion.VERSION_1_8
31
+ }
32
+
33
+ defaultConfig {
34
+ applicationId "com.helloworld"
35
+ minSdkVersion rootProject.ext.minSdkVersion
36
+ targetSdkVersion rootProject.ext.targetSdkVersion
37
+ versionCode 1
38
+ versionName "1.0"
39
+ }
40
+ splits {
41
+ abi {
42
+ reset()
43
+ enable enableSeparateBuildPerCPUArchitecture
44
+ universalApk false // If true, also generate a universal APK
45
+ include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
46
+ }
47
+ }
48
+ signingConfigs {
49
+ debug {
50
+ storeFile file('debug.keystore')
51
+ storePassword 'android'
52
+ keyAlias 'androiddebugkey'
53
+ keyPassword 'android'
54
+ }
55
+ }
56
+ buildTypes {
57
+ debug {
58
+ signingConfig signingConfigs.debug
59
+ }
60
+ release {
61
+ // Caution! In production, you need to generate your own keystore file.
62
+ // see https://reactnative.dev/docs/signed-apk-android.
63
+ signingConfig signingConfigs.debug
64
+ minifyEnabled enableProguardInReleaseBuilds
65
+ proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
66
+ }
67
+ }
68
+
69
+ // applicationVariants are e.g. debug, release
70
+ applicationVariants.all { variant ->
71
+ variant.outputs.each { output ->
72
+ // For each separate APK per architecture, set a unique version code as described here:
73
+ // https://developer.android.com/studio/build/configure-apk-splits.html
74
+ def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
75
+ def abi = output.getFilter(OutputFile.ABI)
76
+ if (abi != null) { // null for the universal-debug, universal-release variants
77
+ output.versionCodeOverride =
78
+ versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
79
+ }
80
+
81
+ }
82
+ }
83
+ }
84
+
85
+ dependencies {
86
+ implementation fileTree(dir: "libs", include: ["*.jar"])
87
+ //noinspection GradleDynamicVersion
88
+ implementation "com.facebook.react:react-native:+" // From node_modules
89
+ implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
90
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
91
+ exclude group:'com.facebook.fbjni'
92
+ }
93
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
94
+ exclude group:'com.facebook.flipper'
95
+ exclude group:'com.squareup.okhttp3', module:'okhttp'
96
+ }
97
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
98
+ exclude group:'com.facebook.flipper'
99
+ }
100
+ addUnimodulesDependencies()
101
+
102
+ if (enableHermes) {
103
+ def hermesPath = "../../node_modules/hermes-engine/android/";
104
+ debugImplementation files(hermesPath + "hermes-debug.aar")
105
+ releaseImplementation files(hermesPath + "hermes-release.aar")
106
+ } else {
107
+ implementation jscFlavor
108
+ }
109
+ }
110
+
111
+ // Run this once to be able to run the application with BUCK
112
+ // puts all compile dependencies into folder libs for BUCK to use
113
+ task copyDownloadableDepsToLibs(type: Copy) {
114
+ from configurations.compile
115
+ into 'libs'
116
+ }
117
+
118
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
@@ -0,0 +1,38 @@
1
+ // Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+
3
+ buildscript {
4
+ ext {
5
+ buildToolsVersion = "29.0.3"
6
+ minSdkVersion = 21
7
+ compileSdkVersion = 30
8
+ targetSdkVersion = 30
9
+ }
10
+ repositories {
11
+ google()
12
+ jcenter()
13
+ }
14
+ dependencies {
15
+ classpath("com.android.tools.build:gradle:4.1.0")
16
+
17
+ // NOTE: Do not place your application dependencies here; they belong
18
+ // in the individual module build.gradle files
19
+ }
20
+ }
21
+
22
+ allprojects {
23
+ repositories {
24
+ mavenLocal()
25
+ maven {
26
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
27
+ url("$rootDir/../node_modules/react-native/android")
28
+ }
29
+ maven {
30
+ // Android JSC is installed from npm
31
+ url("$rootDir/../node_modules/jsc-android/dist")
32
+ }
33
+
34
+ google()
35
+ jcenter()
36
+ maven { url 'https://www.jitpack.io' }
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ /**
3
+ * Update `app/build.gradle` by applying app-distribution monitoring plugin
4
+ */
5
+ export declare const withApplyappDistributionPlugin: ConfigPlugin;
6
+ export declare function applyPlugin(appBuildGradle: string): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withApplyappDistributionPlugin = void 0;
4
+ exports.applyPlugin = applyPlugin;
5
+ const config_plugins_1 = require("@expo/config-plugins");
6
+ const constants_1 = require("./constants");
7
+ /**
8
+ * Update `app/build.gradle` by applying app-distribution monitoring plugin
9
+ */
10
+ const withApplyappDistributionPlugin = config => {
11
+ return (0, config_plugins_1.withAppBuildGradle)(config, config => {
12
+ if (config.modResults.language === 'groovy') {
13
+ config.modResults.contents = applyPlugin(config.modResults.contents);
14
+ }
15
+ else {
16
+ config_plugins_1.WarningAggregator.addWarningAndroid('react-native-firebase-app-distribution', `Cannot automatically configure app build.gradle if it's not groovy`);
17
+ }
18
+ return config;
19
+ });
20
+ };
21
+ exports.withApplyappDistributionPlugin = withApplyappDistributionPlugin;
22
+ function applyPlugin(appBuildGradle) {
23
+ const appDistributionPattern = new RegExp(`apply\\s+plugin:\\s+['"]${constants_1.appDistributionMonitoringPlugin}['"]`);
24
+ if (!appBuildGradle.match(appDistributionPattern)) {
25
+ appBuildGradle += `\napply plugin: '${constants_1.appDistributionMonitoringPlugin}'`;
26
+ }
27
+ return appBuildGradle;
28
+ }
@@ -0,0 +1,6 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ /**
3
+ * Update `<project>/build.gradle` by adding app-distribution dependency to buildscript
4
+ */
5
+ export declare const withBuildscriptDependency: ConfigPlugin;
6
+ export declare function setBuildscriptDependency(buildGradle: string): string;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withBuildscriptDependency = void 0;
4
+ exports.setBuildscriptDependency = setBuildscriptDependency;
5
+ const config_plugins_1 = require("@expo/config-plugins");
6
+ const constants_1 = require("./constants");
7
+ /**
8
+ * Update `<project>/build.gradle` by adding app-distribution dependency to buildscript
9
+ */
10
+ const withBuildscriptDependency = config => {
11
+ return (0, config_plugins_1.withProjectBuildGradle)(config, config => {
12
+ if (config.modResults.language === 'groovy') {
13
+ config.modResults.contents = setBuildscriptDependency(config.modResults.contents);
14
+ }
15
+ else {
16
+ config_plugins_1.WarningAggregator.addWarningAndroid('react-native-firebase-app-distribution', `Cannot automatically configure project build.gradle if it's not groovy`);
17
+ }
18
+ return config;
19
+ });
20
+ };
21
+ exports.withBuildscriptDependency = withBuildscriptDependency;
22
+ function setBuildscriptDependency(buildGradle) {
23
+ // TODO: Find a more stable solution for this
24
+ if (!buildGradle.includes(constants_1.appDistributionMonitoringClassPath)) {
25
+ return buildGradle.replace(/dependencies\s?{/, `dependencies {
26
+ classpath '${constants_1.appDistributionMonitoringClassPath}:${constants_1.appDistributionMonitoringVersion}'`);
27
+ }
28
+ return buildGradle;
29
+ }
@@ -0,0 +1,3 @@
1
+ export declare const appDistributionMonitoringClassPath = "com.google.firebase:firebase-appdistribution-gradle";
2
+ export declare const appDistributionMonitoringPlugin = "com.google.firebase.appdistribution";
3
+ export declare const appDistributionMonitoringVersion: any;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appDistributionMonitoringVersion = exports.appDistributionMonitoringPlugin = exports.appDistributionMonitoringClassPath = void 0;
4
+ const appPackageJson = require('@react-native-firebase/app/package.json');
5
+ exports.appDistributionMonitoringClassPath = 'com.google.firebase:firebase-appdistribution-gradle';
6
+ exports.appDistributionMonitoringPlugin = 'com.google.firebase.appdistribution';
7
+ exports.appDistributionMonitoringVersion = appPackageJson.sdkVersions.android.firebaseAppDistributionGradle;
@@ -0,0 +1,3 @@
1
+ import { withApplyappDistributionPlugin } from './applyPlugin';
2
+ import { withBuildscriptDependency } from './buildscriptDependency';
3
+ export { withBuildscriptDependency, withApplyappDistributionPlugin };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withApplyappDistributionPlugin = exports.withBuildscriptDependency = void 0;
4
+ const applyPlugin_1 = require("./applyPlugin");
5
+ Object.defineProperty(exports, "withApplyappDistributionPlugin", { enumerable: true, get: function () { return applyPlugin_1.withApplyappDistributionPlugin; } });
6
+ const buildscriptDependency_1 = require("./buildscriptDependency");
7
+ Object.defineProperty(exports, "withBuildscriptDependency", { enumerable: true, get: function () { return buildscriptDependency_1.withBuildscriptDependency; } });
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ declare const _default: ConfigPlugin<void>;
3
+ export default _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("@expo/config-plugins");
4
+ const android_1 = require("./android");
5
+ /**
6
+ * A config plugin for configuring `@react-native-firebase/app-distribution`
7
+ */
8
+ const withRnFirebaseAppDistribution = config => {
9
+ return (0, config_plugins_1.withPlugins)(config, [android_1.withBuildscriptDependency, android_1.withApplyappDistributionPlugin]);
10
+ };
11
+ const pak = require('@react-native-firebase/app-distribution/package.json');
12
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withRnFirebaseAppDistribution, pak.name, pak.version);
@@ -0,0 +1,29 @@
1
+ import { ConfigPlugin, WarningAggregator, withAppBuildGradle } from '@expo/config-plugins';
2
+ import { appDistributionMonitoringPlugin } from './constants';
3
+
4
+ /**
5
+ * Update `app/build.gradle` by applying app-distribution monitoring plugin
6
+ */
7
+ export const withApplyappDistributionPlugin: ConfigPlugin = config => {
8
+ return withAppBuildGradle(config, config => {
9
+ if (config.modResults.language === 'groovy') {
10
+ config.modResults.contents = applyPlugin(config.modResults.contents);
11
+ } else {
12
+ WarningAggregator.addWarningAndroid(
13
+ 'react-native-firebase-app-distribution',
14
+ `Cannot automatically configure app build.gradle if it's not groovy`,
15
+ );
16
+ }
17
+ return config;
18
+ });
19
+ };
20
+
21
+ export function applyPlugin(appBuildGradle: string) {
22
+ const appDistributionPattern = new RegExp(
23
+ `apply\\s+plugin:\\s+['"]${appDistributionMonitoringPlugin}['"]`,
24
+ );
25
+ if (!appBuildGradle.match(appDistributionPattern)) {
26
+ appBuildGradle += `\napply plugin: '${appDistributionMonitoringPlugin}'`;
27
+ }
28
+ return appBuildGradle;
29
+ }
@@ -0,0 +1,33 @@
1
+ import { ConfigPlugin, WarningAggregator, withProjectBuildGradle } from '@expo/config-plugins';
2
+
3
+ import { appDistributionMonitoringClassPath, appDistributionMonitoringVersion } from './constants';
4
+
5
+ /**
6
+ * Update `<project>/build.gradle` by adding app-distribution dependency to buildscript
7
+ */
8
+ export const withBuildscriptDependency: ConfigPlugin = config => {
9
+ return withProjectBuildGradle(config, config => {
10
+ if (config.modResults.language === 'groovy') {
11
+ config.modResults.contents = setBuildscriptDependency(config.modResults.contents);
12
+ } else {
13
+ WarningAggregator.addWarningAndroid(
14
+ 'react-native-firebase-app-distribution',
15
+ `Cannot automatically configure project build.gradle if it's not groovy`,
16
+ );
17
+ }
18
+ return config;
19
+ });
20
+ };
21
+
22
+ export function setBuildscriptDependency(buildGradle: string) {
23
+ // TODO: Find a more stable solution for this
24
+ if (!buildGradle.includes(appDistributionMonitoringClassPath)) {
25
+ return buildGradle.replace(
26
+ /dependencies\s?{/,
27
+ `dependencies {
28
+ classpath '${appDistributionMonitoringClassPath}:${appDistributionMonitoringVersion}'`,
29
+ );
30
+ }
31
+
32
+ return buildGradle;
33
+ }
@@ -0,0 +1,7 @@
1
+ const appPackageJson = require('@react-native-firebase/app/package.json');
2
+
3
+ export const appDistributionMonitoringClassPath =
4
+ 'com.google.firebase:firebase-appdistribution-gradle';
5
+ export const appDistributionMonitoringPlugin = 'com.google.firebase.appdistribution';
6
+ export const appDistributionMonitoringVersion =
7
+ appPackageJson.sdkVersions.android.firebaseAppDistributionGradle;
@@ -0,0 +1,4 @@
1
+ import { withApplyappDistributionPlugin } from './applyPlugin';
2
+ import { withBuildscriptDependency } from './buildscriptDependency';
3
+
4
+ export { withBuildscriptDependency, withApplyappDistributionPlugin };
@@ -0,0 +1,13 @@
1
+ import { ConfigPlugin, withPlugins, createRunOncePlugin } from '@expo/config-plugins';
2
+
3
+ import { withApplyappDistributionPlugin, withBuildscriptDependency } from './android';
4
+
5
+ /**
6
+ * A config plugin for configuring `@react-native-firebase/app-distribution`
7
+ */
8
+ const withRnFirebaseAppDistribution: ConfigPlugin = config => {
9
+ return withPlugins(config, [withBuildscriptDependency, withApplyappDistributionPlugin]);
10
+ };
11
+
12
+ const pak = require('@react-native-firebase/app-distribution/package.json');
13
+ export default createRunOncePlugin(withRnFirebaseAppDistribution, pak.name, pak.version);
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@tsconfig/node-lts/tsconfig",
3
+ "compilerOptions": {
4
+ "outDir": "build",
5
+ "rootDir": "src",
6
+ "declaration": true
7
+ },
8
+ "include": ["./src"]
9
+ }
@@ -0,0 +1 @@
1
+ {"root":["./src/index.ts","./src/android/applyPlugin.ts","./src/android/buildscriptDependency.ts","./src/android/constants.ts","./src/android/index.ts"],"version":"5.6.2"}