diff --git a/Makefile b/Makefile index 23a809d50..7e8d8d4b5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ -.PHONY: run check-style test clean +.PHONY: run run-ios run-android check-style test clean .npminstall: package.json + @if ! [ $(shell command -v npm) ]; then \ + echo "npm is not installed"; \ + exit 1; \ + fi + @echo Getting dependencies using npm npm install @@ -8,13 +13,38 @@ touch $@ config/config.secret.json: - @echo Generating default config/config.secret.json - @echo '{}' > config/config.secret.json + @if ! [ $(shell test -f config/config.secret.json) ]; then \ + echo "Generating default config/config.secret.json"; \ + echo '{}' > "config/config.secret.json"; \ + fi -run: .npminstall config/config.secret.json - @echo Running Mobile iOS Apps for development +run: run-ios - react-native run-ios +run-ios: .npminstall config/config.secret.json + @if ! [ $(shell command -v xcodebuild) ]; then \ + echo "xcode is not installed"; \ + exit 1; \ + fi + @echo Running iOS app in development + + npm run run-ios + +run-android: .npminstall config/config.secret.json + @if ! [ $(ANDROID_HOME) ]; then \ + echo "ANDROID_HOME is not set"; \ + exit 1; \ + fi + @if ! [ $(shell command -v adb) ]; then \ + echo "adb is not installed"; \ + exit 1; \ + fi + @if ! [ $(shell adb get-state) == "device" ]; then \ + echo "no android device or emulator is running"; \ + exit 1; \ + fi + @echo Running Android app in development + + npm run run-android test: .npminstall config/config.secret.json npm test @@ -27,5 +57,6 @@ check-style: .npminstall clean: @echo Cleaning app + npm cache clean rm -rf node_modules - rm -f .npminstall \ No newline at end of file + rm -f .npminstall diff --git a/package.json b/package.json index 7ace27641..634abdb67 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,8 @@ }, "scripts": { "check": "node_modules/.bin/eslint --ext \".js\" --ignore-pattern node_modules --quiet .", + "run-ios": "node node_modules/react-native/local-cli/cli.js run-ios", + "run-android": "node node_modules/react-native/local-cli/cli.js run-android", "start": "node node_modules/react-native/local-cli/cli.js start", "test": "mocha --compilers js:babel-register --require babel-polyfill", "postinstall": "remotedev-debugger --hostname localhost --port 5678 --injectserver"