customerio-expo-plugin 0.0.4 → 1.0.0-alpha.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.
Files changed (143) hide show
  1. package/lib/commonjs/android/withAppGoogleServices.js +16 -0
  2. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  3. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  4. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  5. package/lib/commonjs/android/withGistMavenRepository.js +16 -0
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +30 -0
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  9. package/lib/commonjs/android/withProjectGoogleServices.js +16 -0
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  11. package/lib/commonjs/helpers/constants/android.js +19 -0
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  14. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/ios.js +138 -0
  16. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  17. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService-Info.plist +0 -0
  18. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.h +0 -0
  19. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.m +0 -0
  20. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.swift +0 -0
  21. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +0 -0
  22. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  23. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  24. package/lib/commonjs/helpers/utils/fileManagement.js +44 -0
  25. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +32 -0
  27. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  28. package/lib/commonjs/index.js +17 -0
  29. package/lib/commonjs/index.js.map +1 -0
  30. package/lib/commonjs/ios/withAppDelegateModifications.js +76 -0
  31. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +96 -0
  33. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  34. package/lib/commonjs/ios/withCIOIos.js +18 -0
  35. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  36. package/lib/commonjs/ios/withNotificationsXcodeProject.js +157 -0
  37. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  38. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  39. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  40. package/lib/commonjs/types/cio-types.js +15 -0
  41. package/lib/commonjs/types/cio-types.js.map +1 -0
  42. package/lib/module/android/withAppGoogleServices.js +9 -0
  43. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  44. package/lib/module/android/withCIOAndroid.js +12 -0
  45. package/lib/module/android/withCIOAndroid.js.map +1 -0
  46. package/lib/module/android/withGistMavenRepository.js +9 -0
  47. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  48. package/lib/module/android/withGoogleServicesJSON.js +23 -0
  49. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  50. package/lib/module/android/withProjectGoogleServices.js +9 -0
  51. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  52. package/lib/module/helpers/constants/android.js +7 -0
  53. package/lib/module/helpers/constants/android.js.map +1 -0
  54. package/lib/module/helpers/constants/globals.d.js +2 -0
  55. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  56. package/lib/module/helpers/constants/ios.js +102 -0
  57. package/lib/module/helpers/constants/ios.js.map +1 -0
  58. package/lib/module/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  59. package/lib/module/helpers/native-files/ios/CIONotificationService.h +5 -0
  60. package/lib/module/helpers/native-files/ios/CIONotificationService.m +30 -0
  61. package/lib/module/helpers/native-files/ios/CIONotificationService.swift +21 -0
  62. package/lib/module/helpers/native-files/ios/PushNotification.swift +56 -0
  63. package/lib/module/helpers/utils/codeInjection.js +24 -0
  64. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  65. package/lib/module/helpers/utils/fileManagement.js +37 -0
  66. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  67. package/lib/module/helpers/utils/injectCIOPodfileCode.js +25 -0
  68. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  69. package/lib/module/index.js +10 -0
  70. package/lib/module/index.js.map +1 -0
  71. package/lib/module/ios/withAppDelegateModifications.js +69 -0
  72. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  73. package/lib/module/ios/withAppDelegateXcodeProject.js +88 -0
  74. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  75. package/lib/module/ios/withCIOIos.js +12 -0
  76. package/lib/module/ios/withCIOIos.js.map +1 -0
  77. package/lib/module/ios/withNotificationsXcodeProject.js +149 -0
  78. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  79. package/lib/module/ios/withXcodeProject.js +21 -0
  80. package/lib/module/ios/withXcodeProject.js.map +1 -0
  81. package/lib/module/types/cio-types.js +10 -0
  82. package/lib/module/types/cio-types.js.map +1 -0
  83. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  84. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  85. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  86. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  87. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  88. package/lib/typescript/helpers/constants/android.d.ts +6 -0
  89. package/lib/typescript/helpers/constants/ios.d.ts +30 -0
  90. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  91. package/lib/typescript/helpers/utils/fileManagement.d.ts +5 -0
  92. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  93. package/lib/typescript/index.d.ts +4 -0
  94. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  95. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  96. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  97. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  98. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  99. package/lib/typescript/types/cio-types.d.ts +22 -0
  100. package/package.json +87 -13
  101. package/src/android/withAppGoogleServices.ts +19 -0
  102. package/src/android/withCIOAndroid.ts +19 -0
  103. package/src/android/withGistMavenRepository.ts +19 -0
  104. package/src/android/withGoogleServicesJSON.ts +30 -0
  105. package/src/android/withProjectGoogleServices.ts +19 -0
  106. package/src/helpers/constants/android.ts +12 -0
  107. package/src/helpers/constants/globals.d.ts +8 -0
  108. package/src/helpers/constants/ios.ts +116 -0
  109. package/src/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  110. package/src/helpers/native-files/ios/CIONotificationService.h +5 -0
  111. package/src/helpers/native-files/ios/CIONotificationService.m +30 -0
  112. package/src/helpers/native-files/ios/CIONotificationService.swift +21 -0
  113. package/src/helpers/native-files/ios/PushNotification.swift +56 -0
  114. package/src/helpers/utils/codeInjection.ts +46 -0
  115. package/src/helpers/utils/fileManagement.ts +39 -0
  116. package/src/helpers/utils/injectCIOPodfileCode.ts +47 -0
  117. package/src/index.ts +21 -0
  118. package/src/ios/withAppDelegateModifications.ts +150 -0
  119. package/src/ios/withAppDelegateXcodeProject.ts +110 -0
  120. package/src/ios/withCIOIos.ts +19 -0
  121. package/src/ios/withNotificationsXcodeProject.ts +231 -0
  122. package/src/ios/withXcodeProject.ts +25 -0
  123. package/src/types/cio-types.ts +28 -0
  124. package/build/helpers/.DS_Store +0 -0
  125. package/build/helpers/ios/.DS_Store +0 -0
  126. package/build/package.json +0 -36
  127. package/build/src/android/withAppGoogleServices.js +0 -12
  128. package/build/src/android/withCIOAndroid.js +0 -15
  129. package/build/src/android/withGistMavenRepository.js +0 -12
  130. package/build/src/android/withGoogleServicesJSON.js +0 -24
  131. package/build/src/android/withProjectGoogleServices.js +0 -12
  132. package/build/src/helpers/constants/android.js +0 -9
  133. package/build/src/helpers/constants/ios.js +0 -102
  134. package/build/src/helpers/utils/codeInjection.js +0 -30
  135. package/build/src/helpers/utils/fileManagement.js +0 -40
  136. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  137. package/build/src/index.js +0 -11
  138. package/build/src/ios/withAppDelegateModifications.js +0 -77
  139. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  140. package/build/src/ios/withCIOIos.js +0 -15
  141. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  142. package/build/src/ios/withXcodeProject.js +0 -22
  143. package/build/src/types/cio-types.js +0 -8
@@ -0,0 +1,149 @@
1
+ import { withXcodeProject } from '@expo/config-plugins';
2
+ import fs from 'fs';
3
+ import xcode from 'xcode';
4
+ import { CIO_NOTIFICATION_TARGET_NAME, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
5
+ import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
6
+ const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
7
+ const TARGETED_DEVICE_FAMILY = `"1,2"`;
8
+ const addNotificationServiceExtension = async options => {
9
+ const {
10
+ appleTeamId,
11
+ bundleIdentifier,
12
+ bundleShortVersion,
13
+ bundleVersion,
14
+ iosPath,
15
+ appName,
16
+ iosDeploymentTarget
17
+ } = options;
18
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
19
+ const xcodeProject = xcode.project(projPath);
20
+ xcodeProject.parse(async function (err) {
21
+ if (err) {
22
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
23
+ }
24
+ await injectCIONotificationPodfileCode(iosPath);
25
+ fs.mkdirSync(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
26
+ recursive: true
27
+ });
28
+ const files = [PLIST_FILENAME, 'CIONotificationService.h', 'CIONotificationService.swift', 'CIONotificationService.m'];
29
+ const getTargetFile = filename => `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
30
+ files.forEach(filename => {
31
+ const targetFile = getTargetFile(filename);
32
+ fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
33
+ });
34
+
35
+ /* MODIFY COPIED EXTENSION FILES */
36
+ const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
37
+ updateNseInfoPlist({
38
+ bundleVersion,
39
+ bundleShortVersion,
40
+ infoPlistTargetFile
41
+ });
42
+
43
+ // Create new PBXGroup for the extension
44
+ const extGroup = xcodeProject.addPbxGroup(files, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
45
+
46
+ // Add the new PBXGroup to the top level group. This makes the
47
+ // files / folder appear in the file explorer in Xcode.
48
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
49
+ Object.keys(groups).forEach(key => {
50
+ if (groups[key].name === undefined) {
51
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
52
+ }
53
+ });
54
+
55
+ // WORK AROUND for codeProject.addTarget BUG
56
+ // Xcode projects don't contain these if there is only one target
57
+ // An upstream fix should be made to the code referenced in this link:
58
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
59
+ const projObjects = xcodeProject.hash.project.objects;
60
+ projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
61
+ projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
62
+ if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
63
+ console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
64
+ return;
65
+ }
66
+
67
+ // Add the NSE target
68
+ // This also adds PBXTargetDependency and PBXContainerItemProxy
69
+ const nseTarget = xcodeProject.addTarget(CIO_NOTIFICATION_TARGET_NAME, 'app_extension', CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
70
+
71
+ // Add build phases to the new target
72
+ xcodeProject.addBuildPhase(['CIONotificationService.m', 'CIONotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
73
+ xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
74
+ xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
75
+
76
+ // Edit the Deployment info of the target
77
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
78
+ for (const key in configurations) {
79
+ if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
80
+ const buildSettingsObj = configurations[key].buildSettings;
81
+ buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
82
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget ?? '13.0';
83
+ buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
84
+ buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
85
+ buildSettingsObj.SWIFT_VERSION = 4.2;
86
+ }
87
+ }
88
+
89
+ // Add development team to the target & the main
90
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
91
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
92
+ fs.writeFileSync(projPath, xcodeProject.writeSync());
93
+ });
94
+ };
95
+ export const withCioNotificationsXcodeProject = (configOuter, props) => {
96
+ return withXcodeProject(configOuter, async config => {
97
+ const {
98
+ modRequest,
99
+ ios,
100
+ version: bundleShortVersion
101
+ } = config;
102
+ const {
103
+ appleTeamId,
104
+ iosDeploymentTarget
105
+ } = props;
106
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
107
+ const {
108
+ projectName,
109
+ platformProjectRoot
110
+ } = modRequest;
111
+ const {
112
+ bundleIdentifier,
113
+ buildNumber
114
+ } = ios;
115
+ if (bundleShortVersion === undefined) {
116
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
117
+ }
118
+ if (bundleIdentifier === undefined) {
119
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
120
+ }
121
+ if (projectName === undefined) {
122
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
123
+ }
124
+ const options = {
125
+ appleTeamId,
126
+ bundleIdentifier,
127
+ bundleShortVersion,
128
+ bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
129
+ iosPath: platformProjectRoot,
130
+ appName: projectName,
131
+ iosDeploymentTarget
132
+ };
133
+ await addNotificationServiceExtension(options);
134
+ return config;
135
+ });
136
+ };
137
+ const updateNseInfoPlist = payload => {
138
+ const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
139
+ const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
140
+ let plistFileString = fs.readFileSync(payload.infoPlistTargetFile, 'utf-8');
141
+ if (payload.bundleVersion) {
142
+ plistFileString = plistFileString.replace(BUNDLE_VERSION_RE, payload.bundleVersion);
143
+ }
144
+ if (payload.bundleShortVersion) {
145
+ plistFileString = plistFileString.replace(BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
146
+ }
147
+ fs.writeFileSync(payload.infoPlistTargetFile, plistFileString);
148
+ };
149
+ //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","fs","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","injectCIONotificationPodfileCode","PLIST_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdirSync","recursive","files","getTargetFile","filename","forEach","targetFile","copyFileSync","infoPlistTargetFile","updateNseInfoPlist","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","undefined","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","writeFileSync","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFileSync","replace"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport fs from 'fs';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n appName,\n iosDeploymentTarget,\n } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n await injectCIONotificationPodfileCode(iosPath);\n\n fs.mkdirSync(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'CIONotificationService.h',\n 'CIONotificationService.swift',\n 'CIONotificationService.m',\n ];\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] =\n projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['CIONotificationService.m', 'CIONotificationService.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget ?? '13.0';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n\n fs.writeFileSync(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'\n );\n\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = fs.readFileSync(payload.infoPlistTargetFile, 'utf-8');\n\n if (payload.bundleVersion) {\n plistFileString = plistFileString.replace(\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = plistFileString.replace(\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n fs.writeFileSync(payload.infoPlistTargetFile, plistFileString);\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2B,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AuB,EACvBD,OAAO,CAAChE,kBAAkB,CAC3B;EACH;EAEAZ,EAAE,CAACgE,aAAa,CAACY,OAAO,CAAC3C,mBAAmB,EAAE8C,eAAe,CAAC;AAChE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { withXcodeProject } from '@expo/config-plugins';
2
+ import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
3
+ export const withCioXcodeProject = (config, cioProps) => {
4
+ return withXcodeProject(config, async props => {
5
+ var _props$ios, _props$ios2;
6
+ const options = {
7
+ iosPath: props.modRequest.platformProjectRoot,
8
+ bundleIdentifier: (_props$ios = props.ios) === null || _props$ios === void 0 ? void 0 : _props$ios.bundleIdentifier,
9
+ devTeam: cioProps === null || cioProps === void 0 ? void 0 : cioProps.devTeam,
10
+ bundleVersion: (_props$ios2 = props.ios) === null || _props$ios2 === void 0 ? void 0 : _props$ios2.buildNumber,
11
+ bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
12
+ iosDeploymentTarget: cioProps === null || cioProps === void 0 ? void 0 : cioProps.iosDeploymentTarget
13
+ };
14
+ const {
15
+ iosPath
16
+ } = options;
17
+ await injectCIOPodfileCode(iosPath);
18
+ return props;
19
+ });
20
+ };
21
+ //# sourceMappingURL=withXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,GAAG,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOJ,gBAAgB,CAACG,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,gBAAEL,KAAK,CAACM,GAAG,+CAAT,WAAWD,gBAAgB;MAC7CE,OAAO,EAAER,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEQ,OAAO;MAC1BC,aAAa,iBAAER,KAAK,CAACM,GAAG,gDAAT,YAAWG,WAAW;MACrCC,kBAAkB,EAAEV,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,OAAO;MAClCC,mBAAmB,EAAEb,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEa;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAML,oBAAoB,CAACM,OAAO,CAAC;IAEnC,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ // properties set by the user in their app config file (e.g: app.json or app.plugin.js)
2
+
3
+ // Plugin options for pre-build
4
+
5
+ export let Mode;
6
+ (function (Mode) {
7
+ Mode["Dev"] = "development";
8
+ Mode["Prod"] = "production";
9
+ })(Mode || (Mode = {}));
10
+ //# sourceMappingURL=cio-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Mode"],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFilePath?: string;\n};\n\nexport enum Mode {\n Dev = 'development',\n Prod = 'production',\n}\n"],"mappings":"AAAA;;AAOA;;AAiBA,WAAYA,IAAI;AAGf,WAHWA,IAAI;EAAJA,IAAI;EAAJA,IAAI;AAAA,GAAJA,IAAI,KAAJA,IAAI"}
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ export declare const withAppGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,3 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ export declare function withCIOAndroid(config: ExpoConfig, props: CustomerIOPluginOptionsAndroid): ExpoConfig;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare const withGistMavenRepository: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare const withGoogleServicesJSON: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare const withProjectGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,6 @@
1
+ export declare const CIO_PROJECT_BUILDSCRIPTS_REGEX: RegExp;
2
+ export declare const CIO_APP_APPLY_REGEX: RegExp;
3
+ export declare const CIO_PROJECT_ALLPROJECTS_REGEX: RegExp;
4
+ export declare const CIO_PROJECT_GIST_MAVEN_SNIPPET = " maven { url \"https://maven.gist.build\" }";
5
+ export declare const CIO_APP_GOOGLE_SNIPPET = "apply plugin: \"com.google.gms.google-services\" // Google Services plugin";
6
+ export declare const CIO_PROJECT_GOOGLE_SNIPPET = " classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin";
@@ -0,0 +1,30 @@
1
+ export declare const LOCAL_PATH_TO_CIO_NSE_FILES = "node_modules/customerio-expo-plugin/src/helpers/native-files/ios";
2
+ export declare const IOS_DEPLOYMENT_TARGET = "13.0";
3
+ export declare const CIO_PODFILE_REGEX: RegExp;
4
+ export declare const CIO_PODFILE_NOTIFICATION_REGEX: RegExp;
5
+ export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
6
+ export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
7
+ export declare const BUNDLE_VERSION_TEMPLATE_REGEX: RegExp;
8
+ export declare const CIO_PODFILE_POST_INSTALL_REGEX: RegExp;
9
+ export declare const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX: RegExp;
10
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX: RegExp;
11
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX: RegExp;
12
+ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX: RegExp;
13
+ export declare const CIO_APPDELEGATEDECLARATION_REGEX: RegExp;
14
+ export declare const CIO_APPDELEGATEHEADER_REGEX: RegExp;
15
+ export declare const DEFAULT_BUNDLE_VERSION = "1";
16
+ export declare const DEFAULT_BUNDLE_SHORT_VERSION = "1.0";
17
+ export declare const CIO_TARGET_NAME = "CustomerIOSDK";
18
+ export declare const CIO_NOTIFICATION_TARGET_NAME = "CIONotificationService";
19
+ export declare const CIO_APPDELEGATEHEADER_SNIPPET = "\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n";
20
+ export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
21
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [pnHandlerObj application:application error:error];\n";
22
+ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
23
+ export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n";
24
+ export declare const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = "\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}";
25
+ export declare const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = "\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}";
26
+ export declare const CIO_PODFILE_NOTIFICATION_SNIPPET: string;
27
+ export declare const CIO_PODFILE_SNIPPET = "\n pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'\n pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'";
28
+ export declare const CIO_PODFILE_TARGET_NAMES_SNIPPET = "\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]";
29
+ export declare const CIO_PODFILE_POST_INSTALL_SNIPPET = "\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end";
30
+ export declare const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = "\ncio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n]\n\npost_install do |installer|\n\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end\n react_native_post_install(installer)\n __apply_Xcode_12_5_M1_post_install_workaround(installer)\nend";
@@ -0,0 +1,4 @@
1
+ export declare function injectCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string[];
2
+ export declare function injectCodeByMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
3
+ export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
4
+ export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string[];
@@ -0,0 +1,5 @@
1
+ export declare class FileManagement {
2
+ static read(path: string): Promise<string>;
3
+ static write(path: string, contents: string): Promise<void>;
4
+ static append(path: string, contents: string): Promise<void>;
5
+ }
@@ -0,0 +1,2 @@
1
+ export declare function injectCIOPodfileCode(iosPath: string): Promise<void>;
2
+ export declare function injectCIONotificationPodfileCode(iosPath: string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsIOS, CustomerIOPluginOptionsAndroid } from './types/cio-types';
3
+ declare function withCustomerIOPlugin(config: ExpoConfig, props: CustomerIOPluginOptionsIOS | CustomerIOPluginOptionsAndroid): ExpoConfig;
4
+ export default withCustomerIOPlugin;
@@ -0,0 +1,2 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ export declare const withAppDelegateModifications: ConfigPlugin<any>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withCioAppdelegateXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -0,0 +1,3 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare function withCIOIos(config: ExpoConfig, props: CustomerIOPluginOptionsIOS): ExpoConfig;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withCioNotificationsXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -0,0 +1,22 @@
1
+ export declare type CustomerIOPluginProperties = {
2
+ devTeam: string;
3
+ iosDeploymentTarget: string;
4
+ };
5
+ export declare type CustomerIOPluginOptionsIOS = {
6
+ iosPath: string;
7
+ devTeam?: string;
8
+ bundleVersion?: string;
9
+ bundleShortVersion?: string;
10
+ bundleIdentifier?: string;
11
+ iosDeploymentTarget?: string;
12
+ appleTeamId?: string;
13
+ appName?: string;
14
+ };
15
+ export declare type CustomerIOPluginOptionsAndroid = {
16
+ androidPath: string;
17
+ googleServicesFilePath?: string;
18
+ };
19
+ export declare enum Mode {
20
+ Dev = "development",
21
+ Prod = "production"
22
+ }
package/package.json CHANGED
@@ -1,23 +1,41 @@
1
1
  {
2
2
  "name": "customerio-expo-plugin",
3
- "version": "0.0.4",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "Expo config plugin for the Customer IO React Native SDK",
5
- "main": "build/src/index.js",
6
- "types": "build/index.d.ts",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "source": "src/index",
9
+ "react-native": "src/index",
7
10
  "license": "MIT",
8
11
  "files": [
9
- "build/**/*"
12
+ "src",
13
+ "lib/**/*"
10
14
  ],
11
15
  "scripts": {
12
- "copy-native-files": "cp -r src/helpers/native-files build/helpers/",
13
- "build": "rm -rf build && tsc && npm run copy-native-files",
14
- "build:watch": "npm run build && tsc --watch",
15
- "clean": "rm -rf build",
16
+ "build": "npm run clean && tsc",
17
+ "clean": "rm -rf lib",
16
18
  "expo-module": "expo-module",
17
- "lint": "eslint .",
18
- "tc": "tsc --noEmit",
19
- "prepare": "npm run clean && npm run build",
20
- "prepublishOnly": "npm run tc && npm run lint"
19
+ "lint": "eslint . --fix",
20
+ "typescript": "tsc --noEmit",
21
+ "prepare": "npm run clean && bob build"
22
+ },
23
+ "keywords": [
24
+ "react-native",
25
+ "ios",
26
+ "android"
27
+ ],
28
+ "repository": "https://github.com/customerio/customerio-expo-plugin",
29
+ "author": "ami-segun <segun@customer.io> (https://customer.io/)",
30
+ "bugs": {
31
+ "url": "https://github.com/customerio/customerio-expo-plugin/issues"
32
+ },
33
+ "homepage": "https://github.com/customerio/customerio-expo-plugin#readme",
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/"
36
+ },
37
+ "peerDependencies": {
38
+ "customerio-reactnative": "*"
21
39
  },
22
40
  "devDependencies": {
23
41
  "@expo/config-plugins": "^4.1.4",
@@ -27,10 +45,66 @@
27
45
  "eslint": "^8.14.0",
28
46
  "eslint-config-prettier": "^8.5.0",
29
47
  "eslint-plugin-prettier": "^4.0.0",
30
- "expo-module-scripts": "^2.0.0",
31
48
  "expo-build-properties": "^0.2.0",
49
+ "expo-module-scripts": "^2.0.0",
32
50
  "prettier": "^2.6.2",
51
+ "react-native-builder-bob": "^0.18.3",
33
52
  "typescript": "^4.6.4",
34
53
  "xcode": "^3.0.1"
54
+ },
55
+ "jest": {
56
+ "preset": "react-native",
57
+ "modulePathIgnorePatterns": [
58
+ "<rootDir>/lib/"
59
+ ]
60
+ },
61
+ "commitlint": {
62
+ "extends": [
63
+ "@commitlint/config-conventional"
64
+ ]
65
+ },
66
+ "eslintConfig": {
67
+ "root": true,
68
+ "extends": [
69
+ "@react-native-community",
70
+ "prettier"
71
+ ],
72
+ "rules": {
73
+ "prettier/prettier": [
74
+ "error",
75
+ {
76
+ "quoteProps": "consistent",
77
+ "singleQuote": true,
78
+ "tabWidth": 2,
79
+ "trailingComma": "es5",
80
+ "useTabs": false
81
+ }
82
+ ]
83
+ }
84
+ },
85
+ "eslintIgnore": [
86
+ "node_modules/",
87
+ "lib/"
88
+ ],
89
+ "prettier": {
90
+ "quoteProps": "consistent",
91
+ "singleQuote": true,
92
+ "tabWidth": 2,
93
+ "trailingComma": "es5",
94
+ "useTabs": false
95
+ },
96
+ "react-native-builder-bob": {
97
+ "source": "src",
98
+ "output": "lib",
99
+ "targets": [
100
+ "commonjs",
101
+ "module",
102
+ [
103
+ "typescript",
104
+ {
105
+ "project": "tsconfig.build.json"
106
+ }
107
+ ]
108
+ ]
35
109
  }
36
110
  }
@@ -0,0 +1,19 @@
1
+ import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';
2
+
3
+ import {
4
+ CIO_APP_APPLY_REGEX,
5
+ CIO_APP_GOOGLE_SNIPPET,
6
+ } from '../helpers/constants/android';
7
+ import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
8
+
9
+ export const withAppGoogleServices: ConfigPlugin<
10
+ CustomerIOPluginOptionsAndroid
11
+ > = (configOuter) => {
12
+ return withAppBuildGradle(configOuter, (props) => {
13
+ props.modResults.contents = props.modResults.contents.replace(
14
+ CIO_APP_APPLY_REGEX,
15
+ `$1\n${CIO_APP_GOOGLE_SNIPPET}`
16
+ );
17
+ return props;
18
+ });
19
+ };
@@ -0,0 +1,19 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+
3
+ import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
4
+ import { withAppGoogleServices } from './withAppGoogleServices';
5
+ import { withGistMavenRepository } from './withGistMavenRepository';
6
+ import { withGoogleServicesJSON } from './withGoogleServicesJSON';
7
+ import { withProjectGoogleServices } from './withProjectGoogleServices';
8
+
9
+ export function withCIOAndroid(
10
+ config: ExpoConfig,
11
+ props: CustomerIOPluginOptionsAndroid
12
+ ): ExpoConfig {
13
+ config = withGistMavenRepository(config, props);
14
+ config = withProjectGoogleServices(config, props);
15
+ config = withAppGoogleServices(config, props);
16
+ config = withGoogleServicesJSON(config, props);
17
+
18
+ return config;
19
+ }
@@ -0,0 +1,19 @@
1
+ import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';
2
+
3
+ import {
4
+ CIO_PROJECT_ALLPROJECTS_REGEX,
5
+ CIO_PROJECT_GIST_MAVEN_SNIPPET,
6
+ } from '../helpers/constants/android';
7
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
8
+
9
+ export const withGistMavenRepository: ConfigPlugin<
10
+ CustomerIOPluginOptionsAndroid
11
+ > = (configOuter) => {
12
+ return withProjectBuildGradle(configOuter, (props) => {
13
+ props.modResults.contents = props.modResults.contents.replace(
14
+ CIO_PROJECT_ALLPROJECTS_REGEX,
15
+ `$1\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`
16
+ );
17
+ return props;
18
+ });
19
+ };
@@ -0,0 +1,30 @@
1
+ import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';
2
+ import { copyFileSync } from 'fs';
3
+
4
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
5
+
6
+ export const withGoogleServicesJSON: ConfigPlugin<
7
+ CustomerIOPluginOptionsAndroid
8
+ > = (configOuter, cioProps) => {
9
+ return withProjectBuildGradle(configOuter, (props) => {
10
+ const options: CustomerIOPluginOptionsAndroid = {
11
+ androidPath: props.modRequest.platformProjectRoot,
12
+ googleServicesFilePath: cioProps?.googleServicesFilePath,
13
+ };
14
+ const { androidPath, googleServicesFilePath } = options;
15
+ if (googleServicesFilePath) {
16
+ try {
17
+ copyFileSync(
18
+ `${googleServicesFilePath}google-services.json`,
19
+ `${androidPath}/app/google-services.json`
20
+ );
21
+ } catch (e) {
22
+ console.log(
23
+ 'There was an error copying your google-services.json file.'
24
+ );
25
+ }
26
+ }
27
+
28
+ return props;
29
+ });
30
+ };
@@ -0,0 +1,19 @@
1
+ import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';
2
+
3
+ import {
4
+ CIO_PROJECT_BUILDSCRIPTS_REGEX,
5
+ CIO_PROJECT_GOOGLE_SNIPPET,
6
+ } from './../helpers/constants/android';
7
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
8
+
9
+ export const withProjectGoogleServices: ConfigPlugin<
10
+ CustomerIOPluginOptionsAndroid
11
+ > = (configOuter) => {
12
+ return withProjectBuildGradle(configOuter, (props) => {
13
+ props.modResults.contents = props.modResults.contents.replace(
14
+ CIO_PROJECT_BUILDSCRIPTS_REGEX,
15
+ `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`
16
+ );
17
+ return props;
18
+ });
19
+ };
@@ -0,0 +1,12 @@
1
+ export const CIO_PROJECT_BUILDSCRIPTS_REGEX =
2
+ /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
3
+ export const CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
4
+ export const CIO_PROJECT_ALLPROJECTS_REGEX =
5
+ /(allprojects\s*\{(.|\n)*repositories\s*\{)/;
6
+
7
+ export const CIO_PROJECT_GIST_MAVEN_SNIPPET =
8
+ ' maven { url "https://maven.gist.build" }';
9
+ export const CIO_APP_GOOGLE_SNIPPET =
10
+ 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
11
+ export const CIO_PROJECT_GOOGLE_SNIPPET =
12
+ ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
@@ -0,0 +1,8 @@
1
+ declare module 'xcode' {
2
+ interface xcode {
3
+ project(projPath: string): any;
4
+ }
5
+
6
+ const xcode: xcode;
7
+ export default xcode;
8
+ }