Skip to content

Commit

Permalink
Merge pull request #1113 from flexn-io/feat/rn-upgrade-ts-3
Browse files Browse the repository at this point in the history
ReNative major refactor
  • Loading branch information
pavjacko committed Oct 3, 2023
2 parents 7d3e675 + 04070e0 commit 4cbbcf6
Show file tree
Hide file tree
Showing 637 changed files with 18,006 additions and 21,427 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ buck-out/
# Testing
/packages/**/coverage
/packages/**/dist
/packages/**/lib

.expo
coverage

Expand Down
66 changes: 66 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
LOAD FILES TO MEMORY (MIGHT TAKE SEVERAL ROUNDS?)

generate abstract runtime definitions
generate all injections

CREATE ABSTRACT CONTEXT INFO

GENERATE / COPY NEW FILES

copy over template files (.tpl files to be injected )

rnv

@rnv/cli
@rnv/core
@rnv/sdk-tizen
@rnv/sdk-webos
@rnv/sdk-apple

import { executeRnv } from '@rnv/core'

await executeRnv({
commandAsString: 'rnv run -p ios',
commandAsObject: {
command: 'run',
},
cwd: '',
errorHandler: async ({}) => {
return true;
},
inputHandler: async ({}) => {

},
logger: ({}) => {

}

});

- make build hooks typescript (with autocomplete)
- split rnv into cli & core
- move sdkManger to separate sdk packages
- rethink templateFile injection system
- renative.json: engines.engine-rn.platforms.ios.template.ignoreFiles: []
- merge engine-rn + tvos + macos????

templateFiles: {
'ios/Info.plist': {
isTemplate: source.endsWith('.tpl'),
source: 'ios/Info.plist.tpl',
dest: 'ios/Info.plist',
injections: {
'{{NAME}}': 'myApp'
}
},
'ios/image.png': {
source: 'ios/image.png',
dest: 'ios/image.png'
}
}

if isTemplate = true && injections = undefined => use global injections
if isTemplate = true && injections = {...} => use local injections

reading config files 17 times in the first half of an rnv run :D
a plugin that was removed from renative.json still has it's orchestra-plugins/builds and renative.plugins.json overrides applied
125 changes: 125 additions & 0 deletions __mocks__/@rnv/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// __mocks__/@rnv/core.ts
const rnvcore: any = jest.createMockFromModule('@rnv/core');

const configPropMocks = {
scheme: 'debug',
bundleAssets: false,
};

const _chalkCols: any = {
white: (v) => v,
green: (v) => v,
red: (v) => v,
yellow: (v) => v,
default: (v) => v,
gray: (v) => v,
grey: (v) => v,
blue: (v) => v,
cyan: (v) => v,
magenta: (v) => v,
};
_chalkCols.rgb = () => (v) => v;
_chalkCols.bold = _chalkCols;
const _chalkMono = {
..._chalkCols,
};

rnvcore.getEngineRunnerByPlatform = () => ({
getOriginalPlatformTemplatesDir: () => 'sometemptdir',
});
rnvcore.executeTask = jest.fn();
rnvcore.shouldSkipTask = () => false;
rnvcore.generatePlatformChoices = () => [];
rnvcore.executeAsync = jest.fn();
rnvcore.removeDirs = jest.fn();
rnvcore.fsExistsSync = () => true;
rnvcore.fsReaddirSync = () => [];
rnvcore.getRealPath = () => '';
rnvcore.copyFolderContentsRecursiveSync = jest.fn();

rnvcore.getConfigProp = (c, platform, key) => configPropMocks[key];
rnvcore.confirmActiveBundler = () => null;
rnvcore.getAppFolder = () => null;

rnvcore.logToSummary = jest.fn();
rnvcore.logTask = jest.fn();
rnvcore.logDebug = jest.fn();
rnvcore.logInfo = jest.fn();
rnvcore.logError = jest.fn();
rnvcore.logWarning = jest.fn();
rnvcore.logSuccess = jest.fn();
rnvcore.logSummary = jest.fn();
rnvcore.chalk = () => _chalkMono;

// Common: {
// getConfigProp: (c, platform, key) => configPropMocks[key],
// confirmActiveBundler: () => null,
// getAppFolder: () => null,
// },
// Logger: {
// logToSummary: jest.fn(),
// logTask: jest.fn(),
// logDebug: jest.fn(),
// logInfo: jest.fn(),
// logError: jest.fn(),
// logWarning: jest.fn(),
// logSuccess: jest.fn(),
// logSummary: jest.fn(),
// chalk: () => _chalkMono,
// },
// FileUtils: {
// fsExistsSync: () => null,
// copyFileSync: () => null,
// },
// Constants: {
// PARAMS: {
// withBase: () => [],
// withRun: () => [],
// withConfigure: () => [],
// },
// IOS: 'ios',
// },
// TaskManager: {
// executeTask: () => null,
// executeOrSkipTask: () => null,
// shouldSkipTask: () => false,
// },
// Exec: {
// executeAsync: () => null,
// },
// ObjectUtils: {
// isObject: () => null,
// },
// PluginManager: {
// parsePlugins: () => null,
// },
// ProjectManager: {
// copyAssetsFolder: () => null,
// copyBuildsFolder: () => null,
// parseFonts: () => null,
// },
// Resolver: {
// doResolve: () => null,
// doResolvePath: () => null,
// },
// Prompt: {
// isSystemWin: () => null,
// },
// Utils: {
// inquirerPrompt: () => null,
// },
// PlatformManager: {
// isPlatformActive: () => null,
// logErrorPlatform: () => null,
// },
// RuntimeManager: {
// updateRenativeConfigs: () => null,
// },
// SDKManager: {
// Apple: {
// launchAppleSimulator: () => null,
// },
// Android: {},
// },

module.exports = rnvcore;
6 changes: 6 additions & 0 deletions __mocks__/@rnv/sdk-apple.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// __mocks__/@rnv/sdk-apple.ts
const sdkApple: any = jest.createMockFromModule('@rnv/sdk-apple');

sdkApple.launchAppleSimulator = () => null;

module.exports = sdkApple;
6 changes: 6 additions & 0 deletions __mocks__/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// __mocks__/axios.ts
const axios: any = jest.createMockFromModule('axios');

axios.get = () => true;

module.exports = axios;
7 changes: 7 additions & 0 deletions __mocks__/child_process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// __mocks__/child_process.ts

const child_process: any = jest.createMockFromModule('child_process');

child_process.spawn = jest.fn();

module.exports = child_process;
6 changes: 4 additions & 2 deletions __mocks__/fs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// __mocks__/fs.js
// __mocks__/fs.ts
const path = require('path');

const fs = jest.createMockFromModule('fs');
const fs: any = jest.createMockFromModule('fs');

let mockFiles = Object.create(null);
function __setMockFiles(newMockFiles) {
mockFiles = Object.create(null);
//@ts-expect-error
Array.values(newMockFiles).forEach((file) => {
const dir = path.dirname(file);

Expand All @@ -22,5 +23,6 @@ function readdirSync(directoryPath) {

fs.__setMockFiles = __setMockFiles;
fs.readdirSync = readdirSync;
fs.readFileSync = () => '{}';

module.exports = fs;
6 changes: 6 additions & 0 deletions __mocks__/inquirer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// __mocks__/inquirer.ts
const inquirer: any = jest.createMockFromModule('inquirer');

inquirer.prompt = () => true;

module.exports = inquirer;
4 changes: 4 additions & 0 deletions __mocks__/rnv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// __mocks__/rnv.ts
const rnv: any = jest.createMockFromModule('rnv');

module.exports = rnv;
8 changes: 8 additions & 0 deletions __mocks__/shelljs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// __mocks__/rnv.ts
const shelljs: any = jest.createMockFromModule('shelljs');

shelljs.mkdir = () => {
//NOOP
};

module.exports = shelljs;
2 changes: 1 addition & 1 deletion buildHooks/src/prePublish.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { Doctor, FileUtils } from 'rnv';
import { Doctor, FileUtils } from '@rnv/core';
import fs from 'fs';
import { setPackageVersions } from '@flexn/build-hooks-version';

Expand Down
49 changes: 16 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
},
"devDependencies": {
"@babel/eslint-parser": "7.17.0",
"@babel/plugin-transform-runtime": "7.8.3",
"@babel/preset-react": "7.16.7",
"@babel/runtime": "7.12.5",
"@flexn/build-hooks-git": "0.1.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-react": "7.22.15",
"@babel/runtime": "^7.0.0",
"@flexn/build-hooks-git": "0.31.1-canary.0",
"@flexn/build-hooks-version": "0.1.0",
"@flexn/eslint-config": "1.0.0",
"@flexn/prettier-config": "1.0.0",
Expand All @@ -100,31 +100,31 @@
"@types/lodash.set": "4.3.7",
"@types/ncp": "2.0.5",
"@types/node": "~16.11.7",
"@types/node-fetch": "2.6.4",
"@types/shelljs": "0.8.12",
"@types/tar": "6.1.5",
"@types/shell-quote": "1.7.1",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"babel-jest": "26.6.3",
"babel-plugin-module-resolver": "3.2.0",
"babel-plugin-polyfill-corejs2": "0.2.2",
"babel-jest": "29.2.1",
"babel-plugin-module-resolver": "^5.0.0",
"deepmerge": "3.2.0",
"eslint": "8.40.0",
"eslint": "8.19.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-react": "7.33.2",
"husky": "^7.0.0",
"jest": "27.5.1",
"lerna": "6.6.2",
"jest": "29.2.1",
"jest-environment-jsdom": "29.7.0",
"lerna": "^6.6.2",
"lint-staged": "12.3.4",
"prettier": "2.3.1",
"pretty-quick": "1.11.0",
"rnv": "0.38.0-canary.1",
"ts-jest": "^27.0.7",
"ttab": "^0.7.2",
"typescript": "4.9.5"
"typescript": "5.2.2"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
"node": ">=18.0.0",
"npm": ">=9.0.0"
},
"private": true,
"title": "ReNative",
Expand Down Expand Up @@ -154,22 +154,5 @@
"**/@flexn/plugins"
]
},
"resolutions": {
"@types/react": "18.2.6",
"tslib": "2.5.2",
"@react-native-community/cli": "^6.0.0",
"@react-native-community/cli-platform-ios": "^6.0.0",
"@react-native-community/cli-platform-android": "^6.0.0",
"axios": "^0.21.2",
"plist": "^3.0.5",
"merge": "^2.1.1",
"minimist": "1.2.6",
"react-dev-utils": "^12.0.0",
"node-forge": "1.3.0",
"chokidar": "3.5.3",
"terser": "5.14.2",
"simple-plist": "1.3.1",
"ejs": "3.1.7",
"shell-quote": "1.7.3"
}
"resolutions": {}
}
3 changes: 3 additions & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
coverage
21 changes: 21 additions & 0 deletions packages/cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Pavel Jacko

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cli

Loading

0 comments on commit 4cbbcf6

Please sign in to comment.