forked from XRPL-Labs/Xaman-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
132 lines (103 loc) · 4.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.EXPORT_ALL_VARIABLES:
.PHONY: clean validate-style start stop run run-ios run-android build build-ios build-android lear test help test-e2e
OS := $(shell sh -c 'uname -s 2>/dev/null')
VARIANT ?= Debug
SIMULATOR ?= iPhone 15 Pro Max
DETOX_CONFIGURATION ?= ios.simulator+xaman.ios
# Function definitions ============================
define start_packager
@if [ $(shell ps -ef | grep -i "cli.js start" | grep -civ grep) -eq 0 ]; then \
echo Starting React Native packager server; \
npm start & echo; \
fi
endef
define stop_packager
@if [ $(shell ps -ef | grep -i "cli.js start" | grep -civ grep) -eq 1 ]; then \
ps -ef | grep -i "cli.js start" | grep -iv grep | awk '{print $$2}' | xargs kill -9; \
echo React Native packager server stopped; \
fi
endef
# New function to check if a command exists in the system
define check_command_exist
@if ! [ $(shell which $(1) 2> /dev/null) ]; then \
echo "$(1) command is not found. Please, ensure it is installed."; \
exit 1; \
fi
endef
# Private Targets ===========================================
.node_modules: package.json ## Check if we need to install the npm packages
@if ! [ $(shell which npm 2> /dev/null) ]; then \
@echo "npm is not installed https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"; \
exit 1; \
fi
@if npm list --depth=0 | grep -Eq "from the root project|npm ERR! missing:"; then \
@echo "Update/Install dependencies required, please install node dependencies"; \
exit 1; \
fi
.build_env: ## Run script for building the env files
@./scripts/build-env.sh
.pre-android: ## Check if all requirements is met for running/building android version
@if ! [ $(ANDROID_HOME) ]; then \
@echo "$ANDROID_HOME is not set in $PATH env"; \
exit 1; \
fi
@if ! [ $(shell which adb 2> /dev/null) ]; then \
@echo "adb is not installed"; \
exit 1; \
fi
.pre-ios: ## Check if all requirements is met for running/building ios version
ifeq ($(OS), Darwin)
@bundle install
@cd ios && bundle exec pod install;
endif
@touch $@
.pre-run: | .node_modules .build_env # Check if everything is ready for running/building the app
# Public Targets ===========================================
validate-style: .node_modules ## Runs eslint
@echo Checking for style guide compliance
@npm run validate
clean: ## Cleans dependencies, previous builds and temp files
@rm -f .podinstall
@rm -rf ios/Pods
@rm -rf node_modules
@rm -rf ios/build
@rm -rf android/app/build
@echo Done :+1:
start: | .pre-run ## Starts the React Native packager server
$(call start_packager)
stop: | .pre-run ## Stops the React Native packager server
$(call stop_packager)
run: run-ios ## alias for run-ios
run-ios: | .pre-run .pre-ios ## Runs the app on an iOS simulator
$(call start_packager)
@echo Running iOS app in ${VARIANT}
@npx react-native run-ios --simulator="${SIMULATOR}" --mode=${VARIANT}
run-android: | .pre-run .pre-ios ## Runs the app on an Android emulator or dev device
$(call start_packager)
@while [ -z "$(shell adb devices | grep -w device)" ]; do \
echo "Waiting for Android device to be connected..."; \
sleep 5; \
done
@echo Running Android app in ${VARIANT} mode
@for device in $(shell adb devices | tail -n +2 | cut -sf 1); do \
export ANDROID_SERIAL=$$device ; \
npx react-native run-android --main-activity LaunchActivity --no-packager --mode=${VARIANT}; \
done
build-ios: | stop .pre-run .pre-ios ## Builds the iOS app
@echo Building iOS app in ${VARIANT} mode;
@npx react-native build-ios --mode=${VARIANT}
build-android: | stop .pre-run .pre-android ## Build the Android app
@echo Building Android app in ${VARIANT} mode;
@npx react-native build-android --mode=${VARIANT};
test: | .pre-run
@npm run test
test-e2e: | .pre-run ## Runs e2e tests
@npx detox clean-framework-cache;
@npx detox build-framework-cache;
@npx detox build e2e --configuration ${DETOX_CONFIGURATION} --if-missing;
@npx cucumber-js ./e2e test;
bump-build-number: ## Bump build number for Android and iOS
@./scripts/bump-build-number.sh;
## Help documentation https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'