customerio-expo-plugin 1.0.0-alpha.4 → 1.0.0-alpha.6
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.
- package/README.md +10 -8
- package/lib/commonjs/android/withGoogleServicesJSON.js +7 -5
- package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/commonjs/helpers/constants/ios.js +5 -52
- package/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/lib/commonjs/helpers/native-files/ios/Env.swift +8 -0
- package/lib/commonjs/helpers/native-files/ios/NotificationService.swift +4 -1
- package/lib/commonjs/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
- package/lib/commonjs/helpers/utils/codeInjection.js +4 -0
- package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +1 -3
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/commonjs/index.js +0 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ios/withCIOIos.js +2 -7
- package/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +147 -76
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/commonjs/postInstall.js +7 -0
- package/lib/commonjs/postInstall.js.map +1 -0
- package/lib/commonjs/postInstallHelper.js +20 -0
- package/lib/commonjs/postInstallHelper.js.map +1 -0
- package/lib/commonjs/types/cio-types.js.map +1 -1
- package/lib/module/android/withGoogleServicesJSON.js +7 -5
- package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/module/helpers/constants/ios.js +3 -47
- package/lib/module/helpers/constants/ios.js.map +1 -1
- package/lib/module/helpers/native-files/ios/Env.swift +8 -0
- package/lib/module/helpers/native-files/ios/NotificationService.swift +4 -1
- package/lib/module/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
- package/lib/module/helpers/utils/codeInjection.js +3 -0
- package/lib/module/helpers/utils/codeInjection.js.map +1 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -4
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ios/withCIOIos.js +2 -7
- package/lib/module/ios/withCIOIos.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +148 -77
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/module/postInstall.js +5 -0
- package/lib/module/postInstall.js.map +1 -0
- package/lib/module/postInstallHelper.js +18 -0
- package/lib/module/postInstallHelper.js.map +1 -0
- package/lib/module/types/cio-types.js.map +1 -1
- package/lib/typescript/helpers/constants/ios.d.ts +2 -5
- package/lib/typescript/helpers/utils/codeInjection.d.ts +1 -0
- package/lib/typescript/types/cio-types.d.ts +6 -1
- package/package.json +9 -5
- package/src/android/withGoogleServicesJSON.ts +9 -5
- package/src/helpers/constants/ios.ts +3 -46
- package/src/helpers/native-files/ios/Env.swift +8 -0
- package/src/helpers/native-files/ios/NotificationService.swift +4 -1
- package/src/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
- package/src/helpers/utils/codeInjection.ts +8 -0
- package/src/helpers/utils/injectCIOPodfileCode.ts +2 -10
- package/src/index.ts +0 -3
- package/src/ios/withCIOIos.ts +2 -8
- package/src/ios/withNotificationsXcodeProject.ts +221 -127
- package/src/postInstall.js +5 -0
- package/src/postInstallHelper.js +22 -0
- package/src/types/cio-types.ts +6 -1
- package/lib/commonjs/analytics/injectAnalytics.js +0 -31
- package/lib/commonjs/analytics/injectAnalytics.js.map +0 -1
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js +0 -79
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +0 -1
- package/lib/commonjs/version.js +0 -9
- package/lib/commonjs/version.js.map +0 -1
- package/lib/module/analytics/injectAnalytics.js +0 -24
- package/lib/module/analytics/injectAnalytics.js.map +0 -1
- package/lib/module/ios/withAppDelegateXcodeProject.js +0 -71
- package/lib/module/ios/withAppDelegateXcodeProject.js.map +0 -1
- package/lib/module/version.js +0 -2
- package/lib/module/version.js.map +0 -1
- package/lib/typescript/analytics/injectAnalytics.d.ts +0 -3
- package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +0 -3
- package/lib/typescript/version.d.ts +0 -1
- package/src/analytics/injectAnalytics.ts +0 -36
- package/src/ios/withAppDelegateXcodeProject.ts +0 -89
- package/src/version.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":"AAAA,OAAO,SAASA,iBAAiB,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEA,OAAO,SAASE,0BAA0B,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEA,OAAO,SAASW,wCAAwC,
|
|
1
|
+
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","replaceCodeByRegex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":"AAAA,OAAO,SAASA,iBAAiB,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEA,OAAO,SAASE,0BAA0B,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEA,OAAO,SAASW,kBAAkB,CAChCb,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAEC,OAAO,CAAC;AAChD;AAEA,OAAO,SAASY,wCAAwC,CACtDd,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,EAAC,CAAC;AACrD;AAEA,OAAO,SAASa,sBAAsB,CACpCf,WAAmB,EACnBK,KAAa,EACbH,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,IAAIK,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET,
|
|
1
|
+
import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET, CIO_PODFILE_NOTIFICATION_SNIPPET, CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET, CIO_PODFILE_NOTIFICATION_REGEX, CIO_CIO_TARGET_REGEX, CIO_PODFILE_POST_INSTALL_REGEX } from '../constants/ios';
|
|
2
2
|
import { FileManagement } from './fileManagement';
|
|
3
3
|
export async function injectCIOPodfileCode(iosPath) {
|
|
4
4
|
const filename = `${iosPath}/Podfile`;
|
|
@@ -10,9 +10,7 @@ export async function injectCIOPodfileCode(iosPath) {
|
|
|
10
10
|
const index = lines.findIndex(line => CIO_PODFILE_POST_INSTALL_REGEX.test(line));
|
|
11
11
|
let content = lines;
|
|
12
12
|
if (index > -1) {
|
|
13
|
-
content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '',
|
|
14
|
-
} else {
|
|
15
|
-
content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
|
|
13
|
+
content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '', ...lines.slice(index - 1)];
|
|
16
14
|
}
|
|
17
15
|
FileManagement.write(filename, content.join('\n'));
|
|
18
16
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CIO_PODFILE_REGEX","CIO_PODFILE_SNIPPET","
|
|
1
|
+
{"version":3,"names":["CIO_PODFILE_REGEX","CIO_PODFILE_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET","CIO_PODFILE_NOTIFICATION_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","FileManagement","injectCIOPodfileCode","iosPath","filename","podfile","read","matches","match","targetMatch","lines","split","index","findIndex","line","test","content","slice","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","snippet","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n CIO_PODFILE_POST_INSTALL_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n ...lines.slice(index - 1),\n ];\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n const snippet =\n useFrameworks === 'static'\n ? CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET\n : CIO_PODFILE_NOTIFICATION_SNIPPET;\n FileManagement.append(filename, snippet);\n }\n}\n"],"mappings":"AACA,SACEA,iBAAiB,EACjBC,mBAAmB,EACnBC,gCAAgC,EAChCC,iDAAiD,EACjDC,8BAA8B,EAC9BC,oBAAoB,EACpBC,8BAA8B,QACzB,kBAAkB;AACzB,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoB,CAACC,OAAe,EAAE;EAC1D,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACd,iBAAiB,CAAC;EAChD,MAAMe,WAAW,GAAGJ,OAAO,CAACG,KAAK,CAACT,oBAAoB,CAAC;EAEvD,IAAI,CAACU,WAAW,EAAE;IAChB,MAAMC,KAAK,GAAGL,OAAO,CAACM,KAAK,CAAC,IAAI,CAAC;IACjC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IACjCd,8BAA8B,CAACe,IAAI,CAACD,IAAI,CAAC,CAC1C;IACD,IAAIE,OAAiB,GAAGN,KAAK;IAC7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;MACdI,OAAO,GAAG,CACR,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,GAAG,CAAC,CAAC,EAC5B,CAACL,OAAO,GAAGZ,mBAAmB,GAAG,EAAE,EACnC,GAAGe,KAAK,CAACO,KAAK,CAACL,KAAK,GAAG,CAAC,CAAC,CAC1B;IACH;IAEAX,cAAc,CAACiB,KAAK,CAACd,QAAQ,EAAEY,OAAO,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;EACpD,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgC,CACpDnB,OAAe,EACfoB,aAA0D,EAC1D;EACA,MAAMnB,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACV,8BAA8B,CAAC;EAE7D,IAAI,CAACS,OAAO,EAAE;IACZ,MAAMiB,OAAO,GACXD,aAAa,KAAK,QAAQ,GACtB1B,iDAAiD,GACjDD,gCAAgC;IACtCK,cAAc,CAACwB,MAAM,CAACrB,QAAQ,EAAEoB,OAAO,CAAC;EAC1C;AACF"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { withAnalytics } from './analytics/injectAnalytics';
|
|
2
1
|
import { withCIOAndroid } from './android/withCIOAndroid';
|
|
3
2
|
import { withCIOIos } from './ios/withCIOIos';
|
|
4
3
|
// Entry point for config plugin
|
|
@@ -9,7 +8,6 @@ function withCustomerIOPlugin(config, props) {
|
|
|
9
8
|
if (props.android) {
|
|
10
9
|
config = withCIOAndroid(config, props.android);
|
|
11
10
|
}
|
|
12
|
-
config = withAnalytics(config, props);
|
|
13
11
|
return config;
|
|
14
12
|
}
|
|
15
13
|
export default withCustomerIOPlugin;
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;AAG7C;AACA,SAASC,oBAAoB,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACE,OAAO,EAAE;IACjBH,MAAM,GAAGH,cAAc,CAACG,MAAM,EAAEC,KAAK,CAACE,OAAO,CAAC;EAChD;EAEA,OAAOH,MAAM;AACf;AAEA,eAAeD,oBAAoB"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { withAppDelegateModifications } from './withAppDelegateModifications';
|
|
2
|
-
import { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';
|
|
3
2
|
import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
|
|
4
3
|
import { withCioXcodeProject } from './withXcodeProject';
|
|
5
4
|
export function withCIOIos(config, props) {
|
|
6
|
-
var _props$pushNotificati;
|
|
7
|
-
if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.useRichPush) {
|
|
8
|
-
config = withCioNotificationsXcodeProject(config, props);
|
|
9
|
-
}
|
|
10
5
|
if (props.pushNotification) {
|
|
11
6
|
config = withAppDelegateModifications(config, props);
|
|
12
|
-
config =
|
|
7
|
+
config = withCioNotificationsXcodeProject(config, props);
|
|
8
|
+
config = withCioXcodeProject(config, props);
|
|
13
9
|
}
|
|
14
|
-
config = withCioXcodeProject(config, props);
|
|
15
10
|
return config;
|
|
16
11
|
}
|
|
17
12
|
//# sourceMappingURL=withCIOIos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppDelegateModifications","
|
|
1
|
+
{"version":3,"names":["withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGJ,4BAA4B,CAACI,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;IACxDD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC7C;EAEA,OAAOD,MAAM;AACf"}
|
|
@@ -1,96 +1,32 @@
|
|
|
1
1
|
import { withXcodeProject } from '@expo/config-plugins';
|
|
2
2
|
import xcode from 'xcode';
|
|
3
3
|
import { CIO_NOTIFICATION_TARGET_NAME, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
|
|
4
|
-
import {
|
|
4
|
+
import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
5
5
|
import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
6
6
|
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
7
7
|
const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
8
|
+
const ENV_FILENAME = 'Env.swift';
|
|
8
9
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
9
10
|
const addNotificationServiceExtension = async options => {
|
|
11
|
+
// iosPath and appName are predefined from Expo config.
|
|
12
|
+
// See function withCioNotificationsXcodeProject to get where the variabes are pulled from.
|
|
10
13
|
const {
|
|
11
|
-
appleTeamId,
|
|
12
|
-
bundleIdentifier,
|
|
13
|
-
bundleShortVersion,
|
|
14
|
-
bundleVersion,
|
|
15
14
|
iosPath,
|
|
16
|
-
|
|
17
|
-
appName,
|
|
18
|
-
iosDeploymentTarget
|
|
15
|
+
appName
|
|
19
16
|
} = options;
|
|
20
17
|
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
21
18
|
const xcodeProject = xcode.project(projPath);
|
|
22
19
|
xcodeProject.parse(async function (err) {
|
|
20
|
+
var _options$pushNotifica;
|
|
23
21
|
if (err) {
|
|
24
22
|
throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
recursive: true
|
|
29
|
-
});
|
|
30
|
-
const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m'];
|
|
31
|
-
const getTargetFile = filename => `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
|
|
32
|
-
files.forEach(filename => {
|
|
33
|
-
const targetFile = getTargetFile(filename);
|
|
34
|
-
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
/* MODIFY COPIED EXTENSION FILES */
|
|
38
|
-
const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
|
|
39
|
-
updateNseInfoPlist({
|
|
40
|
-
bundleVersion,
|
|
41
|
-
bundleShortVersion,
|
|
42
|
-
infoPlistTargetFile
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Create new PBXGroup for the extension
|
|
46
|
-
const extGroup = xcodeProject.addPbxGroup(files, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
|
|
47
|
-
|
|
48
|
-
// Add the new PBXGroup to the top level group. This makes the
|
|
49
|
-
// files / folder appear in the file explorer in Xcode.
|
|
50
|
-
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
51
|
-
Object.keys(groups).forEach(key => {
|
|
52
|
-
if (groups[key].name === undefined) {
|
|
53
|
-
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// WORK AROUND for codeProject.addTarget BUG
|
|
58
|
-
// Xcode projects don't contain these if there is only one target
|
|
59
|
-
// An upstream fix should be made to the code referenced in this link:
|
|
60
|
-
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
|
|
61
|
-
const projObjects = xcodeProject.hash.project.objects;
|
|
62
|
-
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
|
|
63
|
-
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
|
|
64
|
-
if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
|
|
65
|
-
console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
66
|
-
return;
|
|
24
|
+
if (options.pushNotification) {
|
|
25
|
+
await addPushNotificationFile(options, xcodeProject);
|
|
67
26
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// This also adds PBXTargetDependency and PBXContainerItemProxy
|
|
71
|
-
const nseTarget = xcodeProject.addTarget(CIO_NOTIFICATION_TARGET_NAME, 'app_extension', CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
|
|
72
|
-
|
|
73
|
-
// Add build phases to the new target
|
|
74
|
-
xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
|
|
75
|
-
xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
|
|
76
|
-
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
|
|
77
|
-
|
|
78
|
-
// Edit the Deployment info of the target
|
|
79
|
-
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
|
|
80
|
-
for (const key in configurations) {
|
|
81
|
-
if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
|
|
82
|
-
const buildSettingsObj = configurations[key].buildSettings;
|
|
83
|
-
buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
|
|
84
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
|
|
85
|
-
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
86
|
-
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
87
|
-
buildSettingsObj.SWIFT_VERSION = 4.2;
|
|
88
|
-
}
|
|
27
|
+
if ((_options$pushNotifica = options.pushNotification) !== null && _options$pushNotifica !== void 0 && _options$pushNotifica.useRichPush) {
|
|
28
|
+
await addRichPushXcodeProj(options, xcodeProject);
|
|
89
29
|
}
|
|
90
|
-
|
|
91
|
-
// Add development team to the target & the main
|
|
92
|
-
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
|
|
93
|
-
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
|
|
94
30
|
FileManagement.writeFile(projPath, xcodeProject.writeSync());
|
|
95
31
|
});
|
|
96
32
|
};
|
|
@@ -104,9 +40,12 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
104
40
|
const {
|
|
105
41
|
appleTeamId,
|
|
106
42
|
iosDeploymentTarget,
|
|
43
|
+
pushNotification,
|
|
107
44
|
useFrameworks
|
|
108
45
|
} = props;
|
|
109
46
|
if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.');
|
|
47
|
+
|
|
48
|
+
// projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()
|
|
110
49
|
const {
|
|
111
50
|
projectName,
|
|
112
51
|
platformProjectRoot
|
|
@@ -132,22 +71,154 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
132
71
|
iosPath: platformProjectRoot,
|
|
133
72
|
appName: projectName,
|
|
134
73
|
useFrameworks,
|
|
135
|
-
iosDeploymentTarget
|
|
74
|
+
iosDeploymentTarget,
|
|
75
|
+
pushNotification
|
|
136
76
|
};
|
|
137
77
|
await addNotificationServiceExtension(options);
|
|
138
78
|
return config;
|
|
139
79
|
});
|
|
140
80
|
};
|
|
81
|
+
const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
82
|
+
const {
|
|
83
|
+
appleTeamId,
|
|
84
|
+
bundleIdentifier,
|
|
85
|
+
bundleShortVersion,
|
|
86
|
+
bundleVersion,
|
|
87
|
+
iosPath,
|
|
88
|
+
iosDeploymentTarget,
|
|
89
|
+
useFrameworks
|
|
90
|
+
} = options;
|
|
91
|
+
await injectCIONotificationPodfileCode(iosPath, useFrameworks);
|
|
92
|
+
const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;
|
|
93
|
+
FileManagement.mkdir(nsePath, {
|
|
94
|
+
recursive: true
|
|
95
|
+
});
|
|
96
|
+
const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m', ENV_FILENAME];
|
|
97
|
+
const getTargetFile = filename => `${nsePath}/${filename}`;
|
|
98
|
+
files.forEach(filename => {
|
|
99
|
+
const targetFile = getTargetFile(filename);
|
|
100
|
+
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/* MODIFY COPIED EXTENSION FILES */
|
|
104
|
+
const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
|
|
105
|
+
updateNseInfoPlist({
|
|
106
|
+
bundleVersion,
|
|
107
|
+
bundleShortVersion,
|
|
108
|
+
infoPlistTargetFile
|
|
109
|
+
});
|
|
110
|
+
updateNseEnv(options, getTargetFile(ENV_FILENAME));
|
|
111
|
+
|
|
112
|
+
// Create new PBXGroup for the extension
|
|
113
|
+
const extGroup = xcodeProject.addPbxGroup(files, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
|
|
114
|
+
|
|
115
|
+
// Add the new PBXGroup to the top level group. This makes the
|
|
116
|
+
// files / folder appear in the file explorer in Xcode.
|
|
117
|
+
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
118
|
+
Object.keys(groups).forEach(key => {
|
|
119
|
+
if (groups[key].name === undefined) {
|
|
120
|
+
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// WORK AROUND for codeProject.addTarget BUG
|
|
125
|
+
// Xcode projects don't contain these if there is only one target
|
|
126
|
+
// An upstream fix should be made to the code referenced in this link:
|
|
127
|
+
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
|
|
128
|
+
const projObjects = xcodeProject.hash.project.objects;
|
|
129
|
+
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
|
|
130
|
+
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
|
|
131
|
+
if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
|
|
132
|
+
console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Add the NSE target
|
|
137
|
+
// This also adds PBXTargetDependency and PBXContainerItemProxy
|
|
138
|
+
const nseTarget = xcodeProject.addTarget(CIO_NOTIFICATION_TARGET_NAME, 'app_extension', CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
|
|
139
|
+
|
|
140
|
+
// Add build phases to the new target
|
|
141
|
+
xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift', 'Env.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
|
|
142
|
+
xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
|
|
143
|
+
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
|
|
144
|
+
|
|
145
|
+
// Edit the Deployment info of the target
|
|
146
|
+
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
|
|
147
|
+
for (const key in configurations) {
|
|
148
|
+
if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
|
|
149
|
+
const buildSettingsObj = configurations[key].buildSettings;
|
|
150
|
+
buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
|
|
151
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
|
|
152
|
+
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
153
|
+
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
154
|
+
buildSettingsObj.SWIFT_VERSION = 4.2;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Add development team to the target & the main
|
|
159
|
+
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
|
|
160
|
+
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
|
|
161
|
+
};
|
|
141
162
|
const updateNseInfoPlist = payload => {
|
|
142
163
|
const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
|
|
143
164
|
const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
|
|
144
165
|
let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);
|
|
145
166
|
if (payload.bundleVersion) {
|
|
146
|
-
plistFileString =
|
|
167
|
+
plistFileString = replaceCodeByRegex(plistFileString, BUNDLE_VERSION_RE, payload.bundleVersion);
|
|
147
168
|
}
|
|
148
169
|
if (payload.bundleShortVersion) {
|
|
149
|
-
plistFileString =
|
|
170
|
+
plistFileString = replaceCodeByRegex(plistFileString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
|
|
150
171
|
}
|
|
151
172
|
FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
|
|
152
173
|
};
|
|
174
|
+
const updateNseEnv = (options, envFileName) => {
|
|
175
|
+
var _options$pushNotifica2, _options$pushNotifica3, _options$pushNotifica6, _options$pushNotifica7, _options$pushNotifica10, _options$pushNotifica11;
|
|
176
|
+
const SITE_ID_RE = /\{\{SITE_ID\}\}/;
|
|
177
|
+
const API_KEY_RE = /\{\{API_KEY\}\}/;
|
|
178
|
+
const REGION_RE = /\{\{REGION\}\}/;
|
|
179
|
+
let envFileContent = FileManagement.readFile(envFileName);
|
|
180
|
+
if ((_options$pushNotifica2 = options.pushNotification) !== null && _options$pushNotifica2 !== void 0 && (_options$pushNotifica3 = _options$pushNotifica2.env) !== null && _options$pushNotifica3 !== void 0 && _options$pushNotifica3.siteId) {
|
|
181
|
+
var _options$pushNotifica4, _options$pushNotifica5;
|
|
182
|
+
envFileContent = replaceCodeByRegex(envFileContent, SITE_ID_RE, (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : (_options$pushNotifica5 = _options$pushNotifica4.env) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.siteId);
|
|
183
|
+
}
|
|
184
|
+
if ((_options$pushNotifica6 = options.pushNotification) !== null && _options$pushNotifica6 !== void 0 && (_options$pushNotifica7 = _options$pushNotifica6.env) !== null && _options$pushNotifica7 !== void 0 && _options$pushNotifica7.apiKey) {
|
|
185
|
+
var _options$pushNotifica8, _options$pushNotifica9;
|
|
186
|
+
envFileContent = replaceCodeByRegex(envFileContent, API_KEY_RE, (_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : (_options$pushNotifica9 = _options$pushNotifica8.env) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.apiKey);
|
|
187
|
+
}
|
|
188
|
+
if ((_options$pushNotifica10 = options.pushNotification) !== null && _options$pushNotifica10 !== void 0 && (_options$pushNotifica11 = _options$pushNotifica10.env) !== null && _options$pushNotifica11 !== void 0 && _options$pushNotifica11.region) {
|
|
189
|
+
var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14, _options$pushNotifica15;
|
|
190
|
+
let region = '';
|
|
191
|
+
if (((_options$pushNotifica12 = options.pushNotification) === null || _options$pushNotifica12 === void 0 ? void 0 : (_options$pushNotifica13 = _options$pushNotifica12.env) === null || _options$pushNotifica13 === void 0 ? void 0 : _options$pushNotifica13.region) === 'us') {
|
|
192
|
+
region = 'Region.US';
|
|
193
|
+
} else if (((_options$pushNotifica14 = options.pushNotification) === null || _options$pushNotifica14 === void 0 ? void 0 : (_options$pushNotifica15 = _options$pushNotifica14.env) === null || _options$pushNotifica15 === void 0 ? void 0 : _options$pushNotifica15.region) === 'eu') {
|
|
194
|
+
region = 'Region.EU';
|
|
195
|
+
}
|
|
196
|
+
envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);
|
|
197
|
+
}
|
|
198
|
+
FileManagement.writeFile(envFileName, envFileContent);
|
|
199
|
+
};
|
|
200
|
+
async function addPushNotificationFile(options, xcodeProject) {
|
|
201
|
+
const {
|
|
202
|
+
iosPath,
|
|
203
|
+
appName
|
|
204
|
+
} = options;
|
|
205
|
+
const file = 'PushService.swift';
|
|
206
|
+
const appPath = `${iosPath}/${appName}`;
|
|
207
|
+
const getTargetFile = filename => `${appPath}/${filename}`;
|
|
208
|
+
if (!FileManagement.exists(getTargetFile(file))) {
|
|
209
|
+
FileManagement.mkdir(appPath, {
|
|
210
|
+
recursive: true
|
|
211
|
+
});
|
|
212
|
+
const targetFile = getTargetFile(file);
|
|
213
|
+
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
|
|
214
|
+
} else {
|
|
215
|
+
console.log(`${getTargetFile(file)} already exists. Skipping...`);
|
|
216
|
+
}
|
|
217
|
+
const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');
|
|
218
|
+
const classesKey = xcodeProject.findPBXGroupKey({
|
|
219
|
+
name: `${appName}`
|
|
220
|
+
});
|
|
221
|
+
xcodeProject.addToPbxGroup(group, classesKey);
|
|
222
|
+
xcodeProject.addSourceFile(`${appName}/${file}`, null, group);
|
|
223
|
+
}
|
|
153
224
|
//# sourceMappingURL=withNotificationsXcodeProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","injectCodeByMultiLineRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","useFrameworks","appName","iosDeploymentTarget","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","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","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile"],"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 useFrameworks,\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, useFrameworks);\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, useFrameworks } = 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 useFrameworks,\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,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,0BAA0B,QAAQ,gCAAgC;AAC3E,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEN,4BAA6B,aAAY;AAEnE,M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,cAAc,CAAC4D,SAAS,CAACY,OAAO,CAAC3C,mBAAmB,EAAE8C,eAAe,CAAC;AACxE,CAAC"}
|
|
1
|
+
{"version":3,"names":["withXcodeProject","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","iosPath","appName","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","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","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","envFileName","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","apiKey","region","file","appPath","exists","log","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile"],"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 { replaceCodeByRegex } 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`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n // iosPath and appName are predefined from Expo config.\n // See function withCioNotificationsXcodeProject to get where the variabes are pulled from.\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 if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\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 {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = 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 // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\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 useFrameworks,\n iosDeploymentTarget,\n pushNotification,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${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 updateNseEnv(options, getTargetFile(ENV_FILENAME));\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'] = 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', 'Env.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\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 = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const SITE_ID_RE = /\\{\\{SITE_ID\\}\\}/;\n const API_KEY_RE = /\\{\\{API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.siteId) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n SITE_ID_RE,\n options.pushNotification?.env?.siteId\n );\n }\n\n if (options.pushNotification?.env?.apiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n API_KEY_RE,\n options.pushNotification?.env?.apiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n let region = '';\n if (options.pushNotification?.env?.region === 'us') {\n region = 'Region.US';\n } else if (options.pushNotification?.env?.region === 'eu') {\n region = 'Region.EU';\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\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 const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${file}`, null, group);\n}\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEN,4BAA6B,aAAY;AACnE,MAAMO,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,MACtCC,OAAmC,IAChC;EACH;EACA;EACA,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EAEpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAElE,MAAME,YAAY,GAAGf,KAAK,CAACgB,OAAO,CAACF,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pD,OAAQ;EAAE,CAAC,CAAC;EACvEE,YAAY,CAACmD,aAAa,CAACqC,KAAK,EAAEE,UAAU,CAAC;EAE7C1F,YAAY,CAAC4F,aAAa,CAAE,GAAE9F,OAAQ,IAAGsF,IAAK,EAAC,EAAE,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,EAAE;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
function runPostInstall() {
|
|
3
|
+
// react native SDK package.json path
|
|
4
|
+
const rnPjsonFile = `${__dirname}/../../customerio-reactnative/package.json`;
|
|
5
|
+
const expoPjsonFile = `${__dirname}/../package.json`;
|
|
6
|
+
try {
|
|
7
|
+
// if react native SDK is installed
|
|
8
|
+
if (fs.existsSync(rnPjsonFile)) {
|
|
9
|
+
const rnPJson = fs.readFileSync(rnPjsonFile, 'utf8');
|
|
10
|
+
expoPjson = require(expoPjsonFile);
|
|
11
|
+
const rnPackage = JSON.parse(rnPJson);
|
|
12
|
+
rnPackage.expoVersion = expoPjson.version;
|
|
13
|
+
fs.writeFileSync(rnPjsonFile, JSON.stringify(rnPackage, null, 2));
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {}
|
|
16
|
+
}
|
|
17
|
+
exports.runPostInstall = runPostInstall;
|
|
18
|
+
//# sourceMappingURL=postInstallHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fs","require","runPostInstall","rnPjsonFile","__dirname","expoPjsonFile","existsSync","rnPJson","readFileSync","expoPjson","rnPackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const rnPjsonFile = `${__dirname}/../../customerio-reactnative/package.json`;\n const expoPjsonFile = `${__dirname}/../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(rnPjsonFile)) {\n const rnPJson = fs.readFileSync(rnPjsonFile, 'utf8');\n expoPjson = require(expoPjsonFile);\n\n const rnPackage = JSON.parse(rnPJson);\n rnPackage.expoVersion = expoPjson.version;\n\n\n fs.writeFileSync(rnPjsonFile, JSON.stringify(rnPackage, null, 2));\n }\n } catch (error) {}\n}\n\nexports.runPostInstall = runPostInstall;"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAc,GAAG;EACxB;EACA,MAAMC,WAAW,GAAI,GAAEC,SAAU,4CAA2C;EAC5E,MAAMC,aAAa,GAAI,GAAED,SAAU,kBAAiB;EACpD,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,WAAW,CAAC,EAAE;MAC9B,MAAMI,OAAO,GAAGP,EAAE,CAACQ,YAAY,CAACL,WAAW,EAAE,MAAM,CAAC;MACpDM,SAAS,GAAGR,OAAO,CAACI,aAAa,CAAC;MAElC,MAAMK,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACL,OAAO,CAAC;MACrCG,SAAS,CAACG,WAAW,GAAGJ,SAAS,CAACK,OAAO;MAGzCd,EAAE,CAACe,aAAa,CAACZ,WAAW,EAAEQ,IAAI,CAACK,SAAS,CAACN,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnE;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE,CAAC;AACnB;AAEAC,OAAO,CAAChB,cAAc,GAAGA,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
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 useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n
|
|
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 useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n siteId: string;\n apiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const LOCAL_PATH_TO_CIO_NSE_FILES = "node_modules/customerio-expo-plugin/src/helpers/native-files/ios";
|
|
2
2
|
export declare const IOS_DEPLOYMENT_TARGET = "13.0";
|
|
3
|
-
export declare const CIO_SDK_VERSION = "
|
|
3
|
+
export declare const CIO_SDK_VERSION = "~> 2.0.0";
|
|
4
4
|
export declare const CIO_PODFILE_REGEX: RegExp;
|
|
5
5
|
export declare const CIO_CIO_TARGET_REGEX: RegExp;
|
|
6
6
|
export declare const CIO_PODFILE_NOTIFICATION_REGEX: RegExp;
|
|
7
|
+
export declare const CIO_PODFILE_POST_INSTALL_REGEX: RegExp;
|
|
7
8
|
export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
|
|
8
9
|
export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
|
|
9
10
|
export declare const BUNDLE_VERSION_TEMPLATE_REGEX: RegExp;
|
|
10
|
-
export declare const CIO_PODFILE_POST_INSTALL_REGEX: RegExp;
|
|
11
11
|
export declare const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX: RegExp;
|
|
12
12
|
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX: RegExp;
|
|
13
13
|
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX: RegExp;
|
|
@@ -28,6 +28,3 @@ export declare const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = "\n// show pus
|
|
|
28
28
|
export declare const CIO_PODFILE_SNIPPET: string;
|
|
29
29
|
export declare const CIO_PODFILE_NOTIFICATION_SNIPPET: string;
|
|
30
30
|
export declare const CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET: string;
|
|
31
|
-
export declare const CIO_PODFILE_TARGET_NAMES_SNIPPET = "\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]";
|
|
32
|
-
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";
|
|
33
|
-
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";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function injectCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string[];
|
|
2
2
|
export declare function injectCodeByMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
3
|
+
export declare function replaceCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
3
4
|
export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
4
5
|
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string[];
|
|
@@ -14,11 +14,16 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
14
14
|
useFrameworks?: 'static' | 'dynamic';
|
|
15
15
|
pushNotification?: {
|
|
16
16
|
useRichPush: boolean;
|
|
17
|
+
env: {
|
|
18
|
+
siteId: string;
|
|
19
|
+
apiKey: string;
|
|
20
|
+
region: string;
|
|
21
|
+
};
|
|
17
22
|
};
|
|
18
23
|
};
|
|
19
24
|
export type CustomerIOPluginOptionsAndroid = {
|
|
20
25
|
androidPath: string;
|
|
21
|
-
|
|
26
|
+
googleServicesFile?: string;
|
|
22
27
|
};
|
|
23
28
|
export type CustomerIOPluginOptions = {
|
|
24
29
|
android: CustomerIOPluginOptionsAndroid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -12,14 +12,18 @@
|
|
|
12
12
|
"src",
|
|
13
13
|
"lib/**/*"
|
|
14
14
|
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./lib/commonjs/index.js",
|
|
17
|
+
"./postinstall": "./src/postInstallHelper.js"
|
|
18
|
+
},
|
|
15
19
|
"scripts": {
|
|
16
20
|
"build": "npm run clean && tsc",
|
|
17
|
-
"
|
|
18
|
-
"clean": "rm -rf lib && npm run prebuild",
|
|
21
|
+
"clean": "rm -rf lib",
|
|
19
22
|
"expo-module": "expo-module",
|
|
20
23
|
"lint": "eslint . --fix",
|
|
21
24
|
"typescript": "tsc --noEmit",
|
|
22
|
-
"prepare": "npm run clean && bob build"
|
|
25
|
+
"prepare": "npm run clean && bob build",
|
|
26
|
+
"postinstall": "node src/postInstall.js"
|
|
23
27
|
},
|
|
24
28
|
"keywords": [
|
|
25
29
|
"react-native",
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"registry": "https://registry.npmjs.org/"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
39
|
-
"customerio-reactnative": "
|
|
43
|
+
"customerio-reactnative": "^1.0.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@expo/config-plugins": "^4.1.4",
|