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.
Files changed (80) hide show
  1. package/README.md +10 -8
  2. package/lib/commonjs/android/withGoogleServicesJSON.js +7 -5
  3. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  4. package/lib/commonjs/helpers/constants/ios.js +5 -52
  5. package/lib/commonjs/helpers/constants/ios.js.map +1 -1
  6. package/lib/commonjs/helpers/native-files/ios/Env.swift +8 -0
  7. package/lib/commonjs/helpers/native-files/ios/NotificationService.swift +4 -1
  8. package/lib/commonjs/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
  9. package/lib/commonjs/helpers/utils/codeInjection.js +4 -0
  10. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -1
  11. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +1 -3
  12. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  13. package/lib/commonjs/index.js +0 -2
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/ios/withCIOIos.js +2 -7
  16. package/lib/commonjs/ios/withCIOIos.js.map +1 -1
  17. package/lib/commonjs/ios/withNotificationsXcodeProject.js +147 -76
  18. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  19. package/lib/commonjs/postInstall.js +7 -0
  20. package/lib/commonjs/postInstall.js.map +1 -0
  21. package/lib/commonjs/postInstallHelper.js +20 -0
  22. package/lib/commonjs/postInstallHelper.js.map +1 -0
  23. package/lib/commonjs/types/cio-types.js.map +1 -1
  24. package/lib/module/android/withGoogleServicesJSON.js +7 -5
  25. package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  26. package/lib/module/helpers/constants/ios.js +3 -47
  27. package/lib/module/helpers/constants/ios.js.map +1 -1
  28. package/lib/module/helpers/native-files/ios/Env.swift +8 -0
  29. package/lib/module/helpers/native-files/ios/NotificationService.swift +4 -1
  30. package/lib/module/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
  31. package/lib/module/helpers/utils/codeInjection.js +3 -0
  32. package/lib/module/helpers/utils/codeInjection.js.map +1 -1
  33. package/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -4
  34. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  35. package/lib/module/index.js +0 -2
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/ios/withCIOIos.js +2 -7
  38. package/lib/module/ios/withCIOIos.js.map +1 -1
  39. package/lib/module/ios/withNotificationsXcodeProject.js +148 -77
  40. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  41. package/lib/module/postInstall.js +5 -0
  42. package/lib/module/postInstall.js.map +1 -0
  43. package/lib/module/postInstallHelper.js +18 -0
  44. package/lib/module/postInstallHelper.js.map +1 -0
  45. package/lib/module/types/cio-types.js.map +1 -1
  46. package/lib/typescript/helpers/constants/ios.d.ts +2 -5
  47. package/lib/typescript/helpers/utils/codeInjection.d.ts +1 -0
  48. package/lib/typescript/types/cio-types.d.ts +6 -1
  49. package/package.json +9 -5
  50. package/src/android/withGoogleServicesJSON.ts +9 -5
  51. package/src/helpers/constants/ios.ts +3 -46
  52. package/src/helpers/native-files/ios/Env.swift +8 -0
  53. package/src/helpers/native-files/ios/NotificationService.swift +4 -1
  54. package/src/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
  55. package/src/helpers/utils/codeInjection.ts +8 -0
  56. package/src/helpers/utils/injectCIOPodfileCode.ts +2 -10
  57. package/src/index.ts +0 -3
  58. package/src/ios/withCIOIos.ts +2 -8
  59. package/src/ios/withNotificationsXcodeProject.ts +221 -127
  60. package/src/postInstall.js +5 -0
  61. package/src/postInstallHelper.js +22 -0
  62. package/src/types/cio-types.ts +6 -1
  63. package/lib/commonjs/analytics/injectAnalytics.js +0 -31
  64. package/lib/commonjs/analytics/injectAnalytics.js.map +0 -1
  65. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +0 -79
  66. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +0 -1
  67. package/lib/commonjs/version.js +0 -9
  68. package/lib/commonjs/version.js.map +0 -1
  69. package/lib/module/analytics/injectAnalytics.js +0 -24
  70. package/lib/module/analytics/injectAnalytics.js.map +0 -1
  71. package/lib/module/ios/withAppDelegateXcodeProject.js +0 -71
  72. package/lib/module/ios/withAppDelegateXcodeProject.js.map +0 -1
  73. package/lib/module/version.js +0 -2
  74. package/lib/module/version.js.map +0 -1
  75. package/lib/typescript/analytics/injectAnalytics.d.ts +0 -3
  76. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +0 -3
  77. package/lib/typescript/version.d.ts +0 -1
  78. package/src/analytics/injectAnalytics.ts +0 -36
  79. package/src/ios/withAppDelegateXcodeProject.ts +0 -89
  80. package/src/version.ts +0 -1
@@ -18,12 +18,17 @@ export type CustomerIOPluginOptionsIOS = {
18
18
  useFrameworks?: 'static' | 'dynamic';
19
19
  pushNotification?: {
20
20
  useRichPush: boolean;
21
+ env: {
22
+ siteId: string;
23
+ apiKey: string;
24
+ region: string;
25
+ };
21
26
  };
22
27
  };
23
28
 
24
29
  export type CustomerIOPluginOptionsAndroid = {
25
30
  androidPath: string;
26
- googleServicesFilePath?: string;
31
+ googleServicesFile?: string;
27
32
  };
28
33
 
29
34
  export type CustomerIOPluginOptions = {
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.withAnalytics = void 0;
7
- var _version = require("./../version");
8
- var _configPlugins = require("@expo/config-plugins");
9
- var _fileManagement = require("../helpers/utils/fileManagement");
10
- const withAnalytics = config => {
11
- return (0, _configPlugins.withXcodeProject)(config, async props => {
12
- const expoVersionSnippet = `"expoVersion": "${_version.LIB_VERSION}"`;
13
- let versionRegEx = new RegExp(expoVersionSnippet);
14
- const filename = `node_modules/customerio-reactnative/package.json`;
15
- if (_fileManagement.FileManagement.exists(filename)) {
16
- const pJsonFile = await _fileManagement.FileManagement.read(filename);
17
- const lines = pJsonFile.split('\n');
18
- const missingMmatch = pJsonFile.match(versionRegEx);
19
- const expoVersionRegex = /"expoVersion": ".*"/;
20
- const existatch = pJsonFile.match(expoVersionRegex);
21
- if (existatch && !missingMmatch) {
22
- const index = lines.findIndex(line => expoVersionRegex.test(line));
23
- const content = [...lines.slice(0, index), ` ${expoVersionSnippet},`, ...lines.slice(index + 1)];
24
- _fileManagement.FileManagement.write(filename, content.join('\n'));
25
- }
26
- }
27
- return props;
28
- });
29
- };
30
- exports.withAnalytics = withAnalytics;
31
- //# sourceMappingURL=injectAnalytics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["withAnalytics","config","withXcodeProject","props","expoVersionSnippet","LIB_VERSION","versionRegEx","RegExp","filename","FileManagement","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(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strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.withCioAppdelegateXcodeProject = void 0;
7
- var _configPlugins = require("@expo/config-plugins");
8
- var _xcode = _interopRequireDefault(require("xcode"));
9
- var _ios = require("../helpers/constants/ios");
10
- var _fileManagement = require("./../helpers/utils/fileManagement");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- const addNotificationSwiftFile = async options => {
13
- const {
14
- iosPath,
15
- appName
16
- } = options;
17
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
18
- const xcodeProject = _xcode.default.project(projPath);
19
- xcodeProject.parse(async function (err) {
20
- const file = 'PushNotification.swift';
21
- const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
22
- if (err) {
23
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
24
- }
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
- }
34
- });
35
- };
36
- const withCioAppdelegateXcodeProject = (configOuter, props) => {
37
- return (0, _configPlugins.withXcodeProject)(configOuter, async config => {
38
- const {
39
- modRequest,
40
- ios,
41
- version: bundleShortVersion
42
- } = config;
43
- const {
44
- appleTeamId,
45
- iosDeploymentTarget
46
- } = props;
47
- if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
48
- const {
49
- projectName,
50
- platformProjectRoot
51
- } = modRequest;
52
- const {
53
- bundleIdentifier,
54
- buildNumber
55
- } = ios;
56
- if (bundleShortVersion === undefined) {
57
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
58
- }
59
- if (bundleIdentifier === undefined) {
60
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
61
- }
62
- if (projectName === undefined) {
63
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
64
- }
65
- const options = {
66
- appleTeamId,
67
- bundleIdentifier,
68
- bundleShortVersion,
69
- bundleVersion: buildNumber || _ios.DEFAULT_BUNDLE_VERSION,
70
- iosPath: platformProjectRoot,
71
- appName: projectName,
72
- iosDeploymentTarget
73
- };
74
- await addNotificationSwiftFile(options);
75
- return config;
76
- });
77
- };
78
- exports.withCioAppdelegateXcodeProject = withCioAppdelegateXcodeProject;
79
- //# sourceMappingURL=withAppDelegateXcodeProject.js.map
@@ -1 +0,0 @@
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;AAEnE,MAAMA,wBAAwB,GAAG,MAC/BC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EACpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAClE,MAAME,YAAY,GAAGC,cAAK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AY,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"}
@@ -1,9 +0,0 @@
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.4";
8
- exports.LIB_VERSION = LIB_VERSION;
9
- //# sourceMappingURL=version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["LIB_VERSION"],"sources":["version.ts"],"sourcesContent":["export const LIB_VERSION = \"1.0.0-alpha.4\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,eAAe;AAAC"}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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"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
1
- import { withXcodeProject } from '@expo/config-plugins';
2
- import xcode from 'xcode';
3
- import { DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
4
- import { FileManagement } from './../helpers/utils/fileManagement';
5
- const addNotificationSwiftFile = async options => {
6
- const {
7
- iosPath,
8
- appName
9
- } = options;
10
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
11
- const xcodeProject = xcode.project(projPath);
12
- xcodeProject.parse(async function (err) {
13
- const file = 'PushNotification.swift';
14
- const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
15
- if (err) {
16
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
17
- }
18
- if (!FileManagement.exists(getTargetFile(file))) {
19
- FileManagement.mkdir(`${iosPath}/${appName}`, {
20
- recursive: true
21
- });
22
- const targetFile = getTargetFile(file);
23
- FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
24
- } else {
25
- console.log(`${getTargetFile(file)} already exists. Skipping...`);
26
- }
27
- });
28
- };
29
- export const withCioAppdelegateXcodeProject = (configOuter, props) => {
30
- return withXcodeProject(configOuter, async config => {
31
- const {
32
- modRequest,
33
- ios,
34
- version: bundleShortVersion
35
- } = config;
36
- const {
37
- appleTeamId,
38
- iosDeploymentTarget
39
- } = props;
40
- if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
41
- const {
42
- projectName,
43
- platformProjectRoot
44
- } = modRequest;
45
- const {
46
- bundleIdentifier,
47
- buildNumber
48
- } = ios;
49
- if (bundleShortVersion === undefined) {
50
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
51
- }
52
- if (bundleIdentifier === undefined) {
53
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
54
- }
55
- if (projectName === undefined) {
56
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
57
- }
58
- const options = {
59
- appleTeamId,
60
- bundleIdentifier,
61
- bundleShortVersion,
62
- bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
63
- iosPath: platformProjectRoot,
64
- appName: projectName,
65
- iosDeploymentTarget
66
- };
67
- await addNotificationSwiftFile(options);
68
- return config;
69
- });
70
- };
71
- //# sourceMappingURL=withAppDelegateXcodeProject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["withXcodeProject","xcode","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","FileManagement","addNotificationSwiftFile","options","iosPath","appName","projPath","xcodeProject","project","parse","err","file","getTargetFile","filename","Error","JSON","stringify","exists","mkdir","recursive","targetFile","copyFile","console","log","withCioAppdelegateXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion"],"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,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AAEjC,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,wBAAwB,GAAG,MAC/BC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EACpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAClE,MAAME,YAAY,GAAGT,KAAK,CAACU,OAAO,CAACF,QAAQ,CAAC;EAE5CC,YAAY,CAACE,KAAK,CAAC,gBAAgBC,GA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,IAAIpB,KAAK,CACb,gFAAgF,CACjF;IACH;IAEA,IAAIuB,gBAAgB,KAAKH,SAAS,EAAE;MAClC,MAAM,IAAIpB,KAAK,CACb,6FAA6F,CAC9F;IACH;IAEA,IAAIqB,WAAW,KAAKD,SAAS,EAAE;MAC7B,MAAM,IAAIpB,KAAK,CACb,6EAA6E,CAC9E;IACH;IAEA,MAAMX,OAAO,GAAG;MACd6B,WAAW;MACXK,gBAAgB;MAChBN,kBAAkB;MAClBQ,aAAa,EAAED,WAAW,IAAIvC,sBAAsB;MACpDK,OAAO,EAAEgC,mBAAmB;MAC5B/B,OAAO,EAAE8B,WAAW;MACpBF;IACF,CAAC;IAED,MAAM/B,wBAAwB,CAACC,OAAO,CAAC;IAEvC,OAAOwB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export const LIB_VERSION = "1.0.0-alpha.4";
2
- //# sourceMappingURL=version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["LIB_VERSION"],"sources":["version.ts"],"sourcesContent":["export const LIB_VERSION = \"1.0.0-alpha.4\";\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,eAAe"}
@@ -1,3 +0,0 @@
1
- import { ConfigPlugin } from '@expo/config-plugins';
2
- import type { CustomerIOPluginOptions } from '../types/cio-types';
3
- export declare const withAnalytics: ConfigPlugin<CustomerIOPluginOptions>;
@@ -1,3 +0,0 @@
1
- import { ConfigPlugin } from '@expo/config-plugins';
2
- import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
- export declare const withCioAppdelegateXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -1 +0,0 @@
1
- export declare const LIB_VERSION = "1.0.0-alpha.4";
@@ -1,36 +0,0 @@
1
- import { LIB_VERSION } from './../version';
2
- import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
3
- import { FileManagement } from '../helpers/utils/fileManagement';
4
- import type { CustomerIOPluginOptions } from '../types/cio-types';
5
-
6
-
7
- export const withAnalytics: ConfigPlugin<CustomerIOPluginOptions> = (config) => {
8
- return withXcodeProject(config, async (props) => {
9
- const expoVersionSnippet = `"expoVersion": "${LIB_VERSION}"`;
10
- let versionRegEx = new RegExp(expoVersionSnippet);
11
- const filename = `node_modules/customerio-reactnative/package.json`;
12
- if (FileManagement.exists(filename)) {
13
- const pJsonFile = await FileManagement.read(filename);
14
- const lines = pJsonFile.split('\n');
15
- const missingMmatch = pJsonFile.match(versionRegEx);
16
- const expoVersionRegex = /"expoVersion": ".*"/;
17
- const existatch = pJsonFile.match(expoVersionRegex);
18
-
19
- if (existatch && !missingMmatch) {
20
- const index = lines.findIndex((line) =>
21
- expoVersionRegex.test(line)
22
- );
23
-
24
- const content = [
25
- ...lines.slice(0, index),
26
- ` ${expoVersionSnippet},`,
27
- ...lines.slice(index + 1),
28
- ];
29
-
30
- FileManagement.write(filename, content.join('\n'));
31
- }
32
- }
33
-
34
- return props;
35
- });
36
- };
@@ -1,89 +0,0 @@
1
- import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
2
- import xcode from 'xcode';
3
-
4
- import {
5
- DEFAULT_BUNDLE_VERSION,
6
- LOCAL_PATH_TO_CIO_NSE_FILES,
7
- } from '../helpers/constants/ios';
8
- import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
9
- import { FileManagement } from './../helpers/utils/fileManagement';
10
-
11
- const addNotificationSwiftFile = async (
12
- options: CustomerIOPluginOptionsIOS
13
- ) => {
14
- const { iosPath, appName } = options;
15
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
16
- const xcodeProject = xcode.project(projPath);
17
-
18
- xcodeProject.parse(async function (err: Error) {
19
- const file = 'PushNotification.swift';
20
- const getTargetFile = (filename: string) =>
21
- `${iosPath}/${appName}/${filename}`;
22
- if (err) {
23
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
24
- }
25
-
26
- if (!FileManagement.exists(getTargetFile(file))) {
27
- FileManagement.mkdir(`${iosPath}/${appName}`, {
28
- recursive: true,
29
- });
30
-
31
- const targetFile = getTargetFile(file);
32
- FileManagement.copyFile(
33
- `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,
34
- targetFile
35
- );
36
- } else {
37
- console.log(`${getTargetFile(file)} already exists. Skipping...`);
38
- }
39
- });
40
- };
41
-
42
- export const withCioAppdelegateXcodeProject: ConfigPlugin<
43
- CustomerIOPluginOptionsIOS
44
- > = (configOuter, props) => {
45
- return withXcodeProject(configOuter, async (config) => {
46
- const { modRequest, ios, version: bundleShortVersion } = config;
47
- const { appleTeamId, iosDeploymentTarget } = props;
48
-
49
- if (ios === undefined)
50
- throw new Error(
51
- 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'
52
- );
53
-
54
- const { projectName, platformProjectRoot } = modRequest;
55
- const { bundleIdentifier, buildNumber } = ios;
56
-
57
- if (bundleShortVersion === undefined) {
58
- throw new Error(
59
- 'Adding NotificationServiceExtension failed: version missing from app.config.js'
60
- );
61
- }
62
-
63
- if (bundleIdentifier === undefined) {
64
- throw new Error(
65
- 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'
66
- );
67
- }
68
-
69
- if (projectName === undefined) {
70
- throw new Error(
71
- 'Adding NotificationServiceExtension failed: name missing from app.config.js'
72
- );
73
- }
74
-
75
- const options = {
76
- appleTeamId,
77
- bundleIdentifier,
78
- bundleShortVersion,
79
- bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
80
- iosPath: platformProjectRoot,
81
- appName: projectName,
82
- iosDeploymentTarget,
83
- };
84
-
85
- await addNotificationSwiftFile(options);
86
-
87
- return config;
88
- });
89
- };
package/src/version.ts DELETED
@@ -1 +0,0 @@
1
- export const LIB_VERSION = "1.0.0-alpha.4";