@react-native-firebase/app 12.9.1 → 12.9.2
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 +6 -0
- package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
- package/ios/RNFBApp/RNFBVersion.m +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/plugin/build/ios/appDelegate.js +15 -6
- package/plugin/src/android/applyPlugin.ts +30 -0
- package/plugin/src/android/buildscriptDependency.ts +33 -0
- package/plugin/src/android/constants.ts +7 -0
- package/plugin/src/android/copyGoogleServices.ts +36 -0
- package/plugin/src/android/index.ts +5 -0
- package/plugin/src/index.ts +27 -0
- package/plugin/src/ios/appDelegate.ts +55 -0
- package/plugin/src/ios/googleServicesPlist.ts +55 -0
- package/plugin/src/ios/index.ts +4 -0
- package/plugin/tsconfig.json +9 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
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
|
+
## [12.9.2](https://github.com/invertase/react-native-firebase/compare/v12.9.1...v12.9.2) (2021-10-17)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
- **app, expo:** update iOS `AppDelegate` plugin to work with Expo SDK 43 ([#5796](https://github.com/invertase/react-native-firebase/issues/5796)) ([d67c3b9](https://github.com/invertase/react-native-firebase/commit/d67c3b906d1bb6d858269efba8b597891faf8772))
|
11
|
+
|
6
12
|
## [12.9.1](https://github.com/invertase/react-native-firebase/compare/v12.9.0...v12.9.1) (2021-10-10)
|
7
13
|
|
8
14
|
### Bug Fixes
|
package/lib/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// generated by genversion
|
2
|
-
module.exports = '12.9.
|
2
|
+
module.exports = '12.9.2';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-firebase/app",
|
3
|
-
"version": "12.9.
|
3
|
+
"version": "12.9.2",
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
5
5
|
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Storage and more.",
|
6
6
|
"main": "lib/index.js",
|
@@ -79,5 +79,5 @@
|
|
79
79
|
"playServicesAuth": "19.2.0"
|
80
80
|
}
|
81
81
|
},
|
82
|
-
"gitHead": "
|
82
|
+
"gitHead": "6f435cf294f3d7e0876cff4dda415b1c9bfe6099"
|
83
83
|
}
|
@@ -5,21 +5,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.withFirebaseAppDelegate = exports.modifyObjcAppDelegate = void 0;
|
7
7
|
const config_plugins_1 = require("@expo/config-plugins");
|
8
|
+
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
8
9
|
const fs_1 = __importDefault(require("fs"));
|
9
10
|
const methodInvocationBlock = `[FIRApp configure];`;
|
11
|
+
// https://regex101.com/r/Imm3E8/1
|
12
|
+
const methodInvocationLineMatcher = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])/g;
|
10
13
|
function modifyObjcAppDelegate(contents) {
|
11
14
|
// Add import
|
12
15
|
if (!contents.includes('@import Firebase;')) {
|
13
16
|
contents = contents.replace(/#import "AppDelegate.h"/g, `#import "AppDelegate.h"
|
14
17
|
@import Firebase;`);
|
15
18
|
}
|
16
|
-
//
|
17
|
-
if (
|
18
|
-
|
19
|
-
contents = contents.replace(/self\.moduleRegistryAdapter = \[\[UMModuleRegistryAdapter alloc\]/g, `${methodInvocationBlock}
|
20
|
-
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc]`);
|
19
|
+
// To avoid potential issues with existing changes from older plugin versions
|
20
|
+
if (contents.includes(methodInvocationBlock)) {
|
21
|
+
return contents;
|
21
22
|
}
|
22
|
-
|
23
|
+
// Add invocation
|
24
|
+
return (0, generateCode_1.mergeContents)({
|
25
|
+
tag: '@react-native-firebase/app-didFinishLaunchingWithOptions',
|
26
|
+
src: contents,
|
27
|
+
newSrc: methodInvocationBlock,
|
28
|
+
anchor: methodInvocationLineMatcher,
|
29
|
+
offset: 0,
|
30
|
+
comment: '//',
|
31
|
+
}).contents;
|
23
32
|
}
|
24
33
|
exports.modifyObjcAppDelegate = modifyObjcAppDelegate;
|
25
34
|
const withFirebaseAppDelegate = config => {
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { ConfigPlugin, WarningAggregator, withAppBuildGradle } from '@expo/config-plugins';
|
2
|
+
|
3
|
+
import { googleServicesPlugin } from './constants';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Update `app/build.gradle` by applying google-services plugin
|
7
|
+
*/
|
8
|
+
export const withApplyGoogleServicesPlugin: ConfigPlugin = config => {
|
9
|
+
return withAppBuildGradle(config, config => {
|
10
|
+
if (config.modResults.language === 'groovy') {
|
11
|
+
config.modResults.contents = applyPlugin(config.modResults.contents);
|
12
|
+
} else {
|
13
|
+
WarningAggregator.addWarningAndroid(
|
14
|
+
'react-native-firebase-app',
|
15
|
+
`Cannot automatically configure app build.gradle if it's not groovy`,
|
16
|
+
);
|
17
|
+
}
|
18
|
+
return config;
|
19
|
+
});
|
20
|
+
};
|
21
|
+
|
22
|
+
export function applyPlugin(appBuildGradle: string) {
|
23
|
+
// Make sure the project does not have the plugin already
|
24
|
+
const pattern = new RegExp(`apply\\s+plugin:\\s+['"]${googleServicesPlugin}['"]`);
|
25
|
+
if (!appBuildGradle.match(pattern)) {
|
26
|
+
return appBuildGradle + `\napply plugin: '${googleServicesPlugin}'`;
|
27
|
+
}
|
28
|
+
|
29
|
+
return appBuildGradle;
|
30
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { ConfigPlugin, WarningAggregator, withProjectBuildGradle } from '@expo/config-plugins';
|
2
|
+
|
3
|
+
import { googleServicesClassPath, googleServicesVersion } from './constants';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Update `<project>/build.gradle` by adding google-services 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',
|
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
|
+
if (!buildGradle.includes(googleServicesClassPath)) {
|
24
|
+
// TODO: Find a more stable solution for this
|
25
|
+
return buildGradle.replace(
|
26
|
+
/dependencies\s?{/,
|
27
|
+
`dependencies {
|
28
|
+
classpath '${googleServicesClassPath}:${googleServicesVersion}'`,
|
29
|
+
);
|
30
|
+
} else {
|
31
|
+
return buildGradle;
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
const appPackageJson = require('@react-native-firebase/app/package.json');
|
2
|
+
|
3
|
+
export const DEFAULT_TARGET_PATH = 'app/google-services.json';
|
4
|
+
|
5
|
+
export const googleServicesClassPath = 'com.google.gms:google-services';
|
6
|
+
export const googleServicesPlugin = 'com.google.gms.google-services';
|
7
|
+
export const googleServicesVersion = appPackageJson.sdkVersions.android.gmsGoogleServicesGradle;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ConfigPlugin, withDangerousMod } from '@expo/config-plugins';
|
2
|
+
|
3
|
+
import { DEFAULT_TARGET_PATH } from './constants';
|
4
|
+
import path from 'path';
|
5
|
+
import fs from 'fs';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Copy `google-services.json`
|
9
|
+
*/
|
10
|
+
export const withCopyAndroidGoogleServices: ConfigPlugin = config => {
|
11
|
+
return withDangerousMod(config, [
|
12
|
+
'android',
|
13
|
+
async config => {
|
14
|
+
if (!config.android?.googleServicesFile) {
|
15
|
+
throw new Error(
|
16
|
+
'Path to google-services.json is not defined. Please specify the `expo.android.googleServicesFile` field in app.json.',
|
17
|
+
);
|
18
|
+
}
|
19
|
+
|
20
|
+
const srcPath = path.resolve(
|
21
|
+
config.modRequest.projectRoot,
|
22
|
+
config.android.googleServicesFile,
|
23
|
+
);
|
24
|
+
const destPath = path.resolve(config.modRequest.platformProjectRoot, DEFAULT_TARGET_PATH);
|
25
|
+
|
26
|
+
try {
|
27
|
+
await fs.promises.copyFile(srcPath, destPath);
|
28
|
+
} catch (e) {
|
29
|
+
throw new Error(
|
30
|
+
`Cannot copy google-services.json, because the file ${srcPath} doesn't exist. Please provide a valid path in \`app.json\`.`,
|
31
|
+
);
|
32
|
+
}
|
33
|
+
return config;
|
34
|
+
},
|
35
|
+
]);
|
36
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { withApplyGoogleServicesPlugin } from './applyPlugin';
|
2
|
+
import { withBuildscriptDependency } from './buildscriptDependency';
|
3
|
+
import { withCopyAndroidGoogleServices } from './copyGoogleServices';
|
4
|
+
|
5
|
+
export { withBuildscriptDependency, withApplyGoogleServicesPlugin, withCopyAndroidGoogleServices };
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { ConfigPlugin, withPlugins, createRunOncePlugin } from '@expo/config-plugins';
|
2
|
+
|
3
|
+
import {
|
4
|
+
withApplyGoogleServicesPlugin,
|
5
|
+
withBuildscriptDependency,
|
6
|
+
withCopyAndroidGoogleServices,
|
7
|
+
} from './android';
|
8
|
+
import { withFirebaseAppDelegate, withIosGoogleServicesFile } from './ios';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* A config plugin for configuring `@react-native-firebase/app`
|
12
|
+
*/
|
13
|
+
const withRnFirebaseApp: ConfigPlugin = config => {
|
14
|
+
return withPlugins(config, [
|
15
|
+
// iOS
|
16
|
+
withFirebaseAppDelegate,
|
17
|
+
withIosGoogleServicesFile,
|
18
|
+
|
19
|
+
// Android
|
20
|
+
withBuildscriptDependency,
|
21
|
+
withApplyGoogleServicesPlugin,
|
22
|
+
withCopyAndroidGoogleServices,
|
23
|
+
]);
|
24
|
+
};
|
25
|
+
|
26
|
+
const pak = require('@react-native-firebase/app/package.json');
|
27
|
+
export default createRunOncePlugin(withRnFirebaseApp, pak.name, pak.version);
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { ConfigPlugin, IOSConfig, withDangerousMod } from '@expo/config-plugins';
|
2
|
+
import { mergeContents } from '@expo/config-plugins/build/utils/generateCode';
|
3
|
+
import fs from 'fs';
|
4
|
+
|
5
|
+
const methodInvocationBlock = `[FIRApp configure];`;
|
6
|
+
// https://regex101.com/r/Imm3E8/1
|
7
|
+
const methodInvocationLineMatcher =
|
8
|
+
/(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])/g;
|
9
|
+
|
10
|
+
export function modifyObjcAppDelegate(contents: string): string {
|
11
|
+
// Add import
|
12
|
+
if (!contents.includes('@import Firebase;')) {
|
13
|
+
contents = contents.replace(
|
14
|
+
/#import "AppDelegate.h"/g,
|
15
|
+
`#import "AppDelegate.h"
|
16
|
+
@import Firebase;`,
|
17
|
+
);
|
18
|
+
}
|
19
|
+
|
20
|
+
// To avoid potential issues with existing changes from older plugin versions
|
21
|
+
if (contents.includes(methodInvocationBlock)) {
|
22
|
+
return contents;
|
23
|
+
}
|
24
|
+
|
25
|
+
// Add invocation
|
26
|
+
return mergeContents({
|
27
|
+
tag: '@react-native-firebase/app-didFinishLaunchingWithOptions',
|
28
|
+
src: contents,
|
29
|
+
newSrc: methodInvocationBlock,
|
30
|
+
anchor: methodInvocationLineMatcher,
|
31
|
+
offset: 0, // new line will be inserted right before matched anchor
|
32
|
+
comment: '//',
|
33
|
+
}).contents;
|
34
|
+
}
|
35
|
+
|
36
|
+
export const withFirebaseAppDelegate: ConfigPlugin = config => {
|
37
|
+
return withDangerousMod(config, [
|
38
|
+
'ios',
|
39
|
+
async config => {
|
40
|
+
const fileInfo = IOSConfig.Paths.getAppDelegate(config.modRequest.projectRoot);
|
41
|
+
let contents = await fs.promises.readFile(fileInfo.path, 'utf-8');
|
42
|
+
if (fileInfo.language === 'objc') {
|
43
|
+
contents = modifyObjcAppDelegate(contents);
|
44
|
+
} else {
|
45
|
+
// TODO: Support Swift
|
46
|
+
throw new Error(
|
47
|
+
`Cannot add Firebase code to AppDelegate of language "${fileInfo.language}"`,
|
48
|
+
);
|
49
|
+
}
|
50
|
+
await fs.promises.writeFile(fileInfo.path, contents);
|
51
|
+
|
52
|
+
return config;
|
53
|
+
},
|
54
|
+
]);
|
55
|
+
};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { ConfigPlugin, IOSConfig, withXcodeProject, XcodeProject } from '@expo/config-plugins';
|
2
|
+
import fs from 'fs';
|
3
|
+
import path from 'path';
|
4
|
+
|
5
|
+
export const withIosGoogleServicesFile: ConfigPlugin = config => {
|
6
|
+
return withXcodeProject(config, config => {
|
7
|
+
if (!config.ios?.googleServicesFile) {
|
8
|
+
throw new Error(
|
9
|
+
'Path to GoogleService-Info.plist is not defined. Please specify the `expo.ios.googleServicesFile` field in app.json.',
|
10
|
+
);
|
11
|
+
}
|
12
|
+
|
13
|
+
config.modResults = setGoogleServicesFile({
|
14
|
+
projectRoot: config.modRequest.projectRoot,
|
15
|
+
project: config.modResults,
|
16
|
+
googleServicesFileRelativePath: config.ios.googleServicesFile,
|
17
|
+
});
|
18
|
+
return config;
|
19
|
+
});
|
20
|
+
};
|
21
|
+
|
22
|
+
export function setGoogleServicesFile({
|
23
|
+
projectRoot,
|
24
|
+
project,
|
25
|
+
googleServicesFileRelativePath,
|
26
|
+
}: {
|
27
|
+
project: XcodeProject;
|
28
|
+
projectRoot: string;
|
29
|
+
googleServicesFileRelativePath: string;
|
30
|
+
}): XcodeProject {
|
31
|
+
const googleServiceFilePath = path.resolve(projectRoot, googleServicesFileRelativePath);
|
32
|
+
|
33
|
+
if (!fs.existsSync(googleServiceFilePath)) {
|
34
|
+
throw new Error(
|
35
|
+
`GoogleService-Info.plist doesn't exist in ${googleServiceFilePath}. Place it there or configure the path in app.json`,
|
36
|
+
);
|
37
|
+
}
|
38
|
+
|
39
|
+
fs.copyFileSync(
|
40
|
+
googleServiceFilePath,
|
41
|
+
path.join(IOSConfig.Paths.getSourceRoot(projectRoot), 'GoogleService-Info.plist'),
|
42
|
+
);
|
43
|
+
|
44
|
+
const projectName = IOSConfig.XcodeUtils.getProjectName(projectRoot);
|
45
|
+
const plistFilePath = `${projectName}/GoogleService-Info.plist`;
|
46
|
+
if (!project.hasFile(plistFilePath)) {
|
47
|
+
project = IOSConfig.XcodeUtils.addResourceFileToGroup({
|
48
|
+
filepath: plistFilePath,
|
49
|
+
groupName: projectName,
|
50
|
+
project,
|
51
|
+
isBuildFile: true,
|
52
|
+
});
|
53
|
+
}
|
54
|
+
return project;
|
55
|
+
}
|