feat(Makefile): restructure Makefile into modular files for better organization and maintainability

feat(Makefile): introduce common.mk for shared variables and environment configuration
feat(Makefile): create web.mk for web frontend-related tasks
feat(Makefile): create launchpad.mk for internal launchpad deployment tasks
feat(Makefile): create mobile.mk for mobile app development tasks
feat(Makefile): create dataconnect.mk for Data Connect management tasks
feat(Makefile): create tools.mk for development tools like git hooks
feat(Makefile): remove admin-web specific tasks and files as the admin console is no longer actively maintained
feat(Makefile): update help command to reflect the new modular structure and available commands
feat(Makefile): remove base44 export workflow as it is no longer relevant
feat(Makefile): remove IAP configuration as it is no longer used
feat(Makefile): remove harness-related tasks as they are no longer relevant

The Makefile has been significantly refactored to improve organization and maintainability. The changes include:

- Modularization: The monolithic Makefile has been split into smaller, more manageable files, each responsible for a specific area of the project (web, launchpad, mobile, dataconnect, tools).
- Common Configuration: Shared variables and environment configuration are now centralized in common.mk.
- Removal of Unused Tasks: Tasks related to the admin console, base44 export workflow, IAP configuration, and API test harness have been removed as they are no longer relevant.
- Updated Help Command: The help command has been updated to reflect the new modular structure and available commands.
- Improved Readability: The modular structure makes the Makefile easier to read and understand.
- Maintainability: The modular structure makes it easier to maintain and update the Makefile.
- Scalability: The modular structure makes it easier to add new tasks and features to the Makefile.
This commit is contained in:
bwnyasse
2026-01-10 20:59:18 -05:00
parent d0a536ffa4
commit b8d156b35a
47 changed files with 272 additions and 7124 deletions

110
makefiles/dataconnect.mk Normal file
View File

@@ -0,0 +1,110 @@
# --- Data Connect / Backend ---
.PHONY: dataconnect-enable-apis dataconnect-init dataconnect-deploy dataconnect-sql-migrate dataconnect-generate-sdk dataconnect-sync dataconnect-bootstrap-db check-gcloud-beta
# Enable all required APIs for Firebase Data Connect + Cloud SQL
dataconnect-enable-apis:
@echo "--> Enabling Firebase & Data Connect APIs on project [$(GCP_PROJECT_ID)]..."
@gcloud services enable firebase.googleapis.com --project=$(GCP_PROJECT_ID)
@gcloud services enable firebasedataconnect.googleapis.com --project=$(GCP_PROJECT_ID)
@gcloud services enable sqladmin.googleapis.com --project=$(GCP_PROJECT_ID)
@gcloud services enable iam.googleapis.com --project=$(GCP_PROJECT_ID)
@gcloud services enable cloudresourcemanager.googleapis.com --project=$(GCP_PROJECT_ID)
@gcloud services enable secretmanager.googleapis.com --project=$(GCP_PROJECT_ID)
@echo "✅ APIs enabled for project [$(GCP_PROJECT_ID)]."
# Initialize Firebase Data Connect (interactive wizard).
dataconnect-init:
@echo "--> Initializing Firebase Data Connect for alias [$(FIREBASE_ALIAS)] (project: $(GCP_PROJECT_ID))..."
@firebase init dataconnect --project $(FIREBASE_ALIAS)
@echo "✅ Data Connect initialization command executed. Follow the interactive steps in the CLI."
# Deploy Data Connect schemas (GraphQL → Cloud SQL)
dataconnect-deploy:
@echo "--> Deploying Firebase Data Connect schemas to [$(ENV)] (project: $(FIREBASE_ALIAS))..."
@firebase deploy --only dataconnect --project=$(FIREBASE_ALIAS)
@echo "✅ Data Connect deployment completed for [$(ENV)]."
# Apply pending SQL migrations for Firebase Data Connect
dataconnect-sql-migrate:
@echo "--> Applying Firebase Data Connect SQL migrations to [$(ENV)] (project: $(FIREBASE_ALIAS))..."
@firebase dataconnect:sql:migrate --project=$(FIREBASE_ALIAS)
@echo "✅ Data Connect SQL migration completed for [$(ENV)]."
# Generate Data Connect client SDK for frontend-web and internal-api-harness
dataconnect-generate-sdk:
@echo "--> Generating Firebase Data Connect SDK for web frontend and API harness..."
@firebase dataconnect:sdk:generate --project=$(FIREBASE_ALIAS)
@echo "✅ Data Connect SDK generation completed for [$(ENV)]."
# Unified backend schema update workflow (schema -> deploy -> SDK)
dataconnect-sync:
@echo "--> [1/3] Applying SQL migrations..."
@firebase dataconnect:sql:migrate --project=$(FIREBASE_ALIAS)
@echo "--> [2/3] Deploying Data Connect..."
@firebase deploy --only dataconnect --project=$(FIREBASE_ALIAS)
@echo "--> [3/3] Regenerating SDK..."
@firebase dataconnect:sdk:generate --project=$(FIREBASE_ALIAS)
@echo "✅ Data Connect SQL, deploy, and SDK generation completed for [$(ENV)]."
# -------------------------------------------------------------------
# ONE-TIME FULL SETUP FOR CLOUD SQL + DATA CONNECT
# -------------------------------------------------------------------
# Check if gcloud and beta group are available
check-gcloud-beta:
@command -v gcloud >/dev/null 2>&1 || { \
echo "❌ gcloud CLI not found. Please install it: https://cloud.google.com/sdk/docs/install"; \
exit 1; \
}
@gcloud beta --help >/dev/null 2>&1 || { \
echo "❌ 'gcloud beta' is not available. Run 'gcloud components update' or reinstall the SDK."; \
exit 1; \
}
@echo "✅ gcloud CLI and 'gcloud beta' are available."
dataconnect-bootstrap-db: check-gcloud-beta
@echo "🔍 Checking if Cloud SQL instance krow-sql already exists in [$(GCP_PROJECT_ID)]..."
@if gcloud sql instances describe krow-sql --project=$(GCP_PROJECT_ID) >/dev/null 2>&1; then \
echo "⚠️ Cloud SQL instance 'krow-sql' already exists in project $(GCP_PROJECT_ID)."; \
echo " If you really need to recreate it, delete the instance manually first."; \
exit 1; \
fi
@echo "⚠️ Creating Cloud SQL instance krow-sql (tier: $(SQL_TIER)) (ONLY RUN THIS ONCE PER PROJECT)..."
gcloud sql instances create krow-sql \
--database-version=POSTGRES_15 \
--tier=$(SQL_TIER) \
--region=us-central1 \
--storage-size=10 \
--storage-auto-increase \
--availability-type=zonal \
--backup-start-time=03:00 \
--project=$(GCP_PROJECT_ID)
@echo "⚠️ Creating Cloud SQL database krow_db..."
gcloud sql databases create krow_db \
--instance=krow-sql \
--project=$(GCP_PROJECT_ID)
@echo "⚠️ Creating Firebase Data Connect service identity..."
gcloud beta services identity create \
--service=firebasedataconnect.googleapis.com \
--project=$(GCP_PROJECT_ID)
@echo "⚠️ Enabling IAM authentication on Cloud SQL instance krow-sql..."
gcloud sql instances patch krow-sql \
--project=$(GCP_PROJECT_ID) \
--database-flags=cloudsql.iam_authentication=on \
--quiet
@echo "⚠️ Linking Data Connect service (krow-workforce-db) with Cloud SQL..."
firebase dataconnect:sql:setup krow-workforce-db --project=$(FIREBASE_ALIAS)
@echo "⚠️ Deploying initial Data Connect configuration..."
@firebase deploy --only dataconnect --project=$(FIREBASE_ALIAS)
@echo "⚠️ Generating initial Data Connect SDK..."
@firebase dataconnect:sdk:generate --project=$(FIREBASE_ALIAS)
@echo "🎉 Cloud SQL + Data Connect bootstrap completed successfully!"