customerio-expo-plugin 3.3.0 → 3.5.0

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 (107) hide show
  1. package/package.json +8 -1
  2. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +64 -59
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withAppGoogleServices.js +10 -7
  5. package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +18 -21
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  8. package/plugin/lib/commonjs/android/withLocationGradleProperties.js +16 -12
  9. package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -1
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +19 -12
  11. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +2 -1
  13. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  14. package/plugin/lib/commonjs/android/withProjectBuildGradle.js +29 -25
  15. package/plugin/lib/commonjs/android/withProjectBuildGradle.js.map +1 -1
  16. package/plugin/lib/commonjs/android/withProjectGoogleServices.js +9 -5
  17. package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/constants/ios.js +76 -8
  19. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  20. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +76 -31
  21. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  22. package/plugin/lib/commonjs/index.js +7 -0
  23. package/plugin/lib/commonjs/index.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +47 -33
  25. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +44 -54
  27. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  28. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +46 -30
  29. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  30. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +192 -122
  31. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  32. package/plugin/lib/commonjs/postInstallHelper.js +58 -11
  33. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  34. package/plugin/lib/commonjs/utils/resolveRNSDK.js +97 -0
  35. package/plugin/lib/commonjs/utils/resolveRNSDK.js.map +1 -0
  36. package/plugin/lib/commonjs/utils/writeExpoVersion.js +56 -0
  37. package/plugin/lib/commonjs/utils/writeExpoVersion.js.map +1 -0
  38. package/plugin/lib/module/android/withAndroidManifestUpdates.js +61 -58
  39. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  40. package/plugin/lib/module/android/withAppGoogleServices.js +9 -7
  41. package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
  42. package/plugin/lib/module/android/withGoogleServicesJSON.js +17 -21
  43. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  44. package/plugin/lib/module/android/withLocationGradleProperties.js +15 -12
  45. package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -1
  46. package/plugin/lib/module/android/withMainApplicationModifications.js +18 -12
  47. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  48. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  49. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  50. package/plugin/lib/module/android/withProjectBuildGradle.js +28 -25
  51. package/plugin/lib/module/android/withProjectBuildGradle.js.map +1 -1
  52. package/plugin/lib/module/android/withProjectGoogleServices.js +8 -5
  53. package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
  54. package/plugin/lib/module/helpers/constants/ios.js +75 -8
  55. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  56. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +74 -31
  57. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  58. package/plugin/lib/module/index.js +7 -0
  59. package/plugin/lib/module/index.js.map +1 -1
  60. package/plugin/lib/module/ios/withAppDelegateModifications.js +45 -33
  61. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  62. package/plugin/lib/module/ios/withCIOIosSwift.js +42 -54
  63. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  64. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +45 -30
  65. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  66. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +187 -122
  67. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  68. package/plugin/lib/module/postInstallHelper.js +58 -11
  69. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  70. package/plugin/lib/module/utils/resolveRNSDK.js +88 -0
  71. package/plugin/lib/module/utils/resolveRNSDK.js.map +1 -0
  72. package/plugin/lib/module/utils/writeExpoVersion.js +48 -0
  73. package/plugin/lib/module/utils/writeExpoVersion.js.map +1 -0
  74. package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +2 -0
  75. package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -0
  76. package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -0
  77. package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +2 -0
  78. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +6 -0
  79. package/plugin/lib/typescript/android/withNotificationChannelMetadata.d.ts +5 -0
  80. package/plugin/lib/typescript/android/withProjectBuildGradle.d.ts +9 -0
  81. package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -0
  82. package/plugin/lib/typescript/helpers/constants/ios.d.ts +18 -0
  83. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +25 -1
  84. package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +13 -0
  85. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +11 -0
  86. package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +14 -1
  87. package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +53 -2
  88. package/plugin/lib/typescript/utils/resolveRNSDK.d.ts +7 -0
  89. package/plugin/lib/typescript/utils/writeExpoVersion.d.ts +3 -0
  90. package/plugin/src/android/withAndroidManifestUpdates.ts +83 -73
  91. package/plugin/src/android/withAppGoogleServices.ts +13 -11
  92. package/plugin/src/android/withGoogleServicesJSON.ts +30 -28
  93. package/plugin/src/android/withLocationGradleProperties.ts +23 -17
  94. package/plugin/src/android/withMainApplicationModifications.ts +25 -15
  95. package/plugin/src/android/withNotificationChannelMetadata.ts +1 -1
  96. package/plugin/src/android/withProjectBuildGradle.ts +37 -27
  97. package/plugin/src/android/withProjectGoogleServices.ts +14 -9
  98. package/plugin/src/helpers/constants/ios.ts +87 -8
  99. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +97 -50
  100. package/plugin/src/index.ts +7 -0
  101. package/plugin/src/ios/withAppDelegateModifications.ts +61 -48
  102. package/plugin/src/ios/withCIOIosSwift.ts +58 -62
  103. package/plugin/src/ios/withGoogleServicesJsonFile.ts +66 -48
  104. package/plugin/src/ios/withNotificationsXcodeProject.ts +257 -207
  105. package/plugin/src/postInstallHelper.js +75 -17
  106. package/plugin/src/utils/resolveRNSDK.ts +118 -0
  107. package/plugin/src/utils/writeExpoVersion.ts +62 -0
@@ -1,22 +1,69 @@
1
1
  "use strict";
2
2
 
3
3
  const fs = require('fs');
4
+ const path = require('path');
5
+ const RN_SDK_PACKAGE = 'customerio-reactnative';
6
+
7
+ // Locate customerio-reactnative/package.json from a postinstall context.
8
+ //
9
+ // `INIT_CWD` is set by npm, pnpm, and yarn during lifecycle scripts to point
10
+ // at the consumer's project root. That makes it the most reliable starting
11
+ // point — the plugin's own __dirname can be deep inside `.pnpm/...` under pnpm.
12
+ //
13
+ // We probe `${INIT_CWD}/node_modules/customerio-reactnative/package.json` first
14
+ // so we agree with the symlinked layout React Native autolinking expects, then
15
+ // fall back to resolve-from from the consumer root, then to the legacy
16
+ // __dirname-relative walk-up for environments where INIT_CWD is missing.
17
+ function findRNSDKPackageJson() {
18
+ const candidates = [];
19
+ if (process.env.INIT_CWD) {
20
+ candidates.push(path.join(process.env.INIT_CWD, 'node_modules', RN_SDK_PACKAGE, 'package.json'));
21
+ }
22
+
23
+ // Legacy flat-npm layout fallback: plugin lives at
24
+ // <consumer>/node_modules/customerio-expo-plugin/plugin/src and the SDK at
25
+ // <consumer>/node_modules/customerio-reactnative.
26
+ candidates.push(path.join(__dirname, '..', '..', '..', RN_SDK_PACKAGE, 'package.json'));
27
+ for (const candidate of candidates) {
28
+ if (fs.existsSync(candidate)) {
29
+ return candidate;
30
+ }
31
+ }
32
+
33
+ // Final fallback: resolve-from from INIT_CWD. This walks up node_modules
34
+ // and handles yarn classic workspaces where the dep is hoisted.
35
+ if (process.env.INIT_CWD) {
36
+ try {
37
+ const resolveFrom = require('resolve-from');
38
+ const resolved = resolveFrom.silent(process.env.INIT_CWD, `${RN_SDK_PACKAGE}/package.json`);
39
+ if (resolved) return resolved;
40
+ } catch (_) {
41
+ // resolve-from missing or unable to resolve — fall through to null.
42
+ }
43
+ }
44
+ return null;
45
+ }
4
46
  function runPostInstall() {
5
- // react native SDK package.json path
6
- const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;
7
- const expoPackageJsonFile = `${__dirname}/../../package.json`;
47
+ const expoPackageJsonFile = path.join(__dirname, '..', '..', 'package.json');
8
48
  try {
9
- // if react native SDK is installed
10
- if (fs.existsSync(reactNativePackageJsonFile)) {
11
- const reactNativePackageJson = fs.readFileSync(reactNativePackageJsonFile, 'utf8');
12
- const expoPackageJson = require(expoPackageJsonFile);
13
- const reactNativePackage = JSON.parse(reactNativePackageJson);
14
- reactNativePackage.expoVersion = expoPackageJson.version;
15
- fs.writeFileSync(reactNativePackageJsonFile, JSON.stringify(reactNativePackage, null, 2));
49
+ const reactNativePackageJsonFile = findRNSDKPackageJson();
50
+ if (!reactNativePackageJsonFile) {
51
+ // Not necessarily an error: the plugin may be installed without the RN
52
+ // SDK (e.g., during a tooling-only install). The prebuild-time write
53
+ // covers the common case anyway.
54
+ return;
55
+ }
56
+ const expoPackageJson = require(expoPackageJsonFile);
57
+ const reactNativePackage = JSON.parse(fs.readFileSync(reactNativePackageJsonFile, 'utf8'));
58
+ if (reactNativePackage.expoVersion === expoPackageJson.version) {
59
+ return;
16
60
  }
61
+ reactNativePackage.expoVersion = expoPackageJson.version;
62
+ fs.writeFileSync(reactNativePackageJsonFile, JSON.stringify(reactNativePackage, null, 2));
17
63
  } catch (error) {
18
- console.warn('Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.', error);
64
+ console.warn('customerio-expo-plugin postinstall: failed to write expoVersion into customerio-reactnative/package.json. ' + 'The expo prebuild step will retry this. Original error:', error);
19
65
  }
20
66
  }
21
67
  exports.runPostInstall = runPostInstall;
68
+ exports.findRNSDKPackageJson = findRNSDKPackageJson;
22
69
  //# sourceMappingURL=postInstallHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["fs","require","runPostInstall","reactNativePackageJsonFile","__dirname","expoPackageJsonFile","existsSync","reactNativePackageJson","readFileSync","expoPackageJson","reactNativePackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","console","warn","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;\n const expoPackageJsonFile = `${__dirname}/../../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(reactNativePackageJsonFile)) {\n const reactNativePackageJson = fs.readFileSync(\n reactNativePackageJsonFile,\n 'utf8'\n );\n const expoPackageJson = require(expoPackageJsonFile);\n\n const reactNativePackage = JSON.parse(reactNativePackageJson);\n reactNativePackage.expoVersion = expoPackageJson.version;\n\n fs.writeFileSync(\n reactNativePackageJsonFile,\n JSON.stringify(reactNativePackage, null, 2)\n );\n }\n } catch (error) {\n console.warn(\n 'Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.',\n error\n );\n }\n}\n\nexports.runPostInstall = runPostInstall;\n"],"mappings":";;AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAcA,CAAA,EAAG;EACxB;EACA,MAAMC,0BAA0B,GAAG,GAAGC,SAAS,+CAA+C;EAC9F,MAAMC,mBAAmB,GAAG,GAAGD,SAAS,qBAAqB;EAC7D,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,0BAA0B,CAAC,EAAE;MAC7C,MAAMI,sBAAsB,GAAGP,EAAE,CAACQ,YAAY,CAC5CL,0BAA0B,EAC1B,MACF,CAAC;MACD,MAAMM,eAAe,GAAGR,OAAO,CAACI,mBAAmB,CAAC;MAEpD,MAAMK,kBAAkB,GAAGC,IAAI,CAACC,KAAK,CAACL,sBAAsB,CAAC;MAC7DG,kBAAkB,CAACG,WAAW,GAAGJ,eAAe,CAACK,OAAO;MAExDd,EAAE,CAACe,aAAa,CACdZ,0BAA0B,EAC1BQ,IAAI,CAACK,SAAS,CAACN,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAC5C,CAAC;IACH;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CACV,kIAAkI,EAClIF,KACF,CAAC;EACH;AACF;AAEAG,OAAO,CAAClB,cAAc,GAAGA,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["fs","require","path","RN_SDK_PACKAGE","findRNSDKPackageJson","candidates","process","env","INIT_CWD","push","join","__dirname","candidate","existsSync","resolveFrom","resolved","silent","_","runPostInstall","expoPackageJsonFile","reactNativePackageJsonFile","expoPackageJson","reactNativePackage","JSON","parse","readFileSync","expoVersion","version","writeFileSync","stringify","error","console","warn","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\nconst path = require('path');\n\nconst RN_SDK_PACKAGE = 'customerio-reactnative';\n\n// Locate customerio-reactnative/package.json from a postinstall context.\n//\n// `INIT_CWD` is set by npm, pnpm, and yarn during lifecycle scripts to point\n// at the consumer's project root. That makes it the most reliable starting\n// point — the plugin's own __dirname can be deep inside `.pnpm/...` under pnpm.\n//\n// We probe `${INIT_CWD}/node_modules/customerio-reactnative/package.json` first\n// so we agree with the symlinked layout React Native autolinking expects, then\n// fall back to resolve-from from the consumer root, then to the legacy\n// __dirname-relative walk-up for environments where INIT_CWD is missing.\nfunction findRNSDKPackageJson() {\n const candidates = [];\n\n if (process.env.INIT_CWD) {\n candidates.push(\n path.join(process.env.INIT_CWD, 'node_modules', RN_SDK_PACKAGE, 'package.json')\n );\n }\n\n // Legacy flat-npm layout fallback: plugin lives at\n // <consumer>/node_modules/customerio-expo-plugin/plugin/src and the SDK at\n // <consumer>/node_modules/customerio-reactnative.\n candidates.push(path.join(__dirname, '..', '..', '..', RN_SDK_PACKAGE, 'package.json'));\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n }\n\n // Final fallback: resolve-from from INIT_CWD. This walks up node_modules\n // and handles yarn classic workspaces where the dep is hoisted.\n if (process.env.INIT_CWD) {\n try {\n const resolveFrom = require('resolve-from');\n const resolved = resolveFrom.silent(\n process.env.INIT_CWD,\n `${RN_SDK_PACKAGE}/package.json`\n );\n if (resolved) return resolved;\n } catch (_) {\n // resolve-from missing or unable to resolve — fall through to null.\n }\n }\n\n return null;\n}\n\nfunction runPostInstall() {\n const expoPackageJsonFile = path.join(__dirname, '..', '..', 'package.json');\n\n try {\n const reactNativePackageJsonFile = findRNSDKPackageJson();\n if (!reactNativePackageJsonFile) {\n // Not necessarily an error: the plugin may be installed without the RN\n // SDK (e.g., during a tooling-only install). The prebuild-time write\n // covers the common case anyway.\n return;\n }\n\n const expoPackageJson = require(expoPackageJsonFile);\n const reactNativePackage = JSON.parse(\n fs.readFileSync(reactNativePackageJsonFile, 'utf8')\n );\n\n if (reactNativePackage.expoVersion === expoPackageJson.version) {\n return;\n }\n\n reactNativePackage.expoVersion = expoPackageJson.version;\n fs.writeFileSync(\n reactNativePackageJsonFile,\n JSON.stringify(reactNativePackage, null, 2)\n );\n } catch (error) {\n console.warn(\n 'customerio-expo-plugin postinstall: failed to write expoVersion into customerio-reactnative/package.json. ' +\n 'The expo prebuild step will retry this. Original error:',\n error\n );\n }\n}\n\nexports.runPostInstall = runPostInstall;\nexports.findRNSDKPackageJson = findRNSDKPackageJson;\n"],"mappings":";;AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AACxB,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAE5B,MAAME,cAAc,GAAG,wBAAwB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAG;EAC9B,MAAMC,UAAU,GAAG,EAAE;EAErB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE;IACxBH,UAAU,CAACI,IAAI,CACbP,IAAI,CAACQ,IAAI,CAACJ,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE,cAAc,EAAEL,cAAc,EAAE,cAAc,CAChF,CAAC;EACH;;EAEA;EACA;EACA;EACAE,UAAU,CAACI,IAAI,CAACP,IAAI,CAACQ,IAAI,CAACC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAER,cAAc,EAAE,cAAc,CAAC,CAAC;EAEvF,KAAK,MAAMS,SAAS,IAAIP,UAAU,EAAE;IAClC,IAAIL,EAAE,CAACa,UAAU,CAACD,SAAS,CAAC,EAAE;MAC5B,OAAOA,S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AAoB,GAAGA,oBAAoB","ignoreList":[]}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveRNSDK = resolveRNSDK;
7
+ exports.tryReadRNVersion = tryReadRNVersion;
8
+ exports.tryResolveRNSDK = tryResolveRNSDK;
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _path = _interopRequireDefault(require("path"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const RN_SDK_PACKAGE = 'customerio-reactnative';
13
+ const REACT_NATIVE_PACKAGE = 'react-native';
14
+ // Reads the installed react-native package's version starting from `fromDir`.
15
+ // Used to decide which autolinking flavor will resolve customerio-reactnative
16
+ // at pod install time, so our :path agrees with what autolinking emits:
17
+ // - RN <0.80 ships @react-native-community/cli, which uses a lexical
18
+ // resolution (no realpath following).
19
+ // - RN >=0.80 routes pod autolinking through expo-modules-autolinking,
20
+ // which realpaths.
21
+ // Returns null if react-native cannot be located or its package.json cannot
22
+ // be read; callers should default to the modern (realpath) behavior in that
23
+ // case since it has been the working path for the last several Expo SDKs.
24
+ function tryReadRNVersion(fromDir) {
25
+ try {
26
+ const direct = _path.default.join(fromDir, 'node_modules', REACT_NATIVE_PACKAGE, 'package.json');
27
+ if (_fs.default.existsSync(direct)) {
28
+ return readVersion(direct);
29
+ }
30
+ const resolveFrom = require('resolve-from');
31
+ const fallback = resolveFrom.silent(fromDir, `${REACT_NATIVE_PACKAGE}/package.json`);
32
+ if (fallback) {
33
+ return readVersion(fallback);
34
+ }
35
+ } catch {
36
+ // Fall through to null.
37
+ }
38
+ return null;
39
+ }
40
+ function readVersion(pkgJsonPath) {
41
+ try {
42
+ const pkg = JSON.parse(_fs.default.readFileSync(pkgJsonPath, 'utf-8'));
43
+ return typeof pkg.version === 'string' ? pkg.version : null;
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ // Resolves the customerio-reactnative SDK location starting from `fromDir`.
50
+ //
51
+ // Probe-then-fallback so the result agrees with React Native autolinking
52
+ // across npm flat, pnpm, and yarn-workspace layouts:
53
+ // 1. `fromDir/node_modules/customerio-reactnative/package.json` — preferred.
54
+ // Works for npm flat, pnpm (the symlinked path; we never realpath it),
55
+ // and yarn workspaces with leaf node_modules. Matches what RN
56
+ // autolinking emits for its pod entry, so CocoaPods sees one
57
+ // consistent :path.
58
+ // 2. `resolve-from` walking up from `fromDir` — only used when (1) misses.
59
+ // Handles yarn classic workspaces where the dep is hoisted to a parent
60
+ // node_modules. yarn classic has no symlinks, so the realpath is fine.
61
+ //
62
+ // Returns null if neither finds the package, including the case where
63
+ // `resolve-from` itself can't be required (mirrors tryReadRNVersion's
64
+ // graceful-failure shape so callers can rely on the documented contract).
65
+ function tryResolveRNSDK(fromDir) {
66
+ try {
67
+ const directPkgJson = _path.default.join(fromDir, 'node_modules', RN_SDK_PACKAGE, 'package.json');
68
+ if (_fs.default.existsSync(directPkgJson)) {
69
+ return {
70
+ packageDir: _path.default.dirname(directPkgJson),
71
+ packageJsonPath: directPkgJson
72
+ };
73
+ }
74
+ const resolveFrom = require('resolve-from');
75
+ const fallbackPkgJson = resolveFrom.silent(fromDir, `${RN_SDK_PACKAGE}/package.json`);
76
+ if (fallbackPkgJson) {
77
+ return {
78
+ packageDir: _path.default.dirname(fallbackPkgJson),
79
+ packageJsonPath: fallbackPkgJson
80
+ };
81
+ }
82
+ } catch {
83
+ // Fall through to null. resolveRNSDK() turns this into a clear
84
+ // "customerio-reactnative was not found" error for the caller.
85
+ }
86
+ return null;
87
+ }
88
+
89
+ // Same as tryResolveRNSDK but throws a clear error when the package is missing.
90
+ function resolveRNSDK(fromDir) {
91
+ const resolved = tryResolveRNSDK(fromDir);
92
+ if (!resolved) {
93
+ throw new Error(`${RN_SDK_PACKAGE} was not found relative to ${fromDir}. ` + `Ensure it is installed in your project (or in a parent workspace's node_modules).`);
94
+ }
95
+ return resolved;
96
+ }
97
+ //# sourceMappingURL=resolveRNSDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_fs","_interopRequireDefault","require","_path","e","__esModule","default","RN_SDK_PACKAGE","REACT_NATIVE_PACKAGE","tryReadRNVersion","fromDir","direct","path","join","fs","existsSync","readVersion","resolveFrom","fallback","silent","pkgJsonPath","pkg","JSON","parse","readFileSync","version","tryResolveRNSDK","directPkgJson","packageDir","dirname","packageJsonPath","fallbackPkgJson","resolveRNSDK","resolved","Error"],"sources":["resolveRNSDK.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst RN_SDK_PACKAGE = 'customerio-reactnative';\nconst REACT_NATIVE_PACKAGE = 'react-native';\n\nexport type ResolvedRNSDK = {\n // Absolute path to the package directory.\n packageDir: string;\n // Absolute path to package.json inside that directory.\n packageJsonPath: string;\n};\n\n// Reads the installed react-native package's version starting from `fromDir`.\n// Used to decide which autolinking flavor will resolve customerio-reactnative\n// at pod install time, so our :path agrees with what autolinking emits:\n// - RN <0.80 ships @react-native-community/cli, which uses a lexical\n// resolution (no realpath following).\n// - RN >=0.80 routes pod autolinking through expo-modules-autolinking,\n// which realpaths.\n// Returns null if react-native cannot be located or its package.json cannot\n// be read; callers should default to the modern (realpath) behavior in that\n// case since it has been the working path for the last several Expo SDKs.\nexport function tryReadRNVersion(fromDir: string): string | null {\n try {\n const direct = path.join(\n fromDir,\n 'node_modules',\n REACT_NATIVE_PACKAGE,\n 'package.json'\n );\n if (fs.existsSync(direct)) {\n return readVersion(direct);\n }\n const resolveFrom = require('resolve-from');\n const fallback = resolveFrom.silent(\n fromDir,\n `${REACT_NATIVE_PACKAGE}/package.json`\n );\n if (fallback) {\n return readVersion(fallback);\n }\n } catch {\n // Fall through to null.\n }\n return null;\n}\n\nfunction readVersion(pkgJsonPath: string): string | null {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));\n return typeof pkg.version === 'string' ? pkg.version : null;\n } catch {\n return null;\n }\n}\n\n// Resolves the customerio-reactnative SDK location starting from `fromDir`.\n//\n// Probe-then-fallback so the result agrees with React Native autolinking\n// across npm flat, pnpm, and yarn-workspace layouts:\n// 1. `fromDir/node_modules/customerio-reactnative/package.json` — preferred.\n// Works for npm flat, pnpm (the symlinked path; we never realpath it),\n// and yarn workspaces with leaf node_modules. Matches what RN\n// autolinking emits for its pod entry, so CocoaPods sees one\n// consistent :path.\n// 2. `resolve-from` walking up from `fromDir` — only used when (1) misses.\n// Handles yarn classic workspaces where the dep is hoisted to a parent\n// node_modules. yarn classic has no symlinks, so the realpath is fine.\n//\n// Returns null if neither finds the package, including the case where\n// `resolve-from` itself can't be required (mirrors tryReadRNVersion's\n// graceful-failure shape so callers can rely on the documented contract).\nexport function tryResolveRNSDK(fromDir: string): ResolvedRNSDK | null {\n try {\n const directPkgJson = path.join(\n fromDir,\n 'node_modules',\n RN_SDK_PACKAGE,\n 'package.json'\n );\n if (fs.existsSync(directPkgJson)) {\n return {\n packageDir: path.dirname(directPkgJson),\n packageJsonPath: directPkgJson,\n };\n }\n\n const resolveFrom = require('resolve-from');\n const fallbackPkgJson = resolveFrom.silent(\n fromDir,\n `${RN_SDK_PACKAGE}/package.json`\n );\n if (fallbackPkgJson) {\n return {\n packageDir: path.dirname(fallbackPkgJson),\n packageJsonPath: fallbackPkgJson,\n };\n }\n } catch {\n // Fall through to null. resolveRNSDK() turns this into a clear\n // \"customerio-reactnative was not found\" error for the caller.\n }\n\n return null;\n}\n\n// Same as tryResolveRNSDK but throws a clear error when the package is missing.\nexport function resolveRNSDK(fromDir: string): ResolvedRNSDK {\n const resolved = tryResolveRNSDK(fromDir);\n if (!resolved) {\n throw new Error(\n `${RN_SDK_PACKAGE} was not found relative to ${fromDir}. ` +\n `Ensure it is installed in your project (or in a parent workspace's node_modules).`\n );\n }\n return resolved;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAw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EACP,cAAc,EACdH,cAAc,EACd,cACF,CAAC;IACD,IAAIO,WAAE,CAACC,UAAU,CAACY,aAAa,CAAC,EAAE;MAChC,OAAO;QACLC,UAAU,EAAEhB,aAAI,CAACiB,OAAO,CAACF,aAAa,CAAC;QACvCG,eAAe,EAAEH;MACnB,CAAC;IACH;IAEA,MAAMV,WAAW,GAAGf,OAAO,CAAC,cAAc,CAAC;IAC3C,MAAM6B,eAAe,GAAGd,WAAW,CAACE,MAAM,CACxCT,OAAO,EACP,GAAGH,cAAc,eACnB,CAAC;IACD,IAAIwB,eAAe,EAAE;MACnB,OAAO;QACLH,UAAU,EAAEhB,aAAI,CAACiB,OAAO,CAACE,eAAe,CAAC;QACzCD,eAAe,EAAEC;MACnB,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;IACA;EAAA;EAGF,OAAO,IAAI;AACb;;AAEA;AACO,SAASC,YAAYA,CAACtB,OAAe,EAAiB;EAC3D,MAAMuB,QAAQ,GAAGP,eAAe,CAAChB,OAAO,CAAC;EACzC,IAAI,CAACuB,QAAQ,EAAE;IACb,MAAM,IAAIC,KAAK,CACb,GAAG3B,cAAc,8BAA8BG,OAAO,IAAI,GAC1D,mFACF,CAAC;EACH;EACA,OAAOuB,QAAQ;AACjB","ignoreList":[]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withExpoVersion = void 0;
7
+ exports.writeExpoVersion = writeExpoVersion;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var _logger = require("./logger");
10
+ var _plugin = require("./plugin");
11
+ var _resolveRNSDK = require("./resolveRNSDK");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ // Writes the plugin's version into customerio-reactnative/package.json under
14
+ // the `expoVersion` key. The RN SDK reads this at runtime (customerio-cdp.ts)
15
+ // to set its User-Agent `packageSource` to "Expo" instead of "ReactNative".
16
+ //
17
+ // We rely on the postinstall hook (postInstallHelper.js) for the same write
18
+ // at install time, but call this from the plugin entry as a fallback for
19
+ // installs where postinstall does not run cleanly — most notably pnpm
20
+ // monorepos and any CI that uses --ignore-scripts.
21
+ //
22
+ // The write is idempotent: we no-op when the value is already correct.
23
+ function writeExpoVersion(projectRoot) {
24
+ let resolved;
25
+ try {
26
+ resolved = (0, _resolveRNSDK.tryResolveRNSDK)(projectRoot);
27
+ } catch (error) {
28
+ _logger.logger.warn(`Could not locate customerio-reactnative to write expoVersion. ` + `User-Agent attribution may be incorrect. Original error: ${error}`);
29
+ return;
30
+ }
31
+ if (!resolved) {
32
+ return;
33
+ }
34
+ try {
35
+ const pluginVersion = (0, _plugin.getPluginVersion)();
36
+ const pkg = JSON.parse(_fs.default.readFileSync(resolved.packageJsonPath, 'utf8'));
37
+ if (pkg.expoVersion === pluginVersion) {
38
+ return;
39
+ }
40
+ pkg.expoVersion = pluginVersion;
41
+ _fs.default.writeFileSync(resolved.packageJsonPath, JSON.stringify(pkg, null, 2));
42
+ } catch (error) {
43
+ _logger.logger.warn(`Failed to write expoVersion into ${resolved.packageJsonPath}. ` + `User-Agent attribution may be incorrect. Original error: ${error}`);
44
+ }
45
+ }
46
+ const withExpoVersion = config => {
47
+ var _internal;
48
+ // _internal.projectRoot is set by Expo when running through prebuild;
49
+ // fall back to process.cwd() for any path that calls the plugin in
50
+ // a non-prebuild context.
51
+ const projectRoot = ((_internal = config._internal) === null || _internal === void 0 ? void 0 : _internal.projectRoot) || process.cwd();
52
+ writeExpoVersion(projectRoot);
53
+ return config;
54
+ };
55
+ exports.withExpoVersion = withExpoVersion;
56
+ //# sourceMappingURL=writeExpoVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_fs","_interopRequireDefault","require","_logger","_plugin","_resolveRNSDK","e","__esModule","default","writeExpoVersion","projectRoot","resolved","tryResolveRNSDK","error","logger","warn","pluginVersion","getPluginVersion","pkg","JSON","parse","fs","readFileSync","packageJsonPath","expoVersion","writeFileSync","stringify","withExpoVersion","config","_internal","process","cwd","exports"],"sources":["writeExpoVersion.ts"],"sourcesContent":["import fs from 'fs';\nimport type { ConfigPlugin } from '@expo/config-plugins';\n\nimport { logger } from './logger';\nimport { getPluginVersion } from './plugin';\nimport { tryResolveRNSDK } from './resolveRNSDK';\n\n// Writes the plugin's version into customerio-reactnative/package.json under\n// the `expoVersion` key. The RN SDK reads this at runtime (customerio-cdp.ts)\n// to set its User-Agent `packageSource` to \"Expo\" instead of \"ReactNative\".\n//\n// We rely on the postinstall hook (postInstallHelper.js) for the same write\n// at install time, but call this from the plugin entry as a fallback for\n// installs where postinstall does not run cleanly — most notably pnpm\n// monorepos and any CI that uses --ignore-scripts.\n//\n// The write is idempotent: we no-op when the value is already correct.\nexport function writeExpoVersion(projectRoot: string): void {\n let resolved;\n try {\n resolved = tryResolveRNSDK(projectRoot);\n } catch (error) {\n logger.warn(\n `Could not locate customerio-reactnative to write expoVersion. ` +\n `User-Agent attribution may be incorrect. Original error: ${error}`\n );\n return;\n }\n\n if (!resolved) {\n return;\n }\n\n try {\n const pluginVersion = getPluginVersion();\n const pkg = JSON.parse(fs.readFileSync(resolved.packageJsonPath, 'utf8'));\n if (pkg.expoVersion === pluginVersion) {\n return;\n }\n pkg.expoVersion = pluginVersion;\n fs.writeFileSync(\n resolved.packageJsonPath,\n JSON.stringify(pkg, null, 2)\n );\n } catch (error) {\n logger.warn(\n `Failed to write expoVersion into ${resolved.packageJsonPath}. ` +\n `User-Agent attribution may be incorrect. Original error: ${error}`\n );\n }\n}\n\nexport const withExpoVersion: ConfigPlugin = (config) => {\n // _internal.projectRoot is set by Expo when running through prebuild;\n // fall back to process.cwd() for any path that calls the plugin in\n // a non-prebuild context.\n const projectRoot =\n (config as unknown as { _internal?: { projectRoot?: string } })._internal?.projectRoot ||\n process.cwd();\n writeExpoVersion(projectRoot);\n return config;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAA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A,uBAAzEA,SAAA,CAA2EnB,WAAW,KACtFoB,OAAO,CAACC,GAAG,CAAC,CAAC;EACftB,gBAAgB,CAACC,WAAW,CAAC;EAC7B,OAAOkB,MAAM;AACf,CAAC;AAACI,OAAA,CAAAL,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -3,70 +3,73 @@ import { logger } from '../utils/logger';
3
3
 
4
4
  // Default low priority for Firebase messaging service when setHighPriorityPushHandler is false
5
5
  export const DEFAULT_LOW_PRIORITY = -10;
6
- export const withAndroidManifestUpdates = (configOuter, options) => {
7
- return withAndroidManifest(configOuter, props => {
8
- const application = props.modResults.manifest.application;
9
- const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
10
- if (!application[0].service) {
11
- application[0].service = [];
6
+ export function modifyAndroidManifestApplication(application, options) {
7
+ const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
8
+ if (!application[0].service) {
9
+ application[0].service = [];
10
+ }
11
+ const existingServiceIndex = application[0].service.findIndex(service => service.$['android:name'] === customerIOMessagingpush);
12
+ if (existingServiceIndex === -1) {
13
+ // Intent filter structure for Firebase messaging service
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const intentFilter = {
16
+ action: [{
17
+ $: {
18
+ 'android:name': 'com.google.firebase.MESSAGING_EVENT'
19
+ }
20
+ }]
21
+ };
22
+
23
+ // Handle priority based on setHighPriorityPushHandler value
24
+ if (options.setHighPriorityPushHandler === true) {
25
+ // High priority - no priority attribute means default high priority
26
+ logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
27
+ } else if (options.setHighPriorityPushHandler === false) {
28
+ // Low priority - set fixed priority
29
+ intentFilter.$ = {
30
+ 'android:priority': DEFAULT_LOW_PRIORITY.toString()
31
+ };
32
+ logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
12
33
  }
13
- const existingServiceIndex = application[0].service.findIndex(service => service.$['android:name'] === customerIOMessagingpush);
14
- if (existingServiceIndex === -1) {
15
- // Intent filter structure for Firebase messaging service
34
+ application[0].service.push({
35
+ '$': {
36
+ 'android:name': customerIOMessagingpush,
37
+ 'android:exported': 'false'
38
+ },
39
+ 'intent-filter': [intentFilter]
40
+ });
41
+ } else if (options.setHighPriorityPushHandler === true) {
42
+ // Service exists, need to ensure it becomes high priority (remove priority attribute)
43
+ const existingService = application[0].service[existingServiceIndex];
44
+ if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
16
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const intentFilter = {
18
- action: [{
19
- $: {
20
- 'android:name': 'com.google.firebase.MESSAGING_EVENT'
21
- }
22
- }]
23
- };
24
-
25
- // Handle priority based on setHighPriorityPushHandler value
26
- if (options.setHighPriorityPushHandler === true) {
27
- // High priority - no priority attribute means default high priority
28
- logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
29
- } else if (options.setHighPriorityPushHandler === false) {
30
- // Low priority - set fixed priority
31
- intentFilter.$ = {
32
- 'android:priority': DEFAULT_LOW_PRIORITY.toString()
33
- };
34
- logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
46
+ const intentFilter = existingService['intent-filter'][0];
47
+ if (intentFilter.$ && intentFilter.$['android:priority']) {
48
+ delete intentFilter.$['android:priority'];
49
+ logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
35
50
  }
36
- application[0].service.push({
37
- '$': {
38
- 'android:name': customerIOMessagingpush,
39
- 'android:exported': 'false'
40
- },
41
- 'intent-filter': [intentFilter]
42
- });
43
- } else if (options.setHighPriorityPushHandler === true) {
44
- // Service exists, need to ensure it becomes high priority (remove priority attribute)
45
- const existingService = application[0].service[existingServiceIndex];
46
- if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- const intentFilter = existingService['intent-filter'][0];
49
- if (intentFilter.$ && intentFilter.$['android:priority']) {
50
- delete intentFilter.$['android:priority'];
51
- logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
52
- }
53
- }
54
- } else if (options.setHighPriorityPushHandler === false) {
55
- // Service exists, update to low priority
56
- const existingService = application[0].service[existingServiceIndex];
51
+ }
52
+ } else if (options.setHighPriorityPushHandler === false) {
53
+ // Service exists, update to low priority
54
+ const existingService = application[0].service[existingServiceIndex];
57
55
 
58
- // Update existing service intent-filter with fixed priority
59
- if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- const intentFilter = existingService['intent-filter'][0];
62
- if (!intentFilter.$) {
63
- intentFilter.$ = {};
64
- }
65
- intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
66
- logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
56
+ // Update existing service intent-filter with fixed priority
57
+ if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ const intentFilter = existingService['intent-filter'][0];
60
+ if (!intentFilter.$) {
61
+ intentFilter.$ = {};
67
62
  }
63
+ intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
64
+ logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
68
65
  }
69
- props.modResults.manifest.application = application;
66
+ }
67
+ return application;
68
+ }
69
+ export const withAndroidManifestUpdates = (configOuter, options) => {
70
+ return withAndroidManifest(configOuter, props => {
71
+ const application = props.modResults.manifest.application;
72
+ props.modResults.manifest.application = modifyAndroidManifestApplication(application, options);
70
73
  return props;
71
74
  });
72
75
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifest","logger","DEFAULT_LOW_PRIORITY","withAndroidManifestUpdates","configOuter","options","props","application","modResults","manifest","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","info","toString","push","existingService","length"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n logger.info(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n logger.info(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n logger.info(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n logger.info(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAI1D,SAASC,MAAM,QAAQ,iBAAiB;;AAExC;AACA,OAAO,MAAMC,oBAAoB,GAAG,CAAC,EAAE;AAGvC,OAAO,MAAMC,0BAEZ,GAAGA,CAACC,WAAW,EAAEC,OAAO,KAAK;EAC5B,OAAOL,mBAAmB,CAACI,WAAW,EAAGE,KAAK,IAAK;IACjD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAC1CF,WAAoC;IACvC,MAAMG,uBAAuB,GAC3B,8DAA8D;IAEhE,IAAI,CAACH,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,EAAE;MAC3BJ,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,GAAG,EAAE;IAC7B;IAEA,MAAMC,oBAAoB,GAAGL,WAAW,CA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AOC,YAAY,CAACD,CAAC,CAAC,kBAAkB,CAAC;UACzCb,MAAM,CAACiB,IAAI,CACT,+FACF,CAAC;QACH;MACF;IACF,CAAC,MAAM,IAAIb,OAAO,CAACY,0BAA0B,KAAK,KAAK,EAAE;MACvD;MACA,MAAMI,eAAe,GAAGd,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,CAACC,oBAAoB,CAAC;;MAEpE;MACA,IAAIS,eAAe,CAAC,eAAe,CAAC,IAAIA,eAAe,CAAC,eAAe,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;QACnF;QACA,MAAMP,YAAY,GAAGM,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC,CAAQ;QAC/D,IAAI,CAACN,YAAY,CAACD,CAAC,EAAE;UACnBC,YAAY,CAACD,CAAC,GAAG,CAAC,CAAC;QACrB;QACAC,YAAY,CAACD,CAAC,CAAC,kBAAkB,CAAC,GAAGZ,oBAAoB,CAACiB,QAAQ,CAAC,CAAC;QACpElB,MAAM,CAACiB,IAAI,CACT,0EAA0EhB,oBAAoB,0BAChG,CAAC;MACH;IACF;IAEAI,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACF,WAAW,GAAGA,WAAW;IACnD,OAAOD,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifest","logger","DEFAULT_LOW_PRIORITY","modifyAndroidManifestApplication","application","options","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","info","toString","push","existingService","length","withAndroidManifestUpdates","configOuter","props","modResults","manifest"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport function modifyAndroidManifestApplication(\n application: ManifestApplication[],\n options: CustomerIOPluginOptionsAndroid\n): ManifestApplication[] {\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n logger.info(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n logger.info(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n logger.info(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n logger.info(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n return application;\n}\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n props.modResults.manifest.application = modifyAndroidManifestApplication(\n application,\n options\n );\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAI1D,SAASC,MAAM,QAAQ,iBAAiB;;AAExC;AACA,OAAO,MAAMC,oBAAoB,GAAG,CAAC,EAAE;AAGvC,OAAO,SAASC,gCAAgCA,CAC9CC,WAAkC,EAClCC,OAAuC,EAChB;EACvB,MAAMC,uBAAuB,GAC3B,8DAA8D;EAEhE,IAAI,CAACF,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,EAAE;IAC3BH,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,GAAG,EAAE;EAC7B;EAEA,MAAMC,oBAAoB,GAAGJ,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,CAACE,SAAS,CAC1DF,OAAO,IAAKA,OAAO,CAACG,CAAC,CAAC,cAAc,CAAC,KAAKJ,uBAC7C,CAAC;EAED,IAAIE,oBAAoB,KAAK,CAAC,CAAC,EAAE;IAC/B;IACA;IACA,MAAMG,YAAiB,GAAG;MACxBC,MAAM,EAAE,CACN;QACEF,CAAC,EAAE;UACD,cAAc,EAAE;QAClB;MACF,CAAC;IAEL,CAAC;;IAED;IACA,IAAIL,OAAO,CAACQ,0BAA0B,KAAK,IA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AAC,EAAE;MACnF;MACA,MAAMP,YAAY,GAAGM,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC,CAAQ;MAC/D,IAAI,CAACN,YAAY,CAACD,CAAC,EAAE;QACnBC,YAAY,CAACD,CAAC,GAAG,CAAC,CAAC;MACrB;MACAC,YAAY,CAACD,CAAC,CAAC,kBAAkB,CAAC,GAAGR,oBAAoB,CAACa,QAAQ,CAAC,CAAC;MACpEd,MAAM,CAACa,IAAI,CACT,0EAA0EZ,oBAAoB,0BAChG,CAAC;IACH;EACF;EAEA,OAAOE,WAAW;AACpB;AAEA,OAAO,MAAMe,0BAEZ,GAAGA,CAACC,WAAW,EAAEf,OAAO,KAAK;EAC5B,OAAOL,mBAAmB,CAACoB,WAAW,EAAGC,KAAK,IAAK;IACjD,MAAMjB,WAAW,GAAGiB,KAAK,CAACC,UAAU,CAACC,QAAQ,CAC1CnB,WAAoC;IACvCiB,KAAK,CAACC,UAAU,CAACC,QAAQ,CAACnB,WAAW,GAAGD,gCAAgC,CACtEC,WAAW,EACXC,OACF,CAAC;IACD,OAAOgB,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,15 +1,17 @@
1
1
  import { withAppBuildGradle } from '@expo/config-plugins';
2
2
  import { CIO_APP_APPLY_REGEX, CIO_APP_GOOGLE_SNIPPET } from '../helpers/constants/android';
3
3
  import { logger } from '../utils/logger';
4
+ export function modifyAppBuildGradle(contents) {
5
+ const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
6
+ if (regex.test(contents)) {
7
+ logger.info('app/build.gradle snippet already exists. Skipping...');
8
+ return contents;
9
+ }
10
+ return contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
11
+ }
4
12
  export const withAppGoogleServices = configOuter => {
5
13
  return withAppBuildGradle(configOuter, props => {
6
- const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
7
- const match = props.modResults.contents.match(regex);
8
- if (!match) {
9
- props.modResults.contents = props.modResults.contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
10
- } else {
11
- logger.info('app/build.gradle snippet already exists. Skipping...');
12
- }
14
+ props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);
13
15
  return props;
14
16
  });
15
17
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","logger","withAppGoogleServices","configOuter","props","regex","RegExp","match","modResults","contents","replace","info"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n } else {\n logger.info('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AAEzD,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAErC,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,MAAMC,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOL,kBAAkB,CAACK,WAAW,EAAGC,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACN,sBAAsB,CAAC;IAChD,MAAMO,KAAK,GAAGH,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACF,KAAK,CAAC;IACpD,IAAI,CAACE,KAAK,EAAE;MACVH,KAAK,CAACI,UAAU,CAACC,QAAQ,GAAGL,KAAK,CAACI,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DX,mBAAmB,EACnB,OAAOC,sBAAsB,EAC/B,CAAC;IACH,CAAC,MAAM;MACLC,MAAM,CAACU,IAAI,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOP,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","logger","modifyAppBuildGradle","contents","regex","RegExp","test","info","replace","withAppGoogleServices","configOuter","props","modResults"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\nexport function modifyAppBuildGradle(contents: string): string {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n if (regex.test(contents)) {\n logger.info('app/build.gradle snippet already exists. Skipping...');\n return contents;\n }\n return contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n}\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AAEzD,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAErC,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,SAASC,oBAAoBA,CAACC,QAAgB,EAAU;EAC7D,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACL,sBAAsB,CAAC;EAChD,IAAII,KAAK,CAACE,IAAI,CAACH,QAAQ,CAAC,EAAE;IACxBF,MAAM,CAACM,IAAI,CAAC,sDAAsD,CAAC;IACnE,OAAOJ,QAAQ;EACjB;EACA,OAAOA,QAAQ,CAACK,OAAO,CACrBT,mBAAmB,EACnB,OAAOC,sBAAsB,EAC/B,CAAC;AACH;AAEA,OAAO,MAAMS,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOZ,kBAAkB,CAACY,WAAW,EAAGC,KAAK,IAAK;IAChDA,KAAK,CAACC,UAAU,CAACT,QAAQ,GAAGD,oBAAoB,CAACS,KAAK,CAACC,UAAU,CAACT,QAAQ,CAAC;IAC3E,OAAOQ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,29 +1,25 @@
1
1
  import { withProjectBuildGradle } from '@expo/config-plugins';
2
2
  import { logger } from '../utils/logger';
3
3
  import { FileManagement } from './../helpers/utils/fileManagement';
4
+ export function copyGoogleServicesFile(androidPath, googleServicesFile) {
5
+ const destination = `${androidPath}/app/google-services.json`;
6
+ if (FileManagement.exists(destination)) {
7
+ logger.info(`File already exists: ${destination}. Skipping...`);
8
+ return;
9
+ }
10
+ if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
11
+ try {
12
+ FileManagement.copyFile(googleServicesFile, destination);
13
+ } catch {
14
+ logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${destination}`);
15
+ }
16
+ } else {
17
+ logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`);
18
+ }
19
+ }
4
20
  export const withGoogleServicesJSON = (configOuter, cioProps) => {
5
21
  return withProjectBuildGradle(configOuter, props => {
6
- const options = {
7
- androidPath: props.modRequest.platformProjectRoot,
8
- googleServicesFile: cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile
9
- };
10
- const {
11
- androidPath,
12
- googleServicesFile
13
- } = options;
14
- if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {
15
- if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
16
- try {
17
- FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
18
- } catch {
19
- logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
20
- }
21
- } else {
22
- logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`);
23
- }
24
- } else {
25
- logger.info(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
26
- }
22
+ copyGoogleServicesFile(props.modRequest.platformProjectRoot, cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile);
27
23
  return props;
28
24
  });
29
25
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","logger","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","info"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch {\n logger.info(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n logger.info(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n logger.info(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOL,sBAAsB,CAACI,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAC,GAAGJ,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIT,cAAc,CAACU,MAAM,CAACD,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFT,cAAc,CAACW,QAAQ,CACrBF,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,MAAM;UACNP,MAAM,CAACa,IAAI,CACT,4FAA4FN,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLP,MAAM,CAACa,IAAI,CACT,wCAAwCH,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLP,MAAM,CAACa,IAAI,CACT,wBAAwBN,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withProjectBuildGradle","logger","FileManagement","copyGoogleServicesFile","androidPath","googleServicesFile","destination","exists","info","copyFile","withGoogleServicesJSON","configOuter","cioProps","props","modRequest","platformProjectRoot"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport function copyGoogleServicesFile(\n androidPath: string,\n googleServicesFile: string | undefined\n): void {\n const destination = `${androidPath}/app/google-services.json`;\n\n if (FileManagement.exists(destination)) {\n logger.info(`File already exists: ${destination}. Skipping...`);\n return;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(googleServicesFile, destination);\n } catch {\n logger.info(\n `There was an error copying your google-services.json file. You can copy it manually into ${destination}`\n );\n }\n } else {\n logger.info(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`\n );\n }\n}\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n copyGoogleServicesFile(\n props.modRequest.platformProjectRoot,\n cioProps?.googleServicesFile\n );\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,SAASC,sBAAsBA,CACpCC,WAAmB,EACnBC,kBAAsC,EAChC;EACN,MAAMC,WAAW,GAAG,GAAGF,WAAW,2BAA2B;EAE7D,IAAIF,cAAc,CAACK,MAAM,CAACD,WAAW,CAAC,EAAE;IACtCL,MAAM,CAACO,IAAI,CAAC,wBAAwBF,WAAW,eAAe,CAAC;IAC/D;EACF;EAEA,IAAID,kBAAkB,IAAIH,cAAc,CAACK,MAAM,CAACF,kBAAkB,CAAC,EAAE;IACnE,IAAI;MACFH,cAAc,CAACO,QAAQ,CAACJ,kBAAkB,EAAEC,WAAW,CAAC;IAC1D,CAAC,CAAC,MAAM;MACNL,MAAM,CAACO,IAAI,CACT,4FAA4FF,WAAW,EACzG,CAAC;IACH;EACF,CAAC,MAAM;IACLL,MAAM,CAACO,IAAI,CACT,wCAAwCH,kBAAkB,yDAAyDC,WAAW,EAChI,CAAC;EACH;AACF;AAEA,OAAO,MAAMI,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOZ,sBAAsB,CAACW,WAAW,EAAGE,KAAK,IAAK;IACpDV,sBAAsB,CACpBU,KAAK,CAACC,UAAU,CAACC,mBAAmB,EACpCH,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEP,kBACZ,CAAC;IACD,OAAOQ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,5 +1,19 @@
1
1
  import { withGradleProperties } from '@expo/config-plugins';
2
2
  const CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';
3
+ export function modifyGradleProperties(items) {
4
+ const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
5
+ const newItem = {
6
+ type: 'property',
7
+ key: CUSTOMERIO_LOCATION_ENABLED_KEY,
8
+ value: 'true'
9
+ };
10
+ if (existingIndex >= 0) {
11
+ items[existingIndex] = newItem;
12
+ } else {
13
+ items.push(newItem);
14
+ }
15
+ return items;
16
+ }
3
17
 
4
18
  /**
5
19
  * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
@@ -12,18 +26,7 @@ export const withLocationGradleProperties = (config, props) => {
12
26
  }
13
27
  return withGradleProperties(config, config => {
14
28
  const items = config.modResults;
15
- const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
16
- const newItem = {
17
- type: 'property',
18
- key: CUSTOMERIO_LOCATION_ENABLED_KEY,
19
- value: 'true'
20
- };
21
- if (existingIndex >= 0) {
22
- items[existingIndex] = newItem;
23
- } else {
24
- items.push(newItem);
25
- }
26
- config.modResults = items;
29
+ config.modResults = modifyGradleProperties(items);
27
30
  return config;
28
31
  });
29
32
  };