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

@@ -28,18 +28,19 @@ help:
@echo " make launchpad-dev - Starts the local launchpad server (Firebase Hosting emulator)." @echo " make launchpad-dev - Starts the local launchpad server (Firebase Hosting emulator)."
@echo "" @echo ""
@echo " --- MOBILE APP DEVELOPMENT ---" @echo " --- MOBILE APP DEVELOPMENT ---"
@echo " make mobile-client-install - Install dependencies for client app" @echo " make mobile-install - Bootstrap the mobile workspace (Melos)."
@echo " make mobile-client-dev - Run client app in dev mode" @echo " make mobile-info - List custom mobile development commands."
@echo " make mobile-client-build - Build client app (requires ENV & PLATFORM)" @echo " make mobile-client-dev-android - Run client app in dev mode (Android)."
@echo " make mobile-staff-install - Install dependencies for staff app" @echo " make mobile-client-build PLATFORM=apk - Build client app for specified platform."
@echo " make mobile-staff-dev - Run staff app in dev mode" @echo " make mobile-staff-dev-android - Run staff app in dev mode (Android)."
@echo " make mobile-staff-build - Build staff app (requires ENV & PLATFORM)" @echo " make mobile-staff-build PLATFORM=apk - Build staff app for specified platform."
@echo "" @echo ""
@echo " --- DEPLOYMENT ---" @echo " --- DEPLOYMENT ---"
@echo " make deploy-launchpad-hosting - Deploys internal launchpad to Firebase Hosting." @echo " make deploy-launchpad-hosting - Deploys internal launchpad to Firebase Hosting."
@echo " make deploy-app [ENV=staging] - Builds and deploys the main web app (default: dev)." @echo " make deploy-app [ENV=staging] - Builds and deploys the main web app (default: dev)."
@echo "" @echo ""
@echo " --- DEVELOPMENT TOOLS ---" @echo " --- DEVELOPMENT TOOLS ---"
@echo " make install-melos - Installs Melos globally if not already present."
@echo " make install-git-hooks - Installs git pre-push hook to protect main/dev branches." @echo " make install-git-hooks - Installs git pre-push hook to protect main/dev branches."
@echo " make sync-prototypes - Builds and copies prototypes from adjacent 'client-krow-poc' repo." @echo " make sync-prototypes - Builds and copies prototypes from adjacent 'client-krow-poc' repo."
@echo "" @echo ""

View File

@@ -9,6 +9,27 @@ command:
usePubspecOverrides: true usePubspecOverrides: true
scripts: scripts:
info:
run: |
echo " 🚀 KROW WORKFORCE CUSTOM COMMANDS 🚀"
echo "============================================================"
echo " BUILD COMMANDS:"
echo " - melos run build:client : Build Client App (APK)"
echo " - melos run build:staff : Build Staff App (APK)"
echo " - melos run build:design-system : Build Design System Viewer"
echo ""
echo " DEBUG/START COMMANDS:"
echo " - melos run start:client -- -d <ID> : Run Client App"
echo " - melos run start:staff -- -d <ID> : Run Staff App"
echo " - melos run start:design-system : Run DS Viewer"
echo " (e.g., melos run start:client -- -d chrome)"
echo ""
echo " CODE GENERATION:"
echo " - melos run gen:l10n : Generate Slang l10n"
echo " - melos run gen:build : Run build_runner"
echo "============================================================"
description: "Display information about available custom Melos commands."
gen:l10n: gen:l10n:
exec: dart run slang exec: dart run slang
description: "Generate localization files using Slang across all packages." description: "Generate localization files using Slang across all packages."
@@ -20,3 +41,33 @@ scripts:
description: "Run build_runner build across all packages." description: "Run build_runner build across all packages."
packageFilters: packageFilters:
dependsOn: build_runner dependsOn: build_runner
build:client:
run: |
melos run gen:l10n --filter="core_localization"
melos run gen:build --filter="core_localization"
melos exec --scope="krowwithus_client" -- "flutter build apk"
description: "Build the Client app (Android APK by default)."
build:staff:
run: |
melos run gen:l10n --filter="core_localization"
melos run gen:build --filter="core_localization"
melos exec --scope="krowwithus_staff" -- "flutter build apk"
description: "Build the Staff app (Android APK by default)."
build:design-system-viewer:
run: melos exec --scope="design_system_viewer" -- "flutter build apk"
description: "Build the Design System Viewer app (Android APK by default)."
start:client:
run: melos exec --scope="krowwithus_client" -- "flutter run"
description: "Start the Client app. Pass platform using -- -d <platform>, e.g. -d chrome"
start:staff:
run: melos exec --scope="krowwithus_staff" -- "flutter run"
description: "Start the Staff app. Pass platform using -- -d <platform>, e.g. -d chrome"
start:design-system-viewer:
run: melos exec --scope="design_system_viewer" -- "flutter run"
description: "Start the Design System Viewer app. Pass platform using -- -d <platform>, e.g. -d chrome"

View File

@@ -20,3 +20,68 @@ workspace:
dev_dependencies: dev_dependencies:
melos: ^7.3.0 melos: ^7.3.0
melos:
scripts:
info:
run: |
echo " 🚀 KROW WORKFORCE CUSTOM COMMANDS 🚀"
echo "============================================================"
echo " BUILD COMMANDS:"
echo " - melos run build:client : Build Client App (APK)"
echo " - melos run build:staff : Build Staff App (APK)"
echo " - melos run build:design-system : Build Design System Viewer"
echo ""
echo " DEBUG/START COMMANDS:"
echo " - melos run start:client -- -d <ID> : Run Client App"
echo " - melos run start:staff -- -d <ID> : Run Staff App"
echo " - melos run start:design-system : Run DS Viewer"
echo " (e.g., melos run start:client -- -d chrome)"
echo ""
echo " CODE GENERATION:"
echo " - melos run gen:l10n : Generate Slang l10n"
echo " - melos run gen:build : Run build_runner"
echo "============================================================"
description: "Display information about available custom Melos commands."
gen:l10n:
exec: dart run slang
description: "Generate localization files using Slang across all packages."
packageFilters:
dependsOn: slang
gen:build:
exec: dart run build_runner build --delete-conflicting-outputs
description: "Run build_runner build across all packages."
packageFilters:
dependsOn: build_runner
build:client:
run: |
melos run gen:l10n --filter="core_localization"
melos run gen:build --filter="core_localization"
melos exec --scope="krowwithus_client" -- "flutter build apk"
description: "Build the Client app (Android APK by default)."
build:staff:
run: |
melos run gen:l10n --filter="core_localization"
melos run gen:build --filter="core_localization"
melos exec --scope="krowwithus_staff" -- "flutter build apk"
description: "Build the Staff app (Android APK by default)."
build:design-system:
run: melos exec --scope="design_system_viewer" -- "flutter build apk"
description: "Build the Design System Viewer app (Android APK by default)."
start:client:
run: melos exec --scope="krowwithus_client" -- "flutter run"
description: "Start the Client app. Pass platform using -- -d <platform>, e.g. -d chrome"
start:staff:
run: melos exec --scope="krowwithus_staff" -- "flutter run"
description: "Start the Staff app. Pass platform using -- -d <platform>, e.g. -d chrome"
start:design-system:
run: melos exec --scope="design_system_viewer" -- "flutter run"
description: "Start the Design System Viewer app. Pass platform using -- -d <platform>, e.g. -d chrome"

View File

@@ -1,7 +1,7 @@
# KROW Workforce Platform - Project Onboarding Master Document # KROW Workforce Platform - Project Onboarding Master Document
> **Version:** 1.0 > **Version:** 1.1
> **Last Updated:** 2026-01-11 > **Last Updated:** 2026-01-22
> **Purpose:** Source of Truth for Team Onboarding & Sprint Planning > **Purpose:** Source of Truth for Team Onboarding & Sprint Planning
--- ---
@@ -173,7 +173,7 @@ graph TB
│ ├── mobile/ │ ├── mobile/
| | ├── apps/ | | ├── apps/
| | │ ├── client/ # Flutter (business app) | | │ ├── client/ # Flutter (business app)
| | │ └── worker/ # Flutter (worker app) | | │ └── staff/ # Flutter (staff app)
├── backend/ ├── backend/
│ ├── dataconnect/ # Firebase Data Connect schemas │ ├── dataconnect/ # Firebase Data Connect schemas
│ └── functions/ # Cloud Functions │ └── functions/ # Cloud Functions
@@ -312,7 +312,7 @@ sequenceDiagram
participant Client as Client App participant Client as Client App
participant API as Backend API participant API as Backend API
participant Admin as Admin participant Admin as Admin
participant Staff as Worker App participant Staff as Staff App
Note over Client,API: 1. Event Creation Note over Client,API: 1. Event Creation
Client->>API: Create Event with Shifts & Positions Client->>API: Create Event with Shifts & Positions
@@ -706,9 +706,9 @@ These **must be ported** from legacy:
--- ---
#### 4.7.2 Mobile Worker App (Flutter) #### 4.7.2 Mobile Staff App (Flutter)
**Location:** `internal/launchpad/prototypes-src/mobile/apps/worker/` **Location:** `internal/launchpad/prototypes-src/mobile/apps/staff/`
**Routes (35+ screens):** **Routes (35+ screens):**

View File

@@ -1,68 +1,44 @@
# --- Mobile App Development --- # --- 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 := MOBILE_DIR := apps/mobile
ifeq ($(ENV),dev)
FLAVOR := dev
else ifeq ($(ENV),staging)
FLAVOR := staging
else ifeq ($(ENV),prod)
FLAVOR := production
endif
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 --- # --- Client App ---
mobile-client-install: mobile-client-dev-android:
@echo "--> Installing Flutter dependencies for client app..." @echo "--> Running client app on Android..."
@cd apps/mobile-client && $(FLUTTER) pub get @cd $(MOBILE_DIR) && melos run start:client -- -d android
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-build: mobile-client-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \ @if [ -z "$(PLATFORM)" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; exit 1; \ echo "ERROR: PLATFORM is required (e.g. make mobile-client-build PLATFORM=apk)"; exit 1; \
fi fi
@if [ "$(PLATFORM)" != "android" ] && [ "$(PLATFORM)" != "ios" ]; then \ @echo "--> Building client app for $(PLATFORM)..."
echo "ERROR: PLATFORM must be either android or ios."; exit 1; \ @cd $(MOBILE_DIR) && \
fi melos run gen:l10n --filter="core_localization" && \
@echo "--> Building client app for $(PLATFORM) with flavor $(FLAVOR)..." melos run gen:build --filter="core_localization" && \
@cd apps/mobile-client && \ melos exec --scope="krowwithus_client" -- "flutter build $(PLATFORM)"
$(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
# --- Staff App --- # --- Staff App ---
mobile-staff-install: mobile-staff-dev-android:
@echo "--> Installing Flutter dependencies for staff app..." @echo "--> Running staff app on Android..."
@cd apps/mobile-staff && $(FLUTTER) pub get @cd $(MOBILE_DIR) && melos run start:staff -- -d android
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-build: mobile-staff-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \ @if [ -z "$(PLATFORM)" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; exit 1; \ echo "ERROR: PLATFORM is required (e.g. make mobile-staff-build PLATFORM=apk)"; exit 1; \
fi fi
@if [ "$(PLATFORM)" != "android" ] && [ "$(PLATFORM)" != "ios" ]; then \ @echo "--> Building staff app for $(PLATFORM)..."
echo "ERROR: PLATFORM must be either android or ios."; exit 1; \ @cd $(MOBILE_DIR) && \
fi melos run gen:l10n --filter="core_localization" && \
@echo "--> Building staff app for $(PLATFORM) with flavor $(FLAVOR)..." melos run gen:build --filter="core_localization" && \
@cd apps/mobile-staff && \ melos exec --scope="krowwithus_staff" -- "flutter build $(PLATFORM)"
$(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

View File

@@ -1,6 +1,14 @@
# --- Development Tools --- # --- Development Tools ---
.PHONY: install-git-hooks sync-prototypes .PHONY: install-git-hooks sync-prototypes install-melos
install-melos:
@if ! command -v melos >/dev/null 2>&1; then \
echo "--> Melos not found. Installing globally via dart pub..."; \
dart pub global activate melos; \
else \
echo "✅ Melos is already installed."; \
fi
install-git-hooks: install-git-hooks:
@echo "--> Installing Git hooks..." @echo "--> Installing Git hooks..."