From 68b1b0682e9dd0ce93f6f78934f2b88f8a6a67e2 Mon Sep 17 00:00:00 2001 From: Mihai Blaga Date: Tue, 10 Oct 2023 14:02:52 +0300 Subject: [PATCH 1/2] added withRnvRNConfig, added missing files to template --- .../src/adapters/babelAdapter.ts | 18 ++++ .../{adapter.ts => adapters/metroAdapter.ts} | 19 ----- .../src/adapters/rnConfigAdapter.ts | 64 ++++++++++++++ packages/engine-rn-macos/src/index.ts | 6 +- .../src/adapters/babelAdapter.ts | 18 ++++ .../{adapter.ts => adapters/nextAdapter.ts} | 19 ----- packages/engine-rn-next/src/index.ts | 3 +- .../src/adapters/rnConfigAdapter.ts | 64 ++++++++++++++ packages/engine-rn-tvos/src/index.ts | 3 +- .../src/adapters/babelAdapter.ts | 18 ++++ .../{adapter.ts => adapters/metroAdapter.ts} | 18 ---- .../src/adapters/rnConfigAdapter.ts | 64 ++++++++++++++ packages/engine-rn-windows/src/index.ts | 6 +- .../engine-rn/src/adapters/rnConfigAdapter.ts | 64 ++++++++++++++ packages/engine-rn/src/index.ts | 3 +- packages/rnv/src/adapter/index.ts | 11 +++ packages/template-starter/Gemfile.lock | 1 + packages/template-starter/package.json | 8 +- .../template-starter/react-native.config.js | 85 +------------------ 19 files changed, 345 insertions(+), 147 deletions(-) create mode 100644 packages/engine-rn-macos/src/adapters/babelAdapter.ts rename packages/engine-rn-macos/src/{adapter.ts => adapters/metroAdapter.ts} (85%) create mode 100644 packages/engine-rn-macos/src/adapters/rnConfigAdapter.ts create mode 100644 packages/engine-rn-next/src/adapters/babelAdapter.ts rename packages/engine-rn-next/src/{adapter.ts => adapters/nextAdapter.ts} (90%) create mode 100644 packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts create mode 100644 packages/engine-rn-windows/src/adapters/babelAdapter.ts rename packages/engine-rn-windows/src/{adapter.ts => adapters/metroAdapter.ts} (86%) create mode 100644 packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts create mode 100644 packages/engine-rn/src/adapters/rnConfigAdapter.ts diff --git a/packages/engine-rn-macos/src/adapters/babelAdapter.ts b/packages/engine-rn-macos/src/adapters/babelAdapter.ts new file mode 100644 index 0000000000..cbbe874722 --- /dev/null +++ b/packages/engine-rn-macos/src/adapters/babelAdapter.ts @@ -0,0 +1,18 @@ +export const withRNVBabel = (cnf: any) => { + const plugins = cnf?.plugins || []; + + return { + retainLines: true, + presets: ['module:metro-react-native-babel-preset'], + ...cnf, + plugins: [ + [ + require.resolve('babel-plugin-module-resolver'), + { + root: [process.env.RNV_MONO_ROOT || '.'], + }, + ], + ...plugins, + ], + }; +}; diff --git a/packages/engine-rn-macos/src/adapter.ts b/packages/engine-rn-macos/src/adapters/metroAdapter.ts similarity index 85% rename from packages/engine-rn-macos/src/adapter.ts rename to packages/engine-rn-macos/src/adapters/metroAdapter.ts index bb3c8f802b..d6f3cfd536 100644 --- a/packages/engine-rn-macos/src/adapter.ts +++ b/packages/engine-rn-macos/src/adapters/metroAdapter.ts @@ -75,22 +75,3 @@ export const withRNVMetro = (config: any) => { return cnf; }; - -export const withRNVBabel = (cnf: any) => { - const plugins = cnf?.plugins || []; - - return { - retainLines: true, - presets: ['module:metro-react-native-babel-preset'], - ...cnf, - plugins: [ - [ - require.resolve('babel-plugin-module-resolver'), - { - root: [process.env.RNV_MONO_ROOT || '.'], - }, - ], - ...plugins, - ], - }; -}; diff --git a/packages/engine-rn-macos/src/adapters/rnConfigAdapter.ts b/packages/engine-rn-macos/src/adapters/rnConfigAdapter.ts new file mode 100644 index 0000000000..56994658b7 --- /dev/null +++ b/packages/engine-rn-macos/src/adapters/rnConfigAdapter.ts @@ -0,0 +1,64 @@ +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-macos/src/index.ts b/packages/engine-rn-macos/src/index.ts index 6fd2bbcb10..15aec734e2 100644 --- a/packages/engine-rn-macos/src/index.ts +++ b/packages/engine-rn-macos/src/index.ts @@ -1,5 +1,7 @@ import { generateEngineExtensions, generateEngineTasks, RnvEngine } from '@rnv/core'; -import { withRNVBabel, withRNVMetro } from './adapter'; +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'; @@ -45,6 +47,6 @@ const Engine: RnvEngine = { // Backward compatibility const withRNV = withRNVMetro; -export { withRNV, withRNVMetro, withRNVBabel }; +export { withRNV, withRNVMetro, withRNVBabel, withRNVRNConfig }; export default Engine; diff --git a/packages/engine-rn-next/src/adapters/babelAdapter.ts b/packages/engine-rn-next/src/adapters/babelAdapter.ts new file mode 100644 index 0000000000..3f9c7b487f --- /dev/null +++ b/packages/engine-rn-next/src/adapters/babelAdapter.ts @@ -0,0 +1,18 @@ +export const withRNVBabel = (cnf: any) => { + const plugins = cnf?.plugins || []; + + return { + retainLines: true, + presets: ['module:babel-preset-expo'], + ...cnf, + plugins: [ + [ + require.resolve('babel-plugin-module-resolver'), + { + root: [process.env.RNV_MONO_ROOT || '.'], + }, + ], + ...plugins, + ], + }; +}; diff --git a/packages/engine-rn-next/src/adapter.ts b/packages/engine-rn-next/src/adapters/nextAdapter.ts similarity index 90% rename from packages/engine-rn-next/src/adapter.ts rename to packages/engine-rn-next/src/adapters/nextAdapter.ts index bcabc8d201..3b8b16b18d 100644 --- a/packages/engine-rn-next/src/adapter.ts +++ b/packages/engine-rn-next/src/adapters/nextAdapter.ts @@ -99,22 +99,3 @@ export const withRNVNext = (config: any, opts: any) => { return cnf1; }; - -export const withRNVBabel = (cnf: any) => { - const plugins = cnf?.plugins || []; - - return { - retainLines: true, - presets: ['module:babel-preset-expo'], - ...cnf, - plugins: [ - [ - require.resolve('babel-plugin-module-resolver'), - { - root: [process.env.RNV_MONO_ROOT || '.'], - }, - ], - ...plugins, - ], - }; -}; diff --git a/packages/engine-rn-next/src/index.ts b/packages/engine-rn-next/src/index.ts index a01fe7968d..00c3f25350 100644 --- a/packages/engine-rn-next/src/index.ts +++ b/packages/engine-rn-next/src/index.ts @@ -1,5 +1,6 @@ import { generateEngineExtensions, generateEngineTasks, RnvEngine } from '@rnv/core'; -import { withRNVNext, withRNVBabel } from './adapter'; +import { withRNVNext } from './adapters/nextAdapter'; +import { withRNVBabel } from './adapters/babelAdapter'; //@ts-ignore import CNF from '../renative.engine.json'; import taskRnvRun from './tasks/task.rnv.run'; diff --git a/packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts b/packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts new file mode 100644 index 0000000000..56994658b7 --- /dev/null +++ b/packages/engine-rn-tvos/src/adapters/rnConfigAdapter.ts @@ -0,0 +1,64 @@ +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 cb7f5bc2d1..7ac27a7d67 100644 --- a/packages/engine-rn-tvos/src/index.ts +++ b/packages/engine-rn-tvos/src/index.ts @@ -16,6 +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'; const Engine: RnvEngine = { // initializeRuntimeConfig: (c) => Context.initializeConfig(c), @@ -68,6 +69,6 @@ const Engine: RnvEngine = { const withRNV = withRNVMetro; -export { withRNVMetro, withRNV, withRNVBabel }; +export { withRNVMetro, withRNV, withRNVBabel, withRNVRNConfig }; export default Engine; diff --git a/packages/engine-rn-windows/src/adapters/babelAdapter.ts b/packages/engine-rn-windows/src/adapters/babelAdapter.ts new file mode 100644 index 0000000000..98981565e3 --- /dev/null +++ b/packages/engine-rn-windows/src/adapters/babelAdapter.ts @@ -0,0 +1,18 @@ +export const withRNVBabel = (cnf: any) => { + const plugins = cnf?.plugins || []; + + return { + retainLines: true, + presets: ['module:metro-react-native-babel-preset'], + ...cnf, + plugins: [ + [ + require.resolve('babel-plugin-module-resolver'), + { + root: [process.env.RNV_MONO_ROOT || '.'], + }, + ], + ...plugins, + ], + }; +}; \ No newline at end of file diff --git a/packages/engine-rn-windows/src/adapter.ts b/packages/engine-rn-windows/src/adapters/metroAdapter.ts similarity index 86% rename from packages/engine-rn-windows/src/adapter.ts rename to packages/engine-rn-windows/src/adapters/metroAdapter.ts index 0782910769..8fcdea9d8f 100644 --- a/packages/engine-rn-windows/src/adapter.ts +++ b/packages/engine-rn-windows/src/adapters/metroAdapter.ts @@ -83,21 +83,3 @@ export const withRNVMetro = (config: any) => { return cnf; }; -export const withRNVBabel = (cnf: any) => { - const plugins = cnf?.plugins || []; - - return { - retainLines: true, - presets: ['module:metro-react-native-babel-preset'], - ...cnf, - plugins: [ - [ - require.resolve('babel-plugin-module-resolver'), - { - root: [process.env.RNV_MONO_ROOT || '.'], - }, - ], - ...plugins, - ], - }; -}; diff --git a/packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts b/packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts new file mode 100644 index 0000000000..56994658b7 --- /dev/null +++ b/packages/engine-rn-windows/src/adapters/rnConfigAdapter.ts @@ -0,0 +1,64 @@ +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 cab86913b2..b1876655e1 100644 --- a/packages/engine-rn-windows/src/index.ts +++ b/packages/engine-rn-windows/src/index.ts @@ -1,5 +1,7 @@ import { RnvEngine, generateEngineTasks, generateEngineExtensions } from '@rnv/core'; -import { withRNVBabel, withRNVMetro } from './adapter'; +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'; @@ -43,6 +45,6 @@ const Engine: RnvEngine = { // Backward compatibility const withRNV = withRNVMetro; -export { withRNV, withRNVMetro, withRNVBabel }; +export { withRNV, withRNVMetro, withRNVBabel, withRNVRNConfig }; export default Engine; diff --git a/packages/engine-rn/src/adapters/rnConfigAdapter.ts b/packages/engine-rn/src/adapters/rnConfigAdapter.ts new file mode 100644 index 0000000000..56994658b7 --- /dev/null +++ b/packages/engine-rn/src/adapters/rnConfigAdapter.ts @@ -0,0 +1,64 @@ +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 02cd8407ef..6e25acd260 100644 --- a/packages/engine-rn/src/index.ts +++ b/packages/engine-rn/src/index.ts @@ -1,5 +1,6 @@ import { withRNVMetro } from './adapters/metroAdapter'; import { withRNVBabel } from './adapters/babelAdapter'; +import { withRNVRNConfig } from './adapters/rnConfigAdapter'; //@ts-ignore import CNF from '../renative.engine.json'; @@ -95,4 +96,4 @@ export default Engine; // Backward compatibility const withRNV = withRNVMetro; -export { withRNV, withRNVMetro, withRNVBabel }; +export { withRNV, withRNVMetro, withRNVBabel, withRNVRNConfig }; diff --git a/packages/rnv/src/adapter/index.ts b/packages/rnv/src/adapter/index.ts index 1eb66a5eaa..e3d96492d7 100644 --- a/packages/rnv/src/adapter/index.ts +++ b/packages/rnv/src/adapter/index.ts @@ -43,3 +43,14 @@ export const withRNVMetro = (cnf: any) => { return cnf; }; + +export const withRNVRNConfig = (cnf: any) => { + if (process.env.RNV_ENGINE_PATH) { + const engine = require(process.env.RNV_ENGINE_PATH); + if (engine.withRNVRNConfig) { + return engine.withRNVRNConfig(cnf); + } + } + + return cnf; +}; \ No newline at end of file diff --git a/packages/template-starter/Gemfile.lock b/packages/template-starter/Gemfile.lock index 89621db947..5cb60ce177 100644 --- a/packages/template-starter/Gemfile.lock +++ b/packages/template-starter/Gemfile.lock @@ -89,6 +89,7 @@ PLATFORMS ruby DEPENDENCIES + activesupport (~> 7.0, <= 7.0.8) cocoapods (~> 1.12) RUBY VERSION diff --git a/packages/template-starter/package.json b/packages/template-starter/package.json index 9c23d8523a..8704e307cc 100644 --- a/packages/template-starter/package.json +++ b/packages/template-starter/package.json @@ -53,7 +53,11 @@ "renative.template.json", "src", "static", - "tsconfig.json" + "tsconfig.json", + "Gemfile", + "metro.config.js", + "react-native.config.js", + "next-env.d.ts" ], "repository": { "type": "git", @@ -121,4 +125,4 @@ "last 1 safari version" ] } -} +} \ No newline at end of file diff --git a/packages/template-starter/react-native.config.js b/packages/template-starter/react-native.config.js index 493e0c41e4..ab5f2f06eb 100644 --- a/packages/template-starter/react-native.config.js +++ b/packages/template-starter/react-native.config.js @@ -1,85 +1,6 @@ -// console.log('process EEEENV', process.env); -//! NO CONSOLE LOGS HERE. IT WILL BREAK THE BUILD +//! NO CONSOLE LOGS HERE. IT WILL BREAK THE APP +const { withRNVRNConfig } = require('rnv'); -const getApplicationId = () => { - const appId = process.env.RNV_APP_ID; - return appId; -}; - -const getAppFolderRelative = () => { - const pth = process.env.RNV_APP_BUILD_DIR; - if (pth) { - // const dir = pth.split(getProjectRoot())[1]; - 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 = () => { - //env: REACT_NATIVE_PATH - const rnPath = process.env.RNV_REACT_NATIVE_PATH; - // return '/Users/paveljacko/SAPDevelop/Code/TEMP/RN_TVOS/TestApp2/node_modules/react-native-tvos'; - // return '../../node_modules/react-native-tvos'; - return rnPath; -}; - -const getProjectRoot = () => { - //env: PROJECT_ROOT - const rnPath = process.env.RNV_PROJECT_ROOT; - return rnPath; -}; - -const config = { - 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 config = withRNVRNConfig({}); module.exports = config; - -// module.exports = { -// 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, -// }, -// }, -// }, -// // root: '/Users/paveljacko/SAPDevelop/Code/TEMP/RN_TVOS/TestApp2/packages/template-starter', -// project: { -// ios: { -// sourceDir: "platformBuilds/template_tvos",// MUST BE RELATIVE -// } -// } -// }; From 1309b750853cba259f34f10edf1e1f2a480e6965 Mon Sep 17 00:00:00 2001 From: Mihai Blaga Date: Tue, 10 Oct 2023 14:46:54 +0300 Subject: [PATCH 2/2] 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';