Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added withRnvRNConfig, added missing files to template #1155

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/engine-rn-macos/src/adapters/babelAdapter.ts
Original file line number Diff line number Diff line change
@@ -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,
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
};
};
6 changes: 4 additions & 2 deletions packages/engine-rn-macos/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { generateEngineExtensions, generateEngineTasks, RnvEngine } from '@rnv/core';
import { withRNVBabel, withRNVMetro } from './adapter';
import { withRNVMetro } from './adapters/metroAdapter';
import { withRNVBabel } from './adapters/babelAdapter';
//@ts-ignore
import CNF from '../renative.engine.json';
import taskRnvRun from './tasks/task.rnv.run';
Expand All @@ -9,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 = {
Expand Down Expand Up @@ -45,6 +47,6 @@ const Engine: RnvEngine = {
// Backward compatibility
const withRNV = withRNVMetro;

export { withRNV, withRNVMetro, withRNVBabel };
export { withRNV, withRNVMetro, withRNVBabel, withRNVRNConfig };

export default Engine;
18 changes: 18 additions & 0 deletions packages/engine-rn-next/src/adapters/babelAdapter.ts
Original file line number Diff line number Diff line change
@@ -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,
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
};
};
3 changes: 2 additions & 1 deletion packages/engine-rn-next/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/engine-rn-tvos/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 "@rnv/sdk-react-native";

const Engine: RnvEngine = {
// initializeRuntimeConfig: (c) => Context.initializeConfig(c),
Expand Down Expand Up @@ -68,6 +69,6 @@ const Engine: RnvEngine = {

const withRNV = withRNVMetro;

export { withRNVMetro, withRNV, withRNVBabel };
export { withRNVMetro, withRNV, withRNVBabel, withRNVRNConfig };

export default Engine;
18 changes: 18 additions & 0 deletions packages/engine-rn-windows/src/adapters/babelAdapter.ts
Original file line number Diff line number Diff line change
@@ -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,
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
};
};
6 changes: 4 additions & 2 deletions packages/engine-rn-windows/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RnvEngine, generateEngineTasks, generateEngineExtensions } from '@rnv/core';
import { withRNVBabel, withRNVMetro } from './adapter';
import { withRNVMetro } from './adapters/metroAdapter';
import { withRNVBabel } from './adapters/babelAdapter';
//@ts-ignore
import CNF from '../renative.engine.json';
import taskRnvBuild from './tasks/task.rnv.build';
Expand All @@ -10,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),
Expand Down Expand Up @@ -43,6 +45,6 @@ const Engine: RnvEngine = {
// Backward compatibility
const withRNV = withRNVMetro;

export { withRNV, withRNVMetro, withRNVBabel };
export { withRNV, withRNVMetro, withRNVBabel, withRNVRNConfig };

export default Engine;
3 changes: 2 additions & 1 deletion packages/engine-rn/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,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),
Expand Down Expand Up @@ -95,4 +96,4 @@ export default Engine;
// Backward compatibility
const withRNV = withRNVMetro;

export { withRNV, withRNVMetro, withRNVBabel };
export { withRNV, withRNVMetro, withRNVBabel, withRNVRNConfig };
11 changes: 11 additions & 0 deletions packages/rnv/src/adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
64 changes: 64 additions & 0 deletions packages/sdk-react-native/src/adapters.ts
Original file line number Diff line number Diff line change
@@ -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;
};
1 change: 1 addition & 0 deletions packages/sdk-react-native/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './common';
export * from './androidRunner';
export * from './iosRunner';
export * from './adapters';
1 change: 1 addition & 0 deletions packages/template-starter/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ PLATFORMS
ruby

DEPENDENCIES
activesupport (~> 7.0, <= 7.0.8)
cocoapods (~> 1.12)

RUBY VERSION
Expand Down
8 changes: 6 additions & 2 deletions packages/template-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -121,4 +125,4 @@
"last 1 safari version"
]
}
}
}
Loading
Loading