From 8f551d3948cf33267220b58d5c6271b97db15594 Mon Sep 17 00:00:00 2001 From: Segun Folowosele Date: Thu, 6 Jul 2023 23:56:35 +0400 Subject: [PATCH] fix: path fix for monorepo support (#91) path fix for monorepo support --- src/helpers/constants/ios.ts | 10 ++++++++++ src/helpers/utils/injectCIOPodfileCode.ts | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/helpers/constants/ios.ts b/src/helpers/constants/ios.ts index 9f48f38..220df89 100644 --- a/src/helpers/constants/ios.ts +++ b/src/helpers/constants/ios.ts @@ -6,10 +6,20 @@ let pluginPackageRoot = f.next().filename; // This is the path to the root of the customerio-expo-plugin package pluginPackageRoot = path.dirname(pluginPackageRoot); +export const LOCAL_PATH_TO_RN_SDK = path.join( + pluginPackageRoot, + '../customerio-reactnative' +) + export const LOCAL_PATH_TO_CIO_NSE_FILES = path.join( pluginPackageRoot, 'src/helpers/native-files/ios' ); + +export function getRelativePathToRNSDK(currentFile: string) { + return path.relative(path.dirname(currentFile), LOCAL_PATH_TO_RN_SDK); +} + export const IOS_DEPLOYMENT_TARGET = '13.0'; export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm; export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm; diff --git a/src/helpers/utils/injectCIOPodfileCode.ts b/src/helpers/utils/injectCIOPodfileCode.ts index 26b3d81..cba11fa 100644 --- a/src/helpers/utils/injectCIOPodfileCode.ts +++ b/src/helpers/utils/injectCIOPodfileCode.ts @@ -1,4 +1,5 @@ import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types'; +import { getRelativePathToRNSDK } from '../constants/ios'; import { injectCodeByRegex } from './codeInjection'; import { FileManagement } from './fileManagement'; @@ -18,7 +19,7 @@ export async function injectCIOPodfileCode(iosPath: string) { const snippetToInjectInPodfile = ` ${blockStart} - pod 'customerio-reactnative/apn', :path => '../node_modules/customerio-reactnative' + pod 'customerio-reactnative/apn', :path => '${getRelativePathToRNSDK(filename)}' ${blockEnd} `.trim(); @@ -52,7 +53,7 @@ export async function injectCIONotificationPodfileCode( ${blockStart} target 'NotificationService' do ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''} - pod 'customerio-reactnative-richpush/apn', :path => '../node_modules/customerio-reactnative' + pod 'customerio-reactnative-richpush/apn', :path => '${getRelativePathToRNSDK(filename)}' end ${blockEnd} `.trim();