customerio-expo-plugin 2.7.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +5 -4
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js +2 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withCIOAndroid.js +17 -11
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/commonjs/android/withGistMavenRepository.js +2 -1
- package/plugin/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +4 -3
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +2 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/fileManagement.js +5 -4
- package/plugin/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +5 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/commonjs/index.js +3 -11
- package/plugin/lib/commonjs/index.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +2 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +7 -3
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +11 -10
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +8 -7
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -23
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/utils/android.js +2 -1
- package/plugin/lib/commonjs/utils/android.js.map +1 -1
- package/plugin/lib/commonjs/utils/config.js +3 -2
- package/plugin/lib/commonjs/utils/config.js.map +1 -1
- package/plugin/lib/commonjs/utils/logger.js +35 -0
- package/plugin/lib/commonjs/utils/logger.js.map +1 -0
- package/plugin/lib/commonjs/utils/validation.js +68 -25
- package/plugin/lib/commonjs/utils/validation.js.map +1 -1
- package/plugin/lib/commonjs/utils/xcode.js +2 -1
- package/plugin/lib/commonjs/utils/xcode.js.map +1 -1
- package/plugin/lib/module/android/withAndroidManifestUpdates.js +6 -4
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withAppGoogleServices.js +2 -1
- package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withCIOAndroid.js +17 -11
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/module/android/withGistMavenRepository.js +2 -1
- package/plugin/lib/module/android/withGistMavenRepository.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js +4 -3
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js +2 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/module/helpers/utils/fileManagement.js +6 -5
- package/plugin/lib/module/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +5 -1
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/module/index.js +3 -12
- package/plugin/lib/module/index.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +2 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +7 -3
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +11 -10
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +8 -7
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -23
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/utils/android.js +2 -1
- package/plugin/lib/module/utils/android.js.map +1 -1
- package/plugin/lib/module/utils/config.js +4 -2
- package/plugin/lib/module/utils/config.js.map +1 -1
- package/plugin/lib/module/utils/logger.js +29 -0
- package/plugin/lib/module/utils/logger.js.map +1 -0
- package/plugin/lib/module/utils/validation.js +68 -27
- package/plugin/lib/module/utils/validation.js.map +1 -1
- package/plugin/lib/module/utils/xcode.js +2 -1
- package/plugin/lib/module/utils/xcode.js.map +1 -1
- package/plugin/lib/typescript/android/withCIOAndroid.d.ts +1 -1
- package/plugin/lib/typescript/ios/withCIOIos.d.ts +1 -1
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +1 -1
- package/plugin/lib/typescript/utils/logger.d.ts +8 -0
- package/plugin/lib/typescript/utils/validation.d.ts +6 -3
- package/plugin/src/android/withAndroidManifestUpdates.ts +5 -4
- package/plugin/src/android/withAppGoogleServices.ts +2 -1
- package/plugin/src/android/withCIOAndroid.ts +18 -12
- package/plugin/src/android/withGistMavenRepository.ts +3 -2
- package/plugin/src/android/withGoogleServicesJSON.ts +4 -3
- package/plugin/src/android/withMainApplicationModifications.ts +2 -1
- package/plugin/src/helpers/utils/fileManagement.ts +10 -9
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +2 -1
- package/plugin/src/helpers/utils/patchPluginNativeCode.ts +6 -1
- package/plugin/src/index.ts +3 -13
- package/plugin/src/ios/withAppDelegateModifications.ts +2 -1
- package/plugin/src/ios/withCIOIos.ts +12 -8
- package/plugin/src/ios/withCIOIosSwift.ts +15 -14
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +8 -7
- package/plugin/src/ios/withNotificationsXcodeProject.ts +31 -35
- package/plugin/src/utils/android.ts +2 -1
- package/plugin/src/utils/config.ts +3 -2
- package/plugin/src/utils/logger.ts +37 -0
- package/plugin/src/utils/validation.ts +96 -32
- package/plugin/src/utils/xcode.ts +2 -1
|
@@ -8,7 +8,9 @@ var _configPlugins = require("@expo/config-plugins");
|
|
|
8
8
|
var _ios = require("../helpers/constants/ios");
|
|
9
9
|
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
10
10
|
var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
|
|
11
|
+
var _logger = require("../utils/logger");
|
|
11
12
|
var _plugin = require("../utils/plugin");
|
|
13
|
+
var _validation = require("../utils/validation");
|
|
12
14
|
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
13
15
|
var _utils = require("./utils");
|
|
14
16
|
const PLIST_FILENAME = `${_ios.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
@@ -26,7 +28,7 @@ const addNotificationServiceExtension = async (options, xcodeProject, isExpo53Or
|
|
|
26
28
|
}
|
|
27
29
|
return xcodeProject;
|
|
28
30
|
} catch (error) {
|
|
29
|
-
|
|
31
|
+
_logger.logger.error(String(error));
|
|
30
32
|
return null;
|
|
31
33
|
}
|
|
32
34
|
};
|
|
@@ -98,7 +100,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
98
100
|
// Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
|
|
99
101
|
// If true then skip creating a new group to avoid duplicate folders
|
|
100
102
|
if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
|
|
101
|
-
|
|
103
|
+
_logger.logger.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
const nsePath = `${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}`;
|
|
@@ -151,7 +153,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
151
153
|
projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};
|
|
152
154
|
projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};
|
|
153
155
|
if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
|
|
154
|
-
|
|
156
|
+
_logger.logger.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
155
157
|
return;
|
|
156
158
|
}
|
|
157
159
|
|
|
@@ -201,21 +203,24 @@ const updateNseEnv = (envFileName, richPushConfig) => {
|
|
|
201
203
|
// Use merged config values (config takes precedence over env)
|
|
202
204
|
const cdpApiKey = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.cdpApiKey;
|
|
203
205
|
const region = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.region;
|
|
204
|
-
if (!
|
|
205
|
-
|
|
206
|
+
if (!(0, _validation.validateRichPushConfig)(richPushConfig)) {
|
|
207
|
+
return;
|
|
206
208
|
}
|
|
207
|
-
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, CDP_API_KEY_RE, cdpApiKey);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
209
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, CDP_API_KEY_RE, cdpApiKey || 'MISSING_API_KEY');
|
|
210
|
+
|
|
211
|
+
// Simplify region mapping with case insensitive keys and fallback for invalid regions
|
|
212
|
+
const regionKey = (region === null || region === void 0 ? void 0 : region.toLowerCase()) ?? '';
|
|
213
|
+
const regionMap = {
|
|
214
|
+
us: 'Region.US',
|
|
215
|
+
eu: 'Region.EU'
|
|
216
|
+
};
|
|
217
|
+
const mappedRegion = regionMap[regionKey];
|
|
218
|
+
if (!mappedRegion) {
|
|
219
|
+
_logger.logger.warn(`${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`);
|
|
220
|
+
// Fallback to US if invalid region provided
|
|
221
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, REGION_RE, regionMap.us);
|
|
222
|
+
} else {
|
|
223
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, REGION_RE, mappedRegion);
|
|
219
224
|
}
|
|
220
225
|
_fileManagement.FileManagement.writeFile(envFileName, envFileContent);
|
|
221
226
|
};
|
|
@@ -241,7 +246,7 @@ async function addPushNotificationFile(options, xcodeProject) {
|
|
|
241
246
|
});
|
|
242
247
|
_fileManagement.FileManagement.copyFile(`${(0, _plugin.getIosNativeFilesPath)()}/${sourceFile}`, targetFile);
|
|
243
248
|
} else {
|
|
244
|
-
|
|
249
|
+
_logger.logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);
|
|
245
250
|
return;
|
|
246
251
|
}
|
|
247
252
|
updatePushFile(options, targetFile);
|
|
@@ -257,18 +262,19 @@ const updatePushFile = (options, envFileName) => {
|
|
|
257
262
|
const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
|
|
258
263
|
let envFileContent = _fileManagement.FileManagement.readFile(envFileName);
|
|
259
264
|
const disableNotificationRegistration = (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.disableNotificationRegistration;
|
|
265
|
+
const richPushConfig = (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : _options$pushNotifica4.env;
|
|
260
266
|
const {
|
|
261
267
|
cdpApiKey,
|
|
262
268
|
region
|
|
263
|
-
} =
|
|
264
|
-
cdpApiKey:
|
|
269
|
+
} = richPushConfig || {
|
|
270
|
+
cdpApiKey: 'MISSING_API_KEY',
|
|
265
271
|
region: undefined
|
|
266
272
|
};
|
|
267
|
-
if (!
|
|
268
|
-
|
|
273
|
+
if (!(0, _validation.validateRichPushConfig)(richPushConfig)) {
|
|
274
|
+
return;
|
|
269
275
|
}
|
|
270
276
|
let snippet = '';
|
|
271
|
-
// unless this property is
|
|
277
|
+
// unless this property is explicitly set to true, push notification
|
|
272
278
|
// registration will be added to the AppDelegate
|
|
273
279
|
if (disableNotificationRegistration !== true) {
|
|
274
280
|
snippet = _ios.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_ios","_codeInjection","_injectCIOPodfileCode","_plugin","_fileManagement","_utils","PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","DEFAULT_BUNDLE_VERSION","iosPath","appName","modifiedProjectFile","modResults","isExpoVersion53OrHigher","exports","_options$pushNotifica2","isFcmProvider","isFcmPushProvider","injectCIONotificationPodfileCode","pbxTargetByName","warn","nsePath","FileManagement","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","getIosNativeFilesPath","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","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","replaceCodeByRegex","writeFile","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionMap","us","eu","mappedRegion","toLowerCase","sourceFile","targetFileName","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\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 xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n console.error(error);\n return null;\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 // 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 ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\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 const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${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(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common 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 && groups[key].path === 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 = 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 || '15.1';\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 envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!cdpApiKey) {\n throw new Error(\n 'NotificationServiceExtension failed: cdpApiKey missing. Provide in config.cdpApiKey or ios.pushNotification.env.cdpApiKey.'\n );\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey\n );\n\n if (region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const mappedRegion =\n regionMap[region.toLowerCase() as keyof typeof regionMap] || '';\n if (!mappedRegion) {\n console.warn(\n `${region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const { cdpApiKey, region } = options.pushNotification?.env || {\n cdpApiKey: undefined,\n region: undefined,\n };\n if (!cdpApiKey) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.'\n );\n }\n\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAKA,IAAAE,cAAA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BAAmB,MAAK,KAAK;EACzD7B,cAAc,GAAG,IAAAN,iCAAkB,EACjCM,cAAc,EACd,gCAAgC,EAChC6B,mBAAmB,CAACC,QAAQ,CAAC,CAC/B,CAAC;EAED,MAAMC,oBAAoB,GACxB,EAAAT,sBAAA,GAAAzH,OAAO,CAACI,gBAAgB,cAAAqH,sBAAA,uBAAxBA,sBAAA,CAA0BS,oBAAoB,MAAK,KAAK;EAC1D/B,cAAc,GAAG,IAAAN,iCAAkB,EACjCM,cAAc,EACd,iCAAiC,EACjC+B,oBAAoB,CAACD,QAAQ,CAAC,CAChC,CAAC;EAED,MAAME,uBAAuB,GAC3B,EAAAT,sBAAA,GAAA1H,OAAO,CAACI,gBAAgB,cAAAsH,sBAAA,uBAAxBA,sBAAA,CAA0BS,uBAAuB,MAAK,KAAK;EAC7DhC,cAAc,GAAG,IAAAN,iCAAkB,EACjCM,cAAc,EACd,qCAAqC,EACrCgC,uBAAuB,CAACF,QAAQ,CAAC,CACnC,CAAC;EAEDtF,8BAAc,CAACmD,SAAS,CAACC,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_ios","_codeInjection","_injectCIOPodfileCode","_logger","_plugin","_validation","_fileManagement","_utils","PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","logger","String","withCioNotificationsXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","DEFAULT_BUNDLE_VERSION","iosPath","appName","modifiedProjectFile","modResults","isExpoVersion53OrHigher","exports","_options$pushNotifica2","isFcmProvider","isFcmPushProvider","injectCIONotificationPodfileCode","pbxTargetByName","warn","nsePath","FileManagement","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","getIosNativeFilesPath","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","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","replaceCodeByRegex","writeFile","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","validateRichPushConfig","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","sourceFile","targetFileName","appPath","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\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 xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\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 // 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 ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${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(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common 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 && groups[key].path === 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 = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.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 || '15.1';\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 envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n // Simplify region mapping with case insensitive keys and fallback for invalid regions\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n // Fallback to US if invalid region provided\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);\n } else {\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n\n let snippet = '';\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey,\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n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exports.addImportToFile = exports.addCodeToMethod = void 0;
|
|
7
7
|
var _path = _interopRequireDefault(require("path"));
|
|
8
8
|
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
9
|
+
var _logger = require("./logger");
|
|
9
10
|
var _plugin = require("./plugin");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
// Generic utility to add import to Kotlin files
|
|
@@ -101,7 +102,7 @@ const copyTemplateFile = (expoConfig, filename, classPackage, patchContent) => {
|
|
|
101
102
|
const destinationPath = _path.default.join(packagePath, filename);
|
|
102
103
|
_fileManagement.FileManagement.writeFile(destinationPath, content);
|
|
103
104
|
} catch (error) {
|
|
104
|
-
|
|
105
|
+
_logger.logger.warn(`Failed to copy ${filename} to Android project:`, error);
|
|
105
106
|
throw error;
|
|
106
107
|
}
|
|
107
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_path","_interopRequireDefault","require","_fileManagement","_plugin","e","__esModule","default","addImportToFile","content","importStatement","includes","importRegex","imports","matchAll","length","packageRegex","packageMatch","match","insertPosition","index","substring","lastImport","exports","findMatchingBracketPosition","bracket","startPos","openBracket","closeBracket","depth","foundOpen","i","char","addCodeToMethod","methodRegex","codeToAdd","methodMatch","undefined","methodStart","methodContent","openBraceIndex","indexOf","absoluteOpenBracePos","closeBracePos","linesUpToOpenBrace","split","braceLine","methodIndentMatch","methodIndent","indentLevel","afterBrace","afterBraceLines","filter","l","trim","nextLineIndentMatch","slice","finalIndent","copyTemplateFile","expoConfig","filename","classPackage","patchContent","projectRoot","modRequest","mainSourceDir","path","join","packagePath","replace","FileManagement","mkdir","recursive","sourcePath","getAndroidNativeFilesPath","readFile","destinationPath","writeFile","error","console","warn"],"sources":["android.ts"],"sourcesContent":["import type { ExportedConfigWithProps } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport path from 'path';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { getAndroidNativeFilesPath } from './plugin';\n\n// Generic utility to add import to Kotlin files\nexport const addImportToFile = (content: string, importStatement: string): string => {\n if (content.includes(importStatement)) {\n return content;\n }\n\n const importRegex = /^import\\s+[^\\s\\n]+.*$/gm;\n const imports = [...content.matchAll(importRegex)];\n\n if (imports.length === 0) {\n const packageRegex = /package\\s+[^\\s;]+[;\\s]*\\n/;\n const packageMatch = content.match(packageRegex);\n if (!packageMatch) return content;\n\n const insertPosition = (packageMatch.index ?? 0) + packageMatch[0].length;\n return content.substring(0, insertPosition) + `\\n${importStatement}\\n` + content.substring(insertPosition);\n }\n\n const lastImport = imports[imports.length - 1];\n const insertPosition = (lastImport.index ?? 0) + lastImport[0].length;\n return content.substring(0, insertPosition) + `\\n\\n${importStatement}` + content.substring(insertPosition);\n};\n\n// Find matching bracket position (simplified version inspired by the library method)\nconst findMatchingBracketPosition = (content: string, bracket: string, startPos: number): number => {\n const openBracket = bracket;\n const closeBracket = bracket === '{' ? '}' : bracket === '(' ? ')' : ']';\n\n let depth = 0;\n let foundOpen = false;\n\n for (let i = startPos; i < content.length; i++) {\n const char = content[i];\n if (char === openBracket) {\n foundOpen = true;\n depth++;\n } else if (char === closeBracket) {\n depth--;\n if (foundOpen && depth === 0) {\n return i;\n }\n }\n }\n return -1;\n};\n\n// Generic utility to add code to end of a method (before closing brace)\nexport const addCodeToMethod = (content: string, methodRegex: RegExp, codeToAdd: string): string => {\n const methodMatch = content.match(methodRegex);\n if (!methodMatch || methodMatch.index === undefined) return content;\n\n const methodStart = methodMatch.index;\n const methodContent = methodMatch[0];\n\n // Find the opening brace position within the method match\n const openBraceIndex = methodContent.indexOf('{');\n if (openBraceIndex === -1) return content;\n\n // Find the matching closing brace\n const absoluteOpenBracePos = methodStart + openBraceIndex;\n const closeBracePos = findMatchingBracketPosition(content, '{', absoluteOpenBracePos);\n if (closeBracePos === -1) return content;\n\n // Detect indentation of the method's opening brace line\n const linesUpToOpenBrace = content.substring(0, absoluteOpenBracePos).split('\\n');\n const braceLine = linesUpToOpenBrace[linesUpToOpenBrace.length - 1];\n const methodIndentMatch = braceLine.match(/^(\\s*)/);\n const methodIndent = methodIndentMatch ? methodIndentMatch[1] : '';\n // Assume one indentation level is two spaces if not detected from next line\n let indentLevel = ' ';\n // Try to detect indentation from the next line after the opening brace\n const afterBrace = content.substring(absoluteOpenBracePos + 1, closeBracePos);\n const afterBraceLines = afterBrace.split('\\n').filter(l => l.trim().length > 0);\n if (afterBraceLines.length > 0) {\n const nextLineIndentMatch = afterBraceLines[0].match(/^(\\s*)/);\n if (nextLineIndentMatch && nextLineIndentMatch[1].length > methodIndent.length) {\n indentLevel = nextLineIndentMatch[1].slice(methodIndent.length);\n }\n }\n const finalIndent = methodIndent + indentLevel;\n // Insert code just before the closing brace, with detected indentation\n return content.substring(0, closeBracePos) + '\\n' + finalIndent + codeToAdd + '\\n' + methodIndent + content.substring(closeBracePos);\n};\n\n// Copy template file to Android project with content transformation\nexport const copyTemplateFile = (\n expoConfig: ExportedConfigWithProps<ApplicationProjectFile>,\n filename: string,\n classPackage: string,\n patchContent: (content: string) => string,\n): void => {\n const projectRoot = expoConfig.modRequest.projectRoot;\n const mainSourceDir = path.join(projectRoot, 'android/app/src/main/java');\n const packagePath = path.join(mainSourceDir, classPackage.replace(/\\./g, '/'));\n\n try {\n FileManagement.mkdir(packagePath, { recursive: true });\n const sourcePath = path.join(getAndroidNativeFilesPath(), filename);\n const content = patchContent(FileManagement.readFile(sourcePath));\n const destinationPath = path.join(packagePath, filename);\n FileManagement.writeFile(destinationPath, content);\n } catch (error) {\n console.warn(`Failed to copy ${filename} to Android project:`, error);\n throw error;\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAAqD,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA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ApB,OAAA,CAAAU,eAAA,GAAAA,eAAA;AACO,MAAMyB,gBAAgB,GAAGA,CAC9BC,UAA2D,EAC3DC,QAAgB,EAChBC,YAAoB,EACpBC,YAAyC,KAChC;EACT,MAAMC,WAAW,GAAGJ,UAAU,CAACK,UAAU,CAACD,WAAW;EACrD,MAAME,aAAa,GAAGC,aAAI,CAACC,IAAI,CAACJ,WAAW,EAAE,2BAA2B,CAAC;EACzE,MAAMK,WAAW,GAAGF,aAAI,CAACC,IAAI,CAACF,aAAa,EAAEJ,YAAY,CAACQ,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;EAE9E,IAAI;IACFC,8BAAc,CAACC,KAAK,CAACH,WAAW,EAAE;MAAEI,SAAS,EAAE;IAAK,CAAC,CAAC;IACtD,MAAMC,UAAU,GAAGP,aAAI,CAACC,IAAI,CAAC,IAAAO,iCAAyB,EAAC,CAAC,EAAEd,QAAQ,CAAC;IACnE,MAAMnD,OAAO,GAAGqD,YAAY,CAACQ,8BAAc,CAACK,QAAQ,CAACF,UAAU,CAAC,CAAC;IACjE,MAAMG,eAAe,GAAGV,aAAI,CAACC,IAAI,CAACC,WAAW,EAAER,QAAQ,CAAC;IACxDU,8BAAc,CAACO,SAAS,CAACD,eAAe,EAAEnE,OAAO,CAAC;EACpD,CAAC,CAAC,OAAOqE,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,kBAAkBpB,QAAQ,sBAAsB,EAAEkB,KAAK,CAAC;IACrE,MAAMA,KAAK;EACb;AACF,CAAC;AAACvD,OAAA,CAAAmC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_path","_interopRequireDefault","require","_fileManagement","_logger","_plugin","e","__esModule","default","addImportToFile","content","importStatement","includes","importRegex","imports","matchAll","length","packageRegex","packageMatch","match","insertPosition","index","substring","lastImport","exports","findMatchingBracketPosition","bracket","startPos","openBracket","closeBracket","depth","foundOpen","i","char","addCodeToMethod","methodRegex","codeToAdd","methodMatch","undefined","methodStart","methodContent","openBraceIndex","indexOf","absoluteOpenBracePos","closeBracePos","linesUpToOpenBrace","split","braceLine","methodIndentMatch","methodIndent","indentLevel","afterBrace","afterBraceLines","filter","l","trim","nextLineIndentMatch","slice","finalIndent","copyTemplateFile","expoConfig","filename","classPackage","patchContent","projectRoot","modRequest","mainSourceDir","path","join","packagePath","replace","FileManagement","mkdir","recursive","sourcePath","getAndroidNativeFilesPath","readFile","destinationPath","writeFile","error","logger","warn"],"sources":["android.ts"],"sourcesContent":["import type { ExportedConfigWithProps } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport path from 'path';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { logger } from './logger';\nimport { getAndroidNativeFilesPath } from './plugin';\n\n// Generic utility to add import to Kotlin files\nexport const addImportToFile = (content: string, importStatement: string): string => {\n if (content.includes(importStatement)) {\n return content;\n }\n\n const importRegex = /^import\\s+[^\\s\\n]+.*$/gm;\n const imports = [...content.matchAll(importRegex)];\n\n if (imports.length === 0) {\n const packageRegex = /package\\s+[^\\s;]+[;\\s]*\\n/;\n const packageMatch = content.match(packageRegex);\n if (!packageMatch) return content;\n\n const insertPosition = (packageMatch.index ?? 0) + packageMatch[0].length;\n return content.substring(0, insertPosition) + `\\n${importStatement}\\n` + content.substring(insertPosition);\n }\n\n const lastImport = imports[imports.length - 1];\n const insertPosition = (lastImport.index ?? 0) + lastImport[0].length;\n return content.substring(0, insertPosition) + `\\n\\n${importStatement}` + content.substring(insertPosition);\n};\n\n// Find matching bracket position (simplified version inspired by the library method)\nconst findMatchingBracketPosition = (content: string, bracket: string, startPos: number): number => {\n const openBracket = bracket;\n const closeBracket = bracket === '{' ? '}' : bracket === '(' ? ')' : ']';\n\n let depth = 0;\n let foundOpen = false;\n\n for (let i = startPos; i < content.length; i++) {\n const char = content[i];\n if (char === openBracket) {\n foundOpen = true;\n depth++;\n } else if (char === closeBracket) {\n depth--;\n if (foundOpen && depth === 0) {\n return i;\n }\n }\n }\n return -1;\n};\n\n// Generic utility to add code to end of a method (before closing brace)\nexport const addCodeToMethod = (content: string, methodRegex: RegExp, codeToAdd: string): string => {\n const methodMatch = content.match(methodRegex);\n if (!methodMatch || methodMatch.index === undefined) return content;\n\n const methodStart = methodMatch.index;\n const methodContent = methodMatch[0];\n\n // Find the opening brace position within the method match\n const openBraceIndex = methodContent.indexOf('{');\n if (openBraceIndex === -1) return content;\n\n // Find the matching closing brace\n const absoluteOpenBracePos = methodStart + openBraceIndex;\n const closeBracePos = findMatchingBracketPosition(content, '{', absoluteOpenBracePos);\n if (closeBracePos === -1) return content;\n\n // Detect indentation of the method's opening brace line\n const linesUpToOpenBrace = content.substring(0, absoluteOpenBracePos).split('\\n');\n const braceLine = linesUpToOpenBrace[linesUpToOpenBrace.length - 1];\n const methodIndentMatch = braceLine.match(/^(\\s*)/);\n const methodIndent = methodIndentMatch ? methodIndentMatch[1] : '';\n // Assume one indentation level is two spaces if not detected from next line\n let indentLevel = ' ';\n // Try to detect indentation from the next line after the opening brace\n const afterBrace = content.substring(absoluteOpenBracePos + 1, closeBracePos);\n const afterBraceLines = afterBrace.split('\\n').filter(l => l.trim().length > 0);\n if (afterBraceLines.length > 0) {\n const nextLineIndentMatch = afterBraceLines[0].match(/^(\\s*)/);\n if (nextLineIndentMatch && nextLineIndentMatch[1].length > methodIndent.length) {\n indentLevel = nextLineIndentMatch[1].slice(methodIndent.length);\n }\n }\n const finalIndent = methodIndent + indentLevel;\n // Insert code just before the closing brace, with detected indentation\n return content.substring(0, closeBracePos) + '\\n' + finalIndent + codeToAdd + '\\n' + methodIndent + content.substring(closeBracePos);\n};\n\n// Copy template file to Android project with content transformation\nexport const copyTemplateFile = (\n expoConfig: ExportedConfigWithProps<ApplicationProjectFile>,\n filename: string,\n classPackage: string,\n patchContent: (content: string) => string,\n): void => {\n const projectRoot = expoConfig.modRequest.projectRoot;\n const mainSourceDir = path.join(projectRoot, 'android/app/src/main/java');\n const packagePath = path.join(mainSourceDir, classPackage.replace(/\\./g, '/'));\n\n try {\n FileManagement.mkdir(packagePath, { recursive: true });\n const sourcePath = path.join(getAndroidNativeFilesPath(), filename);\n const content = patchContent(FileManagement.readFile(sourcePath));\n const destinationPath = path.join(packagePath, filename);\n FileManagement.writeFile(destinationPath, content);\n } catch (error) {\n logger.warn(`Failed to copy ${filename} to Android project:`, error);\n throw error;\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAAqD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAErD;AACO,MAAMG,eAAe,GAAGA,CAACC,OAAe,EAAEC,eAAuB,KAAa;EACnF,IAAID,OAAO,CAACE,QAAQ,CAACD,eAAe,CAAC,EAAE;IACrC,OAAOD,OAAO;EAChB;EAEA,MAAMG,WAAW,GAAG,yBAAyB;EAC7C,MAAMC,OAAO,GAAG,CAAC,GAAGJ,OAAO,CAACK,QAAQ,CAACF,WAAW,CAAC,CAAC;EAElD,IAAIC,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,MAAMC,YAAY,GAAG,2BAA2B;IAChD,MAAMC,YAAY,GAAGR,OAAO,CAACS,KAAK,CAACF,YAAY,CAAC;IAChD,IAAI,CAACC,YAAY,EAAE,OAAOR,OAAO;IAEjC,MAAMU,cAAc,GAAG,CAACF,YAAY,CAACG,KAAK,IAAI,CAAC,IAAIH,YAAY,CAAC,CAAC,CAAC,CAACF,MAAM;IACzE,OAAON,OAAO,CAACY,SAAS,CAAC,CAAC,EAAEF,cAAc,CAAC,GAAG,KAAKT,eAAe,IAAI,GAAGD,OAAO,CAACY,SAAS,CAACF,cAAc,CAAC;EAC5G;EAEA,M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AQ,CAAC;IACxDU,8BAAc,CAACO,SAAS,CAACD,eAAe,EAAEnE,OAAO,CAAC;EACpD,CAAC,CAAC,OAAOqE,KAAK,EAAE;IACdC,cAAM,CAACC,IAAI,CAAC,kBAAkBpB,QAAQ,sBAAsB,EAAEkB,KAAK,CAAC;IACpE,MAAMA,KAAK;EACb;AACF,CAAC;AAACvD,OAAA,CAAAmC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.mergeConfigWithEnvValues = mergeConfigWithEnvValues;
|
|
7
|
+
var _logger = require("./logger");
|
|
7
8
|
/**
|
|
8
9
|
* Merges config values with env values for backward compatibility.
|
|
9
10
|
* If env is provided, it takes precedence. If nativeConfig is provided but env is not,
|
|
@@ -21,12 +22,12 @@ function mergeConfigWithEnvValues(props, nativeConfig) {
|
|
|
21
22
|
if (nativeCdpApiKey && envCdpApiKey) {
|
|
22
23
|
if (nativeCdpApiKey !== envCdpApiKey || (nativeRegion === null || nativeRegion === void 0 ? void 0 : nativeRegion.toLowerCase()) !== (envRegion === null || envRegion === void 0 ? void 0 : envRegion.toLowerCase())) {
|
|
23
24
|
const errorMessage = `Configuration conflict: 'config' and 'ios.pushNotification.env' values must match when both are provided.\n` + ` config.cdpApiKey: "${nativeCdpApiKey}"\n` + ` env.cdpApiKey: "${envCdpApiKey}"\n` + ` config.region: "${nativeRegion}"\n` + ` env.region: "${envRegion}"`;
|
|
24
|
-
|
|
25
|
+
_logger.logger.error(errorMessage);
|
|
25
26
|
throw new Error(errorMessage);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
// Values match - warn about redundant configuration
|
|
29
|
-
|
|
30
|
+
_logger.logger.warn(`Both 'config' and 'ios.pushNotification.env' are provided with matching values. ` + `Consider removing 'ios.pushNotification.env' since 'config' is already specified.`);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// Return config (values are guaranteed to be the same if both exist)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["mergeConfigWithEnvValues","props","nativeConfig","_props$pushNotificati","nativeCdpApiKey","cdpApiKey","nativeRegion","region","envConfig","pushNotification","env","envCdpApiKey","envRegion","toLowerCase","errorMessage","
|
|
1
|
+
{"version":3,"names":["_logger","require","mergeConfigWithEnvValues","props","nativeConfig","_props$pushNotificati","nativeCdpApiKey","cdpApiKey","nativeRegion","region","envConfig","pushNotification","env","envCdpApiKey","envRegion","toLowerCase","errorMessage","logger","error","Error","warn","undefined"],"sources":["config.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS, NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Merges config values with env values for backward compatibility.\n * If env is provided, it takes precedence. If nativeConfig is provided but env is not,\n * nativeConfig values are used. This prioritizes existing env configuration for backward compatibility.\n */\nfunction mergeConfigWithEnvValues(\n props: CustomerIOPluginOptionsIOS,\n nativeConfig?: NativeSDKConfig\n): RichPushConfig | undefined {\n const nativeCdpApiKey = nativeConfig?.cdpApiKey;\n const nativeRegion = nativeConfig?.region;\n\n const envConfig = props.pushNotification?.env;\n const envCdpApiKey = envConfig?.cdpApiKey;\n const envRegion = envConfig?.region;\n\n // Check for conflicts between env and nativeConfig\n if (nativeCdpApiKey && envCdpApiKey) {\n if (nativeCdpApiKey !== envCdpApiKey || nativeRegion?.toLowerCase() !== envRegion?.toLowerCase()) {\n const errorMessage = `Configuration conflict: 'config' and 'ios.pushNotification.env' values must match when both are provided.\\n` +\n ` config.cdpApiKey: \"${nativeCdpApiKey}\"\\n` +\n ` env.cdpApiKey: \"${envCdpApiKey}\"\\n` +\n ` config.region: \"${nativeRegion}\"\\n` +\n ` env.region: \"${envRegion}\"`;\n\n logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Values match - warn about redundant configuration\n logger.warn(\n `Both 'config' and 'ios.pushNotification.env' are provided with matching values. ` +\n `Consider removing 'ios.pushNotification.env' since 'config' is already specified.`\n );\n }\n\n // Return config (values are guaranteed to be the same if both exist)\n const cdpApiKey = nativeCdpApiKey || envCdpApiKey;\n const region = nativeRegion || envRegion;\n\n if (cdpApiKey) {\n return {\n cdpApiKey,\n region,\n };\n }\n\n return undefined;\n}\n\nexport { mergeConfigWithEnvValues };\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAC/BC,KAAiC,EACjCC,YAA8B,EACF;EAAA,IAAAC,qBAAA;EAC5B,MAAMC,eAAe,GAAGF,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,SAAS;EAC/C,MAAMC,YAAY,GAAGJ,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEK,MAAM;EAEzC,MAAMC,SAAS,IAAAL,qBAAA,GAAGF,KAAK,CAACQ,gBAAgB,cAAAN,qBAAA,uBAAtBA,qBAAA,CAAwBO,GAAG;EAC7C,MAAMC,YAAY,GAAGH,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEH,SAAS;EACzC,MAAMO,SAAS,GAAGJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAED,MAAM;;EAEnC;EACA,IAAIH,eAAe,IAAIO,YAAY,EAAE;IACnC,IAAIP,eAAe,KAAKO,YAAY,IAAI,CAAAL,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEO,WAAW,CAAC,CAAC,OAAKD,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEC,WAAW,CAAC,CAAC,GAAE;MAChG,MAAMC,YAAY,GAAG,6GAA6G,GAChI,wBAAwBV,eAAe,KAAK,GAC5C,qBAAqBO,YAAY,KAAK,GACtC,qBAAqBL,YAAY,KAAK,GACtC,kBAAkBM,SAAS,GAAG;MAEhCG,cAAM,CAACC,KAAK,CAACF,YAAY,CAAC;MAC1B,MAAM,IAAIG,KAAK,CAACH,YAAY,CAAC;IAC/B;;IAEA;IACAC,cAAM,CAACG,IAAI,CACT,kFAAkF,GAClF,mFACF,CAAC;EACH;;EAEA;EACA,MAAMb,SAAS,GAAGD,eAAe,IAAIO,YAAY;EACjD,MAAMJ,MAAM,GAAGD,YAAY,IAAIM,SAAS;EAExC,IAAIP,SAAS,EAAE;IACb,OAAO;MACLA,SAAS;MACTE;IACF,CAAC;EACH;EAEA,OAAOY,SAAS;AAClB","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logger = void 0;
|
|
7
|
+
// Use CUSTOMERIO_DEBUG_MODE if defined; otherwise enable in development mode only
|
|
8
|
+
const VERBOSE_MODE = process.env.CUSTOMERIO_DEBUG_MODE !== undefined ? process.env.CUSTOMERIO_DEBUG_MODE === 'true' : process.env.NODE_ENV === 'development';
|
|
9
|
+
const PREFIX = '[CustomerIO]';
|
|
10
|
+
const formatMessage = message => `${PREFIX} ${message}`;
|
|
11
|
+
const logger = exports.logger = {
|
|
12
|
+
format: formatMessage,
|
|
13
|
+
error: (message, ...args) => {
|
|
14
|
+
console.error(formatMessage(message), ...args);
|
|
15
|
+
},
|
|
16
|
+
warn: (message, ...args) => {
|
|
17
|
+
console.warn(formatMessage(message), ...args);
|
|
18
|
+
},
|
|
19
|
+
info: (message, ...args) => {
|
|
20
|
+
if (VERBOSE_MODE) {
|
|
21
|
+
console.info(formatMessage(message), ...args);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
log: (message, ...args) => {
|
|
25
|
+
if (VERBOSE_MODE) {
|
|
26
|
+
console.log(formatMessage(message), ...args);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
debug: (message, ...args) => {
|
|
30
|
+
if (VERBOSE_MODE) {
|
|
31
|
+
console.debug(formatMessage(message), ...args);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VERBOSE_MODE","process","env","CUSTOMERIO_DEBUG_MODE","undefined","NODE_ENV","PREFIX","formatMessage","message","logger","exports","format","error","args","console","warn","info","log","debug"],"sources":["logger.ts"],"sourcesContent":["// Use CUSTOMERIO_DEBUG_MODE if defined; otherwise enable in development mode only\nconst VERBOSE_MODE =\n process.env.CUSTOMERIO_DEBUG_MODE !== undefined\n ? process.env.CUSTOMERIO_DEBUG_MODE === 'true'\n : process.env.NODE_ENV === 'development';\nconst PREFIX = '[CustomerIO]';\nconst formatMessage = (message: string): string => `${PREFIX} ${message}`;\n\nexport const logger = {\n format: formatMessage,\n\n error: (message: string, ...args: unknown[]): void => {\n console.error(formatMessage(message), ...args);\n },\n\n warn: (message: string, ...args: unknown[]): void => {\n console.warn(formatMessage(message), ...args);\n },\n\n info: (message: string, ...args: unknown[]): void => {\n if (VERBOSE_MODE) {\n console.info(formatMessage(message), ...args);\n }\n },\n\n log: (message: string, ...args: unknown[]): void => {\n if (VERBOSE_MODE) {\n console.log(formatMessage(message), ...args);\n }\n },\n\n debug: (message: string, ...args: unknown[]): void => {\n if (VERBOSE_MODE) {\n console.debug(formatMessage(message), ...args);\n }\n }\n};\n"],"mappings":";;;;;;AAAA;AACA,MAAMA,YAAY,GAChBC,OAAO,CAACC,GAAG,CAACC,qBAAqB,KAAKC,SAAS,GAC3CH,OAAO,CAACC,GAAG,CAACC,qBAAqB,KAAK,MAAM,GAC5CF,OAAO,CAACC,GAAG,CAACG,QAAQ,KAAK,aAAa;AAC5C,MAAMC,MAAM,GAAG,cAAc;AAC7B,MAAMC,aAAa,GAAIC,OAAe,IAAa,GAAGF,MAAM,IAAIE,OAAO,EAAE;AAElE,MAAMC,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACpBE,MAAM,EAAEJ,aAAa;EAErBK,KAAK,EAAEA,CAACJ,OAAe,EAAE,GAAGK,IAAe,KAAW;IACpDC,OAAO,CAACF,KAAK,CAACL,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGK,IAAI,CAAC;EAChD,CAAC;EAEDE,IAAI,EAAEA,CAACP,OAAe,EAAE,GAAGK,IAAe,KAAW;IACnDC,OAAO,CAACC,IAAI,CAACR,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGK,IAAI,CAAC;EAC/C,CAAC;EAEDG,IAAI,EAAEA,CAACR,OAAe,EAAE,GAAGK,IAAe,KAAW;IACnD,IAAIb,YAAY,EAAE;MAChBc,OAAO,CAACE,IAAI,CAACT,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGK,IAAI,CAAC;IAC/C;EACF,CAAC;EAEDI,GAAG,EAAEA,CAACT,OAAe,EAAE,GAAGK,IAAe,KAAW;IAClD,IAAIb,YAAY,EAAE;MAChBc,OAAO,CAACG,GAAG,CAACV,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGK,IAAI,CAAC;IAC9C;EACF,CAAC;EAEDK,KAAK,EAAEA,CAACV,OAAe,EAAE,GAAGK,IAAe,KAAW;IACpD,IAAIb,YAAY,EAAE;MAChBc,OAAO,CAACI,KAAK,CAACX,aAAa,CAACC,OAAO,CAAC,EAAE,GAAGK,IAAI,CAAC;IAChD;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -4,41 +4,84 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.validateNativeSDKConfig = validateNativeSDKConfig;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
exports.validateRequired = validateRequired;
|
|
8
|
+
exports.validateRichPushConfig = validateRichPushConfig;
|
|
9
|
+
exports.validateString = validateString;
|
|
10
|
+
var _logger = require("./logger");
|
|
11
|
+
/**
|
|
12
|
+
* Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.
|
|
13
|
+
* @param isValid - Function that returns true if validation passes
|
|
14
|
+
* @param messageFactory - Function that returns the error message if validation fails
|
|
15
|
+
* @returns true if validation passes, false if it fails
|
|
16
|
+
*/
|
|
17
|
+
function validate(isValid, messageFactory) {
|
|
18
|
+
if (isValid()) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Throw errors unless explicitly disabled, default to strict validation
|
|
23
|
+
const message = messageFactory();
|
|
24
|
+
// Throw an error if strict mode is enabled, log a warning otherwise
|
|
25
|
+
if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {
|
|
26
|
+
throw new Error(_logger.logger.format(message));
|
|
27
|
+
} else {
|
|
28
|
+
_logger.logger.warn(message);
|
|
10
29
|
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
function isUndefined(value) {
|
|
33
|
+
return value === undefined;
|
|
34
|
+
}
|
|
35
|
+
function validateRequired(value, fieldName, context) {
|
|
36
|
+
return validate(() => !isUndefined(value) && value !== null, () => `${context}: ${fieldName} is required, received: ${value}`);
|
|
11
37
|
}
|
|
12
38
|
function validateString(value, fieldName, context) {
|
|
13
|
-
|
|
14
|
-
throw new Error(`${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `"${value}"` : value}`);
|
|
15
|
-
}
|
|
39
|
+
return validate(() => isUndefined(value) || typeof value === 'string' && value.trim() !== '', () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `"${value}"` : value}`);
|
|
16
40
|
}
|
|
17
41
|
function validateBoolean(value, fieldName, context) {
|
|
18
|
-
|
|
19
|
-
throw new Error(`${context}: ${fieldName} must be a boolean, received: ${value}`);
|
|
20
|
-
}
|
|
42
|
+
return validate(() => isUndefined(value) || typeof value === 'boolean', () => `${context}: ${fieldName} must be a boolean, received: ${value}`);
|
|
21
43
|
}
|
|
22
44
|
function validateEnum(value, fieldName, allowedValues, context) {
|
|
23
|
-
if (value
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const valuesStr = allowedValues.map(v => `"${v}"`).join(', ');
|
|
29
|
-
throw new Error(`${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`);
|
|
45
|
+
if (isUndefined(value)) return true;
|
|
46
|
+
|
|
47
|
+
// First validate it's a string
|
|
48
|
+
if (!validateString(value, fieldName, context)) {
|
|
49
|
+
return false;
|
|
30
50
|
}
|
|
51
|
+
|
|
52
|
+
// Then validate it's in the allowed values
|
|
53
|
+
return validate(() => {
|
|
54
|
+
const lowerValue = value.toLowerCase();
|
|
55
|
+
const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());
|
|
56
|
+
return lowerAllowedValues.includes(lowerValue);
|
|
57
|
+
}, () => {
|
|
58
|
+
const valuesStr = allowedValues.map(v => `"${v}"`).join(', ');
|
|
59
|
+
return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function validateRegion(value, fieldName, context) {
|
|
63
|
+
return validateEnum(value, fieldName, ['US', 'EU'], context);
|
|
31
64
|
}
|
|
32
65
|
function validateNativeSDKConfig(config) {
|
|
33
66
|
const context = 'NativeSDKConfig';
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
validateEnum(config.
|
|
39
|
-
|
|
40
|
-
validateBoolean(config.
|
|
41
|
-
|
|
42
|
-
validateString(config.
|
|
67
|
+
let isValid = true;
|
|
68
|
+
isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;
|
|
69
|
+
isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;
|
|
70
|
+
isValid = validateRegion(config.region, 'region', context) && isValid;
|
|
71
|
+
isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;
|
|
72
|
+
isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;
|
|
73
|
+
isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;
|
|
74
|
+
isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;
|
|
75
|
+
isValid = validateString(config.siteId, 'siteId', context) && isValid;
|
|
76
|
+
isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;
|
|
77
|
+
return isValid;
|
|
78
|
+
}
|
|
79
|
+
function validateRichPushConfig(config) {
|
|
80
|
+
const context = 'NotificationServiceExtension';
|
|
81
|
+
let isValid = true;
|
|
82
|
+
isValid = validateRequired(config === null || config === void 0 ? void 0 : config.cdpApiKey, 'cdpApiKey', context) && isValid;
|
|
83
|
+
isValid = validateString(config === null || config === void 0 ? void 0 : config.cdpApiKey, 'cdpApiKey', context) && isValid;
|
|
84
|
+
isValid = validateRegion(config === null || config === void 0 ? void 0 : config.region, 'region', context) && isValid;
|
|
85
|
+
return isValid;
|
|
43
86
|
}
|
|
44
87
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_logger","require","validate","isValid","messageFactory","message","process","env","CUSTOMERIO_STRICT_MODE","Error","logger","format","warn","isUndefined","value","undefined","validateRequired","fieldName","context","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateRegion","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId","validateRichPushConfig"],"sources":["validation.ts"],"sourcesContent":["import type { NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.\n * @param isValid - Function that returns true if validation passes\n * @param messageFactory - Function that returns the error message if validation fails\n * @returns true if validation passes, false if it fails\n */\nfunction validate(isValid: () => boolean, messageFactory: () => string): boolean {\n if (isValid()) {\n return true;\n }\n\n // Throw errors unless explicitly disabled, default to strict validation\n const message = messageFactory();\n // Throw an error if strict mode is enabled, log a warning otherwise\n if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {\n throw new Error(logger.format(message));\n } else {\n logger.warn(message);\n }\n return false;\n}\n\nfunction isUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => !isUndefined(value) && value !== null,\n () => `${context}: ${fieldName} is required, received: ${value}`\n );\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || (typeof value === 'string' && value.trim() !== ''),\n () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `\"${value}\"` : value}`\n );\n}\n\nfunction validateBoolean(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || typeof value === 'boolean',\n () => `${context}: ${fieldName} must be a boolean, received: ${value}`\n );\n}\n\nfunction validateEnum<T extends string>(\n value: unknown,\n fieldName: string,\n allowedValues: readonly T[],\n context: string\n): boolean {\n if (isUndefined(value)) return true;\n\n // First validate it's a string\n if (!validateString(value, fieldName, context)) {\n return false;\n }\n\n // Then validate it's in the allowed values\n return validate(\n () => {\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n return lowerAllowedValues.includes(lowerValue);\n },\n () => {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;\n }\n );\n}\n\nfunction validateRegion(value: unknown, fieldName: string, context: string): boolean {\n return validateEnum(value, fieldName, ['US', 'EU'], context);\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): boolean {\n const context = 'NativeSDKConfig';\n\n let isValid = true;\n\n isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config.region, 'region', context) && isValid;\n isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;\n isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;\n isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;\n isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;\n isValid = validateString(config.siteId, 'siteId', context) && isValid;\n isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;\n\n return isValid;\n}\n\nfunction validateRichPushConfig(config: RichPushConfig | undefined): boolean {\n const context = 'NotificationServiceExtension';\n\n let isValid = true;\n\n isValid = validateRequired(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config?.region, 'region', context) && isValid;\n\n return isValid;\n}\n\nexport {\n validateNativeSDKConfig,\n validateRequired,\n validateRichPushConfig,\n validateString\n};\n\n"],"mappings":";;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAACC,OAAsB,EAAEC,cAA4B,EAAW;EAC/E,IAAID,OAAO,CAAC,CAAC,EAAE;IACb,OAAO,IAAI;EACb;;EAEA;EACA,MAAME,OAAO,GAAGD,cAAc,CAAC,CAAC;EAChC;EACA,IAAIE,OAAO,CAACC,GAAG,CAACC,sBAAsB,KAAK,MAAM,EAAE;IACjD,MAAM,IAAIC,KAAK,CAACC,cAAM,CAACC,MAAM,CAACN,OAAO,CAAC,CAAC;EACzC,CAAC,MAAM;IACLK,cAAM,CAACE,IAAI,CAACP,OAAO,CAAC;EACtB;EACA,OAAO,KAAK;AACd;AAEA,SAASQ,WAAWA,CAACC,KAAc,EAAW;EAC5C,OAAOA,KAAK,KAAKC,SAAS;AAC5B;AAEA,SAASC,gBAAgBA,CAACF,KAAc,EAAEG,SAAiB,EAAE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AAe,CAACa,MAAM,CAACM,+BAA+B,EAAE,iCAAiC,EAAEtB,OAAO,CAAC,IAAIf,OAAO;EACxHA,OAAO,GAAGgB,cAAc,CAACe,MAAM,CAACO,MAAM,EAAE,QAAQ,EAAEvB,OAAO,CAAC,IAAIf,OAAO;EACrEA,OAAO,GAAGgB,cAAc,CAACe,MAAM,CAACQ,eAAe,EAAE,iBAAiB,EAAExB,OAAO,CAAC,IAAIf,OAAO;EAEvF,OAAOA,OAAO;AAChB;AAEA,SAASwC,sBAAsBA,CAACT,MAAkC,EAAW;EAC3E,MAAMhB,OAAO,GAAG,8BAA8B;EAE9C,IAAIf,OAAO,GAAG,IAAI;EAElBA,OAAO,GAAGa,gBAAgB,CAACkB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEC,SAAS,EAAE,WAAW,EAAEjB,OAAO,CAAC,IAAIf,OAAO;EAC9EA,OAAO,GAAGgB,cAAc,CAACe,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEC,SAAS,EAAE,WAAW,EAAEjB,OAAO,CAAC,IAAIf,OAAO;EAC5EA,OAAO,GAAG6B,cAAc,CAACE,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,EAAE,QAAQ,EAAElB,OAAO,CAAC,IAAIf,OAAO;EAEtE,OAAOA,OAAO;AAChB","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ exports.copyFileToXcode = copyFileToXcode;
|
|
|
7
7
|
exports.getOrCreateCustomerIOGroup = getOrCreateCustomerIOGroup;
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
10
|
+
var _logger = require("./logger");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
/**
|
|
12
13
|
* Gets an existing CustomerIO group or creates a new one in the Xcode project
|
|
@@ -60,7 +61,7 @@ function copyFileToXcode({
|
|
|
60
61
|
xcodeProject.addSourceFile(`${projectName}/${targetFileName}`, null, customerIOGroup);
|
|
61
62
|
return destinationPath;
|
|
62
63
|
} catch (error) {
|
|
63
|
-
|
|
64
|
+
_logger.logger.warn(`Failed to add ${targetFileName} to Xcode project:`, error);
|
|
64
65
|
throw error;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_path","_interopRequireDefault","require","_fileManagement","e","__esModule","default","getOrCreateCustomerIOGroup","xcodeProject","projectName","customerIOGroup","pbxGroupByName","pbxCreateGroup","projectGroupKey","findPBXGroupKey","name","addToPbxGroup","copyFileToXcode","iosProjectRoot","sourceFilePath","targetFileName","transform","destinationPath","path","join","content","FileManagement","readFile","writeFile","addSourceFile","error","
|
|
1
|
+
{"version":3,"names":["_path","_interopRequireDefault","require","_fileManagement","_logger","e","__esModule","default","getOrCreateCustomerIOGroup","xcodeProject","projectName","customerIOGroup","pbxGroupByName","pbxCreateGroup","projectGroupKey","findPBXGroupKey","name","addToPbxGroup","copyFileToXcode","iosProjectRoot","sourceFilePath","targetFileName","transform","destinationPath","path","join","content","FileManagement","readFile","writeFile","addSourceFile","error","logger","warn"],"sources":["xcode.ts"],"sourcesContent":["import type { XcodeProject } from \"@expo/config-plugins\";\nimport path from 'path';\nimport { FileManagement } from \"../helpers/utils/fileManagement\";\nimport { logger } from './logger';\n\n/**\n * Gets an existing CustomerIO group or creates a new one in the Xcode project\n * @param xcodeProject The Xcode project instance\n * @param projectName The iOS project name\n * @returns The CustomerIO group reference\n */\nexport function getOrCreateCustomerIOGroup(\n xcodeProject: XcodeProject,\n projectName: string,\n): XcodeProject['pbxCreateGroup'] {\n // Check if CustomerIO group already exists\n let customerIOGroup = xcodeProject.pbxGroupByName('CustomerIO');\n if (customerIOGroup) {\n return customerIOGroup;\n }\n\n // Create new CustomerIO group and add it to the project\n customerIOGroup = xcodeProject.pbxCreateGroup('CustomerIO');\n const projectGroupKey = xcodeProject.findPBXGroupKey({ name: projectName });\n xcodeProject.addToPbxGroup(customerIOGroup, projectGroupKey);\n return customerIOGroup;\n}\n\n/**\n * Copies template file to iOS project, applies transformations, and registers with Xcode\n * @param params.xcodeProject Xcode project instance\n * @param params.iosProjectRoot iOS project root path\n * @param params.projectName iOS project name\n * @param params.sourceFilePath Source template file path\n * @param params.targetFileName Target file name\n * @param params.transform Content transformation function\n * @param params.customerIOGroup CustomerIO group (auto-created if not provided)\n * @returns Destination file path\n */\nexport function copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath,\n targetFileName,\n transform,\n customerIOGroup = getOrCreateCustomerIOGroup(xcodeProject, projectName),\n}: {\n xcodeProject: XcodeProject;\n iosProjectRoot: string;\n projectName: string;\n sourceFilePath: string;\n targetFileName: string;\n transform: (content: string) => string;\n customerIOGroup?: XcodeProject['pbxCreateGroup'];\n}): string {\n // Construct the full destination path within the iOS project directory\n const destinationPath = path.join(\n iosProjectRoot,\n projectName,\n targetFileName\n );\n\n try {\n // Read template, apply transformations, and write to project\n const content = transform(FileManagement.readFile(sourceFilePath));\n FileManagement.writeFile(destinationPath, content);\n // Register file with Xcode project\n xcodeProject.addSourceFile(`${projectName}/${targetFileName}`, null, customerIOGroup);\n return destinationPath;\n } catch (error) {\n logger.warn(`Failed to add ${targetFileName} to Xcode project:`, error);\n throw error;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAAkC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElC;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,0BAA0BA,CACxCC,YAA0B,EAC1BC,WAAmB,EACa;EAChC;EACA,IAAIC,eAAe,GAAGF,YAAY,CAACG,cAAc,CAAC,YAAY,CAAC;EAC/D,IAAID,eAAe,EAAE;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