Files
Krow-workspace/makefiles/mobile.mk

104 lines
5.4 KiB
Makefile

# --- Mobile App Development ---
.PHONY: mobile-install mobile-info mobile-analyze mobile-client-dev-android mobile-staff-dev-android mobile-client-build mobile-staff-build mobile-hot-reload mobile-hot-restart test-e2e test-e2e-setup test-e2e-client test-e2e-staff
MOBILE_DIR := apps/mobile
# Device ID for running mobile apps (override with DEVICE=<id>)
# Find your device ID with: flutter devices
DEVICE ?= android
# Environment (dev, stage, prod) — defaults to dev
ENV ?= dev
# --- General ---
mobile-install: install-melos dataconnect-generate-sdk
@echo "--> Bootstrapping mobile workspace (Melos)..."
@cd $(MOBILE_DIR) && melos bootstrap
@echo "--> Generating localization files..."
@cd $(MOBILE_DIR) && melos run gen:l10n
mobile-info:
@echo "--> Fetching mobile command info..."
@cd $(MOBILE_DIR) && melos run info
mobile-analyze:
@echo "--> Analyzing mobile workspace for compile-time errors..."
@cd $(MOBILE_DIR) && flutter analyze
# --- Hot Reload & Restart ---
mobile-hot-reload:
@echo "--> Triggering hot reload for running Flutter app..."
@cd $(MOBILE_DIR) && echo "r" | nc localhost 54321 2>/dev/null || \
(cd apps/client && flutter attach --pid-file /tmp/flutter_client.pid && echo "r") || \
(cd apps/staff && flutter attach --pid-file /tmp/flutter_staff.pid && echo "r") || \
echo "❌ No running Flutter app found. Start an app first with mobile-client-dev-android or mobile-staff-dev-android"
mobile-hot-restart:
@echo "--> Triggering hot restart for running Flutter app..."
@cd $(MOBILE_DIR) && echo "R" | nc localhost 54321 2>/dev/null || \
(cd apps/client && flutter attach --pid-file /tmp/flutter_client.pid && echo "R") || \
(cd apps/staff && flutter attach --pid-file /tmp/flutter_staff.pid && echo "R") || \
echo "❌ No running Flutter app found. Start an app first with mobile-client-dev-android or mobile-staff-dev-android"
# --- Client App ---
mobile-client-dev-android: dataconnect-generate-sdk
@echo "--> Running client app on Android (device: $(DEVICE), env: $(ENV))..."
@cd $(MOBILE_DIR) && melos run start:client -- -d $(DEVICE) --flavor $(ENV) --dart-define-from-file=../../config.$(ENV).json
mobile-client-build: dataconnect-generate-sdk
@if [ -z "$(PLATFORM)" ]; then \
echo "ERROR: PLATFORM is required (e.g. make mobile-client-build PLATFORM=apk)"; exit 1; \
fi
$(eval MODE ?= release)
@echo "--> Building client app for $(PLATFORM) in $(MODE) mode (env: $(ENV))..."
@cd $(MOBILE_DIR) && \
melos exec --scope="core_localization" -- "dart run slang" && \
melos exec --scope="core_localization" -- "dart run build_runner build --delete-conflicting-outputs" && \
melos exec --scope="krowwithus_client" -- "flutter build $(PLATFORM) --$(MODE) --flavor $(ENV) --dart-define-from-file=../../config.$(ENV).json"
# --- Staff App ---
mobile-staff-dev-android: dataconnect-generate-sdk
@echo "--> Running staff app on Android (device: $(DEVICE), env: $(ENV))..."
@cd $(MOBILE_DIR) && melos run start:staff -- -d $(DEVICE) --flavor $(ENV) --dart-define-from-file=../../config.$(ENV).json
mobile-staff-build: dataconnect-generate-sdk
@if [ -z "$(PLATFORM)" ]; then \
echo "ERROR: PLATFORM is required (e.g. make mobile-staff-build PLATFORM=apk)"; exit 1; \
fi
$(eval MODE ?= release)
@echo "--> Building staff app for $(PLATFORM) in $(MODE) mode (env: $(ENV))..."
@cd $(MOBILE_DIR) && \
melos exec --scope="core_localization" -- "dart run slang" && \
melos exec --scope="core_localization" -- "dart run build_runner build --delete-conflicting-outputs" && \
melos exec --scope="krowwithus_staff" -- "flutter build $(PLATFORM) --$(MODE) --flavor $(ENV) --dart-define-from-file=../../config.$(ENV).json"
# --- E2E (Maestro) ---
# Set env before running: TEST_CLIENT_EMAIL, TEST_CLIENT_PASSWORD, TEST_CLIENT_COMPANY, TEST_STAFF_PHONE, TEST_STAFF_OTP, TEST_STAFF_SIGNUP_PHONE
# Example: export TEST_CLIENT_EMAIL=legendary@krowd.com TEST_CLIENT_PASSWORD=Demo2026!
# Example: export TEST_STAFF_PHONE=5557654321 TEST_STAFF_OTP=123456
test-e2e-setup:
@echo "--> Checking Maestro CLI..."
@maestro --version
@echo "--> Maestro OK. Ensure apps are built & installed (see docs/research/maestro-test-run-instructions.md)"
test-e2e: test-e2e-setup
@echo "--> Running full E2E suite (Client + Staff auth flows)..."
@maestro test apps/mobile/apps/client/maestro/auth/sign_in.yaml apps/mobile/apps/client/maestro/auth/sign_up.yaml \
apps/mobile/apps/staff/maestro/auth/sign_in.yaml apps/mobile/apps/staff/maestro/auth/sign_up.yaml \
-e TEST_CLIENT_EMAIL="$${TEST_CLIENT_EMAIL}" -e TEST_CLIENT_PASSWORD="$${TEST_CLIENT_PASSWORD}" \
-e TEST_CLIENT_COMPANY="$${TEST_CLIENT_COMPANY}" -e TEST_STAFF_PHONE="$${TEST_STAFF_PHONE}" \
-e TEST_STAFF_OTP="$${TEST_STAFF_OTP}" -e TEST_STAFF_SIGNUP_PHONE="$${TEST_STAFF_SIGNUP_PHONE}"
test-e2e-client: test-e2e-setup
@echo "--> Running Client E2E (sign_in, sign_up)..."
@maestro test apps/mobile/apps/client/maestro/auth/sign_in.yaml apps/mobile/apps/client/maestro/auth/sign_up.yaml \
-e TEST_CLIENT_EMAIL="$${TEST_CLIENT_EMAIL}" -e TEST_CLIENT_PASSWORD="$${TEST_CLIENT_PASSWORD}" \
-e TEST_CLIENT_COMPANY="$${TEST_CLIENT_COMPANY}"
test-e2e-staff: test-e2e-setup
@echo "--> Running Staff E2E (sign_in, sign_up)..."
@maestro test apps/mobile/apps/staff/maestro/auth/sign_in.yaml apps/mobile/apps/staff/maestro/auth/sign_up.yaml \
-e TEST_STAFF_PHONE="$${TEST_STAFF_PHONE}" -e TEST_STAFF_OTP="$${TEST_STAFF_OTP}" \
-e TEST_STAFF_SIGNUP_PHONE="$${TEST_STAFF_SIGNUP_PHONE}"