
set BASE_DIR=%cd%\..
set BASE_DIR=%BASE_DIR:\=\\%

echo "base dir is : %BASE_DIR%"

echo "Checking for Mobile First and React Native version compatibility..."

::List the version of react-native package installed
FOR /F %%a in ('node -pe "require('%BASE_DIR%\\react-native\\package.json')['version']"') do SET RN_VERSION=%%a

::Remove . and ^ from the resultant RN version
SET VERSION=%RN_VERSION:.=%
SET MIN=0615

::Check if react-native version is available. Else throw an error stating to install react-native package first
echo %VERSION%|findstr /r "^[0-9]*$">nul

if %errorlevel% equ 0 (
	echo "react-native version identified."
) else (
	echo "No react-native module found. Please install react-native equal to or above version 0.61.5 and then install the Mobile First react-native package. "
	::Adding a syntax error to throw an error and stop the process
	else(
)

::Check if minimum required react-native version is matched. If not, exit the installation process.
if %VERSION% GEQ %MIN% (
echo "Successful installation"
) else (
echo "MF does not support apps using react-native version below version 0.61.5. Please upgrade to react-native greater than or equal to version 0.61.5 to use Mobile First"
::Adding a syntax error to throw an error and stop the process
else(
)


