@dubsdotapp/expo 0.5.20 → 0.5.21

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 +26 -29
  2. package/package.json +1 -1
package/app.plugin.js CHANGED
@@ -15,14 +15,21 @@ const GMS_PLUGIN = 'apply plugin: "com.google.gms.google-services"';
15
15
  /**
16
16
  * @dubsdotapp/expo Expo config plugin.
17
17
  *
18
- * 1. Generates google-services.json (Dubs Firebase project + app's package name)
18
+ * 1. Stages the developer's google-services.json into android/app/ at prebuild time
19
+ * (each consumer must bring their own Firebase project — no shared fallback)
19
20
  * 2. Adds the Google Services Gradle classpath + plugin so Firebase initialises
20
21
  *
22
+ * The plugin looks for google-services.json in two locations (in priority order):
23
+ * 1. <projectRoot>/google-services.json ← recommended (committed by the dev)
24
+ * 2. <projectRoot>/android/app/google-services.json (already in place — leave alone)
25
+ *
26
+ * If neither exists, prebuild fails with a clear error. Push will not work without it.
27
+ *
21
28
  * Usage in app.json:
22
29
  * ["@dubsdotapp/expo"]
23
30
  */
24
31
  function withDubsNotifications(config) {
25
- // Step 1 — write google-services.json
32
+ // Step 1 — stage google-services.json into android/app/
26
33
  config = withDangerousMod(config, [
27
34
  'android',
28
35
  async (cfg) => {
@@ -34,38 +41,28 @@ function withDubsNotifications(config) {
34
41
  }
35
42
 
36
43
  const projectRoot = cfg.modRequest.projectRoot;
37
- const filePath = path.join(projectRoot, 'android', 'app', 'google-services.json');
44
+ const targetPath = path.join(projectRoot, 'android', 'app', 'google-services.json');
45
+ const rootPath = path.join(projectRoot, 'google-services.json');
38
46
 
39
- // Skip if developer already has their own Firebase config
40
- const rootGoogleServices = path.join(projectRoot, 'google-services.json');
41
- if (fs.existsSync(filePath) || fs.existsSync(rootGoogleServices)) {
47
+ if (fs.existsSync(targetPath)) {
48
+ // Already in place (e.g. committed under android/app/) — leave it alone
42
49
  return cfg;
43
50
  }
44
51
 
45
- const googleServices = {
46
- project_info: {
47
- project_number: '161838368570',
48
- project_id: 'dubs-a835d',
49
- storage_bucket: 'dubs-a835d.firebasestorage.app',
50
- },
51
- client: [
52
- {
53
- client_info: {
54
- mobilesdk_app_id: '1:161838368570:android:5d77e05a49f7efc64b7203',
55
- android_client_info: { package_name: packageName },
56
- },
57
- oauth_client: [],
58
- api_key: [{ current_key: 'AIzaSyCtJKF-o1cZ3Y89oM5FlXIGsjFchETzzkM' }],
59
- services: { appinvite_service: { other_platform_oauth_client: [] } },
60
- },
61
- ],
62
- configuration_version: '1',
63
- };
64
-
65
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
66
- fs.writeFileSync(filePath, JSON.stringify(googleServices, null, 2));
52
+ if (fs.existsSync(rootPath)) {
53
+ // Developer dropped it at project root — copy into android/app/ where Gradle expects
54
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });
55
+ fs.copyFileSync(rootPath, targetPath);
56
+ return cfg;
57
+ }
67
58
 
68
- return cfg;
59
+ throw new Error(
60
+ '@dubsdotapp/expo plugin: google-services.json not found.\n' +
61
+ ' Download it from your Firebase project (Project settings → General → Your apps) and place it at:\n' +
62
+ ` ${path.join(projectRoot, 'google-services.json')}\n` +
63
+ ' The package name in Firebase must match android.package in app.json: ' +
64
+ `${packageName}`,
65
+ );
69
66
  },
70
67
  ]);
71
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.5.20",
3
+ "version": "0.5.21",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",