customerio-expo-plugin 1.0.0-alpha.1 → 1.0.0-alpha.3

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 (103) hide show
  1. package/lib/commonjs/analytics/injectAnalytics.js +31 -0
  2. package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
  3. package/lib/commonjs/android/withAppGoogleServices.js +7 -1
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  5. package/lib/commonjs/android/withGistMavenRepository.js +6 -1
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +10 -6
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/lib/commonjs/android/withProjectGoogleServices.js +5 -1
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  11. package/lib/commonjs/helpers/constants/android.js +4 -2
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -1
  13. package/lib/commonjs/helpers/constants/ios.js +5 -3
  14. package/lib/commonjs/helpers/constants/ios.js.map +1 -1
  15. package/lib/commonjs/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  16. package/lib/commonjs/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  17. package/lib/{module/helpers/native-files/ios/CIONotificationService.m → commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
  18. package/lib/{module/helpers/native-files/ios/CIONotificationService.swift → commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
  19. package/lib/commonjs/helpers/native-files/ios/PushNotification.swift +1 -10
  20. package/lib/commonjs/helpers/utils/fileManagement.js +32 -0
  21. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
  22. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +12 -7
  23. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  24. package/lib/commonjs/index.js +8 -2
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/ios/withAppDelegateModifications.js +27 -18
  27. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  28. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +15 -32
  29. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -1
  30. package/lib/commonjs/ios/withCIOIos.js +8 -3
  31. package/lib/commonjs/ios/withCIOIos.js.map +1 -1
  32. package/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -16
  33. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  34. package/lib/commonjs/types/cio-types.js +0 -13
  35. package/lib/commonjs/types/cio-types.js.map +1 -1
  36. package/lib/commonjs/version.js +9 -0
  37. package/lib/commonjs/version.js.map +1 -0
  38. package/lib/module/analytics/injectAnalytics.js +24 -0
  39. package/lib/module/analytics/injectAnalytics.js.map +1 -0
  40. package/lib/module/android/withAppGoogleServices.js +7 -1
  41. package/lib/module/android/withAppGoogleServices.js.map +1 -1
  42. package/lib/module/android/withGistMavenRepository.js +7 -2
  43. package/lib/module/android/withGistMavenRepository.js.map +1 -1
  44. package/lib/module/android/withGoogleServicesJSON.js +10 -6
  45. package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  46. package/lib/module/android/withProjectGoogleServices.js +5 -1
  47. package/lib/module/android/withProjectGoogleServices.js.map +1 -1
  48. package/lib/module/helpers/constants/android.js +2 -1
  49. package/lib/module/helpers/constants/android.js.map +1 -1
  50. package/lib/module/helpers/constants/ios.js +3 -2
  51. package/lib/module/helpers/constants/ios.js.map +1 -1
  52. package/lib/module/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  53. package/lib/module/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  54. package/{src/helpers/native-files/ios/CIONotificationService.m → lib/module/helpers/native-files/ios/NotificationService.m} +2 -6
  55. package/{src/helpers/native-files/ios/CIONotificationService.swift → lib/module/helpers/native-files/ios/NotificationService.swift} +0 -2
  56. package/lib/module/helpers/native-files/ios/PushNotification.swift +1 -10
  57. package/lib/module/helpers/utils/fileManagement.js +33 -1
  58. package/lib/module/helpers/utils/fileManagement.js.map +1 -1
  59. package/lib/module/helpers/utils/injectCIOPodfileCode.js +13 -8
  60. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  61. package/lib/module/index.js +8 -2
  62. package/lib/module/index.js.map +1 -1
  63. package/lib/module/ios/withAppDelegateModifications.js +27 -18
  64. package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  65. package/lib/module/ios/withAppDelegateXcodeProject.js +15 -32
  66. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -1
  67. package/lib/module/ios/withCIOIos.js +8 -3
  68. package/lib/module/ios/withCIOIos.js.map +1 -1
  69. package/lib/module/ios/withNotificationsXcodeProject.js +17 -16
  70. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  71. package/lib/module/types/cio-types.js +0 -8
  72. package/lib/module/types/cio-types.js.map +1 -1
  73. package/lib/module/version.js +2 -0
  74. package/lib/module/version.js.map +1 -0
  75. package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
  76. package/lib/typescript/helpers/constants/android.d.ts +1 -0
  77. package/lib/typescript/helpers/constants/ios.d.ts +2 -1
  78. package/lib/typescript/helpers/utils/fileManagement.d.ts +7 -0
  79. package/lib/typescript/index.d.ts +2 -2
  80. package/lib/typescript/types/cio-types.d.ts +7 -4
  81. package/lib/typescript/version.d.ts +1 -0
  82. package/package.json +3 -2
  83. package/src/analytics/injectAnalytics.ts +36 -0
  84. package/src/android/withAppGoogleServices.ts +11 -4
  85. package/src/android/withGistMavenRepository.ts +11 -4
  86. package/src/android/withGoogleServicesJSON.ts +17 -11
  87. package/src/android/withProjectGoogleServices.ts +9 -4
  88. package/src/helpers/constants/android.ts +3 -1
  89. package/src/helpers/constants/ios.ts +3 -3
  90. package/src/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  91. package/src/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  92. package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.m → src/helpers/native-files/ios/NotificationService.m} +2 -6
  93. package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.swift → src/helpers/native-files/ios/NotificationService.swift} +0 -2
  94. package/src/helpers/native-files/ios/PushNotification.swift +1 -10
  95. package/src/helpers/utils/fileManagement.ts +49 -1
  96. package/src/helpers/utils/injectCIOPodfileCode.ts +23 -17
  97. package/src/index.ts +12 -7
  98. package/src/ios/withAppDelegateModifications.ts +39 -23
  99. package/src/ios/withAppDelegateXcodeProject.ts +19 -40
  100. package/src/ios/withCIOIos.ts +9 -3
  101. package/src/ios/withNotificationsXcodeProject.ts +24 -18
  102. package/src/types/cio-types.ts +7 -4
  103. package/src/version.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"names":["pushCodeSnippets","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","additionalMethodsForPushNotifications","join","addImport","stringContents","importRegex","addedImport","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","AddDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addAdditionalMethodsForPushNotifications","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","addAppdelegateHeaderModification","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","withAppDelegateModifications","configOuter","withAppDelegate","config","modResults","contents","headerPath","getAppDelegateHeaderFilePath","modRequest","projectRoot","headerContent","FileManagement","read","write"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join w/ newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <testiosapp-Swift.h>\n `;\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst AddDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(stringContents);\n stringContents = addNotificationHandlerDeclaration(stringContents);\n stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n config.modResults.contents = stringContents;\n return config;\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAeA;AAKA;AAEA,MAAMA,gBAAgB,GAAG,CACvBC,sDAAiD,EACjDC,+CAA0C,CAC3C;AAED,MAAMC,qCAAqC,GAAI,GAAEH,gBAAgB,CAACI,IAAI,CACpE,IAAI,CACJ,IAAG,CAAC,CAAC;;AAEP,MAAMC,SAAS,GAAIC,cAAsB,IAAK;EAC5C,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAI;AACvB;AACA;AACA;AACA,GAAG;EAED,MAAMC,KAAK,GAAGH,cAA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,GAAIzB,cAAsB,IAAK;EACnEA,cAAc,GAAG,IAAAiB,uDAAwC,EACvDjB,cAAc,EACd0B,gCAA2B,EAC3BC,kCAA6B,CAC9B;EAED,OAAO3B,cAAc;AACvB,CAAC;AAEM,MAAM4B,4BAA+C,GAC1DC,WAAW,IACR;EACH,OAAO,IAAAC,8BAAe,EAACD,WAAW,EAAE,MAAOE,MAAM,IAAK;IACpD,IAAI/B,cAAc,GAAG+B,MAAM,CAACC,UAAU,CAACC,QAAQ;IAC/C,MAAMC,UAAU,GAAG,IAAAC,mCAA4B,EAC7CJ,MAAM,CAACK,UAAU,CAACC,WAAW,CAC9B;IACD,IAAIC,aAAa,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACN,UAAU,CAAC;IACzDI,aAAa,GAAGb,gCAAgC,CAACa,aAAa,CAAC;IAC/DC,8BAAc,CAACE,KAAK,CAACP,UAAU,EAAEI,aAAa,CAAC;IAE/CtC,cAAc,GAAGD,SAAS,CAACC,cAAc,CAAC;IAC1CA,cAAc,GAAGS,iCAAiC,CAACT,cAAc,CAAC;IAClEA,cAAc,GAAGa,4BAA4B,CAACb,cAAc,CAAC;IAC7DA,cAAc,GAAGuB,wCAAwC,CAACvB,cAAc,CAAC;IACzEA,cAAc,GACZgB,mDAAmD,CAAChB,cAAc,CAAC;IACrEA,cAAc,GACZoB,mDAAmD,CAACpB,cAAc,CAAC;IAErE+B,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGjC,cAAc;IAC3C,OAAO+B,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["pushCodeSnippets","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","AddDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addAdditionalMethodsForPushNotifications","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","addAppdelegateHeaderModification","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","withAppDelegateModifications","configOuter","withAppDelegate","config","modResults","contents","regex","RegExp","modRequest","projectName","headerPath","getAppDelegateHeaderFilePath","projectRoot","headerContent","FileManagement","read","write","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst AddDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAeA;AAKA;AAEA,MAAMA,gBAAgB,GAAG,CACvBC,sDAAiD,EACjDC,+CAA0C,CAC3C;AAED,MAAMC,qCAAqC,GAAI,GAAEH,gBAAgB,CAACI,IAAI,CACpE,IAAI,CACJ,IAAG,CAAC,CAAC;;AAEP,MAAMC,SAAS,GAAG,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAKC,SAAS,EAAE;IACvC;IACAF,eAAe,GAAG,CAAC;EACrB,CAAC,MAAM;IACL;IACAA,eAAe,GAAGD,KAAK,CAACE,KAAK,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACI,MAAM;EACjD;EAEAT,cAAc,GAAG,IAAAU,qCAAsB,EACrCV,cAAc,EACdM,eAAe,EACfH,WAAW,CACZ,CAACL,IAAI,CAAC,IAAI,CAAC;EAEZ,OAAOE,cAAc;AACvB,CAAC;AAED,MAAMW,iCAAiC,GAAIX,cAAsB,IAAK;EACpEA,cAAc,GAAG,IAAAY,yCAA0B,EACzCZ,cAAc,EACda,qCAAgC,EAChCC,mDAA8C,CAC/C;EAED,OAAOd,cAAc;AACvB,CAA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,CAACK,UAAU,CAACI,WAAW,CAC9B;MACD,IAAIC,aAAa,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACL,UAAU,CAAC;MACzDG,aAAa,GAAGhB,gCAAgC,CAACgB,aAAa,CAAC;MAC/DC,8BAAc,CAACE,KAAK,CAACN,UAAU,EAAEG,aAAa,CAAC;MAE/C3C,cAAc,GAAGD,SAAS,CACxBC,cAAc,EACdiC,MAAM,CAACK,UAAU,CAACC,WAAW,CAC9B;MACDvC,cAAc,GAAGW,iCAAiC,CAACX,cAAc,CAAC;MAClEA,cAAc,GAAGe,4BAA4B,CAACf,cAAc,CAAC;MAC7DA,cAAc,GAAGyB,wCAAwC,CAACzB,cAAc,CAAC;MACzEA,cAAc,GACZkB,mDAAmD,CAAClB,cAAc,CAAC;MACrEA,cAAc,GACZsB,mDAAmD,CAACtB,cAAc,CAAC;MAErEiC,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGnC,cAAc;IAC7C,CAAC,MAAM;MACL+C,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOf,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC;AACF,SAAS7B,gBAAgB,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.withCioAppdelegateXcodeProject = void 0;
7
7
  var _configPlugins = require("@expo/config-plugins");
8
- var _fs = _interopRequireDefault(require("fs"));
9
8
  var _xcode = _interopRequireDefault(require("xcode"));
10
9
  var _ios = require("../helpers/constants/ios");
10
+ var _fileManagement = require("./../helpers/utils/fileManagement");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- const addNotificationServiceExtensionFile = async options => {
12
+ const addNotificationSwiftFile = async options => {
13
13
  const {
14
14
  iosPath,
15
15
  appName
@@ -17,37 +17,20 @@ const addNotificationServiceExtensionFile = async options => {
17
17
  const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
18
18
  const xcodeProject = _xcode.default.project(projPath);
19
19
  xcodeProject.parse(async function (err) {
20
+ const file = 'PushNotification.swift';
21
+ const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
20
22
  if (err) {
21
23
  throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
22
24
  }
23
- _fs.default.mkdirSync(`${iosPath}/${appName}`, {
24
- recursive: true
25
- });
26
- const file = 'PushNotification.swift';
27
- const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
28
- const targetFile = getTargetFile(file);
29
- _fs.default.copyFileSync(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
30
-
31
- // Create new PBXGroup for the extension
32
- const extGroup = xcodeProject.addPbxGroup([file], appName, appName);
33
-
34
- // Add the new PBXGroup to the top level group. This makes the
35
- // files / folder appear in the file explorer in Xcode.
36
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
37
- Object.keys(groups).forEach(key => {
38
- if (groups[key].name === undefined) {
39
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
40
- }
41
- });
42
-
43
- // WORK AROUND for codeProject.addTarget BUG
44
- // Xcode projects don't contain these if there is only one target
45
- // An upstream fix should be made to the code referenced in this link:
46
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
47
- const projObjects = xcodeProject.hash.project.objects;
48
- projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
49
- projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
50
- _fs.default.writeFileSync(projPath, xcodeProject.writeSync());
25
+ if (!_fileManagement.FileManagement.exists(getTargetFile(file))) {
26
+ _fileManagement.FileManagement.mkdir(`${iosPath}/${appName}`, {
27
+ recursive: true
28
+ });
29
+ const targetFile = getTargetFile(file);
30
+ _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
31
+ } else {
32
+ console.log(`${getTargetFile(file)} already exists. Skipping...`);
33
+ }
51
34
  });
52
35
  };
53
36
  const withCioAppdelegateXcodeProject = (configOuter, props) => {
@@ -83,12 +66,12 @@ const withCioAppdelegateXcodeProject = (configOuter, props) => {
83
66
  appleTeamId,
84
67
  bundleIdentifier,
85
68
  bundleShortVersion,
86
- bundleVersion: buildNumber ?? _ios.DEFAULT_BUNDLE_VERSION,
69
+ bundleVersion: buildNumber || _ios.DEFAULT_BUNDLE_VERSION,
87
70
  iosPath: platformProjectRoot,
88
71
  appName: projectName,
89
72
  iosDeploymentTarget
90
73
  };
91
- await addNotificationServiceExtensionFile(options);
74
+ await addNotificationSwiftFile(options);
92
75
  return config;
93
76
  });
94
77
  };
@@ -1 +1 @@
1
- {"version":3,"names":["addNotificationServiceExtensionFile","options","iosPath","appName","projPath","xcodeProject","xcode","project","parse","err","Error","JSON","stringify","fs","mkdirSync","recursive","file","getTargetFile","filename","targetFile","copyFileSync","LOCAL_PATH_TO_CIO_NSE_FILES","extGroup","addPbxGroup","groups","hash","objects","Object","keys","forEach","key","name","undefined","addToPbxGroup","uuid","projObjects","writeFileSync","writeSync","withCioAppdelegateXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","DEFAULT_BUNDLE_VERSION"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport fs from 'fs';\nimport xcode from 'xcode';\n\nimport {\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst addNotificationServiceExtensionFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = 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 fs.mkdirSync(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const file = 'PushNotification.swift';\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n\n const targetFile = getTargetFile(file);\n fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup([file], appName, appName);\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 fs.writeFileSync(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioAppdelegateXcodeProject: 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 addNotificationServiceExtensionFile(options);\n\n return config;\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AAGkC;AAGlC,MAAMA,mCAAmC,GAAG,MAC1CC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EAEpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAElE,MAAME,YAAY,GAAGC,cAAK,CAACC,OAAO,CAACH,QAAQ,CAAC;EAE5CC,YAAY,CAACG,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAC7C,IAAIA,GAAG,EAAE;MACP,MAAM,IAAIC,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAE,EAAC,CAAC;IACtE;IAEAI,WAAE,CAACC,SAAS,CAAE,GAAEZ,OAAQ,IAAGC,OAAQ,EAAC,EAAE;MACpCY,SAAS,EAAE;IACb,CAAC,CAAC;IAEF,MAAMC,IAAI,GAAG,wBAAwB;IAErC,MAAMC,aAAa,GAAIC,QAAgB,IACpC,GAAEhB,OAAQ,IAAGC,OAAQ,IAAGe,QAAS,EAAC;IAErC,MAAMC,UAAU,GAAGF,aAAa,CAACD,IAAI,CAAC;IACtCH,WAAE,CAACO,YAAY,CAAE,GAAEC,gCAA4B,IAAGL,IAAK,EAAC,EAAEG,UAAU,CAAC;;IAErE;IACA,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;IACvD,MAAM;MAAEQ,gBAAgB;MAAEC;IAAY,CAAC,GAAGR,GAAG;IAE7C,IAAIE,kBAAkB,KAAKd,SAAS,EAAE;MACpC,MAAM,IAAItB,KAAK,CACb,gFAAgF,CACjF;IACH;IAEA,IAAIyC,gBAAgB,KAAKnB,SAAS,EAAE;MAClC,MAAM,IAAItB,KAAK,CACb,6FAA6F,CAC9F;IACH;IAEA,IAAIuC,WAAW,KAAKjB,SAAS,EAAE;MAC7B,MAAM,IAAItB,KAAK,CACb,6EAA6E,CAC9E;IACH;IAEA,MAAMT,OAAO,GAAG;MACd8C,WAAW;MACXI,gBAAgB;MAChBL,kBAAkB;MAClBO,aAAa,EAAED,WAAW,IAAIE,2BAAsB;MACpDpD,OAAO,EAAEgD,mBAAmB;MAC5B/C,OAAO,EAAE8C,WAAW;MACpBD;IACF,CAAC;IAED,MAAMhD,mCAAmC,CAACC,OAAO,CAAC;IAElD,OAAOyC,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["addNotificationSwiftFile","options","iosPath","appName","projPath","xcodeProject","xcode","project","parse","err","file","getTargetFile","filename","Error","JSON","stringify","FileManagement","exists","mkdir","recursive","targetFile","copyFile","LOCAL_PATH_TO_CIO_NSE_FILES","console","log","withCioAppdelegateXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","DEFAULT_BUNDLE_VERSION"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst addNotificationSwiftFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = options;\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n const file = 'PushNotification.swift';\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const targetFile = getTargetFile(file);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n }\n });\n};\n\nexport const withCioAppdelegateXcodeProject: 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 addNotificationSwiftFile(options);\n\n return config;\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAKA;AAAmE;AAEn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AoB,CAAC,GAAGR,KAAK;IAElD,IAAII,GAAG,KAAKK,SAAS,EACnB,MAAM,IAAIvB,KAAK,CACb,oFAAoF,CACrF;IAEH,MAAM;MAAEwB,WAAW;MAAEC;IAAoB,CAAC,GAAGR,UAAU;IACvD,MAAM;MAAES,gBAAgB;MAAEC;IAAY,CAAC,GAAGT,GAAG;IAE7C,IAAIE,kBAAkB,KAAKG,SAAS,EAAE;MACpC,MAAM,IAAIvB,KAAK,CACb,gFAAgF,CACjF;IACH;IAEA,IAAI0B,gBAAgB,KAAKH,SAAS,EAAE;MAClC,MAAM,IAAIvB,KAAK,CACb,6FAA6F,CAC9F;IACH;IAEA,IAAIwB,WAAW,KAAKD,SAAS,EAAE;MAC7B,MAAM,IAAIvB,KAAK,CACb,6EAA6E,CAC9E;IACH;IAEA,MAAMZ,OAAO,GAAG;MACdiC,WAAW;MACXK,gBAAgB;MAChBN,kBAAkB;MAClBQ,aAAa,EAAED,WAAW,IAAIE,2BAAsB;MACpDxC,OAAO,EAAEoC,mBAAmB;MAC5BnC,OAAO,EAAEkC,WAAW;MACpBF;IACF,CAAC;IAED,MAAMnC,wBAAwB,CAACC,OAAO,CAAC;IAEvC,OAAO4B,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC"}
@@ -9,10 +9,15 @@ var _withAppDelegateXcodeProject = require("./withAppDelegateXcodeProject");
9
9
  var _withNotificationsXcodeProject = require("./withNotificationsXcodeProject");
10
10
  var _withXcodeProject = require("./withXcodeProject");
11
11
  function withCIOIos(config, props) {
12
- config = (0, _withNotificationsXcodeProject.withCioNotificationsXcodeProject)(config, props);
13
- config = (0, _withAppDelegateModifications.withAppDelegateModifications)(config, props);
12
+ var _props$pushNotificati;
13
+ if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.useRichPush) {
14
+ config = (0, _withNotificationsXcodeProject.withCioNotificationsXcodeProject)(config, props);
15
+ }
16
+ if (props.pushNotification) {
17
+ config = (0, _withAppDelegateModifications.withAppDelegateModifications)(config, props);
18
+ config = (0, _withAppDelegateXcodeProject.withCioAppdelegateXcodeProject)(config, props);
19
+ }
14
20
  config = (0, _withXcodeProject.withCioXcodeProject)(config, props);
15
- config = (0, _withAppDelegateXcodeProject.withCioAppdelegateXcodeProject)(config, props);
16
21
  return config;
17
22
  }
18
23
  //# sourceMappingURL=withCIOIos.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withCIOIos","config","props","withCioNotificationsXcodeProject","withAppDelegateModifications","withCioXcodeProject","withCioAppdelegateXcodeProject"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n config = withCioNotificationsXcodeProject(config, props);\n config = withAppDelegateModifications(config, props);\n config = withCioXcodeProject(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AAEO,SAASA,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACAD,MAAM,GAAG,IAAAE,+DAAgC,EAACF,MAAM,EAAEC,KAAK,CAAC;EACxDD,MAAM,GAAG,IAAAG,0DAA4B,EAACH,MAAM,EAAEC,KAAK,CAAC;EACpDD,MAAM,GAAG,IAAAI,qCAAmB,EAACJ,MAAM,EAAEC,KAAK,CAAC;EAC3CD,MAAM,GAAG,IAAAK,2DAA8B,EAACL,MAAM,EAAEC,KAAK,CAAC;EAEtD,OAAOD,MAAM;AACf"}
1
+ {"version":3,"names":["withCIOIos","config","props","pushNotification","useRichPush","withCioNotificationsXcodeProject","withAppDelegateModifications","withCioAppdelegateXcodeProject","withCioXcodeProject"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification?.useRichPush) {\n config = withCioNotificationsXcodeProject(config, props);\n }\n\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n }\n\n config = withCioXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AAEO,SAASA,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EAAA;EACA,6BAAIA,KAAK,CAACC,gBAAgB,kDAAtB,sBAAwBC,WAAW,EAAE;IACvCH,MAAM,GAAG,IAAAI,+DAAgC,EAACJ,MAAM,EAAEC,KAAK,CAAC;EAC1D;EAEA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAG,IAAAK,0DAA4B,EAACL,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAG,IAAAM,2DAA8B,EAACN,MAAM,EAAEC,KAAK,CAAC;EACxD;EAEAD,MAAM,GAAG,IAAAO,qCAAmB,EAACP,MAAM,EAAEC,KAAK,CAAC;EAE3C,OAAOD,MAAM;AACf"}
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.withCioNotificationsXcodeProject = void 0;
7
7
  var _configPlugins = require("@expo/config-plugins");
8
- var _fs = _interopRequireDefault(require("fs"));
9
8
  var _xcode = _interopRequireDefault(require("xcode"));
10
9
  var _ios = require("../helpers/constants/ios");
10
+ var _codeInjection = require("../helpers/utils/codeInjection");
11
11
  var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
12
+ var _fileManagement = require("./../helpers/utils/fileManagement");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  const PLIST_FILENAME = `${_ios.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
14
15
  const TARGETED_DEVICE_FAMILY = `"1,2"`;
@@ -29,14 +30,14 @@ const addNotificationServiceExtension = async options => {
29
30
  throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
30
31
  }
31
32
  await (0, _injectCIOPodfileCode.injectCIONotificationPodfileCode)(iosPath);
32
- _fs.default.mkdirSync(`${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}`, {
33
+ _fileManagement.FileManagement.mkdir(`${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}`, {
33
34
  recursive: true
34
35
  });
35
- const files = [PLIST_FILENAME, 'CIONotificationService.h', 'CIONotificationService.swift', 'CIONotificationService.m'];
36
+ const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m'];
36
37
  const getTargetFile = filename => `${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
37
38
  files.forEach(filename => {
38
39
  const targetFile = getTargetFile(filename);
39
- _fs.default.copyFileSync(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
40
+ _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
40
41
  });
41
42
 
42
43
  /* MODIFY COPIED EXTENSION FILES */
@@ -76,7 +77,7 @@ const addNotificationServiceExtension = async options => {
76
77
  const nseTarget = xcodeProject.addTarget(_ios.CIO_NOTIFICATION_TARGET_NAME, 'app_extension', _ios.CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
77
78
 
78
79
  // Add build phases to the new target
79
- xcodeProject.addBuildPhase(['CIONotificationService.m', 'CIONotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
80
+ xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
80
81
  xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
81
82
  xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
82
83
 
@@ -86,7 +87,7 @@ const addNotificationServiceExtension = async options => {
86
87
  if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${_ios.CIO_NOTIFICATION_TARGET_NAME}"`) {
87
88
  const buildSettingsObj = configurations[key].buildSettings;
88
89
  buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
89
- buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget ?? '13.0';
90
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
90
91
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
91
92
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
92
93
  buildSettingsObj.SWIFT_VERSION = 4.2;
@@ -96,7 +97,7 @@ const addNotificationServiceExtension = async options => {
96
97
  // Add development team to the target & the main
97
98
  xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
98
99
  xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
99
- _fs.default.writeFileSync(projPath, xcodeProject.writeSync());
100
+ _fileManagement.FileManagement.writeFile(projPath, xcodeProject.writeSync());
100
101
  });
101
102
  };
102
103
  const withCioNotificationsXcodeProject = (configOuter, props) => {
@@ -110,7 +111,7 @@ const withCioNotificationsXcodeProject = (configOuter, props) => {
110
111
  appleTeamId,
111
112
  iosDeploymentTarget
112
113
  } = props;
113
- if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
114
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.');
114
115
  const {
115
116
  projectName,
116
117
  platformProjectRoot
@@ -120,19 +121,19 @@ const withCioNotificationsXcodeProject = (configOuter, props) => {
120
121
  buildNumber
121
122
  } = ios;
122
123
  if (bundleShortVersion === undefined) {
123
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
124
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js or app.json');
124
125
  }
125
126
  if (bundleIdentifier === undefined) {
126
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
127
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json');
127
128
  }
128
129
  if (projectName === undefined) {
129
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
130
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js or app.json');
130
131
  }
131
132
  const options = {
132
133
  appleTeamId,
133
134
  bundleIdentifier,
134
135
  bundleShortVersion,
135
- bundleVersion: buildNumber ?? _ios.DEFAULT_BUNDLE_VERSION,
136
+ bundleVersion: buildNumber || _ios.DEFAULT_BUNDLE_VERSION,
136
137
  iosPath: platformProjectRoot,
137
138
  appName: projectName,
138
139
  iosDeploymentTarget
@@ -145,13 +146,13 @@ exports.withCioNotificationsXcodeProject = withCioNotificationsXcodeProject;
145
146
  const updateNseInfoPlist = payload => {
146
147
  const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
147
148
  const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
148
- let plistFileString = _fs.default.readFileSync(payload.infoPlistTargetFile, 'utf-8');
149
+ let plistFileString = _fileManagement.FileManagement.readFile(payload.infoPlistTargetFile);
149
150
  if (payload.bundleVersion) {
150
- plistFileString = plistFileString.replace(BUNDLE_VERSION_RE, payload.bundleVersion);
151
+ plistFileString = (0, _codeInjection.injectCodeByMultiLineRegex)(plistFileString, BUNDLE_VERSION_RE, payload.bundleVersion);
151
152
  }
152
153
  if (payload.bundleShortVersion) {
153
- plistFileString = plistFileString.replace(BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
154
+ plistFileString = (0, _codeInjection.injectCodeByMultiLineRegex)(plistFileString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
154
155
  }
155
- _fs.default.writeFileSync(payload.infoPlistTargetFile, plistFileString);
156
+ _fileManagement.FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
156
157
  };
157
158
  //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","xcode","project","parse","err","Error","JSON","stringify","injectCIONotificationPodfileCode","fs","mkdirSync","recursive","files","getTargetFile","filename","forEach","targetFile","copyFileSync","LOCAL_PATH_TO_CIO_NSE_FILES","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","withXcodeProject","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","DEFAULT_BUNDLE_VERSION","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;AACA;AACA;AAEA;AAKA;AAAyF;AAGzF,MAAMA,cAAc,GAAI,GAAEC,iCAA6B,aAAY;AAEnE,MAAMC,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,MACtCC,OAAmC,IAChC;EACH,MAAM;IACJC,WAAW;IACXC,gBAAgB;IAChBC,kBAAkB;IAClBC,aAAa;IACbC,OAAO;IACPC,OAAO;IACPC;EACF,CAAC,GAAGP,OAAO;EAEX,MAAMQ,QAAQ,GAAI,GAAEH,OAAQ,IAAGC,OAAQ,4BAA2B;EAElE,MAAMG,YAAY,GAAGC,cAAK,CAACC,OAAO,CAACH,QAAQ,CAAC;EAE5CC,YAAY,CAACG,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAC7C,IAAIA,GAAG,EAAE;MACP,MAAM,IAAIC,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAE,EAAC,CAAC;IACtE;IAEA,MAAM,IAAAI,sDAAgC,EAACZ,OAAO,CAAC;IAE/Ca,WAAE,CAACC,SAAS,CAAE,GAAEd,OAAQ,IAAGR,iCAA6B,EAAC,EAAE;MACzDuB,SAAS,EAAE;IACb,CAAC,CAAC;IAEF,MAAMC,KAAK,GAAG,CACZzB,cAAc,EACd,0BAA0B,EAC1B,8BAA8B,EAC9B,0BAA0B,CAC3B;IAED,MAAM0B,aAAa,GAAIC,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,MAAMC,iBAAiB,GAAG,wBAAwB;EAElD,IAAIC,eAAe,GAAG1D,WAAE,CAAC2D,YAAY,CAACJ,OAAO,CAAC7C,mBAAmB,EAAE,OAAO,CAAC;EAE3E,IAAI6C,OAAO,CAACrE,aAAa,EAAE;IACzBwE,eAAe,GAAGA,eAAe,CAACE,OAAO,CACvCH,iBAAiB,EACjBF,OAAO,CAACrE,aAAa,CACtB;EACH;EAEA,IAAIqE,OAAO,CAACtE,kBAAkB,EAAE;IAC9ByE,eAAe,GAAGA,eAAe,CAACE,OAAO,CACvCJ,uBAAuB,EACvBD,OAAO,CAACtE,kBAAkB,CAC3B;EACH;EAEAe,WAAE,CAACyC,aAAa,CAACc,OAAO,CAAC7C,mBAAmB,EAAEgD,eAAe,CAAC;AAChE,CAAC"}
1
+ {"version":3,"names":["PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","xcode","project","parse","err","Error","JSON","stringify","injectCIONotificationPodfileCode","FileManagement","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","LOCAL_PATH_TO_CIO_NSE_FILES","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","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","DEFAULT_BUNDLE_VERSION","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","injectCodeByMultiLineRegex"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\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 { injectCodeByMultiLineRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\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 FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.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 FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\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 ['NotificationService.m', 'NotificationService.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 FileManagement.writeFile(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 or app.json.'\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 or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\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 = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAKA;AACA;AAEA;AAAmE;AAEnE,MAAMA,cAAc,GAAI,GAAEC,iCAA6B,aAAY;AAEnE,MAAMC,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,MACtCC,OAAmC,IAChC;EACH,MAAM;IACJC,WAAW;IACXC,gBAAgB;IAChBC,kBAAkB;IAClBC,aAAa;IACbC,OAAO;IACPC,OAAO;IACPC;EACF,CAAC,GAAGP,OAAO;EAEX,MAAMQ,QAAQ,GAAI,GAAEH,OAAQ,IAAGC,OAAQ,4BAA2B;EAElE,MAAMG,YAAY,GAAGC,cAAK,CAACC,OAAO,CAACH,QAAQ,CAAC;EAE5CC,YAAY,CAACG,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAC7C,IAAIA,GAAG,EAAE;MACP,MAAM,IAAIC,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAE,EAAC,CAAC;IACtE;IAEA,MAAM,IAAAI,sDAAgC,EAACZ,OAAO,CAAC;IAE/Ca,8BAAc,CAACC,KAAK,CAAE,GAAEd,OA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AAC;IAED,MAAMR,+BAA+B,CAACC,OAAO,CAAC;IAE9C,OAAOiE,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAAC;AAEF,MAAMpC,kBAAkB,GAAI4C,OAI3B,IAAK;EACJ,MAAMC,uBAAuB,GAAG,8BAA8B;EAC9D,MAAMC,iBAAiB,GAAG,wBAAwB;EAElD,IAAIC,eAAe,GAAG1D,8BAAc,CAAC2D,QAAQ,CAACJ,OAAO,CAAC7C,mBAAmB,CAAC;EAE1E,IAAI6C,OAAO,CAACrE,aAAa,EAAE;IACzBwE,eAAe,GAAG,IAAAE,yCAA0B,EAC1CF,eAAe,EACfD,iBAAiB,EACjBF,OAAO,CAACrE,aAAa,CACtB;EACH;EAEA,IAAIqE,OAAO,CAACtE,kBAAkB,EAAE;IAC9ByE,eAAe,GAAG,IAAAE,yCAA0B,EAC1CF,eAAe,EACfF,uBAAuB,EACvBD,OAAO,CAACtE,kBAAkB,CAC3B;EACH;EAEAe,8BAAc,CAACyC,SAAS,CAACc,OAAO,CAAC7C,mBAAmB,EAAEgD,eAAe,CAAC;AACxE,CAAC"}
@@ -1,15 +1,2 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Mode = void 0;
7
- // properties set by the user in their app config file (e.g: app.json or app.plugin.js)
8
- // Plugin options for pre-build
9
- let Mode;
10
- exports.Mode = Mode;
11
- (function (Mode) {
12
- Mode["Dev"] = "development";
13
- Mode["Prod"] = "production";
14
- })(Mode || (exports.Mode = Mode = {}));
15
2
  //# sourceMappingURL=cio-types.js.map
@@ -1 +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;AAAA,IAiBYA,IAAI;AAAA;AAAA,WAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;AAAA,GAAJA,IAAI,oBAAJA,IAAI"}
1
+ {"version":3,"names":[],"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 pushNotification?: {\n useRichPush: boolean;\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFilePath?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LIB_VERSION = void 0;
7
+ const LIB_VERSION = "1.0.0-alpha.3";
8
+ exports.LIB_VERSION = LIB_VERSION;
9
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LIB_VERSION"],"sources":["version.ts"],"sourcesContent":["export const LIB_VERSION = \"1.0.0-alpha.3\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,eAAe;AAAC"}
@@ -0,0 +1,24 @@
1
+ import { LIB_VERSION } from './../version';
2
+ import { withXcodeProject } from '@expo/config-plugins';
3
+ import { FileManagement } from '../helpers/utils/fileManagement';
4
+ export const withAnalytics = config => {
5
+ return withXcodeProject(config, async props => {
6
+ const expoVersionSnippet = `"expoVersion": "${LIB_VERSION}"`;
7
+ let versionRegEx = new RegExp(expoVersionSnippet);
8
+ const filename = `node_modules/customerio-reactnative/package.json`;
9
+ if (FileManagement.exists(filename)) {
10
+ const pJsonFile = await FileManagement.read(filename);
11
+ const lines = pJsonFile.split('\n');
12
+ const missingMmatch = pJsonFile.match(versionRegEx);
13
+ const expoVersionRegex = /"expoVersion": ".*"/;
14
+ const existatch = pJsonFile.match(expoVersionRegex);
15
+ if (existatch && !missingMmatch) {
16
+ const index = lines.findIndex(line => expoVersionRegex.test(line));
17
+ const content = [...lines.slice(0, index), ` ${expoVersionSnippet},`, ...lines.slice(index + 1)];
18
+ FileManagement.write(filename, content.join('\n'));
19
+ }
20
+ }
21
+ return props;
22
+ });
23
+ };
24
+ //# sourceMappingURL=injectAnalytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LIB_VERSION","withXcodeProject","FileManagement","withAnalytics","config","props","expoVersionSnippet","versionRegEx","RegExp","filename","exists","pJsonFile","read","lines","split","missingMmatch","match","expoVersionRegex","existatch","index","findIndex","line","test","content","slice","write","join"],"sources":["injectAnalytics.ts"],"sourcesContent":["import { LIB_VERSION } from './../version';\nimport { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptions } from '../types/cio-types';\n\n\nexport const withAnalytics: ConfigPlugin<CustomerIOPluginOptions> = (config) => {\n return withXcodeProject(config, async (props) => {\n const expoVersionSnippet = `\"expoVersion\": \"${LIB_VERSION}\"`;\n let versionRegEx = new RegExp(expoVersionSnippet);\n const filename = `node_modules/customerio-reactnative/package.json`;\n if (FileManagement.exists(filename)) {\n const pJsonFile = await FileManagement.read(filename);\n const lines = pJsonFile.split('\\n');\n const missingMmatch = pJsonFile.match(versionRegEx);\n const expoVersionRegex = /\"expoVersion\": \".*\"/;\n const existatch = pJsonFile.match(expoVersionRegex);\n\n if (existatch && !missingMmatch) {\n const index = lines.findIndex((line) =>\n expoVersionRegex.test(line)\n );\n\n const content = [\n ...lines.slice(0, index),\n ` ${expoVersionSnippet},`,\n ...lines.slice(index + 1),\n ];\n\n FileManagement.write(filename, content.join('\\n'));\n }\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,cAAc;AAC1C,SAAuBC,gBAAgB,QAAQ,sBAAsB;AACrE,SAASC,cAAc,QAAQ,iCAAiC;AAIhE,OAAO,MAAMC,aAAoD,GAAIC,MAAM,IAAK;EAC9E,OAAOH,gBAAgB,CAACG,MAAM,EAAE,MAAOC,KAAK,IAAK;IAC/C,MAAMC,kBAAkB,GAAI,mBAAkBN,WAAY,GAAE;IAC5D,IAAIO,YAAY,GAAG,IAAIC,MAAM,CAACF,kBAAkB,CAAC;IACjD,MAAMG,QAAQ,GAAI,kDAAiD;IACnE,IAAIP,cAAc,CAACQ,MAAM,CAACD,QAAQ,CAAC,EAAE;MACnC,MAAME,SAAS,GAAG,MAAMT,cAAc,CAACU,IAAI,CAACH,QAAQ,CAAC;MACrD,MAAMI,KAAK,GAAGF,SAAS,CAACG,KAAK,CAAC,IAAI,CAAC;MACnC,MAAMC,aAAa,GAAGJ,SAAS,CAACK,KAAK,CAACT,YAAY,CAAC;MACnD,MAAMU,gBAAgB,GAAG,qBAAqB;MAC9C,MAAMC,SAAS,GAAGP,SAAS,CAACK,KAAK,CAACC,gBAAgB,CAAC;MAEnD,IAAIC,SAAS,IAAI,CAACH,aAAa,EAAE;QAC/B,MAAMI,KAAK,GAAGN,KAAK,CAACO,SAAS,CAAEC,IAAI,IACjCJ,gBAAgB,CAACK,IAAI,CAACD,IAAI,CAAC,CAC5B;QAED,MAAME,OAAO,GAAG,CACd,GAAGV,KAAK,CAACW,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EACvB,KAAIb,kBAAmB,GAAE,EAC1B,GAAGO,KAAK,CAACW,KAAK,CAACL,KAAK,GAAG,CAAC,CAAC,CAC1B;QAEDjB,cAAc,CAACuB,KAAK,CAAChB,QAAQ,EAAEc,OAAO,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;MACpD;IACF;IAEA,OAAOrB,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -2,7 +2,13 @@ import { withAppBuildGradle } from '@expo/config-plugins';
2
2
  import { CIO_APP_APPLY_REGEX, CIO_APP_GOOGLE_SNIPPET } from '../helpers/constants/android';
3
3
  export const withAppGoogleServices = configOuter => {
4
4
  return withAppBuildGradle(configOuter, props => {
5
- props.modResults.contents = props.modResults.contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
5
+ const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
6
+ const match = props.modResults.contents.match(regex);
7
+ if (!match) {
8
+ props.modResults.contents = props.modResults.contents.replace(CIO_APP_APPLY_REGEX, `$1\n${CIO_APP_GOOGLE_SNIPPET}`);
9
+ } else {
10
+ console.log('app/build.gradle snippet already exists. Skipping...');
11
+ }
6
12
  return props;
7
13
  });
8
14
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","withAppGoogleServices","configOuter","props","modResults","contents","replace"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, 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';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,kBAAkB,QAAQ,sBAAsB;AAEvE,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAGrC,OAAO,MAAMC,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,kBAAkB,CAACI,WAAW,EAAGC,KAAK,IAAK;IAChDA,KAAK,CAACC,UAAU,CAACC,QAAQ,GAAGF,KAAK,CAACC,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DP,mBAAmB,EAClB,OAAMC,sBAAuB,EAAC,CAChC;IACD,OAAOG,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"names":["withAppBuildGradle","CIO_APP_APPLY_REGEX","CIO_APP_GOOGLE_SNIPPET","withAppGoogleServices","configOuter","props","regex","RegExp","match","modResults","contents","replace","console","log"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, 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';\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 console.log('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,kBAAkB,QAAQ,sBAAsB;AAEvE,SACEC,mBAAmB,EACnBC,sBAAsB,QACjB,8BAA8B;AAGrC,OAAO,MAAMC,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,kBAAkB,CAACI,WAAW,EAAGC,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACL,sBAAsB,CAAC;IAChD,MAAMM,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,CAC3DV,mBAAmB,EAClB,OAAMC,sBAAuB,EAAC,CAChC;IACH,CAAC,MAAM;MACLU,OAAO,CAACC,GAAG,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOR,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -1,8 +1,13 @@
1
1
  import { withProjectBuildGradle } from '@expo/config-plugins';
2
- import { CIO_PROJECT_ALLPROJECTS_REGEX, CIO_PROJECT_GIST_MAVEN_SNIPPET } from '../helpers/constants/android';
2
+ import { CIO_GIST_MAVEN_REGEX, CIO_PROJECT_ALLPROJECTS_REGEX, CIO_PROJECT_GIST_MAVEN_SNIPPET } from '../helpers/constants/android';
3
3
  export const withGistMavenRepository = configOuter => {
4
4
  return withProjectBuildGradle(configOuter, props => {
5
- props.modResults.contents = props.modResults.contents.replace(CIO_PROJECT_ALLPROJECTS_REGEX, `$1\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`);
5
+ const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);
6
+ if (!targetMatch) {
7
+ props.modResults.contents = props.modResults.contents.replace(CIO_PROJECT_ALLPROJECTS_REGEX, `$1\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`);
8
+ } else {
9
+ console.log('build.gradle snippet alreade exists. Skipping...');
10
+ }
6
11
  return props;
7
12
  });
8
13
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","withGistMavenRepository","configOuter","props","modResults","contents","replace"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_ALLPROJECTS_REGEX,\n `$1\\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`\n );\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAsB,sBAAsB;AAE3E,SACEC,6BAA6B,EAC7BC,8BAA8B,QACzB,8BAA8B;AAGrC,OAAO,MAAMC,uBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,sBAAsB,CAACI,WAAW,EAAGC,KAAK,IAAK;IACpDA,KAAK,CAACC,UAAU,CAACC,QAAQ,GAAGF,KAAK,CAACC,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DP,6BAA6B,EAC5B,OAAMC,8BAA+B,EAAC,CACxC;IACD,OAAOG,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"names":["withProjectBuildGradle","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","withGistMavenRepository","configOuter","props","targetMatch","modResults","contents","match","replace","console","log"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport {\n CIO_GIST_MAVEN_REGEX,\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);\n if (!targetMatch) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_ALLPROJECTS_REGEX,\n `$1\\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`\n );\n } else {\n console.log('build.gradle snippet alreade exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAsB,sBAAsB;AAE3E,SACEC,oBAAoB,EACpBC,6BAA6B,EAC7BC,8BAA8B,QACzB,8BAA8B;AAGrC,OAAO,MAAMC,uBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOL,sBAAsB,CAACK,WAAW,EAAGC,KAAK,IAAK;IACpD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACT,oBAAoB,CAAC;IACzE,IAAI,CAACM,WAAW,EAAE;MAChBD,KAAK,CAACE,UAAU,CAACC,QAAQ,GAAGH,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACE,OAAO,CAC3DT,6BAA6B,EAC5B,OAAMC,8BAA+B,EAAC,CACxC;IACH,CAAC,MAAM;MACLS,OAAO,CAACC,GAAG,CAAC,kDAAkD,CAAC;IACjE;IAEA,OAAOP,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { withProjectBuildGradle } from '@expo/config-plugins';
2
- import { copyFileSync } from 'fs';
2
+ import { FileManagement } from './../helpers/utils/fileManagement';
3
3
  export const withGoogleServicesJSON = (configOuter, cioProps) => {
4
4
  return withProjectBuildGradle(configOuter, props => {
5
5
  const options = {
@@ -10,12 +10,16 @@ export const withGoogleServicesJSON = (configOuter, cioProps) => {
10
10
  androidPath,
11
11
  googleServicesFilePath
12
12
  } = options;
13
- if (googleServicesFilePath) {
14
- try {
15
- copyFileSync(`${googleServicesFilePath}google-services.json`, `${androidPath}/app/google-services.json`);
16
- } catch (e) {
17
- console.log('There was an error copying your google-services.json file.');
13
+ if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {
14
+ if (googleServicesFilePath) {
15
+ try {
16
+ FileManagement.copyFile(`${googleServicesFilePath}google-services.json`, `${androidPath}/app/google-services.json`);
17
+ } catch (e) {
18
+ console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/`);
19
+ }
18
20
  }
21
+ } else {
22
+ console.log(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
19
23
  }
20
24
  return props;
21
25
  });
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","copyFileSync","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFilePath","e","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\nimport { copyFileSync } from 'fs';\n\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 googleServicesFilePath: cioProps?.googleServicesFilePath,\n };\n const { androidPath, googleServicesFilePath } = options;\n if (googleServicesFilePath) {\n try {\n copyFileSync(\n `${googleServicesFilePath}google-services.json`,\n `${androidPath}/app/google-services.json`\n );\n } catch (e) {\n console.log(\n 'There was an error copying your google-services.json file.'\n );\n }\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAsB,sBAAsB;AAC3E,SAASC,YAAY,QAAQ,IAAI;AAIjC,OAAO,MAAMC,sBAEZ,GAAG,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOJ,sBAAsB,CAACG,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,sBAAsB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IACpC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAuB,CAAC,GAAGJ,OAAO;IACvD,IAAII,sBAAsB,EAAE;MAC1B,IAAI;QACFT,YAAY,CACT,GAAES,sBAAuB,sBAAqB,EAC9C,GAAEH,WAAY,2BAA0B,CAC1C;MACH,CAAC,CAAC,OAAOI,CAAC,EAAE;QACVC,OAAO,CAACC,GAAG,CACT,4DAA4D,CAC7D;MACH;IACF;IAEA,OAAOR,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFilePath","exists","copyFile","e","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\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 googleServicesFilePath: cioProps?.googleServicesFilePath,\n };\n const { androidPath, googleServicesFilePath } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFilePath) {\n try {\n FileManagement.copyFile(\n `${googleServicesFilePath}google-services.json`,\n `${androidPath}/app/google-services.json`\n );\n } catch (e) {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/`\n );\n }\n }\n } else {\n console.log(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAsB,sBAAsB;AAE3E,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAG,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOJ,sBAAsB,CAACG,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,sBAAsB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IACpC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAuB,CAAC,GAAGJ,OAAO;IACvD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAE,GAAEJ,WAAY,2BAA0B,CAAC,EAAE;MACrE,IAAIG,sBAAsB,EAAE;QAC1B,IAAI;UACFT,cAAc,CAACW,QAAQ,CACpB,GAAEF,sBAAuB,sBAAqB,EAC9C,GAAEH,WAAY,2BAA0B,CAC1C;QACH,CAAC,CAAC,OAAOM,CAAC,EAAE;UACVC,OAAO,CAACC,GAAG,CACR,4FAA2FR,WAAY,OAAM,CAC/G;QACH;MACF;IACF,CAAC,MAAM;MACLO,OAAO,CAACC,GAAG,CACR,wBAAuBR,WAAY,wCAAuC,CAC5E;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -2,7 +2,11 @@ import { withProjectBuildGradle } from '@expo/config-plugins';
2
2
  import { CIO_PROJECT_BUILDSCRIPTS_REGEX, CIO_PROJECT_GOOGLE_SNIPPET } from './../helpers/constants/android';
3
3
  export const withProjectGoogleServices = configOuter => {
4
4
  return withProjectBuildGradle(configOuter, props => {
5
- props.modResults.contents = props.modResults.contents.replace(CIO_PROJECT_BUILDSCRIPTS_REGEX, `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`);
5
+ const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);
6
+ const match = props.modResults.contents.match(regex);
7
+ if (!match) {
8
+ props.modResults.contents = props.modResults.contents.replace(CIO_PROJECT_BUILDSCRIPTS_REGEX, `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`);
9
+ }
6
10
  return props;
7
11
  });
8
12
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_PROJECT_GOOGLE_SNIPPET","withProjectGoogleServices","configOuter","props","modResults","contents","replace"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,sBAAsB,QAAQ,sBAAsB;AAE3E,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,gCAAgC;AAGvC,OAAO,MAAMC,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,sBAAsB,CAACI,WAAW,EAAGC,KAAK,IAAK;IACpDA,KAAK,CAACC,UAAU,CAACC,QAAQ,GAAGF,KAAK,CAACC,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DP,8BAA8B,EAC7B,OAAMC,0BAA2B,EAAC,CACpC;IACD,OAAOG,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"names":["withProjectBuildGradle","CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_PROJECT_GOOGLE_SNIPPET","withProjectGoogleServices","configOuter","props","regex","RegExp","match","modResults","contents","replace"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,sBAAsB,QAAQ,sBAAsB;AAE3E,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,gCAAgC;AAGvC,OAAO,MAAMC,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOJ,sBAAsB,CAACI,WAAW,EAAGC,KAAK,IAAK;IACpD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACL,0BAA0B,CAAC;IACpD,MAAMM,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,CAC3DV,8BAA8B,EAC7B,OAAMC,0BAA2B,EAAC,CACpC;IACH;IAEA,OAAOG,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export const CIO_PROJECT_BUILDSCRIPTS_REGEX = /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
2
2
  export const CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
3
- export const CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n)*repositories\s*\{)/;
3
+ export const CIO_GIST_MAVEN_REGEX = /maven { url "https:\/\/maven.gist.build" }/;
4
+ export const CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n){1,500}repositories\s*\{)/;
4
5
  export const CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
5
6
  export const CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
6
7
  export const CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';