@dubsdotapp/expo 0.2.65 → 0.2.66

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.
Files changed (2) hide show
  1. package/app.plugin.js +53 -38
  2. package/package.json +1 -1
package/app.plugin.js CHANGED
@@ -1,19 +1,27 @@
1
- const { withDangerousMod } = require('@expo/config-plugins');
1
+ const {
2
+ withDangerousMod,
3
+ withProjectBuildGradle,
4
+ withAppBuildGradle,
5
+ } = require('@expo/config-plugins');
2
6
  const fs = require('fs');
3
7
  const path = require('path');
4
8
 
9
+ const GMS_CLASSPATH =
10
+ "classpath('com.google.gms:google-services:4.4.2')";
11
+ const GMS_PLUGIN = 'apply plugin: "com.google.gms.google-services"';
12
+
5
13
  /**
6
14
  * @dubsdotapp/expo Expo config plugin.
7
15
  *
8
- * Generates a google-services.json for the Dubs Firebase project using the
9
- * app's own Android package name. This allows Firebase (and therefore FCM)
10
- * to initialise automatically at runtime — no manual Firebase setup required.
16
+ * 1. Generates google-services.json (Dubs Firebase project + app's package name)
17
+ * 2. Adds the Google Services Gradle classpath + plugin so Firebase initialises
11
18
  *
12
19
  * Usage in app.json:
13
20
  * ["@dubsdotapp/expo"]
14
21
  */
15
22
  function withDubsNotifications(config) {
16
- return withDangerousMod(config, [
23
+ // Step 1 — write google-services.json
24
+ config = withDangerousMod(config, [
17
25
  'android',
18
26
  async (cfg) => {
19
27
  const packageName = cfg.android?.package;
@@ -23,6 +31,15 @@ function withDubsNotifications(config) {
23
31
  );
24
32
  }
25
33
 
34
+ const projectRoot = cfg.modRequest.projectRoot;
35
+ const filePath = path.join(projectRoot, 'android', 'app', 'google-services.json');
36
+
37
+ // Skip if developer already has their own Firebase config
38
+ const rootGoogleServices = path.join(projectRoot, 'google-services.json');
39
+ if (fs.existsSync(filePath) || fs.existsSync(rootGoogleServices)) {
40
+ return cfg;
41
+ }
42
+
26
43
  const googleServices = {
27
44
  project_info: {
28
45
  project_number: '161838368570',
@@ -33,52 +50,50 @@ function withDubsNotifications(config) {
33
50
  {
34
51
  client_info: {
35
52
  mobilesdk_app_id: '1:161838368570:android:5d77e05a49f7efc64b7203',
36
- android_client_info: {
37
- package_name: packageName,
38
- },
53
+ android_client_info: { package_name: packageName },
39
54
  },
40
55
  oauth_client: [],
41
- api_key: [
42
- {
43
- current_key: 'AIzaSyCtJKF-o1cZ3Y89oM5FlXIGsjFchETzzkM',
44
- },
45
- ],
46
- services: {
47
- appinvite_service: {
48
- other_platform_oauth_client: [],
49
- },
50
- },
56
+ api_key: [{ current_key: 'AIzaSyCtJKF-o1cZ3Y89oM5FlXIGsjFchETzzkM' }],
57
+ services: { appinvite_service: { other_platform_oauth_client: [] } },
51
58
  },
52
59
  ],
53
60
  configuration_version: '1',
54
61
  };
55
62
 
56
- const projectRoot = cfg.modRequest.projectRoot;
57
- const filePath = path.join(
58
- projectRoot,
59
- 'android',
60
- 'app',
61
- 'google-services.json',
62
- );
63
-
64
- // If the developer already has their own google-services.json, leave it alone.
65
- // Their existing Firebase project will handle FCM just fine.
66
- if (fs.existsSync(filePath)) {
67
- return cfg;
68
- }
69
-
70
- // Also check the project root (some devs place it there for app.json googleServicesFile)
71
- const rootGoogleServices = path.join(projectRoot, 'google-services.json');
72
- if (fs.existsSync(rootGoogleServices)) {
73
- return cfg;
74
- }
75
-
76
63
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
77
64
  fs.writeFileSync(filePath, JSON.stringify(googleServices, null, 2));
78
65
 
79
66
  return cfg;
80
67
  },
81
68
  ]);
69
+
70
+ // Step 2 — add Google Services classpath to project-level build.gradle
71
+ config = withProjectBuildGradle(config, (cfg) => {
72
+ if (cfg.modResults.contents.includes('com.google.gms:google-services')) {
73
+ return cfg;
74
+ }
75
+ // Insert after the last existing classpath line
76
+ cfg.modResults.contents = cfg.modResults.contents.replace(
77
+ /(classpath\(['"]org\.jetbrains\.kotlin:kotlin-gradle-plugin[^)]*\))/,
78
+ `$1\n ${GMS_CLASSPATH}`,
79
+ );
80
+ return cfg;
81
+ });
82
+
83
+ // Step 3 — apply plugin in app-level build.gradle
84
+ config = withAppBuildGradle(config, (cfg) => {
85
+ if (cfg.modResults.contents.includes('com.google.gms.google-services')) {
86
+ return cfg;
87
+ }
88
+ // Add at the top, after the existing apply plugin lines
89
+ cfg.modResults.contents = cfg.modResults.contents.replace(
90
+ /(apply plugin: "com\.facebook\.react")/,
91
+ `$1\n${GMS_PLUGIN}`,
92
+ );
93
+ return cfg;
94
+ });
95
+
96
+ return config;
82
97
  }
83
98
 
84
99
  module.exports = withDubsNotifications;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.2.65",
3
+ "version": "0.2.66",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",