Skip to content

Commit

Permalink
revert back to template files without engine extend for now
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaiblaga89 committed Nov 2, 2023
1 parent cd5c124 commit 86ab83c
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 7 deletions.
99 changes: 99 additions & 0 deletions packages/app-harness/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.14.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (2.0)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.2.2)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
minitest (5.20.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)

PLATFORMS
ruby

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

RUBY VERSION
ruby 3.0.2p107

BUNDLED WITH
2.2.22
8 changes: 5 additions & 3 deletions packages/app-harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"react-native": "0.72.4",
"react-native-gesture-handler": "2.13.1",
"react-native-tvos": "0.72.4-0",
"react-native-web": "0.19.9"
"react-native-web": "0.19.9",
"@react-native-community/cli": "^11.3.8"
},
"devDependencies": {
"@flexn/assets-renative-outline": "0.3.2",
Expand All @@ -63,7 +64,8 @@
"jetifier": "1.6.5",
"metro-react-native-babel-preset": "0.76.8",
"rnv": "1.0.0-feat-pin-cli.6",
"xcode": "2.1.0"
"xcode": "2.1.0",
"@rnv/template-starter": "^1.0.0-feat-pin-cli.6"
},
"private": true
}
}
4 changes: 3 additions & 1 deletion packages/app-harness/renative.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"$schema": "../../.rnv/schema/rnv.project.json",
"extendsTemplate": "@rnv/template-starter/renative.json",
"plugins": {}
"plugins": {
"@react-native-community/cli": "^11.3.8"

This comment has been minimized.

Copy link
@pavjacko

pavjacko Nov 6, 2023

Member

@mihaiblaga89 we should try to avoid such project injections to keep project configuration simple. what's the reason this was added?

}
}
4 changes: 4 additions & 0 deletions packages/core/jsonSchema/rnv.engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"type": "string",
"description": "Engine extension ised by rnv during compilation"
},
"extends": {
"type": "string",
"description": "ID of engine to extend. Not being used yet"
},
"overview": {
"type": "string",
"description": "Overview description of engine"
Expand Down
19 changes: 18 additions & 1 deletion packages/core/src/engines/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { fsExistsSync, readObjectSync, writeFileSync } from '../system/fs';
import { fsExistsSync, readObjectSync, writeFileSync, copyIfNotExistsRecursiveSync } from '../system/fs';
import { installPackageDependencies } from '../projects/npm';
import { logDebug, logTask, chalk, logInfo, logWarning, logError } from '../logger';
import { getConfigProp } from '../common';
Expand Down Expand Up @@ -28,6 +28,7 @@ export const registerEngine = async (engine: RnvEngine, platform?: RnvPlatform,
if (engConfig?.packageName) {
engine.rootPath = _resolvePkgPath(c, engConfig.packageName);
engine.originalTemplatePlatformsDir = path.join(engine.rootPath, 'templates/platforms');
engine.originalTemplateProjectDir = path.join(engine.rootPath, 'templates/project');
engine.originalTemplatePlatformProjectDir = path.join(
engine.originalTemplatePlatformsDir,
engine.projectDirName
Expand Down Expand Up @@ -557,3 +558,19 @@ export const getEngineRunner = (c: RnvContext, task: string, customTasks?: RnvTa
};

export const getRegisteredEngines = (c: RnvContext) => c.runtime.enginesByIndex;

/*
* Look for ${enginePath}/templates/project and if it exists make sure files from there are copied to project
* It will only copy files if they don't already exist in project, it will not overwrite existing files
*/
export const applyEnginePrerequisites = async (c: RnvContext) => {
logTask('applyEnginePrerequisites');
const currentEngine = c.runtime.enginesByPlatform[c.platform];

const projectPrerequisitesDir = currentEngine?.originalTemplateProjectDir;

if (projectPrerequisitesDir && fsExistsSync(projectPrerequisitesDir)) {
// iterate over every file and copy it if it doesn't already exist
copyIfNotExistsRecursiveSync(projectPrerequisitesDir, c.paths.project.dir);
}
}
1 change: 1 addition & 0 deletions packages/core/src/engines/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { RnvTaskMap } from '../tasks/types';

export type RnvEngine = {
originalTemplatePlatformsDir?: string;
originalTemplateProjectDir?: string;
platforms: Record<string, RnvEnginePlatform>;
config: ConfigFileEngine;
tasks: RnvTaskMap;
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/schema/configFiles/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ const Overview = z.string().describe('Overview description of engine');

const Platforms = z.record(PlatformsKeys, EnginePlatform);

const Extends = z.string().describe('ID of engine to extend. Not being used yet');

export const RootEngineSchema = z.object({
custom: z.optional(Ext),
id: Id,
engineExtension: EngineExtension,
extends: z.optional(Extends),
overview: Overview,
plugins: z.optional(Plugins),
npm: z.optional(Npm),
Expand Down
20 changes: 19 additions & 1 deletion packages/core/src/system/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Svg2Js from 'svg2js';
import shelljs from 'shelljs';
import merge from 'deepmerge';
import ncp from 'ncp';
import { chalk, logDebug, logError, logWarning } from '../logger';
import { chalk, logDebug, logError, logWarning, logInfo } from '../logger';
import type { RnvContext } from '../context/types';
import type { FileUtilsPropConfig, OverridesOptions, TimestampPathsConfig } from './types';
import { getApi } from '../api/provider';
Expand Down Expand Up @@ -823,6 +823,23 @@ export const getRelativePath = (from: string, to: string) => {
return path.relative(from, to);
};

export const copyIfNotExistsRecursiveSync = (src: string | string[], dest: string) => {
const filesOrDirs = Array.isArray(src) ? src : fsReaddirSync(src);
for (const fd of filesOrDirs) {
const srcPath = path.join(src, fd);
const destPath = path.join(dest, fd);

if (!fsExistsSync(destPath)) {
logInfo(`Copying ${fd} to ${dest}`);
if (fsStatSync(srcPath).isDirectory()) {
copyFolderRecursiveSync(srcPath, dest);
} else {
fsCopyFileSync(srcPath, destPath);
}
}
}
}

export default {
sanitizeDynamicRefs,
getFileListSync,
Expand All @@ -846,4 +863,5 @@ export default {
getDirectories,
resolvePackage,
cleanEmptyFoldersRecursively,
copyIfNotExistsRecursiveSync
};
3 changes: 3 additions & 0 deletions packages/engine-core/src/tasks/task.rnv.project.configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
findSuitableTask,
RnvTaskFn,
RnvContext,
applyEnginePrerequisites,
generatePlatformAssetsRuntimeConfig,
} from '@rnv/core';

Expand Down Expand Up @@ -73,6 +74,8 @@ export const taskRnvProjectConfigure: RnvTaskFn = async (c, parentTask, originTa
await executeTask(c, TASK_INSTALL, TASK_PROJECT_CONFIGURE, originTask);
await checkCrypto(c, parentTask, originTask);
await configureRuntimeDefaults(c);

await applyEnginePrerequisites(c);

if (originTask !== TASK_TEMPLATE_APPLY) {
if ((c.runtime.requiresBootstrap || !isTemplateInstalled(c)) && !c.files.project.config?.isTemplate) {
Expand Down
3 changes: 2 additions & 1 deletion packages/engine-rn-tvos/renative.engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "../../.rnv/schema/rnv.engine.json",
"id": "engine-rn-tvos",
"engineExtension": "rntvos",
"extends": "engine-rn",
"overview": "React native based engine with added support for tvOS platform. Runs standard react native apps with native support",
"plugins": {
"react": "source:rnv",
Expand All @@ -25,4 +26,4 @@
}
}
}
}
}
2 changes: 2 additions & 0 deletions packages/engine-rn-tvos/templates/project/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
6 changes: 6 additions & 0 deletions packages/engine-rn-tvos/templates/project/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ignore_dirs": [
"platformBuilds",
"buildHooks/dist"
]
}
8 changes: 8 additions & 0 deletions packages/engine-rn-tvos/templates/project/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.12'
gem 'activesupport', '~> 7.0', '<= 7.0.8'

3 changes: 3 additions & 0 deletions packages/engine-rn-tvos/templates/project/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { withRNVMetro } = require('rnv');

module.exports = withRNVMetro({});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! NO CONSOLE LOGS HERE. IT WILL BREAK THE APP
const { withRNVRNConfig } = require('rnv');

const config = withRNVRNConfig({});

module.exports = config;

0 comments on commit 86ab83c

Please sign in to comment.