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

iOS / tvOS fixes #1121

Merged
merged 9 commits into from
Oct 5, 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
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
},
"devDependencies": {
"@babel/eslint-parser": "7.17.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-react": "7.22.15",
"@babel/runtime": "^7.0.0",
"@flexn/eslint-config": "1.0.0",
"@flexn/prettier-config": "1.0.0",
"@flexn/typescript-config": "1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const _loadConfigFiles = (

if (fsExistsSync(pathObj.appConfigsDir)) {
const appConfigsDirNames = fsReaddirSync(pathObj.appConfigsDir);
if (parseAppConfigs && extendAppId && appConfigsDirNames.includes(extendAppId)) {
if (parseAppConfigs && extendAppId && extendAppId !== 'base' && appConfigsDirNames.includes(extendAppId)) {
const path2 = path.join(pathObj.appConfigsDir, extendAppId);
const pathObj2: RnvContextPathObj = {
...generateRnvConfigPathObj(),
Expand Down Expand Up @@ -346,7 +346,7 @@ const _loadConfigFiles = (
}
}

// PATH2: appConfigs/<appId>
// PATH3: appConfigs/<appId>
const path3 = pathObj.dir;
pathObj.dirs.push(path3);
pathObj.fontsDirs.push(path.join(path3, 'fonts'));
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/context/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ export const generateContextDefaults = (): RnvContext => ({
project: {
...generateRnvConfigPathObj(),
config: '',
appConfigBase: {},
appConfigBase: {
dir: '',
fontsDir: '',
fontsDirs: [],
pluginsDir: '',
},
builds: {},
assets: {},
platformTemplates: {},
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ export const createRnvContext = (ctx?: {
c.paths.RNV_NODE_MODULES_DIR = path.join(c.paths.rnv.dir, 'node_modules');

c.paths.rnv.engines.dir = path.join(c.paths.rnv.dir, 'engineTemplates');
c.paths.rnv.pluginTemplates.dir = path.join(c.paths.rnv.dir, 'pluginTemplates');
c.paths.rnv.pluginTemplates.overrideDir = path.join(c.paths.rnv.dir, 'pluginTemplates');

c.paths.rnv.pluginTemplates.config = path.join(c.paths.rnv.pluginTemplates.dir, RENATIVE_CONFIG_PLUGINS_NAME);
c.paths.rnv.pluginTemplates.config = path.join(
c.paths.rnv.pluginTemplates.overrideDir,
RENATIVE_CONFIG_PLUGINS_NAME
);
c.paths.rnv.projectTemplates.dir = path.join(c.paths.rnv.dir, 'coreTemplateFiles');
c.paths.rnv.projectTemplates.config = path.join(c.paths.rnv.projectTemplates.dir, RENATIVE_CONFIG_TEMPLATES_NAME);
c.paths.rnv.package = path.join(c.paths.rnv.dir, 'package.json');
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export type RnvContextPaths = {
pluginTemplates: {
configs: Record<string, any>;
//ADDON
dir?: string;
overrideDir?: string;
config?: string;
dirs: Record<string, string>;
};
Expand Down Expand Up @@ -203,7 +203,12 @@ export type RnvContextPaths = {
};
};
project: RnvContextPathObj & {
appConfigBase: Record<string, any>;
appConfigBase: {
dir: string;
pluginsDir: string;
fontsDir: string;
fontsDirs: Array<string>;
};
builds: Record<string, any>;
assets: Record<string, any>;
platformTemplates: Record<string, any>;
Expand Down
34 changes: 22 additions & 12 deletions packages/core/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ export const loadPluginTemplates = async (c: RnvContext) => {
rnv: c.files.rnv.pluginTemplates.config,
};

c.paths.rnv.pluginTemplates.dirs = { rnv: flexnPluginTemplatesPath };
//Override default rnv path with flexn one and add it rnv as overrider
c.paths.rnv.pluginTemplates.dirs = {
rnv: flexnPluginTemplatesPath,
};

const customPluginTemplates = c.files.project.config?.paths?.pluginTemplates;
const missingDeps = _parsePluginTemplateDependencies(c, customPluginTemplates);
Expand Down Expand Up @@ -618,7 +621,8 @@ const _parsePluginTemplateDependencies = (
const getCleanRegExString = (str: string) => str.replace(/[-\\.,_*+?^$[\](){}!=|`]/gi, '\\$&');

const _overridePlugin = (c: RnvContext, pluginsPath: string, dir: string) => {
const source = path.resolve(pluginsPath, dir, 'overrides');
const source = path.join(pluginsPath, dir, 'overrides');

const dest = doResolve(dir, false);
if (!dest) return;

Expand Down Expand Up @@ -683,6 +687,7 @@ const _overridePlugin = (c: RnvContext, pluginsPath: string, dir: string) => {
Object.keys(overrides).forEach((k) => {
const ovDir = path.join(dest, k);
const override = overrides[k];

if (fsExistsSync(ovDir)) {
if (fsLstatSync(ovDir).isDirectory()) {
logWarning('overrides.json: Directories not supported yet. specify path to actual file');
Expand All @@ -692,11 +697,15 @@ const _overridePlugin = (c: RnvContext, pluginsPath: string, dir: string) => {
}
});
}

// const parentDest = path.join(dir, '..')
// console.log('SKSLSL', dir, dest);
};

export const overrideFileContents = (dest: string, override: Record<string, string>, overridePath = '') => {
if (fsExistsSync(dest)) {
let fileToFix = fsReadFileSync(dest).toString();

let foundRegEx = false;
const failTerms: Array<string> = [];
Object.keys(override).forEach((fk) => {
Expand Down Expand Up @@ -836,7 +845,7 @@ export const overrideTemplatePlugins = async (c: RnvContext) => {

const rnvPluginsDirs = c.paths.rnv.pluginTemplates.dirs;
const appPluginDirs = c.paths.appConfig.pluginDirs;
const appBasePluginDir = c.paths.project.appConfigBase.pluginsDir;

parsePlugins(
c,
c.platform as RnvPluginPlatform,
Expand All @@ -846,14 +855,15 @@ export const overrideTemplatePlugins = async (c: RnvContext) => {
plugin._scopes.forEach((pluginScope) => {
const pluginOverridePath = rnvPluginsDirs[pluginScope];
if (pluginOverridePath) {
_overridePlugin(c, pluginOverridePath, key);
const rnvOverridePath = path.join(c.paths.rnv.pluginTemplates.overrideDir!, key);
if (fsExistsSync(rnvOverridePath)) {
_overridePlugin(c, c.paths.rnv.pluginTemplates.overrideDir!, key);
} else {
_overridePlugin(c, pluginOverridePath, key);
}
}
});
}

if (appBasePluginDir) {
_overridePlugin(c, appBasePluginDir, key);
}
if (appPluginDirs) {
for (let k = 0; k < appPluginDirs.length; k++) {
_overridePlugin(c, appPluginDirs[k], key);
Expand Down Expand Up @@ -887,10 +897,10 @@ export const copyTemplatePluginsSync = (c: RnvContext) => {
});
}
// FOLDER MERGES FROM PROJECT CONFIG PLUGIN
if (c.paths.rnv.pluginTemplates.dir) {
const sourcePathRnvPlugin = getBuildsFolder(c, platform, path.join(c.paths.rnv.pluginTemplates.dir, key));
copyFolderContentsRecursiveSync(sourcePathRnvPlugin, destPath, true, undefined, false, objectInject);
}
// if (c.paths.rnv.pluginTemplates.dir) {
// const sourcePathRnvPlugin = getBuildsFolder(c, platform, path.join(c.paths.rnv.pluginTemplates.dir, key));
// copyFolderContentsRecursiveSync(sourcePathRnvPlugin, destPath, true, undefined, false, objectInject);
// }

// FOLDER MERGES FROM PROJECT CONFIG PLUGIN
const sourcePath3 = getBuildsFolder(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const checkIfTemplateConfigured = async (c: RnvContext) => {

const _cleanProjectTemplateSync = (c: RnvContext) => {
logTask('_cleanProjectTemplateSync');
const dirsToRemove = [c.paths.project.appConfigBase.dir, c.paths.project.srcDir, c.paths.project.appConfigsDir];
const dirsToRemove = [c.paths.project.appConfigBase.dir, c.paths.project.srcDir!, c.paths.project.appConfigsDir];

const filesToRemove = c.buildConfig.defaults?.supportedPlatforms?.map((p) =>
path.join(c.paths.project.dir, `index.${p}.js`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ - (void)viewDidLoad {
[super viewDidLoad];

RCTBridge *bridge = [((AppDelegate *)[NSApp delegate])bridge];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"App" initialProperties:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"RNVApp" initialProperties:nil];

NSView *view = [self view];

Expand Down
120 changes: 0 additions & 120 deletions packages/engine-rn-tvos/src/adapter.ts.old

This file was deleted.

5 changes: 4 additions & 1 deletion packages/engine-rn-tvos/src/adapters/babelAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export const withRNVBabel = (cnf: any) => {
[
require.resolve('babel-plugin-module-resolver'),
{
root: [process.env.RNV_MONO_ROOT || '.'],
root: [process.env.RNV_MONO_ROOT],
alias: {
'react-native': process.env.RNV_REACT_NATIVE_PATH,
},
},
],
...plugins,
Expand Down
Loading