mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-10 22:36:01 +00:00
Add environment-check script (#1199)
* Add environment-check script * Check version without using semver module
This commit is contained in:
parent
e4e1431c55
commit
f55fa10b6b
@ -74,7 +74,8 @@
|
||||
"win-revert-symlinks": "npm run isWin -s && npm run alias:win:apply && git checkout-symlinks && npm run alias:win:revert || echo .",
|
||||
"prereact-tests-android": "npm run isWin -s && npm run win-fix-symlinks || echo . ",
|
||||
"react-tests-android": "node scripts/react-tests-android.js || npm run postreact-tests-android",
|
||||
"postreact-tests-android": "npm run win-revert-symlinks"
|
||||
"postreact-tests-android": "npm run win-revert-symlinks",
|
||||
"check-environment": "node scripts/check-environment.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"extract-zip": "^1.6.0",
|
||||
|
59
scripts/check-environment.js
Normal file
59
scripts/check-environment.js
Normal file
@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const exec = require('child_process').exec;
|
||||
|
||||
console.log('Checking setup...');
|
||||
|
||||
function successLog(msg) {
|
||||
console.log(` \x1b[32m✓\x1b[0m ${msg}`);
|
||||
}
|
||||
|
||||
function validateEnvPath(envKey) {
|
||||
if (process.env.hasOwnProperty(envKey)) {
|
||||
const resolvedPath = path.resolve(process.env[envKey]);
|
||||
if (process.env[envKey].indexOf('~') !== -1 || resolvedPath !== process.env[envKey]) {
|
||||
console.error(`The ${envKey} environment variable is set to ${process.env[envKey]}.`)
|
||||
console.error('Since gyp doesn\'t expand user- and relative paths, this path will not work. Please use a fully resolved path');
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
successLog(`${envKey} set to ${process.env[envKey]}`);
|
||||
} else {
|
||||
successLog(`${envKey} not set, downloading binaries`);
|
||||
}
|
||||
}
|
||||
|
||||
exec('npm --version', (err, stdout) => {
|
||||
const verRegex = /^(\d+\.)?(\d+\.)?(\*|\d+)$/;
|
||||
const npmVer = stdout.trim();
|
||||
if (!verRegex.test(npmVer)) {
|
||||
console.error(`npm --version returned '${npmVer}. Is Node installed?`);
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
const matches = verRegex.exec(npmVer);
|
||||
const majorVer = +matches[1];
|
||||
|
||||
if (majorVer >= 5) {
|
||||
console.error(`Installed version of npm (${npmVer}) which uses symbolic links for local packages.`);
|
||||
console.error('This is currently incompatible with our tests. Please use npm version 4 or less');
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
successLog(`npm version is ${npmVer}`);
|
||||
|
||||
const objectStoreDir = path.join(__dirname, '..', 'src', 'object-store');
|
||||
if (fs.existsSync(objectStoreDir)) {
|
||||
successLog('Object store submodule is checked out');
|
||||
} else {
|
||||
console.error('Object store folder not found. Did you remember to pull submodules?')
|
||||
}
|
||||
|
||||
validateEnvPath('REALM_CORE_PREFIX');
|
||||
validateEnvPath('REALM_SYNC_PREFIX');
|
||||
|
||||
// TODO: Check ANDROID_NDK and SDK for Android, and XCode for iOS.
|
||||
|
||||
});
|
@ -243,6 +243,9 @@ fi
|
||||
rm -rf ~/.yarn-cache/npm-realm-*
|
||||
|
||||
case "$TARGET" in
|
||||
"check-environment")
|
||||
npm run check-environment
|
||||
;;
|
||||
"eslint")
|
||||
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
||||
npm run eslint
|
||||
@ -268,6 +271,7 @@ case "$TARGET" in
|
||||
stop_server
|
||||
;;
|
||||
"react-tests")
|
||||
npm run check-environment
|
||||
download_server
|
||||
start_server
|
||||
pushd tests/react-test-app
|
||||
@ -280,6 +284,7 @@ case "$TARGET" in
|
||||
stop_server
|
||||
;;
|
||||
"react-example")
|
||||
npm run check-environment
|
||||
pushd examples/ReactExample
|
||||
|
||||
npm install
|
||||
@ -290,6 +295,7 @@ case "$TARGET" in
|
||||
xctest ReactExample
|
||||
;;
|
||||
"react-tests-android")
|
||||
npm run check-environment
|
||||
if [ "$(uname)" = 'Darwin' ]; then
|
||||
download_server
|
||||
start_server
|
||||
@ -335,6 +341,7 @@ case "$TARGET" in
|
||||
|
||||
;;
|
||||
"node")
|
||||
npm run check-environment
|
||||
if [ "$(uname)" = 'Darwin' ]; then
|
||||
download_server
|
||||
start_server
|
||||
@ -395,6 +402,7 @@ case "$TARGET" in
|
||||
fi
|
||||
;;
|
||||
"test-runners")
|
||||
npm run check-environment
|
||||
# Create a fake realm module that points to the source root so that test-runner tests can require('realm')
|
||||
npm install --build-from-source
|
||||
npm run test-runners
|
||||
|
Loading…
x
Reference in New Issue
Block a user