From 1309b750853cba259f34f10edf1e1f2a480e6965 Mon Sep 17 00:00:00 2001 From: Mihai Blaga Date: Tue, 10 Oct 2023 14:46:54 +0300 Subject: [PATCH] moved adapter to sdk-react-native --- packages/engine-rn-macos/src/index.ts | 2 +- .../src/adapters/rnConfigAdapter.ts | 64 ------------------- packages/engine-rn-tvos/src/index.ts | 2 +- .../src/adapters/rnConfigAdapter.ts | 64 ------------------- packages/engine-rn-windows/src/index.ts | 2 +- .../engine-rn/src/adapters/rnConfigAdapter.ts | 64 ------------------- packages/engine-rn/src/index.ts | 2 +- .../src/adapters.ts} | 0 packages/sdk-react-native/src/index.ts | 1 + 9 files changed, 5 insertions(+), 196 deletions(-) delete mode 100644 packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts delete mode 100644 packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts delete mode 100644 packages/engine-rn/src/adapters/rnConfigAdapter.ts rename packages/{engine-rn-macos/src/adapters/rnConfigAdapter.ts => sdk-react-native/src/adapters.ts} (100%) diff --git a/packages/engine-rn-macos/src/index.ts b/packages/engine-rn-macos/src/index.ts index 15aec734e2..947cce21e8 100644 --- a/packages/engine-rn-macos/src/index.ts +++ b/packages/engine-rn-macos/src/index.ts @@ -1,7 +1,6 @@ import { generateEngineExtensions, generateEngineTasks, RnvEngine } from '@rnv/core'; import { withRNVMetro } from './adapters/metroAdapter'; import { withRNVBabel } from './adapters/babelAdapter'; -import { withRNVRNConfig } from './adapters/rnConfigAdapter'; //@ts-ignore import CNF from '../renative.engine.json'; import taskRnvRun from './tasks/task.rnv.run'; @@ -11,6 +10,7 @@ import taskRnvConfigure from './tasks/task.rnv.configure'; import taskRnvStart from './tasks/task.rnv.start'; import taskRnvExport from './tasks/task.rnv.export'; import taskRnvDeploy from './tasks/task.rnv.deploy'; +import { withRNVRNConfig } from "@rnv/sdk-react-native"; // import taskRnvLog from './tasks/task.rnv.log'; const Engine: RnvEngine = { diff --git a/packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts b/packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts deleted file mode 100644 index 56994658b7..0000000000 --- a/packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts +++ /dev/null @@ -1,64 +0,0 @@ -import merge from 'deepmerge'; - -const getApplicationId = () => { - const appId = process.env.RNV_APP_ID; - return appId; -}; - -const getAppFolderRelative = () => { - const pth = process.env.RNV_APP_BUILD_DIR; - if (pth) { - return pth; - } else { - const cwd = process.cwd(); - if (cwd.includes('platformBuilds/')) { - const dir = process.cwd().split('platformBuilds/')[1]; - - return `platformBuilds/${dir}`; - } else { - return undefined; - } - } -}; - -const getReactNativePathRelative = () => { - const rnPath = process.env.RNV_REACT_NATIVE_PATH; - return rnPath; -}; - -const getProjectRoot = () => { - //env: PROJECT_ROOT - const rnPath = process.env.RNV_PROJECT_ROOT; - return rnPath; -}; - -export const withRNVRNConfig = (config: any) => { - const cnfRnv = { - root: getProjectRoot(), - //Required to support 2 react native instances - reactNativePath: getReactNativePathRelative(), - dependencies: { - // Required for Expo CLI to be used with platforms (such as Apple TV) that are not supported in Expo SDK - expo: { - platforms: { - android: null, - ios: null, - macos: null, - }, - }, - }, - project: { - ios: { - sourceDir: getAppFolderRelative(), - }, - android: { - appName: 'app', - sourceDir: getAppFolderRelative(), - packageName: getApplicationId(), - }, - }, - }; - - const cnf = merge(cnfRnv, config); - return cnf; -}; diff --git a/packages/engine-rn-tvos/src/index.ts b/packages/engine-rn-tvos/src/index.ts index 7ac27a7d67..616e74fda6 100644 --- a/packages/engine-rn-tvos/src/index.ts +++ b/packages/engine-rn-tvos/src/index.ts @@ -16,7 +16,7 @@ import taskRnvLog from './tasks/task.rnv.log'; import CNF from '../renative.engine.json'; import { withRNVBabel } from './adapters/babelAdapter'; import { withRNVMetro } from './adapters/metroAdapter'; -import { withRNVRNConfig } from './adapters/rnConfigAdapter'; +import { withRNVRNConfig } from "@rnv/sdk-react-native"; const Engine: RnvEngine = { // initializeRuntimeConfig: (c) => Context.initializeConfig(c), diff --git a/packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts b/packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts deleted file mode 100644 index 56994658b7..0000000000 --- a/packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts +++ /dev/null @@ -1,64 +0,0 @@ -import merge from 'deepmerge'; - -const getApplicationId = () => { - const appId = process.env.RNV_APP_ID; - return appId; -}; - -const getAppFolderRelative = () => { - const pth = process.env.RNV_APP_BUILD_DIR; - if (pth) { - return pth; - } else { - const cwd = process.cwd(); - if (cwd.includes('platformBuilds/')) { - const dir = process.cwd().split('platformBuilds/')[1]; - - return `platformBuilds/${dir}`; - } else { - return undefined; - } - } -}; - -const getReactNativePathRelative = () => { - const rnPath = process.env.RNV_REACT_NATIVE_PATH; - return rnPath; -}; - -const getProjectRoot = () => { - //env: PROJECT_ROOT - const rnPath = process.env.RNV_PROJECT_ROOT; - return rnPath; -}; - -export const withRNVRNConfig = (config: any) => { - const cnfRnv = { - root: getProjectRoot(), - //Required to support 2 react native instances - reactNativePath: getReactNativePathRelative(), - dependencies: { - // Required for Expo CLI to be used with platforms (such as Apple TV) that are not supported in Expo SDK - expo: { - platforms: { - android: null, - ios: null, - macos: null, - }, - }, - }, - project: { - ios: { - sourceDir: getAppFolderRelative(), - }, - android: { - appName: 'app', - sourceDir: getAppFolderRelative(), - packageName: getApplicationId(), - }, - }, - }; - - const cnf = merge(cnfRnv, config); - return cnf; -}; diff --git a/packages/engine-rn-windows/src/index.ts b/packages/engine-rn-windows/src/index.ts index b1876655e1..69bebfea02 100644 --- a/packages/engine-rn-windows/src/index.ts +++ b/packages/engine-rn-windows/src/index.ts @@ -1,7 +1,6 @@ import { RnvEngine, generateEngineTasks, generateEngineExtensions } from '@rnv/core'; import { withRNVMetro } from './adapters/metroAdapter'; import { withRNVBabel } from './adapters/babelAdapter'; -import { withRNVRNConfig } from './adapters/rnConfigAdapter'; //@ts-ignore import CNF from '../renative.engine.json'; import taskRnvBuild from './tasks/task.rnv.build'; @@ -12,6 +11,7 @@ import taskRnvExport from './tasks/task.rnv.export'; import taskRnvPackage from './tasks/task.rnv.package'; import taskRnvRun from './tasks/task.rnv.run'; import taskRnvStart from './tasks/task.rnv.start'; +import { withRNVRNConfig } from "@rnv/sdk-react-native"; const Engine: RnvEngine = { // initializeRuntimeConfig: (c) => Context.initializeConfig(c), diff --git a/packages/engine-rn/src/adapters/rnConfigAdapter.ts b/packages/engine-rn/src/adapters/rnConfigAdapter.ts deleted file mode 100644 index 56994658b7..0000000000 --- a/packages/engine-rn/src/adapters/rnConfigAdapter.ts +++ /dev/null @@ -1,64 +0,0 @@ -import merge from 'deepmerge'; - -const getApplicationId = () => { - const appId = process.env.RNV_APP_ID; - return appId; -}; - -const getAppFolderRelative = () => { - const pth = process.env.RNV_APP_BUILD_DIR; - if (pth) { - return pth; - } else { - const cwd = process.cwd(); - if (cwd.includes('platformBuilds/')) { - const dir = process.cwd().split('platformBuilds/')[1]; - - return `platformBuilds/${dir}`; - } else { - return undefined; - } - } -}; - -const getReactNativePathRelative = () => { - const rnPath = process.env.RNV_REACT_NATIVE_PATH; - return rnPath; -}; - -const getProjectRoot = () => { - //env: PROJECT_ROOT - const rnPath = process.env.RNV_PROJECT_ROOT; - return rnPath; -}; - -export const withRNVRNConfig = (config: any) => { - const cnfRnv = { - root: getProjectRoot(), - //Required to support 2 react native instances - reactNativePath: getReactNativePathRelative(), - dependencies: { - // Required for Expo CLI to be used with platforms (such as Apple TV) that are not supported in Expo SDK - expo: { - platforms: { - android: null, - ios: null, - macos: null, - }, - }, - }, - project: { - ios: { - sourceDir: getAppFolderRelative(), - }, - android: { - appName: 'app', - sourceDir: getAppFolderRelative(), - packageName: getApplicationId(), - }, - }, - }; - - const cnf = merge(cnfRnv, config); - return cnf; -}; diff --git a/packages/engine-rn/src/index.ts b/packages/engine-rn/src/index.ts index 6e25acd260..879c7815b4 100644 --- a/packages/engine-rn/src/index.ts +++ b/packages/engine-rn/src/index.ts @@ -1,6 +1,5 @@ import { withRNVMetro } from './adapters/metroAdapter'; import { withRNVBabel } from './adapters/babelAdapter'; -import { withRNVRNConfig } from './adapters/rnConfigAdapter'; //@ts-ignore import CNF from '../renative.engine.json'; @@ -19,6 +18,7 @@ import taskRnvCryptoInstallProfiles from './tasks/task.rnv.crypto.installProfile import taskRnvLog from './tasks/task.rnv.log'; import taskRnvEject from './tasks/task.rnv.eject'; import { generateEngineExtensions, generateEngineTasks, RnvEngine } from '@rnv/core'; +import { withRNVRNConfig } from "@rnv/sdk-react-native"; const Engine: RnvEngine = { // initializeRuntimeConfig: (c) => Context.initializeConfig(c), diff --git a/packages/engine-rn-macos/src/adapters/rnConfigAdapter.ts b/packages/sdk-react-native/src/adapters.ts similarity index 100% rename from packages/engine-rn-macos/src/adapters/rnConfigAdapter.ts rename to packages/sdk-react-native/src/adapters.ts diff --git a/packages/sdk-react-native/src/index.ts b/packages/sdk-react-native/src/index.ts index 28dba46a3e..7e043d5b4d 100644 --- a/packages/sdk-react-native/src/index.ts +++ b/packages/sdk-react-native/src/index.ts @@ -1,3 +1,4 @@ export * from './common'; export * from './androidRunner'; export * from './iosRunner'; +export * from './adapters';