diff --git a/.github/workflows/rnvUnitTest.yml b/.github/workflows/rnvUnitTest.yml
index ba545806bc..1c042fed5e 100644
--- a/.github/workflows/rnvUnitTest.yml
+++ b/.github/workflows/rnvUnitTest.yml
@@ -20,6 +20,7 @@ jobs:
run: |
yarn
yarn bootstrap
+ yarn lint
yarn test
env:
CI: true
diff --git a/packages/app-harness/appConfigs/base/renative.json b/packages/app-harness/appConfigs/base/renative.json
index e4f34ea3c6..368945c054 100644
--- a/packages/app-harness/appConfigs/base/renative.json
+++ b/packages/app-harness/appConfigs/base/renative.json
@@ -31,8 +31,7 @@
"{{resolvePackage(react-native-vector-icons)}}/Fonts"
],
"excludedPlugins": [
- "@react-native-firebase/app",
- "react-native-photo-editor"
+ "@react-native-firebase/app"
]
},
"platforms": {
diff --git a/packages/app-harness/buildHooks/tsconfig.json b/packages/app-harness/buildHooks/tsconfig.json
deleted file mode 100644
index 82dac4d899..0000000000
--- a/packages/app-harness/buildHooks/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "@rnv/core/tsconfig.hooks.json",
- "compilerOptions": {
- "outDir": "dist",
- "rootDir": "src"
- }
-}
diff --git a/packages/app-harness/package.json b/packages/app-harness/package.json
index cc730db425..f1025443aa 100644
--- a/packages/app-harness/package.json
+++ b/packages/app-harness/package.json
@@ -53,10 +53,12 @@
"react-native-gesture-handler": "2.14.1",
"react-native-orientation-locker": "1.5.0",
"react-native-permissions": "4.1.4",
- "react-native-photo-editor": "1.0.13",
+ "react-native-photo-editor": "github:AppGyver/react-native-photo-editor#v0.1.2",
"react-native-splash-screen": "3.3.0",
"react-native-tvos": "0.73.1-3",
- "react-native-web": "0.19.9"
+ "react-native-web": "0.19.9",
+ "react-native-fs": "2.20.0",
+ "rn-fetch-blob": "0.12.0"
},
"devDependencies": {
"@flexn/assets-renative-outline": "0.3.3",
diff --git a/packages/app-harness/renative.json b/packages/app-harness/renative.json
index e16ab72834..1604502a3b 100644
--- a/packages/app-harness/renative.json
+++ b/packages/app-harness/renative.json
@@ -12,7 +12,7 @@
"react-native-splash-screen": {
"android": {
"templateAndroid": {
- "MainActivity_java": {
+ "MainActivity_kt": {
"createMethods": ["SplashScreen.show(this)"],
"imports": ["org.devio.rn.splashscreen.SplashScreen"]
}
@@ -40,13 +40,14 @@
"TestNativeModule": {
"android": {
"templateAndroid": {
- "MainApplication_java": {
+ "MainApplication_kt": {
"packages": ["MyAppPackage"]
}
},
"forceLinking": true
}
},
+ "rn-fetch-blob": { "tvos": { "disabled": true }, "version": "0.12.0" },
"react-native-carplay": {
"ios": {
"templateXcode": {
@@ -100,6 +101,11 @@
"tag": "manifest",
"android:name": "",
"children": [
+ {
+ "tag": "uses-permission ",
+ "android:name": "android.permission.WRITE_EXTERNAL_STORAGE",
+ "children": []
+ },
{
"tag": "application",
"android:name": ".MainApplication",
@@ -126,10 +132,29 @@
"podName": "iOSPhotoEditor",
"git": "https://github.com/prscX/photo-editor",
"commit": "4924e9ec984d25d03644e58aa148282642171de9",
- "buildType": "dynamic"
+ "buildType": "dynamic",
+ "templateXcode": {
+ "Podfile": {
+ "header": ["plugin 'cocoapods-user-defined-build-types'", "enable_user_defined_build_types!"]
+ },
+ "project_pbxproj": {
+ "resourceFiles": [
+ "Resources/arrow1.png",
+ "Resources/arrow2.png",
+ "Resources/arrow3.png",
+ "Resources/arrow4.png",
+ "Resources/arrow5.png"
+ ],
+ "sourceFiles": ["RNPhotoEditor/RNPhotoEditor.m"],
+ "headerFiles": ["RNPhotoEditor/RNPhotoEditor.h"]
+ }
+ }
+ },
+ "tvos": {
+ "disabled": true
},
"pluginDependencies": null,
- "version": "1.0.13"
+ "version": "github:AppGyver/react-native-photo-editor#v0.1.2"
},
"react-native-permissions": {
"ios": {
@@ -208,6 +233,12 @@
},
"NSContactsUsageDescription": {
"desc": "Contacts usage description"
+ },
+ "NSPhotoLibraryAddUsageDescription": {
+ "desc": "Application needs permission to write photos..."
+ },
+ "NSPhotoLibraryUsageDescription": {
+ "desc": "iOS 10 needs permission to write photos..."
}
}
}
diff --git a/packages/app-harness/src/app/index.tsx b/packages/app-harness/src/app/index.tsx
index dc8019169f..85193e0a18 100644
--- a/packages/app-harness/src/app/index.tsx
+++ b/packages/app-harness/src/app/index.tsx
@@ -1,41 +1,66 @@
import React, { useEffect, useState } from 'react';
import { Button, Image, ScrollView, Text, View } from 'react-native';
+import { Api } from '@rnv/renative';
import { OrientationLocker, PORTRAIT, LANDSCAPE } from '../components/OrientationLocker';
import { NewModuleButton } from '../components/NewModuleButton';
-import { SplashScreen } from '../components/SplashScreen';
+import { useSplashScreen } from '../components/SplashScreen';
import { ICON_LOGO, testProps } from '../config';
import styles from '../styles';
import { addNotificationListeners, removeNotificationListeners } from '../components/Notifications';
import { requestPermissions } from '../components/Permissions';
import { TestCase } from '../components/TestCase';
-const App = () => {
+import config from '../../package.json';
+import { LoggerProvider, useLoggerContext } from '../context';
+import { NotificationCallback } from '../components/types';
+import { PhotoEditorButton } from '../components/PhotoEditor';
+
+const App = () => (
+
+
+
+);
+
+const AppContent = () => {
const [showVideo, setShowVideo] = useState(false);
+ const { logDebug, logs } = useLoggerContext();
+ const { SplashScreen } = useSplashScreen();
+
useEffect(() => {
SplashScreen.hide();
- addNotificationListeners();
+ addNotificationListeners(handleNotification);
return () => {
- removeNotificationListeners();
+ removeNotificationListeners(handleNotification);
};
}, []);
+ const handleNotification: NotificationCallback = (message) => logDebug(message);
+
+ const handleRequestPermissions = async () => {
+ try {
+ const permission = await requestPermissions();
+ logDebug(`Permissions: ${permission}`);
+ } catch (error) {
+ logDebug(`${error}`);
+ }
+ };
+
return (
-
+
-
+
ReNative Harness
- v1.0.0-rc.12, platform: macos, formFactor: desktop
+
+ {`v${config.version}, platform: ${Api.platform}, factor: ${Api.formFactor}, engine: ${Api.engine}`}
+
@@ -58,8 +83,8 @@ const App = () => {
console.log('onChange', orientation)}
- onDeviceChange={(orientation) => console.log('onDeviceChange', orientation)}
+ onChange={(orientation) => logDebug(`onChange ${orientation}`)}
+ onDeviceChange={(orientation) => logDebug(`onDeviceChange ${orientation}`)}
/>
-
+
+
+
+
+
+
-
- Logs:
-
+ {`Logs: `}
+ {logs
+ ? logs.map((it, idx) => (
+
+ {it}
+
+ ))
+ : null}
+
);
};
diff --git a/packages/app-harness/src/components/NewModuleButton/index.native.tsx b/packages/app-harness/src/components/NewModuleButton/index.native.tsx
index fa23fe672a..339efd4d9d 100644
--- a/packages/app-harness/src/components/NewModuleButton/index.native.tsx
+++ b/packages/app-harness/src/components/NewModuleButton/index.native.tsx
@@ -1,17 +1,23 @@
import React from 'react';
import { NativeModules, Button } from 'react-native';
+import { useLoggerContext } from '../../context';
export const NewModuleButton = () => {
const { TestNativeModule } = NativeModules;
+ const { logDebug } = useLoggerContext();
const callback = (error: any, result: string) => {
if (error) {
- console.log(error);
+ logDebug(error);
} else {
- console.log(result);
+ logDebug(result);
}
};
const onPress = () => {
- TestNativeModule.createTestEvent('testName', 'testLocation', callback);
+ if (TestNativeModule) {
+ TestNativeModule.createTestEvent('testName', 'testLocation', callback);
+ } else {
+ logDebug('NativeModules not supported for this platform');
+ }
};
return ;
};
diff --git a/packages/app-harness/src/components/NewModuleButton/index.tsx b/packages/app-harness/src/components/NewModuleButton/index.tsx
index 683662e543..8dbb095c24 100644
--- a/packages/app-harness/src/components/NewModuleButton/index.tsx
+++ b/packages/app-harness/src/components/NewModuleButton/index.tsx
@@ -1,9 +1,11 @@
import React from 'react';
import { Button } from 'react-native';
+import { useLoggerContext } from '../../context';
export const NewModuleButton = () => {
+ const { logDebug } = useLoggerContext();
const onPress = () => {
- console.log('NativeModules not supported in web');
+ logDebug('NativeModules not supported in web');
};
return ;
};
diff --git a/packages/app-harness/src/components/Notifications/index.ios.mobile.ts b/packages/app-harness/src/components/Notifications/index.ios.mobile.ts
index 68050d9d56..986430d95d 100644
--- a/packages/app-harness/src/components/Notifications/index.ios.mobile.ts
+++ b/packages/app-harness/src/components/Notifications/index.ios.mobile.ts
@@ -1,10 +1,11 @@
import PushNotificationIOS from '@react-native-community/push-notification-ios';
+import { NotificationCallback, NotificationError } from '../types';
-export const addNotificationListeners = () => {
+export const addNotificationListeners = (callback: NotificationCallback) => {
PushNotificationIOS.requestPermissions();
PushNotificationIOS.addEventListener('notification', onRemoteNotification);
- PushNotificationIOS.addEventListener('register', onRegistered);
- PushNotificationIOS.addEventListener('registrationError', onError);
+ PushNotificationIOS.addEventListener('register', onRegistered(callback));
+ PushNotificationIOS.addEventListener('registrationError', onError(callback));
};
export const removeNotificationListeners = () => {
@@ -13,12 +14,12 @@ export const removeNotificationListeners = () => {
PushNotificationIOS.removeEventListener('registrationError');
};
-const onRegistered = (deviceToken) => {
- console.log(`Device Token: ${deviceToken}`);
+const onRegistered = (callback: NotificationCallback) => (deviceToken: string) => {
+ callback(`Device Token: ${deviceToken}`);
};
-const onError = (error) => {
- console.log(`Error on notification register: ${error}`);
+const onError = (callback: NotificationCallback) => (error: NotificationError) => {
+ callback(`Error on notification register: ${error.message}`);
};
const onRemoteNotification = (notification) => {
diff --git a/packages/app-harness/src/components/Notifications/index.ts b/packages/app-harness/src/components/Notifications/index.ts
index c73e88ff44..cfad1f229c 100644
--- a/packages/app-harness/src/components/Notifications/index.ts
+++ b/packages/app-harness/src/components/Notifications/index.ts
@@ -1,7 +1,9 @@
-export const addNotificationListeners = () => {
- console.log('addNotificationListeners not supported on this platform');
+import { NotificationCallback } from '../types';
+
+export const addNotificationListeners = (callback: NotificationCallback) => {
+ callback('addNotificationListeners not supported on this platform');
};
-export const removeNotificationListeners = () => {
- console.log('removeNotificationListeners not supported on this platform');
+export const removeNotificationListeners = (callback: NotificationCallback) => {
+ callback('removeNotificationListeners not supported on this platform');
};
diff --git a/packages/app-harness/src/components/Permissions/index.mobile.ts b/packages/app-harness/src/components/Permissions/index.mobile.ts
index 08cd47ddf7..bf6a4086df 100644
--- a/packages/app-harness/src/components/Permissions/index.mobile.ts
+++ b/packages/app-harness/src/components/Permissions/index.mobile.ts
@@ -1,7 +1,5 @@
import { request, PERMISSIONS } from 'react-native-permissions';
export const requestPermissions = () => {
- request(PERMISSIONS.IOS.CONTACTS).then((result) => {
- console.log(result);
- });
+ return request(PERMISSIONS.IOS.CONTACTS);
};
diff --git a/packages/app-harness/src/components/Permissions/index.ts b/packages/app-harness/src/components/Permissions/index.ts
index cad50eb97c..91822826a6 100644
--- a/packages/app-harness/src/components/Permissions/index.ts
+++ b/packages/app-harness/src/components/Permissions/index.ts
@@ -1,3 +1,3 @@
export const requestPermissions = () => {
- console.log('requestPermissions not supported on this platform');
+ return 'requestPermissions not supported on this platform';
};
diff --git a/packages/app-harness/src/components/PhotoEditor/index.mobile.tsx b/packages/app-harness/src/components/PhotoEditor/index.mobile.tsx
new file mode 100644
index 0000000000..c9691b25d7
--- /dev/null
+++ b/packages/app-harness/src/components/PhotoEditor/index.mobile.tsx
@@ -0,0 +1,40 @@
+import React, { useEffect } from 'react';
+import { Button, Image } from 'react-native';
+import { RNPhotoEditor } from 'react-native-photo-editor';
+import RNFS from 'react-native-fs';
+import RNFetchBlob from 'rn-fetch-blob';
+import { useLoggerContext } from '../../context';
+import { ICON_LOGO } from '../../config';
+
+export const PhotoEditorButton = () => {
+ const { logDebug } = useLoggerContext();
+ const photoPath = RNFS.DocumentDirectoryPath + ICON_LOGO;
+ useEffect(() => {
+ const fetchAndMovePhoto = async () => {
+ const binaryFile = Image.resolveAssetSource(ICON_LOGO);
+ try {
+ const resp = await RNFetchBlob.config({ fileCache: true }).fetch('GET', binaryFile.uri);
+ if (await RNFS.exists(photoPath)) {
+ await RNFS.unlink(photoPath);
+ }
+ await RNFS.moveFile(resp.path(), photoPath);
+ logDebug('FILE WRITTEN!');
+ } catch (error) {
+ logDebug(`${error}`);
+ }
+ };
+ fetchAndMovePhoto();
+ }, []);
+ const handlePhotoEditor = () => {
+ RNPhotoEditor.Edit({
+ path: photoPath,
+ onDone: () => {
+ logDebug('on done');
+ },
+ onCancel: () => {
+ logDebug('on cancel');
+ },
+ });
+ };
+ return ;
+};
diff --git a/packages/app-harness/src/components/PhotoEditor/index.tsx b/packages/app-harness/src/components/PhotoEditor/index.tsx
new file mode 100644
index 0000000000..c8a171fd58
--- /dev/null
+++ b/packages/app-harness/src/components/PhotoEditor/index.tsx
@@ -0,0 +1,13 @@
+import React from 'react';
+import { useLoggerContext } from '../../context';
+import { Button } from 'react-native';
+
+export const PhotoEditorButton = () => {
+ const { logDebug } = useLoggerContext();
+
+ const handlePhotoEditor = () => {
+ logDebug('PhotoEditor not supported on this platform');
+ };
+
+ return ;
+};
diff --git a/packages/app-harness/src/components/SplashScreen/index.mobile.ts b/packages/app-harness/src/components/SplashScreen/index.mobile.ts
index f9dd9654ec..77ff63ccf3 100644
--- a/packages/app-harness/src/components/SplashScreen/index.mobile.ts
+++ b/packages/app-harness/src/components/SplashScreen/index.mobile.ts
@@ -1,3 +1,5 @@
import SplashScreen from 'react-native-splash-screen';
-export { SplashScreen };
+export function useSplashScreen() {
+ return { SplashScreen };
+}
diff --git a/packages/app-harness/src/components/SplashScreen/index.ts b/packages/app-harness/src/components/SplashScreen/index.ts
index c7875129df..797c307279 100644
--- a/packages/app-harness/src/components/SplashScreen/index.ts
+++ b/packages/app-harness/src/components/SplashScreen/index.ts
@@ -1,10 +1,20 @@
-const SplashScreen = {
+import { useEffect } from 'react';
+import { NotificationCallback } from '../types';
+import { useLoggerContext } from '../../context';
+
+const SplashScreen = (callback: NotificationCallback) => ({
hide: () => {
- console.log('SplashScreen.hide not supported on this platform');
+ callback('SplashScreen.hide not supported on this platform');
},
show: () => {
- console.log('SplashScreen.show not supported on this platform');
+ callback('SplashScreen.show not supported on this platform');
},
-};
+});
-export { SplashScreen };
+export function useSplashScreen() {
+ const { logDebug } = useLoggerContext();
+ useEffect(() => {
+ //TODO: We could also cache SplashScreen here
+ }, []);
+ return { SplashScreen: SplashScreen(logDebug) };
+}
diff --git a/packages/app-harness/src/components/SplashScreen/types.ts b/packages/app-harness/src/components/SplashScreen/types.ts
new file mode 100644
index 0000000000..2c3e7bd4ba
--- /dev/null
+++ b/packages/app-harness/src/components/SplashScreen/types.ts
@@ -0,0 +1,4 @@
+export type SplashscreenType = {
+ hide: () => void;
+ show: () => void;
+};
diff --git a/packages/app-harness/src/components/types.ts b/packages/app-harness/src/components/types.ts
new file mode 100644
index 0000000000..364f84edcd
--- /dev/null
+++ b/packages/app-harness/src/components/types.ts
@@ -0,0 +1,2 @@
+export type NotificationCallback = (message: string) => void;
+export type NotificationError = { message: string; code: number; details: any };
diff --git a/packages/app-harness/src/context/index.tsx b/packages/app-harness/src/context/index.tsx
new file mode 100644
index 0000000000..37c63f976d
--- /dev/null
+++ b/packages/app-harness/src/context/index.tsx
@@ -0,0 +1,25 @@
+import React, { createContext, useContext, useState, ReactNode, FC } from 'react';
+
+type LogMessage = string;
+
+type LoggerContextType = {
+ logs: LogMessage[];
+ logDebug: (...msg: LogMessage[]) => void;
+};
+type LoggerProviderProps = {
+ children: ReactNode;
+};
+
+const LoggerContext = createContext({} as LoggerContextType);
+
+export const LoggerProvider: FC = ({ children }) => {
+ const [logs, setLogs] = useState([]);
+ const logDebug = (...msg: LogMessage[]) => {
+ setLogs((prevLogs) => prevLogs.concat(msg));
+ console.log(...msg);
+ };
+
+ return {children};
+};
+
+export const useLoggerContext = (): LoggerContextType => useContext(LoggerContext);
diff --git a/packages/app-harness/src/styles/index.ts b/packages/app-harness/src/styles/index.ts
index 9cd30467d7..7ff5e0ef61 100644
--- a/packages/app-harness/src/styles/index.ts
+++ b/packages/app-harness/src/styles/index.ts
@@ -1,7 +1,15 @@
-import { isPlatformIos } from '@rnv/renative';
+import { isPlatformIos, isFactorMobile, isFactorWatch } from '@rnv/renative';
import { StyleSheet } from 'react-native';
const styles = StyleSheet.create({
+ wrapper: {
+ backgroundColor: 'white',
+ position: 'absolute',
+ left: 0,
+ right: 0,
+ bottom: 0,
+ top: 0,
+ },
container: {
flex: 1,
justifyContent: 'center',
@@ -18,13 +26,23 @@ const styles = StyleSheet.create({
header: {
marginTop: isPlatformIos ? 50 : 0, // TODO: remove once safe area view is implemented
flexDirection: 'row',
- height: 50,
+ height: 60,
backgroundColor: 'white',
borderBottomColor: 'black',
borderBottomWidth: 1,
alignItems: 'center',
padding: 10,
},
+ introText: {
+ color: 'black',
+ fontWeight: 'bold',
+ marginHorizontal: 10,
+ display: isFactorMobile || isFactorWatch ? 'none' : 'flex',
+ },
+ dynamicText: {
+ color: 'black',
+ fontSize: isFactorWatch ? 10 : 14,
+ },
});
export default styles;
diff --git a/packages/core/jsonSchema/rnv.app.json b/packages/core/jsonSchema/rnv.app.json
index af37e65f36..9a90fd33c5 100644
--- a/packages/core/jsonSchema/rnv.app.json
+++ b/packages/core/jsonSchema/rnv.app.json
@@ -688,7 +688,7 @@
"properties": {},
"additionalProperties": false
},
- "MainActivity_java": {
+ "MainActivity_kt": {
"type": "object",
"properties": {
"onCreate": {
@@ -723,7 +723,7 @@
},
"additionalProperties": false
},
- "MainApplication_java": {
+ "MainApplication_kt": {
"type": "object",
"properties": {
"imports": {
@@ -1449,20 +1449,6 @@
}
}
},
- "required": [
- "didFinishLaunchingWithOptions",
- "applicationDidBecomeActive",
- "open",
- "supportedInterfaceOrientationsFor",
- "didReceiveRemoteNotification",
- "didFailToRegisterForRemoteNotificationsWithError",
- "didReceive",
- "didRegister",
- "didRegisterForRemoteNotificationsWithDeviceToken",
- "continue",
- "didConnectCarInterfaceController",
- "didDisconnectCarInterfaceController"
- ],
"additionalProperties": false
},
"userNotificationCenter": {
@@ -1481,17 +1467,9 @@
}
}
},
- "required": [
- "willPresent",
- "didReceiveNotificationResponse"
- ],
"additionalProperties": false
}
},
- "required": [
- "application",
- "userNotificationCenter"
- ],
"additionalProperties": false
},
"appDelegateImports": {
@@ -3415,11 +3393,11 @@
},
"additionalProperties": false
},
- "MainActivity_java": {
- "$ref": "#/definitions/rnv.app/properties/platforms/properties/android/properties/templateAndroid/properties/MainActivity_java"
+ "MainActivity_kt": {
+ "$ref": "#/definitions/rnv.app/properties/platforms/properties/android/properties/templateAndroid/properties/MainActivity_kt"
},
- "MainApplication_java": {
- "$ref": "#/definitions/rnv.app/properties/platforms/properties/android/properties/templateAndroid/properties/MainApplication_java"
+ "MainApplication_kt": {
+ "$ref": "#/definitions/rnv.app/properties/platforms/properties/android/properties/templateAndroid/properties/MainApplication_kt"
}
},
"additionalProperties": false
diff --git a/packages/core/jsonSchema/rnv.plugin.json b/packages/core/jsonSchema/rnv.plugin.json
index 6e4a0873cf..238afa2793 100644
--- a/packages/core/jsonSchema/rnv.plugin.json
+++ b/packages/core/jsonSchema/rnv.plugin.json
@@ -372,7 +372,7 @@
},
"additionalProperties": false
},
- "MainActivity_java": {
+ "MainActivity_kt": {
"type": "object",
"properties": {
"onCreate": {
@@ -407,7 +407,7 @@
},
"additionalProperties": false
},
- "MainApplication_java": {
+ "MainApplication_kt": {
"type": "object",
"properties": {
"imports": {
@@ -714,20 +714,6 @@
}
}
},
- "required": [
- "didFinishLaunchingWithOptions",
- "applicationDidBecomeActive",
- "open",
- "supportedInterfaceOrientationsFor",
- "didReceiveRemoteNotification",
- "didFailToRegisterForRemoteNotificationsWithError",
- "didReceive",
- "didRegister",
- "didRegisterForRemoteNotificationsWithDeviceToken",
- "continue",
- "didConnectCarInterfaceController",
- "didDisconnectCarInterfaceController"
- ],
"additionalProperties": false
},
"userNotificationCenter": {
@@ -746,17 +732,9 @@
}
}
},
- "required": [
- "willPresent",
- "didReceiveNotificationResponse"
- ],
"additionalProperties": false
}
},
- "required": [
- "application",
- "userNotificationCenter"
- ],
"additionalProperties": false
},
"appDelegateImports": {
diff --git a/packages/core/jsonSchema/rnv.plugins.json b/packages/core/jsonSchema/rnv.plugins.json
index c22c7b1718..e547809b9e 100644
--- a/packages/core/jsonSchema/rnv.plugins.json
+++ b/packages/core/jsonSchema/rnv.plugins.json
@@ -380,7 +380,7 @@
},
"additionalProperties": false
},
- "MainActivity_java": {
+ "MainActivity_kt": {
"type": "object",
"properties": {
"onCreate": {
@@ -415,7 +415,7 @@
},
"additionalProperties": false
},
- "MainApplication_java": {
+ "MainApplication_kt": {
"type": "object",
"properties": {
"imports": {
@@ -722,20 +722,6 @@
}
}
},
- "required": [
- "didFinishLaunchingWithOptions",
- "applicationDidBecomeActive",
- "open",
- "supportedInterfaceOrientationsFor",
- "didReceiveRemoteNotification",
- "didFailToRegisterForRemoteNotificationsWithError",
- "didReceive",
- "didRegister",
- "didRegisterForRemoteNotificationsWithDeviceToken",
- "continue",
- "didConnectCarInterfaceController",
- "didDisconnectCarInterfaceController"
- ],
"additionalProperties": false
},
"userNotificationCenter": {
@@ -754,17 +740,9 @@
}
}
},
- "required": [
- "willPresent",
- "didReceiveNotificationResponse"
- ],
"additionalProperties": false
}
},
- "required": [
- "application",
- "userNotificationCenter"
- ],
"additionalProperties": false
},
"appDelegateImports": {
diff --git a/packages/core/jsonSchema/rnv.project.json b/packages/core/jsonSchema/rnv.project.json
index 780a887e4d..8865bd7552 100644
--- a/packages/core/jsonSchema/rnv.project.json
+++ b/packages/core/jsonSchema/rnv.project.json
@@ -418,71 +418,54 @@
"templateConfig": {
"type": "object",
"properties": {
- "includedPaths": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "description": "Defines list of all file/dir paths you want to include in template"
+ "disabled": {
+ "type": "boolean"
},
- "bootstrapQuestions": {
+ "includedPaths": {
"type": "array",
"items": {
- "type": "object",
- "properties": {
- "options": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "title": {
- "type": "string"
- },
- "value": {
- "type": "object",
- "properties": {},
- "additionalProperties": false
- }
- },
- "required": [
- "title",
- "value"
- ],
- "additionalProperties": false
- }
+ "anyOf": [
+ {
+ "type": "string"
},
- "configProp": {
+ {
"type": "object",
"properties": {
- "prop": {
- "type": "string"
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
},
- "key": {
- "type": "string"
+ "engines": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
}
},
"required": [
- "prop",
- "key"
+ "paths"
],
"additionalProperties": false
- },
- "type": {
- "type": "string"
- },
- "title": {
- "type": "string"
}
+ ]
+ },
+ "description": "Defines list of all file/dir paths you want to include in template"
+ },
+ "renative_json": {
+ "type": "object",
+ "properties": {
+ "$schema": {
+ "type": "string"
},
- "required": [
- "type",
- "title"
- ],
- "additionalProperties": false
+ "extendsTemplate": {
+ "type": "string"
+ }
},
- "description": "Defines list of custom bootstrap questions"
+ "additionalProperties": true
},
- "packageTemplate": {
+ "package_json": {
"type": "object",
"properties": {
"dependencies": {
@@ -492,13 +475,13 @@
}
},
"devDependencies": {
- "$ref": "#/definitions/rnv.project/properties/templateConfig/properties/packageTemplate/properties/dependencies"
+ "$ref": "#/definitions/rnv.project/properties/templateConfig/properties/package_json/properties/dependencies"
},
"peerDependencies": {
- "$ref": "#/definitions/rnv.project/properties/templateConfig/properties/packageTemplate/properties/dependencies"
+ "$ref": "#/definitions/rnv.project/properties/templateConfig/properties/package_json/properties/dependencies"
},
"optionalDependencies": {
- "$ref": "#/definitions/rnv.project/properties/templateConfig/properties/packageTemplate/properties/dependencies"
+ "$ref": "#/definitions/rnv.project/properties/templateConfig/properties/package_json/properties/dependencies"
},
"name": {
"type": "string"
@@ -507,7 +490,7 @@
"type": "string"
}
},
- "additionalProperties": false
+ "additionalProperties": true
}
},
"additionalProperties": false,
@@ -1163,7 +1146,7 @@
"properties": {},
"additionalProperties": false
},
- "MainActivity_java": {
+ "MainActivity_kt": {
"type": "object",
"properties": {
"onCreate": {
@@ -1198,7 +1181,7 @@
},
"additionalProperties": false
},
- "MainApplication_java": {
+ "MainApplication_kt": {
"type": "object",
"properties": {
"imports": {
@@ -1924,20 +1907,6 @@
}
}
},
- "required": [
- "didFinishLaunchingWithOptions",
- "applicationDidBecomeActive",
- "open",
- "supportedInterfaceOrientationsFor",
- "didReceiveRemoteNotification",
- "didFailToRegisterForRemoteNotificationsWithError",
- "didReceive",
- "didRegister",
- "didRegisterForRemoteNotificationsWithDeviceToken",
- "continue",
- "didConnectCarInterfaceController",
- "didDisconnectCarInterfaceController"
- ],
"additionalProperties": false
},
"userNotificationCenter": {
@@ -1956,17 +1925,9 @@
}
}
},
- "required": [
- "willPresent",
- "didReceiveNotificationResponse"
- ],
"additionalProperties": false
}
},
- "required": [
- "application",
- "userNotificationCenter"
- ],
"additionalProperties": false
},
"appDelegateImports": {
@@ -3890,11 +3851,11 @@
},
"additionalProperties": false
},
- "MainActivity_java": {
- "$ref": "#/definitions/rnv.project/properties/platforms/properties/android/properties/templateAndroid/properties/MainActivity_java"
+ "MainActivity_kt": {
+ "$ref": "#/definitions/rnv.project/properties/platforms/properties/android/properties/templateAndroid/properties/MainActivity_kt"
},
- "MainApplication_java": {
- "$ref": "#/definitions/rnv.project/properties/platforms/properties/android/properties/templateAndroid/properties/MainApplication_java"
+ "MainApplication_kt": {
+ "$ref": "#/definitions/rnv.project/properties/platforms/properties/android/properties/templateAndroid/properties/MainApplication_kt"
}
},
"additionalProperties": false
diff --git a/packages/core/jsonSchema/rnv.template.json b/packages/core/jsonSchema/rnv.template.json
index 29840ca4f2..3d75802603 100644
--- a/packages/core/jsonSchema/rnv.template.json
+++ b/packages/core/jsonSchema/rnv.template.json
@@ -125,13 +125,87 @@
"templateConfig": {
"type": "object",
"properties": {
+ "disabled": {
+ "type": "boolean"
+ },
"includedPaths": {
"type": "array",
"items": {
- "type": "string"
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "paths": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "engines": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "paths"
+ ],
+ "additionalProperties": false
+ }
+ ]
},
"description": "Defines list of all file/dir paths you want to include in template"
},
+ "renative_json": {
+ "type": "object",
+ "properties": {
+ "$schema": {
+ "type": "string"
+ },
+ "extendsTemplate": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": true
+ },
+ "package_json": {
+ "type": "object",
+ "properties": {
+ "dependencies": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ "devDependencies": {
+ "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/package_json/properties/dependencies"
+ },
+ "peerDependencies": {
+ "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/package_json/properties/dependencies"
+ },
+ "optionalDependencies": {
+ "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/package_json/properties/dependencies"
+ },
+ "name": {
+ "type": "string"
+ },
+ "version": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": true
+ }
+ },
+ "additionalProperties": false,
+ "description": "Used in `renative.template.json` allows you to define template behaviour."
+ },
+ "bootstrapConfig": {
+ "type": "object",
+ "properties": {
"bootstrapQuestions": {
"type": "array",
"items": {
@@ -146,9 +220,21 @@
"type": "string"
},
"value": {
- "type": "object",
- "properties": {},
- "additionalProperties": false
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {}
+ },
+ {
+ "type": "string"
+ },
+ {
+ "type": "number"
+ },
+ {
+ "type": "boolean"
+ }
+ ]
}
},
"required": [
@@ -179,6 +265,28 @@
},
"title": {
"type": "string"
+ },
+ "onConfirm": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "action": {
+ "type": "string"
+ },
+ "prop": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "action",
+ "path"
+ ],
+ "additionalProperties": false
+ }
}
},
"required": [
@@ -189,36 +297,46 @@
},
"description": "Defines list of custom bootstrap questions"
},
- "packageTemplate": {
+ "rnvNewPatchDependencies": {
+ "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/package_json/properties/dependencies",
+ "description": "This ensures that the correct version of the npm packages will be used to run the project for the first time after creation"
+ },
+ "configModifiers": {
"type": "object",
"properties": {
- "dependencies": {
- "type": "object",
- "additionalProperties": {
- "type": "string"
+ "engines": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "supportedPlatforms": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "nullifyIfFalse": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "name",
+ "supportedPlatforms"
+ ],
+ "additionalProperties": false
}
- },
- "devDependencies": {
- "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/packageTemplate/properties/dependencies"
- },
- "peerDependencies": {
- "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/packageTemplate/properties/dependencies"
- },
- "optionalDependencies": {
- "$ref": "#/definitions/rnv.template/properties/templateConfig/properties/packageTemplate/properties/dependencies"
- },
- "name": {
- "type": "string"
- },
- "version": {
- "type": "string"
}
},
+ "required": [
+ "engines"
+ ],
"additionalProperties": false
}
},
- "additionalProperties": false,
- "description": "Used in `renative.template.json` allows you to define template behaviour."
+ "additionalProperties": false
},
"$schema": {
"type": "string",
diff --git a/packages/core/src/api/types.ts b/packages/core/src/api/types.ts
index bdc08413ed..b88b8d963c 100644
--- a/packages/core/src/api/types.ts
+++ b/packages/core/src/api/types.ts
@@ -116,9 +116,4 @@ export type PromptParams = {
export type PromptRenderFn = (i: number, obj: any, mapping: any, defaultVal: string) => string;
-export type GetConfigPropFn = (
- c: RnvContext,
- platform: RnvPlatform,
- key: T,
- defaultVal?: ConfigProp[T]
-) => ConfigProp[T];
+export type GetConfigPropFn = (key: T, defaultVal?: ConfigProp[T]) => ConfigProp[T];
diff --git a/packages/core/src/buildHooks/index.ts b/packages/core/src/buildHooks/index.ts
index 486d78e86b..5c96b4cdbe 100644
--- a/packages/core/src/buildHooks/index.ts
+++ b/packages/core/src/buildHooks/index.ts
@@ -3,14 +3,15 @@ import { build } from 'esbuild';
import { logDebug, logError, logHook, logInfo } from '../logger';
import { fsExistsSync, copyFolderContentsRecursiveSync } from '../system/fs';
import { doResolve } from '../system/resolve';
-import { RnvContext } from '../context/types';
import { inquirerPrompt } from '../api';
import { getConfigProp } from '../context/contextProps';
+import { getContext } from '../context/provider';
-export const executePipe = async (c: RnvContext, key: string) => {
+export const executePipe = async (key: string) => {
+ const c = getContext();
logDebug('executePipe', c?.program?.json ? key : `('${key}')`);
- await buildHooks(c);
+ await buildHooks();
const pipes = c.buildPipes ? c.buildPipes[key] : null;
@@ -24,10 +25,10 @@ export const executePipe = async (c: RnvContext, key: string) => {
}
};
-export const buildHooks = async (c: RnvContext) => {
+export const buildHooks = async () => {
logDebug('buildHooks');
-
- const enableHookRebuild = getConfigProp(c, c.platform, 'enableHookRebuild');
+ const c = getContext();
+ const enableHookRebuild = getConfigProp('enableHookRebuild');
let shouldBuildHook =
c.program.reset ||
diff --git a/packages/core/src/configs/appConfigs.ts b/packages/core/src/configs/appConfigs.ts
index 8943625d0e..1456cfc136 100644
--- a/packages/core/src/configs/appConfigs.ts
+++ b/packages/core/src/configs/appConfigs.ts
@@ -2,14 +2,15 @@ import path from 'path';
import { fsExistsSync, fsReaddirSync, fsLstatSync, readObjectSync } from '../system/fs';
import { logDefault, logWarning } from '../logger';
-import { RnvContext } from '../context/types';
import { ConfigFileApp } from '../schema/configFiles/types';
import { ConfigName } from '../enums/configName';
+import { getContext } from '../context/provider';
const IGNORE_FOLDERS = ['.git'];
-export const listAppConfigsFoldersSync = (c: RnvContext, ignoreHiddenConfigs: boolean, appConfigsDirPath?: string) => {
+export const listAppConfigsFoldersSync = (ignoreHiddenConfigs: boolean, appConfigsDirPath?: string) => {
logDefault('listAppConfigsFoldersSync', `ignoreHiddenConfigs:${!!ignoreHiddenConfigs}`);
+ const c = getContext();
if (!c.paths?.project) return [];
diff --git a/packages/core/src/configs/buildConfig.ts b/packages/core/src/configs/buildConfig.ts
index 7ef9b7fa27..9ca3e52e3d 100644
--- a/packages/core/src/configs/buildConfig.ts
+++ b/packages/core/src/configs/buildConfig.ts
@@ -17,8 +17,9 @@ import { PlatformKey } from '../schema/types';
const _arrayMergeOverride = (_destinationArray: Array, sourceArray: Array) => sourceArray;
-const getEnginesPluginDelta = (c: RnvContext) => {
+const getEnginesPluginDelta = () => {
logDebug('getEnginesPluginDelta');
+ const c = getContext();
if (!c.buildConfig) return;
@@ -44,10 +45,10 @@ const getEnginesPluginDelta = (c: RnvContext) => {
return enginePlugins;
};
-export const generateBuildConfig = (_c?: RnvContext) => {
+export const generateBuildConfig = () => {
logDebug('generateBuildConfig');
- const c = _c || getContext();
+ const c = getContext();
const mergeOrder = [
c.paths.defaultWorkspace.config,
@@ -88,7 +89,7 @@ export const generateBuildConfig = (_c?: RnvContext) => {
});
}
- const extraPlugins = getEnginesPluginDelta(c);
+ const extraPlugins = getEnginesPluginDelta();
const mergeFiles = [
c.files.defaultWorkspace.config,
diff --git a/packages/core/src/configs/configLocal.ts b/packages/core/src/configs/configLocal.ts
index 07235ee9bc..6af61257cd 100644
--- a/packages/core/src/configs/configLocal.ts
+++ b/packages/core/src/configs/configLocal.ts
@@ -1,9 +1,11 @@
-import { RnvContext } from '../context/types';
+import { getContext } from '../context/provider';
import { logDefault } from '../logger';
import { writeFileSync } from '../system/fs';
-export const generateLocalConfig = (c: RnvContext, resetAppId?: boolean) => {
+export const generateLocalConfig = (resetAppId?: boolean) => {
logDefault('generateLocalConfig', `resetAppId:${!!resetAppId}`);
+ const c = getContext();
+
const configLocal = c.files.project.configLocal || {};
configLocal._meta = configLocal._meta || {};
if (resetAppId) {
diff --git a/packages/core/src/configs/configProject.ts b/packages/core/src/configs/configProject.ts
index 57b5c9d9b3..028f9ecf2c 100644
--- a/packages/core/src/configs/configProject.ts
+++ b/packages/core/src/configs/configProject.ts
@@ -1,10 +1,10 @@
import { getRealPath, writeFileSync } from '../system/fs';
import { chalk, logDefault, logWarning } from '../logger';
-import { RnvContext } from '../context/types';
import { RnvPlatform } from '../types';
import { PlatformKey } from '../schema/types';
import { NpmPackageFile } from './types';
import { ConfigFileProject } from '../schema/configFiles/types';
+import { getContext } from '../context/provider';
const SYNCED_DEPS = [
'rnv',
@@ -22,9 +22,11 @@ const SYNCED_DEPS = [
const SYNCED_TEMPLATES = ['@rnv/template-starter'];
-export const upgradeProjectDependencies = (c: RnvContext, version: string) => {
+export const upgradeProjectDependencies = (version: string) => {
logDefault('upgradeProjectDependencies');
+ const c = getContext();
+
// const templates = c.files.project.config?.templates;
// TODO: Make this dynamically injected
// SYNC DEPS
@@ -81,7 +83,9 @@ const _fixDeps = (deps: Record | undefined, version: string) =>
});
};
-export const updateProjectPlatforms = (c: RnvContext, platforms: Array) => {
+export const updateProjectPlatforms = (platforms: Array) => {
+ const c = getContext();
+
const {
project: { config },
} = c.paths;
@@ -95,8 +99,10 @@ export const updateProjectPlatforms = (c: RnvContext, platforms: Array {
+export const generatePlatformTemplatePaths = () => {
logDefault('generatePlatformTemplatePaths');
+ const c = getContext();
+
if (!c.buildConfig.paths) {
logWarning(`You're missing paths object in your ${chalk().red(c.paths.project.config)}`);
c.buildConfig.paths = {
@@ -117,14 +123,14 @@ export const generatePlatformTemplatePaths = (c: RnvContext) => {
if (originalPath) {
if (!pt[platform]) {
- const pt1 = getRealPath(c, originalPath, 'platformTemplatesDir', originalPath);
+ const pt1 = getRealPath(originalPath, 'platformTemplatesDir', originalPath);
if (pt1) {
result[platform] = pt1;
} else {
logWarning(`Cannot resolve originalTemplatePlatformsDir: ${originalPath}. SKIPPING...`);
}
} else {
- const pt2 = getRealPath(c, pt[platform], 'platformTemplatesDir', originalPath);
+ const pt2 = getRealPath(pt[platform], 'platformTemplatesDir', originalPath);
if (pt2) {
result[platform] = pt2;
} else {
diff --git a/packages/core/src/configs/engines.ts b/packages/core/src/configs/engines.ts
index 0b9708a6c6..add9577dc7 100644
--- a/packages/core/src/configs/engines.ts
+++ b/packages/core/src/configs/engines.ts
@@ -3,6 +3,7 @@ import { RnvEngineTemplate, RnvEngineTemplateMap } from '../engines/types';
import { logWarning } from '../logger';
import { RnvPlatform } from '../types';
import { getConfigProp } from '../context/contextProps';
+import { getContext } from '../context/provider';
const _getMergedEngineConfigs = (c: RnvContext) => {
const engines = c.buildConfig?.engines;
@@ -33,12 +34,13 @@ const _getMergedEngineConfigs = (c: RnvContext) => {
return mergedEngineConfigs;
};
-export const getEngineTemplateByPlatform = (c: RnvContext, platform: RnvPlatform): RnvEngineTemplate | null => {
+export const getEngineTemplateByPlatform = (platform: RnvPlatform): RnvEngineTemplate | null => {
+ const c = getContext();
const mergedEngineConfigs = _getMergedEngineConfigs(c);
if (!platform) return null;
const engineId =
c.program.engine ||
- getConfigProp(c, platform, 'engine') ||
+ getConfigProp('engine') ||
//Adding this as default engines moved from platforms into platformTemplates
c.files.rnv.projectTemplates.config?.platformTemplates?.[platform]?.engine;
let selectedEngineConfig: RnvEngineTemplate | null = null;
diff --git a/packages/core/src/configs/index.ts b/packages/core/src/configs/index.ts
index f51e7574d9..02a845017a 100644
--- a/packages/core/src/configs/index.ts
+++ b/packages/core/src/configs/index.ts
@@ -12,13 +12,10 @@ import { getWorkspaceDirPath } from './workspaces';
import { generatePlatformTemplatePaths } from './configProject';
import { ConfigFileTemplates } from '../schema/configFiles/types';
import { ConfigName } from '../enums/configName';
+import { getContext } from '../context/provider';
-export const loadFileExtended = (
- c: RnvContext,
- fileObj: Record,
- pathObj: RnvContextPathObj,
- key: RnvContextFileKey
-) => {
+export const loadFileExtended = (fileObj: Record, pathObj: RnvContextPathObj, key: RnvContextFileKey) => {
+ const c = getContext();
const result = loadFile(fileObj, pathObj, key);
if (fileObj[key]) {
fileObj[`${key}_original`] = { ...fileObj[key] };
@@ -71,15 +68,15 @@ const _loadConfigFiles = (
// let result = false;
let extendAppId: string | undefined;
- const extendedFileLoadResult = loadFileExtended(c, fileObj, pathObj, 'config');
+ const extendedFileLoadResult = loadFileExtended(fileObj, pathObj, 'config');
const fileObjConfig = fileObj.config;
if (fileObjConfig && 'extend' in fileObjConfig && extendedFileLoadResult) {
extendAppId = (fileObjConfig.extend as string) || extendAppId;
// result = true;
}
- loadFileExtended(c, fileObj, pathObj, 'configLocal');
- loadFileExtended(c, fileObj, pathObj, 'configPrivate');
+ loadFileExtended(fileObj, pathObj, 'configLocal');
+ loadFileExtended(fileObj, pathObj, 'configPrivate');
//Do not Extend local configs
// if (loadFileExtended(c, fileObj, pathObj, 'configLocal')) {
// extendAppId = fileObj.configLocal?.extend || extendAppId;
@@ -125,9 +122,9 @@ const _loadConfigFiles = (
pathObj.configsPrivate.push(pathObj1.configPrivate);
pathObj.configsLocal.push(pathObj1.configLocal);
// FILE1: appConfigs/base
- loadFileExtended(c, fileObj1, pathObj1, 'config');
- loadFileExtended(c, fileObj1, pathObj1, 'configPrivate');
- loadFileExtended(c, fileObj1, pathObj1, 'configLocal');
+ loadFileExtended(fileObj1, pathObj1, 'config');
+ loadFileExtended(fileObj1, pathObj1, 'configPrivate');
+ loadFileExtended(fileObj1, pathObj1, 'configLocal');
if (fileObj1.config) fileObj.configs.push(fileObj1.config);
if (fileObj1.configPrivate) fileObj.configsPrivate.push(fileObj1.configPrivate);
if (fileObj1.configLocal) fileObj.configsLocal.push(fileObj1.configLocal);
@@ -155,9 +152,9 @@ const _loadConfigFiles = (
pathObj.configsLocal.push(pathObj2.configLocal);
pathObj.configsPrivate.push(pathObj2.configPrivate);
// FILE2: appConfigs/
- loadFileExtended(c, fileObj2, pathObj2, 'config');
- loadFileExtended(c, fileObj2, pathObj2, 'configPrivate');
- loadFileExtended(c, fileObj2, pathObj2, 'configLocal');
+ loadFileExtended(fileObj2, pathObj2, 'config');
+ loadFileExtended(fileObj2, pathObj2, 'configPrivate');
+ loadFileExtended(fileObj2, pathObj2, 'configLocal');
if (fileObj2.config) fileObj.configs.push(fileObj2.config);
if (fileObj2.configLocal) fileObj.configsLocal.push(fileObj2.configLocal);
@@ -174,20 +171,22 @@ const _loadConfigFiles = (
pathObj.configsLocal.push(path.join(path3, ConfigName.renativeLocal));
pathObj.configsPrivate.push(path.join(path3, ConfigName.renativePrivate));
// FILE3: appConfigs/
- loadFileExtended(c, fileObj, pathObj, 'config');
- loadFileExtended(c, fileObj, pathObj, 'configPrivate');
- loadFileExtended(c, fileObj, pathObj, 'configLocal');
+ loadFileExtended(fileObj, pathObj, 'config');
+ loadFileExtended(fileObj, pathObj, 'configPrivate');
+ loadFileExtended(fileObj, pathObj, 'configLocal');
if (fileObj.config) fileObj.configs.push(fileObj.config);
if (fileObj.configPrivate) fileObj.configsPrivate.push(fileObj.configPrivate);
if (fileObj.configLocal) fileObj.configsLocal.push(fileObj.configLocal);
}
- generateBuildConfig(c);
+ generateBuildConfig();
// return result;
};
-export const parseRenativeConfigs = async (c: RnvContext) => {
+export const parseRenativeConfigs = async () => {
logDefault('parseRenativeConfigs');
+ const c = getContext();
+
// LOAD ./package.json
loadFile(c.files.project, c.paths.project, 'package');
@@ -204,7 +203,7 @@ export const parseRenativeConfigs = async (c: RnvContext) => {
loadFile(c.files.project.builds, c.paths.project.builds, 'config');
// LOAD WORKSPACE /RENATIVE.*.JSON
- const wsDir = getRealPath(c, await getWorkspaceDirPath(c));
+ const wsDir = getRealPath(await getWorkspaceDirPath(c));
if (wsDir) {
generateContextPaths(c.paths.workspace, wsDir);
_loadConfigFiles(c, c.files.workspace, c.paths.workspace);
@@ -238,7 +237,7 @@ export const parseRenativeConfigs = async (c: RnvContext) => {
c.paths.workspace.project.appConfigBase.dir = path.join(c.paths.workspace.project.dir, 'appConfigs', 'base');
- generatePlatformTemplatePaths(c);
+ generatePlatformTemplatePaths();
if (c.runtime.appId) {
if (!c.files.appConfig.config) {
@@ -252,7 +251,7 @@ export const parseRenativeConfigs = async (c: RnvContext) => {
}
}
- const workspaceAppConfigsDir = getRealPath(c, c.buildConfig.workspaceAppConfigsDir);
+ const workspaceAppConfigsDir = getRealPath(c.buildConfig.workspaceAppConfigsDir);
c.paths.workspace.project.appConfigsDir =
workspaceAppConfigsDir || path.join(c.paths.workspace.project.dir, 'appConfigs');
@@ -268,14 +267,14 @@ export const parseRenativeConfigs = async (c: RnvContext) => {
// LOAD WORKSPACE /RENATIVE.*.JSON
const wsPath = await getWorkspaceDirPath(c);
if (wsPath) {
- const wsPathReal = getRealPath(c, wsPath);
+ const wsPathReal = getRealPath(wsPath);
if (wsPathReal) {
generateContextPaths(c.paths.workspace, wsPathReal);
_loadConfigFiles(c, c.files.workspace, c.paths.workspace);
}
}
- generateLocalConfig(c);
- generateBuildConfig(c);
+ generateLocalConfig();
+ generateBuildConfig();
}
};
diff --git a/packages/core/src/configs/platformAssets.ts b/packages/core/src/configs/platformAssets.ts
index 767cf473e5..40d9c52220 100644
--- a/packages/core/src/configs/platformAssets.ts
+++ b/packages/core/src/configs/platformAssets.ts
@@ -1,10 +1,11 @@
import { sanitizeDynamicProps, mergeObjects, fsExistsSync, writeFileSync } from '../system/fs';
-import { RnvContext } from '../context/types';
import { getConfigProp } from '../context/contextProps';
import { logDefault } from '../logger';
+import { getContext } from '../context/provider';
-export const generatePlatformAssetsRuntimeConfig = async (c: RnvContext) => {
+export const generatePlatformAssetsRuntimeConfig = async () => {
logDefault('generateRuntimeConfig');
+ const c = getContext();
// c.assetConfig = {
// common: c.buildConfig.common,
// runtime: c.buildConfig.runtime
@@ -16,7 +17,7 @@ export const generatePlatformAssetsRuntimeConfig = async (c: RnvContext) => {
c.assetConfig,
c.platform ? c.buildConfig.platforms?.[c.platform]?.runtime || {} : {}
);
- c.assetConfig = mergeObjects(c, c.assetConfig, getConfigProp(c, c.platform, 'runtime') || {});
+ c.assetConfig = mergeObjects(c, c.assetConfig, getConfigProp('runtime') || {});
if (fsExistsSync(c.paths.project.assets.dir)) {
const sanitizedConfig = sanitizeDynamicProps(c.assetConfig, {
diff --git a/packages/core/src/configs/templates.ts b/packages/core/src/configs/templates.ts
index b0ba10a9c9..b7f2100bc0 100644
--- a/packages/core/src/configs/templates.ts
+++ b/packages/core/src/configs/templates.ts
@@ -1,11 +1,12 @@
import { generateOptions } from '../api';
-import { RnvContext } from '../context/types';
+import { getContext } from '../context/provider';
import { chalk, logInfo, logDefault, logWarning } from '../logger';
import { doResolve } from '../system/resolve';
import { writeRenativeConfigFile } from './utils';
-export const checkIfTemplateConfigured = async (c: RnvContext) => {
+export const checkIfTemplateConfigured = async () => {
logDefault('checkIfTemplateConfigured');
+ const c = getContext();
if (c.program.skipDependencyCheck || c.files.project.config?.isTemplate) return true;
if (!c.buildConfig.templates) {
logWarning(
@@ -33,12 +34,13 @@ export const checkIfTemplateConfigured = async (c: RnvContext) => {
}
});
- writeRenativeConfigFile(c, c.paths.project.package, c.files.project.package);
+ writeRenativeConfigFile(c.paths.project.package, c.files.project.package);
return true;
};
-export const getTemplateOptions = (c: RnvContext, isGlobalScope?: boolean) => {
+export const getTemplateOptions = (isGlobalScope?: boolean) => {
+ const c = getContext();
let defaultProjectTemplates;
if (isGlobalScope) {
defaultProjectTemplates = c.files.rnv.projectTemplates.config?.projectTemplates;
diff --git a/packages/core/src/configs/utils.ts b/packages/core/src/configs/utils.ts
index da0925c488..b7f4c739f4 100644
--- a/packages/core/src/configs/utils.ts
+++ b/packages/core/src/configs/utils.ts
@@ -1,10 +1,9 @@
-import { RnvContext } from '../context/types';
import { logDebug } from '../logger';
import { writeFileSync } from '../system/fs';
import { generateBuildConfig } from './buildConfig';
-export const writeRenativeConfigFile = (c: RnvContext, configPath: string | undefined, configData: string | object) => {
+export const writeRenativeConfigFile = (configPath: string | undefined, configData: string | object) => {
logDebug(`writeRenativeConfigFile:${configPath}`);
writeFileSync(configPath, configData);
- generateBuildConfig(c);
+ generateBuildConfig();
};
diff --git a/packages/core/src/configs/workspaces.ts b/packages/core/src/configs/workspaces.ts
index 0a898472e8..5a7df95712 100644
--- a/packages/core/src/configs/workspaces.ts
+++ b/packages/core/src/configs/workspaces.ts
@@ -8,7 +8,8 @@ import { RnvContext } from '../context/types';
import { generateOptions, inquirerPrompt } from '../api';
import { ConfigFileWorkspace, ConfigFileWorkspaces } from '../schema/configFiles/types';
-export const createWorkspace = async (c: RnvContext, workspaceID: string, workspacePath: string) => {
+export const createWorkspace = async (workspaceID: string, workspacePath: string) => {
+ const c = getContext();
const cnf = c.files.rnv.configWorkspaces;
if (!cnf) return;
@@ -63,7 +64,7 @@ export const getWorkspaceDirPath = async (c: RnvContext) => {
c.runtime.isWSConfirmed = true;
}
if (confirm) {
- await createWorkspace(c, ws, wsDir);
+ await createWorkspace(ws, wsDir);
}
}
}
diff --git a/packages/core/src/context/contextProps.ts b/packages/core/src/context/contextProps.ts
index 7341483d16..c35bd1ca42 100644
--- a/packages/core/src/context/contextProps.ts
+++ b/packages/core/src/context/contextProps.ts
@@ -3,10 +3,11 @@ import { RnvContext } from './types';
import { chalk, logError, logWarning } from '../logger';
import { ConfigFileBuildConfig } from '../schema';
import { ConfigProp, ConfigPropKey } from '../schema/types';
-import { BuildConfigPropKey, BuildSchemePropKey, CommonPropKey, PlatPropKey, RnvPlatform } from '../types';
+import { BuildConfigPropKey, BuildSchemePropKey, CommonPropKey, PlatPropKey } from '../types';
import { TimestampPathsConfig } from '../system/types';
import path from 'path';
import { fsExistsSync } from '../system/fs';
+import { getContext } from './provider';
const _getValueOrMergedObject = (resultScheme: object, resultPlatforms: object, resultCommon: object) => {
if (resultScheme !== undefined) {
@@ -27,25 +28,24 @@ const _getValueOrMergedObject = (resultScheme: object, resultPlatforms: object,
};
export const getConfigProp: GetConfigPropFn = (
- c: RnvContext,
- platform: RnvPlatform,
key: T,
defaultVal?: ConfigProp[T]
): ConfigProp[T] => {
+ const c = getContext();
if (!c.buildConfig) {
logError('getConfigProp: c.buildConfig is undefined!');
return undefined;
}
- return _getConfigProp(c, platform, key, defaultVal, c.buildConfig);
+ return _getConfigProp(c, key, defaultVal, c.buildConfig);
};
export const _getConfigProp = (
c: RnvContext,
- platform: RnvPlatform,
key: T,
defaultVal?: ConfigProp[T],
sourceObj?: Partial
): ConfigProp[T] => {
+ const { platform } = c;
if (!sourceObj || !platform) return undefined;
const platformObj = sourceObj.platforms?.[platform];
@@ -56,22 +56,22 @@ export const _getConfigProp = (
let scheme;
if (platformObj && ps) {
scheme = platformObj.buildSchemes?.[ps] || {};
- resultPlatforms = getFlavouredProp(c, platformObj, key as PlatPropKey);
+ resultPlatforms = getFlavouredProp(platformObj, key as PlatPropKey);
} else {
scheme = {};
}
const resultScheme = key && scheme[key as BuildSchemePropKey];
- const resultCommonRoot = getFlavouredProp(c, sourceObj.common || {}, key as CommonPropKey);
+ const resultCommonRoot = getFlavouredProp(sourceObj.common || {}, key as CommonPropKey);
const resultCommonScheme =
c.runtime.scheme &&
- getFlavouredProp(c, sourceObj.common?.buildSchemes?.[c.runtime.scheme] || {}, key as BuildSchemePropKey);
+ getFlavouredProp(sourceObj.common?.buildSchemes?.[c.runtime.scheme] || {}, key as BuildSchemePropKey);
const resultCommon = resultCommonScheme || resultCommonRoot;
let result = _getValueOrMergedObject(resultScheme, resultPlatforms, resultCommon);
if (result === undefined) {
- result = getFlavouredProp(c, sourceObj, key as BuildConfigPropKey);
+ result = getFlavouredProp(sourceObj, key as BuildConfigPropKey);
}
if (result === undefined) result = defaultVal; // default the value only if it's not specified in any of the files. i.e. undefined
@@ -79,7 +79,8 @@ export const _getConfigProp = (
return result as ConfigProp[T];
};
-export const getFlavouredProp = (c: RnvContext, obj: T, key: K): T[K] | undefined => {
+export const getFlavouredProp = (obj: T, key: K): T[K] | undefined => {
+ const c = getContext();
if (!key || !obj || typeof key !== 'string') return undefined;
const keyScoped = `${key}@${c.runtime.scheme}` as K;
const val1 = obj[keyScoped];
@@ -87,11 +88,13 @@ export const getFlavouredProp = (c: RnvContext, obj: T, ke
return obj[key];
};
-export const getTimestampPathsConfig = (c: RnvContext, platform: RnvPlatform): TimestampPathsConfig | undefined => {
+export const getTimestampPathsConfig = (): TimestampPathsConfig | undefined => {
+ const c = getContext();
+ const { platform } = c;
let timestampBuildFiles: Array = [];
const pPath = path.join(c.paths.project.builds.dir, `${c.runtime.appId}_${platform}`);
if (platform === 'web') {
- timestampBuildFiles = (getConfigProp(c, platform, 'timestampBuildFiles') || []).map((v) => path.join(pPath, v));
+ timestampBuildFiles = (getConfigProp('timestampBuildFiles') || []).map((v) => path.join(pPath, v));
}
if (timestampBuildFiles?.length && c.runtime.timestamp) {
return { paths: timestampBuildFiles, timestamp: c.runtime.timestamp };
@@ -100,7 +103,8 @@ export const getTimestampPathsConfig = (c: RnvContext, platform: RnvPlatform): T
};
//TODO: rename to getPlatformBuildAppDir ???
-export const getAppFolder = (c: RnvContext, isRelativePath?: boolean) => {
+export const getAppFolder = (isRelativePath?: boolean) => {
+ const c = getContext();
if (isRelativePath) {
return `platformBuilds/${c.runtime.appId}_${c.platform}${c.runtime._platformBuildsSuffix || ''}`;
}
@@ -110,15 +114,18 @@ export const getAppFolder = (c: RnvContext, isRelativePath?: boolean) => {
);
};
-export const getPlatformProjectDir = (c: RnvContext) => {
+export const getPlatformProjectDir = () => {
+ const c = getContext();
if (!c.runtime.engine) {
logError('getPlatformProjectDir not available without specific engine');
return null;
}
- return path.join(getAppFolder(c), c.runtime.engine.projectDirName || '');
+ return path.join(getAppFolder(), c.runtime.engine.projectDirName || '');
};
-export const getAppConfigBuildsFolder = (c: RnvContext, platform: RnvPlatform, customPath?: string) => {
+export const getAppConfigBuildsFolder = (customPath?: string) => {
+ const c = getContext();
+ const { platform } = c;
const pp = customPath || c.paths.appConfig.dir;
if (!pp) {
logWarning(
diff --git a/packages/core/src/context/runtime.ts b/packages/core/src/context/runtime.ts
index 5af75c8c60..68d154a996 100644
--- a/packages/core/src/context/runtime.ts
+++ b/packages/core/src/context/runtime.ts
@@ -6,8 +6,11 @@ import { RnvContext, RnvContextPlatform } from './types';
import { generateRuntimePropInjects } from '../system/injectors';
import { getConfigProp } from './contextProps';
import { logDebug, logDefault } from '../logger';
+import { getContext } from './provider';
+
+export const configureRuntimeDefaults = async () => {
+ const c = getContext();
-export const configureRuntimeDefaults = async (c: RnvContext) => {
c.runtime.appId = c.files.project?.configLocal?._meta?.currentAppConfigId || _getAppId(c);
if (c.runtime.appId) {
c.runtime.appConfigDir = path.join(c.paths.project.appConfigsDir, c.runtime.appId);
@@ -46,7 +49,7 @@ export const configureRuntimeDefaults = async (c: RnvContext) => {
generateRuntimePropInjects();
if (c.buildConfig) {
- c.runtime.bundleAssets = getConfigProp(c, c.platform, 'bundleAssets') || false;
+ c.runtime.bundleAssets = getConfigProp('bundleAssets') || false;
const { hosted } = c.program;
c.runtime.hosted = hosted && c.runtime.currentPlatform?.isWebHosted;
@@ -54,7 +57,7 @@ export const configureRuntimeDefaults = async (c: RnvContext) => {
c.runtime.supportedPlatforms = [];
c.buildConfig.defaults.supportedPlatforms.forEach((platform) => {
//TODO: migrate to singular platform engine
- const engine = getEngineRunnerByPlatform(c, platform);
+ const engine = getEngineRunnerByPlatform(platform);
if (engine) {
const dir = engine.originalTemplatePlatformsDir;
@@ -63,7 +66,7 @@ export const configureRuntimeDefaults = async (c: RnvContext) => {
const pDir = c.paths.project.platformTemplatesDirs?.[platform];
if (pDir) {
isValid = true;
- isConnected = pDir?.includes?.(getRealPath(c, dir) || 'UNDEFINED');
+ isConnected = pDir?.includes?.(getRealPath(dir) || 'UNDEFINED');
}
const port = c.buildConfig.defaults?.ports?.[platform] || c.runtime.currentPlatform?.defaultPort;
const cp: RnvContextPlatform = {
diff --git a/packages/core/src/engines/index.ts b/packages/core/src/engines/index.ts
index aa9a254f61..ee40e7649b 100644
--- a/packages/core/src/engines/index.ts
+++ b/packages/core/src/engines/index.ts
@@ -118,8 +118,10 @@ export const configureEngines = async (c: RnvContext) => {
return true;
};
-export const registerMissingPlatformEngines = async (c: RnvContext, taskInstance?: RnvTask) => {
+export const registerMissingPlatformEngines = async (taskInstance?: RnvTask) => {
logDefault('registerMissingPlatformEngines');
+ const c = getContext();
+
if (
!taskInstance ||
(!taskInstance.isGlobalScope && taskInstance?.platforms?.length === 0) ||
@@ -138,7 +140,8 @@ export const registerMissingPlatformEngines = async (c: RnvContext, taskInstance
return true;
};
-export const registerAllPlatformEngines = async (c: RnvContext) => {
+export const registerAllPlatformEngines = async () => {
+ const c = getContext();
logDefault('registerAllPlatformEngines');
if (!c.buildConfig?.defaults?.supportedPlatforms?.forEach) {
@@ -157,8 +160,10 @@ export const registerAllPlatformEngines = async (c: RnvContext) => {
return true;
};
-export const loadEnginePluginDeps = async (c: RnvContext, engineConfigs: Array) => {
+export const loadEnginePluginDeps = async (engineConfigs: Array) => {
logDefault('loadEnginePluginDeps');
+ const c = getContext();
+
if (c.files.project.config?.isTemplate) return 0;
const cnf = c.files.project.config_original;
@@ -206,14 +211,16 @@ If you don't want to use this dependency make sure you remove platform which req
logInfo(`Adding ${addedPluginsKeys.join(',')}. ...DONE`);
// Prepare original file to be decorated (as addon plugins as we can't edit template itself)
cnf.plugins = originalProjectPlugins;
- writeRenativeConfigFile(c, c.paths.project.config, cnf);
+ writeRenativeConfigFile(c.paths.project.config, cnf);
}
}
return Object.keys(addedPlugins).length;
};
-export const loadEnginePackageDeps = async (c: RnvContext, engineConfigs: Array) => {
+export const loadEnginePackageDeps = async (engineConfigs: Array) => {
logDefault('loadEnginePackageDeps');
+ const c = getContext();
+
if (c.program.skipDependencyCheck || c.files.project.config?.isTemplate) return 0;
// Check engine dependencies
const addedDeps = [];
@@ -226,7 +233,7 @@ export const loadEnginePackageDeps = async (c: RnvContext, engineConfigs: Array<
const deps = c.files.project.package.devDependencies || {};
Object.keys(npm.devDependencies).forEach((k) => {
if (!deps[k]) {
- const isMonorepo = getConfigProp(c, c.platform, 'isMonorepo');
+ const isMonorepo = getConfigProp('isMonorepo');
if (isMonorepo) {
logInfo(
`Engine ${ecf.key} requires npm devDependency ${k} for platform ${platform}. project marked as monorepo. SKIPPING`
@@ -357,8 +364,10 @@ const getScopedVersion = (
return null;
};
-export const loadEngines = async (c: RnvContext, failOnMissingDeps?: boolean): Promise => {
+export const loadEngines = async (failOnMissingDeps?: boolean): Promise => {
logDefault('loadEngines');
+ const c = getContext();
+
if (!fsExistsSync(c.paths.project.config)) return true;
const filteredEngines: Record = _getFilteredEngines(c);
@@ -398,7 +407,7 @@ ${enginesToInstall.map((v) => `> ${v.key}@${v.version} path: ${v.engineRootPath}
${enginesToInstall.map((v) => `> ${v.key}@${v.version}`).join('\n')}
ADDING TO PACKAGE.JSON...DONE`);
- await checkAndCreateProjectPackage(c);
+ await checkAndCreateProjectPackage();
const pkg = c.files.project.package;
const devDeps = pkg.devDependencies || {};
pkg.devDependencies = devDeps;
@@ -409,17 +418,17 @@ ${enginesToInstall.map((v) => `> ${v.key}@${v.version}`).join('\n')}
});
writeFileSync(c.paths.project.package, c.files.project.package);
- await installPackageDependencies(c);
- return loadEngines(c, true);
+ await installPackageDependencies();
+ return loadEngines(true);
}
- const plugDepsCount = await loadEnginePluginDeps(c, engineConfigs);
- const pkgDepsCount = await loadEnginePackageDeps(c, engineConfigs);
+ const plugDepsCount = await loadEnginePluginDeps(engineConfigs);
+ const pkgDepsCount = await loadEnginePackageDeps(engineConfigs);
if (plugDepsCount + pkgDepsCount > 0) {
c.runtime._skipPluginScopeWarnings = true;
- await configurePlugins(c); // TODO: This is too early as scoped plugin have not been installed
+ await configurePlugins(); // TODO: This is too early as scoped plugin have not been installed
c.runtime._skipPluginScopeWarnings = false;
- await installPackageDependencies(c);
+ await installPackageDependencies();
}
// All engines ready to be registered
@@ -462,7 +471,7 @@ const _resolvePkgPath = (c: RnvContext, packageName: string) => {
if (fsExistsSync(pkgPath)) {
return pkgPath;
}
- const monoRoot = getConfigProp(c, c.platform, 'monoRoot');
+ const monoRoot = getConfigProp('monoRoot');
pkgPath = path.join(c.paths.project.dir, monoRoot || '../..', 'node_modules', packageName);
if (fsExistsSync(pkgPath)) {
return pkgPath;
@@ -476,7 +485,7 @@ const _registerPlatformEngine = async (c: RnvContext, platform: RnvPlatform | bo
// Only register active platform engine to be faster
if (platform === true || !platform) return;
- const selectedEngineTemplate = getEngineTemplateByPlatform(c, platform);
+ const selectedEngineTemplate = getEngineTemplateByPlatform(platform);
if (selectedEngineTemplate) {
const existingEngine = c.runtime.enginesById[selectedEngineTemplate.id];
@@ -497,8 +506,10 @@ Maybe you forgot to define platforms.${platform}.engine in your renative.json?`)
}
};
-export const getEngineRunnerByPlatform = (c: RnvContext, platform: RnvPlatform, ignoreMissingError?: boolean) => {
+export const getEngineRunnerByPlatform = (platform: RnvPlatform, ignoreMissingError?: boolean) => {
if (!platform) return undefined;
+ const c = getContext();
+
const selectedEngine = c.runtime.enginesByPlatform[platform];
if (!selectedEngine && !ignoreMissingError) {
logDebug(`ERROR: Engine for platform: ${platform} does not exists or is not registered ${new Error()}`);
@@ -530,7 +541,9 @@ export const getEngineSubTasks = (task: string, tasks: RnvTaskMap, exactMatch?:
exactMatch ? v.task.split(' ')[0] === task : v.task.split(' ')[0].startsWith(task)
);
-export const getEngineRunner = (c: RnvContext, task: string, customTasks?: RnvTaskMap, failOnMissingEngine = true) => {
+export const getEngineRunner = (task: string, customTasks?: RnvTaskMap, failOnMissingEngine = true) => {
+ const c = getContext();
+
if (customTasks?.[task]) {
return c.runtime.enginesById[ENGINE_CORE];
}
@@ -559,4 +572,4 @@ export const getEngineRunner = (c: RnvContext, task: string, customTasks?: RnvTa
return undefined;
};
-export const getRegisteredEngines = (c: RnvContext) => c.runtime.enginesByIndex;
+export const getRegisteredEngines = () => getContext().runtime.enginesByIndex;
diff --git a/packages/core/src/env/index.ts b/packages/core/src/env/index.ts
index 7bce5547c4..faf41af2d5 100644
--- a/packages/core/src/env/index.ts
+++ b/packages/core/src/env/index.ts
@@ -17,13 +17,13 @@ export const CoreEnvVars = {
};
const _generateEnvVars = (c: RnvContext) => {
- const isMonorepo = getConfigProp(c, c.platform, 'isMonorepo');
- const monoRoot = getConfigProp(c, c.platform, 'monoRoot') || '../..';
+ const isMonorepo = getConfigProp('isMonorepo');
+ const monoRoot = getConfigProp('monoRoot') || '../..';
const envConfig: RnvEnvContext = {
RNV_ENGINE_PATH: c.runtime.engine?.rootPath,
RNV_PROJECT_ROOT: c.paths.project.dir,
- RNV_APP_BUILD_DIR: getRelativePath(c.paths.project.dir, getAppFolder(c)),
+ RNV_APP_BUILD_DIR: getRelativePath(c.paths.project.dir, getAppFolder()),
RNV_IS_MONOREPO: isMonorepo,
RNV_MONO_ROOT: isMonorepo ? path.join(c.paths.project.dir, monoRoot) : c.paths.project.dir,
RNV_ENGINE: c.runtime.engine?.config.id,
diff --git a/packages/core/src/integrations/index.ts b/packages/core/src/integrations/index.ts
index a3e8b30161..7e5dd70a15 100644
--- a/packages/core/src/integrations/index.ts
+++ b/packages/core/src/integrations/index.ts
@@ -1,12 +1,14 @@
import path from 'path';
-import { RnvContext } from '../context/types';
import { fsExistsSync } from '../system/fs';
import { logDefault, logWarning } from '../logger';
import { registerCustomTask } from '../tasks';
import { RnvIntegration } from './types';
+import { getContext } from '../context/provider';
-export const loadIntegrations = async (c: RnvContext) => {
+export const loadIntegrations = async () => {
logDefault('loadIntegrations');
+ const c = getContext();
+
const integrations = c.buildConfig?.integrations;
if (integrations) {
@@ -20,7 +22,7 @@ export const loadIntegrations = async (c: RnvContext) => {
const instance: RnvIntegration = require(intPath)?.default;
if (instance) {
instance.getTasks().forEach((task) => {
- registerCustomTask(c, task);
+ registerCustomTask(task);
});
}
} catch (err) {
diff --git a/packages/core/src/platforms/__tests__/index.test.ts b/packages/core/src/platforms/__tests__/index.test.ts
new file mode 100644
index 0000000000..429b9f90f4
--- /dev/null
+++ b/packages/core/src/platforms/__tests__/index.test.ts
@@ -0,0 +1,51 @@
+import { createPlatformBuild } from '../../platforms';
+import { copyFolderContentsRecursiveSync } from '../../system/fs';
+import { getContext } from '../../context/provider';
+import { doResolve } from '../../system/resolve';
+import { generateContextDefaults } from '../../context/defaults';
+import { getAppFolder } from '../../context/contextProps';
+
+jest.mock('../../logger');
+jest.mock('../../context/provider');
+jest.mock('../../system/fs');
+jest.mock('../../system/resolve');
+jest.mock('../../context/contextProps');
+
+beforeAll(() => {
+ // Before all placeholder
+});
+
+afterEach(() => {
+ jest.clearAllMocks();
+});
+
+describe('createPlatformBuild', () => {
+ it('should copy platform template files to app folder', async () => {
+ // GIVEN
+ jest.mocked(getContext).mockReturnValue(generateContextDefaults());
+ jest.mocked(doResolve).mockReturnValue('MOCK_RESOLVED_PATH');
+ jest.mocked(getAppFolder).mockReturnValue('MOCKED_APP_FOLDER');
+ const c = getContext();
+ c.platform = 'ios';
+ c.runtime.availablePlatforms = ['ios', 'android'];
+ c.paths.project.platformTemplatesDirs['ios'] = '/path/to/pt';
+ // WHEN
+ await createPlatformBuild('ios');
+ // THEN
+ expect(copyFolderContentsRecursiveSync).toHaveBeenCalledWith(
+ '/path/to/pt/ios',
+ 'MOCKED_APP_FOLDER', // TODO: fix this
+ false,
+ ['/path/to/pt/ios/_privateConfig'],
+ false,
+ [
+ {
+ pattern: '{{PATH_REACT_NATIVE}}',
+ override: 'MOCK_RESOLVED_PATH',
+ },
+ ],
+ undefined,
+ c
+ );
+ });
+});
diff --git a/packages/core/src/platforms/index.ts b/packages/core/src/platforms/index.ts
index acc94ff405..dbd5fb15ae 100644
--- a/packages/core/src/platforms/index.ts
+++ b/packages/core/src/platforms/index.ts
@@ -3,13 +3,15 @@ import { chalk, logDefault, logError, logWarning, logDebug } from '../logger';
import { cleanFolder, copyFolderContentsRecursiveSync } from '../system/fs';
import { getTimestampPathsConfig, getAppFolder } from '../context/contextProps';
import { SUPPORTED_PLATFORMS } from '../constants';
-import type { RnvContext } from '../context/types';
import { generateOptions, inquirerPrompt } from '../api';
import type { RnvPlatform, RnvPlatformWithAll } from '../types';
import { updateProjectPlatforms } from '../configs/configProject';
import { doResolve } from '../system/resolve';
+import { getContext } from '../context/provider';
+
+export const logErrorPlatform = () => {
+ const c = getContext();
-export const logErrorPlatform = (c: RnvContext) => {
logError(
`Platform: ${chalk().bold(c.platform)} doesn't support command: ${chalk().bold(c.command)}`,
true // kill it if we're not supporting this
@@ -17,7 +19,9 @@ export const logErrorPlatform = (c: RnvContext) => {
return false;
};
-export const generatePlatformChoices = (c: RnvContext) => {
+export const generatePlatformChoices = () => {
+ const c = getContext();
+
const options = c.runtime.supportedPlatforms.map((v) => ({
name: `${v.platform} - ${
v.isConnected ? chalk().green('(connected)') : chalk().yellow('(ejected)')
@@ -28,31 +32,34 @@ export const generatePlatformChoices = (c: RnvContext) => {
return options;
};
-export const cleanPlatformBuild = async (c: RnvContext, platform: RnvPlatform) => {
+export const cleanPlatformBuild = async (platform: RnvPlatform) => {
logDebug('cleanPlatformBuild');
+ const c = getContext();
+
const cleanTasks = [];
if ((platform as RnvPlatformWithAll) === 'all' && c.buildConfig.platforms) {
Object.keys(c.buildConfig.platforms).forEach((k) => {
- if (isPlatformSupportedSync(c, k as RnvPlatform)) {
+ if (isPlatformSupportedSync(k as RnvPlatform)) {
const pPath = path.join(c.paths.project.builds.dir, `${c.runtime.appId}_${k}`);
cleanTasks.push(cleanFolder(pPath));
}
});
- } else if (isPlatformSupportedSync(c, platform)) {
- const pPath = getAppFolder(c);
+ } else if (isPlatformSupportedSync(platform)) {
+ const pPath = getAppFolder();
cleanTasks.push(cleanFolder(pPath));
}
await Promise.all(cleanTasks);
};
-export const createPlatformBuild = (c: RnvContext, platform: RnvPlatform) =>
+export const createPlatformBuild = (platform: RnvPlatform) =>
new Promise((resolve, reject) => {
logDefault('createPlatformBuild');
+ const c = getContext();
- if (!platform || !isPlatformSupportedSync(c, platform, undefined, reject)) return;
+ if (!platform || !isPlatformSupportedSync(platform, undefined, reject)) return;
const ptDir = c.paths.project.platformTemplatesDirs[platform];
if (!ptDir) {
@@ -60,7 +67,7 @@ export const createPlatformBuild = (c: RnvContext, platform: RnvPlatform) =>
return;
}
- const pPath = getAppFolder(c);
+ const pPath = getAppFolder();
const ptPath = path.join(ptDir, `${platform}`);
copyFolderContentsRecursiveSync(
@@ -78,14 +85,16 @@ export const createPlatformBuild = (c: RnvContext, platform: RnvPlatform) =>
}) || '',
},
],
- getTimestampPathsConfig(c, platform),
+ getTimestampPathsConfig(),
c
);
resolve();
});
-export const isPlatformSupported = async (c: RnvContext, isGlobalScope = false) => {
+export const isPlatformSupported = async (isGlobalScope = false) => {
+ const c = getContext();
+
if (c.platform && c.program.platform !== true && isGlobalScope) {
return c.platform;
}
@@ -122,7 +131,7 @@ export const isPlatformSupported = async (c: RnvContext, isGlobalScope = false)
if (confirm) {
const newPlatforms = [...configuredPlatforms, c.platform];
- updateProjectPlatforms(c, newPlatforms);
+ updateProjectPlatforms(newPlatforms);
c.buildConfig.defaults = c.buildConfig.defaults || {};
c.buildConfig.defaults.supportedPlatforms = newPlatforms;
// await configureEntryPoints(c);
@@ -134,12 +143,7 @@ export const isPlatformSupported = async (c: RnvContext, isGlobalScope = false)
return c.platform;
};
-export const isPlatformSupportedSync = (
- c: RnvContext,
- platform: RnvPlatform,
- resolve?: () => void,
- reject?: (e: string) => void
-) => {
+export const isPlatformSupportedSync = (platform: RnvPlatform, resolve?: () => void, reject?: (e: string) => void) => {
if (!platform) {
if (reject) {
reject(
@@ -153,6 +157,8 @@ export const isPlatformSupportedSync = (
}
return false;
}
+ const c = getContext();
+
if (!c.runtime.availablePlatforms.includes(platform)) {
if (reject) {
reject(
@@ -169,7 +175,10 @@ export const isPlatformSupportedSync = (
return true;
};
-export const isPlatformActive = (c: RnvContext, platform: RnvPlatform, resolve?: () => void) => {
+export const isPlatformActive = (resolve?: () => void) => {
+ const c = getContext();
+ const { platform } = c;
+
if (!c.buildConfig || !c.buildConfig.platforms) {
logError(
`Your appConfigFile is not configured properly! check ${chalk().bold(c.paths.appConfig.config)} location.`
@@ -184,21 +193,25 @@ export const isPlatformActive = (c: RnvContext, platform: RnvPlatform, resolve?:
}
return true;
};
-export const copySharedPlatforms = (c: RnvContext) =>
+export const copySharedPlatforms = () =>
new Promise((resolve) => {
+ const c = getContext();
+
logDefault('copySharedPlatforms');
if (c.platform) {
copyFolderContentsRecursiveSync(
path.resolve(c.paths.project.platformTemplatesDirs[c.platform], '_shared'),
- getAppFolder(c)
+ getAppFolder()
);
}
resolve();
});
-export const ejectPlatform = (c: RnvContext, platform: string) => {
+export const ejectPlatform = (platform: string) => {
+ const c = getContext();
+
const engine = c.runtime.enginesByPlatform[platform];
const destDir = path.join(c.paths.project.dir, 'platformTemplates', platform);
const sourcePlatformDir = engine.originalTemplatePlatformsDir;
diff --git a/packages/core/src/plugins/__tests__/index.test.ts b/packages/core/src/plugins/__tests__/index.test.ts
index 6406a0e5f4..d3d6981215 100644
--- a/packages/core/src/plugins/__tests__/index.test.ts
+++ b/packages/core/src/plugins/__tests__/index.test.ts
@@ -1,13 +1,12 @@
import { parsePlugins } from '..';
-import { createRnvApi } from '../../api';
-import { createRnvContext } from '../../context';
import { generateContextDefaults } from '../../context/defaults';
+import { getContext } from '../../context/provider';
jest.mock('../../logger');
+jest.mock('../../context/provider');
beforeEach(() => {
- createRnvContext();
- createRnvApi();
+ //TBC
});
afterEach(() => {
@@ -17,7 +16,8 @@ afterEach(() => {
describe('parsePlugins', () => {
it('should parse plugins correctly', () => {
// GIVEN
- const c = generateContextDefaults();
+ jest.mocked(getContext).mockReturnValue(generateContextDefaults());
+ const c = getContext();
c.buildConfig.plugins = {
react: 'source:rnv',
'react-art': 'source:rnv',
@@ -28,13 +28,12 @@ describe('parsePlugins', () => {
version: '3.10.1',
},
};
- const platform = 'ios';
+ c.platform = 'ios';
+
const pluginCallback = jest.fn();
- const ignorePlatformObjectCheck = true;
- const includeDisabledPlugins = true;
// WHEN
- parsePlugins(c, platform, pluginCallback, ignorePlatformObjectCheck, includeDisabledPlugins);
+ parsePlugins(pluginCallback, true, true);
// THEN
expect(pluginCallback).toHaveBeenCalledTimes(3);
@@ -51,7 +50,8 @@ describe('parsePlugins', () => {
it('should exclude disabled plugins per platform', () => {
// GIVEN
- const c = generateContextDefaults();
+ jest.mocked(getContext).mockReturnValue(generateContextDefaults());
+ const c = getContext();
c.buildConfig.plugins = {
react: 'source:rnv',
'react-art': 'source:rnv',
@@ -62,13 +62,12 @@ describe('parsePlugins', () => {
version: '3.10.1',
},
};
- const platform = 'tvos';
+ c.platform = 'tvos';
+
const pluginCallback = jest.fn();
- const ignorePlatformObjectCheck = false;
- const includeDisabledPlugins = false;
// WHEN
- parsePlugins(c, platform, pluginCallback, ignorePlatformObjectCheck, includeDisabledPlugins);
+ parsePlugins(pluginCallback, false, false);
// THEN
expect(pluginCallback).toHaveBeenCalledTimes(2);
@@ -80,7 +79,8 @@ describe('parsePlugins', () => {
it('should ignorePlatformObjectCheck', () => {
// GIVEN
- const c = generateContextDefaults();
+ jest.mocked(getContext).mockReturnValue(generateContextDefaults());
+ const c = getContext();
c.buildConfig.plugins = {
react: 'source:rnv',
'react-art': 'source:rnv',
@@ -91,13 +91,11 @@ describe('parsePlugins', () => {
version: '3.10.1',
},
};
- const platform = 'tvos';
+ c.platform = 'tvos';
const pluginCallback = jest.fn();
- const ignorePlatformObjectCheck = true;
- const includeDisabledPlugins = false;
// WHEN
- parsePlugins(c, platform, pluginCallback, ignorePlatformObjectCheck, includeDisabledPlugins);
+ parsePlugins(pluginCallback, true, false);
// THEN
expect(pluginCallback).toHaveBeenCalledTimes(3);
@@ -114,7 +112,8 @@ describe('parsePlugins', () => {
it('should includeDisabledPlugins and not cause duplicates', () => {
// GIVEN
- const c = generateContextDefaults();
+ jest.mocked(getContext).mockReturnValue(generateContextDefaults());
+ const c = getContext();
c.buildConfig.plugins = {
react: 'source:rnv',
'react-art': 'source:rnv',
@@ -128,15 +127,11 @@ describe('parsePlugins', () => {
disabled: true,
},
};
- const platform = 'tvos';
- const pluginCallback = jest.fn(() => {
- // console.log('callback called', rest)
- });
- const ignorePlatformObjectCheck = true;
- const includeDisabledPlugins = true;
+ c.platform = 'tvos';
+ const pluginCallback = jest.fn();
// WHEN
- parsePlugins(c, platform, pluginCallback, ignorePlatformObjectCheck, includeDisabledPlugins);
+ parsePlugins(pluginCallback, true, true);
// THEN
expect(pluginCallback).toHaveBeenCalledTimes(4);
diff --git a/packages/core/src/plugins/index.ts b/packages/core/src/plugins/index.ts
index 639a7d2c3e..46d957c1c3 100644
--- a/packages/core/src/plugins/index.ts
+++ b/packages/core/src/plugins/index.ts
@@ -18,7 +18,6 @@ import { doResolve } from '../system/resolve';
import { RnvContext } from '../context/types';
import { PluginCallback, RnvPlugin, RnvPluginScope } from './types';
import { RenativeConfigPaths, RenativeConfigPlugin, RenativeConfigPluginPlatform } from '../schema/types';
-import { RnvPlatform } from '../types';
import { inquirerPrompt } from '../api';
import { writeRenativeConfigFile } from '../configs/utils';
import { installPackageDependencies } from '../projects/npm';
@@ -165,9 +164,11 @@ const _applyPackageDependency = (deps: Record, key: string, vers
}
};
-export const configurePlugins = async (c: RnvContext) => {
+export const configurePlugins = async () => {
logDefault('configurePlugins');
+ const c = getContext();
+
if (c.program.skipDependencyCheck) return true;
if (!c.files.project.package.dependencies) {
@@ -292,12 +293,14 @@ ${ovMsg}`
const _updatePackage = (c: RnvContext, override: Partial) => {
const newPackage: NpmPackageFile = merge(c.files.project.package, override);
- writeRenativeConfigFile(c, c.paths.project.package, newPackage);
+ writeRenativeConfigFile(c.paths.project.package, newPackage);
c.files.project.package = newPackage;
c._requiresNpmInstall = true;
};
-export const resolvePluginDependants = async (c: RnvContext) => {
+export const resolvePluginDependants = async () => {
+ const c = getContext();
+
logDefault('resolvePluginDependants');
const { plugins } = c.buildConfig;
@@ -342,7 +345,7 @@ const _resolvePluginDependencies = async (
});
if (confirm && c.files.project.config_original?.plugins) {
c.files.project.config_original.plugins[key] = `source:${scope}`;
- writeRenativeConfigFile(c, c.paths.project.config, c.files.project.config_original);
+ writeRenativeConfigFile(c.paths.project.config, c.files.project.config_original);
logSuccess(`Plugin ${key} sucessfully installed`);
c._requiresNpmInstall = true;
}
@@ -370,19 +373,19 @@ const _resolvePluginDependencies = async (
};
export const parsePlugins = (
- c: RnvContext,
- platform: RnvPlatform,
pluginCallback: PluginCallback,
ignorePlatformObjectCheck?: boolean,
includeDisabledOrExcludedPlugins?: boolean
) => {
+ const c = getContext();
+ const { platform } = c;
logDefault('parsePlugins');
if (c.buildConfig && platform) {
- const includedPluginsConfig = getConfigProp(c, platform, 'includedPlugins');
+ const includedPluginsConfig = getConfigProp('includedPlugins');
// default to all plugins if it's not defined (null allowed for overrides)
const includedPlugins = includedPluginsConfig === undefined ? ['*'] : includedPluginsConfig;
- const excludedPlugins = getConfigProp(c, platform, 'excludedPlugins') || [];
+ const excludedPlugins = getConfigProp('excludedPlugins') || [];
const handleActivePlugin = (plugin: RnvPlugin, pluginPlat: RenativeConfigPluginPlatform, key: string) => {
// log deprecated if present
@@ -459,9 +462,11 @@ export const parsePlugins = (
}
};
-export const loadPluginTemplates = async (c: RnvContext) => {
+export const loadPluginTemplates = async () => {
logDefault('loadPluginTemplates');
+ const c = getContext();
+
//This comes from project dependency
let flexnPluginsPath = doResolve('@flexn/plugins');
@@ -525,8 +530,8 @@ export const loadPluginTemplates = async (c: RnvContext) => {
if (hasPackageChanged) {
_updatePackage(c, { dependencies });
logInfo('Found missing dependency scopes. INSTALLING...');
- await installPackageDependencies(c);
- await loadPluginTemplates(c);
+ await installPackageDependencies();
+ await loadPluginTemplates();
} else {
missingDeps.forEach((npmDep) => {
logWarning(`Plugin scope ${npmDep} does not exists in package.json.`);
@@ -733,13 +738,13 @@ export const overrideFileContents = (dest: string, override: Record {
+export const installPackageDependenciesAndPlugins = async () => {
logDefault('installPackageDependenciesAndPlugins');
- await installPackageDependencies(c);
- await overrideTemplatePlugins(c);
- await configureFonts(c);
- await checkForPluginDependencies(c);
+ await installPackageDependencies();
+ await overrideTemplatePlugins();
+ await configureFonts();
+ await checkForPluginDependencies();
};
const _getPluginConfiguration = (c: RnvContext, pluginName: string) => {
@@ -757,7 +762,9 @@ const _getPluginConfiguration = (c: RnvContext, pluginName: string) => {
return renativePlugin;
};
-export const checkForPluginDependencies = async (c: RnvContext) => {
+export const checkForPluginDependencies = async () => {
+ const c = getContext();
+
const toAdd: Record = {};
if (!c.buildConfig.plugins) return;
@@ -809,64 +816,60 @@ export const checkForPluginDependencies = async (c: RnvContext) => {
...(c.files.project.config_original.plugins || {}),
...toAdd,
};
- writeRenativeConfigFile(c, c.paths.project.config, c.files.project.config_original);
+ writeRenativeConfigFile(c.paths.project.config, c.files.project.config_original);
// Need to reload merged files
- await parseRenativeConfigs(c);
- await configurePlugins(c);
- await installPackageDependenciesAndPlugins(c);
+ await parseRenativeConfigs();
+ await configurePlugins();
+ await installPackageDependenciesAndPlugins();
}
}
};
// const getPluginPlatformFromString = (p: string): RnvPluginPlatform => p as RnvPluginPlatform;
-export const overrideTemplatePlugins = async (c: RnvContext) => {
+export const overrideTemplatePlugins = async () => {
logDefault('overrideTemplatePlugins');
+ const c = getContext();
+
const rnvPluginsDirs = c.paths.rnv.pluginTemplates.dirs;
const appPluginDirs = c.paths.appConfig.pluginDirs;
- parsePlugins(
- c,
- c.platform,
- (plugin, pluginPlat, key) => {
- if (!plugin.disablePluginTemplateOverrides) {
- if (plugin?._scopes?.length) {
- plugin._scopes.forEach((pluginScope) => {
- const pluginOverridePath = rnvPluginsDirs[pluginScope];
- if (pluginOverridePath) {
- 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);
- }
+ parsePlugins((plugin, pluginPlat, key) => {
+ if (!plugin.disablePluginTemplateOverrides) {
+ if (plugin?._scopes?.length) {
+ plugin._scopes.forEach((pluginScope) => {
+ const pluginOverridePath = rnvPluginsDirs[pluginScope];
+ if (pluginOverridePath) {
+ 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 (appPluginDirs) {
- for (let k = 0; k < appPluginDirs.length; k++) {
- _overridePlugin(c, appPluginDirs[k], key);
}
+ });
+ }
+ if (appPluginDirs) {
+ for (let k = 0; k < appPluginDirs.length; k++) {
+ _overridePlugin(c, appPluginDirs[k], key);
}
- } else {
- logInfo(
- `Plugin overrides disabled for: ${chalk().bold(key)} with disablePluginTemplateOverrides. SKIPPING`
- );
}
- },
- true
- );
+ } else {
+ logInfo(
+ `Plugin overrides disabled for: ${chalk().bold(key)} with disablePluginTemplateOverrides. SKIPPING`
+ );
+ }
+ }, true);
return true;
};
export const copyTemplatePluginsSync = (c: RnvContext) => {
- const { platform } = c;
- const destPath = path.join(getAppFolder(c));
+ const destPath = path.join(getAppFolder());
logDefault('copyTemplatePluginsSync', `(${destPath})`);
- parsePlugins(c, platform, (plugin, pluginPlat, key) => {
+ parsePlugins((plugin, pluginPlat, key) => {
const objectInject: OverridesOptions = []; // = { ...c.configPropsInjects };
if (plugin.props) {
Object.keys(plugin.props).forEach((v) => {
@@ -883,41 +886,32 @@ export const copyTemplatePluginsSync = (c: RnvContext) => {
// }
// FOLDER MERGES FROM PROJECT CONFIG PLUGIN
- const sourcePath3 = getAppConfigBuildsFolder(
- c,
- platform,
- path.join(c.paths.project.appConfigBase.dir, `plugins/${key}`)
- );
+ const sourcePath3 = getAppConfigBuildsFolder(path.join(c.paths.project.appConfigBase.dir, `plugins/${key}`));
copyFolderContentsRecursiveSync(sourcePath3, destPath, true, undefined, false, objectInject);
// FOLDER MERGES FROM PROJECT CONFIG PLUGIN (PRIVATE)
const sourcePath3sec = getAppConfigBuildsFolder(
- c,
- platform,
path.join(c.paths.workspace.project.appConfigBase.dir, `plugins/${key}`)
);
copyFolderContentsRecursiveSync(sourcePath3sec, destPath, true, undefined, false, objectInject);
// FOLDER MERGES FROM APP CONFIG PLUGIN
- const sourcePath2 = getAppConfigBuildsFolder(c, platform, path.join(c.paths.appConfig.dir, `plugins/${key}`));
+ const sourcePath2 = getAppConfigBuildsFolder(path.join(c.paths.appConfig.dir, `plugins/${key}`));
copyFolderContentsRecursiveSync(sourcePath2, destPath, true, undefined, false, objectInject);
// FOLDER MERGES FROM APP CONFIG PLUGIN (PRIVATE)
- const sourcePath2sec = getAppConfigBuildsFolder(
- c,
- platform,
- path.join(c.paths.workspace.appConfig.dir, `plugins/${key}`)
- );
+ const sourcePath2sec = getAppConfigBuildsFolder(path.join(c.paths.workspace.appConfig.dir, `plugins/${key}`));
copyFolderContentsRecursiveSync(sourcePath2sec, destPath, true, undefined, false, objectInject);
// FOLDER MERGES FROM SCOPED PLUGIN TEMPLATES
Object.keys(c.paths.rnv.pluginTemplates.dirs).forEach((pathKey) => {
- if (pathKey !== 'rnv') {
- const pluginTemplatePath = c.paths.rnv.pluginTemplates.dirs[pathKey];
+ // TODO: required for external rnv scoped templates to take effect. need to test full implications
+ // if (pathKey !== 'rnv') {
+ const pluginTemplatePath = c.paths.rnv.pluginTemplates.dirs[pathKey];
- const sourcePath4sec = getAppConfigBuildsFolder(c, platform, path.join(pluginTemplatePath, key));
- copyFolderContentsRecursiveSync(sourcePath4sec, destPath, true, undefined, false, objectInject);
- }
+ const sourcePath4sec = getAppConfigBuildsFolder(path.join(pluginTemplatePath, key));
+ copyFolderContentsRecursiveSync(sourcePath4sec, destPath, true, undefined, false, objectInject);
+ // }
});
});
};
@@ -953,8 +947,8 @@ export const getLocalRenativePlugin = () => ({
},
});
-export const updateRenativeConfigs = async (c: RnvContext) => {
- await loadPluginTemplates(c);
- await parseRenativeConfigs(c);
+export const updateRenativeConfigs = async () => {
+ await loadPluginTemplates();
+ await parseRenativeConfigs();
return true;
};
diff --git a/packages/core/src/projects/__tests__/index.test.ts b/packages/core/src/projects/__tests__/index.test.ts
index d49c093674..efae1674a3 100644
--- a/packages/core/src/projects/__tests__/index.test.ts
+++ b/packages/core/src/projects/__tests__/index.test.ts
@@ -1,10 +1,10 @@
import { copyAssetsFolder } from '..';
-import { RnvPlatform } from '../../types';
import { logWarning } from '../../logger';
import path from 'path';
import { isPlatformActive } from '../../platforms';
import { getTimestampPathsConfig, getConfigProp } from '../../context/contextProps';
import { generateContextDefaults } from '../../context/defaults';
+import { getContext } from '../../context/provider';
jest.mock('fs');
jest.mock('path');
@@ -18,14 +18,14 @@ afterEach(() => {
});
describe('copyAssetsFolder', () => {
- const platform: RnvPlatform = 'web';
- const c = generateContextDefaults();
-
it('should exit when platform is not active', async () => {
// GIVEN
+ const c = generateContextDefaults();
+ c.platform = 'web';
+ jest.mocked(getContext).mockReturnValue(c);
jest.mocked(isPlatformActive).mockReturnValue(false);
// WHEN
- const result = await copyAssetsFolder(c, platform);
+ const result = await copyAssetsFolder();
//THEN
expect(isPlatformActive).toHaveBeenCalled();
expect(result).toBeUndefined();
@@ -33,19 +33,22 @@ describe('copyAssetsFolder', () => {
it('shows warning when assetSources is declared but actual folder is missing', async () => {
//GIVEN
+ const c = generateContextDefaults();
+ c.platform = 'web';
+ jest.mocked(getContext).mockReturnValue(c);
jest.mocked(isPlatformActive).mockReturnValue(true);
jest.mocked(getConfigProp).mockReturnValueOnce('web'); //assetFolderPlatform
jest.mocked(getTimestampPathsConfig).mockReturnValueOnce(undefined);
jest.mocked(getConfigProp).mockReturnValueOnce(['./MOCK_PATH']); //assetSources
jest.spyOn(path, 'join').mockReturnValue('MOCK_JOINED_PATH');
//WHEN
- await copyAssetsFolder(c, platform);
+ await copyAssetsFolder();
//THEN
expect(logWarning).toHaveBeenCalledWith(
'AssetSources is specified as ./MOCK_PATH. But path MOCK_JOINED_PATH was not found.'
);
- expect(getConfigProp).toHaveBeenCalledWith(c, platform, 'assetFolderPlatform');
- expect(getConfigProp).toHaveBeenCalledWith(c, platform, 'assetSources');
+ expect(getConfigProp).toHaveBeenCalledWith('assetFolderPlatform');
+ expect(getConfigProp).toHaveBeenCalledWith('assetSources');
expect(getConfigProp).toHaveBeenCalledTimes(2);
});
});
diff --git a/packages/core/src/projects/dependencyManager.ts b/packages/core/src/projects/dependencyManager.ts
index b7ca71417f..454d0254ce 100644
--- a/packages/core/src/projects/dependencyManager.ts
+++ b/packages/core/src/projects/dependencyManager.ts
@@ -12,14 +12,17 @@ import { inquirerPrompt } from '../api';
import { writeRenativeConfigFile } from '../configs/utils';
import { fsExistsSync } from '../system/fs';
import { NpmDepKey, NpmPackageFile } from '../configs/types';
+import { getContext } from '../context/provider';
-export const checkIfProjectAndNodeModulesExists = async (c: RnvContext) => {
+export const checkIfProjectAndNodeModulesExists = async () => {
logDefault('checkIfProjectAndNodeModulesExists');
+ const c = getContext();
+
if (c.paths.project.configExists && !fsExistsSync(c.paths.project.nodeModulesDir)) {
c._requiresNpmInstall = false;
logInfo('node_modules folder is missing. INSTALLING...');
- await installPackageDependencies(c);
+ await installPackageDependencies();
}
};
@@ -38,11 +41,11 @@ const injectProjectDependency = async (
const dep = currentPackage[type] || {};
currentPackage[type] = dep;
dep[dependency] = version;
- writeRenativeConfigFile(c, existingPath, currentPackage);
+ writeRenativeConfigFile(existingPath, currentPackage);
if (!skipInstall) {
- await installPackageDependencies(c);
- await overrideTemplatePlugins(c);
- await configureFonts(c);
+ await installPackageDependencies();
+ await overrideTemplatePlugins();
+ await configureFonts();
}
return true;
}
@@ -125,10 +128,11 @@ export const checkRequiredPackage = async (
return false;
};
-export const injectPlatformDependencies = async (c: RnvContext) => {
+export const injectPlatformDependencies = async () => {
logDefault('injectPlatformDependencies');
+ const c = getContext();
const { platform } = c;
- const engine = getEngineRunnerByPlatform(c, platform);
+ const engine = getEngineRunnerByPlatform(platform);
const npmDepsBase = engine?.config?.npm || {};
const npmDepsExt = platform ? engine?.config?.platforms?.[platform]?.npm || {} : {};
@@ -163,9 +167,9 @@ export const injectPlatformDependencies = async (c: RnvContext) => {
logInfo(
`Found extra npm dependencies required by ${chalk().bold(engine.config.id)} engine. ADDING...DONE`
);
- await installPackageDependencies(c);
- await overrideTemplatePlugins(c);
- await configureFonts(c);
+ await installPackageDependencies();
+ await overrideTemplatePlugins();
+ await configureFonts();
}
}
}
diff --git a/packages/core/src/projects/index.ts b/packages/core/src/projects/index.ts
index b14ea7b58a..d7f21824b6 100644
--- a/packages/core/src/projects/index.ts
+++ b/packages/core/src/projects/index.ts
@@ -34,9 +34,12 @@ import { generateConfigPropInjects } from '../system/injectors';
import { ConfigFileApp, ConfigFileEngine, ConfigFileProject, ConfigFileTemplate } from '../schema/configFiles/types';
import { getConfigProp } from '../context/contextProps';
import { ConfigName } from '../enums/configName';
+import { getContext } from '../context/provider';
-export const checkAndBootstrapIfRequired = async (c: RnvContext) => {
+export const checkAndBootstrapIfRequired = async () => {
logDefault('checkAndBootstrapIfRequired');
+ const c = getContext();
+
const template: string = c.program?.template;
if (!c.paths.project.configExists && template) {
await executeAsync(`${isYarnInstalled() ? 'yarn' : 'npm'} add ${template}`, {
@@ -87,8 +90,8 @@ export const checkAndBootstrapIfRequired = async (c: RnvContext) => {
});
}
- if (config.templateConfig?.packageTemplate) {
- const pkgJson = config.templateConfig.packageTemplate;
+ if (config.templateConfig?.package_json) {
+ const pkgJson = config.templateConfig.package_json;
if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
if (!pkgJson.dependencies) pkgJson.dependencies = {};
c.files.project.package = pkgJson;
@@ -173,16 +176,16 @@ export const checkAndBootstrapIfRequired = async (c: RnvContext) => {
copyFolderContentsRecursiveSync(appConfigsPath, path.join(c.paths.project.appConfigsDir));
}
- await installPackageDependencies(c);
+ await installPackageDependencies();
if (c.program.npxMode) {
return;
}
- await parseRenativeConfigs(c);
+ await parseRenativeConfigs();
- await configureTemplateFiles(c);
- await configureEntryPoint(c, c.platform);
+ await configureTemplateFiles();
+ await configureEntryPoint(c.platform);
// await applyTemplate(c);
// copyFolderContentsRecursiveSync(templatePath, c.paths.project.dir);
@@ -190,7 +193,9 @@ export const checkAndBootstrapIfRequired = async (c: RnvContext) => {
return true;
};
-export const checkAndCreateGitignore = async (c: RnvContext) => {
+export const checkAndCreateGitignore = async () => {
+ const c = getContext();
+
logDefault('checkAndCreateGitignore');
const ignrPath = path.join(c.paths.project.dir, '.gitignore');
if (!fsExistsSync(ignrPath)) {
@@ -201,16 +206,18 @@ export const checkAndCreateGitignore = async (c: RnvContext) => {
return true;
};
-export const configureFonts = async (c: RnvContext) => {
+export const configureFonts = async () => {
+ const c = getContext();
+
// FONTS
let fontsObj = 'export default [';
const duplicateFontCheck: Array = [];
- parseFonts(c, (font, dir) => {
+ parseFonts((font, dir) => {
if (font.includes('.ttf') || font.includes('.otf') || font.includes('.woff')) {
const keOriginal = font.split('.')[0];
const keyNormalised = keOriginal.replace(/__/g, ' ');
- const includedFonts = getConfigProp(c, c.platform, 'includedFonts');
+ const includedFonts = getConfigProp('includedFonts');
if (includedFonts) {
if (
includedFonts.includes('*') ||
@@ -272,9 +279,9 @@ export const configureFonts = async (c: RnvContext) => {
return true;
};
-export const copyRuntimeAssets = async (c: RnvContext) => {
+export const copyRuntimeAssets = async () => {
logDefault('copyRuntimeAssets');
-
+ const c = getContext();
const destPath = path.join(c.paths.project.assets.dir, 'runtime');
// FOLDER MERGERS FROM APP CONFIG + EXTEND
@@ -304,9 +311,11 @@ export const copyRuntimeAssets = async (c: RnvContext) => {
return true;
};
-export const parseFonts = (c: RnvContext, callback: ParseFontsCallback) => {
+export const parseFonts = (callback: ParseFontsCallback) => {
logDefault('parseFonts');
+ const c = getContext();
+
if (c.buildConfig) {
// FONTS - PROJECT CONFIG
if (fsExistsSync(c.paths.project.appConfigBase.fontsDir)) {
@@ -330,18 +339,13 @@ export const parseFonts = (c: RnvContext, callback: ParseFontsCallback) => {
if (callback) callback(font, c.paths.appConfig.fontsDir);
});
}
- _parseFontSources(c, getConfigProp(c, c.platform, 'fontSources') || [], callback);
+ _parseFontSources(c, getConfigProp('fontSources') || [], callback);
// PLUGIN FONTS
- parsePlugins(
- c,
- c.platform,
- (plugin) => {
- if (plugin.config?.fontSources) {
- _parseFontSources(c, plugin.config?.fontSources, callback);
- }
- },
- true
- );
+ parsePlugins((plugin) => {
+ if (plugin.config?.fontSources) {
+ _parseFontSources(c, plugin.config?.fontSources, callback);
+ }
+ }, true);
}
};
@@ -422,17 +426,15 @@ const _resolvePackage = (c: RnvContext, v: string) => {
// return false;
// };
-export const copyAssetsFolder = async (
- c: RnvContext,
- platform: RnvPlatform,
- subPath?: string,
- customFn?: (c: RnvContext, platform: RnvPlatform) => void
-) => {
+export const copyAssetsFolder = async (subPath?: string, customFn?: (c: RnvContext, platform: RnvPlatform) => void) => {
logDefault('copyAssetsFolder');
- if (!isPlatformActive(c, platform)) return;
+ const c = getContext();
+ const { platform } = c;
- const assetFolderPlatform = getConfigProp(c, platform, 'assetFolderPlatform') || platform;
+ if (!isPlatformActive()) return;
+
+ const assetFolderPlatform = getConfigProp('assetFolderPlatform') || platform;
if (assetFolderPlatform !== platform) {
logInfo(
@@ -442,9 +444,9 @@ export const copyAssetsFolder = async (
);
}
- const tsPathsConfig = getTimestampPathsConfig(c, platform);
+ const tsPathsConfig = getTimestampPathsConfig();
- const assetSources = getConfigProp(c, platform, 'assetSources') || [];
+ const assetSources = getConfigProp('assetSources') || [];
const validAssetSources: Array = [];
@@ -462,7 +464,7 @@ export const copyAssetsFolder = async (
});
}
- const destPath = path.join(getPlatformProjectDir(c)!, subPath || '');
+ const destPath = path.join(getPlatformProjectDir()!, subPath || '');
// FOLDER MERGERS FROM EXTERNAL SOURCES
if (validAssetSources.length > 0) {
@@ -541,23 +543,25 @@ export const copyAssetsFolder = async (
// }
// };
-export const copyBuildsFolder = (c: RnvContext, platform: RnvPlatform) =>
+export const copyBuildsFolder = () =>
new Promise((resolve) => {
logDefault('copyBuildsFolder');
- if (!isPlatformActive(c, platform, resolve)) return;
+ const c = getContext();
+
+ if (!isPlatformActive(resolve)) return;
- const destPath = path.join(getAppFolder(c));
- const tsPathsConfig = getTimestampPathsConfig(c, platform);
+ const destPath = path.join(getAppFolder());
+ const tsPathsConfig = getTimestampPathsConfig();
generateConfigPropInjects();
const allInjects = [...c.configPropsInjects, ...c.systemPropsInjects, ...c.runtimePropsInjects];
// FOLDER MERGERS PROJECT CONFIG
- const sourcePath1 = getAppConfigBuildsFolder(c, platform, c.paths.project.appConfigBase.dir);
+ const sourcePath1 = getAppConfigBuildsFolder(c.paths.project.appConfigBase.dir);
copyFolderContentsRecursiveSync(sourcePath1, destPath, true, undefined, false, allInjects, tsPathsConfig);
// FOLDER MERGERS PROJECT CONFIG (PRIVATE)
- const sourcePath1sec = getAppConfigBuildsFolder(c, platform, c.paths.workspace.project.appConfigBase.dir);
+ const sourcePath1sec = getAppConfigBuildsFolder(c.paths.workspace.project.appConfigBase.dir);
copyFolderContentsRecursiveSync(sourcePath1sec, destPath, true, undefined, false, allInjects, tsPathsConfig);
// DEPRECATED SHARED
@@ -566,18 +570,18 @@ export const copyBuildsFolder = (c: RnvContext, platform: RnvPlatform) =>
if (fsExistsSync(sourcePathShared)) {
logWarning('Folder builds/_shared is DEPRECATED. use builds/ instead ');
}
- copyFolderContentsRecursiveSync(sourcePathShared, getAppFolder(c), true, undefined, false, allInjects);
+ copyFolderContentsRecursiveSync(sourcePathShared, getAppFolder(), true, undefined, false, allInjects);
}
// FOLDER MERGERS FROM APP CONFIG + EXTEND
if (c.paths.appConfig.dirs) {
c.paths.appConfig.dirs.forEach((v) => {
- const sourceV = getAppConfigBuildsFolder(c, platform, v);
+ const sourceV = getAppConfigBuildsFolder(v);
copyFolderContentsRecursiveSync(sourceV, destPath, true, undefined, false, allInjects, tsPathsConfig);
});
} else {
copyFolderContentsRecursiveSync(
- getAppConfigBuildsFolder(c, platform, c.paths.appConfig.dir),
+ getAppConfigBuildsFolder(c.paths.appConfig.dir),
destPath,
true,
undefined,
@@ -588,7 +592,7 @@ export const copyBuildsFolder = (c: RnvContext, platform: RnvPlatform) =>
}
// FOLDER MERGERS FROM APP CONFIG (PRIVATE)
- const sourcePath0sec = getAppConfigBuildsFolder(c, platform, c.paths.workspace.appConfig.dir);
+ const sourcePath0sec = getAppConfigBuildsFolder(c.paths.workspace.appConfig.dir);
copyFolderContentsRecursiveSync(sourcePath0sec, destPath, true, undefined, false, allInjects, tsPathsConfig);
copyTemplatePluginsSync(c);
@@ -634,14 +638,15 @@ It is recommended that you run your rnv command with npx prefix: ${recCmd} . or
c.runtime.skipPackageUpdate = chosenAction === actionNoUpdate;
if (chosenAction === actionUpgrade) {
- upgradeProjectDependencies(c, c.runtime.rnvVersionRunner);
+ upgradeProjectDependencies(c.runtime.rnvVersionRunner);
}
}
}
return true;
};
-export const cleanPlaformAssets = async (c: RnvContext) => {
+export const cleanPlaformAssets = async () => {
+ const c = getContext();
logDefault('cleanPlaformAssets');
await cleanFolder(c.paths.project.assets.dir);
diff --git a/packages/core/src/projects/npm.ts b/packages/core/src/projects/npm.ts
index da2a899066..2eeed8524d 100644
--- a/packages/core/src/projects/npm.ts
+++ b/packages/core/src/projects/npm.ts
@@ -5,6 +5,7 @@ import { logDefault, logWarning, logError, logInfo, logDebug, logSuccess } from
import { doResolve } from '../system/resolve';
import { RnvContext } from '../context/types';
import { inquirerPrompt } from '../api';
+import { getContext } from '../context/provider';
export const checkNpxIsInstalled = async () => {
logDefault('checkNpxIsInstalled');
@@ -29,11 +30,11 @@ export const areNodeModulesInstalled = () => !!doResolve('resolve', false);
type NpmVersion = { name: string; value: string };
-export const listAndSelectNpmVersion = async (c: RnvContext, npmPackage: string) => {
- const templateVersionsStr = await executeAsync(c, `npm view ${npmPackage} versions`);
+export const listAndSelectNpmVersion = async (npmPackage: string) => {
+ const templateVersionsStr = await executeAsync(`npm view ${npmPackage} versions`);
const versionArr = templateVersionsStr.replace(/\r?\n|\r|\s|'|\[|\]/g, '').split(',');
- const templateTagsStr = await executeAsync(c, `npm dist-tag ls ${npmPackage}`);
+ const templateTagsStr = await executeAsync(`npm dist-tag ls ${npmPackage}`);
const tagArr: Array<{
name: string;
version: string;
@@ -105,7 +106,9 @@ const _getInstallScript = (c: RnvContext) => {
export const isYarnInstalled = () => commandExistsSync('yarn') || doResolve('yarn', false);
-export const installPackageDependencies = async (c: RnvContext, failOnError = false) => {
+export const installPackageDependencies = async (failOnError = false) => {
+ const c = getContext();
+
c.runtime.forceBuildHookRebuild = true;
const customScript = _getInstallScript(c);
@@ -166,7 +169,7 @@ export const installPackageDependencies = async (c: RnvContext, failOnError = fa
try {
await executeAsync(command);
- await invalidatePodsChecksum(c);
+ await invalidatePodsChecksum();
} catch (e) {
if (failOnError) {
logError(e);
@@ -177,7 +180,7 @@ export const installPackageDependencies = async (c: RnvContext, failOnError = fa
);
try {
await cleanNodeModules();
- await installPackageDependencies(c, true);
+ await installPackageDependencies(true);
} catch (npmErr) {
logError(npmErr);
throw npmErr;
@@ -209,7 +212,8 @@ export const installPackageDependencies = async (c: RnvContext, failOnError = fa
}
};
-export const jetifyIfRequired = async (c: RnvContext) => {
+export const jetifyIfRequired = async () => {
+ const c = getContext();
logDefault('jetifyIfRequired');
if (c.files.project.configLocal?._meta?.requiresJetify) {
if (doResolve('jetifier')) {
diff --git a/packages/core/src/projects/package.ts b/packages/core/src/projects/package.ts
index f001e60c99..c94ab17462 100644
--- a/packages/core/src/projects/package.ts
+++ b/packages/core/src/projects/package.ts
@@ -1,11 +1,12 @@
import path from 'path';
import { fsExistsSync, fsWriteFileSync, loadFile, readObjectSync } from '../system/fs';
import { logDefault, logWarning, logInfo } from '../logger';
-import { RnvContext } from '../context/types';
import { ConfigFileTemplate } from '../schema/configFiles/types';
import { ConfigName } from '../enums/configName';
+import { getContext } from '../context/provider';
-const packageJsonIsValid = (c: RnvContext) => {
+const packageJsonIsValid = () => {
+ const c = getContext();
if (!fsExistsSync(c.paths.project.package)) return false;
const pkg = readObjectSync(c.paths.project.package);
if (!pkg) return false;
@@ -14,10 +15,12 @@ const packageJsonIsValid = (c: RnvContext) => {
return true;
};
-export const checkAndCreateProjectPackage = async (c: RnvContext) => {
+export const checkAndCreateProjectPackage = async () => {
logDefault('checkAndCreateProjectPackage');
- if (!packageJsonIsValid(c)) {
+ const c = getContext();
+
+ if (!packageJsonIsValid()) {
logInfo(`Your ${c.paths.project.package} is missing. CREATING...DONE`);
const packageName = c.files.project.config?.projectName || c.paths.project.dir.split('/').pop();
@@ -39,7 +42,7 @@ export const checkAndCreateProjectPackage = async (c: RnvContext) => {
const templateObj = readObjectSync(c.paths.template.configTemplate);
- const pkgJson = templateObj?.templateConfig?.packageTemplate || {};
+ const pkgJson = templateObj?.templateConfig?.package_json || {};
pkgJson.name = packageName;
pkgJson.version = packageVersion;
pkgJson.dependencies = pkgJson.dependencies || {};
diff --git a/packages/core/src/runner.ts b/packages/core/src/runner.ts
index 063b8d3c2b..04b17bc5f2 100644
--- a/packages/core/src/runner.ts
+++ b/packages/core/src/runner.ts
@@ -10,11 +10,12 @@ import { updateRenativeConfigs } from './plugins';
export const executeRnvCore = async () => {
const c = getContext();
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
await checkAndMigrateProject();
- await updateRenativeConfigs(c);
- await checkAndBootstrapIfRequired(c);
+ await updateRenativeConfigs();
+ await checkAndBootstrapIfRequired();
+ // TODO: rename to something more meaningful or DEPRECATE entirely
if (c.program.npxMode) {
return;
}
@@ -24,28 +25,28 @@ export const executeRnvCore = async () => {
// ie rnv link
const initTask = await findSuitableGlobalTask();
if (initTask?.task && initTask.isGlobalScope) {
- return initializeTask(c, initTask?.task);
+ return initializeTask(initTask?.task);
}
- await loadIntegrations(c);
- const result = await loadEngines(c);
+ await loadIntegrations();
+ const result = await loadEngines();
// If false make sure we reload configs as it means it's freshly installed
if (!result) {
- await updateRenativeConfigs(c);
+ await updateRenativeConfigs();
}
// for root rnv we simply load all engines upfront
const { configExists } = c.paths.project;
if (!c.command && configExists) {
- await registerMissingPlatformEngines(c);
+ await registerMissingPlatformEngines();
}
// Some tasks might require all engines to be present (ie rnv platform list)
- const taskInstance = await findSuitableTask(c);
+ const taskInstance = await findSuitableTask();
if (c.command && !taskInstance?.ignoreEngines) {
- await registerMissingPlatformEngines(c, taskInstance);
+ await registerMissingPlatformEngines(taskInstance);
}
- if (taskInstance?.task) await initializeTask(c, taskInstance?.task);
+ if (taskInstance?.task) await initializeTask(taskInstance?.task);
};
diff --git a/packages/core/src/schema/configFiles/template.ts b/packages/core/src/schema/configFiles/template.ts
index b859513ced..7efd9fb6c2 100644
--- a/packages/core/src/schema/configFiles/template.ts
+++ b/packages/core/src/schema/configFiles/template.ts
@@ -1,11 +1,64 @@
import { z } from 'zod';
import { DefaultsSchema, EnginesSchema } from './project';
-import { TemplateConfig } from '../shared';
+import { NpmDep, TemplateConfig } from '../shared';
+
+const BootstrapQuestionsSchema = z
+ .array(
+ z.object({
+ options: z
+ .array(
+ z.object({
+ title: z.string(),
+ value: z.union([z.record(z.string(), z.any()), z.string(), z.number(), z.boolean()]),
+ })
+ )
+ .optional(),
+ configProp: z
+ .object({
+ prop: z.string(),
+ key: z.string(),
+ })
+ .optional(),
+ type: z.string(),
+ title: z.string(),
+ onConfirm: z
+ .array(
+ z.object({
+ action: z.string(),
+ prop: z.string().optional(),
+ path: z.string(),
+ })
+ )
+ .optional(),
+ })
+ )
+ .describe('Defines list of custom bootstrap questions');
+
+const BootstrapConfig = z
+ .object({
+ bootstrapQuestions: BootstrapQuestionsSchema,
+ rnvNewPatchDependencies: z
+ .optional(NpmDep)
+ .describe(
+ 'This ensures that the correct version of the npm packages will be used to run the project for the first time after creation'
+ ),
+ configModifiers: z.object({
+ engines: z.array(
+ z.object({
+ name: z.string(),
+ supportedPlatforms: z.array(z.string()),
+ nullifyIfFalse: z.boolean().optional(),
+ })
+ ),
+ }),
+ })
+ .partial();
export const RootTemplateSchema = z.object({
defaults: z.optional(DefaultsSchema),
engines: z.optional(EnginesSchema),
templateConfig: TemplateConfig.optional(),
+ bootstrapConfig: BootstrapConfig.optional(),
});
// {
diff --git a/packages/core/src/schema/configFiles/workspace.ts b/packages/core/src/schema/configFiles/workspace.ts
index a88244df77..ee2aceb350 100644
--- a/packages/core/src/schema/configFiles/workspace.ts
+++ b/packages/core/src/schema/configFiles/workspace.ts
@@ -14,7 +14,7 @@ const SDKsSchema = z
// ANDROID_NDK: '~/Library/Android/sdk/ndk-bundle',
// TIZEN_SDK: '~/tizen-studio',
// WEBOS_SDK: '/opt/webOS_TV_SDK',
-// KAIOS_SDK: '/Applications/Kaiosrt.app',
+// KAIOS_SDK: '~/Applications/KaiosSimulators',
//LEVEl 0 (ROOT)
diff --git a/packages/core/src/schema/platforms/fragments/templateAndroidBase.ts b/packages/core/src/schema/platforms/fragments/templateAndroidBase.ts
index d11f47e887..9484a4e0e9 100644
--- a/packages/core/src/schema/platforms/fragments/templateAndroidBase.ts
+++ b/packages/core/src/schema/platforms/fragments/templateAndroidBase.ts
@@ -91,7 +91,7 @@ export const TemplateAndroidBaseFragment = {
),
})
),
- MainActivity_java: z.optional(
+ MainActivity_kt: z.optional(
z.object({
onCreate: z
.string({})
@@ -104,7 +104,7 @@ export const TemplateAndroidBaseFragment = {
resultMethods: z.array(z.string()).optional(),
})
),
- MainApplication_java: z.optional(
+ MainApplication_kt: z.optional(
z
.object({
imports: z.array(z.string()).optional(),
diff --git a/packages/core/src/schema/platforms/fragments/templateXcodeBase.ts b/packages/core/src/schema/platforms/fragments/templateXcodeBase.ts
index f13f686f2b..728a738ca7 100644
--- a/packages/core/src/schema/platforms/fragments/templateXcodeBase.ts
+++ b/packages/core/src/schema/platforms/fragments/templateXcodeBase.ts
@@ -44,24 +44,28 @@ const AppDelegateMethod = z.union([
const AppDelegateMm = z.object({
appDelegateMethods: z.optional(
z.object({
- application: z.object({
- didFinishLaunchingWithOptions: z.array(AppDelegateMethod),
- applicationDidBecomeActive: z.array(AppDelegateMethod),
- open: z.array(AppDelegateMethod),
- supportedInterfaceOrientationsFor: z.array(AppDelegateMethod),
- didReceiveRemoteNotification: z.array(AppDelegateMethod),
- didFailToRegisterForRemoteNotificationsWithError: z.array(AppDelegateMethod),
- didReceive: z.array(AppDelegateMethod),
- didRegister: z.array(AppDelegateMethod),
- didRegisterForRemoteNotificationsWithDeviceToken: z.array(AppDelegateMethod),
- continue: z.array(AppDelegateMethod),
- didConnectCarInterfaceController: z.array(AppDelegateMethod),
- didDisconnectCarInterfaceController: z.array(AppDelegateMethod),
- }),
- userNotificationCenter: z.object({
- willPresent: z.array(AppDelegateMethod),
- didReceiveNotificationResponse: z.array(AppDelegateMethod),
- }),
+ application: z
+ .object({
+ didFinishLaunchingWithOptions: z.array(AppDelegateMethod).optional(),
+ applicationDidBecomeActive: z.array(AppDelegateMethod).optional(),
+ open: z.array(AppDelegateMethod).optional(),
+ supportedInterfaceOrientationsFor: z.array(AppDelegateMethod).optional(),
+ didReceiveRemoteNotification: z.array(AppDelegateMethod).optional(),
+ didFailToRegisterForRemoteNotificationsWithError: z.array(AppDelegateMethod).optional(),
+ didReceive: z.array(AppDelegateMethod).optional(),
+ didRegister: z.array(AppDelegateMethod).optional(),
+ didRegisterForRemoteNotificationsWithDeviceToken: z.array(AppDelegateMethod).optional(),
+ continue: z.array(AppDelegateMethod).optional(),
+ didConnectCarInterfaceController: z.array(AppDelegateMethod).optional(),
+ didDisconnectCarInterfaceController: z.array(AppDelegateMethod).optional(),
+ })
+ .optional(),
+ userNotificationCenter: z
+ .object({
+ willPresent: z.array(AppDelegateMethod).optional(),
+ didReceiveNotificationResponse: z.array(AppDelegateMethod).optional(),
+ })
+ .optional(),
})
),
appDelegateImports: z.optional(z.array(z.string())),
diff --git a/packages/core/src/schema/shared/index.ts b/packages/core/src/schema/shared/index.ts
index 6d66722325..a6b97ef388 100644
--- a/packages/core/src/schema/shared/index.ts
+++ b/packages/core/src/schema/shared/index.ts
@@ -42,47 +42,42 @@ export const BuildSchemeFragment = {
),
};
-const NpmDep = z.record(z.string(), z.string());
-
-const BootstrapQuestionsSchema = z
- .array(
- z.object({
- options: z
- .array(
- z.object({
- title: z.string(),
- value: z.object({}),
- })
- )
- .optional(),
- configProp: z
- .object({
- prop: z.string(),
- key: z.string(),
- })
- .optional(),
- type: z.string(),
- title: z.string(),
- })
- )
- .describe('Defines list of custom bootstrap questions');
+export const NpmDep = z.record(z.string(), z.string());
export const TemplateConfig = z
.object({
+ disabled: z.boolean().optional(),
includedPaths: z
- .array(z.string())
+ .array(
+ z.union([
+ z.string(),
+ z.object({
+ paths: z.array(z.string()),
+ engines: z.array(z.string()).optional(),
+ }),
+ ])
+ )
.describe('Defines list of all file/dir paths you want to include in template')
.optional(),
- bootstrapQuestions: BootstrapQuestionsSchema.optional(),
- packageTemplate: z.optional(
- z.object({
- dependencies: z.optional(NpmDep),
- devDependencies: z.optional(NpmDep),
- peerDependencies: z.optional(NpmDep),
- optionalDependencies: z.optional(NpmDep),
- name: z.string().optional(),
- version: z.string().optional(),
+ // bootstrapQuestions: BootstrapQuestionsSchema.optional(),
+ renative_json: z
+ .object({
+ $schema: z.string().optional(),
+ extendsTemplate: z.string().optional(),
})
+ .passthrough()
+ .optional(),
+ package_json: z.optional(
+ z
+ .object({
+ dependencies: z.optional(NpmDep),
+ devDependencies: z.optional(NpmDep),
+ peerDependencies: z.optional(NpmDep),
+ optionalDependencies: z.optional(NpmDep),
+ name: z.string().optional(),
+ version: z.string().optional(),
+ })
+ .passthrough()
),
})
.describe('Used in `renative.template.json` allows you to define template behaviour.');
diff --git a/packages/core/src/system/__tests__/exec.test.ts b/packages/core/src/system/__tests__/exec.test.ts
index 4325ba2533..38efc4c2eb 100644
--- a/packages/core/src/system/__tests__/exec.test.ts
+++ b/packages/core/src/system/__tests__/exec.test.ts
@@ -1,6 +1,5 @@
import { createRnvApi } from '../../api';
import { createRnvContext } from '../../context';
-import { generateContextDefaults } from '../../context/defaults';
import { executeAsync, commandExistsSync, commandExists } from '../../system/exec';
jest.mock('../../logger');
@@ -13,30 +12,24 @@ describe('Testing exec functions', () => {
it('should execute command', async () => {
expect.assertions(1);
- await expect(executeAsync(generateContextDefaults(), 'node -v').then((data) => typeof data)).resolves.toBe(
- 'string'
- );
+ await expect(executeAsync('node -v').then((data) => typeof data)).resolves.toBe('string');
});
it('should execute array command', async () => {
expect.assertions(1);
- await expect(executeAsync(generateContextDefaults(), ['node', '-v']).then((data) => typeof data)).resolves.toBe(
- 'string'
- );
+ await expect(executeAsync(['node', '-v']).then((data) => typeof data)).resolves.toBe('string');
});
it('should execute command with privateParams', async () => {
expect.assertions(1);
await expect(
- executeAsync(generateContextDefaults(), 'node -v 1234', { privateParams: ['1234'] }).then(
- (data) => typeof data
- )
+ executeAsync('node -v 1234', { privateParams: ['1234'] }).then((data) => typeof data)
).resolves.toBe('string');
});
it('should execute with error', async () => {
expect.assertions(1);
- await expect(executeAsync(generateContextDefaults(), 'shouldTrow')).rejects.toBeDefined();
+ await expect(executeAsync('shouldTrow')).rejects.toBeDefined();
});
it('should recognize command sync', () => {
diff --git a/packages/core/src/system/__tests__/fs.test.ts b/packages/core/src/system/__tests__/fs.test.ts
index a074ff6399..a74b63a0e4 100644
--- a/packages/core/src/system/__tests__/fs.test.ts
+++ b/packages/core/src/system/__tests__/fs.test.ts
@@ -1,27 +1,19 @@
-import { createPlatformBuild } from '../../platforms';
-import { createRnvApi } from '../../api';
-import { createRnvContext } from '../../context';
-import { sanitizeDynamicProps, getRelativePath, copyFolderContentsRecursiveSync } from '../fs';
-import { RnvPlatform } from '../../types';
+import { sanitizeDynamicProps, getRelativePath } from '../fs';
import { getContext } from '../../context/provider';
-import { doResolve } from '../resolve';
+import { generateContextDefaults } from '../../context/defaults';
jest.mock('../../logger');
-jest.mock('../fs', () => {
- const original = jest.requireActual('../fs');
+jest.mock('../../context/provider');
- return {
- ...original,
- copyFolderContentsRecursiveSync: jest.fn(),
- };
+beforeAll(() => {
+ // Before all placeholder
});
-describe('sanitizeDynamicProps', () => {
- beforeAll(() => {
- createRnvContext();
- createRnvApi();
- });
+afterEach(() => {
+ jest.clearAllMocks();
+});
+describe('sanitizeDynamicProps', () => {
it('sanitize {{props.XXX}}', async () => {
const buildConfig = {
common: {
@@ -59,9 +51,11 @@ describe('sanitizeDynamicProps', () => {
});
it('sanitize {{files.XXX}}', async () => {
- const buildConfig = {
+ jest.mocked(getContext).mockReturnValue(generateContextDefaults());
+ const c = getContext();
+ c.buildConfig = {
common: {
- foo: '{{files.project.config.common.foo}}',
+ runtime: '{{files.project.config.common.runtime}}',
},
};
const propConfig = {
@@ -69,7 +63,7 @@ describe('sanitizeDynamicProps', () => {
project: {
config: {
common: {
- foo: 'bar',
+ runtime: 'bar',
},
},
},
@@ -78,8 +72,8 @@ describe('sanitizeDynamicProps', () => {
props: {},
configProps: {},
};
- const result = sanitizeDynamicProps(buildConfig, propConfig);
- expect(result.common.foo).toEqual('bar');
+ const result = sanitizeDynamicProps(c.buildConfig, propConfig);
+ expect(result.common?.runtime).toEqual('bar');
});
it('sanitize {{runtimeProps.XXX}}', async () => {
@@ -135,36 +129,3 @@ describe('getRelativePath', () => {
expect(result).toEqual(expected);
});
});
-
-describe('createPlatformBuild', () => {
- // GIVEN
- const platform: RnvPlatform = 'ios';
- const c = getContext();
- c.runtime.availablePlatforms = ['ios', 'android'];
- c.paths.project.platformTemplatesDirs[platform] = '/path/to/pt';
-
- it('should copy platform template files to app folder', async () => {
- // WHEN
- await createPlatformBuild(c, platform);
-
- // THEN
- expect(copyFolderContentsRecursiveSync).toHaveBeenCalledWith(
- '/path/to/pt/ios',
- 'undefined_null', // TODO: fix this
- false,
- ['/path/to/pt/ios/_privateConfig'],
- false,
- [
- {
- pattern: '{{PATH_REACT_NATIVE}}',
- override:
- doResolve(c.runtime.runtimeExtraProps?.reactNativePackageName || 'react-native', true, {
- forceForwardPaths: true,
- }) || '',
- },
- ],
- undefined,
- c
- );
- });
-});
diff --git a/packages/core/src/system/exec.ts b/packages/core/src/system/exec.ts
index 58d185ace3..bc8a04d6e2 100755
--- a/packages/core/src/system/exec.ts
+++ b/packages/core/src/system/exec.ts
@@ -259,7 +259,9 @@ const _execute = (c: RnvContext, command: string | Array, opts: ExecOpti
* @returns {Promise}
*
*/
-const execCLI = (c: RnvContext, cli: string, command: string, opts: ExecOptions = {}) => {
+const execCLI = (cli: string, command: string, opts: ExecOptions = {}) => {
+ const c = getContext();
+
if (!c.program) {
return Promise.reject('You need to pass c object as first parameter to execCLI()');
}
@@ -292,29 +294,8 @@ const execCLI = (c: RnvContext, cli: string, command: string, opts: ExecOptions
*
*/
-const executeAsync = async (
- _c: RnvContext | string | Array,
- _cmd?: string | Array | ExecOptions,
- _opts?: ExecOptions
-): Promise => {
- // swap values if c is not specified and get it from it's rightful place, config :)
- let c: RnvContext;
- let cmd: string | Array = '';
- let opts: ExecOptions = _opts || {};
- const isArg1Command = typeof _c === 'string' || Array.isArray(_c);
- if (isArg1Command) {
- cmd = _c;
- c = getContext();
- } else {
- c = _c;
- }
-
- const isArg2Command = typeof _cmd === 'string' || Array.isArray(_cmd);
- if (isArg2Command) {
- cmd = _cmd;
- } else if (_cmd) {
- opts = _cmd;
- }
+const executeAsync = async (cmd: string | Array, opts?: ExecOptions): Promise => {
+ const c = getContext();
if (cmd.includes('npm') && process.platform === 'win32') {
if (typeof cmd === 'string') {
@@ -324,26 +305,7 @@ const executeAsync = async (
cmd = cmd.split(' ');
}
}
- // let cmdArr;
- // if (typeof cmd === 'string') {
- // cmdArr = cmd.split('&&');
- // } else {
- // cmdArr = cmd;
- // }
- // let result;
- // if (cmdArr.length) {
- // for (let i = 0; i < cmdArr.length; i++) {
- // // if (cmdArr[i].startsWith('cd ')) {
- // // // TODO: flaky. will need to improve
- // // const newCwd = path.join(CURRENT_DIR, cmdArr[i].replace('cd ', ''));
- // // opts.cwd = newCwd;
- // // } else {
- // // await _execute(c, cmdArr[i], opts);
- // // }
- // result = await _execute(c, cmdArr[i], opts);
- // }
- // }
const result = await _execute(c, cmd, opts);
return result;
};
@@ -361,9 +323,11 @@ export const execaCommand = (cmd: string, options?: execa.Options) => {
* @returns {Promise}
*
*/
-const executeTelnet = (c: RnvContext, port: string, command: string) =>
+const executeTelnet = (port: string, command: string) =>
new Promise((resolve) => {
logDebug(`execTelnet: ${port} ${command}`);
+ const c = getContext();
+
try {
let output = '';
const nc2 = new NClient();
@@ -612,11 +576,11 @@ const commandExistsSync = (commandName: string) => {
const openCommand = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
export const waitForExecCLI = async (
- c: RnvContext,
cli: string,
command: string,
callback: (resp: string | true) => boolean
): Promise => {
+ const c = getContext();
let attempts = 0;
const maxAttempts = 30;
const CHECK_INTEVAL = 2000;
@@ -625,7 +589,7 @@ export const waitForExecCLI = async (
return new Promise((resolve, reject) => {
const interval = setInterval(() => {
- execCLI(c, cli, command, {
+ execCLI(cli, command, {
silent: true,
timeout: 10000,
maxErrorLength,
diff --git a/packages/core/src/system/fs.ts b/packages/core/src/system/fs.ts
index ecc2257df1..c548c5f966 100755
--- a/packages/core/src/system/fs.ts
+++ b/packages/core/src/system/fs.ts
@@ -150,7 +150,7 @@ export const writeCleanFile = (
if (occurences) {
occurences.forEach((occ) => {
const val = occ.replace('{{configProps.', '').replace('}}', '') as ConfigPropKey;
- const configVal = api.getConfigProp(c, c.platform, val) || '';
+ const configVal = api.getConfigProp(val) || '';
pFileClean = pFileClean.replace(occ, configVal);
});
}
@@ -221,7 +221,8 @@ export const copyFileWithInjectSync = (
}
};
-export const invalidatePodsChecksum = (c: RnvContext) => {
+export const invalidatePodsChecksum = () => {
+ const c = getContext();
const appFolder = path.join(c.paths.project.builds.dir, `${c.runtime.appId}_${c.platform}`);
const podChecksumPath = path.join(appFolder, 'Podfile.checksum');
if (fs.existsSync(podChecksumPath)) {
@@ -537,13 +538,14 @@ export const updateObjectSync = (filePath: string, updateObj: object) => {
return output;
};
-export const getRealPath = (c: RnvContext, p: string | undefined, key = 'undefined', original?: string) => {
+export const getRealPath = (p: string | undefined, key = 'undefined', original?: string) => {
if (!p) {
if (original) {
logDebug(`Path ${chalk().bold(key)} is not defined. using default: ${chalk().bold(original)}`);
}
return original;
}
+ const c = getContext();
if (p.startsWith('./')) {
return path.join(c.paths.project.dir, p);
}
@@ -559,11 +561,11 @@ export const getRealPath = (c: RnvContext, p: string | undefined, key = 'undefin
return output;
};
-const _refToValue = (c: RnvContext, ref: string, key: string) => {
+const _refToValue = (ref: string, key: string) => {
// ref=> '$REF$:./my/path/to/file.json$...prop.subProp'
const val = ref.replace('$REF$:', '').split('$...');
// val=> ['./my/path/to/file.json', 'prop.subProp']
- const realPath = getRealPath(c, val[0], key);
+ const realPath = getRealPath(val[0], key);
if (realPath && realPath.includes('.json') && val.length === 2) {
if (fs.existsSync(realPath)) {
@@ -600,7 +602,7 @@ export const sanitizeDynamicRefs = (c: RnvContext, obj: T) => {
if (val) {
if (typeof val === 'string') {
if (val.startsWith('$REF$:')) {
- obj[key as keyof T] = _refToValue(c, val, key);
+ obj[key as keyof T] = _refToValue(val, key);
}
} else if (Array.isArray(val) || typeof val === 'object') {
sanitizeDynamicRefs(c, val as DynaObj);
diff --git a/packages/core/src/system/injectors.ts b/packages/core/src/system/injectors.ts
index 0b24be942d..ca69891f1a 100644
--- a/packages/core/src/system/injectors.ts
+++ b/packages/core/src/system/injectors.ts
@@ -22,7 +22,7 @@ export const generateConfigPropInjects = () => {
const ctx = getContext();
const configPropsInjects: OverridesOptions = [];
INJECTABLE_CONFIG_PROPS.forEach((v) => {
- const configProp = getConfigProp(ctx, ctx.platform, v);
+ const configProp = getConfigProp(v);
if (!ctx.injectableConfigProps) ctx.injectableConfigProps = {};
ctx.injectableConfigProps[v] = configProp;
configPropsInjects.push({
diff --git a/packages/core/src/tasks/__tests__/index.test.ts b/packages/core/src/tasks/__tests__/index.test.ts
new file mode 100644
index 0000000000..497a19115c
--- /dev/null
+++ b/packages/core/src/tasks/__tests__/index.test.ts
@@ -0,0 +1,100 @@
+import { getAllSuitableTasks } from '..';
+import { createRnvContext } from '@rnv/core';
+import { getRegisteredEngines } from '../../engines';
+import { RnvEngine } from '../../engines/types';
+import { DEFAULT_TASK_DESCRIPTIONS } from '../constants';
+
+jest.mock('../../engines');
+jest.mock('chalk');
+jest.mock('../../logger');
+jest.mock('../../api');
+jest.mock('../constants', () => ({ DEFAULT_TASK_DESCRIPTIONS: {} }));
+
+beforeEach(() => {
+ createRnvContext();
+});
+
+afterEach(() => {
+ jest.resetAllMocks();
+});
+
+const ENGINE_MOCK_PROPS = {
+ platforms: {},
+ config: {
+ id: '',
+ engineExtension: '',
+ overview: '',
+ },
+ projectDirName: '',
+ runtimeExtraProps: {},
+ serverDirName: '',
+};
+
+const rnvEngineMock1: RnvEngine = {
+ ...ENGINE_MOCK_PROPS,
+ tasks: {
+ ['mock-task']: {
+ description: 'mock task 1',
+ task: 'mock-task',
+ options: [],
+ platforms: [],
+ },
+ },
+};
+
+const rnvEngineMock2: RnvEngine = {
+ ...ENGINE_MOCK_PROPS,
+ tasks: {
+ //NOTE: order of task here is IMPORTANT
+ ['mock-task-2']: {
+ description: 'mock task 2',
+ task: 'mock-task-2',
+ options: [],
+ platforms: [],
+ },
+ ['mock-task']: {
+ description: 'mock task 1',
+ task: 'mock-task',
+ options: [],
+ platforms: [],
+ },
+ },
+};
+
+describe('Get suitable tasks', () => {
+ it('should return all tasks for given 1 engine', () => {
+ // GIVEN
+ // const c = getContext();
+ jest.mocked(getRegisteredEngines).mockReturnValue([rnvEngineMock1]);
+ // WHEN
+ const result = getAllSuitableTasks();
+ // THEN
+ expect(Object.keys(result)).toEqual(['mock-task']);
+ expect(result['mock-task'].description).toEqual('mock task 1');
+ });
+
+ it('should return common description for tasks from 2 different engines but same name', () => {
+ // GIVEN
+ // const c = getContext();
+ jest.mocked(getRegisteredEngines).mockReturnValue([rnvEngineMock1, rnvEngineMock2]);
+ DEFAULT_TASK_DESCRIPTIONS['mock-task'] = 'mock task common';
+
+ // WHEN
+ const result = getAllSuitableTasks();
+ // THEN
+ expect(Object.keys(result)).toEqual(['mock-task', 'mock-task-2']);
+ expect(result['mock-task'].description).toEqual('mock task common');
+ });
+
+ it('should return first task description for tasks from 2 different engines but same name if common desc not available', () => {
+ // GIVEN
+ // const c = getContext();
+ jest.mocked(getRegisteredEngines).mockReturnValue([rnvEngineMock2, rnvEngineMock1]);
+ delete DEFAULT_TASK_DESCRIPTIONS['mock-task'];
+ // WHEN
+ const result = getAllSuitableTasks();
+ // THEN
+ expect(Object.keys(result)).toEqual(['mock-task-2', 'mock-task']);
+ expect(result['mock-task'].description).toEqual('mock task 1');
+ });
+});
diff --git a/packages/core/src/tasks/index.ts b/packages/core/src/tasks/index.ts
index f967955a79..0d6c48f6f7 100644
--- a/packages/core/src/tasks/index.ts
+++ b/packages/core/src/tasks/index.ts
@@ -22,14 +22,16 @@ let executedTasks: Record = {};
const CUSTOM_TASKS: RnvTaskMap = {};
-export const registerCustomTask = async (_c: RnvContext, task: RnvTask) => {
+export const registerCustomTask = async (task: RnvTask) => {
if (task.task) {
CUSTOM_TASKS[task.task] = task;
}
};
-export const initializeTask = async (c: RnvContext, task: string) => {
+export const initializeTask = async (task: string) => {
logDefault('initializeTask', task);
+ const c = getContext();
+
logInfo(
`Current engine: ${chalk().bold(c.runtime.engine?.config.id)} ${chalk().grey(
`(${c.runtime.engine?.rootPath})`
@@ -43,7 +45,7 @@ export const initializeTask = async (c: RnvContext, task: string) => {
platform: c.platform,
});
- await executeTask(c, task, undefined, task, true);
+ await executeTask(task, undefined, task, true);
return true;
};
@@ -94,8 +96,8 @@ const _getTaskObj = (taskInstance: RnvTask) => {
};
};
-export const getAllSuitableTasks = (c: RnvContext): Record => {
- const REGISTERED_ENGINES = getRegisteredEngines(c);
+export const getAllSuitableTasks = (): Record => {
+ const REGISTERED_ENGINES = getRegisteredEngines();
const suitableTasks: Record = {};
REGISTERED_ENGINES.forEach((engine) => {
@@ -131,20 +133,22 @@ export const findSuitableGlobalTask = async () => {
if (c.command) task = c.command;
if (c.subCommand) task += ` ${c.subCommand}`;
- c.runtime.engine = getEngineRunner(c, task, undefined, false);
+ c.runtime.engine = getEngineRunner(task, undefined, false);
const tsk = getEngineTask(task, c.runtime.engine?.tasks);
return tsk;
};
-export const findSuitableTask = async (c: RnvContext, specificTask?: string): Promise => {
+export const findSuitableTask = async (specificTask?: string): Promise => {
logDefault('findSuitableTask');
- const REGISTERED_ENGINES = getRegisteredEngines(c);
+ const c = getContext();
+
+ const REGISTERED_ENGINES = getRegisteredEngines();
let task = '';
if (!specificTask) {
if (!c.command) {
- const suitableTasks = getAllSuitableTasks(c);
+ const suitableTasks = getAllSuitableTasks();
const taskInstances = Object.values(suitableTasks);
let tasks: TaskPromptOption[];
@@ -307,24 +311,24 @@ export const findSuitableTask = async (c: RnvContext, specificTask?: string): Pr
} else if (!suitableEngines.length) {
if (!c.runtime.hasAllEnginesRegistered) {
// No platform was specified. we have no option other than load all engines and offer platform list next round
- await registerAllPlatformEngines(c);
- return findSuitableTask(c);
+ await registerAllPlatformEngines();
+ return findSuitableTask();
}
logInfo(`could not find suitable task for ${chalk().bold(c.command)}. GETTING OPTIONS...`);
c.command = null;
c.subCommand = null;
- return findSuitableTask(c);
+ return findSuitableTask();
}
//TODO: special type case for c.platform
if (!c.platform || c.program.platform === true) {
await _selectPlatform(c, suitableEngines, task);
}
- c.runtime.engine = getEngineRunner(c, task, CUSTOM_TASKS, false);
+ c.runtime.engine = getEngineRunner(task, CUSTOM_TASKS, false);
// Cover scenarios of -p xxxxxxxxx
if (!c.runtime.engine) {
await _selectPlatform(c, suitableEngines, task);
- c.runtime.engine = getEngineRunner(c, task, CUSTOM_TASKS);
+ c.runtime.engine = getEngineRunner(task, CUSTOM_TASKS);
}
if (c.runtime.engine?.runtimeExtraProps) {
c.runtime.runtimeExtraProps = c.runtime.engine.runtimeExtraProps;
@@ -338,7 +342,7 @@ export const findSuitableTask = async (c: RnvContext, specificTask?: string): Pr
}
} else {
task = specificTask;
- c.runtime.engine = getEngineRunner(c, task);
+ c.runtime.engine = getEngineRunner(task);
}
const plats = c.runtime.engine?.platforms || [];
c.runtime.availablePlatforms = Object.keys(plats) as PlatformKey[];
@@ -397,17 +401,12 @@ const _selectPlatform = async (c: RnvContext, suitableEngines: Array,
};
const _executePipe = async (c: RnvContext, task: string, phase: string) =>
- executePipe(c, `${task.split(' ').join(':')}:${phase}`);
+ executePipe(`${task.split(' ').join(':')}:${phase}`);
const TASK_LIMIT = 20;
-export const executeTask = async (
- c: RnvContext,
- task: string,
- parentTask?: string,
- originTask?: string,
- isFirstTask?: boolean
-) => {
+export const executeTask = async (task: string, parentTask?: string, originTask?: string, isFirstTask?: boolean) => {
+ const c = getContext();
// const pt = parentTask ? `=> [${parentTask}] ` : '';
c._currentTask = task;
// logInitTask(`${pt}=> [${chalk().bold.rgb(170, 106, 170)(task)}]`);
@@ -422,15 +421,8 @@ but issue migh not be necessarily with this task
To avoid that test your task code against parentTask and avoid executing same task X from within task X`);
}
- await executeEngineTask(
- c,
- task,
- parentTask,
- originTask,
- getEngineRunner(c, task, CUSTOM_TASKS)?.tasks,
- isFirstTask
- );
- // await getEngineRunner(c, task, CUSTOM_TASKS).executeTask(c, task, parentTask, originTask, isFirstTask);
+ await executeEngineTask(task, parentTask, originTask, getEngineRunner(task, CUSTOM_TASKS)?.tasks, isFirstTask);
+ // await getEngineRunner(task, CUSTOM_TASKS).executeTask(task, parentTask, originTask, isFirstTask);
executedTasks[task]++;
c._currentTask = parentTask;
@@ -441,11 +433,12 @@ To avoid that test your task code against parentTask and avoid executing same ta
/**
* @deprecated Use executeDependantTask instead
*/
-export const executeOrSkipTask = async (c: RnvContext, task: string, parentTask: string, originTask?: string) => {
+export const executeOrSkipTask = async (task: string, parentTask: string, originTask?: string) => {
+ const c = getContext();
if (!c.program.only) {
- return executeTask(c, task, parentTask, originTask);
+ return executeTask(task, parentTask, originTask);
}
- return executeTask(c, 'configureSoft', parentTask, originTask);
+ return executeTask('configureSoft', parentTask, originTask);
};
export const executeDependantTask = async ({
@@ -461,10 +454,10 @@ export const executeDependantTask = async ({
}) => {
const ctx = getContext();
if (!ctx.program.only) {
- return executeTask(ctx, task, parentTask, originTask);
+ return executeTask(task, parentTask, originTask);
}
if (alternativeTask) {
- return executeTask(ctx, alternativeTask, parentTask, originTask);
+ return executeTask(alternativeTask, parentTask, originTask);
}
return true;
};
@@ -477,7 +470,8 @@ const _logSkip = (task: string) => {
logInfo(`Original RNV task ${chalk().bold(task)} marked to ignore. SKIPPING...`);
};
-export const shouldSkipTask = (c: RnvContext, taskKey: string, originRnvTaskName?: string) => {
+export const shouldSkipTask = (taskKey: string, originRnvTaskName?: string) => {
+ const c = getContext();
const task = taskKey as RenativeConfigRnvTaskName;
const originTask = originRnvTaskName as RenativeConfigRnvTaskName;
const tasks = c.buildConfig?.tasks;
@@ -544,13 +538,13 @@ export const shouldSkipTask = (c: RnvContext, taskKey: string, originRnvTaskName
};
export const executeEngineTask = async (
- c: RnvContext,
task: string,
parentTask?: string,
originTask?: string,
tasks?: Record,
isFirstTask?: boolean
) => {
+ const c = getContext();
const needsHelp = Object.prototype.hasOwnProperty.call(c.program, 'help');
const t = getEngineTask(task, tasks, CUSTOM_TASKS);
@@ -583,7 +577,7 @@ ${t.options
if (t && !t.isGlobalScope && isFirstTask) {
if (c.files.project.package) {
// This has to happen in order for hooks to be able to run
- await checkIfProjectAndNodeModulesExists(c);
+ await checkIfProjectAndNodeModulesExists();
}
}
if (isFirstTask) {
diff --git a/packages/core/src/templates/index.ts b/packages/core/src/templates/index.ts
index 8837e1fc5f..7714b786bb 100644
--- a/packages/core/src/templates/index.ts
+++ b/packages/core/src/templates/index.ts
@@ -25,6 +25,7 @@ import { ConfigFileApp, ConfigFileProject, ConfigFileTemplate } from '../schema/
import { PlatformKey } from '../schema/types';
import { getConfigProp } from '../context/contextProps';
import { ConfigName } from '../enums/configName';
+import { getContext } from '../context/provider';
const _cleanProjectTemplateSync = (c: RnvContext) => {
logDefault('_cleanProjectTemplateSync');
@@ -112,7 +113,7 @@ const _configureAppConfigs = async (c: RnvContext) => {
// TODO: GET CORRECT PROJECT TEMPLATE
copyFolderContentsRecursiveSync(c.paths.template.appConfigsDir, c.paths.project.appConfigsDir);
- const appConfigIds = listAppConfigsFoldersSync(c, false);
+ const appConfigIds = listAppConfigsFoldersSync(false);
// Update App Title to match package.json
try {
@@ -140,7 +141,7 @@ const _configureAppConfigs = async (c: RnvContext) => {
});
}
- writeRenativeConfigFile(c, appConfigPath, appConfig);
+ writeRenativeConfigFile(appConfigPath, appConfig);
}
}
});
@@ -174,8 +175,10 @@ const _configureRenativeConfig = async (c: RnvContext) => {
logInfo(
`Your ${c.paths.project.config} needs to be updated with ${c.paths.template.configTemplate}. UPDATING...DONE`
);
- const mergedObj = getProjectTemplateMergedConfig(c, templateConfig);
- if (mergedObj) {
+ const mergedObjBase = getProjectTemplateMergedConfig(templateConfig);
+ if (mergedObjBase) {
+ const mergedObj = { ...mergedObjBase, ...(mergedObjBase.templateConfig?.renative_json || {}) };
+
// Do not override supportedPlatforms
mergedObj.defaults = mergedObj.defaults || {};
mergedObj.defaults.supportedPlatforms = c.files.project.config_original?.defaults?.supportedPlatforms;
@@ -190,19 +193,20 @@ const _configureRenativeConfig = async (c: RnvContext) => {
delete mergedObj.isNew;
delete mergedObj.templateConfig;
// c.files.project.config = mergedObj;
- writeRenativeConfigFile(c, c.paths.project.config, mergedObj);
- loadFileExtended(c, c.files.project, c.paths.project, 'config');
+ writeRenativeConfigFile(c.paths.project.config, mergedObj);
+ loadFileExtended(c.files.project, c.paths.project, 'config');
}
}
return true;
};
-const getProjectTemplateMergedConfig = (c: RnvContext, templateConfig: ConfigFileTemplate | null) => {
+const getProjectTemplateMergedConfig = (templateConfig: ConfigFileTemplate | null) => {
+ const c = getContext();
if (c.files.project.config_original && templateConfig) {
const mergedObj = mergeObjects(
c,
- templateConfig,
+ templateConfig || {},
c.files.project.config_original,
false,
true
@@ -212,30 +216,48 @@ const getProjectTemplateMergedConfig = (c: RnvContext, templateConfig: ConfigFil
return null;
};
-export const configureTemplateFiles = async (c: RnvContext) => {
+const _copyIncludedPath = (c: RnvContext, name: string) => {
+ const sourcePath = path.join(c.paths.template.dir, name);
+ const destPath = path.join(c.paths.project.dir, name);
+ if (!fsExistsSync(destPath) && fsExistsSync(sourcePath)) {
+ try {
+ if (fsLstatSync(sourcePath).isDirectory()) {
+ logInfo(`Missing directory ${chalk().bold(`${destPath}.js`)}. COPYING from TEMPATE...DONE`);
+ copyFolderContentsRecursiveSync(sourcePath, destPath);
+ } else {
+ logInfo(`Missing file ${chalk().bold(`${destPath}.js`)}. COPYING from TEMPATE...DONE`);
+ copyFileSync(sourcePath, destPath);
+ }
+ } catch (e) {
+ // Get some beer and order hookers
+ }
+ }
+};
+
+export const configureTemplateFiles = async () => {
logDefault('configureTemplateFiles');
+ const c = getContext();
+
const templateConfig = readObjectSync(c.paths.template.configTemplate);
- let mergedObj = getProjectTemplateMergedConfig(c, templateConfig);
+ let mergedObj = getProjectTemplateMergedConfig(templateConfig);
const includedPaths = mergedObj?.templateConfig?.includedPaths;
if (includedPaths) {
- includedPaths.forEach((name: string) => {
+ includedPaths.forEach((pth) => {
if (c.paths.template.dir) {
- const sourcePath = path.join(c.paths.template.dir, name);
- const destPath = path.join(c.paths.project.dir, name);
- if (!fsExistsSync(destPath) && fsExistsSync(sourcePath)) {
- try {
- if (fsLstatSync(sourcePath).isDirectory()) {
- logInfo(`Missing directory ${chalk().bold(`${destPath}.js`)}. COPYING from TEMPATE...DONE`);
- copyFolderContentsRecursiveSync(sourcePath, destPath);
- } else {
- logInfo(`Missing file ${chalk().bold(`${destPath}.js`)}. COPYING from TEMPATE...DONE`);
- copyFileSync(sourcePath, destPath);
+ if (typeof pth === 'string') {
+ _copyIncludedPath(c, pth);
+ } else {
+ const engId = c.runtime.engine?.config?.id;
+ if (!pth.engines || (engId && pth.engines?.includes?.(engId))) {
+ const incPaths = pth.paths;
+ if (incPaths.length > 0) {
+ incPaths.forEach((pth) => {
+ _copyIncludedPath(c, pth);
+ });
}
- } catch (e) {
- // Get some beer and order hookers
}
}
}
@@ -243,12 +265,13 @@ export const configureTemplateFiles = async (c: RnvContext) => {
}
};
-export const configureEntryPoint = async (c: RnvContext, platform: RnvPlatform) => {
+export const configureEntryPoint = async (platform: RnvPlatform) => {
logDefault('configureEntryPoint');
+ const c = getContext();
if (c.files.project.config?.isTemplate) return true;
- const entryFile = getConfigProp(c, platform, 'entryFile');
+ const entryFile = getConfigProp('entryFile');
try {
const source = path.join(c.paths.template.dir, `${entryFile}.js`);
@@ -278,7 +301,8 @@ export const configureEntryPoint = async (c: RnvContext, platform: RnvPlatform)
return true;
};
-export const getInstalledTemplateOptions = (c: RnvContext): PromptOptions | null => {
+export const getInstalledTemplateOptions = (): PromptOptions | null => {
+ const c = getContext();
if (c.files.project.config?.isTemplate) return null;
if (c.buildConfig.templates) {
return generateOptions(c.buildConfig.templates);
@@ -287,10 +311,13 @@ export const getInstalledTemplateOptions = (c: RnvContext): PromptOptions | null
return null;
};
-export const isTemplateInstalled = (c: RnvContext) =>
- c.buildConfig.currentTemplate ? doResolve(c.buildConfig.currentTemplate) : false;
+export const isTemplateInstalled = () => {
+ const c = getContext();
+ return c.buildConfig.currentTemplate ? doResolve(c.buildConfig.currentTemplate) : false;
+};
-export const applyTemplate = async (c: RnvContext, selectedTemplate?: string) => {
+export const applyTemplate = async (selectedTemplate?: string) => {
+ const c = getContext();
logDefault('applyTemplate', `${c.buildConfig.currentTemplate}=>${selectedTemplate}`);
if (c.files.project.config?.isTemplate) return true;
@@ -303,7 +330,7 @@ export const applyTemplate = async (c: RnvContext, selectedTemplate?: string) =>
if (!c.buildConfig.currentTemplate) {
logWarning("You don't have any current template selected");
- const opts = getInstalledTemplateOptions(c);
+ const opts = getInstalledTemplateOptions();
if (opts) {
const { template } = await inquirerPrompt({
@@ -314,7 +341,7 @@ export const applyTemplate = async (c: RnvContext, selectedTemplate?: string) =>
});
c.buildConfig.currentTemplate = template;
c.files.project.config.currentTemplate = template;
- writeRenativeConfigFile(c, c.paths.project.config, c.files.project.config);
+ writeRenativeConfigFile(c.paths.project.config, c.files.project.config);
} else {
logError('Could not find any installed templates');
}
@@ -323,7 +350,7 @@ export const applyTemplate = async (c: RnvContext, selectedTemplate?: string) =>
const templateIsInstalled = doResolve(c.buildConfig.currentTemplate);
if (!templateIsInstalled) {
// We Need template to be installed before other dependency resolutions (due to scoping)
- await checkIfProjectAndNodeModulesExists(c);
+ await checkIfProjectAndNodeModulesExists();
}
await _applyTemplate(c);
diff --git a/packages/engine-core/src/buildSchemes.ts b/packages/engine-core/src/buildSchemes.ts
index 940ac78dac..2a3973324a 100644
--- a/packages/engine-core/src/buildSchemes.ts
+++ b/packages/engine-core/src/buildSchemes.ts
@@ -1,9 +1,9 @@
import merge from 'deepmerge';
-import { RnvContext, chalk, inquirerPrompt, logDefault, logError, logInfo, logWarning } from '@rnv/core';
+import { chalk, getContext, inquirerPrompt, logDefault, logError, logInfo, logWarning } from '@rnv/core';
-export const isBuildSchemeSupported = async (c: RnvContext) => {
+export const isBuildSchemeSupported = async () => {
logDefault('isBuildSchemeSupported');
-
+ const c = getContext();
const { scheme } = c.program;
if (!c.platform) return;
diff --git a/packages/engine-core/src/common.ts b/packages/engine-core/src/common.ts
index 5dd88fd335..4aebfcc1ec 100644
--- a/packages/engine-core/src/common.ts
+++ b/packages/engine-core/src/common.ts
@@ -1,43 +1,46 @@
-import { logDefault, RnvContext } from '@rnv/core';
+import { getContext, logDefault } from '@rnv/core';
import { checkAndConfigureAndroidSdks, checkAndroidSdk } from '@rnv/sdk-android';
import { checkAndConfigureTizenSdks, checkTizenSdk } from '@rnv/sdk-tizen';
import { checkAndConfigureWebosSdks, checkWebosSdk } from '@rnv/sdk-webos';
-export const checkAndConfigureSdks = async (c: RnvContext) => {
+export const checkAndConfigureSdks = async () => {
logDefault('checkAndConfigureSdks');
+ const c = getContext();
+
switch (c.platform) {
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
- return checkAndConfigureAndroidSdks(c);
+ return checkAndConfigureAndroidSdks();
case 'tizen':
case 'tizenmobile':
case 'tizenwatch':
- return checkAndConfigureTizenSdks(c);
+ return checkAndConfigureTizenSdks();
case 'webos':
- return checkAndConfigureWebosSdks(c);
+ return checkAndConfigureWebosSdks();
default:
return true;
}
};
-export const checkSdk = async (c: RnvContext) => {
+export const checkSdk = async () => {
logDefault('checkSdk');
+ const c = getContext();
switch (c.platform) {
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
- return checkAndroidSdk(c);
+ return checkAndroidSdk();
case 'tizen':
case 'tizenmobile':
case 'tizenwatch':
- return checkTizenSdk(c);
+ return checkTizenSdk();
case 'webos':
- return checkWebosSdk(c);
+ return checkWebosSdk();
default:
return true;
}
diff --git a/packages/engine-core/src/plugins.ts b/packages/engine-core/src/plugins.ts
index 316667d3b6..a738ddb9db 100644
--- a/packages/engine-core/src/plugins.ts
+++ b/packages/engine-core/src/plugins.ts
@@ -1,7 +1,9 @@
-import { PluginListResponse, RnvContext, chalk } from '@rnv/core';
+import { PluginListResponse, chalk, getContext } from '@rnv/core';
import intersection from 'lodash/intersection';
-export const getPluginList = (c: RnvContext, isUpdate = false) => {
+export const getPluginList = (isUpdate = false) => {
+ const c = getContext();
+
const output: PluginListResponse = {
asString: '',
asArray: [],
diff --git a/packages/engine-core/src/tasks/app/taskAppConfigure.ts b/packages/engine-core/src/tasks/app/taskAppConfigure.ts
index 69f569f93d..8ced25d6d4 100644
--- a/packages/engine-core/src/tasks/app/taskAppConfigure.ts
+++ b/packages/engine-core/src/tasks/app/taskAppConfigure.ts
@@ -149,7 +149,7 @@ const _setAppId = (c: RnvContext, appId: string) => {
const taskAppConfigure = async (c: RnvContext) => {
logTask('taskAppConfigure');
- c.paths.project.appConfigsDirNames = listAppConfigsFoldersSync(c, true);
+ c.paths.project.appConfigsDirNames = listAppConfigsFoldersSync(true);
c.paths.project.appConfigsDirNames.forEach((dirName) => {
c.paths.project.appConfigsDirs.push(path.join(c.paths.project.appConfigsDir, dirName));
});
@@ -157,7 +157,7 @@ const taskAppConfigure = async (c: RnvContext) => {
const appConfigsDirsExt = c.buildConfig?.paths?.appConfigsDirs;
if (appConfigsDirsExt) {
appConfigsDirsExt.forEach((apePath) => {
- const appConfigsExt = listAppConfigsFoldersSync(c, true, apePath);
+ const appConfigsExt = listAppConfigsFoldersSync(true, apePath);
appConfigsExt.forEach((appExtName) => {
c.paths.project.appConfigsDirNames.push(appExtName);
c.paths.project.appConfigsDirs.push(path.join(apePath, appExtName));
@@ -199,7 +199,7 @@ const taskAppConfigure = async (c: RnvContext) => {
c.paths.project.appConfigsDirs[c.paths.project.appConfigsDirNames.indexOf(c.runtime.appId)];
}
- await updateRenativeConfigs(c);
+ await updateRenativeConfigs();
logAppInfo(c);
return true;
diff --git a/packages/engine-core/src/tasks/app/taskAppCreate.ts b/packages/engine-core/src/tasks/app/taskAppCreate.ts
index 8ab14aee61..bc15e52a5c 100644
--- a/packages/engine-core/src/tasks/app/taskAppCreate.ts
+++ b/packages/engine-core/src/tasks/app/taskAppCreate.ts
@@ -22,7 +22,7 @@ import {
const taskAppCreate: RnvTaskFn = async (c) => {
logTask('taskAppCreate');
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
let sourcePath: string | undefined;
diff --git a/packages/engine-core/src/tasks/app/taskAppSwitch.ts b/packages/engine-core/src/tasks/app/taskAppSwitch.ts
index 9829bfa620..e18ab7ad40 100644
--- a/packages/engine-core/src/tasks/app/taskAppSwitch.ts
+++ b/packages/engine-core/src/tasks/app/taskAppSwitch.ts
@@ -15,11 +15,11 @@ const taskSwitch: RnvTaskFn = async (c, _parentTask, originTask) => {
c.program.appConfigID = true;
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.appSwitch, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.appSwitch, originTask);
- await copyRuntimeAssets(c);
- await generatePlatformAssetsRuntimeConfig(c);
- await configureFonts(c);
+ await copyRuntimeAssets();
+ await generatePlatformAssetsRuntimeConfig();
+ await configureFonts();
return true;
};
diff --git a/packages/engine-core/src/tasks/crypto/common.ts b/packages/engine-core/src/tasks/crypto/common.ts
index 97f0ee0c94..e4e38ea56e 100644
--- a/packages/engine-core/src/tasks/crypto/common.ts
+++ b/packages/engine-core/src/tasks/crypto/common.ts
@@ -1,10 +1,10 @@
import {
- RnvContext,
RnvTaskName,
chalk,
executeTask,
fsExistsSync,
fsReadFileSync,
+ getContext,
getRealPath,
isSystemWin,
logDebug,
@@ -21,7 +21,8 @@ export const getEnvExportCmd = (envVar: string, key: string) => {
return `${chalk().bold(`export ${envVar}="${key}"`)}`;
};
-export const getEnvVar = (c: RnvContext) => {
+export const getEnvVar = () => {
+ const c = getContext();
if (!c.files.project.package.name) {
logError('package.json requires `name` field. cannot generate ENV variables for crypto');
return;
@@ -35,7 +36,8 @@ export const getEnvVar = (c: RnvContext) => {
return envVar;
};
-export const checkCrypto = async (c: RnvContext, parentTask?: string, originTask?: string) => {
+export const checkCrypto = async (parentTask?: string, originTask?: string) => {
+ const c = getContext();
logTask('checkCrypto');
if (c.program.ci || c.files.project.config?.crypto?.isOptional) return;
@@ -47,7 +49,7 @@ export const checkCrypto = async (c: RnvContext, parentTask?: string, originTask
}
if (sourceRaw) {
- const source = `${getRealPath(c, sourceRaw, 'crypto.path')}`;
+ const source = `${getRealPath(sourceRaw, 'crypto.path')}`;
const tsProjectPath = `${source}.timestamp`;
const wsPath = path.join(c.paths.workspace.dir, c.files.project.package.name);
const tsWorkspacePath = path.join(wsPath, 'timestamp');
@@ -69,7 +71,7 @@ export const checkCrypto = async (c: RnvContext, parentTask?: string, originTask
project timestamp: ${chalk().grey(`${tsProject} - ${new Date(tsProject)}`)}
workspace timestamp: ${chalk().grey(`${tsWorkspace} - ${new Date(tsWorkspace)}`)}
you should run decrypt`);
- await executeTask(c, RnvTaskName.cryptoDecrypt, parentTask, originTask);
+ await executeTask(RnvTaskName.cryptoDecrypt, parentTask, originTask);
return;
}
diff --git a/packages/engine-core/src/tasks/crypto/taskCryptoDecrypt.ts b/packages/engine-core/src/tasks/crypto/taskCryptoDecrypt.ts
index 8ef03c86f0..bd2f4e9e16 100644
--- a/packages/engine-core/src/tasks/crypto/taskCryptoDecrypt.ts
+++ b/packages/engine-core/src/tasks/crypto/taskCryptoDecrypt.ts
@@ -52,7 +52,7 @@ const taskCryptoDecrypt: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskCryptoDecrypt');
if (!parentTask) {
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoDecrypt, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoDecrypt, originTask);
}
const crypto = c.files.project.config?.crypto;
@@ -60,10 +60,10 @@ const taskCryptoDecrypt: RnvTaskFn = async (c, parentTask, originTask) => {
const projectName = c.files.project.config?.projectName;
if (!crypto?.isOptional && sourceRaw) {
- const envVar = getEnvVar(c);
+ const envVar = getEnvVar();
if (!projectName || !envVar) return;
- const source = `${getRealPath(c, sourceRaw, 'crypto.path')}`;
+ const source = `${getRealPath(sourceRaw, 'crypto.path')}`;
const ts = `${source}.timestamp`;
const destFolder = path.join(c.paths.workspace.dir, projectName);
const destTemp = `${path.join(c.paths.workspace.dir, projectName.replace('/', '-'))}.tgz`;
diff --git a/packages/engine-core/src/tasks/crypto/taskCryptoEncrypt.ts b/packages/engine-core/src/tasks/crypto/taskCryptoEncrypt.ts
index d19e785e3b..481e709084 100644
--- a/packages/engine-core/src/tasks/crypto/taskCryptoEncrypt.ts
+++ b/packages/engine-core/src/tasks/crypto/taskCryptoEncrypt.ts
@@ -23,6 +23,7 @@ import {
copyFileSync,
RnvTask,
RnvTaskName,
+ getContext,
} from '@rnv/core';
import { statSync } from 'fs';
import { getEnvExportCmd, getEnvVar } from './common';
@@ -37,7 +38,8 @@ const generateRandomKey = (length: number) =>
.map((x) => x[Math.floor(Math.random() * x.length)])
.join('');
-const initializeCryptoDirectory = async (c: RnvContext, sourceFolder: string) => {
+const initializeCryptoDirectory = async (sourceFolder: string) => {
+ const c = getContext();
const configDir = path.join(sourceFolder, 'appConfigs');
const targetFile = 'renative.private.json';
mkdirSync(sourceFolder);
@@ -98,7 +100,7 @@ const _checkAndConfigureCrypto = async (c: RnvContext) => {
const cnf = c.files.project.config_original;
if (!cnf) return;
- const envVar = getEnvVar(c);
+ const envVar = getEnvVar();
if (!envVar) return;
if (c.files.project.config && !c.files.project.config.crypto) {
@@ -127,7 +129,7 @@ const _checkAndConfigureCrypto = async (c: RnvContext) => {
)} does not exist yet.
RNV will create it for you, make sure you add whatever you want encrypted in it and then run the command again`
);
- await initializeCryptoDirectory(c, sourceFolder);
+ await initializeCryptoDirectory(sourceFolder);
// writeFileSync(path.join(sourceFolder), c.files.project.config);
await inquirerPrompt({
type: 'confirm',
@@ -176,7 +178,7 @@ Make sure you take into account special characters that might need to be escaped
const taskCryptoEncrypt: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoEncrypt');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoEncrypt, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoEncrypt, originTask);
const projectName = c.files.project.config?.projectName;
@@ -188,14 +190,14 @@ const taskCryptoEncrypt: RnvTaskFn = async (c, _parentTask, originTask) => {
const destRaw = c.files.project.config?.crypto?.path;
const tsWorkspacePath = path.join(c.paths.workspace.dir, projectName, 'timestamp');
- const envVar = getEnvVar(c);
+ const envVar = getEnvVar();
if (!envVar) return;
const key = c.program.key || c.process.env[envVar];
if (destRaw) {
- const dest = `${getRealPath(c, destRaw, 'crypto.path')}`;
+ const dest = `${getRealPath(destRaw, 'crypto.path')}`;
const destTemp = `${path.join(c.paths.workspace.dir, projectName.replace('/', '-'))}.tgz`;
const timestamp = new Date().getTime();
diff --git a/packages/engine-core/src/tasks/global/__tests__/taskClean.test.ts b/packages/engine-core/src/tasks/global/__tests__/taskClean.test.ts
index 8dc1d8000b..160c26ea14 100644
--- a/packages/engine-core/src/tasks/global/__tests__/taskClean.test.ts
+++ b/packages/engine-core/src/tasks/global/__tests__/taskClean.test.ts
@@ -33,9 +33,8 @@ test('Execute task.rnv.clean', async () => {
await expect(taskClean.fn?.(ctx)).resolves.toEqual(true);
//THEN
expect(removeDirs).toHaveBeenCalledTimes(3);
- expect(executeAsync).toHaveBeenCalledWith(ctx, 'watchman watch-del-all');
+ expect(executeAsync).toHaveBeenCalledWith('watchman watch-del-all');
expect(executeAsync).toHaveBeenCalledWith(
- ctx,
'npx rimraf -I $TMPDIR/metro-* && npx rimraf -I $TMPDIR/react-* && npx rimraf -I $TMPDIR/haste-*'
);
});
diff --git a/packages/engine-core/src/tasks/global/__tests__/taskKill.test.ts b/packages/engine-core/src/tasks/global/__tests__/taskKill.test.ts
index 1c2f3fe23a..9e91129cb0 100644
--- a/packages/engine-core/src/tasks/global/__tests__/taskKill.test.ts
+++ b/packages/engine-core/src/tasks/global/__tests__/taskKill.test.ts
@@ -20,5 +20,5 @@ test('Execute task.rnv.kill', async () => {
//WHEN
await expect(taskKill.fn?.(ctx)).resolves.toEqual(true);
//THEN
- expect(executeTask).toHaveBeenCalledWith(ctx, 'app configure', 'kill', undefined);
+ expect(executeTask).toHaveBeenCalledWith('app configure', 'kill', undefined);
});
diff --git a/packages/engine-core/src/tasks/global/taskClean.ts b/packages/engine-core/src/tasks/global/taskClean.ts
index c63741b587..b7590d42ca 100644
--- a/packages/engine-core/src/tasks/global/taskClean.ts
+++ b/packages/engine-core/src/tasks/global/taskClean.ts
@@ -195,13 +195,12 @@ const taskClean: RnvTaskFn = async (c) => {
clearWindowsCacheFiles();
} else {
try {
- await executeAsync(c, 'watchman watch-del-all');
+ await executeAsync('watchman watch-del-all');
} catch (e) {
logDebug('watchman not installed. skipping');
}
await executeAsync(
- c,
'npx rimraf -I $TMPDIR/metro-* && npx rimraf -I $TMPDIR/react-* && npx rimraf -I $TMPDIR/haste-*'
);
}
diff --git a/packages/engine-core/src/tasks/global/taskConfig.ts b/packages/engine-core/src/tasks/global/taskConfig.ts
index 7725d75c67..6b34bae0b8 100644
--- a/packages/engine-core/src/tasks/global/taskConfig.ts
+++ b/packages/engine-core/src/tasks/global/taskConfig.ts
@@ -11,7 +11,7 @@ import {
const taskConfig: RnvTaskFn = async (c, _, originTask) => {
logTask('taskConfig');
- await executeTask(c, RnvTaskName.configureSoft, RnvTaskName.config, originTask);
+ await executeTask(RnvTaskName.configureSoft, RnvTaskName.config, originTask);
console.log(JSON.stringify(c.buildConfig, null, 2));
diff --git a/packages/engine-core/src/tasks/global/taskConfigureSoft.ts b/packages/engine-core/src/tasks/global/taskConfigureSoft.ts
index 9f23346d2d..a1799465c5 100644
--- a/packages/engine-core/src/tasks/global/taskConfigureSoft.ts
+++ b/packages/engine-core/src/tasks/global/taskConfigureSoft.ts
@@ -11,16 +11,16 @@ import {
import { checkAndConfigureSdks, checkSdk } from '../../common';
import { isBuildSchemeSupported } from '../../buildSchemes';
-const taskConfigureSoft: RnvTaskFn = async (c, parentTask, originTask) => {
+const taskConfigureSoft: RnvTaskFn = async (_c, parentTask, originTask) => {
logTask('taskConfigureSoft');
- await configureRuntimeDefaults(c);
- await executeTask(c, RnvTaskName.appConfigure, parentTask, originTask);
- await isPlatformSupported(c);
- await isBuildSchemeSupported(c);
- await checkAndConfigureSdks(c);
- await checkSdk(c);
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
+ await executeTask(RnvTaskName.appConfigure, parentTask, originTask);
+ await isPlatformSupported();
+ await isBuildSchemeSupported();
+ await checkAndConfigureSdks();
+ await checkSdk();
+ await configureRuntimeDefaults();
return true;
};
diff --git a/packages/engine-core/src/tasks/global/taskDeploy.ts b/packages/engine-core/src/tasks/global/taskDeploy.ts
index 803afd6e0f..68d69c7b11 100644
--- a/packages/engine-core/src/tasks/global/taskDeploy.ts
+++ b/packages/engine-core/src/tasks/global/taskDeploy.ts
@@ -9,12 +9,12 @@ import {
SUPPORTED_PLATFORMS,
} from '@rnv/core';
-const taskDeploy: RnvTaskFn = async (c, parentTask, originTask) => {
+const taskDeploy: RnvTaskFn = async (_c, parentTask, originTask) => {
logTask('taskDeploy', `parent:${parentTask}`);
- await executeOrSkipTask(c, RnvTaskName.export, RnvTaskName.deploy, originTask);
+ await executeOrSkipTask(RnvTaskName.export, RnvTaskName.deploy, originTask);
- if (shouldSkipTask(c, RnvTaskName.deploy, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.deploy, originTask)) return true;
// Deploy simply trggets hook
return true;
diff --git a/packages/engine-core/src/tasks/global/taskDoctor.ts b/packages/engine-core/src/tasks/global/taskDoctor.ts
index a6e42f10e5..2a0d4d08ee 100644
--- a/packages/engine-core/src/tasks/global/taskDoctor.ts
+++ b/packages/engine-core/src/tasks/global/taskDoctor.ts
@@ -25,9 +25,9 @@ const configTargets = [
const taskDoctor: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskDoctor');
- await configureRuntimeDefaults(c);
- await executeTask(c, RnvTaskName.appConfigure, parentTask, originTask);
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
+ await executeTask(RnvTaskName.appConfigure, parentTask, originTask);
+ await configureRuntimeDefaults();
const configPaths: Array = [];
diff --git a/packages/engine-core/src/tasks/global/taskHelp.ts b/packages/engine-core/src/tasks/global/taskHelp.ts
index 4c9755161e..fe83e4d93a 100644
--- a/packages/engine-core/src/tasks/global/taskHelp.ts
+++ b/packages/engine-core/src/tasks/global/taskHelp.ts
@@ -10,7 +10,7 @@ import {
generateStringFromTaskOption,
} from '@rnv/core';
-const taskHelp: RnvTaskFn = async (c) => {
+const taskHelp: RnvTaskFn = async () => {
logTask('taskHelp');
// PARAMS
@@ -22,7 +22,7 @@ const taskHelp: RnvTaskFn = async (c) => {
// TASKS
const commands: Array = [];
- const engines = getRegisteredEngines(c);
+ const engines = getRegisteredEngines();
engines.forEach((engine) => {
Object.values(engine.tasks).forEach(({ task }) => {
diff --git a/packages/engine-core/src/tasks/global/taskInstall.ts b/packages/engine-core/src/tasks/global/taskInstall.ts
index 89f75c1cf5..6c9e0102e4 100644
--- a/packages/engine-core/src/tasks/global/taskInstall.ts
+++ b/packages/engine-core/src/tasks/global/taskInstall.ts
@@ -25,7 +25,7 @@ const taskInstall: RnvTaskFn = async (c, parentTask, _) => {
logInfo('node_modules folder is out of date. INSTALLING...');
}
c._requiresNpmInstall = false;
- await installPackageDependenciesAndPlugins(c);
+ await installPackageDependenciesAndPlugins();
}
return true;
};
diff --git a/packages/engine-core/src/tasks/global/taskKill.ts b/packages/engine-core/src/tasks/global/taskKill.ts
index 15ddd8120c..1ce87abc36 100644
--- a/packages/engine-core/src/tasks/global/taskKill.ts
+++ b/packages/engine-core/src/tasks/global/taskKill.ts
@@ -23,11 +23,11 @@ const taskKill: RnvTaskFn = async (c, _parentTask, originTask) => {
const results = [];
let ports: Partial> = {};
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
if (c.paths.project.configExists) {
- await executeTask(c, RnvTaskName.appConfigure, RnvTaskName.kill, originTask);
- await configureRuntimeDefaults(c);
+ await executeTask(RnvTaskName.appConfigure, RnvTaskName.kill, originTask);
+ await configureRuntimeDefaults();
platArray = Object.values(c.runtime.supportedPlatforms);
ports = c.buildConfig?.defaults?.ports || {};
}
@@ -36,7 +36,7 @@ const taskKill: RnvTaskFn = async (c, _parentTask, originTask) => {
const port = ports?.[plat.platform];
plat.port = port;
if (port) {
- results.push(checkPortInUse(c, plat.platform, port));
+ results.push(checkPortInUse(port));
}
}
const usedPortsArr = await Promise.all(results);
diff --git a/packages/engine-core/src/tasks/global/taskNew.ts b/packages/engine-core/src/tasks/global/taskNew.ts
index 617418c176..0a70b48250 100644
--- a/packages/engine-core/src/tasks/global/taskNew.ts
+++ b/packages/engine-core/src/tasks/global/taskNew.ts
@@ -158,7 +158,7 @@ const _prepareProjectOverview = (c: RnvContext, data: NewProjectData) => {
data.confirmString = str;
};
-type ConfigProp = Required['templateConfig']>['bootstrapQuestions'][number]['configProp'];
+type ConfigProp = Required['bootstrapConfig']>['bootstrapQuestions'][number]['configProp'];
type QuestionResults = Record<
string,
@@ -169,7 +169,7 @@ type QuestionResults = Record<
}
>;
-type BootstrapQuestions = Required['templateConfig']>['bootstrapQuestions'];
+type BootstrapQuestions = Required['bootstrapConfig']>['bootstrapQuestions'];
const interactiveQuestion = async (
results: QuestionResults,
@@ -430,8 +430,8 @@ const taskNew = async (c: RnvContext) => {
data.optionWorkspaces.selectedOption = inputWorkspace;
c.runtime.selectedWorkspace = inputWorkspace;
- await updateRenativeConfigs(c);
- data.optionTemplates = getTemplateOptions(c);
+ await updateRenativeConfigs();
+ data.optionTemplates = getTemplateOptions();
const options = [];
const values = data.optionTemplates.valuesAsObject;
@@ -488,7 +488,7 @@ const taskNew = async (c: RnvContext) => {
if (checkInputValue(templateVersion)) {
inputTemplateVersion = templateVersion;
} else {
- inputTemplateVersion = await listAndSelectNpmVersion(c, data.optionTemplates.selectedOption || '');
+ inputTemplateVersion = await listAndSelectNpmVersion(data.optionTemplates.selectedOption || '');
}
data.optionTemplates.selectedVersion = inputTemplateVersion;
@@ -501,10 +501,6 @@ const taskNew = async (c: RnvContext) => {
await executeAsync(`${isYarnInstalled() ? 'yarn' : 'npm'} add rnv@${c.rnvVersion}`, {
cwd: c.paths.project.dir,
});
- // Add pkg-dir to have the correct version before the first run
- await executeAsync(`${isYarnInstalled() ? 'yarn' : 'npm'} add pkg-dir@7.0.0`, {
- cwd: c.paths.project.dir,
- });
// Check if node_modules folder exists
if (!fsExistsSync(path.join(c.paths.project.dir, 'node_modules'))) {
@@ -515,6 +511,22 @@ const taskNew = async (c: RnvContext) => {
);
return;
}
+ // This ensures that the correct version of the npm packages will be used to run the project for the first time after creation
+
+ const renativeTemplateConfig =
+ readObjectSync(
+ path.join(c.paths.project.dir, 'node_modules', selectedInputTemplate, ConfigName.renativeTemplate)
+ ) || {};
+
+ const rnvNewPatchDependencies = renativeTemplateConfig.bootstrapConfig?.rnvNewPatchDependencies;
+
+ if (rnvNewPatchDependencies) {
+ const patchDeps = Object.entries(rnvNewPatchDependencies);
+ for (const [dependency, version] of patchDeps) {
+ const command = `${isYarnInstalled() ? 'yarn' : 'npm'} add ${dependency}@${version}`;
+ await executeAsync(command, { cwd: c.paths.project.dir });
+ }
+ }
if (!data.optionTemplates.keysAsArray?.includes(selectedInputTemplate)) {
const { confirmAddTemplate } = await inquirerPrompt({
@@ -534,18 +546,13 @@ const taskNew = async (c: RnvContext) => {
}
configFile.projectTemplates[selectedInputTemplate] = {};
writeFileSync(c.paths.workspace.config, configFile);
- await updateRenativeConfigs(c);
+ await updateRenativeConfigs();
logInfo(`Updating ${c.paths.workspace.config}...DONE`);
}
}
}
- const renativeTemplateConfig =
- readObjectSync(
- path.join(c.paths.project.dir, 'node_modules', selectedInputTemplate, ConfigName.renativeTemplate)
- ) || {};
-
const renativeConfig = readObjectSync(
path.join(c.paths.project.dir, 'node_modules', selectedInputTemplate, ConfigName.renative)
);
@@ -583,7 +590,7 @@ const taskNew = async (c: RnvContext) => {
// INPUT: Custom Questions
// ==================================================
const renativeTemplateConfigExt = {};
- const bootstrapQuestions = renativeTemplateConfig?.templateConfig?.bootstrapQuestions || [];
+ const bootstrapQuestions = renativeTemplateConfig?.bootstrapConfig?.bootstrapQuestions || [];
const results: QuestionResults = {};
const providedAnswers: Record = {};
@@ -700,6 +707,7 @@ const taskNew = async (c: RnvContext) => {
}
delete renativeTemplateConfig.templateConfig;
+ delete renativeTemplateConfig.bootstrapConfig;
if (!data.optionTemplates.selectedOption) {
logError('Current template not selected!');
@@ -770,7 +778,7 @@ const taskNew = async (c: RnvContext) => {
writeFileSync(c.paths.project.config, config);
if (data.gitEnabled) {
- await checkAndCreateGitignore(c);
+ await checkAndCreateGitignore();
await configureGit(c);
}
diff --git a/packages/engine-core/src/tasks/hooks/taskHooksList.ts b/packages/engine-core/src/tasks/hooks/taskHooksList.ts
index e62486e50f..d8589e9068 100644
--- a/packages/engine-core/src/tasks/hooks/taskHooksList.ts
+++ b/packages/engine-core/src/tasks/hooks/taskHooksList.ts
@@ -13,8 +13,8 @@ import {
const taskHooksList: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskHooksList');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.hooksList, originTask);
- await buildHooks(c);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.hooksList, originTask);
+ await buildHooks();
if (c.buildHooks) {
const hookOpts = generateOptions(c.buildHooks);
diff --git a/packages/engine-core/src/tasks/hooks/taskHooksPipes.ts b/packages/engine-core/src/tasks/hooks/taskHooksPipes.ts
index 4316546494..3de65ec7a1 100644
--- a/packages/engine-core/src/tasks/hooks/taskHooksPipes.ts
+++ b/packages/engine-core/src/tasks/hooks/taskHooksPipes.ts
@@ -13,9 +13,9 @@ import {
const taskHooksPipes: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskHooksPipes');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.hooksPipes, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.hooksPipes, originTask);
- await buildHooks(c);
+ await buildHooks();
const pipeOpts = generateOptions(c.buildPipes);
logRaw(`Pipes:\n${pipeOpts.asString}`);
diff --git a/packages/engine-core/src/tasks/hooks/taskHooksRun.ts b/packages/engine-core/src/tasks/hooks/taskHooksRun.ts
index 40743e04bf..81a350c4c3 100644
--- a/packages/engine-core/src/tasks/hooks/taskHooksRun.ts
+++ b/packages/engine-core/src/tasks/hooks/taskHooksRun.ts
@@ -16,12 +16,12 @@ const taskHooksRun: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskHooksRun');
if (fsExistsSync(c.paths.project.config)) {
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.hooksRun, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.hooksRun, originTask);
} else {
logInfo('Your are running your buildHook outside of renative project');
}
- await buildHooks(c);
+ await buildHooks();
if (!c.buildHooks) {
return Promise.reject('Build hooks have not been compiled properly!');
diff --git a/packages/engine-core/src/tasks/platform/__tests__/taskPlatformConfigure.test.ts b/packages/engine-core/src/tasks/platform/__tests__/taskPlatformConfigure.test.ts
index 942d8ed8c5..1afd83046c 100644
--- a/packages/engine-core/src/tasks/platform/__tests__/taskPlatformConfigure.test.ts
+++ b/packages/engine-core/src/tasks/platform/__tests__/taskPlatformConfigure.test.ts
@@ -19,5 +19,5 @@ test('Execute task.rnv.platform.configure', async () => {
//WHEN
await expect(taskPlatformConfigure.fn?.(ctx)).resolves.toEqual(true);
//THEN
- expect(executeTask).toHaveBeenCalledWith(ctx, 'project configure', 'platform configure', undefined);
+ expect(executeTask).toHaveBeenCalledWith('project configure', 'platform configure', undefined);
});
diff --git a/packages/engine-core/src/tasks/platform/__tests__/taskPlatformList.test.ts b/packages/engine-core/src/tasks/platform/__tests__/taskPlatformList.test.ts
index 5ba0afe611..b8d33a0d6f 100644
--- a/packages/engine-core/src/tasks/platform/__tests__/taskPlatformList.test.ts
+++ b/packages/engine-core/src/tasks/platform/__tests__/taskPlatformList.test.ts
@@ -18,5 +18,5 @@ test('Execute task.rnv.platform.list', async () => {
//WHEN
await expect(taskPlatformList.fn?.(ctx)).resolves.toEqual(true);
//THEN
- expect(executeTask).toHaveBeenCalledWith(ctx, 'project configure', 'platform list', undefined);
+ expect(executeTask).toHaveBeenCalledWith('project configure', 'platform list', undefined);
});
diff --git a/packages/engine-core/src/tasks/platform/taskPlatformConfigure.ts b/packages/engine-core/src/tasks/platform/taskPlatformConfigure.ts
index ce70b6bde0..8e89c402d5 100644
--- a/packages/engine-core/src/tasks/platform/taskPlatformConfigure.ts
+++ b/packages/engine-core/src/tasks/platform/taskPlatformConfigure.ts
@@ -22,19 +22,19 @@ import { isBuildSchemeSupported } from '../../buildSchemes';
const taskPlatformConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskPlatformConfigure', '');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.platformConfigure, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.platformConfigure, originTask);
- if (shouldSkipTask(c, RnvTaskName.platformConfigure, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.platformConfigure, originTask)) return true;
- await isPlatformSupported(c);
- await isBuildSchemeSupported(c);
- await checkAndConfigureSdks(c);
- await checkSdk(c);
- await configureRuntimeDefaults(c);
+ await isPlatformSupported();
+ await isBuildSchemeSupported();
+ await checkAndConfigureSdks();
+ await checkSdk();
+ await configureRuntimeDefaults();
if (c.program.only && !!parentTask) return true;
- await executeTask(c, RnvTaskName.install, RnvTaskName.platformConfigure, originTask);
+ await executeTask(RnvTaskName.install, RnvTaskName.platformConfigure, originTask);
const hasBuild = fsExistsSync(c.paths.project.builds.dir);
logTask('', `taskPlatformConfigure hasBuildFolderPresent:${hasBuild}`);
@@ -42,14 +42,14 @@ const taskPlatformConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
if ((c.program.reset || c.program.resetHard) && !c.runtime.disableReset) {
logInfo(
`You passed ${chalk().bold(c.program.reset ? '-r' : '-R')} argument. "${chalk().bold(
- getAppFolder(c)
+ getAppFolder()
)}" CLEANING...DONE`
);
- await cleanPlatformBuild(c, c.platform);
+ await cleanPlatformBuild(c.platform);
}
- await createPlatformBuild(c, c.platform);
- await injectPlatformDependencies(c);
+ await createPlatformBuild(c.platform);
+ await injectPlatformDependencies();
// await _runCopyPlatforms(c);
return true;
};
diff --git a/packages/engine-core/src/tasks/platform/taskPlatformConnect.ts b/packages/engine-core/src/tasks/platform/taskPlatformConnect.ts
index 00c8fc3427..6b18a2017f 100644
--- a/packages/engine-core/src/tasks/platform/taskPlatformConnect.ts
+++ b/packages/engine-core/src/tasks/platform/taskPlatformConnect.ts
@@ -20,7 +20,7 @@ import {
const taskPlatformConnect: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskPlatformConnect');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.platformConnect, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.platformConnect, originTask);
const configOriginal = c.files.project.config_original;
if (!configOriginal) {
@@ -41,7 +41,7 @@ const taskPlatformConnect: RnvTaskFn = async (c, _parentTask, originTask) => {
message:
'This will point platformTemplates folders from your local project to ReNative managed one. Select platforms you would like to connect',
type: 'checkbox',
- choices: generatePlatformChoices(c).map((choice) => ({
+ choices: generatePlatformChoices().map((choice) => ({
...choice,
disabled: choice.isConnected,
})),
diff --git a/packages/engine-core/src/tasks/platform/taskPlatformEject.ts b/packages/engine-core/src/tasks/platform/taskPlatformEject.ts
index cdeec96676..225975e0f1 100644
--- a/packages/engine-core/src/tasks/platform/taskPlatformEject.ts
+++ b/packages/engine-core/src/tasks/platform/taskPlatformEject.ts
@@ -19,7 +19,7 @@ import {
const taskPlatformEject: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskPlatformEject');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.platformEject, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.platformEject, originTask);
const configOriginal = c.files.project.config_original;
@@ -36,7 +36,7 @@ const taskPlatformEject: RnvTaskFn = async (c, _parentTask, originTask) => {
name: 'ejectedPlatforms',
message: 'Select platforms you would like to eject (use SPACE key)',
type: 'checkbox',
- choices: generatePlatformChoices(c).map((choice) => ({
+ choices: generatePlatformChoices().map((choice) => ({
...choice,
disabled: !choice.isConnected,
})),
@@ -50,7 +50,7 @@ const taskPlatformEject: RnvTaskFn = async (c, _parentTask, originTask) => {
// const destDir = path.join(c.paths.project.dir, 'platformTemplates', platform);
// engine.ejectPlatform(c, platform, destDir);
- ejectPlatform(c, platform);
+ ejectPlatform(platform);
configOriginal.paths = configOriginal.paths || {};
diff --git a/packages/engine-core/src/tasks/platform/taskPlatformList.ts b/packages/engine-core/src/tasks/platform/taskPlatformList.ts
index 5d54ad8137..7880926255 100644
--- a/packages/engine-core/src/tasks/platform/taskPlatformList.ts
+++ b/packages/engine-core/src/tasks/platform/taskPlatformList.ts
@@ -10,12 +10,12 @@ import {
RnvTaskName,
} from '@rnv/core';
-const taskPlatformList: RnvTaskFn = async (c, _parentTask, originTask) => {
+const taskPlatformList: RnvTaskFn = async (_c, _parentTask, originTask) => {
logTask('taskPlatformList');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.platformList, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.platformList, originTask);
- const opts = generatePlatformChoices(c).map((v, i) => ` [${chalk().bold(i + 1)}]> ${v.name}`);
+ const opts = generatePlatformChoices().map((v, i) => ` [${chalk().bold(i + 1)}]> ${v.name}`);
logToSummary(`Platforms:\n\n${opts.join('\n')}`);
return true;
};
diff --git a/packages/engine-core/src/tasks/platform/taskPlatformSetup.ts b/packages/engine-core/src/tasks/platform/taskPlatformSetup.ts
index e350896b85..902b07a646 100644
--- a/packages/engine-core/src/tasks/platform/taskPlatformSetup.ts
+++ b/packages/engine-core/src/tasks/platform/taskPlatformSetup.ts
@@ -12,7 +12,7 @@ import {
const taskPlatformSetup: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskPlatformSetup');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.platformSetup, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.platformSetup, originTask);
const currentPlatforms = c.files.project.config?.defaults?.supportedPlatforms || [];
@@ -26,7 +26,7 @@ const taskPlatformSetup: RnvTaskFn = async (c, _parentTask, originTask) => {
choices: c.runtime.availablePlatforms,
});
- updateProjectPlatforms(c, inputSupportedPlatforms);
+ updateProjectPlatforms(inputSupportedPlatforms);
};
const Task: RnvTask = {
diff --git a/packages/engine-core/src/tasks/plugin/taskPluginAdd.ts b/packages/engine-core/src/tasks/plugin/taskPluginAdd.ts
index 0990628063..1b98f0e4f5 100644
--- a/packages/engine-core/src/tasks/plugin/taskPluginAdd.ts
+++ b/packages/engine-core/src/tasks/plugin/taskPluginAdd.ts
@@ -20,11 +20,11 @@ import { getPluginList } from '../../plugins';
const taskPluginAdd: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskPluginAdd');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.pluginAdd, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.pluginAdd, originTask);
const selPluginKey = c.program.rawArgs?.[4];
- const o = getPluginList(c);
+ const o = getPluginList();
const selPlugin = selPluginKey && o.allPlugins[selPluginKey];
const selectedPlugins: Record = {};
@@ -89,11 +89,11 @@ const taskPluginAdd: RnvTaskFn = async (c, _parentTask, originTask) => {
.spinner(`Installing: ${installMessage.join(', ')}`)
.start('');
- writeRenativeConfigFile(c, c.paths.project.config, cnfOriginal);
+ writeRenativeConfigFile(c.paths.project.config, cnfOriginal);
- await resolvePluginDependants(c);
+ await resolvePluginDependants();
- await executeTask(c, RnvTaskName.install, RnvTaskName.pluginAdd, originTask);
+ await executeTask(RnvTaskName.install, RnvTaskName.pluginAdd, originTask);
spinner.succeed('All plugins installed!');
logSuccess('Plugins installed successfully!');
diff --git a/packages/engine-core/src/tasks/plugin/taskPluginList.ts b/packages/engine-core/src/tasks/plugin/taskPluginList.ts
index 290866b540..e8e46ee907 100644
--- a/packages/engine-core/src/tasks/plugin/taskPluginList.ts
+++ b/packages/engine-core/src/tasks/plugin/taskPluginList.ts
@@ -4,9 +4,9 @@ import { getPluginList } from '../../plugins';
const taskPluginList: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskPluginList');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.pluginList, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.pluginList, originTask);
- const o = getPluginList(c);
+ const o = getPluginList();
// console.log(o.asString);
logToSummary(`Plugins:\n\n${o.asString}`);
diff --git a/packages/engine-core/src/tasks/plugin/taskPluginUpdate.ts b/packages/engine-core/src/tasks/plugin/taskPluginUpdate.ts
index b99a871cb7..f56635f62a 100644
--- a/packages/engine-core/src/tasks/plugin/taskPluginUpdate.ts
+++ b/packages/engine-core/src/tasks/plugin/taskPluginUpdate.ts
@@ -14,7 +14,7 @@ import {
const taskPluginUpdate: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskPluginUpdate');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.pluginUpdate, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.pluginUpdate, originTask);
// const pluginList = getPluginList(c, true);
diff --git a/packages/engine-core/src/tasks/project/taskProjectConfigure.ts b/packages/engine-core/src/tasks/project/taskProjectConfigure.ts
index f568498071..6d756ce11d 100644
--- a/packages/engine-core/src/tasks/project/taskProjectConfigure.ts
+++ b/packages/engine-core/src/tasks/project/taskProjectConfigure.ts
@@ -26,15 +26,16 @@ import {
initializeTask,
findSuitableTask,
RnvTaskFn,
- RnvContext,
generatePlatformAssetsRuntimeConfig,
RnvTask,
generateLocalJsonSchemas,
RnvTaskName,
+ getContext,
} from '@rnv/core';
import { checkCrypto } from '../crypto/common';
-const checkIsRenativeProject = async (c: RnvContext) => {
+const checkIsRenativeProject = async () => {
+ const c = getContext();
if (!c.paths.project.configExists) {
return Promise.reject(
`This directory is not ReNative project. Project config ${chalk().bold(
@@ -45,7 +46,8 @@ const checkIsRenativeProject = async (c: RnvContext) => {
return true;
};
-const configurePlatformBuilds = async (c: RnvContext) => {
+const configurePlatformBuilds = async () => {
+ const c = getContext();
if (c.paths.project.builds.dir && !fsExistsSync(c.paths.project.builds.dir)) {
logInfo(`Creating folder ${c.paths.project.builds.dir} ...DONE`);
fsMkdirSync(c.paths.project.builds.dir);
@@ -55,53 +57,53 @@ const configurePlatformBuilds = async (c: RnvContext) => {
const taskProjectConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskProjectConfigure');
- await configurePlatformBuilds(c);
+ await configurePlatformBuilds();
await checkAndMigrateProject();
- await updateRenativeConfigs(c);
- await checkIsRenativeProject(c);
+ await updateRenativeConfigs();
+ await checkIsRenativeProject();
await generateLocalJsonSchemas();
- await executeTask(c, RnvTaskName.workspaceConfigure, RnvTaskName.projectConfigure, originTask);
+ await executeTask(RnvTaskName.workspaceConfigure, RnvTaskName.projectConfigure, originTask);
if (c.program.only && !!parentTask) {
- await configureRuntimeDefaults(c);
- await executeTask(c, RnvTaskName.appConfigure, RnvTaskName.projectConfigure, originTask);
- await generatePlatformAssetsRuntimeConfig(c);
+ await configureRuntimeDefaults();
+ await executeTask(RnvTaskName.appConfigure, RnvTaskName.projectConfigure, originTask);
+ await generatePlatformAssetsRuntimeConfig();
return true;
}
- await checkIfTemplateConfigured(c);
- await executeTask(c, RnvTaskName.install, RnvTaskName.projectConfigure, originTask);
+ await checkIfTemplateConfigured();
+ await executeTask(RnvTaskName.install, RnvTaskName.projectConfigure, originTask);
if (originTask !== RnvTaskName.cryptoDecrypt) {
//If we explicitly running rnv crypto decrypt there is no need to check crypto
- await checkCrypto(c, parentTask, originTask);
+ await checkCrypto(parentTask, originTask);
}
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
if (originTask !== RnvTaskName.templateApply) {
- if ((c.runtime.requiresBootstrap || !isTemplateInstalled(c)) && !c.files.project.config?.isTemplate) {
- await applyTemplate(c);
+ if ((c.runtime.requiresBootstrap || !isTemplateInstalled()) && !c.files.project.config?.isTemplate) {
+ await applyTemplate();
// We'll have to install the template first and reset current engine
logInfo('Your template has been bootstraped. Command reset is required. RESTRATING...DONE');
- const taskInstance = await findSuitableTask(c);
+ const taskInstance = await findSuitableTask();
c.runtime.requiresBootstrap = false;
if (taskInstance?.task) {
- return initializeTask(c, taskInstance?.task);
+ return initializeTask(taskInstance?.task);
}
}
- await applyTemplate(c);
- await configureRuntimeDefaults(c);
- await executeTask(c, RnvTaskName.install, RnvTaskName.projectConfigure, originTask);
- await executeTask(c, RnvTaskName.appConfigure, RnvTaskName.projectConfigure, originTask);
+ await applyTemplate();
+ await configureRuntimeDefaults();
+ await executeTask(RnvTaskName.install, RnvTaskName.projectConfigure, originTask);
+ await executeTask(RnvTaskName.appConfigure, RnvTaskName.projectConfigure, originTask);
// IMPORTANT: configurePlugins must run after appConfig present to ensure merge of all configs/plugins
await versionCheck(c);
await configureEngines(c);
- await resolvePluginDependants(c);
- await configurePlugins(c);
+ await resolvePluginDependants();
+ await configurePlugins();
- await configureRuntimeDefaults(c);
+ await configureRuntimeDefaults();
if (!c.runtime.disableReset) {
if (c.program.resetHard) {
logInfo(
@@ -109,28 +111,28 @@ const taskProjectConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
'./platformAssets'
)}" will be cleaned up first`
);
- await cleanPlaformAssets(c);
+ await cleanPlaformAssets();
} else if (c.program.resetAssets) {
logInfo(
`You passed ${chalk().bold('-a, --resetAssets')} argument. "${chalk().bold(
'./platformAssets'
)}" will be cleaned up first`
);
- await cleanPlaformAssets(c);
+ await cleanPlaformAssets();
}
}
- await copyRuntimeAssets(c);
- await configureTemplateFiles(c);
- await checkAndCreateGitignore(c);
+ await copyRuntimeAssets();
+ await configureTemplateFiles();
+ await checkAndCreateGitignore();
if (!c.buildConfig.platforms) {
- await updateRenativeConfigs(c);
+ await updateRenativeConfigs();
}
- await generatePlatformAssetsRuntimeConfig(c);
- await overrideTemplatePlugins(c);
+ await generatePlatformAssetsRuntimeConfig();
+ await overrideTemplatePlugins();
// NOTE: this is needed to ensure missing rnv plugin sub-deps are caught
- await checkForPluginDependencies(c);
- await configureFonts(c);
+ await checkForPluginDependencies();
+ await configureFonts();
}
return true;
diff --git a/packages/engine-core/src/tasks/project/taskProjectUpgrade.ts b/packages/engine-core/src/tasks/project/taskProjectUpgrade.ts
index cdab3fdefc..a94c4bde27 100644
--- a/packages/engine-core/src/tasks/project/taskProjectUpgrade.ts
+++ b/packages/engine-core/src/tasks/project/taskProjectUpgrade.ts
@@ -23,17 +23,17 @@ const taskProjectUpgrade: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskProjectUpgrade');
const upgradedPaths = [];
if (fsExistsSync(c.paths.project.config)) {
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.projectUpgrade, originTask);
- const selectedVersion = await listAndSelectNpmVersion(c, 'rnv');
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.projectUpgrade, originTask);
+ const selectedVersion = await listAndSelectNpmVersion('rnv');
- upgradedPaths.push(...upgradeProjectDependencies(c, selectedVersion));
+ upgradedPaths.push(...upgradeProjectDependencies(selectedVersion));
- await installPackageDependenciesAndPlugins(c);
+ await installPackageDependenciesAndPlugins();
} else {
logInfo('Your are running rnv upgrade outside of renative project');
const packagesPath = path.join(c.paths.project.dir, 'packages');
if (fsExistsSync(c.paths.project.package) && fsExistsSync(packagesPath)) {
- const selectedVersion = await listAndSelectNpmVersion(c, 'rnv');
+ const selectedVersion = await listAndSelectNpmVersion('rnv');
upgradedPaths.push(
...upgradeDependencies(
diff --git a/packages/engine-core/src/tasks/target/taskTargetLaunch.ts b/packages/engine-core/src/tasks/target/taskTargetLaunch.ts
index 3333f9596e..4152d88db0 100644
--- a/packages/engine-core/src/tasks/target/taskTargetLaunch.ts
+++ b/packages/engine-core/src/tasks/target/taskTargetLaunch.ts
@@ -16,12 +16,12 @@ import { launchTizenSimulator } from '@rnv/sdk-tizen';
import { launchWebOSimulator } from '@rnv/sdk-webos';
import { launchKaiOSSimulator } from '@rnv/sdk-kaios';
-const taskTargetLaunch: RnvTaskFn = async (c, parentTask, originTask) => {
+const taskTargetLaunch: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskTargetLaunch');
- await isPlatformSupported(c, true);
- await checkAndConfigureSdks(c);
- await executeTask(c, RnvTaskName.workspaceConfigure, RnvTaskName.targetLaunch, originTask);
+ await isPlatformSupported(true);
+ await checkAndConfigureSdks();
+ await executeTask(RnvTaskName.workspaceConfigure, RnvTaskName.targetLaunch, originTask);
const { platform, program } = c;
let target = program?.target;
@@ -33,7 +33,6 @@ const taskTargetLaunch: RnvTaskFn = async (c, parentTask, originTask) => {
options.push({ name: `${projectTarget} (project default)`, value: projectTarget });
}
const workspaceTarget = c.files.workspace.config?.defaultTargets?.[platform];
-
if (workspaceTarget) {
options.push({ name: `${workspaceTarget} (global default)`, value: workspaceTarget });
}
@@ -52,23 +51,23 @@ const taskTargetLaunch: RnvTaskFn = async (c, parentTask, originTask) => {
}
}
- await checkSdk(c);
+ await checkSdk();
switch (platform) {
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
- return launchAndroidSimulator(c, target);
+ return launchAndroidSimulator(target);
case 'ios':
case 'tvos':
- return launchAppleSimulator(c, target);
+ return launchAppleSimulator(target);
case 'tizen':
- return launchTizenSimulator(c, target);
+ return launchTizenSimulator(target);
case 'webos':
- return launchWebOSimulator(c, target);
+ return launchWebOSimulator(target);
case 'kaios':
- return launchKaiOSSimulator(c);
+ return launchKaiOSSimulator(target);
default:
return Promise.reject(
`"target launch" command does not support ${chalk().white.bold(
diff --git a/packages/engine-core/src/tasks/target/taskTargetList.ts b/packages/engine-core/src/tasks/target/taskTargetList.ts
index bd93f51054..d993f57eb1 100644
--- a/packages/engine-core/src/tasks/target/taskTargetList.ts
+++ b/packages/engine-core/src/tasks/target/taskTargetList.ts
@@ -17,13 +17,13 @@ import { checkAndConfigureSdks, checkSdk } from '../../common';
const taskTargetList: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskTargetList');
- await isPlatformSupported(c, true);
- await checkAndConfigureSdks(c);
- await executeTask(c, RnvTaskName.workspaceConfigure, RnvTaskName.targetList, originTask);
+ await isPlatformSupported(true);
+ await checkAndConfigureSdks();
+ await executeTask(RnvTaskName.workspaceConfigure, RnvTaskName.targetList, originTask);
const { platform } = c;
- await checkSdk(c);
+ await checkSdk();
switch (platform) {
case 'android':
@@ -35,7 +35,7 @@ const taskTargetList: RnvTaskFn = async (c, _parentTask, originTask) => {
case 'tvos':
return listAppleDevices(c);
case 'tizen':
- return listTizenTargets(c);
+ return listTizenTargets();
case 'webos':
return listWebOSTargets(c);
default:
diff --git a/packages/engine-core/src/tasks/template/taskTemplateAdd.ts b/packages/engine-core/src/tasks/template/taskTemplateAdd.ts
index 987850598d..6784443103 100644
--- a/packages/engine-core/src/tasks/template/taskTemplateAdd.ts
+++ b/packages/engine-core/src/tasks/template/taskTemplateAdd.ts
@@ -12,9 +12,9 @@ import {
RnvTaskName,
} from '@rnv/core';
-const _writeObjectSync = (c: RnvContext, p: string, s: object) => {
+const _writeObjectSync = (p: string, s: object) => {
writeFileSync(p, s);
- generateBuildConfig(c);
+ generateBuildConfig();
};
export const _addTemplate = (c: RnvContext, template: string) => {
@@ -31,15 +31,15 @@ export const _addTemplate = (c: RnvContext, template: string) => {
};
}
- _writeObjectSync(c, c.paths.project.config, cnf);
+ _writeObjectSync(c.paths.project.config, cnf);
};
const taskTemplateAdd: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskTemplateAdd');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.templateAdd, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.templateAdd, originTask);
- const opts = getTemplateOptions(c);
+ const opts = getTemplateOptions();
const { template } = await inquirerPrompt({
type: 'list',
diff --git a/packages/engine-core/src/tasks/template/taskTemplateApply.ts b/packages/engine-core/src/tasks/template/taskTemplateApply.ts
index 4b19e9f056..28d1e158e7 100644
--- a/packages/engine-core/src/tasks/template/taskTemplateApply.ts
+++ b/packages/engine-core/src/tasks/template/taskTemplateApply.ts
@@ -13,21 +13,21 @@ import {
const taskTemplateApply: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskTemplateApply', `template: ${c.program.template}`);
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.templateApply, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.templateApply, originTask);
if (c.files.project.config?.isTemplate) {
return Promise.reject('Template projects cannot use template apply command');
}
if (c.program.template) {
- await applyTemplate(c, c.program.template);
+ await applyTemplate(c.program.template);
if (c.program.appConfigID) {
- await executeTask(c, RnvTaskName.appConfigure, RnvTaskName.templateApply, originTask);
+ await executeTask(RnvTaskName.appConfigure, RnvTaskName.templateApply, originTask);
}
return true;
}
- const opts = getInstalledTemplateOptions(c);
+ const opts = getInstalledTemplateOptions();
const { template } = await inquirerPrompt({
type: 'list',
@@ -36,9 +36,9 @@ const taskTemplateApply: RnvTaskFn = async (c, _parentTask, originTask) => {
choices: opts?.keysAsArray,
});
- await applyTemplate(c, template);
+ await applyTemplate(template);
if (c.program.appConfigID) {
- await executeTask(c, RnvTaskName.appConfigure, RnvTaskName.templateApply, originTask);
+ await executeTask(RnvTaskName.appConfigure, RnvTaskName.templateApply, originTask);
}
return true;
};
diff --git a/packages/engine-core/src/tasks/template/taskTemplateList.ts b/packages/engine-core/src/tasks/template/taskTemplateList.ts
index f426633747..5226044c4c 100644
--- a/packages/engine-core/src/tasks/template/taskTemplateList.ts
+++ b/packages/engine-core/src/tasks/template/taskTemplateList.ts
@@ -13,9 +13,9 @@ const taskTemplateList: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskTemplateList');
if (c.paths.project.configExists) {
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.templateList, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.templateList, originTask);
}
- const opts = getTemplateOptions(c, !c.paths.project.configExists);
+ const opts = getTemplateOptions(!c.paths.project.configExists);
logToSummary(`Templates:\n\n${opts.asString}`);
return true;
};
diff --git a/packages/engine-core/src/tasks/workspace/taskWorkspaceAdd.ts b/packages/engine-core/src/tasks/workspace/taskWorkspaceAdd.ts
index e21b914fc3..4ad6facfc1 100644
--- a/packages/engine-core/src/tasks/workspace/taskWorkspaceAdd.ts
+++ b/packages/engine-core/src/tasks/workspace/taskWorkspaceAdd.ts
@@ -11,10 +11,10 @@ import {
RnvTaskName,
} from '@rnv/core';
-const taskWorkspaceAdd: RnvTaskFn = async (c, _parentTask, originTask) => {
+const taskWorkspaceAdd: RnvTaskFn = async (_c, _parentTask, originTask) => {
logTask('taskWorkspaceAdd');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.workspaceAdd, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.workspaceAdd, originTask);
const { workspace } = await inquirerPrompt({
name: 'workspace',
@@ -43,7 +43,7 @@ const taskWorkspaceAdd: RnvTaskFn = async (c, _parentTask, originTask) => {
});
workspaceID = workspaceIDInput || workspaceID;
- createWorkspace(c, workspaceID, workspacePath);
+ createWorkspace(workspaceID, workspacePath);
return true;
};
diff --git a/packages/engine-core/src/tasks/workspace/taskWorkspaceConnect.ts b/packages/engine-core/src/tasks/workspace/taskWorkspaceConnect.ts
index 3e5c1ea622..4e1d05bf10 100644
--- a/packages/engine-core/src/tasks/workspace/taskWorkspaceConnect.ts
+++ b/packages/engine-core/src/tasks/workspace/taskWorkspaceConnect.ts
@@ -16,7 +16,7 @@ const taskWorkspaceConnect: RnvTaskFn = async (c, _parentTask, originTask) => {
if (!c.paths.project.configExists) {
return Promise.reject(`${RnvTaskName.projectConfigure} not supported outside of renative project`);
}
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.workspaceConnect, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.workspaceConnect, originTask);
const cnf = c.files.rnv.configWorkspaces;
if (!cnf) return;
diff --git a/packages/engine-core/src/tasks/workspace/taskWorkspaceList.ts b/packages/engine-core/src/tasks/workspace/taskWorkspaceList.ts
index f09a4af7ad..6f6e58618d 100644
--- a/packages/engine-core/src/tasks/workspace/taskWorkspaceList.ts
+++ b/packages/engine-core/src/tasks/workspace/taskWorkspaceList.ts
@@ -14,7 +14,7 @@ const taskWorkspaceList: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskWorkspaceList');
if (c.paths.project.configExists) {
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.workspaceList, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.workspaceList, originTask);
}
const opts = generateOptions(
diff --git a/packages/engine-core/src/tasks/workspace/taskWorkspaceUpdate.ts b/packages/engine-core/src/tasks/workspace/taskWorkspaceUpdate.ts
index 912dc93201..b0e7c55e2d 100644
--- a/packages/engine-core/src/tasks/workspace/taskWorkspaceUpdate.ts
+++ b/packages/engine-core/src/tasks/workspace/taskWorkspaceUpdate.ts
@@ -1,10 +1,10 @@
import { logTask, executeTask, RnvTaskOptionPresets, RnvTaskFn, RnvTask, RnvTaskName } from '@rnv/core';
-const taskWorkspaceUpdate: RnvTaskFn = async (c, _parentTask, originTask) => {
+const taskWorkspaceUpdate: RnvTaskFn = async (_c, _parentTask, originTask) => {
// TODO: taskWorkspaceUpdate
logTask('taskWorkspaceUpdate');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.workspaceUpdate, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.workspaceUpdate, originTask);
return true;
};
diff --git a/packages/engine-lightning/src/sdks/sdk-lightning/env.ts b/packages/engine-lightning/src/sdks/sdk-lightning/env.ts
index 05cbdfbd0c..592b3fb0c0 100644
--- a/packages/engine-lightning/src/sdks/sdk-lightning/env.ts
+++ b/packages/engine-lightning/src/sdks/sdk-lightning/env.ts
@@ -2,14 +2,10 @@ import { getAppFolder, getConfigProp, getContext } from '@rnv/core';
export const EnvVars = {
LNG_BUILD_FOLDER: () => {
- const ctx = getContext();
-
- return { LNG_BUILD_FOLDER: getAppFolder(ctx, true) };
+ return { LNG_BUILD_FOLDER: getAppFolder(true) };
},
LNG_ENTRY_FILE: () => {
- const ctx = getContext();
-
- const entryFile = getConfigProp(ctx, ctx.platform, 'entryFile');
+ const entryFile = getConfigProp('entryFile');
return { LNG_ENTRY_FILE: entryFile };
},
LNG_SERVE_PORT: () => {
@@ -19,7 +15,6 @@ export const EnvVars = {
};
},
LNG_DIST_FOLDER: () => {
- const ctx = getContext();
- return { LNG_DIST_FOLDER: getAppFolder(ctx, true) };
+ return { LNG_DIST_FOLDER: getAppFolder(true) };
},
};
diff --git a/packages/engine-lightning/src/sdks/sdk-lightning/index.ts b/packages/engine-lightning/src/sdks/sdk-lightning/index.ts
index 6b82ec090f..32565bb5ea 100644
--- a/packages/engine-lightning/src/sdks/sdk-lightning/index.ts
+++ b/packages/engine-lightning/src/sdks/sdk-lightning/index.ts
@@ -17,6 +17,7 @@ import {
CoreEnvVars,
getAppFolder,
logDefault,
+ getContext,
} from '@rnv/core';
import semver from 'semver';
@@ -25,14 +26,15 @@ import { CLI_WEBOS_ARES_PACKAGE, runWebosSimOrDevice } from '@rnv/sdk-webos';
import { getAppVersion, getAppTitle, getAppId, getAppDescription, addSystemInjects } from '@rnv/sdk-utils';
import { EnvVars } from './env';
-export const runLightningProject = async (c: RnvContext) => {
+export const runLightningProject = async () => {
+ const c = getContext();
logDefault('runLightningProject');
const { platform } = c;
const { hosted } = c.program;
- const isHosted = hosted && !getConfigProp(c, platform, 'bundleAssets');
+ const isHosted = hosted && !getConfigProp('bundleAssets');
if (isHosted) {
- await executeAsync(c, 'lng dev', {
+ await executeAsync('lng dev', {
stdio: 'inherit',
silent: false,
env: {
@@ -43,31 +45,32 @@ export const runLightningProject = async (c: RnvContext) => {
},
});
} else {
- await buildLightningProject(c);
+ await buildLightningProject();
if (platform === 'tizen') {
- await runTizenSimOrDevice(c);
+ await runTizenSimOrDevice();
} else {
- await runWebosSimOrDevice(c);
+ await runWebosSimOrDevice();
}
}
return true;
};
-export const buildLightningProject = async (c: RnvContext) => {
+export const buildLightningProject = async () => {
+ const c = getContext();
logDefault('buildLightningProject');
const { platform } = c;
if (!platform) return;
- const certProfile = getConfigProp(c, c.platform, 'certificateProfile') || DEFAULTS.certificateProfile;
+ const certProfile = getConfigProp('certificateProfile') || DEFAULTS.certificateProfile;
- const target = getConfigProp(c, platform, 'target', 'es6');
- const tBuild = getPlatformProjectDir(c);
+ const target = getConfigProp('target', 'es6');
+ const tBuild = getPlatformProjectDir();
const tOut = path.join(tBuild || '', 'output');
- await executeAsync(c, `lng dist --${target}`, {
+ await executeAsync(`lng dist --${target}`, {
stdio: 'inherit',
silent: false,
env: {
@@ -78,11 +81,11 @@ export const buildLightningProject = async (c: RnvContext) => {
});
if (platform === 'tizen') {
- await execCLI(c, CLI_TIZEN, `package -- ${tBuild} -s ${certProfile} -t wgt -o ${tOut}`);
+ await execCLI(CLI_TIZEN, `package -- ${tBuild} -s ${certProfile} -t wgt -o ${tOut}`);
logSuccess(`Your WGT package is located in ${chalk().cyan(tOut)} .`);
} else {
- await execCLI(c, CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${tBuild} -n`);
+ await execCLI(CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${tBuild} -n`);
logSuccess(`Your IPK package is located in ${chalk().cyan(tOut)} .`);
}
@@ -90,16 +93,16 @@ export const buildLightningProject = async (c: RnvContext) => {
return true;
};
-export const configureLightningProject = async (c: RnvContext) => {
+export const configureLightningProject = async () => {
logTask('configureLightningProject');
- const { platform } = c;
- c.runtime.platformBuildsProjectPath = `${getAppFolder(c)}`;
- if (!isPlatformActive(c, platform)) {
+ const c = getContext();
+ c.runtime.platformBuildsProjectPath = `${getAppFolder()}`;
+ if (!isPlatformActive()) {
return;
}
- await copyAssetsFolder(c, platform);
+ await copyAssetsFolder();
await _configureProject(c);
- return copyBuildsFolder(c, platform);
+ return copyBuildsFolder();
};
const _configureProject = (c: RnvContext) =>
@@ -112,9 +115,9 @@ const _configureProject = (c: RnvContext) =>
return;
}
- const pkg = getConfigProp(c, c.platform, 'package') || '';
- const id = getConfigProp(c, c.platform, 'id') || '';
- const appName = getConfigProp(c, c.platform, 'appName') || '';
+ const pkg = getConfigProp('package') || '';
+ const id = getConfigProp('id') || '';
+ const appName = getConfigProp('appName') || '';
const injects: OverridesOptions =
platform === 'tizen'
@@ -124,23 +127,23 @@ const _configureProject = (c: RnvContext) =>
{ pattern: '{{APP_NAME}}', override: appName },
{
pattern: '{{APP_VERSION}}',
- override: semver.coerce(getAppVersion(c, platform))?.format(),
+ override: semver.coerce(getAppVersion())?.format(),
},
]
: [
- { pattern: '{{APPLICATION_ID}}', override: getAppId(c, platform)?.toLowerCase() },
- { pattern: '{{APP_TITLE}}', override: getAppTitle(c, platform) },
- { pattern: '{{APP_VERSION}}', override: semver.coerce(getAppVersion(c, platform))?.format() },
- { pattern: '{{APP_DESCRIPTION}}', override: getAppDescription(c, platform) },
- { pattern: '{{APP_BG_COLOR}}', override: getConfigProp(c, platform, 'backgroundColor', '#fff') },
- { pattern: '{{APP_ICON_COLOR}}', override: getConfigProp(c, platform, 'iconColor', '#000') },
- { pattern: '{{APP_VENDOR}}', override: getConfigProp(c, platform, 'author') || DEFAULTS.author },
+ { pattern: '{{APPLICATION_ID}}', override: getAppId()?.toLowerCase() },
+ { pattern: '{{APP_TITLE}}', override: getAppTitle() },
+ { pattern: '{{APP_VERSION}}', override: semver.coerce(getAppVersion())?.format() },
+ { pattern: '{{APP_DESCRIPTION}}', override: getAppDescription() },
+ { pattern: '{{APP_BG_COLOR}}', override: getConfigProp('backgroundColor', '#fff') },
+ { pattern: '{{APP_ICON_COLOR}}', override: getConfigProp('iconColor', '#000') },
+ { pattern: '{{APP_VENDOR}}', override: getConfigProp('author') || DEFAULTS.author },
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
const configFile = platform === 'tizen' ? 'config.xml' : 'appinfo.json';
- const file = path.join(getPlatformProjectDir(c)!, configFile);
+ const file = path.join(getPlatformProjectDir()!, configFile);
writeCleanFile(file, file, injects, undefined, c);
resolve();
diff --git a/packages/engine-lightning/src/tasks/taskBuild.ts b/packages/engine-lightning/src/tasks/taskBuild.ts
index 045d0e5f0d..4b66486cc0 100644
--- a/packages/engine-lightning/src/tasks/taskBuild.ts
+++ b/packages/engine-lightning/src/tasks/taskBuild.ts
@@ -15,17 +15,17 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
const { platform } = c;
c.runtime.forceBundleAssets = true;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'tizen':
case 'webos':
- await buildLightningProject(c);
+ await buildLightningProject();
return;
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-lightning/src/tasks/taskConfigure.ts b/packages/engine-lightning/src/tasks/taskConfigure.ts
index 11c1ad687f..21e11193fd 100644
--- a/packages/engine-lightning/src/tasks/taskConfigure.ts
+++ b/packages/engine-lightning/src/tasks/taskConfigure.ts
@@ -12,7 +12,7 @@ import { configureLightningProject } from '../sdks/sdk-lightning';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
if (c.program.only && !!parentTask) {
return true;
@@ -21,9 +21,9 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
switch (c.platform) {
case 'tizen':
case 'webos':
- return configureLightningProject(c);
+ return configureLightningProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-lightning/src/tasks/taskRun.ts b/packages/engine-lightning/src/tasks/taskRun.ts
index 4d72e9e842..f0162a0b11 100644
--- a/packages/engine-lightning/src/tasks/taskRun.ts
+++ b/packages/engine-lightning/src/tasks/taskRun.ts
@@ -17,14 +17,14 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} target:${target} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
switch (platform) {
case 'tizen':
case 'webos':
- return runLightningProject(c);
+ return runLightningProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-electron/src/sdk.ts b/packages/engine-rn-electron/src/sdk.ts
index a61513ecb9..75834d241c 100644
--- a/packages/engine-rn-electron/src/sdk.ts
+++ b/packages/engine-rn-electron/src/sdk.ts
@@ -27,6 +27,7 @@ import {
ExecOptionsPresets,
getAppFolder,
RnvTaskName,
+ getContext,
} from '@rnv/core';
import { FileElectronPackage } from './types';
import { NpmPackageFile } from '@rnv/core/lib/configs/types';
@@ -43,56 +44,56 @@ import {
addSystemInjects,
} from '@rnv/sdk-utils';
-export const configureElectronProject = async (c: RnvContext, exitOnFail?: boolean) => {
+export const configureElectronProject = async (exitOnFail?: boolean) => {
+ const c = getContext();
logDefault('configureElectronProject');
const { platform } = c;
- c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir(c)}`;
+ c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir()}`;
c.runtime.webpackTarget = 'electron-main';
// If path does not exist for png, try iconset
const iconsetPath = path.join(c.paths.appConfig.dir, `assets/${platform}/resources/AppIcon.iconset`);
await copyAssetsFolder(
- c,
- platform,
undefined,
(platform === 'macos' || platform === 'linux') && fsExistsSync(iconsetPath) ? _generateICNS : undefined
);
await configureCoreWebProject();
- await configureProject(c, exitOnFail);
- return copyBuildsFolder(c, platform);
+ await configureProject(exitOnFail);
+ return copyBuildsFolder();
};
const merge = require('deepmerge');
-const configureProject = (c: RnvContext, exitOnFail?: boolean) =>
+const configureProject = (exitOnFail?: boolean) =>
new Promise((resolve, reject) => {
+ const c = getContext();
logDefault('configureProject');
const { platform } = c;
- if (!isPlatformActive(c, platform, resolve)) return;
+ if (!isPlatformActive(resolve)) return;
- const platformProjectDir = getPlatformProjectDir(c)!;
- const engine = getEngineRunnerByPlatform(c, c.platform);
+ const platformProjectDir = getPlatformProjectDir()!;
+ const engine = getEngineRunnerByPlatform(c.platform);
if (!engine || !platform) return;
- const platformBuildDir = getAppFolder(c)!;
- const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
+ const platformBuildDir = getAppFolder()!;
+ const bundleAssets = getConfigProp('bundleAssets') === true;
const electronConfigPath = path.join(platformBuildDir, 'electronConfig.json');
const packagePath = path.join(platformBuildDir, 'package.json');
// If path does not exist for png, try iconset
const pngIconPath = path.join(c.paths.appConfig.dir, `assets/${platform}/resources/icon.png`);
- const appId = getAppId(c, platform);
+ const appId = getAppId();
if (!fsExistsSync(packagePath)) {
if (exitOnFail) {
logWarning(`Your ${chalk().bold(platform)} platformBuild is misconfigured!. let's repair it.`);
- createPlatformBuild(c, platform)
- .then(() => configureElectronProject(c, true))
+ createPlatformBuild(platform)
+ .then(() => configureElectronProject(true))
.then(() => resolve())
.catch((e) => reject(e));
return;
@@ -104,11 +105,11 @@ const configureProject = (c: RnvContext, exitOnFail?: boolean) =>
const packageJson = readObjectSync(pkgJson) || {};
packageJson.name = `${c.runtime.appId}-${platform}`;
- packageJson.productName = `${getAppTitle(c, platform)}`;
- packageJson.version = `${getAppVersion(c, platform)}`;
- packageJson.description = `${getAppDescription(c, platform)}`;
- packageJson.author = getAppAuthor(c, platform);
- packageJson.license = `${getAppLicense(c, platform)}`;
+ packageJson.productName = `${getAppTitle()}`;
+ packageJson.version = `${getAppVersion()}`;
+ packageJson.description = `${getAppDescription()}`;
+ packageJson.author = getAppAuthor();
+ packageJson.license = `${getAppLicense()}`;
packageJson.main = './main.js';
// check if project includes @electron/remote
@@ -134,12 +135,12 @@ const configureProject = (c: RnvContext, exitOnFail?: boolean) =>
? path.join(platformProjectDir, 'resources', 'icon.icns')
: path.join(platformProjectDir, 'resources', 'icon.png'),
};
- const browserWindowExt = getConfigProp(c, platform, 'BrowserWindow');
+ const browserWindowExt = getConfigProp('BrowserWindow');
if (browserWindowExt) {
browserWindow = merge(browserWindow, browserWindowExt);
}
const browserWindowStr = JSON.stringify(browserWindow, null, 2);
- const electronConfigExt = getConfigProp(c, platform, 'electronConfig');
+ const electronConfigExt = getConfigProp('electronConfig');
const mainInjection = electronConfigExt?.mainInjection || '';
const mainHeadInjection = electronConfigExt?.mainHeadInjection || '';
@@ -163,7 +164,7 @@ const configureProject = (c: RnvContext, exitOnFail?: boolean) =>
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(
path.join(platformProjectDir, 'main.prod.js'),
@@ -196,7 +197,7 @@ const configureProject = (c: RnvContext, exitOnFail?: boolean) =>
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(
path.join(platformProjectDir, 'main.dev.js'),
@@ -253,13 +254,14 @@ const configureProject = (c: RnvContext, exitOnFail?: boolean) =>
resolve();
});
-const buildElectron = async (c: RnvContext) => {
+const buildElectron = async () => {
+ const c = getContext();
logDefault('buildElectron');
- await buildCoreWebpackProject(c);
+ await buildCoreWebpackProject();
// Webpack 5 deletes build folder but does not copy package json
- const platformBuildDir = getAppFolder(c)!;
+ const platformBuildDir = getAppFolder()!;
// workaround: electron-builder fails export in npx mode due to trying install node_modules. we trick it not to do that
mkdirSync(path.join(platformBuildDir, 'build', 'node_modules'));
@@ -283,10 +285,11 @@ const buildElectron = async (c: RnvContext) => {
return true;
};
-const exportElectron = async (c: RnvContext) => {
+const exportElectron = async () => {
+ const c = getContext();
logDefault('exportElectron');
- const platformBuildDir = getAppFolder(c)!;
+ const platformBuildDir = getAppFolder()!;
const buildPath = path.join(platformBuildDir, 'build', 'release');
if (fsExistsSync(buildPath)) {
@@ -306,46 +309,46 @@ const exportElectron = async (c: RnvContext) => {
electronBuilderPath = 'npx electron-builder';
}
await executeAsync(
- c,
`${electronBuilderPath} --config ${path.join(platformBuildDir, 'electronConfig.json')} --${c.platform}`
);
logSuccess(`Your Exported App is located in ${chalk().cyan(path.join(platformBuildDir, 'export'))} .`);
};
-export const runElectron = async (c: RnvContext) => {
+export const runElectron = async () => {
+ const c = getContext();
logDefault('runElectron');
const { platform } = c;
const { port } = c.runtime;
- // const bundleIsDev = getConfigProp(c, platform, 'bundleIsDev') === true;
- const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
+ // const bundleIsDev = getConfigProp('bundleIsDev') === true;
+ const bundleAssets = getConfigProp('bundleAssets') === true;
if (bundleAssets) {
- await buildElectron(c);
+ await buildElectron();
await _runElectronSimulator(c);
} else {
- const isPortActive = await checkPortInUse(c, platform, port);
+ const isPortActive = await checkPortInUse(port);
if (!isPortActive) {
logInfo(
`Your ${chalk().bold(platform)} devServer at port ${chalk().bold(
port
)} is not running. Starting it up for you...`
);
- waitForHost(c, '')
+ waitForHost('')
.then(() => _runElectronSimulator(c))
.catch(logError);
// await _runElectronSimulator(c);
- await runWebpackServer(c);
+ await runWebpackServer();
} else {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
if (resetCompleted) {
- waitForHost(c, '')
+ waitForHost('')
.then(() => _runElectronSimulator(c))
.catch(logError);
// await _runElectronSimulator(c);
- await runWebpackServer(c);
+ await runWebpackServer();
} else {
await _runElectronSimulator(c);
}
@@ -355,17 +358,17 @@ export const runElectron = async (c: RnvContext) => {
const _runElectronSimulator = async (c: RnvContext) => {
logDefault(`_runElectronSimulator:${c.platform}`);
- // const appFolder = getAppFolder(c, c.platform);
+ // const appFolder = getAppFolder(c.platform);
// const elc = `${doResolve('electron')}/cli.js`;
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets') === true;
- let platformProjectDir = getPlatformProjectDir(c)!;
+ const bundleAssets = getConfigProp('bundleAssets') === true;
+ let platformProjectDir = getPlatformProjectDir()!;
if (bundleAssets) {
- platformProjectDir = path.join(getAppFolder(c)!, 'build');
+ platformProjectDir = path.join(getAppFolder()!, 'build');
}
const cmd = `node ${doResolve('electron')}/cli.js ${path.join(platformProjectDir, '/main.js')}`;
- await executeAsync(c, cmd, ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER);
+ await executeAsync(cmd, ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER);
};
const _generateICNS = (c: RnvContext) =>
@@ -386,7 +389,7 @@ const _generateICNS = (c: RnvContext) =>
source = path.join(c.paths.appConfig.dir, `assets/${platform}/AppIcon.iconset`);
}
- const dest = path.join(getPlatformProjectDir(c)!, 'resources/icon.icns');
+ const dest = path.join(getPlatformProjectDir()!, 'resources/icon.icns');
// It's ok if icns are not generated as png is also valid https://www.electron.build/icons.html#macos
if (!source) {
@@ -405,11 +408,11 @@ const _generateICNS = (c: RnvContext) =>
return;
}
- mkdirSync(path.join(getPlatformProjectDir(c)!, 'resources'));
+ mkdirSync(path.join(getPlatformProjectDir()!, 'resources'));
const p = ['--convert', 'icns', source, '--output', dest];
try {
- executeAsync(c, `iconutil ${p.join(' ')}`);
+ executeAsync(`iconutil ${p.join(' ')}`);
resolve();
} catch (e) {
reject(e);
diff --git a/packages/engine-rn-electron/src/tasks/taskBuild.ts b/packages/engine-rn-electron/src/tasks/taskBuild.ts
index 7af89aa441..271483148c 100644
--- a/packages/engine-rn-electron/src/tasks/taskBuild.ts
+++ b/packages/engine-rn-electron/src/tasks/taskBuild.ts
@@ -14,18 +14,18 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskBuild', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'macos':
case 'windows':
case 'linux':
- await buildElectron(c);
+ await buildElectron();
return;
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-electron/src/tasks/taskConfigure.ts b/packages/engine-rn-electron/src/tasks/taskConfigure.ts
index 577b9ddeac..5fadfdea33 100644
--- a/packages/engine-rn-electron/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn-electron/src/tasks/taskConfigure.ts
@@ -15,13 +15,13 @@ import { configureElectronProject } from '../sdk';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
- await configureEntryPoint(c, c.platform);
+ await configureEntryPoint(c.platform);
- await copySharedPlatforms(c);
+ await copySharedPlatforms();
if (c.program.only && !!parentTask) {
return true;
@@ -31,9 +31,9 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
case 'macos':
case 'windows':
case 'linux':
- return configureElectronProject(c);
+ return configureElectronProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-electron/src/tasks/taskExport.ts b/packages/engine-rn-electron/src/tasks/taskExport.ts
index 7d49049d0e..9b49a9cff3 100644
--- a/packages/engine-rn-electron/src/tasks/taskExport.ts
+++ b/packages/engine-rn-electron/src/tasks/taskExport.ts
@@ -14,17 +14,17 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskExport', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.build, RnvTaskName.export, originTask);
+ await executeOrSkipTask(RnvTaskName.build, RnvTaskName.export, originTask);
- if (shouldSkipTask(c, RnvTaskName.export, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.export, originTask)) return true;
switch (platform) {
case 'macos':
case 'windows':
case 'linux':
- return exportElectron(c);
+ return exportElectron();
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-electron/src/tasks/taskRun.ts b/packages/engine-rn-electron/src/tasks/taskRun.ts
index fb161c6469..9dedcbf054 100644
--- a/packages/engine-rn-electron/src/tasks/taskRun.ts
+++ b/packages/engine-rn-electron/src/tasks/taskRun.ts
@@ -17,17 +17,17 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} target:${target} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
switch (platform) {
case 'macos':
case 'windows':
case 'linux':
- return runElectron(c);
+ return runElectron();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-electron/src/tasks/taskStart.ts b/packages/engine-rn-electron/src/tasks/taskStart.ts
index b1e07f9fc4..cd61ec490d 100644
--- a/packages/engine-rn-electron/src/tasks/taskStart.ts
+++ b/packages/engine-rn-electron/src/tasks/taskStart.ts
@@ -20,24 +20,24 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskStart', `parent:${parentTask} port:${c.runtime.port} hosted:${!!hosted}`);
if (hosted) {
- waitForHost(c, '')
+ waitForHost('')
.then(() => openBrowser(`http://${c.runtime.localhost}:${port}/`))
.catch(logError);
}
if (!parentTask) {
- await executeTask(c, RnvTaskName.configure, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configure, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
switch (platform) {
case 'macos':
case 'windows':
case 'linux':
- return runWebpackServer(c);
+ return runWebpackServer();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-macos/src/tasks/taskBuild.ts b/packages/engine-rn-macos/src/tasks/taskBuild.ts
index 61ce0fd4eb..b4ee9e9bce 100644
--- a/packages/engine-rn-macos/src/tasks/taskBuild.ts
+++ b/packages/engine-rn-macos/src/tasks/taskBuild.ts
@@ -14,9 +14,9 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskBuild');
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.package, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.package, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'macos':
@@ -24,9 +24,9 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
// build task is not necessary when exporting macos
return true;
}
- return buildXcodeProject(c);
+ return buildXcodeProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-macos/src/tasks/taskConfigure.ts b/packages/engine-rn-macos/src/tasks/taskConfigure.ts
index 73e721339c..bbf64953f6 100644
--- a/packages/engine-rn-macos/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn-macos/src/tasks/taskConfigure.ts
@@ -14,10 +14,10 @@ import { configureXcodeProject } from '@rnv/sdk-apple';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
- await configureEntryPoint(c, c.platform);
+ await configureEntryPoint(c.platform);
if (c.program.only && !!parentTask) {
return true;
@@ -25,10 +25,10 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
switch (c.platform) {
case 'macos':
- await configureXcodeProject(c);
+ await configureXcodeProject();
return true;
default:
- await logErrorPlatform(c);
+ await logErrorPlatform();
return true;
}
};
diff --git a/packages/engine-rn-macos/src/tasks/taskExport.ts b/packages/engine-rn-macos/src/tasks/taskExport.ts
index e220cbcf99..39cf506e2f 100644
--- a/packages/engine-rn-macos/src/tasks/taskExport.ts
+++ b/packages/engine-rn-macos/src/tasks/taskExport.ts
@@ -14,15 +14,15 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskExport', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.build, RnvTaskName.export, originTask);
+ await executeOrSkipTask(RnvTaskName.build, RnvTaskName.export, originTask);
- if (shouldSkipTask(c, RnvTaskName.export, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.export, originTask)) return true;
switch (platform) {
case 'macos':
- return exportXcodeProject(c);
+ return exportXcodeProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-macos/src/tasks/taskPackage.ts b/packages/engine-rn-macos/src/tasks/taskPackage.ts
index 56238a5a6a..48e9f0c3d0 100644
--- a/packages/engine-rn-macos/src/tasks/taskPackage.ts
+++ b/packages/engine-rn-macos/src/tasks/taskPackage.ts
@@ -15,21 +15,21 @@ const taskPackage: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskPackage', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.package, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.package, originTask);
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
if (!bundleAssets) {
return true;
}
- if (shouldSkipTask(c, RnvTaskName.package, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.package, originTask)) return true;
switch (platform) {
case 'macos':
- return packageBundleForXcode(c);
+ return packageBundleForXcode();
default:
- logErrorPlatform(c);
+ logErrorPlatform();
return false;
}
};
diff --git a/packages/engine-rn-macos/src/tasks/taskRun.ts b/packages/engine-rn-macos/src/tasks/taskRun.ts
index 17beabe10f..4a28888851 100644
--- a/packages/engine-rn-macos/src/tasks/taskRun.ts
+++ b/packages/engine-rn-macos/src/tasks/taskRun.ts
@@ -21,25 +21,25 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} target:${target} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const bundleAssets = getConfigProp('bundleAssets', false);
switch (platform) {
case 'macos':
if (!c.program.only) {
- await startBundlerIfRequired(c, RnvTaskName.run, originTask);
- await runXcodeProject(c);
+ await startBundlerIfRequired(RnvTaskName.run, originTask);
+ await runXcodeProject();
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
- return waitForBundlerIfRequired(c);
+ return waitForBundlerIfRequired();
}
- return runXcodeProject(c);
+ return runXcodeProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-macos/src/tasks/taskStart.ts b/packages/engine-rn-macos/src/tasks/taskStart.ts
index 90a9d27c70..309aba751b 100644
--- a/packages/engine-rn-macos/src/tasks/taskStart.ts
+++ b/packages/engine-rn-macos/src/tasks/taskStart.ts
@@ -29,21 +29,21 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
// Disable reset for other commands (ie. cleaning platforms)
c.runtime.disableReset = true;
if (!parentTask) {
- await executeTask(c, RnvTaskName.configureSoft, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configureSoft, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
switch (platform) {
case 'macos': {
- return startReactNative(c, {
+ return startReactNative({
waitForBundler: !parentTask,
customCliPath: `${doResolve('react-native')}/local-cli/cli.js`,
metroConfigName: 'metro.config.rnm.js',
});
}
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-next/src/env.ts b/packages/engine-rn-next/src/env.ts
index fd2f3ff62b..4ed491a446 100644
--- a/packages/engine-rn-next/src/env.ts
+++ b/packages/engine-rn-next/src/env.ts
@@ -12,9 +12,7 @@ export const EnvVars = {
return _checkPagesDir();
},
NODE_ENV: () => {
- const c = getContext();
- const env = getConfigProp(c, c.platform, 'environment');
-
+ const env = getConfigProp('environment');
return {
NODE_ENV: env || 'development',
};
@@ -23,34 +21,29 @@ export const EnvVars = {
const getTranspileModules = () => {
const c = getContext();
- const transModules = getConfigProp(c, c.platform, 'nextTranspileModules') || [];
+ const transModules = getConfigProp('nextTranspileModules') || [];
- parsePlugins(
- c,
- c.platform,
- (plugin, pluginPlat, key) => {
- const { webpackConfig } = plugin;
- if (webpackConfig) {
- transModules.push(key);
- if (webpackConfig.nextTranspileModules?.length) {
- webpackConfig.nextTranspileModules.forEach((module) => {
- if (module.startsWith('.')) {
- transModules.push(path.join(c.paths.project.dir, module));
- } else {
- transModules.push(module);
- }
- });
- }
+ parsePlugins((plugin, pluginPlat, key) => {
+ const { webpackConfig } = plugin;
+ if (webpackConfig) {
+ transModules.push(key);
+ if (webpackConfig.nextTranspileModules?.length) {
+ webpackConfig.nextTranspileModules.forEach((module) => {
+ if (module.startsWith('.')) {
+ transModules.push(path.join(c.paths.project.dir, module));
+ } else {
+ transModules.push(module);
+ }
+ });
}
- },
- true
- );
+ }
+ }, true);
return transModules;
};
const _checkPagesDir = () => {
const c = getContext();
- const pagesDir = getConfigProp(c, c.platform, 'pagesDir');
+ const pagesDir = getConfigProp('pagesDir');
const distDir = getExportDir(c);
const isExport = c._currentTask === 'export';
diff --git a/packages/engine-rn-next/src/sdk.ts b/packages/engine-rn-next/src/sdk.ts
index 2c51e0a388..cc847685e9 100644
--- a/packages/engine-rn-next/src/sdk.ts
+++ b/packages/engine-rn-next/src/sdk.ts
@@ -12,22 +12,23 @@ import {
logSummary,
logSuccess,
copyAssetsFolder,
- RnvPlatform,
CoreEnvVars,
ExecOptionsPresets,
getAppFolder,
+ getContext,
} from '@rnv/core';
import { checkPortInUse, confirmActiveBundler, getDevServerHost, openBrowser, waitForHost } from '@rnv/sdk-utils';
import { EnvVars } from './env';
-export const configureNextIfRequired = async (c: RnvContext) => {
+export const configureNextIfRequired = async () => {
+ const c = getContext();
logDefault('configureNextIfRequired');
if (!c.platform) return;
- c.runtime.platformBuildsProjectPath = `${getAppFolder(c)}`;
+ c.runtime.platformBuildsProjectPath = `${getAppFolder()}`;
- await copyAssetsFolder(c, c.platform);
+ await copyAssetsFolder();
const destPath = path.join(c.paths.project.dir, 'public');
@@ -42,17 +43,18 @@ export const configureNextIfRequired = async (c: RnvContext) => {
}
};
-export const runWebNext = async (c: RnvContext) => {
+export const runWebNext = async () => {
+ const c = getContext();
const { port } = c.runtime;
logDefault('runWebNext', `port:${port}`);
const { platform } = c;
if (!c.platform) return;
- const devServerHost = getDevServerHost(c);
+ const devServerHost = getDevServerHost();
- const isPortActive = await checkPortInUse(c, platform, port);
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const isPortActive = await checkPortInUse(port);
+ const bundleAssets = getConfigProp('bundleAssets', false);
if (!isPortActive) {
logInfo(
@@ -60,38 +62,33 @@ export const runWebNext = async (c: RnvContext) => {
port
)} is not running. Starting it up for you...`
);
- await _runWebBrowser(c, platform, devServerHost, port, false);
+ await _runWebBrowser(devServerHost, port, false);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
await runWebDevServer(c);
} else {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
if (resetCompleted) {
- await _runWebBrowser(c, platform, devServerHost, port, false);
+ await _runWebBrowser(devServerHost, port, false);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
await runWebDevServer(c);
} else {
- await _runWebBrowser(c, platform, devServerHost, port, true);
+ await _runWebBrowser(devServerHost, port, true);
}
}
};
-const _runWebBrowser = (
- c: RnvContext,
- _platform: RnvPlatform,
- devServerHost: string,
- port: number,
- alreadyStarted: boolean
-) =>
+const _runWebBrowser = (devServerHost: string, port: number, alreadyStarted: boolean) =>
new Promise((resolve) => {
+ const c = getContext();
logDefault('_runWebBrowser', `ip:${devServerHost} port:${port} openBrowser:${!!c.runtime.shouldOpenBrowser}`);
if (!c.runtime.shouldOpenBrowser) return resolve();
- const wait = waitForHost(c, '')
+ const wait = waitForHost('')
.then(() => {
openBrowser(`http://${devServerHost}:${port}/`);
})
@@ -103,8 +100,8 @@ const _runWebBrowser = (
});
export const getExportDir = (c: RnvContext) => {
- const exportDir = getConfigProp(c, c.platform, 'exportDir');
- const maybeAbsolutePath = exportDir || path.join(getAppFolder(c)!, 'output');
+ const exportDir = getConfigProp('exportDir');
+ const maybeAbsolutePath = exportDir || path.join(getAppFolder()!, 'output');
// if path is absolute, make it relative to project root. Next 14 doesn't seem to like absolute paths
if (path.isAbsolute(maybeAbsolutePath)) {
@@ -113,10 +110,11 @@ export const getExportDir = (c: RnvContext) => {
return maybeAbsolutePath;
};
-export const buildWebNext = async (c: RnvContext) => {
+export const buildWebNext = async () => {
+ const c = getContext();
logDefault('buildWebNext');
- await executeAsync(c, 'npx next build', {
+ await executeAsync('npx next build', {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
@@ -131,18 +129,18 @@ export const buildWebNext = async (c: RnvContext) => {
export const runWebDevServer = async (c: RnvContext) => {
logDefault('runWebDevServer');
- const devServerHost = getDevServerHost(c);
+ const devServerHost = getDevServerHost();
const url = chalk().cyan(`http://${devServerHost}:${c.runtime.port}`);
logRaw(`
Dev server running at: ${url}
`);
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const bundleAssets = getConfigProp('bundleAssets', false);
const opts = !c.program?.json
? ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER
: ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY;
- return executeAsync(c, `npx next ${bundleAssets ? 'start' : 'dev'} --port ${c.runtime.port}`, {
+ return executeAsync(`npx next ${bundleAssets ? 'start' : 'dev'} --port ${c.runtime.port}`, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
@@ -154,12 +152,13 @@ Dev server running at: ${url}
});
};
-export const exportWebNext = async (c: RnvContext) => {
+export const exportWebNext = async () => {
+ const c = getContext();
logDefault('exportWebNext');
const exportDir = getExportDir(c);
- await executeAsync(c, `npx next build`, {
+ await executeAsync(`npx next build`, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
diff --git a/packages/engine-rn-next/src/tasks/taskBuild.ts b/packages/engine-rn-next/src/tasks/taskBuild.ts
index ddb2131bc1..d59544630a 100644
--- a/packages/engine-rn-next/src/tasks/taskBuild.ts
+++ b/packages/engine-rn-next/src/tasks/taskBuild.ts
@@ -14,9 +14,9 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskBuild', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'web':
@@ -25,10 +25,10 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
// build task is not necessary when exporting. They do the same thing, only difference is a next.config.js config flag
return true;
}
- await buildWebNext(c);
+ await buildWebNext();
return;
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-next/src/tasks/taskConfigure.ts b/packages/engine-rn-next/src/tasks/taskConfigure.ts
index df944812b5..8bbf32fc51 100644
--- a/packages/engine-rn-next/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn-next/src/tasks/taskConfigure.ts
@@ -13,9 +13,9 @@ import { configureNextIfRequired } from '../sdk';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
if (c.program.only && !!parentTask) {
return true;
@@ -24,9 +24,9 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
switch (c.platform) {
case 'web':
case 'chromecast':
- return configureNextIfRequired(c);
+ return configureNextIfRequired();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-next/src/tasks/taskExport.ts b/packages/engine-rn-next/src/tasks/taskExport.ts
index e682baa29c..89c1977d70 100644
--- a/packages/engine-rn-next/src/tasks/taskExport.ts
+++ b/packages/engine-rn-next/src/tasks/taskExport.ts
@@ -14,16 +14,16 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskExport', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.build, RnvTaskName.export, originTask);
+ await executeOrSkipTask(RnvTaskName.build, RnvTaskName.export, originTask);
- if (shouldSkipTask(c, RnvTaskName.export, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.export, originTask)) return true;
switch (platform) {
case 'web':
case 'chromecast':
- return exportWebNext(c);
+ return exportWebNext();
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-next/src/tasks/taskRun.ts b/packages/engine-rn-next/src/tasks/taskRun.ts
index 605ed9b9b6..48862ffd5f 100644
--- a/packages/engine-rn-next/src/tasks/taskRun.ts
+++ b/packages/engine-rn-next/src/tasks/taskRun.ts
@@ -14,17 +14,17 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { platform } = c;
logTask('taskRun', `parent:${parentTask}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
switch (platform) {
case 'web':
case 'chromecast':
c.runtime.shouldOpenBrowser = true;
- return runWebNext(c);
+ return runWebNext();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-next/src/tasks/taskStart.ts b/packages/engine-rn-next/src/tasks/taskStart.ts
index e22823e02d..a04d81fdd6 100644
--- a/packages/engine-rn-next/src/tasks/taskStart.ts
+++ b/packages/engine-rn-next/src/tasks/taskStart.ts
@@ -20,16 +20,16 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskStart', `parent:${parentTask} port:${c.runtime.port} hosted:${!!hosted}`);
if (hosted) {
- waitForHost(c)
+ waitForHost()
.then(() => openBrowser(`http://${c.runtime.localhost}:${port}/`))
.catch(logError);
}
if (!parentTask) {
- await executeTask(c, RnvTaskName.configure, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configure, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
if (hosted) {
return logError('This platform does not support hosted mode', true);
@@ -38,9 +38,9 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
case 'web':
case 'chromecast':
c.runtime.shouldOpenBrowser = false;
- return runWebNext(c);
+ return runWebNext();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/__tests__/run.test.ts b/packages/engine-rn-tvos/src/tasks/__tests__/run.test.ts
index 1f5d822510..ce0e25f2af 100644
--- a/packages/engine-rn-tvos/src/tasks/__tests__/run.test.ts
+++ b/packages/engine-rn-tvos/src/tasks/__tests__/run.test.ts
@@ -23,5 +23,5 @@ test('Execute task.rnv.run', async () => {
// WHEN
await taskRun.fn?.(ctx, undefined, undefined);
// THEN
- expect(runXcodeProject).toHaveBeenCalledWith(ctx, 'MOCK_DEVICE_ARGS');
+ expect(runXcodeProject).toHaveBeenCalledWith('MOCK_DEVICE_ARGS');
});
diff --git a/packages/engine-rn-tvos/src/tasks/__tests__/start.test.ts b/packages/engine-rn-tvos/src/tasks/__tests__/start.test.ts
index 763869de92..20513fbd7f 100644
--- a/packages/engine-rn-tvos/src/tasks/__tests__/start.test.ts
+++ b/packages/engine-rn-tvos/src/tasks/__tests__/start.test.ts
@@ -22,7 +22,7 @@ test('Execute task.rnv.start with no parent', async () => {
await taskStart.fn?.(ctx, undefined, undefined);
// THEN
expect(executeTask).toHaveBeenCalledTimes(1);
- expect(startReactNative).toHaveBeenCalledWith(ctx, {
+ expect(startReactNative).toHaveBeenCalledWith({
waitForBundler: true,
customCliPath: 'MOCKED_PATH/local-cli/cli.js',
metroConfigName: 'metro.config.js',
@@ -37,7 +37,7 @@ test('Execute task.rnv.start', async () => {
// WHEN
await taskStart.fn?.(ctx, 'parent', undefined);
// THEN
- expect(startReactNative).toHaveBeenCalledWith(ctx, {
+ expect(startReactNative).toHaveBeenCalledWith({
waitForBundler: false,
customCliPath: 'MOCKED_PATH/local-cli/cli.js',
metroConfigName: 'metro.config.js',
diff --git a/packages/engine-rn-tvos/src/tasks/taskBuild.ts b/packages/engine-rn-tvos/src/tasks/taskBuild.ts
index b1d2bd112e..d3afed5e5e 100644
--- a/packages/engine-rn-tvos/src/tasks/taskBuild.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskBuild.ts
@@ -15,22 +15,22 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskBuild');
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.package, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.package, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'androidtv':
case 'firetv':
- return buildReactNativeAndroid(c);
+ return buildReactNativeAndroid();
case 'tvos':
if (parentTask === RnvTaskName.export) {
// build task is not necessary when exporting ios
return true;
}
- return buildXcodeProject(c);
+ return buildXcodeProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/taskConfigure.ts b/packages/engine-rn-tvos/src/tasks/taskConfigure.ts
index 05495a1dbc..43a255daf1 100644
--- a/packages/engine-rn-tvos/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskConfigure.ts
@@ -16,10 +16,10 @@ import { configureXcodeProject } from '@rnv/sdk-apple';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
- await configureEntryPoint(c, c.platform);
+ await configureEntryPoint(c.platform);
if (c.program.only && !!parentTask) {
return true;
@@ -28,14 +28,14 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
switch (c.platform) {
case 'androidtv':
case 'firetv':
- await configureGradleProject(c);
- await jetifyIfRequired(c);
+ await configureGradleProject();
+ await jetifyIfRequired();
return true;
case 'tvos':
- await configureXcodeProject(c);
+ await configureXcodeProject();
return true;
default:
- await logErrorPlatform(c);
+ await logErrorPlatform();
return true;
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/taskCryptoInstallCerts.ts b/packages/engine-rn-tvos/src/tasks/taskCryptoInstallCerts.ts
index bd55e8a1d7..bfb9a51ec3 100644
--- a/packages/engine-rn-tvos/src/tasks/taskCryptoInstallCerts.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskCryptoInstallCerts.ts
@@ -15,9 +15,9 @@ import {
const taskCryptoInstallCerts: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoInstallCerts');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallCerts, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallCerts, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoInstallCerts, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoInstallCerts, originTask)) return true;
if (c.platform !== 'tvos') {
logError(`_installTempCerts: platform ${c.platform} not supported`);
@@ -29,7 +29,7 @@ const taskCryptoInstallCerts: RnvTaskFn = async (c, _parentTask, originTask) =>
const cerArr = list.filter((v) => v.endsWith('.cer'));
try {
- Promise.all(cerArr.map((v) => executeAsync(c, `security import ${v} -k ${kChain} -A`)));
+ Promise.all(cerArr.map((v) => executeAsync(`security import ${v} -k ${kChain} -A`)));
} catch (e) {
logWarning(e);
return true;
diff --git a/packages/engine-rn-tvos/src/tasks/taskCryptoInstallProfiles.ts b/packages/engine-rn-tvos/src/tasks/taskCryptoInstallProfiles.ts
index 04eb0152f6..43311186c7 100644
--- a/packages/engine-rn-tvos/src/tasks/taskCryptoInstallProfiles.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskCryptoInstallProfiles.ts
@@ -19,9 +19,9 @@ import {
const taskCryptoInstallProfiles: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoInstallProfiles');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallProfiles, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallProfiles, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoInstallProfiles, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoInstallProfiles, originTask)) return true;
if (c.platform !== 'tvos') {
logError(`taskCryptoInstallProfiles: platform ${c.platform} not supported`);
diff --git a/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfile.ts b/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfile.ts
index cd1c849b2a..58afdc544a 100644
--- a/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfile.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfile.ts
@@ -1,14 +1,14 @@
import { RnvTaskFn, executeTask, shouldSkipTask, logTask, RnvTaskOptionPresets, RnvTask, RnvTaskName } from '@rnv/core';
import { updateProfile } from '@rnv/sdk-apple';
-const taskCryptoUpdateProfile: RnvTaskFn = async (c, _parentTask, originTask) => {
+const taskCryptoUpdateProfile: RnvTaskFn = async (_c, _parentTask, originTask) => {
logTask('taskCryptoUpdateProfile');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfile, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfile, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoUpdateProfile, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoUpdateProfile, originTask)) return true;
- await updateProfile(c);
+ await updateProfile();
};
const Task: RnvTask = {
diff --git a/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfiles.ts b/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfiles.ts
index f6901540cc..d0186ff767 100644
--- a/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfiles.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskCryptoUpdateProfiles.ts
@@ -1,6 +1,5 @@
import {
RnvTaskFn,
- RnvContext,
listAppConfigsFoldersSync,
chalk,
logTask,
@@ -12,31 +11,31 @@ import {
} from '@rnv/core';
import { updateProfile } from '@rnv/sdk-apple';
-const _updateProfile = (c: RnvContext, v: string) =>
+const _updateProfile = (v: string) =>
new Promise((resolve, reject) => {
logTask(`_updateProfile:${v}`, chalk().grey);
- updateProfile(c)
+ updateProfile()
.then(() => resolve())
.catch((e) => reject(e));
});
-const _updateProfiles = (c: RnvContext) => {
+const _updateProfiles = () => {
logTask('_updateProfiles', chalk().grey);
- const acList = listAppConfigsFoldersSync(c, true);
+ const acList = listAppConfigsFoldersSync(true);
- return acList.reduce((previousPromise, v) => previousPromise.then(() => _updateProfile(c, v)), Promise.resolve());
+ return acList.reduce((previousPromise, v) => previousPromise.then(() => _updateProfile(v)), Promise.resolve());
};
const taskCryptoUpdateProfiles: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoUpdateProfiles');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfiles, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfiles, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoUpdateProfiles, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoUpdateProfiles, originTask)) return true;
switch (c.platform) {
case 'tvos':
- await _updateProfiles(c);
+ await _updateProfiles();
break;
default:
return true;
diff --git a/packages/engine-rn-tvos/src/tasks/taskExport.ts b/packages/engine-rn-tvos/src/tasks/taskExport.ts
index c69fbda3ea..4a75c170b1 100644
--- a/packages/engine-rn-tvos/src/tasks/taskExport.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskExport.ts
@@ -14,9 +14,9 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskExport', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.build, RnvTaskName.export, originTask);
+ await executeOrSkipTask(RnvTaskName.build, RnvTaskName.export, originTask);
- if (shouldSkipTask(c, RnvTaskName.export, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.export, originTask)) return true;
switch (platform) {
case 'androidtv':
@@ -24,9 +24,9 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
// Android Platforms don't need extra export step
return true;
case 'tvos':
- return exportXcodeProject(c);
+ return exportXcodeProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/taskLog.ts b/packages/engine-rn-tvos/src/tasks/taskLog.ts
index 668e9dbe1a..03f984a782 100644
--- a/packages/engine-rn-tvos/src/tasks/taskLog.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskLog.ts
@@ -14,17 +14,17 @@ import { runAndroidLog, checkAndConfigureAndroidSdks } from '@rnv/sdk-android';
const taskLog: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskLog', `parent:${parentTask}`);
- await executeTask(c, RnvTaskName.workspaceConfigure, RnvTaskName.projectConfigure, originTask);
+ await executeTask(RnvTaskName.workspaceConfigure, RnvTaskName.projectConfigure, originTask);
switch (c.platform) {
case 'androidtv':
case 'firetv':
- await checkAndConfigureAndroidSdks(c);
- return runAndroidLog(c);
+ await checkAndConfigureAndroidSdks();
+ return runAndroidLog();
case 'tvos':
- return runAppleLog(c);
+ return runAppleLog();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/taskPackage.ts b/packages/engine-rn-tvos/src/tasks/taskPackage.ts
index 232b3d4aa0..129415b452 100644
--- a/packages/engine-rn-tvos/src/tasks/taskPackage.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskPackage.ts
@@ -16,32 +16,32 @@ const taskPackage: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskPackage', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.package, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.package, originTask);
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
if (!bundleAssets) {
return true;
}
- if (shouldSkipTask(c, RnvTaskName.package, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.package, originTask)) return true;
switch (platform) {
case 'androidtv':
case 'firetv': {
// NOTE: react-native v0.73 triggers packaging automatically so we skipping it unless we need to
// package it explicitly for tasks where it is not triggered automatically
- const signingConfig = getConfigProp(c, c.platform, 'signingConfig');
+ const signingConfig = getConfigProp('signingConfig');
if (originTask === RnvTaskName.eject || signingConfig !== 'Release') {
- return packageAndroid(c);
+ return packageAndroid();
}
return true;
}
case 'tvos':
- return packageBundleForXcode(c);
+ return packageBundleForXcode();
default:
- logErrorPlatform(c);
+ logErrorPlatform();
return false;
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/taskRun.ts b/packages/engine-rn-tvos/src/tasks/taskRun.ts
index 25343be9f7..7279f66c36 100644
--- a/packages/engine-rn-tvos/src/tasks/taskRun.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskRun.ts
@@ -22,43 +22,43 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} target:${target} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const bundleAssets = getConfigProp('bundleAssets', false);
switch (platform) {
case 'androidtv':
case 'firetv':
// eslint-disable-next-line no-case-declarations
- const runDevice = await getAndroidDeviceToRunOn(c);
+ const runDevice = await getAndroidDeviceToRunOn();
if (!c.program.only) {
- await startBundlerIfRequired(c, RnvTaskName.run, originTask);
+ await startBundlerIfRequired(RnvTaskName.run, originTask);
if (bundleAssets) {
- await packageAndroid(c);
+ await packageAndroid();
}
- await runAndroid(c, runDevice!);
+ await runAndroid(runDevice!);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
- return waitForBundlerIfRequired(c);
+ return waitForBundlerIfRequired();
}
- return runAndroid(c, runDevice!);
+ return runAndroid(runDevice!);
case 'tvos':
// eslint-disable-next-line no-case-declarations
const runDeviceArgs = await getIosDeviceToRunOn(c);
if (!c.program.only) {
- await startBundlerIfRequired(c, RnvTaskName.run, originTask);
- await runXcodeProject(c, runDeviceArgs);
+ await startBundlerIfRequired(RnvTaskName.run, originTask);
+ await runXcodeProject(runDeviceArgs);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
- return waitForBundlerIfRequired(c);
+ return waitForBundlerIfRequired();
}
- return runXcodeProject(c, runDeviceArgs);
+ return runXcodeProject(runDeviceArgs);
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-tvos/src/tasks/taskStart.ts b/packages/engine-rn-tvos/src/tasks/taskStart.ts
index 1fd3b68433..a00d47fb10 100644
--- a/packages/engine-rn-tvos/src/tasks/taskStart.ts
+++ b/packages/engine-rn-tvos/src/tasks/taskStart.ts
@@ -31,23 +31,23 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
// Disable reset for other commands (ie. cleaning platforms)
c.runtime.disableReset = true;
if (!parentTask) {
- await executeTask(c, RnvTaskName.configureSoft, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configureSoft, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
switch (platform) {
case 'androidtv':
case 'firetv':
case 'tvos': {
- return startReactNative(c, {
+ return startReactNative({
waitForBundler: !parentTask,
customCliPath: `${doResolve('react-native-tvos')}/local-cli/cli.js`,
metroConfigName: 'metro.config.js',
});
}
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-tvos/templates/platforms/androidtv/build.gradle b/packages/engine-rn-tvos/templates/platforms/androidtv/build.gradle
index cad91e38b6..34d32ff150 100644
--- a/packages/engine-rn-tvos/templates/platforms/androidtv/build.gradle
+++ b/packages/engine-rn-tvos/templates/platforms/androidtv/build.gradle
@@ -11,6 +11,17 @@ buildscript {
ndkVersion = '{{NDK_VERSION}}'
kotlinVersion = '{{INJECT_KOTLIN_VERSION}}'
}
+ subprojects { subproject ->
+ afterEvaluate{
+ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
+ android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+ }
+ }
+ }
+}
+
repositories {
google()
mavenCentral()
diff --git a/packages/engine-rn-tvos/templates/platforms/firetv/build.gradle b/packages/engine-rn-tvos/templates/platforms/firetv/build.gradle
index 3220373103..8af47d3fd4 100644
--- a/packages/engine-rn-tvos/templates/platforms/firetv/build.gradle
+++ b/packages/engine-rn-tvos/templates/platforms/firetv/build.gradle
@@ -11,6 +11,17 @@ buildscript {
ndkVersion = '{{NDK_VERSION}}'
kotlinVersion = '{{INJECT_KOTLIN_VERSION}}'
}
+ subprojects { subproject ->
+ afterEvaluate{
+ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
+ android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+ }
+ }
+ }
+}
+
repositories {
google()
mavenCentral()
diff --git a/packages/engine-rn-web/src/tasks/taskBuild.ts b/packages/engine-rn-web/src/tasks/taskBuild.ts
index 444bbf29f1..42592a0561 100644
--- a/packages/engine-rn-web/src/tasks/taskBuild.ts
+++ b/packages/engine-rn-web/src/tasks/taskBuild.ts
@@ -21,29 +21,29 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
// Build aways bundles assets
c.runtime.forceBundleAssets = true;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'web':
case 'webtv':
case 'chromecast':
- await buildWeb(c);
+ await buildWeb();
return;
case 'kaios':
- await buildKaiOSProject(c);
+ await buildKaiOSProject();
return;
case 'tizen':
case 'tizenmobile':
case 'tizenwatch':
- await buildTizenProject(c);
+ await buildTizenProject();
return;
case 'webos':
- await buildWebOSProject(c);
+ await buildWebOSProject();
return;
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-web/src/tasks/taskConfigure.ts b/packages/engine-rn-web/src/tasks/taskConfigure.ts
index e4dbe71e99..c16c9d7fa2 100644
--- a/packages/engine-rn-web/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn-web/src/tasks/taskConfigure.ts
@@ -18,11 +18,11 @@ import { configureTizenProject } from '@rnv/sdk-tizen';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
- await configureEntryPoint(c, c.platform);
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
+ await configureEntryPoint(c.platform);
- await copySharedPlatforms(c);
+ await copySharedPlatforms();
if (c.program.only && !!parentTask) {
return true;
@@ -31,19 +31,19 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
switch (c.platform) {
case 'web':
case 'webtv':
- return configureWebProject(c);
+ return configureWebProject();
case 'tizen':
case 'tizenmobile':
case 'tizenwatch':
- return configureTizenProject(c);
+ return configureTizenProject();
case 'webos':
- return configureWebOSProject(c);
+ return configureWebOSProject();
case 'chromecast':
- return configureChromecastProject(c);
+ return configureChromecastProject();
case 'kaios':
- return configureKaiOSProject(c);
+ return configureKaiOSProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-web/src/tasks/taskDebug.ts b/packages/engine-rn-web/src/tasks/taskDebug.ts
index b61048a7f9..f8cf670561 100644
--- a/packages/engine-rn-web/src/tasks/taskDebug.ts
+++ b/packages/engine-rn-web/src/tasks/taskDebug.ts
@@ -12,7 +12,7 @@ import {
const taskDebug: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskDebug', `parent:${parentTask}`);
- if (shouldSkipTask(c, RnvTaskName.debug, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.debug, originTask)) return true;
const { platform } = c;
@@ -20,9 +20,9 @@ const taskDebug: RnvTaskFn = async (c, parentTask, originTask) => {
case 'web':
case 'webtv':
case 'tizen':
- return executeAsync(c, 'npx weinre --boundHost -all-');
+ return executeAsync('npx weinre --boundHost -all-');
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-web/src/tasks/taskRun.ts b/packages/engine-rn-web/src/tasks/taskRun.ts
index 309871d03f..a5fd147b0a 100644
--- a/packages/engine-rn-web/src/tasks/taskRun.ts
+++ b/packages/engine-rn-web/src/tasks/taskRun.ts
@@ -25,7 +25,7 @@ import { runKaiOSProject } from '@rnv/sdk-kaios';
import { getIP } from '@rnv/sdk-utils';
const existBuildsOverrideForTargetPathSync = (c: RnvContext, destPath: string) => {
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const relativePath = path.relative(appFolder, destPath);
let result = false;
@@ -33,7 +33,7 @@ const existBuildsOverrideForTargetPathSync = (c: RnvContext, destPath: string) =
if (c.paths.appConfig.dirs) {
c.paths.appConfig.dirs.forEach((v) => {
- const bf = getAppConfigBuildsFolder(c, c.platform, v);
+ const bf = getAppConfigBuildsFolder(v);
if (bf) pathsToCheck.push();
});
}
@@ -50,16 +50,16 @@ const existBuildsOverrideForTargetPathSync = (c: RnvContext, destPath: string) =
const _configureHostedIfRequired = async (c: RnvContext) => {
logTask('_configureHostedIfRequired');
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const bundleAssets = getConfigProp('bundleAssets', false);
- if (!bundleAssets && !existBuildsOverrideForTargetPathSync(c, path.join(getPlatformProjectDir(c)!, 'index.html'))) {
+ if (!bundleAssets && !existBuildsOverrideForTargetPathSync(c, path.join(getPlatformProjectDir()!, 'index.html'))) {
logDebug('Running hosted build');
const ipAddress = c.program.hostIp || getIP();
if (c.runtime.currentEngine?.rootPath) {
writeCleanFile(
path.join(c.runtime.currentEngine.rootPath, 'templates', 'appShell', 'index.html'),
- path.join(getPlatformProjectDir(c)!, 'index.html'),
+ path.join(getPlatformProjectDir()!, 'index.html'),
[
{
pattern: '{{DEV_SERVER}}',
@@ -80,21 +80,21 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} target:${target} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
if (hosted) {
c.runtime.shouldOpenBrowser = true;
// return _taskStart(c);
- return executeTask(c, RnvTaskName.start, RnvTaskName.run, originTask);
+ return executeTask(RnvTaskName.start, RnvTaskName.run, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
switch (platform) {
case 'web':
case 'webtv':
c.runtime.shouldOpenBrowser = true;
- return runWebpackServer(c);
+ return runWebpackServer();
case 'tizen':
case 'tizenmobile':
case 'tizenwatch':
@@ -108,14 +108,14 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
}
return runWebOS(c);
case 'kaios':
- return runKaiOSProject(c);
+ return runKaiOSProject();
case 'chromecast':
if (!c.program.only) {
await _configureHostedIfRequired(c);
}
return runChromecast(c);
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-web/src/tasks/taskStart.ts b/packages/engine-rn-web/src/tasks/taskStart.ts
index 87dfaa6f31..f50bdf875f 100644
--- a/packages/engine-rn-web/src/tasks/taskStart.ts
+++ b/packages/engine-rn-web/src/tasks/taskStart.ts
@@ -23,17 +23,17 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskStart', `parent:${parentTask} port:${port} hosted:${!!hosted}`);
if (!parentTask) {
- await executeTask(c, RnvTaskName.configure, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configure, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
if (hosted) {
- waitForHost(c, '')
+ waitForHost('')
.then(() => openBrowser(`http://${c.runtime.localhost}:${port}/`))
.catch(logError);
}
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
const isWeinreEnabled = REMOTE_DEBUGGER_ENABLED_PLATFORMS.includes(platform) && !bundleAssets && !hosted;
switch (platform) {
@@ -44,12 +44,12 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
case 'tizenmobile':
case 'tizenwatch':
// c.runtime.keepSessionActive = true;
- return runWebpackServer(c, isWeinreEnabled);
+ return runWebpackServer(isWeinreEnabled);
default:
if (hosted) {
return logError('This platform does not support hosted mode', true);
}
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-windows/src/sdks/sdk-windows/copyTemplate.js b/packages/engine-rn-windows/src/sdks/sdk-windows/copyTemplate.js
index 9f2acaca10..55cac02657 100644
--- a/packages/engine-rn-windows/src/sdks/sdk-windows/copyTemplate.js
+++ b/packages/engine-rn-windows/src/sdks/sdk-windows/copyTemplate.js
@@ -30,7 +30,7 @@ const bundleDir = 'Bundle';
// FUNCTIONS
async function generateCertificate(srcPath, currentUser, c, options) {
logDefault('Generating self-signed certificate');
- const appFolder = getAppFolder(c, true);
+ const appFolder = getAppFolder(true);
if (os.platform() === 'win32') {
try {
// TODO. What's with this timeout?
@@ -75,8 +75,8 @@ export async function copyProjectTemplateAndReplace(c, options) {
throw new Error('Need a path to copy to');
}
- const appTitle = getAppTitle(c, c.platform);
- const appFolder = getAppFolder(c, true);
+ const appTitle = getAppTitle();
+ const appFolder = getAppFolder(true);
const RNIconsPluginPath = path.join(
path.dirname(
require.resolve('react-native-vector-icons/package.json', {
@@ -86,17 +86,17 @@ export async function copyProjectTemplateAndReplace(c, options) {
'Fonts'
);
- const language = getConfigProp(c, c.platform, 'language', options.language);
+ const language = getConfigProp('language', options.language);
const experimentalNuGetDependency = getConfigProp(
c,
c.platform,
'experimentalNuGetDependency',
options.experimentalNuGetDependency
);
- const useWinUI3 = getConfigProp(c, c.platform, 'useWinUI3', options.useWinUI3);
- const nuGetTestVersion = getConfigProp(c, c.platform, 'nuGetTestVersion', options.nuGetTestVersion);
- const useHermes = !!getConfigProp(c, c.platform, 'reactNativeEngine', options.reactNativeEngine) === 'hermes';
- const nuGetTestFeed = getConfigProp(c, c.platform, 'nuGetTestFeed', options.nuGetTestFeed);
+ const useWinUI3 = getConfigProp('useWinUI3', options.useWinUI3);
+ const nuGetTestVersion = getConfigProp('nuGetTestVersion', options.nuGetTestVersion);
+ const useHermes = !!getConfigProp('reactNativeEngine', options.reactNativeEngine) === 'hermes';
+ const nuGetTestFeed = getConfigProp('nuGetTestFeed', options.nuGetTestFeed);
generator_common_1.createDir(path.join(c.paths.project.dir, appFolder));
generator_common_1.createDir(path.join(c.paths.project.dir, appFolder, c.runtime.appId));
@@ -222,8 +222,8 @@ export async function copyProjectTemplateAndReplace(c, options) {
});
}
- const isMonorepo = getConfigProp(c, c.platform, 'isMonorepo', false);
- const monoRoot = getConfigProp(c, c.platform, 'monoRoot') || '..\\..';
+ const isMonorepo = getConfigProp('isMonorepo', false);
+ const monoRoot = getConfigProp('monoRoot') || '..\\..';
const templateVars = {
rnwPackagePath: isMonorepo
@@ -386,7 +386,7 @@ export async function copyProjectTemplateAndReplace(c, options) {
}
// Firstly attempt to copy assets specified in project, if user has none specified use default from renative
- await copyAssetsFolder(c, c.platform, c.runtime.appId);
+ await copyAssetsFolder(c.runtime.appId);
// shared assets
if (fs.existsSync(path.join(sharedPath, 'assets'))) {
@@ -401,7 +401,7 @@ export async function copyProjectTemplateAndReplace(c, options) {
}
// Non relative path to appFolder is needed
- const appFolderFull = getAppFolder(c);
+ const appFolderFull = getAppFolder();
// react native vector icons fonts
// Only copy the files if the plugin is added to the project, aka plugin dir exists
if (RNIconsPluginPath && fs.existsSync(RNIconsPluginPath)) {
diff --git a/packages/engine-rn-windows/src/sdks/sdk-windows/index.ts b/packages/engine-rn-windows/src/sdks/sdk-windows/index.ts
index 8a6c853a46..b84e2bb19f 100644
--- a/packages/engine-rn-windows/src/sdks/sdk-windows/index.ts
+++ b/packages/engine-rn-windows/src/sdks/sdk-windows/index.ts
@@ -102,44 +102,37 @@ const defaultOptions = {
type ConfigKey = any;
const getOptions = (c: RnvContext, injectedOptions: InjectOptions = {}) => {
- const language = getConfigProp(c, c.platform, 'language', defaultOptions.language);
- const release = getConfigProp(c, c.platform, 'release', defaultOptions.release);
- const root = getConfigProp(c, c.platform, 'root', c.paths.project.dir);
- const arch = getConfigProp(c, c.platform, 'arch', defaultOptions.arch);
- const singleproc = getConfigProp(c, c.platform, 'singleproc', defaultOptions.singleproc);
- const emulator = getConfigProp(c, c.platform, 'emulator', defaultOptions.emulator);
- const device = getConfigProp(c, c.platform, 'device', defaultOptions.device);
- const target = getConfigProp(c, c.platform, 'target', defaultOptions.target);
- const overwrite = getConfigProp(c, c.platform, 'overwrite', defaultOptions.overwrite);
- const remoteDebugging = getConfigProp(c, c.platform, 'remoteDebugging', defaultOptions.remoteDebugging);
- const logging = getConfigProp(c, c.platform, 'logging', defaultOptions.logging);
- const packager = getConfigProp(c, c.platform, 'packager', defaultOptions.packager);
- const bundle = getConfigProp(c, c.platform, 'bundle', defaultOptions.bundle);
- const launch = getConfigProp(c, c.platform, 'launch', defaultOptions.launch);
- const autolink = getConfigProp(c, c.platform, 'autolink', defaultOptions.autolink);
- const build = getConfigProp(c, c.platform, 'build', defaultOptions.build);
- const deploy = getConfigProp(c, c.platform, 'deploy', defaultOptions.deploy);
- const sln = getConfigProp(c, c.platform, 'sln', defaultOptions.sln);
- const proj = getConfigProp(c, c.platform, 'proj', c.paths.project.dir);
- const appPath = getConfigProp(c, c.platform, 'appPath', getAppFolder(c));
- const msbuildprops = getConfigProp(c, c.platform, 'msbuildprops', defaultOptions.msbuildprops);
- const buildLogDirectory = getConfigProp(
- c,
- c.platform,
- 'buildLogDirectory',
- path.join(getAppFolder(c), 'BuildLogs')
- );
- const info = getConfigProp(c, c.platform, 'info', defaultOptions.info);
- const directDebugging = getConfigProp(c, c.platform, 'directDebugging', defaultOptions.directDebugging);
- const telemetry = getConfigProp(c, c.platform, 'telemetry', defaultOptions.telemetry);
- const devPort = getConfigProp(c, c.platform, 'devPort', c.runtime.port);
- const env = getConfigProp(c, c.platform, 'environment');
+ const language = getConfigProp('language', defaultOptions.language);
+ const release = getConfigProp('release', defaultOptions.release);
+ const root = getConfigProp('root', c.paths.project.dir);
+ const arch = getConfigProp('arch', defaultOptions.arch);
+ const singleproc = getConfigProp('singleproc', defaultOptions.singleproc);
+ const emulator = getConfigProp('emulator', defaultOptions.emulator);
+ const device = getConfigProp('device', defaultOptions.device);
+ const target = getConfigProp('target', defaultOptions.target);
+ const overwrite = getConfigProp('overwrite', defaultOptions.overwrite);
+ const remoteDebugging = getConfigProp('remoteDebugging', defaultOptions.remoteDebugging);
+ const logging = getConfigProp('logging', defaultOptions.logging);
+ const packager = getConfigProp('packager', defaultOptions.packager);
+ const bundle = getConfigProp('bundle', defaultOptions.bundle);
+ const launch = getConfigProp('launch', defaultOptions.launch);
+ const autolink = getConfigProp('autolink', defaultOptions.autolink);
+ const build = getConfigProp('build', defaultOptions.build);
+ const deploy = getConfigProp('deploy', defaultOptions.deploy);
+ const sln = getConfigProp('sln', defaultOptions.sln);
+ const proj = getConfigProp('proj', c.paths.project.dir);
+ const appPath = getConfigProp('appPath', getAppFolder());
+ const msbuildprops = getConfigProp('msbuildprops', defaultOptions.msbuildprops);
+ const buildLogDirectory = getConfigProp('buildLogDirectory', path.join(getAppFolder(), 'BuildLogs'));
+ const info = getConfigProp('info', defaultOptions.info);
+ const directDebugging = getConfigProp('directDebugging', defaultOptions.directDebugging);
+ const telemetry = getConfigProp('telemetry', defaultOptions.telemetry);
+ const devPort = getConfigProp('devPort', c.runtime.port);
+ const env = getConfigProp('environment');
// Aditional ReNative property configurations
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets') === true;
- const bundleIsDev = getConfigProp(c, c.platform, 'bundleIsDev') === true;
+ const bundleAssets = getConfigProp('bundleAssets') === true;
+ const bundleIsDev = getConfigProp('bundleIsDev') === true;
const additionalMetroOptions = getConfigProp(
- c,
- c.platform,
'additionalMetroOptions',
defaultOptions.additionalMetroOptions
);
@@ -209,7 +202,7 @@ export const ruWindowsProject = async (c: RnvContext, injectedOptions?: InjectOp
}
const cnfg = {
- sourceDir: getAppFolder(c, true),
+ sourceDir: getAppFolder(true),
solutionFile: `${c.runtime.appId}.sln`,
project: {
projectName: c.runtime.appId,
@@ -276,7 +269,7 @@ const copyWindowsTemplateProject = async (c: RnvContext, injectedOptions = {}) =
function clearWindowsTemporaryFiles(c: RnvContext) {
logDefault('clearWindowsTemporaryFiles');
- const logging = getConfigProp(c, c.platform, 'logging', defaultOptions.logging);
+ const logging = getConfigProp('logging', defaultOptions.logging);
const opts = {
cwd: c.paths.project.dir,
detached: false,
@@ -304,7 +297,7 @@ function clearWindowsTemporaryFiles(c: RnvContext) {
const packageBundleForWindows = (c: RnvContext, isDev = false) => {
logDefault('packageBundleForWindows');
// const { maxErrorLength } = c.program;
- const entryFile = getConfigProp(c, c.platform, 'entryFile');
+ const entryFile = getConfigProp('entryFile');
if (!c.runtime.appId) return;
@@ -315,20 +308,20 @@ const packageBundleForWindows = (c: RnvContext, isDev = false) => {
'--dev',
isDev,
'--assets-dest',
- `${getAppFolder(c).replace(/\//g, '\\')}\\${c.runtime.appId}\\Bundle`,
+ `${getAppFolder().replace(/\//g, '\\')}\\${c.runtime.appId}\\Bundle`,
'--entry-file',
`${entryFile}.js`,
'--bundle-output',
- `${getAppFolder(c).replace(/\//g, '\\')}\\${c.runtime.appId}\\Bundle\\index.windows.bundle`,
+ `${getAppFolder().replace(/\//g, '\\')}\\${c.runtime.appId}\\Bundle\\index.windows.bundle`,
];
if (c.program.info) {
args.push('--verbose');
}
- if (getConfigProp(c, c.platform, 'enableSourceMaps', false)) {
+ if (getConfigProp('enableSourceMaps', false)) {
// Directory might not exist yet (created during builds proccess)
- const dir = path.join(getAppFolder(c), 'Release', c.runtime.appId, 'sourcemaps', 'react');
+ const dir = path.join(getAppFolder(), 'Release', c.runtime.appId, 'sourcemaps', 'react');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
@@ -338,7 +331,6 @@ const packageBundleForWindows = (c: RnvContext, isDev = false) => {
}
return executeAsync(
- c,
`node ${doResolve('react-native', true, { forceForwardPaths: false })}\\local-cli\\cli.js ${args.join(
' '
)} --config=metro.config.js`,
@@ -350,7 +342,7 @@ const setSingleBuildProcessForWindows = (c: RnvContext) => {
logDefault('setSingleBuildProcessForWindows');
// eslint-disable-next-line eqeqeq
if (env.MSBUILDDISABLENODEREUSE != 1) {
- const logging = getConfigProp(c, c.platform, 'logging', defaultOptions.logging);
+ const logging = getConfigProp('logging', defaultOptions.logging);
const opts = {
cwd: c.paths.project.dir,
detached: false,
@@ -374,7 +366,7 @@ const pushd = (pathArg: string) => {
// Copied from @react-native-windows/cli/overrides/lib-commonjs/runWindows/utils/deploy.js
const getWindowsStoreAppUtils = (c: RnvContext) => {
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const RNWinPath = path.join(
path.dirname(
require.resolve('@react-native-windows/cli/package.json', {
@@ -395,7 +387,7 @@ const getWindowsStoreAppUtils = (c: RnvContext) => {
function getAppPackage(c: RnvContext, injectedOptions?: InjectOptions) {
const options = getOptions(c, injectedOptions);
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
let appPackage;
const rootGlob = `${appFolder.replace(/\\/g, '/')}/{*/AppPackages,AppPackages/*}`;
@@ -418,7 +410,7 @@ function getAppPackage(c: RnvContext, injectedOptions?: InjectOptions) {
const signWindowsApp = async (c: RnvContext, script: string, windowsStoreAppUtils: string) => {
try {
- const logging = getConfigProp(c, c.platform, 'logging', defaultOptions.logging);
+ const logging = getConfigProp('logging', defaultOptions.logging);
// TODO Installs the app instead of just saving a certificate
await runPowerShellScriptFunction(
'Saving certificate in the local certificate store',
@@ -432,7 +424,7 @@ const signWindowsApp = async (c: RnvContext, script: string, windowsStoreAppUtil
};
const installWindowsApp = async (c: RnvContext, script: string, windowsStoreAppUtils: string) => {
- const logging = getConfigProp(c, c.platform, 'logging', defaultOptions.logging);
+ const logging = getConfigProp('logging', defaultOptions.logging);
await runPowerShellScriptFunction(
'Removing old version of the app',
windowsStoreAppUtils,
@@ -450,16 +442,16 @@ const installWindowsApp = async (c: RnvContext, script: string, windowsStoreAppU
const packageWindowsApp = async (c: RnvContext, injectedOptions?: InjectOptions) => {
if (!c.runtime.appId) return;
try {
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const windowsStoreAppUtils = getWindowsStoreAppUtils(c);
const appPackage = getAppPackage(c, injectedOptions);
// TODO For the most part package generated by runWindows with release option set to true is enough
// but you might want to package and sign the app manually with a different certificate
- // const arch = getConfigProp(c, c.platform, 'arch', defaultOptions.arch);
- // const logging = getConfigProp(c, c.platform, 'logging', defaultOptions.logging);
- // const packageExtension = getConfigProp(c, c.platform, 'packageExtension', defaultOptions.packageExtension);
- // // const packageExtension = getConfigProp(c, c.platform, 'packageExtension', defaultOptions.packageExtension);
+ // const arch = getConfigProp('arch', defaultOptions.arch);
+ // const logging = getConfigProp('logging', defaultOptions.logging);
+ // const packageExtension = getConfigProp('packageExtension', defaultOptions.packageExtension);
+ // // const packageExtension = getConfigProp('packageExtension', defaultOptions.packageExtension);
// // Find available SDKs, which have MakeAppx tool
// const sdks = msBuildTools.getAllAvailableUAPVersions();
// const packageTaskDescription = 'Packaging UWP Application';
diff --git a/packages/engine-rn-windows/src/tasks/taskBuild.ts b/packages/engine-rn-windows/src/tasks/taskBuild.ts
index 4e3752f127..5713b2a093 100644
--- a/packages/engine-rn-windows/src/tasks/taskBuild.ts
+++ b/packages/engine-rn-windows/src/tasks/taskBuild.ts
@@ -14,16 +14,16 @@ const taskBuild: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskBuild');
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.package, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.package, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'xbox':
case 'windows':
return ruWindowsProject(c, { release: true, launch: false, deploy: false, logging: false });
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-windows/src/tasks/taskConfigure.ts b/packages/engine-rn-windows/src/tasks/taskConfigure.ts
index a57fcad304..dd86e211bb 100644
--- a/packages/engine-rn-windows/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn-windows/src/tasks/taskConfigure.ts
@@ -17,11 +17,11 @@ const { configureWindowsProject } = SDKWindows;
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
- await configureEntryPoint(c, c.platform);
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
+ await configureEntryPoint(c.platform);
- await copySharedPlatforms(c);
+ await copySharedPlatforms();
if (c.program.only && !!parentTask) {
return true;
@@ -32,7 +32,7 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
case 'windows':
return configureWindowsProject(c);
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-windows/src/tasks/taskExport.ts b/packages/engine-rn-windows/src/tasks/taskExport.ts
index 4863e3aee5..b10f6dc0e6 100644
--- a/packages/engine-rn-windows/src/tasks/taskExport.ts
+++ b/packages/engine-rn-windows/src/tasks/taskExport.ts
@@ -18,9 +18,9 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.build, RnvTaskName.export, originTask);
+ await executeOrSkipTask(RnvTaskName.build, RnvTaskName.export, originTask);
- if (shouldSkipTask(c, RnvTaskName.export, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.export, originTask)) return true;
switch (platform) {
case 'xbox':
@@ -28,7 +28,7 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
await clearWindowsTemporaryFiles(c);
return packageWindowsApp(c);
default:
- logErrorPlatform(c);
+ logErrorPlatform();
}
};
diff --git a/packages/engine-rn-windows/src/tasks/taskPackage.ts b/packages/engine-rn-windows/src/tasks/taskPackage.ts
index 1d8d2e586d..edd2b2afd1 100644
--- a/packages/engine-rn-windows/src/tasks/taskPackage.ts
+++ b/packages/engine-rn-windows/src/tasks/taskPackage.ts
@@ -17,22 +17,22 @@ const taskPackage: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskPackage', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.package, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.package, originTask);
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
if (!bundleAssets) {
return true;
}
- if (shouldSkipTask(c, RnvTaskName.package, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.package, originTask)) return true;
switch (platform) {
case 'xbox':
case 'windows':
return packageBundleForWindows(c);
default:
- logErrorPlatform(c);
+ logErrorPlatform();
return false;
}
};
diff --git a/packages/engine-rn-windows/src/tasks/taskRun.ts b/packages/engine-rn-windows/src/tasks/taskRun.ts
index e10a54eaca..a21db06f91 100644
--- a/packages/engine-rn-windows/src/tasks/taskRun.ts
+++ b/packages/engine-rn-windows/src/tasks/taskRun.ts
@@ -20,19 +20,19 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} target:${target} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
switch (platform) {
case 'xbox':
case 'windows':
await clearWindowsTemporaryFiles(c);
- await startBundlerIfRequired(c, RnvTaskName.run, originTask);
+ await startBundlerIfRequired(RnvTaskName.run, originTask);
await ruWindowsProject(c);
- return waitForBundlerIfRequired(c);
+ return waitForBundlerIfRequired();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn-windows/src/tasks/taskStart.ts b/packages/engine-rn-windows/src/tasks/taskStart.ts
index eb0057af50..c100a6b4b9 100644
--- a/packages/engine-rn-windows/src/tasks/taskStart.ts
+++ b/packages/engine-rn-windows/src/tasks/taskStart.ts
@@ -30,22 +30,22 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
// Disable reset for other commands (ie. cleaning platforms)
c.runtime.disableReset = true;
if (!parentTask) {
- await executeTask(c, RnvTaskName.configureSoft, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configureSoft, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
switch (platform) {
case 'xbox':
case 'windows': {
- return startReactNative(c, {
+ return startReactNative({
waitForBundler: !!parentTask,
customCliPath: `${doResolve('react-native')}/local-cli/cli.js`,
metroConfigName: 'metro.config.js',
});
}
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn/src/tasks/__tests__/taskRun.test.ts b/packages/engine-rn/src/tasks/__tests__/taskRun.test.ts
index f26f3638c2..15c885f4f0 100644
--- a/packages/engine-rn/src/tasks/__tests__/taskRun.test.ts
+++ b/packages/engine-rn/src/tasks/__tests__/taskRun.test.ts
@@ -23,5 +23,5 @@ test('Execute task.rnv.run', async () => {
// WHEN
await taskRun.fn?.(ctx, undefined, undefined);
// THEN
- expect(runXcodeProject).toHaveBeenCalledWith(ctx, 'MOCK_DEVICE_ARGS');
+ expect(runXcodeProject).toHaveBeenCalledWith('MOCK_DEVICE_ARGS');
});
diff --git a/packages/engine-rn/src/tasks/__tests__/taskStart.test.ts b/packages/engine-rn/src/tasks/__tests__/taskStart.test.ts
index 83b3dd4312..515f2f0b98 100644
--- a/packages/engine-rn/src/tasks/__tests__/taskStart.test.ts
+++ b/packages/engine-rn/src/tasks/__tests__/taskStart.test.ts
@@ -22,7 +22,7 @@ describe('taskStart', () => {
// WHEN
await taskStart.fn?.(ctx, undefined, undefined);
// THEN
- expect(startReactNative).toHaveBeenCalledWith(ctx, { waitForBundler: true });
+ expect(startReactNative).toHaveBeenCalledWith({ waitForBundler: true });
});
it('Execute task.rnv.start', async () => {
// GIVEN
@@ -31,6 +31,6 @@ describe('taskStart', () => {
// WHEN
await taskStart.fn?.(ctx, 'parent', undefined);
// THEN
- expect(startReactNative).toHaveBeenCalledWith(ctx, { waitForBundler: false });
+ expect(startReactNative).toHaveBeenCalledWith({ waitForBundler: false });
});
});
diff --git a/packages/engine-rn/src/tasks/taskBuild.ts b/packages/engine-rn/src/tasks/taskBuild.ts
index fd2b111a4b..d4347ee6b7 100644
--- a/packages/engine-rn/src/tasks/taskBuild.ts
+++ b/packages/engine-rn/src/tasks/taskBuild.ts
@@ -15,25 +15,25 @@ const taskBuild: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskBuild');
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.package, RnvTaskName.build, originTask);
+ await executeOrSkipTask(RnvTaskName.package, RnvTaskName.build, originTask);
- if (shouldSkipTask(c, RnvTaskName.build, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.build, originTask)) return true;
switch (platform) {
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
- return buildReactNativeAndroid(c);
+ return buildReactNativeAndroid();
case 'ios':
case 'macos':
if (parentTask === RnvTaskName.export) {
// build task is not necessary when exporting ios
return true;
}
- return buildXcodeProject(c);
+ return buildXcodeProject();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn/src/tasks/taskConfigure.ts b/packages/engine-rn/src/tasks/taskConfigure.ts
index ed8b11855c..8a04c3a121 100644
--- a/packages/engine-rn/src/tasks/taskConfigure.ts
+++ b/packages/engine-rn/src/tasks/taskConfigure.ts
@@ -17,10 +17,10 @@ import { configureFonts } from '@rnv/sdk-react-native';
const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskConfigure');
- await executeTask(c, RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
- if (shouldSkipTask(c, RnvTaskName.configure, originTask)) return true;
+ await executeTask(RnvTaskName.platformConfigure, RnvTaskName.configure, originTask);
+ if (shouldSkipTask(RnvTaskName.configure, originTask)) return true;
- await configureEntryPoint(c, c.platform);
+ await configureEntryPoint(c.platform);
if (c.program.only && !!parentTask) {
return true;
@@ -29,21 +29,21 @@ const taskConfigure: RnvTaskFn = async (c, parentTask, originTask) => {
switch (c.platform) {
case 'ios':
case 'macos':
- await configureXcodeProject(c);
+ await configureXcodeProject();
break;
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
- await configureGradleProject(c);
- await jetifyIfRequired(c);
+ await configureGradleProject();
+ await jetifyIfRequired();
break;
default:
- logErrorPlatform(c);
+ logErrorPlatform();
break;
}
- await configureFonts(c);
+ await configureFonts();
return true;
};
diff --git a/packages/engine-rn/src/tasks/taskCryptoInstallCerts.ts b/packages/engine-rn/src/tasks/taskCryptoInstallCerts.ts
index 4161fe2a65..6f96a86740 100644
--- a/packages/engine-rn/src/tasks/taskCryptoInstallCerts.ts
+++ b/packages/engine-rn/src/tasks/taskCryptoInstallCerts.ts
@@ -15,9 +15,9 @@ import {
const taskCryptoInstallCerts: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoInstallCerts');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallCerts, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallCerts, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoInstallCerts, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoInstallCerts, originTask)) return true;
if (c.platform !== 'ios') {
logError(`_installTempCerts: platform ${c.platform} not supported`);
@@ -29,7 +29,7 @@ const taskCryptoInstallCerts: RnvTaskFn = async (c, _parentTask, originTask) =>
const cerArr = list.filter((v) => v.endsWith('.cer'));
try {
- Promise.all(cerArr.map((v) => executeAsync(c, `security import ${v} -k ${kChain} -A`)));
+ Promise.all(cerArr.map((v) => executeAsync(`security import ${v} -k ${kChain} -A`)));
} catch (e) {
logWarning(e);
return true;
diff --git a/packages/engine-rn/src/tasks/taskCryptoInstallProfiles.ts b/packages/engine-rn/src/tasks/taskCryptoInstallProfiles.ts
index aa231c0013..1b90be0aff 100644
--- a/packages/engine-rn/src/tasks/taskCryptoInstallProfiles.ts
+++ b/packages/engine-rn/src/tasks/taskCryptoInstallProfiles.ts
@@ -18,9 +18,9 @@ import {
const taskCryptoInstallProfiles: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoInstallProfiles');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallProfiles, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoInstallProfiles, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoInstallProfiles, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoInstallProfiles, originTask)) return true;
if (c.platform !== 'ios') {
logError(`taskCryptoInstallProfiles: platform ${c.platform} not supported`);
diff --git a/packages/engine-rn/src/tasks/taskCryptoUpdateProfile.ts b/packages/engine-rn/src/tasks/taskCryptoUpdateProfile.ts
index c789c9570c..2903e14182 100644
--- a/packages/engine-rn/src/tasks/taskCryptoUpdateProfile.ts
+++ b/packages/engine-rn/src/tasks/taskCryptoUpdateProfile.ts
@@ -4,11 +4,11 @@ import { updateProfile } from '@rnv/sdk-apple';
const taskCryptoUpdateProfile: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoUpdateProfile');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfile, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfile, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoUpdateProfile, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoUpdateProfile, originTask)) return true;
- await updateProfile(c);
+ await updateProfile();
};
const Task: RnvTask = {
diff --git a/packages/engine-rn/src/tasks/taskCryptoUpdateProfiles.ts b/packages/engine-rn/src/tasks/taskCryptoUpdateProfiles.ts
index bc86e2d323..7e49fb907a 100644
--- a/packages/engine-rn/src/tasks/taskCryptoUpdateProfiles.ts
+++ b/packages/engine-rn/src/tasks/taskCryptoUpdateProfiles.ts
@@ -15,14 +15,14 @@ import { updateProfile } from '@rnv/sdk-apple';
const _updateProfile = (c: RnvContext, v: string) =>
new Promise((resolve, reject) => {
logTask(`_updateProfile:${v}`, chalk().grey);
- updateProfile(c)
+ updateProfile()
.then(() => resolve())
.catch((e) => reject(e));
});
const _updateProfiles = (c: RnvContext) => {
logTask('_updateProfiles', chalk().grey);
- const acList = listAppConfigsFoldersSync(c, true);
+ const acList = listAppConfigsFoldersSync(true);
return acList.reduce((previousPromise, v) => previousPromise.then(() => _updateProfile(c, v)), Promise.resolve());
};
@@ -30,9 +30,9 @@ const _updateProfiles = (c: RnvContext) => {
const taskCryptoUpdateProfiles: RnvTaskFn = async (c, _parentTask, originTask) => {
logTask('taskCryptoUpdateProfiles');
- await executeTask(c, RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfiles, originTask);
+ await executeTask(RnvTaskName.projectConfigure, RnvTaskName.cryptoUpdateProfiles, originTask);
- if (shouldSkipTask(c, RnvTaskName.cryptoUpdateProfiles, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.cryptoUpdateProfiles, originTask)) return true;
switch (c.platform) {
case 'ios':
diff --git a/packages/engine-rn/src/tasks/taskEject.ts b/packages/engine-rn/src/tasks/taskEject.ts
index 4b8c72e5d5..a926f3f551 100644
--- a/packages/engine-rn/src/tasks/taskEject.ts
+++ b/packages/engine-rn/src/tasks/taskEject.ts
@@ -29,22 +29,22 @@ const taskEject: RnvTaskFn = async (c, _parentTask, originTask) => {
c.runtime._skipNativeDepResolutions = true;
- await executeOrSkipTask(c, RnvTaskName.package, RnvTaskName.eject, originTask);
+ await executeOrSkipTask(RnvTaskName.package, RnvTaskName.eject, originTask);
- if (shouldSkipTask(c, RnvTaskName.eject, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.eject, originTask)) return true;
switch (platform) {
case 'ios':
case 'macos':
- await ejectXcodeProject(c);
+ await ejectXcodeProject();
return true;
case 'android':
case 'androidtv':
case 'androidwear':
- await ejectGradleProject(c);
+ await ejectGradleProject();
return true;
default:
- await logErrorPlatform(c);
+ await logErrorPlatform();
return true;
}
};
diff --git a/packages/engine-rn/src/tasks/taskExport.ts b/packages/engine-rn/src/tasks/taskExport.ts
index ce4019a154..549e073cb1 100644
--- a/packages/engine-rn/src/tasks/taskExport.ts
+++ b/packages/engine-rn/src/tasks/taskExport.ts
@@ -14,21 +14,21 @@ const taskExport: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskExport', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.build, RnvTaskName.export, originTask);
+ await executeOrSkipTask(RnvTaskName.build, RnvTaskName.export, originTask);
- if (shouldSkipTask(c, RnvTaskName.export, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.export, originTask)) return true;
switch (platform) {
case 'ios':
case 'macos':
- return exportXcodeProject(c);
+ return exportXcodeProject();
case 'android':
case 'androidtv':
case 'androidwear':
// Android Platforms don't need extra export step
return true;
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn/src/tasks/taskLog.ts b/packages/engine-rn/src/tasks/taskLog.ts
index 0c5ae849b2..3f07c342a5 100644
--- a/packages/engine-rn/src/tasks/taskLog.ts
+++ b/packages/engine-rn/src/tasks/taskLog.ts
@@ -15,19 +15,19 @@ import {} from '@rnv/sdk-android';
const taskLog: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskLog', `parent:${parentTask}`);
- await executeTask(c, RnvTaskName.workspaceConfigure, RnvTaskName.projectConfigure, originTask);
+ await executeTask(RnvTaskName.workspaceConfigure, RnvTaskName.projectConfigure, originTask);
switch (c.platform) {
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
- await checkAndConfigureAndroidSdks(c);
- return runAndroidLog(c);
+ await checkAndConfigureAndroidSdks();
+ return runAndroidLog();
case 'ios':
- return runAppleLog(c);
+ return runAppleLog();
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn/src/tasks/taskPackage.ts b/packages/engine-rn/src/tasks/taskPackage.ts
index 0a04d9863d..14cb0929e2 100644
--- a/packages/engine-rn/src/tasks/taskPackage.ts
+++ b/packages/engine-rn/src/tasks/taskPackage.ts
@@ -16,11 +16,11 @@ const taskPackage: RnvTaskFn = async (c, parentTask, originTask) => {
logTask('taskPackage', `parent:${parentTask}`);
const { platform } = c;
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.package, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.package, originTask);
- if (shouldSkipTask(c, RnvTaskName.package, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.package, originTask)) return true;
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
if (!bundleAssets) {
return true;
@@ -29,7 +29,7 @@ const taskPackage: RnvTaskFn = async (c, parentTask, originTask) => {
switch (platform) {
case 'ios':
case 'macos':
- return packageBundleForXcode(c);
+ return packageBundleForXcode();
case 'android':
case 'androidtv':
case 'firetv':
@@ -37,16 +37,16 @@ const taskPackage: RnvTaskFn = async (c, parentTask, originTask) => {
// NOTE: react-native v0.73 triggers packaging automatically so we skipping it unless we need to
// package it explicitly for tasks where it is not triggered automatically
- const signingConfig = getConfigProp(c, c.platform, 'signingConfig');
+ const signingConfig = getConfigProp('signingConfig');
if (originTask === RnvTaskName.eject || signingConfig !== 'Release') {
//if bundleAssets === true AND signingConfig is not releaase RN will not trigger packaging
- return packageAndroid(c);
+ return packageAndroid();
}
return true;
}
default:
- logErrorPlatform(c);
+ logErrorPlatform();
return false;
}
};
diff --git a/packages/engine-rn/src/tasks/taskRun.ts b/packages/engine-rn/src/tasks/taskRun.ts
index 15e40a0241..5b82196228 100644
--- a/packages/engine-rn/src/tasks/taskRun.ts
+++ b/packages/engine-rn/src/tasks/taskRun.ts
@@ -21,11 +21,11 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
const { hosted } = c.program;
logTask('taskRun', `parent:${parentTask} port:${port} hosted:${hosted}`);
- await executeOrSkipTask(c, RnvTaskName.configure, RnvTaskName.run, originTask);
+ await executeOrSkipTask(RnvTaskName.configure, RnvTaskName.run, originTask);
- if (shouldSkipTask(c, RnvTaskName.run, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.run, originTask)) return true;
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const bundleAssets = getConfigProp('bundleAssets', false);
switch (platform) {
case 'ios':
@@ -33,37 +33,37 @@ const taskRun: RnvTaskFn = async (c, parentTask, originTask) => {
// eslint-disable-next-line no-case-declarations
const runDeviceArgs = await getIosDeviceToRunOn(c);
if (!c.program.only) {
- await startBundlerIfRequired(c, RnvTaskName.run, originTask);
- await runXcodeProject(c, runDeviceArgs);
+ await startBundlerIfRequired(RnvTaskName.run, originTask);
+ await runXcodeProject(runDeviceArgs);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
- return waitForBundlerIfRequired(c);
+ return waitForBundlerIfRequired();
}
- return runXcodeProject(c, runDeviceArgs);
+ return runXcodeProject(runDeviceArgs);
case 'android':
case 'androidtv':
case 'firetv':
case 'androidwear':
// eslint-disable-next-line no-case-declarations
- const runDevice = await getAndroidDeviceToRunOn(c);
+ const runDevice = await getAndroidDeviceToRunOn();
if (runDevice) {
c.runtime.target = runDevice?.name || runDevice?.udid;
}
if (!c.program.only) {
- await startBundlerIfRequired(c, RnvTaskName.run, originTask);
+ await startBundlerIfRequired(RnvTaskName.run, originTask);
if (bundleAssets || platform === 'androidwear') {
- await packageAndroid(c);
+ await packageAndroid();
}
- await runAndroid(c, runDevice!);
+ await runAndroid(runDevice!);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
- return waitForBundlerIfRequired(c);
+ return waitForBundlerIfRequired();
}
- return runAndroid(c, runDevice!);
+ return runAndroid(runDevice!);
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn/src/tasks/taskStart.ts b/packages/engine-rn/src/tasks/taskStart.ts
index 0d60fc90cc..2840748c69 100644
--- a/packages/engine-rn/src/tasks/taskStart.ts
+++ b/packages/engine-rn/src/tasks/taskStart.ts
@@ -23,10 +23,10 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
// Disable reset for other commands (ie. cleaning platforms)
c.runtime.disableReset = true;
if (!parentTask) {
- await executeTask(c, RnvTaskName.configureSoft, RnvTaskName.start, originTask);
+ await executeTask(RnvTaskName.configureSoft, RnvTaskName.start, originTask);
}
- if (shouldSkipTask(c, RnvTaskName.start, originTask)) return true;
+ if (shouldSkipTask(RnvTaskName.start, originTask)) return true;
switch (platform) {
case 'ios':
@@ -35,10 +35,10 @@ const taskStart: RnvTaskFn = async (c, parentTask, originTask) => {
case 'androidtv':
case 'firetv':
case 'androidwear': {
- return startReactNative(c, { waitForBundler: !parentTask });
+ return startReactNative({ waitForBundler: !parentTask });
}
default:
- return logErrorPlatform(c);
+ return logErrorPlatform();
}
};
diff --git a/packages/engine-rn/templates/platforms/android/build.gradle b/packages/engine-rn/templates/platforms/android/build.gradle
index 1f762cc2a0..9ebe9747f3 100644
--- a/packages/engine-rn/templates/platforms/android/build.gradle
+++ b/packages/engine-rn/templates/platforms/android/build.gradle
@@ -11,9 +11,20 @@ buildscript {
ndkVersion = '{{NDK_VERSION}}'
kotlinVersion = '{{INJECT_KOTLIN_VERSION}}'
}
+ subprojects { subproject ->
+ afterEvaluate{
+ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
+ android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+ }
+ }
+ }
+}
repositories {
google()
mavenCentral()
+ maven { url = uri("https://www.jitpack.io" ) }
}
dependencies {
classpath("com.android.tools.build:gradle")
diff --git a/packages/engine-rn/templates/platforms/androidwear/build.gradle b/packages/engine-rn/templates/platforms/androidwear/build.gradle
index cad91e38b6..3cd9be67fd 100644
--- a/packages/engine-rn/templates/platforms/androidwear/build.gradle
+++ b/packages/engine-rn/templates/platforms/androidwear/build.gradle
@@ -11,6 +11,17 @@ buildscript {
ndkVersion = '{{NDK_VERSION}}'
kotlinVersion = '{{INJECT_KOTLIN_VERSION}}'
}
+
+ subprojects { subproject ->
+ afterEvaluate{
+ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
+ android {
+ compileSdkVersion rootProject.ext.compileSdkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+ }
+ }
+ }
+}
repositories {
google()
mavenCentral()
diff --git a/packages/integration-docker/src/docker.ts b/packages/integration-docker/src/docker.ts
index e08ad91c0a..4c23b71753 100644
--- a/packages/integration-docker/src/docker.ts
+++ b/packages/integration-docker/src/docker.ts
@@ -15,26 +15,27 @@ import {
chalk,
ExecOptionsPresets,
getAppFolder,
+ getContext,
} from '@rnv/core';
const rootPath = path.join(__dirname, './');
class Docker {
c: RnvContext;
- constructor(c: RnvContext) {
- this.c = c;
+ constructor() {
+ this.c = getContext();
}
async buildImage() {
const { c } = this;
- const { runtime, platform, files } = c;
+ const { runtime, files } = c;
let outputDir = 'output';
- let projectBuildWeb = path.join(getAppFolder(c)!, outputDir);
+ let projectBuildWeb = path.join(getAppFolder()!, outputDir);
if (!fsExistsSync(projectBuildWeb)) {
outputDir = 'project';
- projectBuildWeb = path.join(getAppFolder(c)!, outputDir);
+ projectBuildWeb = path.join(getAppFolder()!, outputDir);
}
- const dockerDestination = path.join(getAppFolder(c)!, 'export', 'docker');
+ const dockerDestination = path.join(getAppFolder()!, 'export', 'docker');
const dockerFile = path.join(rootPath, '../Dockerfile');
const nginxConfFile = path.join(rootPath, '../nginx/default.conf');
@@ -54,7 +55,7 @@ class Docker {
// save the docker files
logDefault('docker:Dockerfile:create');
- const deployOptions = getConfigProp(c, platform, 'custom').deploy;
+ const deployOptions = getConfigProp('custom').deploy;
const healthCheck = deployOptions?.docker?.healthcheckProbe;
let additionalCommands = '';
@@ -85,14 +86,13 @@ class Docker {
const {
runtime,
files,
- platform,
program: { scheme = 'debug' },
} = c;
const imageName = runtime.appId?.toLowerCase();
const appVersion = files.project.package.version;
- const dockerDestination = path.join(getAppFolder(c)!, 'export', 'docker');
+ const dockerDestination = path.join(getAppFolder()!, 'export', 'docker');
const dockerSaveFile = path.join(dockerDestination, `${imageName}_${appVersion}.tar`);
logDefault('docker:Dockerfile:build');
@@ -110,7 +110,7 @@ class Docker {
)} and then opening ${chalk().bold('http://localhost:8081')}`
);
- const deployOptions = getConfigProp(c, platform, 'custom').deploy;
+ const deployOptions = getConfigProp('custom').deploy;
const zipImage = deployOptions?.docker?.zipImage;
if (zipImage) {
diff --git a/packages/integration-docker/src/tasks/taskDockerDeploy.ts b/packages/integration-docker/src/tasks/taskDockerDeploy.ts
index 2a6bece4ed..62cd8863c5 100644
--- a/packages/integration-docker/src/tasks/taskDockerDeploy.ts
+++ b/packages/integration-docker/src/tasks/taskDockerDeploy.ts
@@ -15,13 +15,13 @@ const taskDockerDeploy: RnvTaskFn = async (c, parentTask, originTask) => {
if (c.program.only) {
// If run as standalone command skip all the export
- await executeOrSkipTask(c, RnvTaskName.export, 'docker export', originTask);
+ await executeOrSkipTask(RnvTaskName.export, 'docker export', originTask);
} else {
- const taskInstance = await findSuitableTask(c, RnvTaskName.export);
- if (taskInstance) await initializeTask(c, taskInstance.task);
+ const taskInstance = await findSuitableTask(RnvTaskName.export);
+ if (taskInstance) await initializeTask(taskInstance.task);
}
- const docker = new Docker(c);
+ const docker = new Docker();
await docker.doDeploy();
return true;
};
diff --git a/packages/integration-docker/src/tasks/taskDockerExport.ts b/packages/integration-docker/src/tasks/taskDockerExport.ts
index 64cd5ff860..7fd2b18bc1 100644
--- a/packages/integration-docker/src/tasks/taskDockerExport.ts
+++ b/packages/integration-docker/src/tasks/taskDockerExport.ts
@@ -15,13 +15,13 @@ const taskDockerExport: RnvTaskFn = async (c, parentTask, originTask) => {
if (c.program.only) {
// If run as standalone command skip all the export
- await executeOrSkipTask(c, RnvTaskName.export, 'docker export', originTask);
+ await executeOrSkipTask(RnvTaskName.export, 'docker export', originTask);
} else {
- const taskInstance = await findSuitableTask(c, RnvTaskName.export);
- if (taskInstance) await initializeTask(c, taskInstance.task);
+ const taskInstance = await findSuitableTask(RnvTaskName.export);
+ if (taskInstance) await initializeTask(taskInstance.task);
}
- const docker = new Docker(c);
+ const docker = new Docker();
await docker.doExport();
return true;
};
diff --git a/packages/rnv/coreTemplateFiles/global-config-template.json b/packages/rnv/coreTemplateFiles/global-config-template.json
index c9a0cc8f30..85b56a76cd 100644
--- a/packages/rnv/coreTemplateFiles/global-config-template.json
+++ b/packages/rnv/coreTemplateFiles/global-config-template.json
@@ -4,7 +4,7 @@
"ANDROID_NDK": "/Users//Library/Android/sdk/ndk-bundle",
"TIZEN_SDK": "/Users//tizen-studio",
"WEBOS_SDK": "/Users//Library/webOS_TV_SDK",
- "KAIOS_SDK": "/Applications/Kaiosrt.app"
+ "KAIOS_SDK": "/Applications/KaiosSimulators"
},
"defaultTargets": {
"android": "Nexus_5X_API_26",
@@ -16,6 +16,7 @@
"tizen": "T-samsung-5.5-x86",
"tizenwatch": "W-5.5-circle-x86",
"tizenmobile": "mobile-5.5-x86",
- "webos": "emulator"
+ "webos": "emulator",
+ "kaios": "Kaiosrtv3.0_ubuntu"
}
}
diff --git a/packages/sdk-android/src/__tests__/runner.test.ts b/packages/sdk-android/src/__tests__/runner.test.ts
index c2aaa35674..a8e3766363 100644
--- a/packages/sdk-android/src/__tests__/runner.test.ts
+++ b/packages/sdk-android/src/__tests__/runner.test.ts
@@ -1,8 +1,11 @@
-import { getAndroidTargets } from '../deviceManager';
+import { getAndroidTargets, composeDevicesArray, connectToWifiDevice, checkForActiveEmulator } from '../deviceManager';
import { getAndroidDeviceToRunOn } from '../runner';
-import { createRnvContext, getContext } from '@rnv/core';
+import { createRnvContext, getContext, inquirerPrompt } from '@rnv/core';
+import net from 'net';
jest.mock('../deviceManager');
+jest.mock('@rnv/core');
+jest.mock('net');
beforeEach(() => {
createRnvContext();
@@ -13,6 +16,78 @@ afterEach(() => {
});
describe('getAndroidDeviceToRunOn', () => {
+ it('should fail if a device is provided but no active device exists', async () => {
+ //GIVEN
+ const ctx = getContext();
+ ctx.platform = 'android';
+ ctx.program.target = true;
+ ctx.program.device = 'device1';
+ ctx.runtime.target = 'defaultTarget';
+ const mockFoundDevice = { name: 'simulator1', isActive: false, udid: '', isDevice: false };
+
+ jest.mocked(getAndroidTargets).mockResolvedValue([mockFoundDevice]);
+
+ //WHEN
+ await expect(getAndroidDeviceToRunOn()).resolves.toBe(undefined);
+
+ //THEN
+ });
+ it('should fail if targetToConnectWiFi is not a valid IP address - npx rnv -p android -t -d ', async () => {
+ //GIVEN
+ const targetToConnectWiFi = 'invalidIPAdress';
+ const ctx = getContext();
+ ctx.platform = 'android';
+ ctx.program.target = true;
+ ctx.runtime.target = 'defaultTarget';
+ ctx.program.device = targetToConnectWiFi;
+ const mockFoundDevice = { name: 'simulator1', isActive: false, udid: '', isDevice: false };
+
+ net.isIP = jest.fn().mockReturnValue(false);
+
+ jest.mocked(getAndroidTargets).mockResolvedValue([mockFoundDevice]);
+
+ //WHEN
+ await expect(getAndroidDeviceToRunOn()).resolves.toBe(undefined);
+
+ //THEN
+ expect(connectToWifiDevice).not.toHaveBeenCalled();
+ });
+ it('should connect to WiFi device if targetToConnectWiFi is a string and a valid IP address', async () => {
+ //GIVEN
+ const targetToConnectWiFi = '192.168.0.1';
+ const ctx = getContext();
+ ctx.platform = 'android';
+ ctx.program.target = true;
+ ctx.runtime.target = 'defaultTarget';
+ ctx.program.device = targetToConnectWiFi;
+ net.isIP = jest.fn().mockReturnValue(true);
+
+ jest.mocked(connectToWifiDevice).mockResolvedValue(true);
+ const mockFoundDevice = { name: '192.168.0.1', isActive: true, udid: '', isDevice: true };
+ jest.mocked(getAndroidTargets).mockResolvedValue([mockFoundDevice]);
+ jest.mocked(checkForActiveEmulator).mockResolvedValue(mockFoundDevice);
+
+ //WHEN
+ const result = await getAndroidDeviceToRunOn();
+
+ //THEN
+ expect(connectToWifiDevice).toHaveBeenCalledWith(targetToConnectWiFi);
+ expect(result).toEqual(mockFoundDevice);
+ });
+ it('should return defaultTarget if it exists and -t is not specified', async () => {
+ //GIVEN
+ const ctx = getContext();
+ ctx.platform = 'android';
+ ctx.program.target = undefined;
+ ctx.runtime.target = 'defaultTarget';
+ const mockFoundDevice = { name: 'defaultTarget', isActive: true, udid: '', isDevice: false };
+
+ jest.mocked(getAndroidTargets).mockResolvedValue([mockFoundDevice]);
+
+ const result = await getAndroidDeviceToRunOn();
+ //THEN
+ expect(result).toEqual(mockFoundDevice);
+ });
it('should return found sim if target is provided and found - npx rnv -p android -t ', async () => {
//GIVEN
const ctx = getContext();
@@ -22,26 +97,44 @@ describe('getAndroidDeviceToRunOn', () => {
const mockFoundDevice = { name: 'existingTarget', isActive: true, udid: '' };
jest.mocked(getAndroidTargets).mockResolvedValueOnce([mockFoundDevice]);
//WHEN
- const result = await getAndroidDeviceToRunOn(ctx);
+ const result = await getAndroidDeviceToRunOn();
//THEN
expect(result).toEqual(mockFoundDevice);
});
- // it('should ask from devices and sims if target is not provided - npx rnv -p android', async () => {
- // //GIVEN
- // const ctx = getContext();
- // ctx.platform = 'android';
- // ctx.program.target = false;
- // ctx.runtime.target = 'defaultTarget';
- // const mockDevicesAndEmulators = [
- // { name: 'simulator1', udid: 'udid1', isActive: true },
- // { name: 'simulator2', udid: 'udid2', isActive: false },
- // // Add more mock targets as needed
- // ];
- // const { getAndroidTargets } = require('../deviceManager');
- // getAndroidTargets.mockResolvedValueOnce(mockDevicesAndEmulators);
- // //WHEN
-
- // // const result = await getAndroidDeviceToRunOn(ctx);
- // //THEN
- // });
+ it('should ask devices and sims if no target is specified and the available target list does not include defaultTarget - npx rnv -p android - npx rnv -p android', async () => {
+ //GIVEN
+ const ctx = getContext();
+ ctx.platform = 'android';
+ ctx.program.target = false;
+ ctx.runtime.target = 'defaultTarget';
+
+ const mockDevicesAndEmulators = [
+ { name: 'simulator1', udid: 'udid1', isActive: true },
+ { name: 'simulator2', udid: 'udid2', isActive: false },
+ ];
+
+ jest.mocked(getAndroidTargets).mockResolvedValue(mockDevicesAndEmulators);
+ jest.mocked(composeDevicesArray)
+ .mockReturnValueOnce([
+ {
+ key: 'simulator1',
+ name: 'simulator1',
+ value: 'simulator1',
+ icon: 'Phone 📱',
+ },
+ ])
+ .mockReturnValueOnce([
+ {
+ key: 'simulator2',
+ name: 'simulator2',
+ value: 'simulator2',
+ icon: 'Phone 📱',
+ },
+ ]);
+ jest.mocked(inquirerPrompt).mockResolvedValue({ chosenTarget: 'simulator1' });
+ //WHEN
+ const result = await getAndroidDeviceToRunOn();
+ //THEN
+ expect(result).toEqual(mockDevicesAndEmulators[0]);
+ });
});
diff --git a/packages/sdk-android/src/deviceManager.ts b/packages/sdk-android/src/deviceManager.ts
index f06e088a0d..814329a90e 100644
--- a/packages/sdk-android/src/deviceManager.ts
+++ b/packages/sdk-android/src/deviceManager.ts
@@ -21,10 +21,10 @@ import {
RnvContext,
waitForExecCLI,
inquirerPrompt,
- RnvPlatform,
executeAsync,
ExecOptionsPresets,
PlatformKey,
+ getContext,
} from '@rnv/core';
import { CLI_ANDROID_EMULATOR, CLI_ANDROID_ADB, CLI_ANDROID_AVDMANAGER, CLI_ANDROID_SDKMANAGER } from './constants';
@@ -55,10 +55,10 @@ const ERROR_MSG = {
};
export const launchAndroidSimulator = async (
- c: RnvContext,
target: true | { name: string } | string,
isIndependentThread = false
): Promise => {
+ const c = getContext();
logDefault(
'launchAndroidSimulator',
`target:${typeof target === 'object' ? target?.name : target} independentThread:${!!isIndependentThread}`
@@ -69,7 +69,7 @@ export const launchAndroidSimulator = async (
const {
program: { device },
} = c;
- const list = await getAndroidTargets(c, false, device, device);
+ const list = await getAndroidTargets(false, device, device);
const devicesString = composeDevicesArray(list);
const choices = devicesString;
@@ -89,7 +89,6 @@ export const launchAndroidSimulator = async (
if (isIndependentThread) {
executeAsync(
- c,
`${c.cli[CLI_ANDROID_EMULATOR]} -avd ${actualTarget}`,
ExecOptionsPresets.FIRE_AND_FORGET
).catch((err) => {
@@ -108,7 +107,6 @@ export const launchAndroidSimulator = async (
try {
await executeAsync(
- c,
`${c.cli[CLI_ANDROID_EMULATOR]} -avd ${actualTarget}`,
ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY
);
@@ -121,7 +119,7 @@ export const launchAndroidSimulator = async (
newTarget
)} does not exist. You can update it here: ${chalk().cyan(c.paths.GLOBAL_RNV_CONFIG)}`
);
- await launchAndroidSimulator(c, true, false);
+ await launchAndroidSimulator(true, false);
return true;
} else if (e.includes(ERROR_MSG.TARGET_EXISTS)) {
logToSummary(`Target with name ${chalk().red(newTarget)} already running. SKIPPING.`);
@@ -140,8 +138,8 @@ export const listAndroidTargets = async (c: RnvContext) => {
program: { device },
} = c;
- await resetAdb(c);
- const list = await getAndroidTargets(c, false, device, device);
+ await resetAdb();
+ const list = await getAndroidTargets(false, device, device);
const devices = await composeDevicesString(list);
logToSummary(`Android Targets:\n${devices}`);
if (typeof devices === 'string' && devices.trim() === '') {
@@ -188,15 +186,16 @@ const _getDeviceAsObject = (device: AndroidDevice): DeviceInfo => {
return { key: name, name: deviceString, value: name, icon: deviceIcon };
};
-export const resetAdb = async (c: RnvContext, forceRun?: boolean, ranBefore?: boolean) => {
+export const resetAdb = async (forceRun?: boolean, ranBefore?: boolean) => {
+ const c = getContext();
if (!c.program.resetAdb && !forceRun) return;
try {
- if (!ranBefore) await execCLI(c, CLI_ANDROID_ADB, 'kill-server');
+ if (!ranBefore) await execCLI(CLI_ANDROID_ADB, 'kill-server');
} catch (e) {
logWarning(e);
}
try {
- await execCLI(c, CLI_ANDROID_ADB, 'start-server');
+ await execCLI(CLI_ANDROID_ADB, 'start-server');
} catch (e) {
if (ranBefore) {
return Promise.reject(e);
@@ -206,7 +205,8 @@ export const resetAdb = async (c: RnvContext, forceRun?: boolean, ranBefore?: bo
}
};
-export const getAndroidTargets = async (c: RnvContext, skipDevices: boolean, skipAvds: boolean, deviceOnly = false) => {
+export const getAndroidTargets = async (skipDevices: boolean, skipAvds: boolean, deviceOnly = false) => {
+ const c = getContext();
logDefault('getAndroidTargets', `skipDevices:${!!skipDevices} skipAvds:${!!skipAvds} deviceOnly:${!!deviceOnly}`);
// Temp workaround for race conditions receiving devices with offline status
await new Promise((r) => setTimeout(r, 1000));
@@ -216,10 +216,10 @@ export const getAndroidTargets = async (c: RnvContext, skipDevices: boolean, ski
let avdResult: string | undefined;
if (!skipDevices) {
- devicesResult = await execCLI(c, CLI_ANDROID_ADB, 'devices -l');
+ devicesResult = await execCLI(CLI_ANDROID_ADB, 'devices -l');
}
if (!skipAvds) {
- avdResult = await execCLI(c, CLI_ANDROID_EMULATOR, '-list-avds');
+ avdResult = await execCLI(CLI_ANDROID_EMULATOR, '-list-avds');
}
return _parseDevicesResult(c, devicesResult, avdResult, deviceOnly);
} catch (e) {
@@ -234,13 +234,13 @@ const calculateDeviceDiagonal = (width: number, height: number, density: number)
return Math.sqrt(widthInches * widthInches + heightInches * heightInches);
};
-const getRunningDeviceProp = async (c: RnvContext, udid: string, prop: string): Promise => {
+const getRunningDeviceProp = async (udid: string, prop: string): Promise => {
// avoid multiple calls to the same device
if (currentDeviceProps[udid]) {
// if (!prop) return currentDeviceProps[udid];
return currentDeviceProps[udid][prop];
}
- const rawProps = await execCLI(c, CLI_ANDROID_ADB, `-s ${udid} shell getprop`);
+ const rawProps = await execCLI(CLI_ANDROID_ADB, `-s ${udid} shell getprop`);
const reg = /\[.+\]: \[.*\n?[^[]*\]/gm;
const lines = rawProps.match(reg);
@@ -255,20 +255,20 @@ const getRunningDeviceProp = async (c: RnvContext, udid: string, prop: string):
});
}
- return getRunningDeviceProp(c, udid, prop);
+ return getRunningDeviceProp(udid, prop);
};
const decideIfTVRunning = async (c: RnvContext, device: AndroidDevice) => {
const { udid, model, product } = device;
- const mod = await getRunningDeviceProp(c, udid, 'ro.product.model');
- const name = await getRunningDeviceProp(c, udid, 'ro.product.name');
- const flavor = await getRunningDeviceProp(c, udid, 'ro.build.flavor');
- const clientIdBase = await getRunningDeviceProp(c, udid, 'ro.com.google.clientidbase');
- const description = await getRunningDeviceProp(c, udid, 'ro.build.description');
- const hdmi = await getRunningDeviceProp(c, udid, 'init.svc.hdmi');
- const modelGroup = await getRunningDeviceProp(c, udid, 'ro.nrdp.modelgroup');
- const configuration = await getRunningDeviceProp(c, udid, 'ro.build.configuration');
- const cecEnabled = await getRunningDeviceProp(c, udid, 'persist.sys.cec.enabled');
+ const mod = await getRunningDeviceProp(udid, 'ro.product.model');
+ const name = await getRunningDeviceProp(udid, 'ro.product.name');
+ const flavor = await getRunningDeviceProp(udid, 'ro.build.flavor');
+ const clientIdBase = await getRunningDeviceProp(udid, 'ro.com.google.clientidbase');
+ const description = await getRunningDeviceProp(udid, 'ro.build.description');
+ const hdmi = await getRunningDeviceProp(udid, 'init.svc.hdmi');
+ const modelGroup = await getRunningDeviceProp(udid, 'ro.nrdp.modelgroup');
+ const configuration = await getRunningDeviceProp(udid, 'ro.build.configuration');
+ const cecEnabled = await getRunningDeviceProp(udid, 'persist.sys.cec.enabled');
let isTV = false;
[mod, name, flavor, clientIdBase, description, model, product].forEach((string) => {
@@ -286,11 +286,11 @@ const decideIfTVRunning = async (c: RnvContext, device: AndroidDevice) => {
const decideIfWearRunning = async (c: RnvContext, device: AndroidDevice) => {
const { udid, model, product } = device;
- const fingerprint = await getRunningDeviceProp(c, udid, 'ro.vendor.build.fingerprint');
- const name = await getRunningDeviceProp(c, udid, 'ro.product.vendor.name');
- const mod = await getRunningDeviceProp(c, udid, 'ro.product.vendor.model');
- const flavor = await getRunningDeviceProp(c, udid, 'ro.build.flavor');
- const description = await getRunningDeviceProp(c, udid, 'ro.build.description');
+ const fingerprint = await getRunningDeviceProp(udid, 'ro.vendor.build.fingerprint');
+ const name = await getRunningDeviceProp(udid, 'ro.product.vendor.name');
+ const mod = await getRunningDeviceProp(udid, 'ro.product.vendor.model');
+ const flavor = await getRunningDeviceProp(udid, 'ro.build.flavor');
+ const description = await getRunningDeviceProp(udid, 'ro.build.description');
let isWear = false;
[fingerprint, name, mod, flavor, description, model, product].forEach((string) => {
@@ -304,9 +304,9 @@ const getDeviceType = async (device: AndroidDevice, c: RnvContext) => {
logDebug('getDeviceType - in', { device });
if (device.udid !== 'unknown') {
- const screenSizeResult = await execCLI(c, CLI_ANDROID_ADB, `-s ${device.udid} shell wm size`);
- const screenDensityResult = await execCLI(c, CLI_ANDROID_ADB, `-s ${device.udid} shell wm density`);
- const arch = await getRunningDeviceProp(c, device.udid, 'ro.product.cpu.abi');
+ const screenSizeResult = await execCLI(CLI_ANDROID_ADB, `-s ${device.udid} shell wm size`);
+ const screenDensityResult = await execCLI(CLI_ANDROID_ADB, `-s ${device.udid} shell wm density`);
+ const arch = await getRunningDeviceProp(device.udid, 'ro.product.cpu.abi');
let screenProps = {
width: 0,
height: 0,
@@ -425,25 +425,25 @@ const getAvdDetails = (c: RnvContext, deviceName: string) => {
return results;
};
-const getEmulatorName = async (c: RnvContext, words: Array) => {
+const getEmulatorName = async (words: Array) => {
const emulator = words[0];
const port = emulator.split('-')[1];
- const emulatorReply = await executeTelnet(c, port, 'avd name');
+ const emulatorReply = await executeTelnet(port, 'avd name');
const emulatorReplyArray = emulatorReply.split('OK');
const emulatorNameStr = emulatorReplyArray[emulatorReplyArray.length - 2];
const emulatorName = emulatorNameStr?.trim?.() || '(err: could not parse emulator name)';
return emulatorName;
};
-export const connectToWifiDevice = async (c: RnvContext, target: string) => {
+export const connectToWifiDevice = async (target: string) => {
let connect_str = `connect ${target}`;
if (!target.includes(':')) {
connect_str = `connect ${target}:5555`;
}
- const deviceResponse = await execCLI(c, CLI_ANDROID_ADB, connect_str);
+ const deviceResponse = await execCLI(CLI_ANDROID_ADB, connect_str);
if (deviceResponse.includes('connected')) return true;
logError(`Failed to ${connect_str}`, false, true);
return false;
@@ -476,8 +476,8 @@ const _parseDevicesResult = async (
const product = _getDeviceProp(words, 'product:');
logDebug('_parseDevicesResult 4', { name });
if (!isDevice) {
- await waitForEmulatorToBeReady(c, words[0]);
- name = await getEmulatorName(c, words);
+ await waitForEmulatorToBeReady(words[0]);
+ name = await getEmulatorName(words);
logDebug('_parseDevicesResult 5', { name });
}
logDebug('_parseDevicesResult 6', {
@@ -583,7 +583,9 @@ const _getDeviceProp = (arr: Array, prop: string) => {
return '';
};
-export const askForNewEmulator = async (c: RnvContext, platform: RnvPlatform) => {
+export const askForNewEmulator = async () => {
+ const c = getContext();
+ const { platform } = c;
logDefault('askForNewEmulator');
if (!platform) return;
@@ -614,15 +616,15 @@ export const askForNewEmulator = async (c: RnvContext, platform: RnvPlatform) =>
switch (platform) {
case 'android':
return _createEmulator(c, sdk, 'google_apis', emuName, arch).then(() =>
- launchAndroidSimulator(c, emuLaunch, true)
+ launchAndroidSimulator(emuLaunch, true)
);
case 'androidtv':
return _createEmulator(c, sdk, 'android-tv', emuName, arch).then(() =>
- launchAndroidSimulator(c, emuLaunch, true)
+ launchAndroidSimulator(emuLaunch, true)
);
case 'androidwear':
return _createEmulator(c, sdk, 'android-wear', emuName, arch).then(() =>
- launchAndroidSimulator(c, emuLaunch, true)
+ launchAndroidSimulator(emuLaunch, true)
);
default:
return Promise.reject('Cannot find any active or created emulators');
@@ -634,10 +636,9 @@ export const askForNewEmulator = async (c: RnvContext, platform: RnvPlatform) =>
const _createEmulator = (c: RnvContext, apiVersion: string, emuPlatform: string, emuName: string, arch = 'x86') => {
logDefault('_createEmulator');
- return execCLI(c, CLI_ANDROID_SDKMANAGER, `"system-images;android-${apiVersion};${emuPlatform};${arch}"`)
+ return execCLI(CLI_ANDROID_SDKMANAGER, `"system-images;android-${apiVersion};${emuPlatform};${arch}"`)
.then(() =>
execCLI(
- c,
CLI_ANDROID_AVDMANAGER,
`create avd -n ${emuName} -k "system-images;android-${apiVersion};${emuPlatform};x86"`,
ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER
@@ -646,16 +647,17 @@ const _createEmulator = (c: RnvContext, apiVersion: string, emuPlatform: string,
.catch((e) => logError(e, true));
};
-const waitForEmulatorToBeReady = (c: RnvContext, emulator: string) =>
- waitForExecCLI(c, CLI_ANDROID_ADB, `-s ${emulator} shell getprop init.svc.bootanim`, (res) => {
+const waitForEmulatorToBeReady = (emulator: string) =>
+ waitForExecCLI(CLI_ANDROID_ADB, `-s ${emulator} shell getprop init.svc.bootanim`, (res) => {
if (typeof res === 'string') {
return res.includes('stopped');
}
return res;
});
-export const checkForActiveEmulator = (c: RnvContext, emulatorName?: string) =>
+export const checkForActiveEmulator = (emulatorName?: string) =>
new Promise((resolve, reject) => {
+ const c = getContext();
logDefault('checkForActiveEmulator');
const { platform } = c;
@@ -671,7 +673,7 @@ export const checkForActiveEmulator = (c: RnvContext, emulatorName?: string) =>
// Prevent the interval from running until enough promises return to make it stop or we get a result
if (!running) {
running = true;
- getAndroidTargets(c, false, true, false)
+ getAndroidTargets(false, true, false)
.then(async (v) => {
const simsOnly = v.filter((device) => !device.isDevice);
logDebug('Available devices after filtering', simsOnly);
@@ -689,7 +691,7 @@ export const checkForActiveEmulator = (c: RnvContext, emulatorName?: string) =>
attempts++;
const check: PlatformKey[] = ['androidtv', 'firetv', 'androidwear'];
if (check.includes(platform) && attempts === 2) {
- await resetAdb(c, true); // from time to time adb reports a recently started atv emu as being offline. Restarting adb fixes it
+ await resetAdb(true); // from time to time adb reports a recently started atv emu as being offline. Restarting adb fixes it
}
if (attempts > maxAttempts) {
clearInterval(poll);
diff --git a/packages/sdk-android/src/ejector.ts b/packages/sdk-android/src/ejector.ts
index f57fbda054..8caab11081 100644
--- a/packages/sdk-android/src/ejector.ts
+++ b/packages/sdk-android/src/ejector.ts
@@ -1,6 +1,5 @@
import path from 'path';
import {
- RnvContext,
fsExistsSync,
copyFileSync,
fsWriteFileSync,
@@ -10,16 +9,18 @@ import {
getConfigProp,
doResolvePath,
parsePlugins,
+ getContext,
} from '@rnv/core';
-export const ejectGradleProject = async (c: RnvContext) => {
- const isMonorepo = getConfigProp(c, c.platform, 'isMonorepo');
- const monoRoot = getConfigProp(c, c.platform, 'monoRoot');
+export const ejectGradleProject = async () => {
+ const c = getContext();
+ const isMonorepo = getConfigProp('isMonorepo');
+ const monoRoot = getConfigProp('monoRoot');
const rootMonoProjectPath = isMonorepo ? path.join(c.paths.project.dir, monoRoot || '../..') : c.paths.project.dir;
// const rootProjectPath = c.paths.project.dir;
- const appFolder = path.join(getAppFolder(c), '..');
+ const appFolder = path.join(getAppFolder(), '..');
//= ==========
// settings.gradle
@@ -113,7 +114,7 @@ export const ejectGradleProject = async (c: RnvContext) => {
const afterEvaluateFix: Array<{ match: string; replace: string }> = [];
- parsePlugins(c, c.platform, (_plugin, pluginPlat, key: string) => {
+ parsePlugins((_plugin, pluginPlat, key: string) => {
const pluginPath = doResolvePath(key);
if (!pluginPath) return;
diff --git a/packages/sdk-android/src/gradleParser.ts b/packages/sdk-android/src/gradleParser.ts
index 1c5ddf3c7f..88b84e0d28 100644
--- a/packages/sdk-android/src/gradleParser.ts
+++ b/packages/sdk-android/src/gradleParser.ts
@@ -10,6 +10,7 @@ import {
fsWriteFileSync,
getAppFolder,
getConfigProp,
+ getContext,
includesPluginPath,
isSystemWin,
logDebug,
@@ -24,9 +25,9 @@ import { getBuildFilePath, getAppId, getAppVersion, getAppVersionCode, addSystem
const currentOs = process.platform === 'darwin' ? 'osx' : process.platform === 'win32' ? 'win64' : 'linux64';
-export const parseBuildGradleSync = (c: Context) => {
- const appFolder = getAppFolder(c);
- const { platform } = c;
+export const parseBuildGradleSync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
let dexOptions = '';
@@ -126,15 +127,9 @@ export const parseBuildGradleSync = (c: Context) => {
}/sdks/hermesc/${currentOs}-bin/hermesc`,
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, platform, 'build.gradle'),
- path.join(appFolder, 'build.gradle'),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath('build.gradle'), path.join(appFolder, 'build.gradle'), injects, undefined, c);
};
const setReactNativeEngineDefault = (c: Context) => {
@@ -177,27 +172,26 @@ const setReactNativeEngineV8 = (c: Context) => {
exclude '**/libjsc.so'`;
};
-export const parseAppBuildGradleSync = (c: Context) => {
+export const parseAppBuildGradleSync = () => {
+ const c = getContext();
logDefault('parseAppBuildGradleSync');
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const { platform } = c;
if (!platform) return;
// ANDROID PROPS
- c.payload.pluginConfigAndroid.minSdkVersion = getConfigProp(c, platform, 'minSdkVersion') || 24;
- c.payload.pluginConfigAndroid.targetSdkVersion = getConfigProp(c, platform, 'targetSdkVersion') || 34;
- c.payload.pluginConfigAndroid.compileSdkVersion = getConfigProp(c, platform, 'compileSdkVersion') || 34;
- c.payload.pluginConfigAndroid.ndkVersion = getConfigProp(c, platform, 'ndkVersion') || '25.1.8937393';
- c.payload.pluginConfigAndroid.gradleBuildToolsVersion =
- getConfigProp(c, platform, 'gradleBuildToolsVersion') || '4.2.2';
- c.payload.pluginConfigAndroid.supportLibVersion = getConfigProp(c, platform, 'supportLibVersion') || '28.0.0';
- c.payload.pluginConfigAndroid.buildToolsVersion = getConfigProp(c, platform, 'buildToolsVersion') || '34.0.0';
- c.payload.pluginConfigAndroid.kotlinVersion = getConfigProp(c, platform, 'kotlinVersion') || '1.8.0';
- c.payload.pluginConfigAndroid.googleServicesVersion =
- getConfigProp(c, platform, 'googleServicesVersion') || '4.2.0';
-
- const reactNativeEngine = getConfigProp(c, c.platform, 'reactNativeEngine') || 'hermes';
+ c.payload.pluginConfigAndroid.minSdkVersion = getConfigProp('minSdkVersion') || 24;
+ c.payload.pluginConfigAndroid.targetSdkVersion = getConfigProp('targetSdkVersion') || 34;
+ c.payload.pluginConfigAndroid.compileSdkVersion = getConfigProp('compileSdkVersion') || 34;
+ c.payload.pluginConfigAndroid.ndkVersion = getConfigProp('ndkVersion') || '25.1.8937393';
+ c.payload.pluginConfigAndroid.gradleBuildToolsVersion = getConfigProp('gradleBuildToolsVersion') || '4.2.2';
+ c.payload.pluginConfigAndroid.supportLibVersion = getConfigProp('supportLibVersion') || '28.0.0';
+ c.payload.pluginConfigAndroid.buildToolsVersion = getConfigProp('buildToolsVersion') || '34.0.0';
+ c.payload.pluginConfigAndroid.kotlinVersion = getConfigProp('kotlinVersion') || '1.8.0';
+ c.payload.pluginConfigAndroid.googleServicesVersion = getConfigProp('googleServicesVersion') || '4.2.0';
+
+ const reactNativeEngine = getConfigProp('reactNativeEngine') || 'hermes';
switch (reactNativeEngine) {
case 'jsc': {
@@ -243,11 +237,11 @@ export const parseAppBuildGradleSync = (c: Context) => {
release`;
c.payload.pluginConfigAndroid.localProperties = '';
- const storeFile = getConfigProp(c, c.platform, 'storeFile');
- const keyAlias = getConfigProp(c, c.platform, 'keyAlias');
- const storePassword = getConfigProp(c, c.platform, 'storePassword');
- const keyPassword = getConfigProp(c, c.platform, 'keyPassword');
- const minifyEnabled = getConfigProp(c, c.platform, 'minifyEnabled', false);
+ const storeFile = getConfigProp('storeFile');
+ const keyAlias = getConfigProp('keyAlias');
+ const storePassword = getConfigProp('storePassword');
+ const keyPassword = getConfigProp('keyPassword');
+ const minifyEnabled = getConfigProp('minifyEnabled', false);
c.payload.pluginConfigAndroid.store = {
storeFile: storeFile,
@@ -312,12 +306,12 @@ ${chalk().bold(c.paths.workspace?.appConfig?.configsPrivate?.join('\n'))}`);
}
// BUILD_TYPES
- const templateAndroid = getConfigProp(c, c.platform, 'templateAndroid');
+ const templateAndroid = getConfigProp('templateAndroid');
// const pluginConfig = c.buildConfig ?? {};
const appBuildGradle = templateAndroid?.app_build_gradle;
const debugBuildTypes = appBuildGradle?.buildTypes?.debug ?? [];
const releaseBuildTypes: string[] = appBuildGradle?.buildTypes?.release ?? [];
- const isSigningDisabled = getConfigProp(c, platform, 'disableSigning') === true;
+ const isSigningDisabled = getConfigProp('disableSigning') === true;
c.payload.pluginConfigAndroid.buildTypes = `
debug {
minifyEnabled ${minifyEnabled}
@@ -332,8 +326,8 @@ ${chalk().bold(c.paths.workspace?.appConfig?.configsPrivate?.join('\n'))}`);
}`;
// MULTI APK
- // const versionCodeOffset = getConfigProp(c, platform, 'versionCodeOffset', 0);
- const isMultiApk = getConfigProp(c, platform, 'multipleAPKs', false) === true;
+ // const versionCodeOffset = getConfigProp('versionCodeOffset', 0);
+ const isMultiApk = getConfigProp('multipleAPKs', false) === true;
c.payload.pluginConfigAndroid.multiAPKs = '';
if (isMultiApk) {
// TODO migrate this to gradle.properties + it's enabled by default
@@ -395,14 +389,14 @@ ${chalk().bold(c.paths.workspace?.appConfig?.configsPrivate?.join('\n'))}`);
pattern: '{{PLUGIN_APPLY}}',
override: c.payload.pluginConfigAndroid.applyPlugin,
},
- { pattern: '{{APPLICATION_ID}}', override: getAppId(c, platform) },
+ { pattern: '{{APPLICATION_ID}}', override: getAppId() },
{
pattern: '{{VERSION_CODE}}',
- override: getAppVersionCode(c, platform),
+ override: getAppVersionCode(),
},
{
pattern: '{{VERSION_NAME}}',
- override: getAppVersion(c, platform),
+ override: getAppVersion(),
},
{
pattern: '{{PLUGIN_IMPLEMENTATIONS}}',
@@ -489,9 +483,9 @@ ${chalk().bold(c.paths.workspace?.appConfig?.configsPrivate?.join('\n'))}`);
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(
- getBuildFilePath(c, platform, 'app/build.gradle'),
+ getBuildFilePath('app/build.gradle'),
path.join(appFolder, 'app/build.gradle'),
injects,
undefined,
@@ -499,10 +493,9 @@ ${chalk().bold(c.paths.workspace?.appConfig?.configsPrivate?.join('\n'))}`);
);
};
-export const parseSettingsGradleSync = (c: Context) => {
- const appFolder = getAppFolder(c);
- const { platform } = c;
-
+export const parseSettingsGradleSync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const rnCliLocation = doResolve('@react-native-community/cli-platform-android', true, { forceForwardPaths: true });
const rnGradlePluginLocation = doResolve('@react-native/gradle-plugin', true, { forceForwardPaths: true });
@@ -533,26 +526,21 @@ export const parseSettingsGradleSync = (c: Context) => {
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, platform, 'settings.gradle'),
- path.join(appFolder, 'settings.gradle'),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath('settings.gradle'), path.join(appFolder, 'settings.gradle'), injects, undefined, c);
};
-export const parseGradlePropertiesSync = (c: Context) => {
- const appFolder = getAppFolder(c);
+export const parseGradlePropertiesSync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const { platform } = c;
if (!platform) return;
// GRADLE.PROPERTIES
let pluginGradleProperties = '';
- const templateAndroid = getConfigProp(c, c.platform, 'templateAndroid');
+ const templateAndroid = getConfigProp('templateAndroid');
const gradleProps = templateAndroid?.gradle_properties;
@@ -564,8 +552,8 @@ export const parseGradlePropertiesSync = (c: Context) => {
const gradleProperties = 'gradle.properties';
- const newArchEnabled = getConfigProp(c, c.platform, 'newArchEnabled', false);
- const reactNativeEngine = getConfigProp(c, c.platform, 'reactNativeEngine') || 'hermes';
+ const newArchEnabled = getConfigProp('newArchEnabled', false);
+ const reactNativeEngine = getConfigProp('reactNativeEngine') || 'hermes';
const injects = [
{
@@ -582,31 +570,20 @@ export const parseGradlePropertiesSync = (c: Context) => {
},
{
pattern: '{{ENABLE_JETIFIER}}',
- override: getConfigProp(c, platform, 'enableJetifier', true) ? 'true' : 'false',
+ override: getConfigProp('enableJetifier', true) ? 'true' : 'false',
},
{
pattern: '{{ENABLE_ANDROID_X}}',
- override: getConfigProp(c, platform, 'enableAndroidX', true) ? 'true' : 'false',
+ override: getConfigProp('enableAndroidX', true) ? 'true' : 'false',
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, platform, gradleProperties),
- path.join(appFolder, gradleProperties),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath(gradleProperties), path.join(appFolder, gradleProperties), injects, undefined, c);
};
-export const injectPluginGradleSync = (
- c: Context,
- pluginRoot: RnvPlugin,
- plugin: RenativeConfigPluginPlatform,
- key: string
-) => {
+export const injectPluginGradleSync = (pluginRoot: RnvPlugin, plugin: RenativeConfigPluginPlatform, key: string) => {
// const keyFixed = key.replace(/\//g, '-').replace(/@/g, '');
// const packagePath = plugin.path ?? `${key}/android`;
// let pathAbsolute;
@@ -626,6 +603,7 @@ export const injectPluginGradleSync = (
// if (plugin.packageParams) {
// packageParams = plugin.packageParams.join(',');
// }
+ const c = getContext();
const pathFixed = plugin.path ? `${plugin.path}` : `${key}/android`;
const skipPathResolutions = pluginRoot.disableNpm;
let pathAbsolute;
@@ -643,15 +621,16 @@ export const injectPluginGradleSync = (
c.payload.pluginConfigAndroid.appBuildGradleImplementations += `${plugin.implementation}\n`;
}
- parseAndroidConfigObject(c, plugin, key);
+ parseAndroidConfigObject(plugin, key);
if (!skipPathResolutions && pathAbsolute) {
_fixAndroidLegacy(c, pathAbsolute);
}
};
-export const parseAndroidConfigObject = (c: RnvContext, plugin?: RenativeConfigPluginPlatform, key = '') => {
+export const parseAndroidConfigObject = (plugin?: RenativeConfigPluginPlatform, key = '') => {
// APP/BUILD.GRADLE
+ const c = getContext();
const templateAndroid = plugin?.templateAndroid;
const appBuildGradle = templateAndroid?.app_build_gradle;
diff --git a/packages/sdk-android/src/gradleWrapperParser.ts b/packages/sdk-android/src/gradleWrapperParser.ts
index 6db4ff4bb8..6c39dbb265 100644
--- a/packages/sdk-android/src/gradleWrapperParser.ts
+++ b/packages/sdk-android/src/gradleWrapperParser.ts
@@ -7,15 +7,15 @@ import {
copyFolderContentsRecursiveSync,
fsChmodSync,
DEFAULTS,
+ getContext,
} from '@rnv/core';
-import { Context } from './types';
import { addSystemInjects, getBuildFilePath } from '@rnv/sdk-utils';
const GRADLE_SOURCE_PATH = path.join(__dirname, '../templates/gradleProject');
-const copyGradleProjectTemplate = async (c: Context) => {
+const copyGradleProjectTemplate = async () => {
logDefault('copyGradleProjectTemplate');
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
copyFolderContentsRecursiveSync(GRADLE_SOURCE_PATH, appFolder);
@@ -24,26 +24,26 @@ const copyGradleProjectTemplate = async (c: Context) => {
fsChmodSync(gradlew, '755');
};
-export const parseGradleWrapperSync = (c: Context) => {
+export const parseGradleWrapperSync = () => {
+ const c = getContext();
logDefault('parseGradleWrapperSync');
- copyGradleProjectTemplate(c);
+ copyGradleProjectTemplate();
- const appFolder = getAppFolder(c);
- const { platform } = c;
+ const appFolder = getAppFolder();
c.payload.pluginConfigAndroid.gradleWrapperVersion =
- getConfigProp(c, platform, 'gradleWrapperVersion') || DEFAULTS.gradleWrapperVersion;
+ getConfigProp('gradleWrapperVersion') || DEFAULTS.gradleWrapperVersion;
const injects = [
{
pattern: '{{INJECT_GRADLE_WRAPPER_VERSION}}',
override: c.payload.pluginConfigAndroid.gradleWrapperVersion,
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(
- getBuildFilePath(c, platform, 'gradle/wrapper/gradle-wrapper.properties', GRADLE_SOURCE_PATH),
+ getBuildFilePath('gradle/wrapper/gradle-wrapper.properties', GRADLE_SOURCE_PATH),
path.join(appFolder, 'gradle/wrapper/gradle-wrapper.properties'),
injects,
undefined,
diff --git a/packages/sdk-android/src/installer.ts b/packages/sdk-android/src/installer.ts
index 54195d0cfb..3d88a0365f 100644
--- a/packages/sdk-android/src/installer.ts
+++ b/packages/sdk-android/src/installer.ts
@@ -17,6 +17,7 @@ import {
RnvContext,
inquirerPrompt,
ConfigFileWorkspace,
+ getContext,
} from '@rnv/core';
import { CLI_ANDROID_EMULATOR, CLI_ANDROID_ADB, CLI_ANDROID_AVDMANAGER, CLI_ANDROID_SDKMANAGER } from './constants';
@@ -49,32 +50,27 @@ const _logSdkWarning = (c: RnvContext) => {
logWarning(`Your ${c.paths.workspace.config} is missing SDK configuration object`);
};
-export const checkAndConfigureAndroidSdks = async (c: RnvContext) => {
+export const checkAndConfigureAndroidSdks = async () => {
+ const c = getContext();
const sdk = c.buildConfig?.sdks?.ANDROID_SDK;
logDefault('checkAndConfigureAndroidSdks', `(${sdk})`);
if (!sdk) return _logSdkWarning(c);
- let sdkManagerPath = getRealPath(
- c,
- path.join(sdk, `cmdline-tools/latest/bin/sdkmanager${isSystemWin ? '.bat' : ''}`)
- );
+ let sdkManagerPath = getRealPath(path.join(sdk, `cmdline-tools/latest/bin/sdkmanager${isSystemWin ? '.bat' : ''}`));
if (!fsExistsSync(sdkManagerPath)) {
- sdkManagerPath = getRealPath(c, path.join(sdk, `tools/bin/sdkmanager${isSystemWin ? '.bat' : ''}`));
+ sdkManagerPath = getRealPath(path.join(sdk, `tools/bin/sdkmanager${isSystemWin ? '.bat' : ''}`));
}
- let avdManagerPath = getRealPath(
- c,
- path.join(sdk, `cmdline-tools/latest/bin/avdmanager${isSystemWin ? '.bat' : ''}`)
- );
+ let avdManagerPath = getRealPath(path.join(sdk, `cmdline-tools/latest/bin/avdmanager${isSystemWin ? '.bat' : ''}`));
if (!fsExistsSync(avdManagerPath)) {
- avdManagerPath = getRealPath(c, path.join(sdk, `tools/bin/avdmanager${isSystemWin ? '.bat' : ''}`));
+ avdManagerPath = getRealPath(path.join(sdk, `tools/bin/avdmanager${isSystemWin ? '.bat' : ''}`));
}
- c.cli[CLI_ANDROID_EMULATOR] = getRealPath(c, path.join(sdk, `emulator/emulator${isSystemWin ? '.exe' : ''}`));
- c.cli[CLI_ANDROID_ADB] = getRealPath(c, path.join(sdk, `platform-tools/adb${isSystemWin ? '.exe' : ''}`));
+ c.cli[CLI_ANDROID_EMULATOR] = getRealPath(path.join(sdk, `emulator/emulator${isSystemWin ? '.exe' : ''}`));
+ c.cli[CLI_ANDROID_ADB] = getRealPath(path.join(sdk, `platform-tools/adb${isSystemWin ? '.exe' : ''}`));
c.cli[CLI_ANDROID_AVDMANAGER] = avdManagerPath;
c.cli[CLI_ANDROID_SDKMANAGER] = sdkManagerPath;
};
@@ -88,7 +84,7 @@ const _isSdkInstalled = (c: RnvContext) => {
const sdkPath = _getCurrentSdkPath(c);
- return fsExistsSync(getRealPath(c, sdkPath));
+ return fsExistsSync(getRealPath(sdkPath));
};
const _findFolderWithFile = (dir: string, fileToFind: string) => {
@@ -158,8 +154,8 @@ const _attemptAutoFix = async (c: RnvContext, sdkPlatform: string, sdkKey: SDKKe
if (!c.files.workspace.config?.sdks) c.files.workspace.config.sdks = {};
c.files.workspace.config.sdks[sdkKey] = result;
writeFileSync(c.paths.workspace.config, c.files.workspace.config);
- generateBuildConfig(c);
- await checkAndConfigureAndroidSdks(c);
+ generateBuildConfig();
+ await checkAndConfigureAndroidSdks();
} catch (e) {
logError(e);
}
@@ -172,11 +168,12 @@ const _attemptAutoFix = async (c: RnvContext, sdkPlatform: string, sdkKey: SDKKe
// const setupInstance = PlatformSetup(c);
// await setupInstance.askToInstallSDK(sdkPlatform);
- generateBuildConfig(c);
+ generateBuildConfig();
return true;
};
-export const checkAndroidSdk = async (c: RnvContext) => {
+export const checkAndroidSdk = async () => {
+ const c = getContext();
logDefault('checkAndroidSdk');
if (!_isSdkInstalled(c)) {
logWarning(
@@ -196,7 +193,7 @@ export const checkAndroidSdk = async (c: RnvContext) => {
return true;
}
} else {
- await checkAndConfigureAndroidSdks(c);
+ await checkAndConfigureAndroidSdks();
}
return true;
};
diff --git a/packages/sdk-android/src/kotlinParser.ts b/packages/sdk-android/src/kotlinParser.ts
index 1a29b03cc5..d025a4d0a4 100644
--- a/packages/sdk-android/src/kotlinParser.ts
+++ b/packages/sdk-android/src/kotlinParser.ts
@@ -4,11 +4,10 @@ import {
RnvContext,
getAppFolder,
getConfigProp,
+ getContext,
writeCleanFile,
} from '@rnv/core';
-import { mkdirSync } from 'fs';
import path from 'path';
-import { Context } from './types';
import { getBuildFilePath, getEntryFile, getAppId, addSystemInjects } from '@rnv/sdk-utils';
// const JS_BUNDLE_DEFAULTS: Partial> = {
@@ -16,35 +15,36 @@ import { getBuildFilePath, getEntryFile, getAppId, addSystemInjects } from '@rnv
// androidwear: '"assets://index.androidwear.bundle"',
// };
-export const parseFlipperSync = (c: Context, scheme: 'debug' | 'release') => {
- const appFolder = getAppFolder(c);
- const { platform } = c;
+// export const parseFlipperSync = (c: Context, scheme: 'debug' | 'release') => {
+// const appFolder = getAppFolder();
+// const { platform } = c;
- const appId = getAppId(c, c.platform);
- // console.log('appId', appId);
- const javaPackageArray = appId?.split('.') || [];
+// const appId = getAppId(c, c.platform);
+// // console.log('appId', appId);
+// const javaPackageArray = appId?.split('.') || [];
- const javaPackagePath = `app/src/${scheme}/java/${javaPackageArray.join('/')}`;
- mkdirSync(path.join(appFolder, javaPackagePath), { recursive: true });
+// const javaPackagePath = `app/src/${scheme}/java/${javaPackageArray.join('/')}`;
+// mkdirSync(path.join(appFolder, javaPackagePath), { recursive: true });
- const templatePath = `app/src/${scheme}/java/rnv_template/ReactNativeFlipper.kt`;
- const applicationPath = `${javaPackagePath}/ReactNativeFlipper.java`;
+// const templatePath = `app/src/${scheme}/java/rnv_template/ReactNativeFlipper.kt`;
+// const applicationPath = `${javaPackagePath}/ReactNativeFlipper.java`;
- const injects: OverridesOptions = [{ pattern: '{{APPLICATION_ID}}', override: getAppId(c, platform) }];
+// const injects: OverridesOptions = [{ pattern: '{{APPLICATION_ID}}', override: getAppId() }];
- addSystemInjects(c, injects);
+// addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, platform, templatePath),
- path.join(appFolder, applicationPath),
- injects,
- undefined,
- c
- );
-};
+// writeCleanFile(
+// getBuildFilePath(templatePath),
+// path.join(appFolder, applicationPath),
+// injects,
+// undefined,
+// c
+// );
+// };
-export const parseMainApplicationSync = (c: Context) => {
- const appFolder = getAppFolder(c);
+export const parseMainApplicationSync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const { platform } = c;
if (!platform) return;
@@ -58,7 +58,7 @@ export const parseMainApplicationSync = (c: Context) => {
const templatePath = 'app/src/main/java/rnv_template/MainApplication.kt';
// const applicationPath = `${javaPackagePath}/MainApplication.java`;
- // const bundleAssets = getConfigProp(c, platform, 'bundleAssets');
+ // const bundleAssets = getConfigProp('bundleAssets');
// const bundleDefault = JS_BUNDLE_DEFAULTS[platform];
// const bundleFile: string =
@@ -73,8 +73,8 @@ export const parseMainApplicationSync = (c: Context) => {
// }
const injects: OverridesOptions = [
- { pattern: '{{APPLICATION_ID}}', override: getAppId(c, platform) },
- { pattern: '{{ENTRY_FILE}}', override: getEntryFile(c, platform) || '' },
+ { pattern: '{{APPLICATION_ID}}', override: getAppId() },
+ { pattern: '{{ENTRY_FILE}}', override: getEntryFile() || '' },
// { pattern: '{{GET_JS_BUNDLE_FILE}}', override: bundleFile },
{
pattern: '{{PLUGIN_IMPORTS}}',
@@ -102,32 +102,26 @@ export const parseMainApplicationSync = (c: Context) => {
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, platform, templatePath),
- path.join(appFolder, templatePath),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath(templatePath), path.join(appFolder, templatePath), injects, undefined, c);
};
-export const parseMainActivitySync = (c: RnvContext) => {
- const appFolder = getAppFolder(c);
- const { platform } = c;
+export const parseMainActivitySync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const templatePath = 'app/src/main/java/rnv_template/MainActivity.kt';
- const templateAndroid = getConfigProp(c, platform, 'templateAndroid', {});
+ const templateAndroid = getConfigProp('templateAndroid', {});
- const mainActivity = templateAndroid?.MainActivity_java;
+ const mainActivity = templateAndroid?.MainActivity_kt;
c.payload.pluginConfigAndroid.injectActivityOnCreate =
mainActivity?.onCreate || 'super.onCreate(savedInstanceState)';
const injects = [
- { pattern: '{{APPLICATION_ID}}', override: getAppId(c, platform) },
+ { pattern: '{{APPLICATION_ID}}', override: getAppId() },
{
pattern: '{{PLUGIN_ACTIVITY_IMPORTS}}',
override: c.payload.pluginConfigAndroid.pluginActivityImports,
@@ -150,25 +144,19 @@ export const parseMainActivitySync = (c: RnvContext) => {
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, platform, templatePath),
- path.join(appFolder, templatePath),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath(templatePath), path.join(appFolder, templatePath), injects, undefined, c);
};
-export const parseSplashActivitySync = (c: Context) => {
- const appFolder = getAppFolder(c);
- const { platform } = c;
+export const parseSplashActivitySync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const splashTemplatePath = 'app/src/main/java/rnv_template/SplashActivity.kt';
// TODO This is temporary ANDROIDX support. whole kotlin parser will be refactored in the near future
- const enableAndroidX = getConfigProp(c, platform, 'enableAndroidX', true);
+ const enableAndroidX = getConfigProp('enableAndroidX', true);
if (enableAndroidX === true) {
c.payload.pluginConfigAndroid.pluginSplashActivityImports +=
'import androidx.appcompat.app.AppCompatActivity;\n';
@@ -178,17 +166,17 @@ export const parseSplashActivitySync = (c: Context) => {
}
const injects = [
- { pattern: '{{APPLICATION_ID}}', override: getAppId(c, platform) },
+ { pattern: '{{APPLICATION_ID}}', override: getAppId() },
{
pattern: '{{PLUGIN_SPLASH_ACTIVITY_IMPORTS}}',
override: c.payload.pluginConfigAndroid.pluginSplashActivityImports,
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(
- getBuildFilePath(c, platform, splashTemplatePath),
+ getBuildFilePath(splashTemplatePath),
path.join(appFolder, splashTemplatePath),
injects,
undefined,
@@ -196,14 +184,10 @@ export const parseSplashActivitySync = (c: Context) => {
);
};
-export const injectPluginKotlinSync = (
- c: RnvContext,
- plugin: RenativeConfigPluginPlatform,
- key: string,
- pkg: string | undefined
-) => {
+export const injectPluginKotlinSync = (plugin: RenativeConfigPluginPlatform, key: string, pkg: string | undefined) => {
+ const c = getContext();
const templ = plugin.templateAndroid;
- const mainActivity = templ?.MainActivity_java;
+ const mainActivity = templ?.MainActivity_kt;
if (mainActivity?.imports) {
mainActivity.imports.forEach((activityImport) => {
// Avoid duplicate imports
@@ -232,7 +216,7 @@ export const injectPluginKotlinSync = (
_injectPackage(c, plugin, pkg);
- const mainApplication = templ?.MainApplication_java;
+ const mainApplication = templ?.MainApplication_kt;
if (mainApplication?.packages) {
mainApplication.packages.forEach((v) => {
@@ -264,7 +248,7 @@ const _injectPackage = (c: RnvContext, plugin: RenativeConfigPluginPlatform, pkg
c.payload.pluginConfigAndroid.pluginApplicationImports += `import ${pkg}\n`;
}
let packageParams = '';
- const mainApplication = plugin.templateAndroid?.MainApplication_java;
+ const mainApplication = plugin.templateAndroid?.MainApplication_kt;
if (mainApplication?.packageParams) {
packageParams = mainApplication.packageParams.join(',');
}
diff --git a/packages/sdk-android/src/manifestParser.ts b/packages/sdk-android/src/manifestParser.ts
index 280db670a3..ebaa9dcc2b 100644
--- a/packages/sdk-android/src/manifestParser.ts
+++ b/packages/sdk-android/src/manifestParser.ts
@@ -18,6 +18,7 @@ import {
ConfigProp,
_getConfigProp,
ConfigFileBuildConfig,
+ getContext,
} from '@rnv/core';
import { Context } from './types';
import { getBuildFilePath, getAppId, addSystemInjects } from '@rnv/sdk-utils';
@@ -114,7 +115,7 @@ const _mergeNodeParameters = (
const key = k as NodeKey;
const val = nodeParamsExt[key];
- if (val && !SYSTEM_TAGS.includes(k)) {
+ if (val !== 'undefined' && !SYSTEM_TAGS.includes(k)) {
//TODO: fix this
(node as Record)[key] = val;
}
@@ -161,7 +162,7 @@ const _mergeFeatures = (
configKey: 'includedFeatures' | 'excludedFeatures',
value: boolean
) => {
- const features = getConfigProp(c, c.platform, configKey);
+ const features = getConfigProp(configKey);
if (features) {
const featuresObj: Array = [];
@@ -202,7 +203,7 @@ const getConfigPropArray = (c: RnvContext, platform: Rn
configArr.forEach((config) => {
if (config) {
//TODO: this is bit of a hack. _getConfigProp expectes already merged obj needs to be redone
- const val = _getConfigProp(c, platform, key, null, config as ConfigFileBuildConfig);
+ const val = _getConfigProp(c, key, null, config as ConfigFileBuildConfig);
if (val) {
result.push(val);
}
@@ -212,7 +213,8 @@ const getConfigPropArray = (c: RnvContext, platform: Rn
return result;
};
-export const parseAndroidManifestSync = (c: Context) => {
+export const parseAndroidManifestSync = () => {
+ const c = getContext();
logDefault('parseAndroidManifestSync');
const { platform } = c;
@@ -226,7 +228,7 @@ export const parseAndroidManifestSync = (c: Context) => {
return;
}
- baseManifestFile.package = getAppId(c, platform);
+ baseManifestFile.package = getAppId();
const objArr = getConfigPropArray(c, c.platform, 'templateAndroid');
@@ -240,11 +242,10 @@ export const parseAndroidManifestSync = (c: Context) => {
_mergeNodeChildren(baseManifestFile, manifestObj.children);
}
});
- //TODO: Should be mark as deprecated
// appConfigs/base/plugins.json PLUGIN CONFIG OVERRIDES
- parsePlugins(c, platform, (_plugin, pluginPlat) => {
- const androidManifestPlugin = getFlavouredProp(c, pluginPlat, 'templateAndroid')?.AndroidManifest_xml;
+ parsePlugins((_plugin, pluginPlat) => {
+ const androidManifestPlugin = getFlavouredProp(pluginPlat, 'templateAndroid')?.AndroidManifest_xml;
if (androidManifestPlugin) {
_mergeNodeChildren(baseManifestFile, androidManifestPlugin.children);
if (androidManifestPlugin.children) {
@@ -256,8 +257,8 @@ export const parseAndroidManifestSync = (c: Context) => {
// appConfig PERMISSIONS OVERRIDES
const configPermissions = c.buildConfig?.permissions;
- const includedPermissions = getConfigProp(c, platform, 'includedPermissions');
- const excludedPermissions = getConfigProp(c, platform, 'excludedPermissions');
+ const includedPermissions = getConfigProp('includedPermissions');
+ const excludedPermissions = getConfigProp('excludedPermissions');
if (includedPermissions?.forEach && configPermissions) {
const platPerm = 'android'; //configPermissions[platform] ? platform : 'android';
const pc = configPermissions[platPerm];
@@ -299,17 +300,11 @@ export const parseAndroidManifestSync = (c: Context) => {
const manifestFile = 'app/src/main/AndroidManifest.xml';
const injects = [{ pattern: '{{PLUGIN_MANIFEST_FILE}}', override: manifestXml || '' }];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
- writeCleanFile(
- getBuildFilePath(c, platform, manifestFile),
- path.join(appFolder, manifestFile),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath(manifestFile), path.join(appFolder, manifestFile), injects, undefined, c);
return;
} catch (e) {
diff --git a/packages/sdk-android/src/runner.ts b/packages/sdk-android/src/runner.ts
index e22e01faa3..4b6e6cb87d 100644
--- a/packages/sdk-android/src/runner.ts
+++ b/packages/sdk-android/src/runner.ts
@@ -30,6 +30,7 @@ import {
RnvPlatform,
logInfo,
PlatformKey,
+ getContext,
} from '@rnv/core';
import { parseAndroidManifestSync, injectPluginManifestSync } from './manifestParser';
import {
@@ -49,7 +50,7 @@ import {
import { parseGradleWrapperSync } from './gradleWrapperParser';
import { parseValuesStringsSync, injectPluginXmlValuesSync, parseValuesColorsSync } from './xmlValuesParser';
import { ejectGradleProject } from './ejector';
-import { AndroidDevice, Context } from './types';
+import { AndroidDevice, Context, Payload } from './types';
import {
resetAdb,
getAndroidTargets,
@@ -63,29 +64,30 @@ import { CLI_ANDROID_ADB } from './constants';
import { runReactNativeAndroid, packageReactNativeAndroid } from '@rnv/sdk-react-native';
import { getEntryFile } from '@rnv/sdk-utils';
-export const packageAndroid = async (c: Context) => {
+export const packageAndroid = async () => {
logDefault('packageAndroid');
- return packageReactNativeAndroid(c);
+ return packageReactNativeAndroid();
};
-export const getAndroidDeviceToRunOn = async (c: Context) => {
+export const getAndroidDeviceToRunOn = async () => {
+ const c = getContext();
+
const defaultTarget = c.runtime.target;
logDefault('getAndroidDeviceToRunOn', `default:${defaultTarget}`);
if (!c.platform) return;
const { target, device } = c.program;
- const { platform } = c;
- await resetAdb(c);
+ await resetAdb();
const targetToConnectWiFi = _isString(target) ? target : device;
if (_isString(targetToConnectWiFi) && net.isIP(targetToConnectWiFi.split(':')[0])) {
- await connectToWifiDevice(c, targetToConnectWiFi);
+ await connectToWifiDevice(targetToConnectWiFi);
}
- const devicesAndEmulators = await getAndroidTargets(c, false, false, !!device);
+ const devicesAndEmulators = await getAndroidTargets(false, false, !!device);
const activeDevices = devicesAndEmulators.filter((d) => d.isActive);
const inactiveDevices = devicesAndEmulators.filter((d) => !d.isActive);
@@ -134,16 +136,16 @@ export const getAndroidDeviceToRunOn = async (c: Context) => {
const dev = activeDevices.find((d) => d.name === chosenTarget);
if (dev) return dev;
- await launchAndroidSimulator(c, chosenTarget, true);
- const device = await checkForActiveEmulator(c, chosenTarget);
+ await launchAndroidSimulator(chosenTarget, true);
+ const device = await checkForActiveEmulator(chosenTarget);
return device;
}
} else {
if (c.program.device) {
return logError('No active devices found, please connect one or remove the device argument', true);
}
- await askForNewEmulator(c, platform);
- const device = await checkForActiveEmulator(c);
+ await askForNewEmulator();
+ const device = await checkForActiveEmulator();
return device;
}
};
@@ -154,8 +156,8 @@ export const getAndroidDeviceToRunOn = async (c: Context) => {
if (foundDevice.isActive) {
return foundDevice;
}
- await launchAndroidSimulator(c, foundDevice, true);
- const device = await checkForActiveEmulator(c, foundDevice.name);
+ await launchAndroidSimulator(foundDevice, true);
+ const device = await checkForActiveEmulator(foundDevice.name);
return device;
}
logDebug('Target not found, asking where to run');
@@ -171,8 +173,8 @@ export const getAndroidDeviceToRunOn = async (c: Context) => {
logDebug('Target not provided, asking where to run');
return askWhereToRun();
} else if (!foundDevice.isActive) {
- await launchAndroidSimulator(c, foundDevice, true);
- const device = await checkForActiveEmulator(c, foundDevice.name);
+ await launchAndroidSimulator(foundDevice, true);
+ const device = await checkForActiveEmulator(foundDevice.name);
return device;
}
return foundDevice;
@@ -183,18 +185,15 @@ export const getAndroidDeviceToRunOn = async (c: Context) => {
}
};
-export const runAndroid = async (c: Context, device: AndroidDevice) => {
+export const runAndroid = async (device: AndroidDevice) => {
logDefault('runAndroid', `target:${device.udid}`);
- const { platform } = c;
-
- if (!platform) return;
- await runReactNativeAndroid(c, platform, device);
+ await runReactNativeAndroid(device);
};
const _checkSigningCerts = async (c: Context) => {
logDefault('_checkSigningCerts');
- const signingConfig = getConfigProp(c, c.platform, 'signingConfig', 'Debug');
+ const signingConfig = getConfigProp('signingConfig', 'Debug');
const isRelease = signingConfig === 'Release';
if (!c.platform) return;
@@ -285,7 +284,7 @@ const _checkSigningCerts = async (c: Context) => {
const keystorePath = path.join(c.paths.workspace.appConfig.dir, 'release.keystore');
mkdirSync(c.paths.workspace.appConfig.dir);
const keytoolCmd = `keytool -genkey -v -keystore ${keystorePath} -alias ${keyAlias} -keypass ${keyPassword} -storepass ${storePassword} -keyalg RSA -keysize 2048 -validity 10000`;
- await executeAsync(c, keytoolCmd, {
+ await executeAsync(keytoolCmd, {
shell: true,
stdio: 'inherit',
silent: true,
@@ -312,8 +311,8 @@ const _checkSigningCerts = async (c: Context) => {
updateObjectSync(c.paths.workspace.appConfig.configPrivate, c.files.workspace.appConfig.configPrivate);
logSuccess(`Successfully updated private config file at ${chalk().bold(c.paths.workspace.appConfig.dir)}.`);
// await configureProject(c);
- await updateRenativeConfigs(c);
- await parseAppBuildGradleSync(c);
+ await updateRenativeConfigs();
+ await parseAppBuildGradleSync();
// await configureGradleProject(c);
} else {
return Promise.reject("You selected no. Can't proceed");
@@ -321,16 +320,18 @@ const _checkSigningCerts = async (c: Context) => {
}
};
-export const configureAndroidProperties = async (c: Context) => {
+export const configureAndroidProperties = async () => {
logDefault('configureAndroidProperties');
- const appFolder = getAppFolder(c);
+ const c = getContext();
+
+ const appFolder = getAppFolder();
c.runtime.platformBuildsProjectPath = appFolder;
const addNDK = c.buildConfig?.sdks?.ANDROID_NDK && !c.buildConfig.sdks.ANDROID_NDK.includes('');
- let ndkString = `ndk.dir=${getRealPath(c, c.buildConfig?.sdks?.ANDROID_NDK)}`;
- let sdkDir = getRealPath(c, c.buildConfig?.sdks?.ANDROID_SDK);
+ let ndkString = `ndk.dir=${getRealPath(c.buildConfig?.sdks?.ANDROID_NDK)}`;
+ let sdkDir = getRealPath(c.buildConfig?.sdks?.ANDROID_SDK);
if (!sdkDir) {
logError(`Cannot resolve c.buildConfig?.sdks?.ANDROID_SDK: ${c.buildConfig?.sdks?.ANDROID_SDK}`);
@@ -352,15 +353,14 @@ sdk.dir=${sdkDir}`
return true;
};
-export const configureGradleProject = async (c: Context) => {
- const { platform } = c;
+export const configureGradleProject = async () => {
logDefault('configureGradleProject');
- if (!isPlatformActive(c, platform)) return;
- await copyAssetsFolder(c, platform, 'app/src/main');
- await configureAndroidProperties(c);
- await configureProject(c);
- await copyBuildsFolder(c, platform);
+ if (!isPlatformActive()) return;
+ await copyAssetsFolder('app/src/main');
+ await configureAndroidProperties();
+ await configureProject();
+ await copyBuildsFolder();
return true;
};
@@ -378,11 +378,11 @@ export const configureGradleProject = async (c: Context) => {
// throw new Error('createJavaPackageFolders not implemented');
// }
-export const configureProject = async (c: Context) => {
+export const configureProject = async () => {
logDefault('configureProject');
- const { platform } = c;
+ const c = getContext();
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
// if (!fsExistsSync(gradlew)) {
// logWarning(`Your ${chalk().bold(platform)} platformBuild is misconfigured!. let's repair it.`);
@@ -392,7 +392,7 @@ export const configureProject = async (c: Context) => {
// return true;
// }
- const outputFile = getEntryFile(c, platform);
+ const outputFile = getEntryFile();
// await createJavaPackageFolders(c, appFolder);
mkdirSync(path.join(appFolder, 'app/src/main/assets'));
@@ -445,11 +445,11 @@ export const configureProject = async (c: Context) => {
};
// PLUGINS
- parsePlugins(c, platform, (plugin, pluginPlat, key) => {
- injectPluginGradleSync(c, plugin, pluginPlat, key);
- injectPluginKotlinSync(c, pluginPlat, key, pluginPlat.package);
+ parsePlugins((plugin, pluginPlat, key) => {
+ injectPluginGradleSync(plugin, pluginPlat, key);
+ injectPluginKotlinSync(pluginPlat, key, pluginPlat.package);
injectPluginManifestSync();
- injectPluginXmlValuesSync(c, pluginPlat);
+ injectPluginXmlValuesSync(pluginPlat);
});
c.payload.pluginConfigAndroid.pluginPackages = c.payload.pluginConfigAndroid.pluginPackages.substring(
@@ -458,8 +458,8 @@ export const configureProject = async (c: Context) => {
);
// FONTS
- const includedFonts = getConfigProp(c, c.platform, 'includedFonts') || [];
- parseFonts(c, (font: string, dir: string) => {
+ const includedFonts = getConfigProp('includedFonts') || [];
+ parseFonts((font: string, dir: string) => {
if (font.includes('.ttf') || font.includes('.otf')) {
const key = font.split('.')[0];
@@ -481,18 +481,18 @@ export const configureProject = async (c: Context) => {
}
}
});
- parseAndroidConfigObject(c);
- parseSettingsGradleSync(c);
- parseAppBuildGradleSync(c);
- parseBuildGradleSync(c);
- parseGradleWrapperSync(c);
- parseMainActivitySync(c);
- parseMainApplicationSync(c);
- parseSplashActivitySync(c);
- parseValuesStringsSync(c);
- parseValuesColorsSync(c);
- parseAndroidManifestSync(c);
- parseGradlePropertiesSync(c);
+ parseAndroidConfigObject();
+ parseSettingsGradleSync();
+ parseAppBuildGradleSync();
+ parseBuildGradleSync();
+ parseGradleWrapperSync();
+ parseMainActivitySync();
+ parseMainApplicationSync();
+ parseSplashActivitySync();
+ parseValuesStringsSync();
+ parseValuesColorsSync();
+ parseAndroidManifestSync();
+ parseGradlePropertiesSync();
// parseFlipperSync(c, 'debug');
// parseFlipperSync(c, 'release');
await _checkSigningCerts(c);
@@ -501,7 +501,8 @@ export const configureProject = async (c: Context) => {
};
// Resolve or reject will not be called so this will keep running
-export const runAndroidLog = async (c: Context) => {
+export const runAndroidLog = async () => {
+ const c = getContext();
logDefault('runAndroidLog');
const filter = c.program.filter || '';
const child = execaCommand(`${c.cli[CLI_ANDROID_ADB]} logcat`);
diff --git a/packages/sdk-android/src/xmlValuesParser.ts b/packages/sdk-android/src/xmlValuesParser.ts
index 2c0f2135a3..12925ada61 100644
--- a/packages/sdk-android/src/xmlValuesParser.ts
+++ b/packages/sdk-android/src/xmlValuesParser.ts
@@ -1,13 +1,21 @@
import path from 'path';
-import { RenativeConfigPluginPlatform, getAppFolder, getConfigProp, writeFileSync, writeCleanFile } from '@rnv/core';
-import { Context } from './types';
+import {
+ RenativeConfigPluginPlatform,
+ getAppFolder,
+ getConfigProp,
+ writeFileSync,
+ writeCleanFile,
+ getContext,
+} from '@rnv/core';
import { getBuildFilePath, getAppTitle, sanitizeColor, addSystemInjects } from '@rnv/sdk-utils';
+import { Payload } from './types';
-export const parseValuesStringsSync = (c: Context) => {
- const appFolder = getAppFolder(c);
+export const parseValuesStringsSync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const stringsPath = 'app/src/main/res/values/strings.xml';
let strings = '\n';
- strings += ` ${getAppTitle(c, c.platform)}\n`;
+ strings += ` ${getAppTitle()}\n`;
c.payload.pluginConfigAndroid.resourceStrings.forEach((v) => {
strings += ` <${v.tag} name="${v.name}">${v.child_value}${v.tag}>\n`;
});
@@ -15,31 +23,27 @@ export const parseValuesStringsSync = (c: Context) => {
writeFileSync(path.join(appFolder, stringsPath), strings);
};
-export const parseValuesColorsSync = (c: Context) => {
- const appFolder = getAppFolder(c);
+export const parseValuesColorsSync = () => {
+ const c = getContext();
+ const appFolder = getAppFolder();
const stringsPath = 'app/src/main/res/values/colors.xml';
const injects = [
{
pattern: '{{PLUGIN_COLORS_BG}}',
- override: sanitizeColor(getConfigProp(c, c.platform, 'backgroundColor'), 'backgroundColor').hex,
+ override: sanitizeColor(getConfigProp('backgroundColor'), 'backgroundColor').hex,
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- writeCleanFile(
- getBuildFilePath(c, c.platform, stringsPath),
- path.join(appFolder, stringsPath),
- injects,
- undefined,
- c
- );
+ writeCleanFile(getBuildFilePath(stringsPath), path.join(appFolder, stringsPath), injects, undefined, c);
};
-export const injectPluginXmlValuesSync = (c: Context, plugin: RenativeConfigPluginPlatform) => {
+export const injectPluginXmlValuesSync = (plugin: RenativeConfigPluginPlatform) => {
const rStrings = plugin.templateAndroid?.strings_xml?.children;
if (rStrings) {
+ const c = getContext();
rStrings.forEach((obj) => {
c.payload.pluginConfigAndroid.resourceStrings.push(obj);
});
diff --git a/packages/sdk-apple/src/common.ts b/packages/sdk-apple/src/common.ts
index f71fee9bd6..4934cf7e65 100644
--- a/packages/sdk-apple/src/common.ts
+++ b/packages/sdk-apple/src/common.ts
@@ -1,9 +1,10 @@
-import { RnvPlatform, getConfigProp } from '@rnv/core';
-import { Context } from './types';
+import { getConfigProp, getContext } from '@rnv/core';
+
+export const getAppFolderName = () => {
+ const c = getContext();
-export const getAppFolderName = (c: Context, platform: RnvPlatform) => {
// NOTE: DEPRECATED
- let projectFolder = getConfigProp(c, platform, 'scheme');
+ let projectFolder = getConfigProp('scheme');
if (projectFolder) {
return projectFolder;
}
diff --git a/packages/sdk-apple/src/deviceManager.ts b/packages/sdk-apple/src/deviceManager.ts
index a52bbaea43..1f2b998d00 100644
--- a/packages/sdk-apple/src/deviceManager.ts
+++ b/packages/sdk-apple/src/deviceManager.ts
@@ -12,6 +12,7 @@ import {
ExecOptionsPresets,
logInfo,
logSuccess,
+ getContext,
} from '@rnv/core';
import { AppiumAppleDevice, AppleDevice } from './types';
import { execFileSync } from 'child_process';
@@ -181,7 +182,8 @@ const _parseIOSDevicesList = (
return devices;
};
-export const launchAppleSimulator = async (c: RnvContext, target: string | boolean) => {
+export const launchAppleSimulator = async (target: string | boolean) => {
+ const c = getContext();
logDefault('launchAppleSimulator', `${target}`);
const devicesArr = await getAppleDevices(c, true);
diff --git a/packages/sdk-apple/src/ejector.ts b/packages/sdk-apple/src/ejector.ts
index ab1b659e70..f0671c69f2 100644
--- a/packages/sdk-apple/src/ejector.ts
+++ b/packages/sdk-apple/src/ejector.ts
@@ -11,19 +11,20 @@ import {
doResolvePath,
parseFonts,
parsePlugins,
+ getContext,
} from '@rnv/core';
import { getAppFolderName } from './common';
-import { Context } from './types';
-export const ejectXcodeProject = async (c: Context) => {
- const isMonorepo = getConfigProp(c, c.platform, 'isMonorepo');
- const monoRoot = getConfigProp(c, c.platform, 'monoRoot');
+export const ejectXcodeProject = async () => {
+ const c = getContext();
+ const isMonorepo = getConfigProp('isMonorepo');
+ const monoRoot = getConfigProp('monoRoot');
const rootMonoProjectPath = isMonorepo ? path.join(c.paths.project.dir, monoRoot || '../..') : c.paths.project.dir;
const rootProjectPath = c.paths.project.dir;
- const appFolder = getAppFolder(c);
- const appFolderName = getAppFolderName(c, c.platform);
+ const appFolder = getAppFolder();
+ const appFolderName = getAppFolderName();
//= ==========
// xcodeproj
@@ -79,7 +80,7 @@ export const ejectXcodeProject = async (c: Context) => {
// Plugins
//= ==========
- parsePlugins(c, c.platform, (_plugin, pluginPlat, key) => {
+ parsePlugins((_plugin, pluginPlat, key) => {
const podPath = doResolvePath(key);
const extensionsFilter = ['.h', '.m', '.swift', '.c', '.podspec', '.rb', '.mm'];
// const excludeFolders = ['node_modules', 'android'];
@@ -111,10 +112,10 @@ export const ejectXcodeProject = async (c: Context) => {
// Fonts
//= ==========
- parseFonts(c, (font, dir) => {
+ parseFonts((font, dir) => {
if (font.includes('.ttf') || font.includes('.otf')) {
const key = font.split('.')[0];
- const includedFonts = getConfigProp(c, c.platform, 'includedFonts');
+ const includedFonts = getConfigProp('includedFonts');
if (includedFonts && (includedFonts.includes('*') || includedFonts.includes(key))) {
const fontSource = path.join(dir, font);
if (fsExistsSync(fontSource)) {
diff --git a/packages/sdk-apple/src/fastlane.ts b/packages/sdk-apple/src/fastlane.ts
index be5b024d5b..3ebc439704 100644
--- a/packages/sdk-apple/src/fastlane.ts
+++ b/packages/sdk-apple/src/fastlane.ts
@@ -1,19 +1,19 @@
import path from 'path';
-import { getConfigProp, chalk, logDefault, logWarning, logSuccess, executeAsync } from '@rnv/core';
-import { Context } from './types';
+import { getConfigProp, chalk, logDefault, logWarning, logSuccess, executeAsync, getContext } from '@rnv/core';
import { getAppId } from '@rnv/sdk-utils';
-export const registerDevice = async (c: Context) => {
+export const registerDevice = async () => {
+ const c = getContext();
logDefault(`registerDevice:${c.platform}`);
- const teamID = getConfigProp(c, c.platform, 'teamID');
+ const teamID = getConfigProp('teamID');
const udid = c.runtime.targetUDID;
const deviceName = c.runtime.target;
const args = ['run', 'register_device', `team_id:"${teamID}"`, `udid:"${udid}"`, `name:"${deviceName}"`];
try {
- await executeAsync(c, `fastlane ${args.join(' ')}`, {
+ await executeAsync(`fastlane ${args.join(' ')}`, {
shell: true,
stdio: 'inherit',
silent: true,
@@ -26,8 +26,9 @@ export const registerDevice = async (c: Context) => {
}
};
-export const updateProfile = async (c: Context): Promise => {
+export const updateProfile = async (): Promise => {
logDefault(`updateProfile`, chalk().grey);
+ const c = getContext();
// TODO: run trough all schemes
// const schemes = c.buildConfig.platforms?.[c.platform]?.buildSchemes
@@ -47,10 +48,10 @@ export const updateProfile = async (c: Context): Promise => {
const { appId } = c.runtime;
- const id = getAppId(c, platform);
- const teamID = getConfigProp(c, platform, 'teamID');
- const pMethod = getConfigProp(c, platform, 'exportOptions')?.method;
- const runScheme = getConfigProp(c, platform, 'runScheme');
+ const id = getAppId();
+ const teamID = getConfigProp('teamID');
+ const pMethod = getConfigProp('exportOptions')?.method;
+ const runScheme = getConfigProp('runScheme');
let provisioning;
if (pMethod === 'ad-hoc') provisioning = 'adhoc';
if (pMethod === 'development' || runScheme === 'Debug') {
@@ -79,7 +80,7 @@ export const updateProfile = async (c: Context): Promise => {
}
try {
- await executeAsync(c, `fastlane ${args.join(' ')}`, {
+ await executeAsync(`fastlane ${args.join(' ')}`, {
shell: true,
stdio: 'inherit',
silent: true,
diff --git a/packages/sdk-apple/src/objectiveCParser.ts b/packages/sdk-apple/src/objectiveCParser.ts
index 0290068269..167ea14ac3 100644
--- a/packages/sdk-apple/src/objectiveCParser.ts
+++ b/packages/sdk-apple/src/objectiveCParser.ts
@@ -9,8 +9,8 @@ import {
logWarning,
parsePlugins,
writeCleanFile,
- RnvPlatform,
RenativeConfigAppDelegateMethod,
+ getContext,
} from '@rnv/core';
import {
Context,
@@ -25,13 +25,12 @@ import {
import { addSystemInjects, getAppTemplateFolder, sanitizeColor } from '@rnv/sdk-utils';
export const parseAppDelegate = (
- c: Context,
- platform: RnvPlatform,
appFolder: string,
appFolderName: string
// isBundled = false,
) =>
new Promise((resolve) => {
+ const c = getContext();
logDefault('parseAppDelegateSync');
const appDelegateMm = 'AppDelegate.mm';
const appDelegateH = 'AppDelegate.h';
@@ -48,7 +47,7 @@ export const parseAppDelegate = (
// }
// PLUGINS
- parsePlugins(c, platform, (plugin, pluginPlat, key) => {
+ parsePlugins((plugin, pluginPlat, key) => {
injectPluginObjectiveCSync(c, pluginPlat, key);
});
@@ -63,7 +62,7 @@ export const parseAppDelegate = (
// }
// }
- const clr = sanitizeColor(getConfigProp(c, platform, 'backgroundColor'), 'backgroundColor').rgbDecimal;
+ const clr = sanitizeColor(getConfigProp('backgroundColor'), 'backgroundColor').rgbDecimal;
const pluginBgColor = `vc.view.backgroundColor = UIColor(red: ${clr[0]}, green: ${clr[1]}, blue: ${clr[2]}, alpha: ${clr[3]})`;
const methods: ObjectiveCAppDelegate = {
application: {
@@ -262,19 +261,19 @@ export const parseAppDelegate = (
: '',
},
];
- addSystemInjects(c, injectsMm);
+ addSystemInjects(injectsMm);
writeCleanFile(
- path.join(getAppTemplateFolder(c, platform)!, appFolderName, appDelegateMm),
+ path.join(getAppTemplateFolder()!, appFolderName, appDelegateMm),
path.join(appFolder, appFolderName, appDelegateMm),
injectsMm,
undefined,
c
);
- addSystemInjects(c, injectsH);
+ addSystemInjects(injectsH);
writeCleanFile(
- path.join(getAppTemplateFolder(c, platform)!, appFolderName, appDelegateH),
+ path.join(getAppTemplateFolder()!, appFolderName, appDelegateH),
path.join(appFolder, appFolderName, appDelegateH),
injectsH,
undefined,
@@ -285,7 +284,7 @@ export const parseAppDelegate = (
export const injectPluginObjectiveCSync = (c: Context, plugin: RenativeConfigPluginPlatform, key: string) => {
logDebug(`injectPluginObjectiveCSync:${c.platform}:${key}`);
- const templateXcode = getFlavouredProp(c, plugin, 'templateXcode');
+ const templateXcode = getFlavouredProp(plugin, 'templateXcode');
const appDelegateMmImports = templateXcode?.AppDelegate_mm?.appDelegateImports;
if (appDelegateMmImports) {
@@ -316,26 +315,29 @@ export const injectPluginObjectiveCSync = (c: Context, plugin: RenativeConfigPlu
if (appDelegateMethods) {
const admk = Object.keys(appDelegateMethods) as Array;
admk.forEach((delKey) => {
- const amdk2 = Object.keys(appDelegateMethods[delKey]) as Array;
- amdk2.forEach((key2) => {
- const plugArr: Array =
- c.payload.pluginConfigiOS.appDelegateMmMethods[delKey][key2];
- if (!plugArr) {
- logWarning(`appDelegateMethods.${delKey}.${chalk().red(key2)} not supported. SKIPPING.`);
- } else {
- const plugVal: Array = appDelegateMethods[delKey][key2];
- if (plugVal) {
- plugVal.forEach((v) => {
- const isString = typeof v === 'string';
- plugArr.push({
- order: isString ? 0 : v?.order || 0,
- value: isString ? v : v?.value,
- weight: isString ? 0 : v?.weight || 0,
+ const apDelMet = appDelegateMethods[delKey];
+ if (apDelMet) {
+ const amdk2 = Object.keys(apDelMet) as Array;
+ amdk2.forEach((key2) => {
+ const plugArr: Array =
+ c.payload.pluginConfigiOS.appDelegateMmMethods[delKey][key2];
+ if (!plugArr) {
+ logWarning(`appDelegateMethods.${delKey}.${chalk().red(key2)} not supported. SKIPPING.`);
+ } else {
+ const plugVal: Array = apDelMet[key2];
+ if (plugVal) {
+ plugVal.forEach((v) => {
+ const isString = typeof v === 'string';
+ plugArr.push({
+ order: isString ? 0 : v?.order || 0,
+ value: isString ? v : v?.value,
+ weight: isString ? 0 : v?.weight || 0,
+ });
});
- });
+ }
}
- }
- });
+ });
+ }
});
}
};
diff --git a/packages/sdk-apple/src/plistParser.ts b/packages/sdk-apple/src/plistParser.ts
index 6ad12bb3e1..c0aaabce4f 100644
--- a/packages/sdk-apple/src/plistParser.ts
+++ b/packages/sdk-apple/src/plistParser.ts
@@ -11,7 +11,7 @@ import {
mergeObjects,
writeCleanFile,
fsWriteFileSync,
- RnvPlatform,
+ getContext,
} from '@rnv/core';
import { getAppFolderName } from './common';
import { Context, FilePlistJSON } from './types';
@@ -23,13 +23,14 @@ const isString = (value: unknown) => typeof value === 'string' || value instance
const isArray = (value: unknown) => value && typeof value === 'object' && value.constructor === Array;
const isObject = (value: unknown) => value && typeof value === 'object' && value.constructor === Object;
-export const parseExportOptionsPlist = (c: Context, platform: RnvPlatform) =>
+export const parseExportOptionsPlist = () =>
new Promise((resolve) => {
// EXPORT OPTIONS
- const tId = getConfigProp(c, platform, 'teamID');
- const appFolder = getAppFolder(c);
- const exportOptions = getConfigProp(c, platform, 'exportOptions') || {};
- const id = getConfigProp(c, platform, 'id');
+ const c = getContext();
+ const tId = getConfigProp('teamID');
+ const appFolder = getAppFolder();
+ const exportOptions = getConfigProp('exportOptions') || {};
+ const id = getConfigProp('id');
c.payload.pluginConfigiOS.exportOptions = objToPlist(exportOptions);
@@ -42,7 +43,7 @@ export const parseExportOptionsPlist = (c: Context, platform: RnvPlatform) =>
}
}
- const bPath = getBuildFilePath(c, platform, 'exportOptions.plist');
+ const bPath = getBuildFilePath('exportOptions.plist');
const injects = [
{ pattern: '{{TEAM_ID}}', override: tId },
@@ -52,21 +53,21 @@ export const parseExportOptionsPlist = (c: Context, platform: RnvPlatform) =>
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(bPath, path.join(appFolder, 'exportOptions.plist'), injects, undefined, c);
resolve();
});
-export const parseEntitlementsPlist = (c: Context, platform: RnvPlatform) =>
+export const parseEntitlementsPlist = () =>
new Promise((resolve) => {
logDefault('parseEntitlementsPlist');
-
- const appFolder = getAppFolder(c);
- const appFolderName = getAppFolderName(c, platform);
+ const c = getContext();
+ const appFolder = getAppFolder();
+ const appFolderName = getAppFolderName();
const entitlementsPath = path.join(appFolder, `${appFolderName}/${appFolderName}.entitlements`);
// PLUGIN ENTITLEMENTS
- let pluginsEntitlementsObj = getConfigProp(c, platform, 'entitlements');
+ let pluginsEntitlementsObj = getConfigProp('entitlements');
if (!pluginsEntitlementsObj) {
pluginsEntitlementsObj =
readObjectSync(path.join(__dirname, '../supportFiles/entitlements.json')) || undefined;
@@ -76,31 +77,32 @@ export const parseEntitlementsPlist = (c: Context, platform: RnvPlatform) =>
resolve();
});
-export const parseInfoPlist = (c: Context, platform: RnvPlatform) =>
+export const parseInfoPlist = () =>
new Promise((resolve) => {
+ const c = getContext();
logDefault('parseInfoPlist');
-
+ const { platform } = c;
if (!platform) return;
- const appFolder = getAppFolder(c);
- const appFolderName = getAppFolderName(c, platform);
- const orientationSupport = getConfigProp(c, c.platform, 'orientationSupport');
- const urlScheme = getConfigProp(c, c.platform, 'urlScheme');
+ const appFolder = getAppFolder();
+ const appFolderName = getAppFolderName();
+ const orientationSupport = getConfigProp('orientationSupport');
+ const urlScheme = getConfigProp('urlScheme');
const plistPath = path.join(appFolder, `${appFolderName}/Info.plist`);
// PLIST
let plistObj =
readObjectSync(path.join(__dirname, `../supportFiles/info.plist.${platform}.json`)) || {};
- plistObj.CFBundleDisplayName = getAppTitle(c, platform);
- plistObj.CFBundleShortVersionString = getAppVersion(c, platform);
- plistObj.CFBundleVersion = getAppVersionCode(c, platform);
+ plistObj.CFBundleDisplayName = getAppTitle();
+ plistObj.CFBundleShortVersionString = getAppVersion();
+ plistObj.CFBundleVersion = getAppVersionCode();
// FONTS
if (c.payload.pluginConfigiOS.embeddedFonts.length) {
plistObj.UIAppFonts = c.payload.pluginConfigiOS.embeddedFonts;
}
// PERMISSIONS
- const includedPermissions = getConfigProp(c, platform, 'includedPermissions');
+ const includedPermissions = getConfigProp('includedPermissions');
if (includedPermissions && c.buildConfig.permissions) {
const platPrem = 'ios'; // c.buildConfig.permissions[platform] ? platform : 'ios';
const pc = c.buildConfig.permissions[platPrem] || {};
@@ -143,14 +145,14 @@ export const parseInfoPlist = (c: Context, platform: RnvPlatform) =>
// PLIST
- const plist = getConfigProp(c, platform, 'templateXcode')?.Info_plist;
+ const plist = getConfigProp('templateXcode')?.Info_plist;
if (plist) {
plistObj = mergeObjects(c, plistObj, plist, true, true);
}
// PLUGINS
- parsePlugins(c, platform, (plugin, pluginPlat) => {
- const plistPlug = getFlavouredProp(c, pluginPlat, 'templateXcode')?.Info_plist;
+ parsePlugins((plugin, pluginPlat) => {
+ const plistPlug = getFlavouredProp(pluginPlat, 'templateXcode')?.Info_plist;
if (plistPlug) {
plistObj = mergeObjects(c, plistObj, plistPlug, true, false);
}
diff --git a/packages/sdk-apple/src/podfileParser.ts b/packages/sdk-apple/src/podfileParser.ts
index 2bc18a99fc..b8c34fb8bf 100644
--- a/packages/sdk-apple/src/podfileParser.ts
+++ b/packages/sdk-apple/src/podfileParser.ts
@@ -9,31 +9,29 @@ import {
logDefault,
parsePlugins,
writeCleanFile,
- RnvPlatform,
DEFAULTS,
+ getContext,
} from '@rnv/core';
-import { Context } from './types';
import { addSystemInjects, getAppTemplateFolder } from '@rnv/sdk-utils';
-export const parsePodFile = async (c: Context, platform: RnvPlatform) => {
+export const parsePodFile = async () => {
logDefault('parsePodFile');
-
- const appFolder = getAppFolder(c);
- const useHermes = getConfigProp(c, c.platform, 'reactNativeEngine') === 'hermes';
-
+ const c = getContext();
+ const appFolder = getAppFolder();
+ const useHermes = getConfigProp('reactNativeEngine') === 'hermes';
let pluginInject = '';
// PLUGINS
c.payload.pluginConfigiOS.podfileInject = '';
- parsePlugins(c, platform, (plugin, pluginPlat, key) => {
- const templateXcode = getFlavouredProp(c, pluginPlat, 'templateXcode');
+ parsePlugins((plugin, pluginPlat, key) => {
+ const templateXcode = getFlavouredProp(pluginPlat, 'templateXcode');
- const podName = getFlavouredProp(c, pluginPlat, 'podName');
+ const podName = getFlavouredProp(pluginPlat, 'podName');
if (podName && (pluginPlat.git || pluginPlat.commit || pluginPlat.buildType || pluginPlat.version)) {
pluginInject += _injectPod(podName, pluginPlat, plugin, key);
}
- const podNames = getFlavouredProp(c, pluginPlat, 'podNames');
+ const podNames = getFlavouredProp(pluginPlat, 'podNames');
if (podNames) {
podNames.forEach((v) => {
pluginInject += `${v}\n`;
@@ -74,10 +72,10 @@ export const parsePodFile = async (c: Context, platform: RnvPlatform) => {
});
// WARNINGS
- const ignoreWarnings = getConfigProp(c, platform, 'ignoreWarnings');
+ const ignoreWarnings = getConfigProp('ignoreWarnings');
const podWarnings = ignoreWarnings ? 'inhibit_all_warnings!' : '';
- const templateXcode = getConfigProp(c, c.platform, 'templateXcode');
+ const templateXcode = getConfigProp('templateXcode');
const podfile = templateXcode?.Podfile;
if (podfile) {
const { injectLines, post_install, header, sources } = podfile;
@@ -110,7 +108,7 @@ export const parsePodFile = async (c: Context, platform: RnvPlatform) => {
}
// DEPLOYMENT TARGET
- const deploymentTarget = getConfigProp(c, platform, 'deploymentTarget') || DEFAULTS.deploymentTarget;
+ const deploymentTarget = getConfigProp('deploymentTarget') || DEFAULTS.deploymentTarget;
c.payload.pluginConfigiOS.deploymentTarget = deploymentTarget;
const injects: OverridesOptions = [
@@ -150,10 +148,10 @@ export const parsePodFile = async (c: Context, platform: RnvPlatform) => {
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(
- path.join(getAppTemplateFolder(c, platform)!, 'Podfile'),
+ path.join(getAppTemplateFolder()!, 'Podfile'),
path.join(appFolder, 'Podfile'),
injects,
undefined,
diff --git a/packages/sdk-apple/src/provisionParser.ts b/packages/sdk-apple/src/provisionParser.ts
index c17e8df3ea..de3ece7d25 100644
--- a/packages/sdk-apple/src/provisionParser.ts
+++ b/packages/sdk-apple/src/provisionParser.ts
@@ -5,8 +5,8 @@ import { Context } from './types';
export const parseProvisioningProfiles = async (c: Context) => {
// PROJECT
- const teamID = getConfigProp(c, c.platform, 'teamID');
- const id = getConfigProp(c, c.platform, 'id');
+ const teamID = getConfigProp('teamID');
+ const id = getConfigProp('id');
const certificates = cert.read();
try {
const provisionProfiles = provision.read();
diff --git a/packages/sdk-apple/src/runner.ts b/packages/sdk-apple/src/runner.ts
index 51d688e8f7..eb1467d802 100644
--- a/packages/sdk-apple/src/runner.ts
+++ b/packages/sdk-apple/src/runner.ts
@@ -21,8 +21,8 @@ import {
logSuccess,
logRaw,
inquirerPrompt,
- RnvPlatform,
CoreEnvVars,
+ getContext,
} from '@rnv/core';
import { getAppleDevices } from './deviceManager';
@@ -37,16 +37,16 @@ import { ObjectEncodingOptions } from 'fs';
import { packageReactNativeIOS, runCocoaPods, runReactNativeIOS, EnvVars } from '@rnv/sdk-react-native';
import { registerDevice } from './fastlane';
-export const packageBundleForXcode = (c: Context) => {
- return packageReactNativeIOS(c);
+export const packageBundleForXcode = () => {
+ return packageReactNativeIOS();
};
-const copyAppleAssets = (c: Context, platform: RnvPlatform, appFolderName: string) =>
+const copyAppleAssets = (appFolderName: string) =>
new Promise((resolve) => {
logDefault('copyAppleAssets');
- if (!isPlatformActive(c, platform, resolve)) return;
+ if (!isPlatformActive(resolve)) return;
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
// ASSETS
fsWriteFileSync(path.join(appFolder, 'main.jsbundle'), '{}');
@@ -212,39 +212,39 @@ export const getIosDeviceToRunOn = async (c: Context) => {
return p;
};
-export const runXcodeProject = async (c: Context, runDeviceArguments?: string) => {
+export const runXcodeProject = async (runDeviceArguments?: string) => {
+ const c = getContext();
logDefault('runXcodeProject', `targetArgs:${runDeviceArguments}`);
- const appPath = getAppFolder(c);
- const schemeTarget = getConfigProp(c, c.platform, 'schemeTarget') || _getDefaultSchemeTarget(c.platform!);
- const runScheme = getConfigProp(c, c.platform, 'runScheme') || 'Debug';
- const bundleIsDev = getConfigProp(c, c.platform, 'bundleIsDev') === true;
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets') === true;
+ const appPath = getAppFolder();
+ const schemeTarget = getConfigProp('schemeTarget') || _getDefaultSchemeTarget(c.platform!);
+ const runScheme = getConfigProp('runScheme') || 'Debug';
+ const bundleIsDev = getConfigProp('bundleIsDev') === true;
+ const bundleAssets = getConfigProp('bundleAssets') === true;
if (runDeviceArguments) {
// await launchAppleSimulator(c, c.runtime.target); @TODO - do we still need this? RN CLI does it as well
- //const allowProvisioningUpdates = getConfigProp(c, c.platform, 'allowProvisioningUpdates', true);
+ //const allowProvisioningUpdates = getConfigProp('allowProvisioningUpdates', true);
//if (allowProvisioningUpdates) p = `${p} --allowProvisioningUpdates`;
if (bundleAssets) {
- await packageReactNativeIOS(c, bundleIsDev);
+ await packageReactNativeIOS(bundleIsDev);
}
return _checkLockAndExec(c, appPath, schemeTarget, runScheme, runDeviceArguments);
}
if (c.platform === 'macos') {
if (bundleAssets) {
- await packageReactNativeIOS(c, bundleIsDev);
+ await packageReactNativeIOS(bundleIsDev);
}
try {
- await buildXcodeProject(c);
+ await buildXcodeProject();
} catch (e) {
await _handleMissingTeam(c, e);
}
return executeAsync(
- c,
`open ${path.join(appPath, `build/RNVApp/Build/Products/${runScheme}-maccatalyst/RNVApp.app`)}`
);
}
@@ -261,7 +261,7 @@ const _checkLockAndExec = async (
logDefault('_checkLockAndExec', `scheme:${scheme} runScheme:${runScheme} p:${extraParamsString}`);
if (!c.platform) return;
- const appFolderName = getAppFolderName(c, c.platform);
+ const appFolderName = getAppFolderName();
try {
return runReactNativeIOS(c, scheme, runScheme, extraParamsString);
@@ -282,9 +282,7 @@ const _checkLockAndExec = async (
logWarning(
`${c.platform} DEVICE: ${chalk().bold(c.runtime.target)} with UDID: ${chalk().bold(
c.runtime.targetUDID
- )} is not included in your provisionong profile in TEAM: ${chalk().bold(
- getConfigProp(c, c.platform, 'teamID')
- )}`
+ )} is not included in your provisionong profile in TEAM: ${chalk().bold(getConfigProp('teamID'))}`
);
const { confirm } = await inquirerPrompt({
name: 'confirm',
@@ -292,7 +290,7 @@ const _checkLockAndExec = async (
type: 'confirm',
});
if (confirm) {
- await registerDevice(c);
+ await registerDevice();
return Promise.reject('Updated. Re-run your last command');
// TODO: Tot picking up if re-run from here. forcing users to do it themselves for now
// await configureXcodeProject(c, c.platform);
@@ -364,8 +362,8 @@ Type in your Apple Team ID to be used (will be saved to ${c.paths.appConfig?.con
};
const _handleProvisioningIssues = async (c: Context, e: unknown, msg: string) => {
- const provisioningStyle = c.program.provisioningStyle || getConfigProp(c, c.platform, 'provisioningStyle');
- const appFolderName = getAppFolderName(c, c.platform); // Sometimes xcodebuild reports Automatic signing is disabled but it could be keychain not accepted by user
+ const provisioningStyle = c.program.provisioningStyle || getConfigProp('provisioningStyle');
+ const appFolderName = getAppFolderName(); // Sometimes xcodebuild reports Automatic signing is disabled but it could be keychain not accepted by user
const isProvAutomatic = provisioningStyle === 'Automatic';
const proAutoText = isProvAutomatic
? ''
@@ -373,7 +371,7 @@ const _handleProvisioningIssues = async (c: Context, e: unknown, msg: string) =>
c.platform
}, scheme: ${c.runtime.scheme}`;
const fixCommand = `rnv crypto updateProfile -p ${c.platform} -s ${c.runtime.scheme}`;
- const workspacePath = chalk().bold(`${getAppFolder(c)}/${appFolderName}.xcworkspace`);
+ const workspacePath = chalk().bold(`${getAppFolder()}/${appFolderName}.xcworkspace`);
logError(e);
logWarning(`${msg}. To fix try:
${chalk().bold('[1]>')} Configure your certificates, provisioning profiles correctly manually
@@ -457,14 +455,15 @@ const composeXcodeArgsFromCLI = (string: string) => {
return unescapedValues;
};
-export const buildXcodeProject = async (c: Context) => {
+export const buildXcodeProject = async () => {
+ const c = getContext();
logDefault('buildXcodeProject');
const { platform } = c;
- const appFolderName = getAppFolderName(c, platform);
- const runScheme = getConfigProp(c, platform, 'runScheme', 'Debug');
- const schemeTarget = getConfigProp(c, c.platform, 'schemeTarget') || _getDefaultSchemeTarget(c.platform!);
+ const appFolderName = getAppFolderName();
+ const runScheme = getConfigProp('runScheme', 'Debug');
+ const schemeTarget = getConfigProp('schemeTarget') || _getDefaultSchemeTarget(c.platform!);
let destinationPlatform = '';
switch (c.platform) {
@@ -492,10 +491,10 @@ export const buildXcodeProject = async (c: Context) => {
logError(`platform ${c.platform} not supported`);
}
- const appPath = getAppFolder(c);
+ const appPath = getAppFolder();
const buildPath = path.join(appPath, `build/${appFolderName}`);
- const allowProvisioningUpdates = getConfigProp(c, platform, 'allowProvisioningUpdates') || true;
- const ignoreLogs = getConfigProp(c, platform, 'ignoreLogs');
+ const allowProvisioningUpdates = getConfigProp('allowProvisioningUpdates') || true;
+ const ignoreLogs = getConfigProp('ignoreLogs');
let ps = '';
if (c.program.xcodebuildArgs) {
ps = c.program.xcodebuildArgs;
@@ -562,15 +561,16 @@ export const buildXcodeProject = async (c: Context) => {
});
};
-const archiveXcodeProject = (c: Context) => {
+const archiveXcodeProject = () => {
+ const c = getContext();
logDefault('archiveXcodeProject');
const { platform } = c;
- const appFolderName = getAppFolderName(c, c.platform);
- const schemeTarget = getConfigProp(c, platform, 'schemeTarget', _getDefaultSchemeTarget(c.platform!));
+ const appFolderName = getAppFolderName();
+ const schemeTarget = getConfigProp('schemeTarget', _getDefaultSchemeTarget(c.platform!));
- const runScheme = getConfigProp(c, platform, 'runScheme', 'Debug');
- let sdk = getConfigProp(c, platform, 'sdk');
+ const runScheme = getConfigProp('runScheme', 'Debug');
+ let sdk = getConfigProp('sdk');
if (!sdk) {
if (platform === 'ios') sdk = 'iphoneos';
// if (platform === MACOS) sdk = 'macosx';
@@ -581,11 +581,11 @@ const archiveXcodeProject = (c: Context) => {
sdkArr.push(sdk);
}
- const appPath = getAppFolder(c);
+ const appPath = getAppFolder();
const exportPath = path.join(appPath, 'release');
- const allowProvisioningUpdates = getConfigProp(c, platform, 'allowProvisioningUpdates', true);
- const ignoreLogs = getConfigProp(c, platform, 'ignoreLogs');
+ const allowProvisioningUpdates = getConfigProp('allowProvisioningUpdates', true);
+ const ignoreLogs = getConfigProp('ignoreLogs');
const exportPathArchive = `${exportPath}/${appFolderName}.xcarchive`;
let ps = '';
if (c.program.xcodebuildArchiveArgs) {
@@ -644,19 +644,18 @@ const archiveXcodeProject = (c: Context) => {
});
};
-export const exportXcodeProject = async (c: Context) => {
+export const exportXcodeProject = async () => {
+ const c = getContext();
logDefault('exportXcodeProject');
- const { platform } = c;
-
- await archiveXcodeProject(c);
+ await archiveXcodeProject();
- const appPath = getAppFolder(c);
+ const appPath = getAppFolder();
const exportPath = path.join(appPath, 'release');
- const appFolderName = getAppFolderName(c, c.platform);
- const allowProvisioningUpdates = getConfigProp(c, platform, 'allowProvisioningUpdates', true);
- const ignoreLogs = getConfigProp(c, platform, 'ignoreLogs');
+ const appFolderName = getAppFolderName();
+ const allowProvisioningUpdates = getConfigProp('allowProvisioningUpdates', true);
+ const ignoreLogs = getConfigProp('ignoreLogs');
let ps = '';
if (c.program.xcodebuildExportArgs) {
@@ -683,14 +682,15 @@ export const exportXcodeProject = async (c: Context) => {
logDefault('exportXcodeProject', 'STARTING xcodebuild EXPORT...');
- return executeAsync(c, `xcodebuild ${p.join(' ')}`).then(() => {
+ return executeAsync(`xcodebuild ${p.join(' ')}`).then(() => {
logSuccess(`Your IPA is located in ${chalk().cyan(exportPath)} .`);
});
};
// Resolve or reject will not be called so this will keep running
-export const runAppleLog = (c: Context) =>
+export const runAppleLog = () =>
new Promise(() => {
+ const c = getContext();
logDefault('runAppleLog');
const filter = c.program.filter || 'RNV';
const opts: ObjectEncodingOptions & ExecFileOptions = {}; //{ stdio: 'inherit', customFds: [0, 1, 2] };
@@ -714,17 +714,18 @@ export const runAppleLog = (c: Context) =>
}
});
-export const configureXcodeProject = async (c: Context) => {
+export const configureXcodeProject = async () => {
+ const c = getContext();
logDefault('configureXcodeProject');
const { device } = c.program;
const { platform } = c;
// const bundlerIp = device ? getIP() : 'localhost';
- const appFolder = getAppFolder(c);
- const appFolderName = getAppFolderName(c, platform);
+ const appFolder = getAppFolder();
+ const appFolderName = getAppFolderName();
c.runtime.platformBuildsProjectPath = `${appFolder}/${appFolderName}.xcworkspace`;
- // const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
+ // const bundleAssets = getConfigProp('bundleAssets') === true;
// INJECTORS
c.payload.pluginConfigiOS = {
podfileHeader: '',
@@ -765,7 +766,7 @@ export const configureXcodeProject = async (c: Context) => {
};
// FONTS
- // parsePlugins(c, platform, (plugin, pluginPlat) => {
+ // parsePlugins((plugin, pluginPlat) => {
// // const ignoreProjectFonts = getFlavouredProp(
// // c,
// // pluginPlat,
@@ -783,10 +784,10 @@ export const configureXcodeProject = async (c: Context) => {
// // }
// });
const embeddedFontSourcesCheck: Array = [];
- parseFonts(c, (font, dir) => {
+ parseFonts((font, dir) => {
if (font.includes('.ttf') || font.includes('.otf')) {
const key = font.split('.')[0];
- const includedFonts = getConfigProp(c, c.platform, 'includedFonts');
+ const includedFonts = getConfigProp('includedFonts');
if (includedFonts && (includedFonts.includes('*') || includedFonts.includes(key))) {
const fontSource = path.join(dir, font);
if (fsExistsSync(fontSource)) {
@@ -814,7 +815,7 @@ export const configureXcodeProject = async (c: Context) => {
});
// CHECK TEAM ID IF DEVICE
- const tId = getConfigProp(c, platform, 'teamID');
+ const tId = getConfigProp('teamID');
if (device && (!tId || tId === '')) {
logError(
`You're missing teamID in your ${chalk().bold(
@@ -823,17 +824,17 @@ export const configureXcodeProject = async (c: Context) => {
);
}
- await copyAssetsFolder(c, platform, appFolderName);
- await copyAppleAssets(c, platform, appFolderName);
- await parseAppDelegate(c, platform, appFolder, appFolderName);
- await parseExportOptionsPlist(c, platform);
- await parseXcscheme(c, platform);
- await parsePodFile(c, platform);
- await parseEntitlementsPlist(c, platform);
- await parseInfoPlist(c, platform);
- await copyBuildsFolder(c, platform);
- await runCocoaPods(c);
- await parseXcodeProject(c);
+ await copyAssetsFolder(appFolderName);
+ await copyAppleAssets(appFolderName);
+ await parseAppDelegate(appFolder, appFolderName);
+ await parseExportOptionsPlist();
+ await parseXcscheme();
+ await parsePodFile();
+ await parseEntitlementsPlist();
+ await parseInfoPlist();
+ await copyBuildsFolder();
+ await runCocoaPods();
+ await parseXcodeProject();
return true;
};
diff --git a/packages/sdk-apple/src/swiftParser.ts b/packages/sdk-apple/src/swiftParser.ts
index 359a0c6f2b..6161f78b39 100644
--- a/packages/sdk-apple/src/swiftParser.ts
+++ b/packages/sdk-apple/src/swiftParser.ts
@@ -54,7 +54,7 @@
// }
// // PLUGINS
-// parsePlugins(c, platform, (plugin, pluginPlat, key) => {
+// parsePlugins((plugin, pluginPlat, key) => {
// injectPluginSwiftSync(c, pluginPlat, key);
// });
@@ -69,7 +69,7 @@
// // }
// // }
-// const clr = sanitizeColor(getConfigProp(c, platform, 'backgroundColor'), 'backgroundColor').rgbDecimal;
+// const clr = sanitizeColor(getConfigProp('backgroundColor'), 'backgroundColor').rgbDecimal;
// const pluginBgColor = `vc.view.backgroundColor = UIColor(red: ${clr[0]}, green: ${clr[1]}, blue: ${clr[2]}, alpha: ${clr[3]})`;
// const methods: SwiftAppDelegate = {
// application: {
@@ -244,10 +244,10 @@
// },
// ];
-// addSystemInjects(c, injects);
+// addSystemInjects(injects);
// writeCleanFile(
-// path.join(getAppTemplateFolder(c, platform)!, appFolderName, appDelegate),
+// path.join(getAppTemplateFolder()!, appFolderName, appDelegate),
// path.join(appFolder, appFolderName, appDelegate),
// injects,
// undefined,
@@ -258,7 +258,7 @@
// export const injectPluginSwiftSync = (c: Context, plugin: RenativeConfigPluginPlatform, key: string) => {
// logDebug(`injectPluginSwiftSync:${c.platform}:${key}`);
-// const templateXcode = getFlavouredProp(c, plugin, 'templateXcode');
+// const templateXcode = getFlavouredProp(plugin, 'templateXcode');
// const appDelegateImports = templateXcode?.AppDelegate_mm?.appDelegateImports;
// if (appDelegateImports) {
// appDelegateImports.forEach((appDelegateImport) => {
diff --git a/packages/sdk-apple/src/xcodeParser.ts b/packages/sdk-apple/src/xcodeParser.ts
index 3412b2b65b..a3269fe971 100644
--- a/packages/sdk-apple/src/xcodeParser.ts
+++ b/packages/sdk-apple/src/xcodeParser.ts
@@ -13,6 +13,7 @@ import {
logWarning,
parsePlugins,
writeFileSync,
+ getContext,
} from '@rnv/core';
import { provision } from 'ios-mobileprovision-finder';
import path from 'path';
@@ -21,29 +22,30 @@ import { parseProvisioningProfiles } from './provisionParser';
import { Context } from './types';
import { getAppId } from '@rnv/sdk-utils';
-export const parseXcodeProject = async (c: Context) => {
+export const parseXcodeProject = async () => {
+ const c = getContext();
logDefault('parseXcodeProject');
const { platform } = c;
if (!platform) return;
// PROJECT
c.payload.xcodeProj = {};
c.payload.xcodeProj.provisioningStyle =
- c.program.provisioningStyle || getConfigProp(c, platform, 'provisioningStyle', 'Automatic');
- c.payload.xcodeProj.deploymentTarget = getConfigProp(c, platform, 'deploymentTarget', '14.0');
+ c.program.provisioningStyle || getConfigProp('provisioningStyle', 'Automatic');
+ c.payload.xcodeProj.deploymentTarget = getConfigProp('deploymentTarget', '14.0');
c.payload.xcodeProj.provisionProfileSpecifier =
- c.program.provisionProfileSpecifier || getConfigProp(c, platform, 'provisionProfileSpecifier');
- c.payload.xcodeProj.provisionProfileSpecifiers = getConfigProp(c, platform, 'provisionProfileSpecifiers') || {};
+ c.program.provisionProfileSpecifier || getConfigProp('provisionProfileSpecifier');
+ c.payload.xcodeProj.provisionProfileSpecifiers = getConfigProp('provisionProfileSpecifiers') || {};
c.payload.xcodeProj.codeSignIdentity =
- c.program.codeSignIdentity || getConfigProp(c, platform, 'codeSignIdentity', 'iPhone Developer');
+ c.program.codeSignIdentity || getConfigProp('codeSignIdentity', 'iPhone Developer');
- c.payload.xcodeProj.codeSignIdentities = getConfigProp(c, platform, 'codeSignIdentities');
+ c.payload.xcodeProj.codeSignIdentities = getConfigProp('codeSignIdentities');
- c.payload.xcodeProj.systemCapabilities = getConfigProp(c, platform, 'systemCapabilities');
- c.payload.xcodeProj.excludedArchs = getConfigProp(c, platform, 'excludedArchs');
- c.payload.xcodeProj.runScheme = getConfigProp(c, platform, 'runScheme');
- c.payload.xcodeProj.teamID = getConfigProp(c, platform, 'teamID');
- c.payload.xcodeProj.id = getConfigProp(c, platform, 'id');
- c.payload.xcodeProj.appId = getAppId(c, platform);
+ c.payload.xcodeProj.systemCapabilities = getConfigProp('systemCapabilities');
+ c.payload.xcodeProj.excludedArchs = getConfigProp('excludedArchs');
+ c.payload.xcodeProj.runScheme = getConfigProp('runScheme');
+ c.payload.xcodeProj.teamID = getConfigProp('teamID');
+ c.payload.xcodeProj.id = getConfigProp('id');
+ c.payload.xcodeProj.appId = getAppId();
if (c.payload.xcodeProj.provisioningStyle !== 'Automatic' && !c.payload.xcodeProj.provisionProfileSpecifier) {
const result = await parseProvisioningProfiles(c);
@@ -97,8 +99,8 @@ const _parseXcodeProject = (c: Context, platform: RnvPlatform) =>
}
const xcode = require(xcodePath);
// const xcode = require(`${c.paths.project.nodeModulesDir}/xcode`);
- const appFolder = getAppFolder(c);
- const appFolderName = getAppFolderName(c, platform);
+ const appFolder = getAppFolder();
+ const appFolderName = getAppFolderName();
const projectPath = path.join(appFolder, `${appFolderName}.xcodeproj/project.pbxproj`);
const xcodeProj = xcode.project(projectPath);
xcodeProj.parse(() => {
@@ -193,7 +195,7 @@ const _parseXcodeProject = (c: Context, platform: RnvPlatform) =>
xcodeProj.addTargetAttribute('SystemCapabilities', sysCapObj);
}
- const templateXcode = getConfigProp(c, c.platform, 'templateXcode');
+ const templateXcode = getConfigProp('templateXcode');
const xcodeprojObj1 = templateXcode?.project_pbxproj;
@@ -213,8 +215,8 @@ const _parseXcodeProject = (c: Context, platform: RnvPlatform) =>
}
// PLUGINS
- parsePlugins(c, platform, (plugin, pluginPlat) => {
- const templateXcode = getFlavouredProp(c, pluginPlat, 'templateXcode');
+ parsePlugins((plugin, pluginPlat) => {
+ const templateXcode = getFlavouredProp(pluginPlat, 'templateXcode');
const xcodeprojObj = templateXcode?.project_pbxproj;
if (xcodeprojObj) {
diff --git a/packages/sdk-apple/src/xcschemeParser.ts b/packages/sdk-apple/src/xcschemeParser.ts
index d319ea09c6..b27e00300b 100644
--- a/packages/sdk-apple/src/xcschemeParser.ts
+++ b/packages/sdk-apple/src/xcschemeParser.ts
@@ -1,14 +1,14 @@
import path from 'path';
-import { getAppFolder, getConfigProp, logDefault, writeCleanFile, RnvPlatform } from '@rnv/core';
+import { getAppFolder, getConfigProp, logDefault, writeCleanFile, getContext } from '@rnv/core';
import { getAppFolderName } from './common';
-import { Context } from './types';
import { addSystemInjects, getAppTemplateFolder } from '@rnv/sdk-utils';
// const xml2js = require('xml2js');
// const parser = new xml2js.Parser();
-export const parseXcscheme = async (c: Context, platform: RnvPlatform) => {
+export const parseXcscheme = async () => {
logDefault('parseXcscheme');
+ const c = getContext();
// XCSCHEME
// const allowProvisioningUpdates = getConfigProp(
// c,
@@ -25,9 +25,9 @@ export const parseXcscheme = async (c: Context, platform: RnvPlatform) => {
// const poisxSpawn = runScheme === 'Release' && !allowProvisioningUpdates && provisioningStyle === 'Manual';
// Since RN 61+ this must be set to true otherwise debug apps install but not launch
const poisxSpawn = true;
- const appFolder = getAppFolder(c);
- const appFolderName = getAppFolderName(c, platform);
- const appTemplateFolder = getAppTemplateFolder(c, platform);
+ const appFolder = getAppFolder();
+ const appFolderName = getAppFolderName();
+ const appTemplateFolder = getAppTemplateFolder();
const debuggerId = poisxSpawn ? '' : 'Xcode.DebuggerFoundation.Debugger.LLDB';
const launcherId = poisxSpawn
@@ -36,7 +36,7 @@ export const parseXcscheme = async (c: Context, platform: RnvPlatform) => {
const schemePath = `${appFolderName}.xcodeproj/xcshareddata/xcschemes/${appFolderName}.xcscheme`;
let _commandLineArguments = '';
- const commandLineArguments = getConfigProp(c, c.platform, 'commandLineArguments');
+ const commandLineArguments = getConfigProp('commandLineArguments');
if (commandLineArguments?.length) {
commandLineArguments.forEach((arg) => {
_commandLineArguments += `
@@ -54,7 +54,7 @@ export const parseXcscheme = async (c: Context, platform: RnvPlatform) => {
{ pattern: '{{INJECT_COMMAND_LINE_ARGUMENTS}}', override: _commandLineArguments },
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
writeCleanFile(path.join(appTemplateFolder!, schemePath), path.join(appFolder, schemePath), injects, undefined, c);
diff --git a/packages/sdk-kaios/src/constants.ts b/packages/sdk-kaios/src/constants.ts
index b8ca689090..9defc3359d 100644
--- a/packages/sdk-kaios/src/constants.ts
+++ b/packages/sdk-kaios/src/constants.ts
@@ -1 +1 @@
-export const CLI_KAIOS_EMULATOR = 'tizenEmulator';
+export const CLI_KAIOS_EMULATOR = 'kaiosEmulator';
diff --git a/packages/sdk-kaios/src/deviceManager.ts b/packages/sdk-kaios/src/deviceManager.ts
index 262947f389..db0cc44b33 100644
--- a/packages/sdk-kaios/src/deviceManager.ts
+++ b/packages/sdk-kaios/src/deviceManager.ts
@@ -1,34 +1,47 @@
-import { fsExistsSync, getRealPath, chalk, logDefault, RnvError, RnvContext } from '@rnv/core';
-
-const childProcess = require('child_process');
-
-export const launchKaiOSSimulator = (c: RnvContext) =>
- new Promise((resolve, reject) => {
- logDefault('launchKaiOSSimulator');
-
- if (!c.buildConfig?.sdks?.KAIOS_SDK) {
- reject(
- `KAIOS_SDK is not configured in your ${
- c.paths.workspace.config
- } file. Make sure you add location to your Kaiosrt App path similar to: ${chalk().white.bold(
- '"KAIOS_SDK": "/Applications/Kaiosrt.app"'
- )}`
- );
- return;
- }
-
- const ePath = getRealPath(c, c.buildConfig?.sdks?.KAIOS_SDK);
-
- if (ePath && !fsExistsSync(ePath)) {
- reject(`Can't find emulator at path: ${ePath}`);
- return;
- }
-
- childProcess.exec(`open ${ePath}`, (err: RnvError) => {
- if (err) {
- reject(err);
- return;
- }
- resolve();
+import {
+ fsExistsSync,
+ getRealPath,
+ logDefault,
+ inquirerPrompt,
+ getDirectories,
+ getContext,
+ executeAsync,
+ ExecOptionsPresets,
+} from '@rnv/core';
+import path from 'path';
+
+export const launchKaiOSSimulator = async (target: string | boolean) => {
+ const c = getContext();
+ logDefault(`launchKaiOSSimulator: ${target}`);
+
+ const kaiosSdkPath = getRealPath(c.buildConfig?.sdks?.KAIOS_SDK);
+
+ if (!kaiosSdkPath) {
+ return Promise.reject(`c.buildConfig.sdks.KAIOS_SDK undefined`);
+ }
+
+ if (target === true) {
+ const availableSimulatorVersions = getDirectories(kaiosSdkPath).filter(
+ (directory) => directory.toLowerCase().indexOf('kaios') !== -1
+ );
+
+ const { selectedSimulator } = await inquirerPrompt({
+ name: 'selectedSimulator',
+ type: 'list',
+ message: 'What simulator would you like to launch?',
+ choices: availableSimulatorVersions,
});
+ target = selectedSimulator;
+ }
+
+ const simulatorPath = path.join(kaiosSdkPath, `${target}/kaiosrt/kaiosrt`);
+
+ if (simulatorPath && !fsExistsSync(simulatorPath)) {
+ return Promise.reject(`Can't find simulator at path: ${simulatorPath}`);
+ }
+
+ await executeAsync(simulatorPath, {
+ cwd: `${kaiosSdkPath}/${target}/kaiosrt`,
+ ...ExecOptionsPresets.NO_SPINNER_FULL_ERROR_SUMMARY,
});
+};
diff --git a/packages/sdk-kaios/src/runner.ts b/packages/sdk-kaios/src/runner.ts
index 0d0bc292c5..a997fb51e2 100644
--- a/packages/sdk-kaios/src/runner.ts
+++ b/packages/sdk-kaios/src/runner.ts
@@ -1,7 +1,6 @@
import { buildCoreWebpackProject, configureCoreWebProject } from '@rnv/sdk-webpack';
import path from 'path';
import {
- RnvContext,
getPlatformProjectDir,
fsWriteFileSync,
fsReadFileSync,
@@ -9,58 +8,56 @@ import {
isPlatformActive,
copyBuildsFolder,
copyAssetsFolder,
+ getContext,
} from '@rnv/core';
import { launchKaiOSSimulator } from './deviceManager';
import { getAppAuthor, getAppDescription, getAppTitle } from '@rnv/sdk-utils';
-export const configureKaiOSProject = async (c: RnvContext) => {
+export const configureKaiOSProject = async () => {
+ const c = getContext();
logDefault('configureKaiOSProject');
- const { platform } = c;
+ c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir()}`;
- c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir(c)}`;
+ if (!isPlatformActive()) return;
- if (!isPlatformActive(c, platform)) return;
-
- await copyAssetsFolder(c, platform);
+ await copyAssetsFolder();
await configureCoreWebProject();
- await _configureProject(c);
- return copyBuildsFolder(c, platform);
+ await _configureProject();
+ return copyBuildsFolder();
};
-const _configureProject = (c: RnvContext) =>
+const _configureProject = () =>
new Promise((resolve) => {
logDefault('configureProject');
- const { platform } = c;
-
- if (!isPlatformActive(c, platform, resolve)) return;
+ if (!isPlatformActive(resolve)) return;
- const appFolder = getPlatformProjectDir(c);
+ const appFolder = getPlatformProjectDir();
const manifestFilePath = path.join(appFolder!, 'manifest.webapp');
const manifestFile = JSON.parse(fsReadFileSync(manifestFilePath).toString());
- manifestFile.name = `${getAppTitle(c, platform)}`;
- manifestFile.description = `${getAppDescription(c, platform)}`;
- manifestFile.developer = getAppAuthor(c, platform);
+ manifestFile.name = `${getAppTitle()}`;
+ manifestFile.description = `${getAppDescription()}`;
+ manifestFile.developer = getAppAuthor();
fsWriteFileSync(manifestFilePath, JSON.stringify(manifestFile, null, 2));
resolve();
});
-export const runKaiOSProject = async (c: RnvContext) => {
+export const runKaiOSProject = async () => {
logDefault('runKaiOSProject');
- await buildCoreWebpackProject(c);
- await launchKaiOSSimulator(c);
+ await buildCoreWebpackProject();
+ await launchKaiOSSimulator(true);
return true;
};
-export const buildKaiOSProject = async (c: RnvContext) => {
+export const buildKaiOSProject = async () => {
logDefault('buildKaiOSProject');
- await buildCoreWebpackProject(c);
+ await buildCoreWebpackProject();
return true;
};
diff --git a/packages/sdk-react-native/src/androidRunner.ts b/packages/sdk-react-native/src/androidRunner.ts
index 5f4c80ba3f..3d0f0001d2 100644
--- a/packages/sdk-react-native/src/androidRunner.ts
+++ b/packages/sdk-react-native/src/androidRunner.ts
@@ -8,31 +8,31 @@ import {
logDefault,
logInfo,
logSuccess,
- RnvContext,
DEFAULTS,
- RnvPlatform,
CoreEnvVars,
ExecOptionsPresets,
+ getContext,
} from '@rnv/core';
import { EnvVars } from './env';
import { getEntryFile } from '@rnv/sdk-utils';
-export const packageReactNativeAndroid = async (c: RnvContext) => {
+export const packageReactNativeAndroid = async () => {
+ const c = getContext();
logDefault('packageAndroid');
const { platform } = c;
if (!c.platform) return;
- const bundleAssets = getConfigProp(c, platform, 'bundleAssets', false) === true;
+ const bundleAssets = getConfigProp('bundleAssets', false) === true;
if (!bundleAssets && platform !== 'androidwear') {
logInfo(`bundleAssets in scheme ${chalk().bold(c.runtime.scheme)} marked false. SKIPPING PACKAGING...`);
return true;
}
- const outputFile = getEntryFile(c, platform);
+ const outputFile = getEntryFile();
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
let reactNative = c.runtime.runtimeExtraProps?.reactNativePackageName || 'react-native';
if (isSystemWin) {
@@ -57,7 +57,7 @@ export const packageReactNativeAndroid = async (c: RnvContext) => {
`${outputFile}.bundle`
)} --config=metro.config.js`;
- if (getConfigProp(c, c.platform, 'enableSourceMaps', false)) {
+ if (getConfigProp('enableSourceMaps', false)) {
cmd += ` --sourcemap-output ${path.join(
appFolder,
'app',
@@ -68,12 +68,13 @@ export const packageReactNativeAndroid = async (c: RnvContext) => {
)}`;
}
- await executeAsync(c, cmd, {
+ await executeAsync(cmd, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
...EnvVars.RNV_REACT_NATIVE_PATH(),
...EnvVars.RNV_APP_ID(),
+ ...EnvVars.RNV_SKIP_LINKING(),
},
});
@@ -85,15 +86,13 @@ export const packageReactNativeAndroid = async (c: RnvContext) => {
}
};
-export const runReactNativeAndroid = async (
- c: RnvContext,
- platform: RnvPlatform,
- device: { udid?: string } | undefined
-) => {
+export const runReactNativeAndroid = async (device: { udid?: string } | undefined) => {
+ const c = getContext();
+ const { platform } = c;
logDefault('_runGradleApp');
- const signingConfig = getConfigProp(c, platform, 'signingConfig', 'Debug');
- const appFolder = getAppFolder(c);
+ const signingConfig = getConfigProp('signingConfig', 'Debug');
+ const appFolder = getAppFolder();
const udid = device?.udid;
@@ -105,13 +104,14 @@ export const runReactNativeAndroid = async (
command += ` --deviceId=${udid}`;
}
- return executeAsync(c, command, {
+ return executeAsync(command, {
env: {
...CoreEnvVars.BASE(),
...CoreEnvVars.RNV_EXTENSIONS(),
...EnvVars.RCT_METRO_PORT(),
...EnvVars.RNV_REACT_NATIVE_PATH(),
...EnvVars.RNV_APP_ID(),
+ ...EnvVars.RNV_SKIP_LINKING(),
},
cwd: appFolder,
//This is required to make rn cli logs visible in rnv executed terminal
@@ -119,14 +119,13 @@ export const runReactNativeAndroid = async (
});
};
-export const buildReactNativeAndroid = async (c: RnvContext) => {
+export const buildReactNativeAndroid = async () => {
logDefault('buildAndroid');
- const { platform } = c;
- const appFolder = getAppFolder(c);
- const signingConfig = getConfigProp(c, platform, 'signingConfig') || DEFAULTS.signingConfig;
- const outputAab = getConfigProp(c, platform, 'aab', false);
- const extraGradleParams = getConfigProp(c, platform, 'extraGradleParams', '');
+ const appFolder = getAppFolder();
+ const signingConfig = getConfigProp('signingConfig') || DEFAULTS.signingConfig;
+ const outputAab = getConfigProp('aab', false);
+ const extraGradleParams = getConfigProp('extraGradleParams', '');
let command = `npx react-native build-android --mode=${signingConfig} --tasks ${
outputAab ? 'bundle' : 'assemble'
@@ -136,7 +135,7 @@ export const buildReactNativeAndroid = async (c: RnvContext) => {
command += ` --extra-params ${extraGradleParams}`;
}
- await executeAsync(c, command, {
+ await executeAsync(command, {
cwd: appFolder,
env: {
...CoreEnvVars.BASE(),
@@ -144,6 +143,7 @@ export const buildReactNativeAndroid = async (c: RnvContext) => {
...CoreEnvVars.RNV_EXTENSIONS(),
...EnvVars.RNV_REACT_NATIVE_PATH(),
...EnvVars.RNV_APP_ID(),
+ ...EnvVars.RNV_SKIP_LINKING(),
},
});
diff --git a/packages/sdk-react-native/src/common.ts b/packages/sdk-react-native/src/common.ts
index 57ad3b09d5..c3b3c93305 100644
--- a/packages/sdk-react-native/src/common.ts
+++ b/packages/sdk-react-native/src/common.ts
@@ -5,42 +5,42 @@ import {
executeTask,
chalk,
getConfigProp,
- RnvContext,
fsExistsSync,
logWarning,
parseFonts,
getApi,
RnvTaskName,
+ getContext,
} from '@rnv/core';
import { confirmActiveBundler } from '@rnv/sdk-utils';
let keepRNVRunning = false;
-export const startBundlerIfRequired = async (c: RnvContext, parentTask: string, originTask?: string) => {
+export const startBundlerIfRequired = async (parentTask: string, originTask?: string) => {
logDefault('startBundlerIfRequired');
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
if (bundleAssets === true) return;
- const isRunning = await isBundlerActive(c);
+ const isRunning = await isBundlerActive();
if (!isRunning) {
// _taskStart(c, parentTask, originTask);
- await executeTask(c, RnvTaskName.start, parentTask, originTask);
+ await executeTask(RnvTaskName.start, parentTask, originTask);
keepRNVRunning = true;
- await waitForBundler(c);
+ await waitForBundler();
} else {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
if (resetCompleted) {
- await executeTask(c, RnvTaskName.start, parentTask, originTask);
+ await executeTask(RnvTaskName.start, parentTask, originTask);
keepRNVRunning = true;
- await waitForBundler(c);
+ await waitForBundler();
}
}
};
-export const waitForBundlerIfRequired = async (c: RnvContext) => {
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+export const waitForBundlerIfRequired = async () => {
+ const bundleAssets = getConfigProp('bundleAssets');
if (bundleAssets === true) return;
// return a new promise that does...nothing, just to keep RNV running while the bundler is running
if (keepRNVRunning)
@@ -50,11 +50,13 @@ export const waitForBundlerIfRequired = async (c: RnvContext) => {
return true;
};
-const _isBundlerRunning = async (c: RnvContext) => {
+const _isBundlerRunning = async () => {
+ const c = getContext();
+
logDefault('_isBundlerRunning');
try {
const { data } = await axios.get(
- `http://${c.runtime.localhost}:${c.runtime.port}/${getConfigProp(c, c.platform, 'entryFile')}.js`
+ `http://${c.runtime.localhost}:${c.runtime.port}/${getConfigProp('entryFile')}.js`
);
if (data.includes('import')) {
logDefault('_isBundlerRunning', '(YES)');
@@ -68,7 +70,9 @@ const _isBundlerRunning = async (c: RnvContext) => {
}
};
-export const isBundlerActive = async (c: RnvContext) => {
+export const isBundlerActive = async () => {
+ const c = getContext();
+
logDefault('isBundlerActive', `(http://${c.runtime.localhost}:${c.runtime.port})`);
try {
await axios.get(`http://${c.runtime.localhost}:${c.runtime.port}`);
@@ -107,12 +111,13 @@ const poll = (fn: () => Promise, timeout = 30000, interval = 1000) => {
return new Promise(checkCondition);
};
-export const configureFonts = async (c: RnvContext) => {
+export const configureFonts = async () => {
+ const c = getContext();
const fontFolders = new Set();
- parseFonts(c, (font, dir) => {
+ parseFonts((font, dir) => {
if (font.includes('.ttf') || font.includes('.otf')) {
const key = font.split('.')[0];
- const includedFonts = getConfigProp(c, c.platform, 'includedFonts');
+ const includedFonts = getConfigProp('includedFonts');
if (includedFonts && (includedFonts.includes('*') || includedFonts.includes(key))) {
const fontSource = path.join(dir, font);
if (fsExistsSync(fontSource)) {
@@ -130,4 +135,4 @@ export const configureFonts = async (c: RnvContext) => {
c.paths.project.fontSourceDirs = Array.from(fontFolders);
};
-export const waitForBundler = async (c: RnvContext) => poll(() => _isBundlerRunning(c));
+export const waitForBundler = async () => poll(() => _isBundlerRunning());
diff --git a/packages/sdk-react-native/src/env.ts b/packages/sdk-react-native/src/env.ts
index 22758d6703..eaa544a605 100644
--- a/packages/sdk-react-native/src/env.ts
+++ b/packages/sdk-react-native/src/env.ts
@@ -1,7 +1,6 @@
import { doResolve, getConfigProp, getContext, getRelativePath, parsePlugins } from '@rnv/core';
import { getAppId } from '@rnv/sdk-utils';
-
export const EnvVars = {
RCT_METRO_PORT: () => {
const ctx = getContext();
@@ -21,15 +20,11 @@ export const EnvVars = {
return { RCT_NO_LAUNCH_PACKAGER: 1 };
},
RNV_APP_ID: () => {
- const ctx = getContext();
-
- return { RNV_APP_ID: getAppId(ctx, ctx.platform) };
+ return { RNV_APP_ID: getAppId() };
},
RCT_NEW_ARCH_ENABLED: () => {
- const ctx = getContext();
-
// new arch support
- const newArchEnabled = getConfigProp(ctx, ctx.platform, 'newArchEnabled', false);
+ const newArchEnabled = getConfigProp('newArchEnabled', false);
if (newArchEnabled) {
return { RCT_NEW_ARCH_ENABLED: 1 };
@@ -37,12 +32,8 @@ export const EnvVars = {
return {};
},
RNV_SKIP_LINKING: () => {
- const ctx = getContext();
-
const skipPlugins: string[] = [];
parsePlugins(
- ctx,
- ctx.platform,
(plugin, pluginPlat, key) => {
if (pluginPlat.disabled || plugin.disabled) {
skipPlugins.push(key);
diff --git a/packages/sdk-react-native/src/iosRunner.ts b/packages/sdk-react-native/src/iosRunner.ts
index 542199b6ce..09314c940e 100644
--- a/packages/sdk-react-native/src/iosRunner.ts
+++ b/packages/sdk-react-native/src/iosRunner.ts
@@ -21,10 +21,11 @@ import shellQuote from 'shell-quote';
import path from 'path';
import crypto from 'crypto';
-export const packageReactNativeIOS = (c: RnvContext, isDev = false) => {
+export const packageReactNativeIOS = (isDev = false) => {
+ const c = getContext();
logDefault('packageBundleForXcode');
- const entryFile = getConfigProp(c, c.platform, 'entryFile');
+ const entryFile = getConfigProp('entryFile');
if (!c.platform) return;
// const { maxErrorLength } = c.program;
@@ -40,12 +41,12 @@ export const packageReactNativeIOS = (c: RnvContext, isDev = false) => {
// SECURITY-PATCH https://github.com/flexn-io/renative/security/code-scanning/112
shellQuote.quote([`${entryFile}.js`]),
'--bundle-output',
- `${getAppFolder(c)}/main.jsbundle`,
+ `${getAppFolder()}/main.jsbundle`,
];
- if (getConfigProp(c, c.platform, 'enableSourceMaps', false)) {
+ if (getConfigProp('enableSourceMaps', false)) {
args.push('--sourcemap-output');
- args.push(`${getAppFolder(c)}/main.jsbundle.map`);
+ args.push(`${getAppFolder()}/main.jsbundle.map`);
}
if (c.program.info) {
@@ -53,7 +54,6 @@ export const packageReactNativeIOS = (c: RnvContext, isDev = false) => {
}
return executeAsync(
- c,
`node ${doResolve(
c.runtime.runtimeExtraProps?.reactNativePackageName || 'react-native'
)}/local-cli/cli.js ${args.join(' ')} --config=${
@@ -93,7 +93,7 @@ export const runReactNativeIOS = async (
try {
// Inherit full logs
// return executeAsync(c, cmd, { stdio: 'inherit', silent: true });
- return executeAsync(c, cmd, {
+ return executeAsync(cmd, {
env,
});
} catch (e) {
@@ -112,7 +112,7 @@ export const generateChecksum = (str: string, algorithm?: string, encoding?: 'ba
const generateCombinedChecksum = () => {
const c = getContext();
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const podContentChecksum = generateChecksum(fsReadFileSync(path.join(appFolder, 'Podfile')).toString());
const pluginVersionsChecksum = generateChecksum(JSON.stringify(c.runtime.pluginVersions));
@@ -128,7 +128,7 @@ const checkIfPodsIsRequired = (c: RnvContext): { result: boolean; reason: string
if (c.program.updatePods) {
return { result: true, reason: 'You passed --updatePods option', code: 2 };
}
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const podLockPath = path.join(appFolder, 'Podfile.lock');
if (!fsExistsSync(podLockPath)) {
@@ -149,9 +149,9 @@ const checkIfPodsIsRequired = (c: RnvContext): { result: boolean; reason: string
return { result: false, reason: 'Podfile.checksum matches current value', code: 6 };
};
-const updatePodsChecksum = (c: RnvContext) => {
+const updatePodsChecksum = () => {
logDefault('updatePodsChecksum');
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
const podChecksumPath = path.join(appFolder, 'Podfile.checksum');
const combinedChecksum = generateCombinedChecksum();
@@ -167,7 +167,8 @@ const updatePodsChecksum = (c: RnvContext) => {
return fsWriteFileSync(podChecksumPath, combinedChecksum);
};
-export const runCocoaPods = async (c: RnvContext) => {
+export const runCocoaPods = async () => {
+ const c = getContext();
logDefault('runCocoaPods', `forceUpdate:${!!c.program.updatePods}`);
const checkResult = await checkIfPodsIsRequired(c);
@@ -179,7 +180,7 @@ export const runCocoaPods = async (c: RnvContext) => {
// logInfo(`Will execute pod command. Reason: ${checkResult.reason}`);
- const appFolder = getAppFolder(c);
+ const appFolder = getAppFolder();
if (!fsExistsSync(appFolder)) {
return Promise.reject(`Location ${appFolder} does not exists!`);
@@ -190,7 +191,7 @@ export const runCocoaPods = async (c: RnvContext) => {
const option3 = "Skip and don't ask again";
const runPods = async () => {
- await executeAsync(c, 'bundle install');
+ await executeAsync('bundle install');
const env = {
...CoreEnvVars.BASE(),
@@ -200,18 +201,18 @@ export const runCocoaPods = async (c: RnvContext) => {
};
if (c.program.updatePods) {
- await executeAsync(c, 'bundle exec pod update', {
+ await executeAsync('bundle exec pod update', {
cwd: appFolder,
env,
});
} else {
- await executeAsync(c, 'bundle exec pod install', {
+ await executeAsync('bundle exec pod install', {
cwd: appFolder,
env,
});
}
- updatePodsChecksum(c);
+ updatePodsChecksum();
};
if (checkResult.code === 3) {
@@ -234,6 +235,6 @@ export const runCocoaPods = async (c: RnvContext) => {
return false;
}
- updatePodsChecksum(c);
+ updatePodsChecksum();
return false;
};
diff --git a/packages/sdk-react-native/src/metroRunner.ts b/packages/sdk-react-native/src/metroRunner.ts
index 290f8bed54..a745fc61f4 100644
--- a/packages/sdk-react-native/src/metroRunner.ts
+++ b/packages/sdk-react-native/src/metroRunner.ts
@@ -1,7 +1,6 @@
import {
CoreEnvVars,
PlatformKey,
- RnvContext,
chalk,
executeAsync,
logError,
@@ -9,6 +8,7 @@ import {
logInfo,
logRaw,
logDefault,
+ getContext,
} from '@rnv/core';
import { isBundlerActive } from './common';
import { EnvVars } from './env';
@@ -23,14 +23,16 @@ BUNDLER_PLATFORMS['androidtv'] = 'android';
BUNDLER_PLATFORMS['firetv'] = 'android';
BUNDLER_PLATFORMS['androidwear'] = 'android';
-export const startReactNative = async (
- c: RnvContext,
- opts: { waitForBundler?: boolean; customCliPath?: string; metroConfigName?: string }
-) => {
+export const startReactNative = async (opts: {
+ waitForBundler?: boolean;
+ customCliPath?: string;
+ metroConfigName?: string;
+}) => {
+ const c = getContext();
logDefault('startReactNative');
if (!c.platform) {
- logErrorPlatform(c);
+ logErrorPlatform();
return false;
}
@@ -61,7 +63,7 @@ export const startReactNative = async (
}
// logSummary('BUNDLER STARTED');
const url = chalk().cyan(
- `http://${c.runtime.localhost}:${c.runtime.port}/${getEntryFile(c, c.platform)}.bundle?platform=${
+ `http://${c.runtime.localhost}:${c.runtime.port}/${getEntryFile()}.bundle?platform=${
BUNDLER_PLATFORMS[c.platform]
}`
);
@@ -69,14 +71,14 @@ export const startReactNative = async (
Dev server running at: ${url}
`);
if (waitForBundler) {
- const isRunning = await isBundlerActive(c);
+ const isRunning = await isBundlerActive();
let resetCompleted = false;
if (isRunning) {
- resetCompleted = await confirmActiveBundler(c);
+ resetCompleted = await confirmActiveBundler();
}
if (!isRunning || (isRunning && resetCompleted)) {
- return executeAsync(c, startCmd, {
+ return executeAsync(startCmd, {
stdio: 'inherit',
silent: true,
env: {
@@ -89,7 +91,7 @@ Dev server running at: ${url}
});
}
if (resetCompleted) {
- return executeAsync(c, startCmd, {
+ return executeAsync(startCmd, {
stdio: 'inherit',
silent: true,
env: {
@@ -103,7 +105,7 @@ Dev server running at: ${url}
return true;
}
- executeAsync(c, startCmd, {
+ executeAsync(startCmd, {
stdio: 'inherit',
silent: true,
env: {
diff --git a/packages/sdk-tizen/src/deviceManager.ts b/packages/sdk-tizen/src/deviceManager.ts
index 177daaec1f..de42626865 100644
--- a/packages/sdk-tizen/src/deviceManager.ts
+++ b/packages/sdk-tizen/src/deviceManager.ts
@@ -19,6 +19,7 @@ import {
executeAsync,
ExecOptionsPresets,
ConfigName,
+ getContext,
} from '@rnv/core';
import { CLI_SDB_TIZEN, CLI_TIZEN, CLI_TIZEN_EMULATOR } from './constants';
@@ -70,11 +71,12 @@ const formatXMLObject = (
return {};
};
-export const launchTizenSimulator = async (c: RnvContext, name: string | true): Promise => {
+export const launchTizenSimulator = async (name: string | true): Promise => {
+ const c = getContext();
logDefault(`launchTizenSimulator:${name}`);
if (name === true) {
- const targets = await execCLI(c, CLI_TIZEN_EMULATOR, 'list-vm', {
+ const targets = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm', {
detached: true,
});
const lines = targets.split('\n');
@@ -93,7 +95,6 @@ export const launchTizenSimulator = async (c: RnvContext, name: string | true):
if (name) {
try {
await executeAsync(
- c,
`${c.cli[CLI_TIZEN_EMULATOR]} launch --name ${name}`,
ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY
);
@@ -102,7 +103,7 @@ export const launchTizenSimulator = async (c: RnvContext, name: string | true):
if (typeof e === 'string') {
if (e.includes(ERROR_MSG.UNKNOWN_VM)) {
logError(`The VM "${name}" does not exist.`);
- return launchTizenSimulator(c, true);
+ return launchTizenSimulator(true);
}
if (e.includes(ERROR_MSG.ALREADY_RUNNING)) {
@@ -115,8 +116,8 @@ export const launchTizenSimulator = async (c: RnvContext, name: string | true):
return Promise.reject('No simulator -t target name specified!');
};
-export const listTizenTargets = async (c: RnvContext) => {
- const targets = await execCLI(c, CLI_TIZEN_EMULATOR, 'list-vm', {
+export const listTizenTargets = async () => {
+ const targets = await execCLI(CLI_TIZEN_EMULATOR, 'list-vm', {
detached: true,
});
const targetArr = targets.split('\n');
@@ -136,7 +137,6 @@ export const createDevelopTizenCertificate = (c: RnvContext) =>
const certPassword = '1234';
execCLI(
- c,
CLI_TIZEN,
`certificate -- ${certDirPath} -a rnv -f ${certFilename} -p ${certPassword}`
// { privateParams: [certPassword] },
@@ -160,7 +160,7 @@ export const addDevelopTizenCertificate = (c: RnvContext, secureProfileConfig: T
logDefault('addDevelopTizenCertificate');
const { profileName, certPath, certPassword } = secureProfileConfig || {};
- execCLI(c, CLI_TIZEN, `security-profiles add -n ${profileName} -a ${certPath} -p ${certPassword}`, {
+ execCLI(CLI_TIZEN, `security-profiles add -n ${profileName} -a ${certPath} -p ${certPassword}`, {
privateParams: [certPassword],
})
.then(() => resolve())
@@ -176,7 +176,7 @@ const _getDeviceID = async (c: RnvContext, target: string) => {
if (device) {
let connectResponse: string;
try {
- connectResponse = await execCLI(c, CLI_SDB_TIZEN, `connect ${target}`);
+ connectResponse = await execCLI(CLI_SDB_TIZEN, `connect ${target}`);
} catch (e) {
if (typeof e === 'string') {
connectResponse = e;
@@ -199,7 +199,7 @@ const _getDeviceID = async (c: RnvContext, target: string) => {
if (connectResponse.includes('error')) throw new Error(connectResponse);
}
- const devicesList = await execCLI(c, CLI_SDB_TIZEN, 'devices');
+ const devicesList = await execCLI(CLI_SDB_TIZEN, 'devices');
if (devicesList.includes(target)) {
const lines = devicesList.trim().split(/\r?\n/);
const devices = lines.filter((line) => line.includes(target));
@@ -216,7 +216,7 @@ const _getDeviceID = async (c: RnvContext, target: string) => {
const _getRunningDevices = async (c: RnvContext) => {
const { platform } = c.program;
- const devicesList = await execCLI(c, CLI_SDB_TIZEN, 'devices');
+ const devicesList = await execCLI(CLI_SDB_TIZEN, 'devices');
const lines = devicesList
.trim()
.split(/\r?\n/)
@@ -229,7 +229,6 @@ const _getRunningDevices = async (c: RnvContext) => {
if (words.length >= 3) {
const name = words[0].trim();
const deviceInfoXML = await execCLI(
- c,
CLI_SDB_TIZEN,
`-s ${name} shell cat /etc/config/model-config.xml`,
{ ignoreErrors: true }
@@ -266,8 +265,8 @@ const _getRunningDevices = async (c: RnvContext) => {
return devices;
};
-const _waitForEmulatorToBeReady = (c: RnvContext, target: string): Promise =>
- waitForExecCLI(c, CLI_SDB_TIZEN, 'devices', (res) => {
+const _waitForEmulatorToBeReady = (target: string): Promise =>
+ waitForExecCLI(CLI_SDB_TIZEN, 'devices', (res) => {
if (typeof res === 'string') {
const lines = res.trim().split(/\r?\n/);
const devices = lines.filter((line) => line.includes(target) && line.includes('device'));
@@ -289,31 +288,14 @@ const _composeDevicesString = (devices: Array>)
// }
// };
-export const runTizenSimOrDevice = async (
- c: RnvContext,
- buildCoreWebpackProject?: (c: RnvContext) => Promise
-) => {
- const { hosted } = c.program;
- const { target, engine } = c.runtime;
+export const runTizenSimOrDevice = async () => {
+ const c = getContext();
+ const { target } = c.runtime;
const { platform } = c;
if (!platform) return;
- // const platformConfig = c.buildConfig.platforms?.[platform];
- const bundleAssets = getConfigProp(c, platform, 'bundleAssets');
- const isHosted = hosted ?? !bundleAssets;
- const isLightningEngine = engine?.config.id === 'engine-lightning';
- if (!bundleAssets && !hosted) {
- // console.log('RUN WEINRE');
- }
-
- // if (!platformConfig) {
- // throw new Error(
- // `runTizen: ${chalk().grey(platform)} not defined in your ${chalk().bold(c.paths.appConfig.config)}`
- // );
- // }
-
- const appName = getConfigProp(c, platform, 'appName');
+ const appName = getConfigProp('appName');
if (!appName) {
throw new Error(
@@ -321,11 +303,14 @@ export const runTizenSimOrDevice = async (
);
}
- const tDir = getPlatformProjectDir(c)!;
- const tBuild = path.join(tDir, 'build');
+ const bundleAssets = getConfigProp('bundleAssets') === true;
+ const tDir = getPlatformProjectDir()!;
+ // use build folder only if webpack is used, i.e. bundleAssets is true
+ const tBuild = bundleAssets ? path.join(tDir, 'build') : tDir;
+ const intermediate = path.join(tDir, 'intermediate');
const tOut = path.join(tDir, 'output');
- const tId = getConfigProp(c, platform, 'id');
- const certProfile = getConfigProp(c, platform, 'certificateProfile') || DEFAULTS.certificateProfile;
+ const tId = getConfigProp('id');
+ const certProfile = getConfigProp('certificateProfile') || DEFAULTS.certificateProfile;
const wgt = `${appName}.wgt`;
// the tizen CLI cannot handle .wgt files with spaces correctly.
@@ -349,17 +334,17 @@ export const runTizenSimOrDevice = async (
return;
}
try {
- await launchTizenSimulator(c, defaultTarget);
+ await launchTizenSimulator(defaultTarget);
deviceID = defaultTarget;
- await _waitForEmulatorToBeReady(c, defaultTarget);
+ await _waitForEmulatorToBeReady(defaultTarget);
return continueLaunching();
} catch (e) {
logDebug(`askForEmulator:ERRROR: ${e}`);
try {
- await execCLI(c, CLI_TIZEN_EMULATOR, `create -n ${defaultTarget} -p tv-samsung-5.0-x86`);
- await launchTizenSimulator(c, defaultTarget);
+ await execCLI(CLI_TIZEN_EMULATOR, `create -n ${defaultTarget} -p tv-samsung-5.0-x86`);
+ await launchTizenSimulator(defaultTarget);
deviceID = defaultTarget;
- await _waitForEmulatorToBeReady(c, defaultTarget);
+ await _waitForEmulatorToBeReady(defaultTarget);
return continueLaunching();
} catch (err) {
logDebug(err);
@@ -375,22 +360,18 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
const continueLaunching = async () => {
let hasDevice = false;
- if (!isLightningEngine && buildCoreWebpackProject) {
- // lightning engine handles the build and packaging
- !isHosted && (await buildCoreWebpackProject(c));
- await execCLI(c, CLI_TIZEN, `build-web -- ${tDir} -out ${tBuild}`);
- await execCLI(c, CLI_TIZEN, `package -- ${tBuild} -s ${certProfile} -t wgt -o ${tOut}`);
- }
+ await execCLI(CLI_TIZEN, `build-web -- ${tBuild} -out ${intermediate}`);
+ await execCLI(CLI_TIZEN, `package -- ${intermediate} -s ${certProfile} -t wgt -o ${tOut}`);
try {
const packageID = platform === 'tizenwatch' || platform === 'tizenmobile' ? tId.split('.')[0] : tId;
- await execCLI(c, CLI_TIZEN, `uninstall -p ${packageID} -t ${deviceID}`, { ignoreErrors: true });
+ await execCLI(CLI_TIZEN, `uninstall -p ${packageID} -t ${deviceID}`, { ignoreErrors: true });
hasDevice = true;
} catch (e) {
if (typeof e === 'string' && e.includes('No device matching')) {
if (target) {
- await launchTizenSimulator(c, target);
- hasDevice = await _waitForEmulatorToBeReady(c, target);
+ await launchTizenSimulator(target);
+ hasDevice = await _waitForEmulatorToBeReady(target);
} else {
return Promise.reject('Not target specified. (-t)');
}
@@ -407,7 +388,7 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
logError(err);
}
try {
- await execCLI(c, CLI_TIZEN, `install -- ${tOut} -n ${wgtClean} -t ${deviceID}`);
+ await execCLI(CLI_TIZEN, `install -- ${tOut} -n ${wgtClean} -t ${deviceID}`);
hasDevice = true;
} catch (err) {
logError(err);
@@ -418,8 +399,8 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
);
if (target) {
- await launchTizenSimulator(c, target);
- hasDevice = await _waitForEmulatorToBeReady(c, target);
+ await launchTizenSimulator(target);
+ hasDevice = await _waitForEmulatorToBeReady(target);
} else {
return Promise.reject('Not target specified. (-t)');
}
@@ -429,14 +410,14 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
// if (isHosted) {
// toReturn = startHostedServerIfRequired(c);
- // await waitForHost(c);
+ // await waitForHost();
// }
if (platform !== 'tizenwatch' && platform !== 'tizenmobile' && hasDevice) {
- await execCLI(c, CLI_TIZEN, `run -p ${tId} -t ${deviceID}`);
+ await execCLI(CLI_TIZEN, `run -p ${tId} -t ${deviceID}`);
} else if ((platform === 'tizenwatch' || platform === 'tizenmobile') && hasDevice) {
const packageID = tId.split('.');
- await execCLI(c, CLI_TIZEN, `run -p ${packageID[0]} -t ${deviceID}`);
+ await execCLI(CLI_TIZEN, `run -p ${packageID[0]} -t ${deviceID}`);
}
return toReturn;
};
@@ -463,8 +444,8 @@ Please create one and then edit the default target from ${c.paths.workspace.dir}
}
try {
// try to launch it, see if it's a simulator that's not started yet
- await launchTizenSimulator(c, target);
- await _waitForEmulatorToBeReady(c, target);
+ await launchTizenSimulator(target);
+ await _waitForEmulatorToBeReady(target);
deviceID = target;
return continueLaunching();
} catch (e) {
diff --git a/packages/sdk-tizen/src/installer.ts b/packages/sdk-tizen/src/installer.ts
index 2817a738cb..c4e014cef2 100644
--- a/packages/sdk-tizen/src/installer.ts
+++ b/packages/sdk-tizen/src/installer.ts
@@ -14,6 +14,7 @@ import {
generateBuildConfig,
RnvContext,
inquirerPrompt,
+ getContext,
} from '@rnv/core';
import { CLI_SDB_TIZEN, CLI_TIZEN, CLI_TIZEN_EMULATOR } from './constants';
@@ -27,16 +28,16 @@ const _logSdkWarning = (c: RnvContext) => {
logWarning(`Your ${c.paths.workspace.config} is missing SDK configuration object`);
};
-export const checkAndConfigureTizenSdks = async (c: RnvContext) => {
+export const checkAndConfigureTizenSdks = async () => {
+ const c = getContext();
logDefault(`checkAndConfigureTizenSdks:${c.platform}`);
const sdk = c.buildConfig?.sdks?.TIZEN_SDK;
if (sdk) {
c.cli[CLI_TIZEN_EMULATOR] = getRealPath(
- c,
path.join(sdk, `tools/emulator/bin/em-cli${isSystemWin ? '.bat' : ''}`)
);
- c.cli[CLI_TIZEN] = getRealPath(c, path.join(sdk, `tools/ide/bin/tizen${isSystemWin ? '.bat' : ''}`));
- c.cli[CLI_SDB_TIZEN] = getRealPath(c, path.join(sdk, `tools/sdb${isSystemWin ? '.exe' : ''}`));
+ c.cli[CLI_TIZEN] = getRealPath(path.join(sdk, `tools/ide/bin/tizen${isSystemWin ? '.bat' : ''}`));
+ c.cli[CLI_SDB_TIZEN] = getRealPath(path.join(sdk, `tools/sdb${isSystemWin ? '.exe' : ''}`));
} else {
_logSdkWarning(c);
}
@@ -51,7 +52,7 @@ const _isSdkInstalled = (c: RnvContext) => {
const sdkPath = _getCurrentSdkPath(c);
- return fsExistsSync(getRealPath(c, sdkPath));
+ return fsExistsSync(getRealPath(sdkPath));
};
const _attemptAutoFix = async (c: RnvContext) => {
@@ -84,8 +85,8 @@ const _attemptAutoFix = async (c: RnvContext) => {
c.files.workspace.config.sdks.TIZEN_SDK = result;
//TODO: use config_original here?
writeFileSync(c.paths.workspace.config, c.files.workspace.config);
- generateBuildConfig(c);
- await checkAndConfigureTizenSdks(c);
+ generateBuildConfig();
+ await checkAndConfigureTizenSdks();
} catch (e) {
logError(e);
}
@@ -98,11 +99,13 @@ const _attemptAutoFix = async (c: RnvContext) => {
// const setupInstance = PlatformSetup(c);
// await setupInstance.askToInstallSDK(sdkPlatform);
- generateBuildConfig(c);
+ generateBuildConfig();
return true;
};
-export const checkTizenSdk = async (c: RnvContext) => {
+export const checkTizenSdk = async () => {
+ const c = getContext();
+
logDefault('checkTizenSdk');
if (!_isSdkInstalled(c)) {
logWarning(
diff --git a/packages/sdk-tizen/src/runner.ts b/packages/sdk-tizen/src/runner.ts
index 2ad5f1e277..cc962d76a8 100644
--- a/packages/sdk-tizen/src/runner.ts
+++ b/packages/sdk-tizen/src/runner.ts
@@ -20,6 +20,7 @@ import {
OverridesOptions,
DEFAULTS,
copyFileSync,
+ getContext,
} from '@rnv/core';
import semver from 'semver';
import { CLI_TIZEN } from './constants';
@@ -41,24 +42,25 @@ import {
const DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION = `${DEFAULT_CERTIFICATE_NAME}.p12`;
-export const checkTizenStudioCert = async (c: RnvContext): Promise => {
+export const checkTizenStudioCert = async (): Promise => {
try {
- await execCLI(c, CLI_TIZEN, `security-profiles list -n ${DEFAULTS.certificateProfile}`);
+ await execCLI(CLI_TIZEN, `security-profiles list -n ${DEFAULTS.certificateProfile}`);
return true;
} catch (e) {
return false;
}
};
-export const configureTizenGlobal = (c: RnvContext) =>
+export const configureTizenGlobal = () =>
new Promise((resolve, reject) => {
+ const c = getContext();
logDefault('configureTizenGlobal');
// Check Tizen Cert
// if (isPlatformActive(c, TIZEN) || isPlatformActive(c, TIZEN_WATCH)) {
const tizenAuthorCert = path.join(c.paths.workspace.dir, DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION);
if (fsExistsSync(tizenAuthorCert)) {
- checkTizenStudioCert(c)
+ checkTizenStudioCert()
.then((certificateExists) => {
if (certificateExists) {
logDebug(`${DEFAULT_CERTIFICATE_NAME_WITH_EXTENSION} file exists in Tizen Studio!`);
@@ -94,14 +96,16 @@ export const configureTizenGlobal = (c: RnvContext) =>
// }
});
-const _runTizenSimOrDevice = async (c: RnvContext) => {
- try {
- await runTizenSimOrDevice(c, buildCoreWebpackProject);
- } catch (e) {
- // TODO: Capture different errors and react accordingly
- return Promise.reject(e);
- }
- return true;
+const _copyRequiredFiles = () => {
+ const tDir = getPlatformProjectDir()!;
+ const tBuild = path.join(tDir, 'build');
+
+ const requiredFiles = ['.project', '.tproject', 'config.xml', 'icon.png'];
+
+ requiredFiles.map((requiredFile) => {
+ const requiredFilePath = path.join(tDir, requiredFile);
+ copyFileSync(requiredFilePath, path.join(tBuild, requiredFile));
+ });
};
export const runTizen = async (c: RnvContext, target?: string) => {
@@ -111,26 +115,25 @@ export const runTizen = async (c: RnvContext, target?: string) => {
if (!platform) return;
- const isHosted = hosted && !getConfigProp(c, platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets') === true;
+ const isHosted = hosted && !bundleAssets;
if (isHosted) {
- const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
+ const isPortActive = await checkPortInUse(c.runtime.port);
if (isPortActive) {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
c.runtime.skipActiveServerCheck = !resetCompleted;
}
+ logDefault('runTizen', `target:${target} hosted:${!!isHosted}`);
+ return;
}
- logDefault('runTizen', `target:${target} hosted:${!!isHosted}`);
- if (isHosted) return;
-
- const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
-
if (bundleAssets) {
- await buildCoreWebpackProject(c);
- await _runTizenSimOrDevice(c);
+ await buildCoreWebpackProject();
+ _copyRequiredFiles();
+ await runTizenSimOrDevice();
} else {
- const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
+ const isPortActive = await checkPortInUse(c.runtime.port);
const isWeinreEnabled = REMOTE_DEBUGGER_ENABLED_PLATFORMS.includes(platform) && !bundleAssets && !hosted;
if (!isPortActive) {
@@ -139,50 +142,46 @@ export const runTizen = async (c: RnvContext, target?: string) => {
c.runtime.port
)} is not running. Starting it up for you...`
);
- waitForHost(c, '')
- .then(() => _runTizenSimOrDevice(c))
+ waitForHost('')
+ .then(() => runTizenSimOrDevice())
.catch(logError);
- await runWebpackServer(c, isWeinreEnabled);
+ await runWebpackServer(isWeinreEnabled);
} else {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
if (resetCompleted) {
- waitForHost(c, '')
- .then(() => _runTizenSimOrDevice(c))
+ waitForHost('')
+ .then(() => runTizenSimOrDevice())
.catch(logError);
- await runWebpackServer(c, isWeinreEnabled);
+ await runWebpackServer(isWeinreEnabled);
} else {
- await _runTizenSimOrDevice(c);
+ await runTizenSimOrDevice();
}
}
}
};
-export const buildTizenProject = async (c: RnvContext) => {
+export const buildTizenProject = async () => {
+ const c = getContext();
logDefault('buildTizenProject');
const { platform } = c;
if (!platform) return;
- const certProfile = getConfigProp(c, c.platform, 'certificateProfile') || DEFAULTS.certificateProfile;
- const tDir = getPlatformProjectDir(c)!;
+ const certProfile = getConfigProp('certificateProfile') || DEFAULTS.certificateProfile;
+ const tDir = getPlatformProjectDir()!;
+
+ await buildCoreWebpackProject();
- await buildCoreWebpackProject(c);
if (!c.program.hosted) {
+ _copyRequiredFiles();
const tOut = path.join(tDir, 'output');
const tIntermediate = path.join(tDir, 'intermediate');
const tBuild = path.join(tDir, 'build');
- const requiredFiles = ['.project', '.tproject', 'config.xml', 'icon.png'];
-
- requiredFiles.map((requiredFile) => {
- const requiredFilePath = path.join(tDir, requiredFile);
- copyFileSync(requiredFilePath, path.join(tBuild, requiredFile));
- });
-
- await execCLI(c, CLI_TIZEN, `build-web -- ${tBuild} -out ${tIntermediate}`);
- await execCLI(c, CLI_TIZEN, `package -- ${tIntermediate} -s ${certProfile} -t wgt -o ${tOut}`);
+ await execCLI(CLI_TIZEN, `build-web -- ${tBuild} -out ${tIntermediate}`);
+ await execCLI(CLI_TIZEN, `package -- ${tIntermediate} -s ${certProfile} -t wgt -o ${tOut}`);
logSuccess(`Your WGT package is located in ${chalk().cyan(tOut)} .`);
}
@@ -192,26 +191,25 @@ export const buildTizenProject = async (c: RnvContext) => {
let _isGlobalConfigured = false;
-export const configureTizenProject = async (c: RnvContext) => {
+export const configureTizenProject = async () => {
+ const c = getContext();
logDefault('configureTizenProject');
- const { platform } = c;
-
- c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir(c)}`;
+ c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir()}`;
- if (!isPlatformActive(c, platform)) {
+ if (!isPlatformActive()) {
return;
}
if (!_isGlobalConfigured && !c.program.hosted) {
_isGlobalConfigured = true;
- await configureTizenGlobal(c);
+ await configureTizenGlobal();
}
- await copyAssetsFolder(c, platform);
+ await copyAssetsFolder();
await configureCoreWebProject();
await _configureProject(c);
- return copyBuildsFolder(c, platform);
+ return copyBuildsFolder();
};
const _configureProject = (c: RnvContext) =>
@@ -224,20 +222,20 @@ const _configureProject = (c: RnvContext) =>
const configFile = 'config.xml';
// const p = c.buildConfig.platforms?.[platform];
- const pkg = getConfigProp(c, c.platform, 'package') || '';
- const id = getConfigProp(c, c.platform, 'id') || '';
- const appName = getConfigProp(c, c.platform, 'appName') || '';
+ const pkg = getConfigProp('package') || '';
+ const id = getConfigProp('id') || '';
+ const appName = getConfigProp('appName') || '';
const injects: OverridesOptions = [
{ pattern: '{{PACKAGE}}', override: pkg },
{ pattern: '{{ID}}', override: id },
{ pattern: '{{APP_NAME}}', override: appName },
- { pattern: '{{APP_VERSION}}', override: semver.valid(semver.coerce(getAppVersion(c, platform))) || '' },
+ { pattern: '{{APP_VERSION}}', override: semver.valid(semver.coerce(getAppVersion())) || '' },
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- const file = path.join(getPlatformProjectDir(c)!, configFile);
+ const file = path.join(getPlatformProjectDir()!, configFile);
writeCleanFile(file, file, injects, undefined, c);
resolve();
diff --git a/packages/sdk-utils/src/__tests__/index.test.ts b/packages/sdk-utils/src/__tests__/index.test.ts
index 81b0a35537..d6c7e34a9d 100644
--- a/packages/sdk-utils/src/__tests__/index.test.ts
+++ b/packages/sdk-utils/src/__tests__/index.test.ts
@@ -53,7 +53,7 @@ describe('Test getDevServerHost', () => {
c.runtime.localhost = '0.0.0.0 ';
jest.mocked(getConfigProp).mockReturnValue(undefined);
// WHEN
- const result = getDevServerHost(c);
+ const result = getDevServerHost();
// THEN
expect(result).toBe(DEFAULTS.devServerHost);
});
@@ -63,7 +63,7 @@ describe('Test getDevServerHost', () => {
c.runtime.localhost = '0.0.0.0';
jest.mocked(getConfigProp).mockReturnValue('localhost');
// WHEN
- const result = getDevServerHost(c);
+ const result = getDevServerHost();
// THEN
expect(result).toBe('0.0.0.0');
});
@@ -72,158 +72,188 @@ describe('Test getDevServerHost', () => {
describe('Test getAppVersionCode', () => {
it('should evaluate 1.2.3', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.2.3'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('10203');
});
it('should evaluate 1.2.3 with 00.00.00.00.00', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.2.3'); //version
jest.mocked(getConfigProp).mockReturnValueOnce('00.00.00.00.00'); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('102030000');
});
it('should evaluate 2.0.0+build.1848', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('2.0.0+build.1848'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('2000018');
});
it('should evaluate 2.0.0+build.1848 with 00.00.0000', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('2.0.0+build.1848'); //version
jest.mocked(getConfigProp).mockReturnValueOnce('00.00.00.0000'); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('200001848');
});
it('should evaluate 1.0.0-alpha+beta', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.0.0-alpha+beta'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('10000');
});
it('should evaluate 999999999999.99999999999.9999999', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('999999999999.99999999999.9999999'); //version
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('999999');
});
it('should evaluate 2.0.1-alpha.1227', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('2.0.1-alpha.1227'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('2000112');
});
it('should evaluate 2.0.1-alpha.1227', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('2.0.1-alpha.1227'); //version
jest.mocked(getConfigProp).mockReturnValueOnce('00.00.00.0000'); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('200011227');
});
it('should evaluate 1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('100000101');
});
it('should evaluate 1.0.1-beta+exp.sha.5114f85', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.0.1-beta+exp.sha.5114f85'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('10001');
});
it('should evaluate 1.0.1-beta+exp.sha.5114f85 with 00.00.00.00.00.00', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.0.1-beta+exp.sha.5114f85'); //version
jest.mocked(getConfigProp).mockReturnValueOnce('00.00.00.00.00.00'); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('10001000000');
});
it('should evaluate 1.0.1-beta+exp.sha.5114f85 with 00.00.00.000000', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1.0.1-beta+exp.sha.5114f85'); //version
jest.mocked(getConfigProp).mockReturnValueOnce('00.00.00.000000'); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('10001000000');
});
it('should evaluate 1', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1'); //version
jest.mocked(getConfigProp).mockReturnValueOnce(undefined); //versionCodeFormat
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('10000');
});
it('should evaluate given versionCode 1 with 1 on android', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'android';
jest.mocked(getConfigProp).mockReturnValueOnce('1'); //versionCode
jest.mocked(getConfigProp).mockReturnValueOnce('1'); //version
// WHEN
- const result = getAppVersionCode(getContext(), 'android');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('1');
});
it('should throw on given versionCode `string` on android', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'android';
jest.mocked(getConfigProp).mockReturnValueOnce('something as a string'); //versionCode
expect.assertions(1);
try {
// WHEN
- getAppVersionCode(getContext(), 'android');
+ getAppVersionCode();
} catch (e) {
// THEN
expect(e).toEqual(Error(`'versionCode' should be a positive integer. Check your config`));
@@ -232,11 +262,13 @@ describe('Test getAppVersionCode', () => {
it('should throw on given versionCode negative on android', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'android';
jest.mocked(getConfigProp).mockReturnValueOnce('-1'); //versionCode
expect.assertions(1);
try {
// WHEN
- getAppVersionCode(getContext(), 'android');
+ getAppVersionCode();
} catch (e) {
// THEN
expect(e).toEqual(Error(`'versionCode' should be a positive integer. Check your config`));
@@ -245,9 +277,11 @@ describe('Test getAppVersionCode', () => {
it('should evaluate given versionCode 4.4.4 with 4.4.4 on ios', async () => {
// GIVEN
+ const c = getContext();
+ c.platform = 'ios';
jest.mocked(getConfigProp).mockReturnValueOnce('4.4.4'); //versionCode
// WHEN
- const result = getAppVersionCode(getContext(), 'ios');
+ const result = getAppVersionCode();
// THEN
expect(result).toEqual('4.4.4');
});
diff --git a/packages/sdk-utils/src/index.ts b/packages/sdk-utils/src/index.ts
index 6ccbe02cad..833b5c77f8 100644
--- a/packages/sdk-utils/src/index.ts
+++ b/packages/sdk-utils/src/index.ts
@@ -5,12 +5,12 @@ import {
inquirerPrompt,
logWarning,
DEFAULTS,
- RnvContext,
RnvPlatform,
getConfigProp,
logDefault,
fsExistsSync,
PlatformKey,
+ getContext,
} from '@rnv/core';
import axios from 'axios';
import open from 'better-opn';
@@ -36,8 +36,9 @@ export const getValidLocalhost = (value: string, localhost: string) => {
export const openBrowser = open;
-export const getDevServerHost = (c: RnvContext) => {
- const devServerHostOrig = getConfigProp(c, c.platform, 'devServerHost');
+export const getDevServerHost = () => {
+ const c = getContext();
+ const devServerHostOrig = getConfigProp('devServerHost');
const devServerHostFixed = devServerHostOrig
? getValidLocalhost(devServerHostOrig, c.runtime.localhost || DEFAULTS.devServerHost)
@@ -46,14 +47,15 @@ export const getDevServerHost = (c: RnvContext) => {
return devServerHostFixed;
};
-export const waitForHost = async (c: RnvContext, suffix = 'assets/bundle.js') => {
+export const waitForHost = async (suffix = 'assets/bundle.js') => {
+ const c = getContext();
logDefault('waitForHost', `port:${c.runtime.port}`);
let attempts = 0;
const maxAttempts = 10;
const CHECK_INTEVAL = 2000;
// const spinner = ora('Waiting for webpack to finish...').start();
- const devServerHost = getDevServerHost(c);
+ const devServerHost = getDevServerHost();
const url = `http://${devServerHost}:${c.runtime.port}/${suffix}`;
return new Promise((resolve, reject) => {
@@ -85,7 +87,7 @@ export const waitForHost = async (c: RnvContext, suffix = 'assets/bundle.js') =>
});
};
-export const checkPortInUse = (c: RnvContext, platform: RnvPlatform, port: number) =>
+export const checkPortInUse = (port: number) =>
new Promise((resolve, reject) => {
if (port === undefined || port === null) {
resolve(false);
@@ -101,23 +103,19 @@ export const checkPortInUse = (c: RnvContext, platform: RnvPlatform, port: numbe
});
});
-export const getBuildFilePath = (
- c: RnvContext,
- platform: RnvPlatform,
- filePath: string,
- altTemplateFolder?: string
-) => {
+export const getBuildFilePath = (filePath: string, altTemplateFolder?: string) => {
+ const c = getContext();
// P1 => platformTemplates
- let sp = path.join(altTemplateFolder || getAppTemplateFolder(c, platform)!, filePath);
+ let sp = path.join(altTemplateFolder || getAppTemplateFolder()!, filePath);
// P2 => appConfigs/base + @buildSchemes
- const sp2bf = getAppConfigBuildsFolder(c, platform, c.paths.project.appConfigBase.dir);
+ const sp2bf = getAppConfigBuildsFolder(c.paths.project.appConfigBase.dir);
if (sp2bf) {
const sp2 = path.join(sp2bf, filePath);
if (fsExistsSync(sp2)) sp = sp2;
}
// P3 => appConfigs + @buildSchemes
- const sp3bf = getAppConfigBuildsFolder(c, platform);
+ const sp3bf = getAppConfigBuildsFolder();
if (sp3bf) {
const sp3 = path.join(sp3bf, filePath);
@@ -127,36 +125,34 @@ export const getBuildFilePath = (
return sp;
};
-export const getAppId = (c: RnvContext, platform: RnvPlatform) => {
- const id = getConfigProp(c, platform, 'id');
- const idSuffix = getConfigProp(c, platform, 'idSuffix');
+export const getAppId = () => {
+ const id = getConfigProp('id');
+ const idSuffix = getConfigProp('idSuffix');
return idSuffix ? `${id}${idSuffix}` : id;
};
-export const getAppTitle = (c: RnvContext, platform: RnvPlatform) => getConfigProp(c, platform, 'title');
+export const getAppTitle = () => getConfigProp('title');
-export const getAppAuthor = (c: RnvContext, platform: RnvPlatform) =>
- getConfigProp(c, platform, 'author') || c.files.project.package?.author;
+export const getAppAuthor = () => getConfigProp('author') || getContext().files.project.package?.author;
-export const getAppLicense = (c: RnvContext, platform: RnvPlatform) =>
- getConfigProp(c, platform, 'license') || c.files.project.package?.license;
+export const getAppLicense = () => getConfigProp('license') || getContext().files.project.package?.license;
-export const getEntryFile = (c: RnvContext, platform: RnvPlatform) =>
- platform ? c.buildConfig.platforms?.[platform]?.entryFile : undefined;
+export const getEntryFile = () => {
+ const c = getContext();
+ return c.platform ? c.buildConfig.platforms?.[c.platform]?.entryFile : undefined;
+};
-export const getGetJsBundleFile = (c: RnvContext, platform: RnvPlatform) =>
- getConfigProp(c, platform, 'getJsBundleFile');
+export const getGetJsBundleFile = () => getConfigProp('getJsBundleFile');
-export const getAppDescription = (c: RnvContext, platform: RnvPlatform) =>
- getConfigProp(c, platform, 'description') || c.files.project.package?.description;
+export const getAppDescription = () => getConfigProp('description') || getContext().files.project.package?.description;
-export const getAppVersion = (c: RnvContext, platform: RnvPlatform) => {
- const version = getConfigProp(c, platform, 'version') || c.files.project.package?.version;
+export const getAppVersion = () => {
+ const version = getConfigProp('version') || getContext().files.project.package?.version;
if (!version) {
logWarning('You are missing version prop in your config. will default to 0');
return '0';
}
- const versionFormat = getConfigProp(c, platform, 'versionFormat');
+ const versionFormat = getConfigProp('versionFormat');
if (!versionFormat) return version;
const versionCodeArr = versionFormat.split('.');
const dotLength = versionCodeArr.length;
@@ -201,12 +197,13 @@ const _androidLikePlatform = (platform: RnvPlatform) =>
* @returns The version code as a string.
* @throws An error if the version code is not a positive integer for Android platforms.
*/
-export const getAppVersionCode = (c: RnvContext, platform: RnvPlatform) => {
- const versionCode = getConfigProp(c, platform, 'versionCode');
+export const getAppVersionCode = () => {
+ const c = getContext();
+ const versionCode = getConfigProp('versionCode');
if (versionCode) {
// android platforms don't allow versionCode to be a string, only positive integer
- if (_androidLikePlatform(platform)) {
+ if (_androidLikePlatform(c.platform)) {
const isValidVersionCode = Number.isInteger(Number(versionCode)) && Number(versionCode) > 0;
if (!isValidVersionCode) {
throw new Error(`'versionCode' should be a positive integer. Check your config`);
@@ -215,12 +212,12 @@ export const getAppVersionCode = (c: RnvContext, platform: RnvPlatform) => {
return versionCode;
}
- const version = getConfigProp(c, platform, 'version') || c.files.project.package?.version;
+ const version = getConfigProp('version') || c.files.project.package?.version;
if (!version || typeof version !== 'string') {
logWarning('You are missing version prop in your config. will default to 0');
return '0';
}
- const versionCodeFormat = getConfigProp(c, platform, 'versionCodeFormat') || '00.00.00';
+ const versionCodeFormat = getConfigProp('versionCodeFormat') || '00.00.00';
const vFormatArr = versionCodeFormat.split('.').map((v: string) => v.length);
const versionCodeMaxCount = vFormatArr.length;
const verArr = [];
@@ -267,7 +264,8 @@ export const getAppVersionCode = (c: RnvContext, platform: RnvPlatform) => {
return output;
};
-export const confirmActiveBundler = async (c: RnvContext) => {
+export const confirmActiveBundler = async () => {
+ const c = getContext();
if (c.runtime.skipActiveServerCheck) return true;
if (c.program.ci) {
@@ -286,7 +284,8 @@ export const confirmActiveBundler = async (c: RnvContext) => {
});
if (choices[0] === selectedOption) {
- await killPort(c.runtime.port);
+ const result = await killPort(c.runtime.port);
+ console.log('WTFFF', result);
} else {
return false;
}
@@ -295,10 +294,14 @@ export const confirmActiveBundler = async (c: RnvContext) => {
export const getIP = () => ip.address();
-export const getAppTemplateFolder = (c: RnvContext, platform: RnvPlatform) =>
- platform ? path.join(c.paths.project.platformTemplatesDirs[platform], `${platform}`) : undefined;
+export const getAppTemplateFolder = () => {
+ const c = getContext();
+ const { platform } = c;
+ return platform ? path.join(c.paths.project.platformTemplatesDirs[platform], `${platform}`) : undefined;
+};
-export const addSystemInjects = (c: RnvContext, injects: OverridesOptions) => {
+export const addSystemInjects = (injects: OverridesOptions) => {
+ const c = getContext();
if (!c.systemPropsInjects) c.systemPropsInjects = [];
if (injects) {
injects.forEach((item) => {
diff --git a/packages/sdk-webos/src/deviceManager.ts b/packages/sdk-webos/src/deviceManager.ts
index 4fc08e9114..c0d918d718 100644
--- a/packages/sdk-webos/src/deviceManager.ts
+++ b/packages/sdk-webos/src/deviceManager.ts
@@ -24,6 +24,7 @@ import {
logSuccess,
getConfigProp,
getAppFolder,
+ getContext,
} from '@rnv/core';
import { WebosDevice } from './types';
import {
@@ -37,9 +38,10 @@ import {
import semver from 'semver';
import { isUrlLocalhost } from '@rnv/sdk-utils';
-export const launchWebOSimulator = async (c: RnvContext, target: string | boolean) => {
+export const launchWebOSimulator = async (target: string | boolean) => {
logTask('launchWebOSimulator', `${target}`);
- const webosSdkPath = getRealPath(c, c.buildConfig?.sdks?.WEBOS_SDK);
+ const c = getContext();
+ const webosSdkPath = getRealPath(c.buildConfig?.sdks?.WEBOS_SDK);
if (!webosSdkPath) {
return Promise.reject(`c.buildConfig.sdks.WEBOS_SDK undefined`);
}
@@ -60,7 +62,7 @@ export const launchWebOSimulator = async (c: RnvContext, target: string | boolea
c.paths.GLOBAL_RNV_CONFIG
)}`
);
- await launchWebOSimulator(c, true);
+ await launchWebOSimulator(true);
return true;
}
@@ -73,10 +75,10 @@ export const launchWebOSimulator = async (c: RnvContext, target: string | boolea
return Promise.reject(`Can't find simulator at path: ${ePath}`);
}
if (isSystemWin || isSystemLinux) {
- return executeAsync(c, ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY);
+ return executeAsync(ePath, ExecOptionsPresets.SPINNER_FULL_ERROR_SUMMARY);
}
- await executeAsync(c, `${openCommand} ${ePath}`, ExecOptionsPresets.FIRE_AND_FORGET);
+ await executeAsync(`${openCommand} ${ePath}`, ExecOptionsPresets.FIRE_AND_FORGET);
logSuccess(`Succesfully launched ${target}`);
return true;
};
@@ -95,7 +97,7 @@ const parseDevices = (c: RnvContext, devicesResponse: string): Promise word !== '');
let deviceInfo = '';
try {
- deviceInfo = await execCLI(c, CLI_WEBOS_ARES_DEVICE_INFO, `-d ${name}`, {
+ deviceInfo = await execCLI(CLI_WEBOS_ARES_DEVICE_INFO, `-d ${name}`, {
silent: true,
timeout: 10000,
});
@@ -123,7 +125,7 @@ const parseDevices = (c: RnvContext, devicesResponse: string): Promise {
logDefault('launchAppOnSimulator');
- const webosSdkPath = getRealPath(c, c.buildConfig?.sdks?.WEBOS_SDK);
+ const webosSdkPath = getRealPath(c.buildConfig?.sdks?.WEBOS_SDK);
if (!webosSdkPath) {
return Promise.reject(`c.buildConfig.sdks.WEBOS_SDK undefined`);
@@ -131,7 +133,7 @@ const launchAppOnSimulator = async (c: RnvContext, appPath: string) => {
const simulatorDirPath = path.join(webosSdkPath, 'Simulator');
- const webOS_cli_version = await execCLI(c, CLI_WEBOS_ARES_LAUNCH, `-V`);
+ const webOS_cli_version = await execCLI(CLI_WEBOS_ARES_LAUNCH, `-V`);
const webOS_cli_version_number = semver.coerce(webOS_cli_version);
@@ -171,30 +173,30 @@ const launchAppOnSimulator = async (c: RnvContext, appPath: string) => {
);
}
- await execCLI(c, CLI_WEBOS_ARES_LAUNCH, `-s ${version} ${appPath}`);
+ await execCLI(CLI_WEBOS_ARES_LAUNCH, `-s ${version} ${appPath}`);
logInfo(
`Launched app on webOS TV simulator ${selectedOption}. If you do not see the app opening please close the simulator and try again.`
);
};
// Used for actual devices
-const installAndLaunchApp = async (c: RnvContext, target: string, appPath: string, tId: string) => {
+const installAndLaunchApp = async (target: string, appPath: string, tId: string) => {
try {
- await execCLI(c, CLI_WEBOS_ARES_INSTALL, `--device ${target} ${appPath}`);
+ await execCLI(CLI_WEBOS_ARES_INSTALL, `--device ${target} ${appPath}`);
} catch (e) {
// installing it again if it fails. For some reason webosCLI says that it can't connect to
// the device from time to time. Running it again works.
- await execCLI(c, CLI_WEBOS_ARES_INSTALL, `--device ${target} ${appPath}`);
+ await execCLI(CLI_WEBOS_ARES_INSTALL, `--device ${target} ${appPath}`);
}
// const { hosted } = c.program;
// const { platform } = c;
- // const isHosted = hosted || !getConfigProp(c, platform, 'bundleAssets');
+ // const isHosted = hosted || !getConfigProp('bundleAssets');
const toReturn = true;
// if (isHosted) {
// toReturn = startHostedServerIfRequired(c);
- // await waitForHost(c);
+ // await waitForHost();
// }
- await execCLI(c, CLI_WEBOS_ARES_LAUNCH, `--device ${target} ${tId}`);
+ await execCLI(CLI_WEBOS_ARES_LAUNCH, `--device ${target} ${tId}`);
return toReturn;
};
@@ -206,12 +208,12 @@ const buildDeviceChoices = (devices: Array) =>
}));
export const listWebOSTargets = async (c: RnvContext) => {
- const devicesResponse = await execCLI(c, CLI_WEBOS_ARES_DEVICE_INFO, '-D');
+ const devicesResponse = await execCLI(CLI_WEBOS_ARES_DEVICE_INFO, '-D');
const devices = await parseDevices(c, devicesResponse);
const deviceArray = devices.map((device, i) => ` [${i + 1}]> ${chalk().bold(device.name)} | ${device.device}`);
- const webosSdkPath = getRealPath(c, c.buildConfig?.sdks?.WEBOS_SDK);
+ const webosSdkPath = getRealPath(c.buildConfig?.sdks?.WEBOS_SDK);
if (!webosSdkPath) {
return Promise.reject(`c.buildConfig.sdks.WEBOS_SDK undefined`);
}
@@ -225,20 +227,21 @@ export const listWebOSTargets = async (c: RnvContext) => {
return true;
};
-export const runWebosSimOrDevice = async (c: RnvContext) => {
+export const runWebosSimOrDevice = async () => {
+ const c = getContext();
const { device } = c.program;
- const platDir = getAppFolder(c);
+ const platDir = getAppFolder();
if (!platDir) {
return Promise.reject(`Cannot determine getAppFolder value`);
}
- const tDir = getPlatformProjectDir(c);
+ const tDir = getPlatformProjectDir();
if (!tDir) {
return Promise.reject(`Cannot determine getPlatformProjectDir value`);
}
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets');
+ const bundleAssets = getConfigProp('bundleAssets');
const appLocation = bundleAssets ? path.join(tDir, 'build') : tDir;
if (!appLocation) {
@@ -252,10 +255,10 @@ export const runWebosSimOrDevice = async (c: RnvContext) => {
const appPath = path.join(tOut, `${tId}_${cnfg.version}_all.ipk`);
// Start the fun
- await execCLI(c, CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${appLocation} -n`);
+ await execCLI(CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${appLocation} -n`);
// List all devices
- const devicesResponse = await execCLI(c, CLI_WEBOS_ARES_DEVICE_INFO, '-D');
+ const devicesResponse = await execCLI(CLI_WEBOS_ARES_DEVICE_INFO, '-D');
const devices = await parseDevices(c, devicesResponse);
const activeDevices = devices.filter((d) => d.active);
@@ -277,9 +280,9 @@ export const runWebosSimOrDevice = async (c: RnvContext) => {
logInfo(
'Please follow the instructions from http://webostv.developer.lge.com/develop/app-test/#installDevModeApp on how to setup the TV and the connection with the PC. Then follow the onscreen prompts\n'
);
- await execCLI(c, CLI_WEBOS_ARES_SETUP_DEVICE, '', ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER);
+ await execCLI(CLI_WEBOS_ARES_SETUP_DEVICE, '', ExecOptionsPresets.INHERIT_OUTPUT_NO_SPINNER);
- const newDeviceResponse = await execCLI(c, CLI_WEBOS_ARES_DEVICE_INFO, '-D');
+ const newDeviceResponse = await execCLI(CLI_WEBOS_ARES_DEVICE_INFO, '-D');
const dev = await parseDevices(c, newDeviceResponse);
const actualDev = dev.filter((d) => d.isDevice);
@@ -287,23 +290,23 @@ export const runWebosSimOrDevice = async (c: RnvContext) => {
const newDevice = actualDev[0];
// Oh boy, oh boy, I did it! I have a TV connected!
logInfo("Please enter the `Passphrase` from the TV's Developer Mode app");
- await execCLI(c, CLI_WEBOS_ARES_NOVACOM, `--device ${newDevice.name} --getkey`, {
+ await execCLI(CLI_WEBOS_ARES_NOVACOM, `--device ${newDevice.name} --getkey`, {
stdio: 'inherit',
});
- return installAndLaunchApp(c, newDevice.name, appPath, tId);
+ return installAndLaunchApp(newDevice.name, appPath, tId);
}
// Yes, I said I would but I didn't
// @todo handle user not setting up the device
}
} else if (actualDevices.length === 1) {
const tv = actualDevices[0];
- return installAndLaunchApp(c, tv.name, appPath, tId);
+ return installAndLaunchApp(tv.name, appPath, tId);
}
} else if (!c.program.target) {
// No target specified
if (activeDevices.length === 1) {
// One device present
- return installAndLaunchApp(c, devices[0].name, appPath, tId);
+ return installAndLaunchApp(devices[0].name, appPath, tId);
}
if (activeDevices.length > 1) {
// More than one, choosing
@@ -315,13 +318,13 @@ export const runWebosSimOrDevice = async (c: RnvContext) => {
choices,
});
if (response.chosenDevice) {
- return installAndLaunchApp(c, response.chosenDevice, appPath, tId);
+ return installAndLaunchApp(response.chosenDevice, appPath, tId);
}
} else {
return launchAppOnSimulator(c, appLocation);
}
} else {
// Target specified, using that
- return installAndLaunchApp(c, c.program.target, appPath, tId);
+ return installAndLaunchApp(c.program.target, appPath, tId);
}
};
diff --git a/packages/sdk-webos/src/installer.ts b/packages/sdk-webos/src/installer.ts
index e3e2871242..54173b742f 100644
--- a/packages/sdk-webos/src/installer.ts
+++ b/packages/sdk-webos/src/installer.ts
@@ -13,6 +13,7 @@ import {
generateBuildConfig,
RnvContext,
inquirerPrompt,
+ getContext,
} from '@rnv/core';
import {
@@ -31,35 +32,22 @@ const _logSdkWarning = (c: RnvContext) => {
logWarning(`Your ${c.paths.workspace.config} is missing SDK configuration object`);
};
-export const checkAndConfigureWebosSdks = async (c: RnvContext) => {
+export const checkAndConfigureWebosSdks = async () => {
+ const c = getContext();
logDefault(`checkAndConfigureWebosSdks:${c.platform}`);
const sdk = c.buildConfig?.sdks?.WEBOS_SDK;
if (sdk) {
- c.cli[CLI_WEBOS_ARES] = getRealPath(c, path.join(sdk, `CLI/bin/ares${isSystemWin ? '.cmd' : ''}`));
- c.cli[CLI_WEBOS_ARES_PACKAGE] = getRealPath(
- c,
- path.join(sdk, `CLI/bin/ares-package${isSystemWin ? '.cmd' : ''}`)
- );
- c.cli[CLI_WEBOS_ARES_INSTALL] = getRealPath(
- c,
- path.join(sdk, `CLI/bin/ares-install${isSystemWin ? '.cmd' : ''}`)
- );
- c.cli[CLI_WEBOS_ARES_LAUNCH] = getRealPath(
- c,
- path.join(sdk, `CLI/bin/ares-launch${isSystemWin ? '.cmd' : ''}`)
- );
+ c.cli[CLI_WEBOS_ARES] = getRealPath(path.join(sdk, `CLI/bin/ares${isSystemWin ? '.cmd' : ''}`));
+ c.cli[CLI_WEBOS_ARES_PACKAGE] = getRealPath(path.join(sdk, `CLI/bin/ares-package${isSystemWin ? '.cmd' : ''}`));
+ c.cli[CLI_WEBOS_ARES_INSTALL] = getRealPath(path.join(sdk, `CLI/bin/ares-install${isSystemWin ? '.cmd' : ''}`));
+ c.cli[CLI_WEBOS_ARES_LAUNCH] = getRealPath(path.join(sdk, `CLI/bin/ares-launch${isSystemWin ? '.cmd' : ''}`));
c.cli[CLI_WEBOS_ARES_SETUP_DEVICE] = getRealPath(
- c,
path.join(sdk, `CLI/bin/ares-setup-device${isSystemWin ? '.cmd' : ''}`)
);
c.cli[CLI_WEBOS_ARES_DEVICE_INFO] = getRealPath(
- c,
path.join(sdk, `CLI/bin/ares-device-info${isSystemWin ? '.cmd' : ''}`)
);
- c.cli[CLI_WEBOS_ARES_NOVACOM] = getRealPath(
- c,
- path.join(sdk, `CLI/bin/ares-novacom${isSystemWin ? '.cmd' : ''}`)
- );
+ c.cli[CLI_WEBOS_ARES_NOVACOM] = getRealPath(path.join(sdk, `CLI/bin/ares-novacom${isSystemWin ? '.cmd' : ''}`));
} else {
_logSdkWarning(c);
}
@@ -74,7 +62,7 @@ const _isSdkInstalled = (c: RnvContext) => {
const sdkPath = _getCurrentSdkPath(c);
- return fsExistsSync(getRealPath(c, sdkPath));
+ return fsExistsSync(getRealPath(sdkPath));
};
const _attemptAutoFix = async (c: RnvContext) => {
@@ -106,8 +94,8 @@ const _attemptAutoFix = async (c: RnvContext) => {
if (!cnf.sdks) cnf.sdks = {};
cnf.sdks.WEBOS_SDK = result;
writeFileSync(c.paths.workspace.config, cnf);
- generateBuildConfig(c);
- await checkAndConfigureWebosSdks(c);
+ generateBuildConfig();
+ await checkAndConfigureWebosSdks();
} catch (e) {
logError(e);
}
@@ -120,11 +108,13 @@ const _attemptAutoFix = async (c: RnvContext) => {
// const setupInstance = PlatformSetup(c);
// await setupInstance.askToInstallSDK(sdkPlatform);
- generateBuildConfig(c);
+ generateBuildConfig();
return true;
};
-export const checkWebosSdk = async (c: RnvContext) => {
+export const checkWebosSdk = async () => {
+ const c = getContext();
+
logDefault('checkWebosSdk');
if (!_isSdkInstalled(c)) {
logWarning(
diff --git a/packages/sdk-webos/src/runner.ts b/packages/sdk-webos/src/runner.ts
index f2de7e7b76..d423967278 100644
--- a/packages/sdk-webos/src/runner.ts
+++ b/packages/sdk-webos/src/runner.ts
@@ -18,6 +18,7 @@ import {
DEFAULTS,
OverridesOptions,
getAppFolder,
+ getContext,
} from '@rnv/core';
import semver from 'semver';
import { runWebosSimOrDevice } from './deviceManager';
@@ -40,21 +41,22 @@ export const runWebOS = async (c: RnvContext) => {
const { target } = c.runtime;
const { platform } = c;
- const isHosted = hosted && !getConfigProp(c, platform, 'bundleAssets');
+ if (!platform) return;
+
+ const bundleAssets = getConfigProp('bundleAssets') === true;
+ const isHosted = hosted && !bundleAssets;
if (isHosted) {
- const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
+ const isPortActive = await checkPortInUse(c.runtime.port);
if (isPortActive) {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
c.runtime.skipActiveServerCheck = !resetCompleted;
}
logDefault('runWebOS', `target:${target} hosted:${!!isHosted}`);
return;
}
- const bundleAssets = getConfigProp(c, platform, 'bundleAssets') === true;
-
- const env = getConfigProp(c, platform, 'environment');
+ const env = getConfigProp('environment');
if (env !== 'production') {
process.env.RNV_INJECTED_WEBPACK_SCRIPTS = `${
process.env.RNV_INJECTED_WEBPACK_SCRIPTS || ''
@@ -62,9 +64,9 @@ export const runWebOS = async (c: RnvContext) => {
}
if (bundleAssets) {
- await buildCoreWebpackProject(c);
+ await buildCoreWebpackProject();
- const appPath = getAppFolder(c);
+ const appPath = getAppFolder();
if (!appPath) {
throw new Error('Failed to resolve appPath');
@@ -78,9 +80,9 @@ export const runWebOS = async (c: RnvContext) => {
copyFileSync(requiredFilePath, path.join(appPath, 'build', requiredFile));
}
});
- await runWebosSimOrDevice(c);
+ await runWebosSimOrDevice();
} else {
- const isPortActive = await checkPortInUse(c, platform, c.runtime.port);
+ const isPortActive = await checkPortInUse(c.runtime.port);
const isWeinreEnabled = platform
? REMOTE_DEBUGGER_ENABLED_PLATFORMS.includes(platform) && !bundleAssets && !hosted
: false;
@@ -91,107 +93,106 @@ export const runWebOS = async (c: RnvContext) => {
c.runtime.port
)} is not running. Starting it up for you...`
);
- waitForHost(c, '')
+ waitForHost('')
.then(() => {
- runWebosSimOrDevice(c);
+ runWebosSimOrDevice();
})
.catch(logError);
- await runWebpackServer(c, isWeinreEnabled);
+ await runWebpackServer(isWeinreEnabled);
} else {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
if (resetCompleted) {
- waitForHost(c, '')
- .then(() => runWebosSimOrDevice(c))
+ waitForHost('')
+ .then(() => runWebosSimOrDevice())
.catch(logError);
- await runWebpackServer(c, isWeinreEnabled);
+ await runWebpackServer(isWeinreEnabled);
} else {
- await runWebosSimOrDevice(c);
+ await runWebosSimOrDevice();
}
}
}
};
-export const buildWebOSProject = async (c: RnvContext) => {
+export const buildWebOSProject = async () => {
+ const c = getContext();
logDefault('buildWebOSProject');
- await buildCoreWebpackProject(c);
+ await buildCoreWebpackProject();
if (!c.program.hosted) {
- const tDir = path.join(getPlatformProjectDir(c)!, 'build');
- const tOut = path.join(getAppFolder(c)!, 'output');
+ const tDir = path.join(getPlatformProjectDir()!, 'build');
+ const tOut = path.join(getAppFolder()!, 'output');
- const appinfoSrc = path.join(getPlatformProjectDir(c)!, 'appinfo.json');
+ const appinfoSrc = path.join(getPlatformProjectDir()!, 'appinfo.json');
const appinfoDest = path.join(tDir, 'appinfo.json');
copyFileSync(appinfoSrc, appinfoDest);
- copyFileSync(path.join(getPlatformProjectDir(c)!, 'icon.png'), path.join(tDir, 'icon.png'));
- copyFileSync(path.join(getPlatformProjectDir(c)!, 'largeIcon.png'), path.join(tDir, 'largeIcon.png'));
+ copyFileSync(path.join(getPlatformProjectDir()!, 'icon.png'), path.join(tDir, 'icon.png'));
+ copyFileSync(path.join(getPlatformProjectDir()!, 'largeIcon.png'), path.join(tDir, 'largeIcon.png'));
copyFileSync(
- path.join(getPlatformProjectDir(c)!, 'splashBackground.png'),
+ path.join(getPlatformProjectDir()!, 'splashBackground.png'),
path.join(tDir, 'splashBackground.png')
);
- await execCLI(c, CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${tDir} -n`);
+ await execCLI(CLI_WEBOS_ARES_PACKAGE, `-o ${tOut} ${tDir} -n`);
logSuccess(`Your IPK package is located in ${chalk().cyan(tOut)} .`);
}
};
-export const configureWebOSProject = async (c: RnvContext) => {
+export const configureWebOSProject = async () => {
+ const c = getContext();
logDefault('configureWebOSProject');
- const { platform } = c;
+ c.runtime.platformBuildsProjectPath = getPlatformProjectDir()!;
- c.runtime.platformBuildsProjectPath = getPlatformProjectDir(c)!;
+ if (!isPlatformActive()) return;
- if (!isPlatformActive(c, platform)) return;
-
- await copyAssetsFolder(c, platform);
+ await copyAssetsFolder();
await configureCoreWebProject();
await _configureProject(c);
- return copyBuildsFolder(c, platform);
+ return copyBuildsFolder();
};
const _configureProject = async (c: RnvContext) => {
logDefault('_configureProject');
- const { platform } = c;
const configFile = 'appinfo.json';
const injects: OverridesOptions = [
{
pattern: '{{APPLICATION_ID}}',
- override: getAppId(c, platform)?.toLowerCase(),
+ override: getAppId()?.toLowerCase(),
},
{
pattern: '{{APP_TITLE}}',
- override: getAppTitle(c, platform),
+ override: getAppTitle(),
},
{
pattern: '{{APP_VERSION}}',
- override: semver.coerce(getAppVersion(c, platform))?.format(),
+ override: semver.coerce(getAppVersion())?.format(),
},
{
pattern: '{{APP_DESCRIPTION}}',
- override: getAppDescription(c, platform),
+ override: getAppDescription(),
},
{
pattern: '{{APP_BG_COLOR}}',
- override: getConfigProp(c, platform, 'backgroundColor') || DEFAULTS.backgroundColor,
+ override: getConfigProp('backgroundColor') || DEFAULTS.backgroundColor,
},
{
pattern: '{{APP_ICON_COLOR}}',
- override: getConfigProp(c, platform, 'iconColor', '#000'),
+ override: getConfigProp('iconColor', '#000'),
},
{
pattern: '{{APP_VENDOR}}',
- override: getConfigProp(c, platform, 'author') || 'Unspecified',
+ override: getConfigProp('author') || 'Unspecified',
},
];
- addSystemInjects(c, injects);
+ addSystemInjects(injects);
- const file = path.join(getPlatformProjectDir(c)!, configFile);
+ const file = path.join(getPlatformProjectDir()!, configFile);
writeCleanFile(file, file, injects, undefined, c);
diff --git a/packages/sdk-webpack/src/env.ts b/packages/sdk-webpack/src/env.ts
index 4be8bf953d..f6d512b27c 100644
--- a/packages/sdk-webpack/src/env.ts
+++ b/packages/sdk-webpack/src/env.ts
@@ -24,12 +24,10 @@ export const EnvVars = {
};
},
PUBLIC_URL: () => {
- const ctx = getContext();
- return { PUBLIC_URL: getConfigProp(ctx, ctx.platform, 'webpackConfig')?.publicUrl || '.' };
+ return { PUBLIC_URL: getConfigProp('webpackConfig')?.publicUrl || '.' };
},
RNV_ENTRY_FILE: () => {
- const ctx = getContext();
- return { RNV_ENTRY_FILE: getConfigProp(ctx, ctx.platform, 'entryFile') };
+ return { RNV_ENTRY_FILE: getConfigProp('entryFile') };
},
PORT: () => {
const ctx = getContext();
@@ -56,48 +54,43 @@ export const getModuleConfigs = (): RnvModuleConfig => {
const doNotResolveModulePaths: Array = [];
// PLUGINS
- parsePlugins(
- c,
- c.platform,
- (plugin, pluginPlat, key) => {
- const { webpackConfig } = plugin;
+ parsePlugins((plugin, pluginPlat, key) => {
+ const { webpackConfig } = plugin;
- if (webpackConfig) {
- if (webpackConfig.modulePaths) {
- if (typeof webpackConfig.modulePaths === 'boolean') {
- if (webpackConfig.modulePaths) {
- modulePaths.push(`node_modules/${key}`);
- }
- } else {
- webpackConfig.modulePaths.forEach((v) => {
- modulePaths.push(v);
- });
+ if (webpackConfig) {
+ if (webpackConfig.modulePaths) {
+ if (typeof webpackConfig.modulePaths === 'boolean') {
+ if (webpackConfig.modulePaths) {
+ modulePaths.push(`node_modules/${key}`);
}
+ } else {
+ webpackConfig.modulePaths.forEach((v) => {
+ modulePaths.push(v);
+ });
}
- const wpMa = webpackConfig.moduleAliases;
- if (wpMa) {
- if (typeof wpMa === 'boolean') {
- moduleAliases[key] = doResolvePath(key, true, {}, c.paths.project.nodeModulesDir);
- } else {
- Object.keys(wpMa).forEach((aKey) => {
- const mAlias = wpMa[aKey];
- if (typeof mAlias === 'string') {
- moduleAliases[key] = doResolvePath(mAlias, true, {}, c.paths.project.nodeModulesDir);
- // DEPRECATED use => projectPath
- // } else if (mAlias.path) {
- // moduleAliases[key] = path.join(c.paths.project.dir, mAlias.path);
- } else if (includesPluginPath(mAlias.projectPath)) {
- moduleAliases[key] = sanitizePluginPath(mAlias.projectPath, key);
- } else if (mAlias.projectPath) {
- moduleAliases[key] = path.join(c.paths.project.dir, mAlias.projectPath);
- }
- });
- }
+ }
+ const wpMa = webpackConfig.moduleAliases;
+ if (wpMa) {
+ if (typeof wpMa === 'boolean') {
+ moduleAliases[key] = doResolvePath(key, true, {}, c.paths.project.nodeModulesDir);
+ } else {
+ Object.keys(wpMa).forEach((aKey) => {
+ const mAlias = wpMa[aKey];
+ if (typeof mAlias === 'string') {
+ moduleAliases[key] = doResolvePath(mAlias, true, {}, c.paths.project.nodeModulesDir);
+ // DEPRECATED use => projectPath
+ // } else if (mAlias.path) {
+ // moduleAliases[key] = path.join(c.paths.project.dir, mAlias.path);
+ } else if (includesPluginPath(mAlias.projectPath)) {
+ moduleAliases[key] = sanitizePluginPath(mAlias.projectPath, key);
+ } else if (mAlias.projectPath) {
+ moduleAliases[key] = path.join(c.paths.project.dir, mAlias.projectPath);
+ }
+ });
}
}
- },
- true
- );
+ }
+ }, true);
const moduleAliasesArray: Array = [];
Object.keys(moduleAliases).forEach((key) => {
diff --git a/packages/sdk-webpack/src/index.ts b/packages/sdk-webpack/src/index.ts
index 72c528b6a7..6fb617c717 100644
--- a/packages/sdk-webpack/src/index.ts
+++ b/packages/sdk-webpack/src/index.ts
@@ -19,9 +19,9 @@ import {
copyFileSync,
fsExistsSync,
RnvContext,
- RnvPlatform,
CoreEnvVars,
Env,
+ getContext,
} from '@rnv/core';
import { checkPortInUse, getDevServerHost, openBrowser, waitForHost, confirmActiveBundler } from '@rnv/sdk-utils';
import { EnvVars } from './env';
@@ -52,17 +52,12 @@ export const waitForUrl = (url: string) =>
}, CHECK_INTEVAL);
});
-const _runWebBrowser = (
- c: RnvContext,
- platform: RnvPlatform,
- devServerHost: string,
- port: number,
- alreadyStarted: boolean
-) =>
+const _runWebBrowser = (devServerHost: string, port: number, alreadyStarted: boolean) =>
new Promise((resolve) => {
+ const c = getContext();
logDefault('_runWebBrowser', `ip:${devServerHost} port:${port} openBrowser:${!!c.runtime.shouldOpenBrowser}`);
if (!c.runtime.shouldOpenBrowser) return resolve();
- const wait = waitForHost(c, '')
+ const wait = waitForHost('')
.then(() => {
openBrowser(`http://${devServerHost}:${port}/`);
})
@@ -78,7 +73,7 @@ const _runRemoteDebuggerChii = async (c: RnvContext, obj: { remoteDebuggerActive
try {
await commandExists('chii');
- const resolvedDebugIp = debugIp || getDevServerHost(c);
+ const resolvedDebugIp = debugIp || getDevServerHost();
logInfo(
`Starting a remote debugger build with ip ${resolvedDebugIp}. If this IP is not correct, you can always override it with --debugIp`
);
@@ -86,7 +81,7 @@ const _runRemoteDebuggerChii = async (c: RnvContext, obj: { remoteDebuggerActive
const debugUrl = chalk().cyan(`http://${resolvedDebugIp}:${REMOTE_DEBUG_PORT}`);
const command = `chii start --port ${REMOTE_DEBUG_PORT}`;
- executeAsync(c, command, { stdio: 'inherit', silent: true });
+ executeAsync(command, { stdio: 'inherit', silent: true });
try {
await waitForUrl(`http://${resolvedDebugIp}:${REMOTE_DEBUG_PORT}`);
@@ -115,7 +110,7 @@ const _runRemoteDebuggerWeinre = async (c: RnvContext, obj: { remoteDebuggerActi
try {
await commandExists('weinre');
- const resolvedDebugIp = debugIp || getDevServerHost(c);
+ const resolvedDebugIp = debugIp || getDevServerHost();
logInfo(
`Starting a remote debugger build with ip ${resolvedDebugIp}. If this IP is not correct, you can always override it with --debugIp`
);
@@ -123,7 +118,7 @@ const _runRemoteDebuggerWeinre = async (c: RnvContext, obj: { remoteDebuggerActi
const debugUrl = chalk().cyan(`http://${resolvedDebugIp}:${REMOTE_DEBUG_PORT}/client/#${c.platform}`);
const command = `weinre --boundHost -all- --httpPort ${REMOTE_DEBUG_PORT}`;
- executeAsync(c, command, { stdio: 'inherit', silent: true });
+ executeAsync(command, { stdio: 'inherit', silent: true });
try {
await waitForUrl(`http://${resolvedDebugIp}:${REMOTE_DEBUG_PORT}`);
@@ -190,7 +185,8 @@ export const _runWebDevServer = async (c: RnvContext, enableRemoteDebugger?: boo
await start();
};
-export const buildCoreWebpackProject = async (c: RnvContext) => {
+export const buildCoreWebpackProject = async () => {
+ const c = getContext();
const { debug, debugIp } = c.program;
logDefault('buildCoreWebpackProject');
const env: Record = {
@@ -210,7 +206,7 @@ export const buildCoreWebpackProject = async (c: RnvContext) => {
if (debug) {
logInfo(
`Starting a remote debugger build with ip ${
- debugIp || getDevServerHost(c)
+ debugIp || getDevServerHost()
}. If this IP is not correct, you can always override it with --debugIp`
);
// process.env.RNV_INJECTED_WEBPACK_SCRIPTS += `DEBUG_IP=${debugIp || ip.address()}`;
@@ -224,21 +220,22 @@ export const configureCoreWebProject = async () => {
logDefault('configureCoreWebProject');
};
-export const runWebpackServer = async (c: RnvContext, enableRemoteDebugger?: boolean) => {
+export const runWebpackServer = async (enableRemoteDebugger?: boolean) => {
+ const c = getContext();
const { port } = c.runtime;
const { platform } = c;
logDefault('runWeb', `port:${port} debugger:${!!enableRemoteDebugger}`);
let devServerHost = c.runtime.localhost;
- devServerHost = getDevServerHost(c);
+ devServerHost = getDevServerHost();
- const isPortActive = await checkPortInUse(c, platform, port);
- const bundleAssets = getConfigProp(c, c.platform, 'bundleAssets', false);
+ const isPortActive = await checkPortInUse(port);
+ const bundleAssets = getConfigProp('bundleAssets', false);
if (bundleAssets) {
logSuccess('bundleAssets set to true. webpack dev server will not run');
- await buildCoreWebpackProject(c);
+ await buildCoreWebpackProject();
return true;
}
@@ -248,34 +245,35 @@ export const runWebpackServer = async (c: RnvContext, enableRemoteDebugger?: boo
port
)} is not running. Starting it up for you...`
);
- await _runWebBrowser(c, platform, devServerHost, port, false);
+ await _runWebBrowser(devServerHost, port, false);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
await _runWebDevServer(c, enableRemoteDebugger);
} else {
- const resetCompleted = await confirmActiveBundler(c);
+ const resetCompleted = await confirmActiveBundler();
if (resetCompleted) {
- await _runWebBrowser(c, platform, devServerHost, port, false);
+ await _runWebBrowser(devServerHost, port, false);
if (!bundleAssets) {
logSummary('BUNDLER STARTED');
}
await _runWebDevServer(c, enableRemoteDebugger);
} else {
- await _runWebBrowser(c, platform, devServerHost, port, true);
+ await _runWebBrowser(devServerHost, port, true);
}
}
};
-export const waitForWebpack = async (c: RnvContext, suffix = 'assets/bundle.js') => {
+export const waitForWebpack = async (suffix = 'assets/bundle.js') => {
+ const c = getContext();
logDefault('waitForWebpack', `port:${c.runtime.port}`);
let attempts = 0;
const maxAttempts = 10;
const CHECK_INTEVAL = 2000;
// const spinner = ora('Waiting for webpack to finish...').start();
- const devServerHost = getDevServerHost(c);
+ const devServerHost = getDevServerHost();
const url = `http://${devServerHost}:${c.runtime.port}/${suffix}`;
return new Promise((resolve, reject) => {
@@ -307,34 +305,34 @@ export const waitForWebpack = async (c: RnvContext, suffix = 'assets/bundle.js')
});
};
-export const buildWeb = async (c: RnvContext) => buildCoreWebpackProject(c);
+export const buildWeb = async () => buildCoreWebpackProject();
-export const configureWebProject = async (c: RnvContext) => {
+export const configureWebProject = async () => {
+ const c = getContext();
logDefault('configureWebProject');
- const { platform } = c;
-
- c.runtime.platformBuildsProjectPath = getPlatformProjectDir(c) || undefined;
+ c.runtime.platformBuildsProjectPath = getPlatformProjectDir() || undefined;
- if (!isPlatformActive(c, platform)) return;
+ if (!isPlatformActive()) return;
- await copyAssetsFolder(c, platform);
+ await copyAssetsFolder();
await configureCoreWebProject();
- return copyBuildsFolder(c, platform);
+ return copyBuildsFolder();
};
// CHROMECAST
-export const configureChromecastProject = async (c: RnvContext) => {
+export const configureChromecastProject = async () => {
+ const c = getContext();
logDefault(`configureChromecastProject:${c.platform}`);
- c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir(c)}`;
+ c.runtime.platformBuildsProjectPath = `${getPlatformProjectDir()}`;
- await copyAssetsFolder(c, c.platform);
+ await copyAssetsFolder();
await configureCoreWebProject();
await _configureProject(c);
- return copyBuildsFolder(c, c.platform);
+ return copyBuildsFolder();
};
const _configureProject = async (c: RnvContext) => {
@@ -343,5 +341,5 @@ const _configureProject = async (c: RnvContext) => {
export const runChromecast = async (c: RnvContext) => {
logDefault(`runChromecast:${c.platform}`);
- await runWebpackServer(c);
+ await runWebpackServer();
};
diff --git a/packages/template-starter/buildHooks/tsconfig.json b/packages/template-starter/buildHooks/tsconfig.json
deleted file mode 100644
index 82dac4d899..0000000000
--- a/packages/template-starter/buildHooks/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "@rnv/core/tsconfig.hooks.json",
- "compilerOptions": {
- "outDir": "dist",
- "rootDir": "src"
- }
-}
diff --git a/packages/template-starter/package.json b/packages/template-starter/package.json
index af1919b3a7..24a4df0905 100644
--- a/packages/template-starter/package.json
+++ b/packages/template-starter/package.json
@@ -129,5 +129,8 @@
"browserslist": [
">0.2%",
"op_mini all"
- ]
-}
\ No newline at end of file
+ ],
+ "dependencies": {
+ "raf": "3.4.1"
+ }
+}
diff --git a/packages/template-starter/renative.json b/packages/template-starter/renative.json
index 8b87fd95c3..3f8b9c90ef 100644
--- a/packages/template-starter/renative.json
+++ b/packages/template-starter/renative.json
@@ -1,4 +1,5 @@
{
+ "$schema": ".rnv/schema/rnv.project.json",
"engines": {
"@rnv/engine-lightning": "source:rnv",
"@rnv/engine-rn": "source:rnv",
@@ -7,7 +8,6 @@
"@rnv/engine-rn-tvos": "source:rnv",
"@rnv/engine-rn-web": "source:rnv"
},
- "$schema": ".rnv/schema/rnv.project.json",
"isTemplate": true,
"projectName": "@rnv/template-starter",
"enableHookRebuild": false,
@@ -95,7 +95,7 @@
"org.gradle.parallel": true,
"org.gradle.configureondemand": true
},
- "MainActivity_java": {
+ "MainActivity_kt": {
"onCreate": "super.onCreate(null)"
}
}
diff --git a/packages/template-starter/renative.template.json b/packages/template-starter/renative.template.json
index 2c2366fc99..7da29a1354 100644
--- a/packages/template-starter/renative.template.json
+++ b/packages/template-starter/renative.template.json
@@ -1,22 +1,29 @@
{
"$schema": ".rnv/schema/rnv.template.json",
"templateConfig": {
+ "disabled": false,
"includedPaths": [
- "buildHooks",
- "src",
- "index.js",
- "tsconfig.json",
- "Gemfile",
- "metro.config.js",
- ".bundle",
- "react-native.config.js",
- "babel.config.js",
- "next.config.js",
- "next-env.d.ts",
- "typings",
- "webpack.config.js"
+ {
+ "paths": ["buildHooks", "src", "index.js", "tsconfig.json", "babel.config.js", "typings"]
+ },
+ {
+ "paths": ["Gemfile", "metro.config.js", ".bundle", "react-native.config.js"],
+ "engines": ["engine-rn", "engine-rn-tvos"]
+ },
+ {
+ "paths": ["next.config.js", "next-env.d.ts"],
+ "engines": ["engine-rn-next"]
+ },
+ {
+ "paths": ["webpack.config.js"],
+ "engines": ["engine-web"]
+ }
],
- "packageTemplate": {
+ "renative_json": {
+ "$schema": ".rnv/schema/rnv.project.json",
+ "extendsTemplate": "@rnv/template-starter/renative.json"
+ },
+ "package_json": {
"devDependencies": {
"typescript": "5.0.4",
"@types/react": "18.2.52",
@@ -27,16 +34,8 @@
"babel-loader": "9.1.3"
},
"browserslist": {
- "production": [
- ">0.2%",
- "not dead",
- "not op_mini all"
- ],
- "development": [
- "last 1 chrome version",
- "last 1 firefox version",
- "last 1 safari version"
- ]
+ "production": [">0.2%", "not dead", "not op_mini all"],
+ "development": ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
},
"resolutions": {
"@babel/traverse": "7.15.0",
@@ -44,7 +43,10 @@
}
}
},
- "platforms": {},
- "plugins": {},
- "extendsTemplate": "@rnv/template-starter/renative.json"
-}
\ No newline at end of file
+ "bootstrapConfig": {
+ "rnvNewPatchDependencies": {
+ "pkg-dir": "7.0.0",
+ "xmlbuilder": "^15.1.1"
+ }
+ }
+}
diff --git a/packages/template-starter/renative.template.spec.json b/packages/template-starter/renative.template.spec.json
new file mode 100644
index 0000000000..32a552faa6
--- /dev/null
+++ b/packages/template-starter/renative.template.spec.json
@@ -0,0 +1,105 @@
+{
+ "$schema": ".rnv/schema/rnv.template.json",
+ "templateConfig": {
+ "disabled": false,
+ "includedPaths": [
+ {
+ "paths": ["buildHooks", "src", "index.js", "tsconfig.json", "babel.config.js", "typings"]
+ },
+ {
+ "paths": ["Gemfile", "metro.config.js", ".bundle", "react-native.config.js"],
+ "engines": ["engine-rn", "engine-rn-tvos"]
+ },
+ {
+ "paths": ["next.config.js", "next-env.d.ts"],
+ "engines": ["engine-rn-next"]
+ },
+ {
+ "paths": ["webpack.config.js"],
+ "engines": ["engine-web"]
+ }
+ ],
+ "renative_json": {
+ "$schema": ".rnv/schema/rnv.project.json",
+ "extendsTemplate": "@rnv/template-starter/renative.json"
+ },
+ "package_json": {
+ "devDependencies": {
+ "typescript": "5.0.4",
+ "@types/react": "18.2.52",
+ "@types/react-dom": "18.2.18",
+ "@types/react-native": "0.72.3",
+ "@flexn/typescript-config": "1.0.0",
+ "@flexn/assets-renative-outline": "0.3.3",
+ "babel-loader": "9.1.3"
+ },
+ "browserslist": {
+ "production": [">0.2%", "not dead", "not op_mini all"],
+ "development": ["last 1 chrome version", "last 1 firefox version", "last 1 safari version"]
+ },
+ "resolutions": {
+ "@babel/traverse": "7.15.0",
+ "@types/react": "18.2.52"
+ }
+ }
+ },
+ "bootstrapConfig": {
+ "rnvNewPatchDependencies": {
+ "pkg-dir": "7.0.0",
+ "xmlbuilder": "^15.1.1"
+ },
+ "bootstrapQuestions": [
+ {
+ "type": "textInput",
+ "title": "App name?",
+ "onConfirm": [
+ {
+ "action": "writeToFile",
+ "path": "./appConfig/hello/renative.json",
+ "prop": "common.id"
+ }
+ ]
+ },
+ {
+ "type": "confirm",
+ "title": "Need git?",
+ "onConfirm": [
+ {
+ "action": "deleteFile",
+ "path": "./gitignore"
+ }
+ ]
+ },
+ {
+ "type": "list",
+ "title": "Pick provider",
+ "options": [
+ {
+ "value": "aws",
+ "title": "AWS"
+ },
+ {
+ "value": "firebase",
+ "title": "Firebase"
+ }
+ ],
+ "onConfirm": [
+ {
+ "action": "writeToFile",
+ "path": "./renative.json",
+ "prop": "runtime.provider"
+ }
+ ]
+ }
+ ],
+ "configModifiers": {
+ "engines": [
+ {
+ "name": "@rnv/engine-lightning",
+ "supportedPlatforms": ["tizen", "webos"],
+ "nullifyIfFalse": true
+ }
+ ]
+ }
+ }
+}
diff --git a/packages/template-starter/src/app/index.tsx b/packages/template-starter/src/app/index.tsx
index eb8cebf05f..452d2f10d2 100644
--- a/packages/template-starter/src/app/index.tsx
+++ b/packages/template-starter/src/app/index.tsx
@@ -23,7 +23,7 @@ const AppThemed = () => {
return (
-
+
{
+const getFlexShrinkPropertyValue = () => {
return isPlatformAndroidwear ? 0 : 1;
};
if (!global.performance) {
@@ -70,15 +70,20 @@ const createStyleSheet = (currentTheme) =>
bottom: 0,
right: 0,
backgroundColor: currentTheme.colorBgPrimary,
+ justifyContent: 'center',
+ display: 'flex',
+ alignItems: 'center',
+ },
+ scrollView: {
+ flexGrow: 0,
+ width: '100%',
},
-
container: {
- justifyContent: 'center',
+ flexShrink: getFlexShrinkPropertyValue(),
alignItems: 'center',
paddingVertical: getScaledValue(10),
- minHeight: getScaledValue(300),
+ minHeight: 'auto',
alignSelf: 'stretch',
- flex: getFlexPropertyValue(),
backgroundColor: currentTheme.colorBgPrimary,
},
textH2: {
@@ -149,6 +154,7 @@ export type ThemeInterface = {
image: ImageStyle;
button: ViewStyle;
buttonText: TextStyle;
+ scrollView: ViewStyle;
};
};
dark: boolean;
diff --git a/yarn.lock b/yarn.lock
index e8f8acd7d0..dc4c737958 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7096,6 +7096,11 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
+base-64@0.1.0, base-64@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb"
+ integrity sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==
+
base64-js@^1.1.2, base64-js@^1.3.1, base64-js@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
@@ -11249,6 +11254,18 @@ glob@10.3.10, glob@^10.2.2, glob@^10.3.10, glob@^10.3.3, glob@^10.3.7:
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"
path-scurry "^1.10.1"
+glob@7.0.6:
+ version "7.0.6"
+ resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.6.tgz#211bafaf49e525b8cd93260d14ab136152b3f57a"
+ integrity sha512-f8c0rE8JiCxpa52kWPAOa3ZaYEnzofDzCQLCn3Vdk0Z5OVLq3BsRFJI4S4ykpeVW6QMGBUkMeUpoEgWnMTnw5Q==
+ dependencies:
+ fs.realpath "^1.0.0"
+ inflight "^1.0.4"
+ inherits "2"
+ minimatch "^3.0.2"
+ once "^1.3.0"
+ path-is-absolute "^1.0.0"
+
glob@7.1.4:
version "7.1.4"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255"
@@ -16797,6 +16814,11 @@ pluralize@8.0.0, pluralize@^8.0.0:
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1"
integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==
+pod-installer@0.0.0:
+ version "0.0.0"
+ resolved "https://registry.yarnpkg.com/pod-installer/-/pod-installer-0.0.0.tgz#363290ec9f2eb7a88bc3e1f229793efdcc7c81c6"
+ integrity sha512-5GFFvaXwESMx0QoopeJqFZzi4xOqI86Lh65WqWAVuZNorUio4/ZBRx7AQBfwnBwOeGA/JjXHP+nHZmSKWGoG1g==
+
popper.js@^1.14.4:
version "1.16.1"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
@@ -17924,6 +17946,14 @@ react-native-carplay@2.3.0:
dependencies:
traverse "^0.6.6"
+react-native-fs@2.20.0:
+ version "2.20.0"
+ resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.20.0.tgz#05a9362b473bfc0910772c0acbb73a78dbc810f6"
+ integrity sha512-VkTBzs7fIDUiy/XajOSNk0XazFE9l+QlMAce7lGuebZcag5CnjszB+u4BdqzwaQOdcYb5wsJIsqq4kxInIRpJQ==
+ dependencies:
+ base-64 "^0.1.0"
+ utf8 "^3.0.0"
+
react-native-gesture-handler@2.14.1:
version "2.14.1"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.14.1.tgz#930640231024b7921435ab476aa501dd4a6b2e01"
@@ -17945,10 +17975,11 @@ react-native-permissions@4.1.4:
resolved "https://registry.yarnpkg.com/react-native-permissions/-/react-native-permissions-4.1.4.tgz#7e105470acea7fc1748bb36915095fd3304cd9da"
integrity sha512-el6u90VZNFDEtmHpSheirwRhGvs6M5rSZcoqIqB128IPO00f2c1q+PP4kEaM1u19Q0ldQ+R+S7C/l8Zrduy6JQ==
-react-native-photo-editor@1.0.13:
- version "1.0.13"
- resolved "https://registry.yarnpkg.com/react-native-photo-editor/-/react-native-photo-editor-1.0.13.tgz#292d2f1a87bb3fb9b75000683f05664f360bdf6b"
- integrity sha512-SWrnatVC4H73cEN+6rVlc0M5cGS20K6EwL8u2CmlBlLNEwH6OfayMgOCwpKJdmN2GPZKJ2JraQru8Ga7JL4zaw==
+"react-native-photo-editor@github:AppGyver/react-native-photo-editor#v0.1.2":
+ version "0.1.1"
+ resolved "https://codeload.github.com/AppGyver/react-native-photo-editor/tar.gz/ed05b06d13df9945433bf84366b3e4f01787c0ae"
+ dependencies:
+ pod-installer "0.0.0"
react-native-splash-screen@3.3.0:
version "3.3.0"
@@ -18738,6 +18769,14 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"
+rn-fetch-blob@0.12.0:
+ version "0.12.0"
+ resolved "https://registry.yarnpkg.com/rn-fetch-blob/-/rn-fetch-blob-0.12.0.tgz#ec610d2f9b3f1065556b58ab9c106eeb256f3cba"
+ integrity sha512-+QnR7AsJ14zqpVVUbzbtAjq0iI8c9tCg49tIoKO2ezjzRunN7YL6zFSFSWZm6d+mE/l9r+OeDM3jmb2tBb2WbA==
+ dependencies:
+ base-64 "0.1.0"
+ glob "7.0.6"
+
roarr@^2.15.3:
version "2.15.4"
resolved "https://registry.yarnpkg.com/roarr/-/roarr-2.15.4.tgz#f5fe795b7b838ccfe35dc608e0282b9eba2e7afd"
@@ -21065,6 +21104,11 @@ utf8-byte-length@^1.0.1:
resolved "https://registry.yarnpkg.com/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz#f45f150c4c66eee968186505ab93fcbb8ad6bf61"
integrity sha512-4+wkEYLBbWxqTahEsWrhxepcoVOJ+1z5PGIjPZxRkytcdSUaNjIjBM7Xn8E+pdSuV7SzvWovBFA54FO0JSoqhA==
+utf8@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1"
+ integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==
+
util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"