chore: Refactor mobile build scripts to use Melos

Updated Makefile, mobile.mk, and melos.yaml to centralize mobile app build, start, and code generation commands using Melos scripts. Added info and install-melos commands for easier onboarding and workspace setup. Documentation updated to reflect staff app naming and new command structure.
This commit is contained in:
Achintha Isuru
2026-01-22 10:55:46 -05:00
parent cf59935ec8
commit ecc7aece6e
6 changed files with 168 additions and 67 deletions

View File

@@ -1,68 +1,44 @@
# --- Mobile App Development ---
.PHONY: mobile-client-install mobile-client-dev mobile-client-build mobile-staff-install mobile-staff-dev mobile-staff-build
.PHONY: mobile-install mobile-info mobile-client-dev-android mobile-staff-dev-android mobile-client-build mobile-staff-build
FLAVOR :=
ifeq ($(ENV),dev)
FLAVOR := dev
else ifeq ($(ENV),staging)
FLAVOR := staging
else ifeq ($(ENV),prod)
FLAVOR := production
endif
MOBILE_DIR := apps/mobile
BUILD_TYPE ?= appbundle
# --- General ---
mobile-install: install-melos
@echo "--> Bootstrapping mobile workspace (Melos)..."
@cd $(MOBILE_DIR) && melos bootstrap
mobile-info:
@echo "--> Fetching mobile command info..."
@cd $(MOBILE_DIR) && melos run info
# --- Client App ---
mobile-client-install:
@echo "--> Installing Flutter dependencies for client app..."
@cd apps/mobile-client && $(FLUTTER) pub get
mobile-client-dev:
@echo "--> Running client app in dev mode..."
@echo "--> If using VS code, use the debug configurations"
@cd apps/mobile-client && $(FLUTTER) run --flavor dev -t lib/main_dev.dart
mobile-client-dev-android:
@echo "--> Running client app on Android..."
@cd $(MOBILE_DIR) && melos run start:client -- -d android
mobile-client-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; exit 1; \
@if [ -z "$(PLATFORM)" ]; then \
echo "ERROR: PLATFORM is required (e.g. make mobile-client-build PLATFORM=apk)"; exit 1; \
fi
@if [ "$(PLATFORM)" != "android" ] && [ "$(PLATFORM)" != "ios" ]; then \
echo "ERROR: PLATFORM must be either android or ios."; exit 1; \
fi
@echo "--> Building client app for $(PLATFORM) with flavor $(FLAVOR)..."
@cd apps/mobile-client && \
$(FLUTTER) pub get && \
$(FLUTTER) pub run build_runner build --delete-conflicting-outputs && \
if [ "$(PLATFORM)" = "android" ]; then \
$(FLUTTER) build $(BUILD_TYPE) --flavor $(FLAVOR); \
elif [ "$(PLATFORM)" = "ios" ]; then \
$(FLUTTER) build ipa --flavor $(FLAVOR); \
fi
@echo "--> Building client app for $(PLATFORM)..."
@cd $(MOBILE_DIR) && \
melos run gen:l10n --filter="core_localization" && \
melos run gen:build --filter="core_localization" && \
melos exec --scope="krowwithus_client" -- "flutter build $(PLATFORM)"
# --- Staff App ---
mobile-staff-install:
@echo "--> Installing Flutter dependencies for staff app..."
@cd apps/mobile-staff && $(FLUTTER) pub get
mobile-staff-dev:
@echo "--> Running staff app in dev mode..."
@echo "--> If using VS code, use the debug configurations"
@cd apps/mobile-staff && $(FLUTTER) run --flavor dev -t lib/main_dev.dart
mobile-staff-dev-android:
@echo "--> Running staff app on Android..."
@cd $(MOBILE_DIR) && melos run start:staff -- -d android
mobile-staff-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; exit 1; \
@if [ -z "$(PLATFORM)" ]; then \
echo "ERROR: PLATFORM is required (e.g. make mobile-staff-build PLATFORM=apk)"; exit 1; \
fi
@if [ "$(PLATFORM)" != "android" ] && [ "$(PLATFORM)" != "ios" ]; then \
echo "ERROR: PLATFORM must be either android or ios."; exit 1; \
fi
@echo "--> Building staff app for $(PLATFORM) with flavor $(FLAVOR)..."
@cd apps/mobile-staff && \
$(FLUTTER) pub get && \
$(FLUTTER) pub run build_runner build --delete-conflicting-outputs && \
if [ "$(PLATFORM)" = "android" ]; then \
$(FLUTTER) build $(BUILD_TYPE) --flavor $(FLAVOR); \
elif [ "$(PLATFORM)" = "ios" ]; then \
$(FLUTTER) build ipa --flavor $(FLAVOR); \
fi
@echo "--> Building staff app for $(PLATFORM)..."
@cd $(MOBILE_DIR) && \
melos run gen:l10n --filter="core_localization" && \
melos run gen:build --filter="core_localization" && \
melos exec --scope="krowwithus_staff" -- "flutter build $(PLATFORM)"