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

537
Makefile
View File

@@ -1,60 +1,21 @@
# KROW Workforce Project Makefile # KROW Workforce Project Makefile
# ------------------------------- # -------------------------------
# This Makefile provides a central place for common project commands. # This is the main entry point. It includes modular Makefiles from the 'makefiles/' directory.
# It is designed to be the main entry point for developers.
# Use .PHONY to declare targets that are not files, to avoid conflicts. # The default command to run if no target is specified.
.PHONY: help install dev build integrate-export prepare-export deploy-launchpad deploy-launchpad-full deploy-app admin-install admin-dev admin-build deploy-admin deploy-admin-full configure-iap-launchpad configure-iap-admin list-iap-users remove-iap-user setup-labels export-issues create-issues-from-file install-git-hooks mobile-client-install mobile-client-dev mobile-client-build mobile-staff-install mobile-staff-dev mobile-staff-build dataconnect-enable-apis dataconnect-init dataconnect-deploy dataconnect-sql-migrate dataconnect-generate-sdk dataconnect-sync dataconnect-bootstrap-db
# The default command to run if no target is specified (e.g., just 'make').
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
# --- Flutter check --- # --- Include Modules ---
FLUTTER := $(shell which flutter) include makefiles/common.mk
ifeq ($(FLUTTER),) include makefiles/web.mk
#$(error "flutter not found in PATH. Please install Flutter and add it to your PATH.") include makefiles/launchpad.mk
endif include makefiles/mobile.mk
include makefiles/dataconnect.mk
include makefiles/tools.mk
# --- Firebase & GCP Configuration --- # --- Main Help Command ---
GCP_DEV_PROJECT_ID := krow-workforce-dev .PHONY: help
GCP_STAGING_PROJECT_ID := krow-workforce-staging
IAP_SERVICE_ACCOUNT := service-933560802882@gcp-sa-iap.iam.gserviceaccount.com
# --- Cloud Run Configuration ---
CR_ADMIN_SERVICE_NAME := admin-console
CR_ADMIN_REGION := us-central1
CR_ADMIN_IMAGE_URI = us-docker.pkg.dev/$(GCP_PROJECT_ID)/gcr-io/$(CR_ADMIN_SERVICE_NAME)
# --- Environment Detection ---
ENV ?= dev
SERVICE ?= launchpad # Default service for IAP commands: 'launchpad' or 'admin'
# --- Conditional Variables by Environment ---
ifeq ($(ENV),staging)
GCP_PROJECT_ID := $(GCP_STAGING_PROJECT_ID)
FIREBASE_ALIAS := staging
HOSTING_TARGET := app-staging
SQL_TIER := db-n1-standard-1
else
GCP_PROJECT_ID := $(GCP_DEV_PROJECT_ID)
FIREBASE_ALIAS := dev
HOSTING_TARGET := app-dev
SQL_TIER := db-g1-small
endif
# --- Conditional Variables by Service for IAP commands ---
ifeq ($(SERVICE),admin)
IAP_SERVICE_NAME := $(CR_ADMIN_SERVICE_NAME)
IAP_SERVICE_REGION := $(CR_ADMIN_REGION)
IAP_PROJECT_ID := $(GCP_PROJECT_ID) # Admin console is env-specific
else
IAP_SERVICE_NAME := $(CR_LAUNCHPAD_SERVICE_NAME)
IAP_SERVICE_REGION := $(CR_LAUNCHPAD_REGION)
IAP_PROJECT_ID := $(GCP_DEV_PROJECT_ID) # Launchpad is dev-only
endif
# Shows this help message.
help: help:
@echo "--------------------------------------------------" @echo "--------------------------------------------------"
@echo " KROW Workforce - Available Makefile Commands" @echo " KROW Workforce - Available Makefile Commands"
@@ -69,479 +30,25 @@ help:
@echo " --- MOBILE APP DEVELOPMENT ---" @echo " --- MOBILE APP DEVELOPMENT ---"
@echo " make mobile-client-install - Install dependencies for client app" @echo " make mobile-client-install - Install dependencies for client app"
@echo " make mobile-client-dev - Run client app in dev mode" @echo " make mobile-client-dev - Run client app in dev mode"
@echo " make mobile-client-build - Build client app (requires ENV & PLATFORM, optional BUILD_TYPE=apk)" @echo " make mobile-client-build - Build client app (requires ENV & PLATFORM)"
@echo ""
@echo " make mobile-staff-install - Install dependencies for staff app" @echo " make mobile-staff-install - Install dependencies for staff app"
@echo " make mobile-staff-dev - Run staff app in dev mode" @echo " make mobile-staff-dev - Run staff app in dev mode"
@echo " make mobile-staff-build - Build staff app (requires ENV & PLATFORM, optional BUILD_TYPE=apk)" @echo " make mobile-staff-build - Build staff app (requires ENV & PLATFORM)"
@echo "" @echo ""
@echo " --- DEPLOYMENT ---" @echo " --- DEPLOYMENT ---"
@echo " make deploy-launchpad-hosting - Deploys internal launchpad to Firebase Hosting (Auth via Firebase)." @echo " make deploy-launchpad-hosting - Deploys internal launchpad to Firebase Hosting."
@echo " make deploy-admin-full [ENV=staging] - Deploys Admin Console to Cloud Run with IAP (default: dev)." @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 via Firebase Hosting (default: dev)."
@echo "" @echo ""
@echo " --- CLOUD IAP MANAGEMENT ---" @echo " --- DEVELOPMENT TOOLS ---"
@echo " make list-iap-users [SERVICE=admin] - Lists IAP users for a service (default: launchpad)."
@echo " make remove-iap-user USER=... [SERVICE=admin] - Removes an IAP user from a service."
@echo ""
@echo " --- PROJECT MANAGEMENT & TOOLS ---"
@echo " make setup-labels - Creates/updates GitHub labels from labels.yml."
@echo " make export-issues [ARGS=\"--state=all --label=bug\"] - Exports GitHub issues to a markdown file. See scripts/export_issues.sh for options."
@echo " make create-issues-from-file - Bulk creates GitHub issues from a markdown file."
@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 "" @echo ""
@echo " --- DATA CONNECT MANAGEMENT ---" @echo " --- DATA CONNECT MANAGEMENT ---"
@echo " make dataconnect-enable-apis - Enables required GCP APIs for Data Connect." @echo " make dataconnect-init - Initializes Firebase Data Connect."
@echo " make dataconnect-init - Initializes Firebase Data Connect (interactive wizard)." @echo " make dataconnect-deploy - Deploys Data Connect schemas."
@echo " make dataconnect-deploy - Deploys Data Connect schemas (GraphQL -> Cloud SQL)." @echo " make dataconnect-sql-migrate - Applies SQL migrations."
@echo " make dataconnect-sql-migrate - Applies Data Connect SQL migrations to Cloud SQL." @echo " make dataconnect-generate-sdk - Regenerates the Data Connect SDK."
@echo " make dataconnect-generate-sdk - Regenerates the Data Connect SDK (frontend-web + internal-api-harness)." @echo " make dataconnect-sync - Runs migrate + deploy + generate-sdk."
@echo " make dataconnect-sync - Runs sql:migrate + deploy + sdk:generate in order." @echo " make dataconnect-bootstrap-db - ONE-TIME: Full Cloud SQL + Data Connect setup."
@echo " make dataconnect-bootstrap-db - ONE-TIME: creates krow-sql, krow_db, links Data Connect, deploys, and generates initial SDK."
@echo " make check-gcloud-beta - Validates gcloud + gcloud beta group availability."
@echo ""
@echo " --- BASE44 EXPORT WORKFLOW ---"
@echo " make integrate-export - Integrates a new Base44 export from '../krow-workforce-export-latest'."
@echo " make prepare-export - Prepares a fresh Base44 export for local use."
@echo "" @echo ""
@echo " make help - Shows this help message." @echo " make help - Shows this help message."
@echo "--------------------------------------------------" @echo "--------------------------------------------------"
# --- Core Development ---
install:
@echo "--> Installing web frontend dependencies..."
@cd frontend-web && npm install
dev:
@echo "--> Ensuring web frontend dependencies are installed..."
@cd frontend-web && npm install
@echo "--> Starting web frontend development server on http://localhost:5173 ..."
@cd frontend-web && npm run dev
build:
@echo "--> Building web frontend for production..."
@cd frontend-web && VITE_APP_ENV=$(ENV) npm run build
launchpad-dev:
@echo "--> Starting local Launchpad server using Firebase Hosting emulator..."
@echo " - Generating secure email hashes..."
@node scripts/generate-allowed-hashes.js
@firebase serve --only hosting:launchpad --project=$(FIREBASE_ALIAS)
# --- Deployment ---
deploy-launchpad-hosting:
@echo "--> Deploying Internal Launchpad to Firebase Hosting..."
@echo " - Generating secure email hashes..."
@node scripts/generate-allowed-hashes.js
@echo " - Target: hosting:launchpad"
@echo " - Project: $(FIREBASE_ALIAS)"
@firebase deploy --only hosting:launchpad --project=$(FIREBASE_ALIAS)
@echo "--> ✅ Deployment to Firebase Hosting successful."
deploy-app: build
@echo "--> Deploying Frontend Web App to [$(ENV)] environment..."
@firebase deploy --only hosting:$(HOSTING_TARGET) --project=$(FIREBASE_ALIAS)
# --- Admin Console ---
admin-install:
@echo "--> Installing admin console dependencies..."
@cd admin-web && npm install
admin-dev:
@echo "--> Starting admin console development server on http://localhost:5174 ..."
@cd admin-web && npm run dev -- --port 5174
admin-build:
@echo "--> Building admin console for production..."
@node scripts/patch-admin-layout-for-env-label.js
@cd admin-web && VITE_APP_ENV=$(ENV) npm run build
# --- API Test Harness ---
harness-install:
@echo "--> Installing API Test Harness dependencies..."
@cd internal-api-harness && npm install
harness-dev: dataconnect-sync
@echo "--> Starting API Test Harness development server on http://localhost:5175 ..."
@cd internal-api-harness && npm run dev -- --port 5175
harness-build:
@echo "--> Building API Test Harness for production..."
@cd internal-api-harness && npm run build -- --mode $(ENV)
harness-deploy: harness-build
@echo "--> Deploying API Test Harness to [$(ENV)] environment..."
@firebase deploy --only hosting:api-harness-$(ENV) --project=$(FIREBASE_ALIAS)
deploy-admin: admin-build
@echo "--> Building and deploying Admin Console to Cloud Run [$(ENV)]..."
@echo " - Step 1: Building container image..."
@cd admin-web && gcloud builds submit \
--tag $(CR_ADMIN_IMAGE_URI) \
--project=$(GCP_PROJECT_ID)
@echo " - Step 2: Deploying to Cloud Run..."
@gcloud run deploy $(CR_ADMIN_SERVICE_NAME) \
--image $(CR_ADMIN_IMAGE_URI) \
--platform managed \
--region $(CR_ADMIN_REGION) \
--no-allow-unauthenticated \
--project=$(GCP_PROJECT_ID)
@echo " - Step 3: Enabling IAP on the service..."
@gcloud beta run services update $(CR_ADMIN_SERVICE_NAME) \
--region=$(CR_ADMIN_REGION) \
--project=$(GCP_PROJECT_ID) \
--iap
@echo "--> ✅ Admin Console deployment to Cloud Run successful."
deploy-admin-full: deploy-admin configure-iap-admin
@echo "✅ Admin Console deployed and IAP configured successfully!"
# --- Frontend Web Free ---
free-dev: dataconnect-sync
@echo "--> Starting free web development server on http://localhost:5174 ..."
@cd frontend-web-free && npm run dev -- --port 5174
# --- Cloud IAP Configuration ---
configure-iap-admin:
@echo "--> Configuring IAP for Cloud Run service [$(CR_ADMIN_SERVICE_NAME)] in [$(ENV)]..."
@echo " - Granting Cloud Run Invoker role to IAP Service Account..."
@gcloud run services add-iam-policy-binding $(CR_ADMIN_SERVICE_NAME) \
--region=$(CR_ADMIN_REGION) \
--project=$(GCP_PROJECT_ID) \
--member=\"serviceAccount:$(IAP_SERVICE_ACCOUNT)\" \
--role='roles/run.invoker' \
--quiet
@echo " - Adding users from iap-users.txt..."
@cd admin-web && \
grep -v '^#' iap-users.txt | grep -v '^$$' | while read -r member; do \
echo " Adding $$member as IAP-secured Web App User..."; \
gcloud beta iap web add-iam-policy-binding \
--project=$(GCP_PROJECT_ID) \
--resource-type=cloud-run \
--service=$(CR_ADMIN_SERVICE_NAME) \
--region=$(CR_ADMIN_REGION) \
--member=\"$$member\" \
--role='roles/iap.httpsResourceAccessor' \
--quiet; \
done
@echo "✅ IAP configuration for Admin Console complete."
list-iap-users:
@echo "--> Current IAP users for Cloud Run service [$(IAP_SERVICE_NAME)]:"
@gcloud beta iap web get-iam-policy \
--project=$(IAP_PROJECT_ID) \
--resource-type=cloud-run \
--service=$(IAP_SERVICE_NAME) \
--region=$(IAP_SERVICE_REGION)
remove-iap-user:
@if [ -z "$(USER)" ]; then \
echo "❌ Error: Please specify USER=user:email@example.com"; \
exit 1; \
fi
@echo "--> Removing IAP access for $(USER) from Cloud Run service [$(IAP_SERVICE_NAME)]..."
@gcloud beta iap web remove-iam-policy-binding \
--project=$(IAP_PROJECT_ID) \
--resource-type=cloud-run \
--service=$(IAP_SERVICE_NAME) \
--region=$(IAP_SERVICE_REGION) \
--member=\"$(USER)\" \
--role='roles/iap.httpsResourceAccessor' \
--quiet
@echo "✅ User removed from IAP."
# --- Project Management ---
setup-labels:
@echo "--> Setting up GitHub labels..."
@./scripts/setup-github-labels.sh
export-issues:
@echo "--> Exporting GitHub issues to documentation..."
@./scripts/export_issues.sh $(ARGS)
create-issues-from-file:
@echo "--> Creating GitHub issues from file..."
@./scripts/create_issues.py $(ARGS)
# --- Development Tools ---
install-git-hooks:
@echo "--> Installing Git hooks..."
@ln -sf ../../scripts/git-hooks/pre-push .git/hooks/pre-push
@echo "✅ pre-push hook installed successfully. Direct pushes to 'main' and 'dev' are now blocked."
# --- Base44 Export Workflow ---
integrate-export:
@echo "--> Integrating new Base44 export into frontend-web/..."
@if [ ! -d "../krow-workforce-export-latest" ]; then \
echo "❌ Error: Export directory '../krow-workforce-export-latest' not found."; \
exit 1; \
fi
@echo " - Creating frontend-web/.local-preserve to preserve local directories (src/dataconnect-generated, src/lib)..."
@mkdir -p frontend-web/.local-preserve
@if [ -d "frontend-web/src/dataconnect-generated" ]; then \
mv frontend-web/src/dataconnect-generated frontend-web/.local-preserve/dataconnect-generated; \
fi
@if [ -d "frontend-web/src/lib" ]; then \
mv frontend-web/src/lib frontend-web/.local-preserve/lib; \
fi
@if [ -d "frontend-web/src/api" ]; then \
mv frontend-web/src/api frontend-web/.local-preserve/api; \
fi
@if [ -f "frontend-web/src/firebase.js" ]; then \
mv frontend-web/src/firebase.js frontend-web/.local-preserve/firebase.js; \
fi
@if [ -d "frontend-web/src/components/auth" ]; then \
mv frontend-web/src/components/auth frontend-web/.local-preserve/components-auth; \
fi
@if [ -f "frontend-web/src/hooks/useAuth.js" ]; then \
mv frontend-web/src/hooks/useAuth.js frontend-web/.local-preserve/useAuth.js; \
fi
@if [ -f "frontend-web/src/pages/Login.jsx" ]; then \
mv frontend-web/src/pages/Login.jsx frontend-web/.local-preserve/Login.jsx; \
fi
@if [ -f "frontend-web/src/pages/Register.jsx" ]; then \
mv frontend-web/src/pages/Register.jsx frontend-web/.local-preserve/Register.jsx; \
fi
@echo " - Removing old src directory..."
@rm -rf frontend-web/src
@echo " - Copying new src directory..."
@cp -R ../krow-workforce-export-latest/src ./frontend-web/src
@echo " - Restoring preserved directories..."
@if [ -d "frontend-web/.local-preserve/dataconnect-generated" ]; then \
rm -rf frontend-web/src/dataconnect-generated; \
mv frontend-web/.local-preserve/dataconnect-generated frontend-web/src/dataconnect-generated; \
fi
@if [ -d "frontend-web/.local-preserve/lib" ]; then \
rm -rf frontend-web/src/lib; \
mv frontend-web/.local-preserve/lib frontend-web/src/lib; \
fi
@if [ -d "frontend-web/.local-preserve/api" ]; then \
rm -rf frontend-web/src/api; \
mv frontend-web/.local-preserve/api frontend-web/src/api; \
fi
@if [ -f "frontend-web/.local-preserve/firebase.js" ]; then \
mv frontend-web/.local-preserve/firebase.js frontend-web/src/firebase.js; \
fi
@if [ -d "frontend-web/.local-preserve/components-auth" ]; then \
mkdir -p frontend-web/src/components; \
rm -rf frontend-web/src/components/auth; \
mv frontend-web/.local-preserve/components-auth frontend-web/src/components/auth; \
fi
@if [ -f "frontend-web/.local-preserve/useAuth.js" ]; then \
mkdir -p frontend-web/src/hooks; \
rm -f frontend-web/src/hooks/useAuth.js; \
mv frontend-web/.local-preserve/useAuth.js frontend-web/src/hooks/useAuth.js; \
fi
@if [ -f "frontend-web/.local-preserve/Login.jsx" ]; then \
mkdir -p frontend-web/src/pages; \
rm -f frontend-web/src/pages/Login.jsx; \
mv frontend-web/.local-preserve/Login.jsx frontend-web/src/pages/Login.jsx; \
fi
@if [ -f "frontend-web/.local-preserve/Register.jsx" ]; then \
mkdir -p frontend-web/src/pages; \
rm -f frontend-web/src/pages/Register.jsx; \
mv frontend-web/.local-preserve/Register.jsx frontend-web/src/pages/Register.jsx; \
fi
@echo " - Deleting frontend-web/.local-preserve..."
@rm -rf frontend-web/.local-preserve
@echo " - Copying new index.html..."
@cp ../krow-workforce-export-latest/index.html ./frontend-web/index.html
@echo " - Patching base44Client.js for local development..."
@node scripts/patch-base44-client.js
@echo " - Patching queryKey in Layout.jsx for local development..."
@node scripts/patch-layout-query-key.js
@echo " - Patching Dashboard.jsx for environment label..."
@node scripts/patch-dashboard-for-env-label.js
@echo " - Patching index.html for title..."
@node scripts/patch-index-html.js
@echo "--> Integration complete. Next step: 'make prepare-export'."
prepare-export:
@echo "--> Preparing fresh Base44 export for local development..."
@node scripts/prepare-export.js
@echo "--> Preparation complete. You can now run 'make dev'."
# --- Data Connect / Backend ---
# 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).
# This wraps the command so we remember how to run it for dev/staging/prod.
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
# -------------------------------------------------------------------
# ⚠️ WARNING:
# This should only be executed when setting up a brand new environment
# (e.g., first-time dev setup or new GCP project).
# -------------------------------------------------------------------
# Comprueba que gcloud y el grupo beta están disponibles
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!"
# --- Mobile App Development ---
FLAVOR :=
ifeq ($(ENV),dev)
FLAVOR := dev
else ifeq ($(ENV),staging)
FLAVOR := staging
else ifeq ($(ENV),prod)
FLAVOR := production
endif
BUILD_TYPE ?= appbundle
mobile-client-install:
@echo "--> Installing Flutter dependencies for client app..."
@cd mobile-apps/client-app && $(FLUTTER) pub get
mobile-client-dev:
@echo "--> Running client app in dev mode..."
@echo "--> If using VS code, use the debug configurations"
@cd mobile-apps/client-app && $(FLUTTER) run --flavor dev -t lib/main_dev.dart
mobile-client-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; 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 mobile-apps/client-app && \
$(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
mobile-staff-install:
@echo "--> Installing Flutter dependencies for staff app..."
@cd mobile-apps/staff-app && $(FLUTTER) pub get
mobile-staff-dev:
@echo "--> Running staff app in dev mode..."
@echo "--> If using VS code, use the debug configurations"
@cd mobile-apps/staff-app && $(FLUTTER) run --flavor dev -t lib/main_dev.dart
mobile-staff-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; 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 mobile-apps/staff-app && \
$(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,17 +0,0 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
# Node.js dependencies:
node_modules/

24
admin-web/.gitignore vendored
View File

@@ -1,24 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -1,29 +0,0 @@
# STAGE 1: Build the React application
FROM node:20-alpine AS build
WORKDIR /app
# Copy package files and install dependencies
COPY package.json package-lock.json ./
RUN npm install
# Copy the rest of the application source code
COPY . .
# Build the application for production
RUN npm run build
# STAGE 2: Serve the static files with Nginx
FROM nginx:alpine
# Copy the built files from the build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy the custom Nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose the port Nginx is listening on
EXPOSE 8080
# Command to run Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -1,35 +0,0 @@
# Krow Admin Console
This is the central administration web application for the Krow platform, built with React and Vite.
## Overview
The Krow Admin Console provides a secure and centralized interface for platform administrators to perform high-level management tasks. Its primary functions are:
- **User Ecosystem Management:** Invite, view, and manage access for all users across the platform (Clients, Operators, Vendors, etc.).
- **Platform Health Monitoring:** Get a high-level overview of system activity, usage, and performance.
- **Diagnostics and Troubleshooting:** Access system logs for maintenance and issue resolution.
## Features
- **Dashboard:** A central hub displaying key platform metrics like total users, active vendors, and pending invitations.
- **User Management:** A complete interface to invite new users and manage existing ones, including role assignments.
- **Analytics:** A view of application usage statistics, such as top users and most visited pages.
- **Logs Explorer:** A simple tool to monitor and filter system logs for diagnostics.
## Getting Started
1. Navigate to the `admin-web` directory:
```bash
cd admin-web
```
2. Install the dependencies:
```bash
npm install
```
3. Start the development server:
```bash
npm run dev
```
The application will be available at `http://localhost:5173/admin-web/`.

View File

@@ -1,21 +0,0 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": false,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"iconLibrary": "lucide"
}

View File

@@ -1,29 +0,0 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{js,jsx}'],
extends: [
js.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
},
},
])

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="200 180 280 140" style="enable-background:new 0 0 500 500;" xml:space="preserve">
<style type="text/css">
.st0{fill:#24303B;}
.st1{fill:#002FE3;}
</style>
<g>
<path class="st1" d="M459.81,202.55c-5.03,0.59-9.08,4.49-10.36,9.38l-15.99,59.71l-16.24-56.3
c-1.68-5.92-6.22-10.86-12.19-12.34c-1.58-0.39-3.11-0.54-4.64-0.49h-0.15c-1.53-0.05-3.11,0.1-4.64,0.49
c-5.97,1.48-10.51,6.42-12.24,12.34l-3.6,12.53l-11.35,39.38l-7.9-27.54c-10.76-37.5-48.56-62.23-88.38-55.32
c-33.26,5.82-57.05,35.68-56.99,69.48v0.79c0,4.34,0.39,8.73,1.13,13.18c0.18,1.02,0.37,2.03,0.6,3.03
c1.84,8.31,10.93,12.73,18.49,8.8v0c5.36-2.79,7.84-8.89,6.42-14.77c-0.85-3.54-1.28-7.23-1.23-11.03
c0-25.02,20.48-45.5,45.55-45.2c7.6,0.1,15.59,2.07,23.59,6.37c13.52,7.3,23.15,20.18,27.34,34.94l13.32,46.34
c1.73,5.97,6.22,11,12.24,12.58c9.62,2.62,19-3.06,21.51-12.04l16.09-56.7l0.2-0.1l16.09,56.85c1.63,5.68,5.87,10.41,11.55,11.99
c9.13,2.57,18.11-2.66,20.67-11.2l24.13-79.6C475.35,209.85,468.64,201.56,459.81,202.55z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,8 +0,0 @@
# List of authorized users for the Admin Console
# Format: one email per line, lines starting with # are comments
#
# IMPORTANT: These users must belong to the 'krowwithus.com' organization.
# This is a known limitation of enabling IAP directly on Cloud Run.
# See: https://docs.cloud.google.com/run/docs/securing/identity-aware-proxy-cloud-run#known_limitations
user:admin@krowwithus.com

View File

@@ -1,13 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>KROW Admin Console</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>

View File

@@ -1,10 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"jsx": "react-jsx"
},
"include": ["src/**/*.js", "src/**/*.jsx"]
}

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="200 180 280 140" style="enable-background:new 0 0 500 500;" xml:space="preserve">
<style type="text/css">
.st0{fill:#24303B;}
.st1{fill:#002FE3;}
</style>
<g>
<path class="st1" d="M459.81,202.55c-5.03,0.59-9.08,4.49-10.36,9.38l-15.99,59.71l-16.24-56.3
c-1.68-5.92-6.22-10.86-12.19-12.34c-1.58-0.39-3.11-0.54-4.64-0.49h-0.15c-1.53-0.05-3.11,0.1-4.64,0.49
c-5.97,1.48-10.51,6.42-12.24,12.34l-3.6,12.53l-11.35,39.38l-7.9-27.54c-10.76-37.5-48.56-62.23-88.38-55.32
c-33.26,5.82-57.05,35.68-56.99,69.48v0.79c0,4.34,0.39,8.73,1.13,13.18c0.18,1.02,0.37,2.03,0.6,3.03
c1.84,8.31,10.93,12.73,18.49,8.8v0c5.36-2.79,7.84-8.89,6.42-14.77c-0.85-3.54-1.28-7.23-1.23-11.03
c0-25.02,20.48-45.5,45.55-45.2c7.6,0.1,15.59,2.07,23.59,6.37c13.52,7.3,23.15,20.18,27.34,34.94l13.32,46.34
c1.73,5.97,6.22,11,12.24,12.58c9.62,2.62,19-3.06,21.51-12.04l16.09-56.7l0.2-0.1l16.09,56.85c1.63,5.68,5.87,10.41,11.55,11.99
c9.13,2.57,18.11-2.66,20.67-11.2l24.13-79.6C475.35,209.85,468.64,201.56,459.81,202.55z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,13 +0,0 @@
server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,38 +0,0 @@
{
"name": "admin-web",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-slot": "^1.2.4",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.553.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-router-dom": "^7.9.6",
"tailwind-merge": "^3.4.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^5.1.0",
"autoprefixer": "^10.4.22",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"postcss": "^8.5.6",
"tailwindcss": "^3.4.18",
"vite": "^7.2.2"
}
}

View File

@@ -1,6 +0,0 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,42 +0,0 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}

View File

@@ -1,24 +0,0 @@
import React from "react";
import Layout from "./pages/Layout";
import Dashboard from "./pages/Dashboard";
import UserManagement from "./pages/UserManagement";
import Analytics from "./pages/Analytics";
import Logs from "./pages/Logs";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
function App() {
return (
<Router>
<Layout>
<Routes>
<Route path="/admin-web/" element={<Dashboard />} />
<Route path="/admin-web/user-management" element={<UserManagement />} />
<Route path="/admin-web/analytics" element={<Analytics />} />
<Route path="/admin-web/logs" element={<Logs />} />
</Routes>
</Layout>
</Router>
);
}
export default App;

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -1,58 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 0 0% 3.9%;
--card: 0 0% 100%;
--card-foreground: 0 0% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 9%;
--muted: 0 0% 96.1%;
--muted-foreground: 0 0% 45.1%;
--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 89.8%;
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--radius: 0.5rem;
}
.dark {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 0 0% 9%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}

View File

@@ -1,6 +0,0 @@
import { clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs) {
return twMerge(clsx(inputs))
}

View File

@@ -1,10 +0,0 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@@ -1,61 +0,0 @@
import React from "react";
const topUsers = [
{ email: "ian.gomez@example.com", visits: 6950 },
{ email: "admin@krow.com", visits: 193 },
{ email: "paula.orte@example.com", visits: 81 },
{ email: "test.user@example.com", visits: 50 },
];
const topPages = [
{ name: "VendorManagement", visits: 718 },
{ name: "Dashboard", visits: 600 },
{ name: "unknown", visits: 587 },
{ name: "ClientDashboard", visits: 475 },
{ name: "Events", visits: 456 },
];
export default function Analytics() {
return (
<div>
<h1 className="text-3xl font-bold text-slate-800">Analytics</h1>
<p className="mt-2 text-base text-slate-600">
An overview of your application's data.
</p>
<div className="mt-8">
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="bg-white shadow-lg rounded-2xl p-6">
<h3 className="text-lg font-medium text-gray-900">Total Unique Users</h3>
<p className="mt-2 text-4xl font-bold text-blue-600">3</p>
</div>
</div>
</div>
<div className="mt-8 grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<h3 className="text-xl font-semibold text-gray-900">Top Users</h3>
<ul className="mt-4 space-y-4">
{topUsers.map((user) => (
<li key={user.email} className="bg-white shadow-lg rounded-2xl p-4">
<p className="font-semibold text-slate-800">{user.email}</p>
<p className="text-slate-500">{user.visits.toLocaleString()} visits</p>
</li>
))}
</ul>
</div>
<div>
<h3 className="text-xl font-semibold text-gray-900">Top Pages</h3>
<ul className="mt-4 space-y-4">
{topPages.map((page) => (
<li key={page.name} className="bg-white shadow-lg rounded-2xl p-4 flex justify-between items-center">
<p className="font-semibold text-slate-800">{page.name}</p>
<p className="text-slate-500 font-medium">{page.visits.toLocaleString()}</p>
</li>
))}
</ul>
</div>
</div>
</div>
);
}

View File

@@ -1,38 +0,0 @@
import React from "react";
import { Users, Building2, Mail, FileText } from "lucide-react";
const stats = [
{ name: "Total Users", stat: "15", icon: Users, color: "bg-blue-500" },
{ name: "Active Vendors", stat: "8", icon: Building2, color: "bg-green-500" },
{ name: "Pending Invitations", stat: "3", icon: Mail, color: "bg-yellow-500" },
{ name: "Open Orders", stat: "12", icon: FileText, color: "bg-purple-500" },
];
export default function Dashboard() {
return (
<div>
<h1 className="text-3xl font-bold text-slate-800">Admin Dashboard</h1>
<p className="mt-2 text-base text-slate-600">
Welcome to the Krow Admin Console. Here is a quick overview of the platform.
</p>
<div className="mt-8">
<dl className="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-4">
{stats.map((item) => (
<div key={item.name} className="relative overflow-hidden rounded-2xl bg-white px-4 py-5 shadow-lg sm:px-6 sm:py-6">
<dt>
<div className={`absolute rounded-xl p-3 ${item.color}`}>
<item.icon className="h-8 w-8 text-white" aria-hidden="true" />
</div>
<p className="ml-20 truncate text-sm font-medium text-gray-500">{item.name}</p>
</dt>
<dd className="ml-20 flex items-baseline">
<p className="text-3xl font-semibold text-gray-900">{item.stat}</p>
</dd>
</div>
))}
</dl>
</div>
</div>
);
}

View File

@@ -1,88 +0,0 @@
import React from "react";
import { Link, useLocation } from "react-router-dom";
import { Building2, Users, BarChart3, Terminal, LayoutDashboard, LogOut } from "lucide-react";
const navigation = [
{ name: "Dashboard", href: "/admin-web/", icon: LayoutDashboard },
{ name: "User Management", href: "/admin-web/user-management", icon: Users },
{ name: "Analytics", href: "/admin-web/analytics", icon: BarChart3 },
{ name: "Logs Explorer", href: "/admin-web/logs", icon: Terminal },
];
export default function Layout({ children }) {
const location = useLocation();
return (
<div className="flex h-screen bg-slate-50">
{/* Sidebar */}
<div className="hidden md:flex md:flex-shrink-0">
<div className="flex flex-col w-64">
{/* Sidebar header */}
<div className="flex items-center h-16 flex-shrink-0 px-4 bg-white border-b border-slate-200">
<div className="flex items-center space-x-3">
<div className="w-8 h-8 rounded-lg flex items-center justify-center">
<img src="/logo.svg" alt="Krow Logo" className="h-full w-full" />
</div>
<div>
<h1 className="text-lg font-bold text-slate-800">KROW</h1>
<p className="text-xs text-slate-500">Admin Console</p>
</div>
</div>
{import.meta.env.VITE_APP_ENV && (
<span className={`ml-auto inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${
import.meta.env.VITE_APP_ENV === 'staging' ? 'bg-amber-100 text-amber-800' : 'bg-blue-100 text-blue-800'
}`}>
{import.meta.env.VITE_APP_ENV === 'staging' ? 'Staging' : 'Dev'}
</span>
)}
</div>
{/* Sidebar content */}
<div className="flex-1 flex flex-col overflow-y-auto bg-white">
<nav className="flex-1 px-4 py-4">
{navigation.map((item) => (
<Link
key={item.name}
to={item.href}
className={`
${
location.pathname === item.href
? "bg-blue-50 text-blue-600"
: "text-slate-600 hover:bg-slate-100 hover:text-slate-900"
}
group flex items-center px-3 py-3 text-sm font-medium rounded-lg
`}
>
<item.icon
className="mr-3 h-6 w-6"
aria-hidden="true"
/>
{item.name}
</Link>
))}
</nav>
<div className="px-4 py-4 border-t border-slate-200">
<Link
to="#"
className="group flex items-center px-3 py-3 text-sm font-medium rounded-lg text-slate-600 hover:bg-slate-100 hover:text-slate-900"
>
<LogOut className="mr-3 h-6 w-6" />
Logout
</Link>
</div>
</div>
</div>
</div>
{/* Main content */}
<div className="flex flex-col w-0 flex-1 overflow-hidden">
<main className="flex-1 relative z-0 overflow-y-auto focus:outline-none">
<div className="py-8">
<div className="max-w-7xl mx-auto px-4 sm:px-6 md:px-8">
{children}
</div>
</div>
</main>
</div>
</div>
);
}

View File

@@ -1,54 +0,0 @@
import React from "react";
const logs = [
{ level: "INFO", message: "User admin@krow.com logged in.", timestamp: "2024-05-21T10:00:00Z" },
{ level: "WARN", message: "API response time is slow: 2500ms for /api/vendors", timestamp: "2024-05-21T10:01:00Z" },
{ level: "ERROR", message: "Failed to process payment for invoice INV-12345.", timestamp: "2024-05-21T10:02:00Z" },
{ level: "INFO", message: "New vendor 'New Staffing Co' invited by admin@krow.com.", timestamp: "2024-05-21T10:05:00Z" },
];
export default function Logs() {
return (
<div>
<h1 className="text-3xl font-bold text-slate-800">Logs Explorer</h1>
<p className="mt-2 text-base text-slate-600">
Monitor system logs across your application.
</p>
<div className="mt-8 flow-root">
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 sm:rounded-2xl">
<table className="min-w-full divide-y divide-gray-300">
<thead className="bg-slate-50">
<tr>
<th scope="col" className="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Level</th>
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Message</th>
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Timestamp</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-200 bg-white">
{logs.map((log, index) => (
<tr key={index}>
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
<span className={`inline-flex items-center px-3 py-1 rounded-full text-xs font-medium ${
log.level === 'ERROR' ? 'bg-red-100 text-red-800' :
log.level === 'WARN' ? 'bg-yellow-100 text-yellow-800' :
'bg-green-100 text-green-800'
}`}>
{log.level}
</span>
</td>
<td className="px-3 py-4 text-sm text-gray-500 font-mono">{log.message}</td>
<td className="px-3 py-4 text-sm text-gray-500">{new Date(log.timestamp).toLocaleString()}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
);
}

View File

@@ -1,146 +0,0 @@
import React, { useState } from "react";
import { Plus, Send } from "lucide-react";
const users = [
{ name: "Alex Johnson", email: "alex.j@krow.com", role: "Admin", status: "Active", avatar: "https://randomuser.me/api/portraits/men/1.jpg" },
{ name: "Samantha Lee", email: "samantha.lee@vendor.com", role: "Vendor", status: "Active", avatar: "https://randomuser.me/api/portraits/women/2.jpg" },
{ name: "Michael Chen", email: "michael.chen@client.com", role: "Client", status: "Pending", avatar: "https://randomuser.me/api/portraits/men/3.jpg" },
];
function InviteUserModal({ isOpen, onClose }) {
if (!isOpen) return null;
return (
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity">
<div className="fixed inset-0 z-10 w-screen overflow-y-auto">
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<div className="relative transform overflow-hidden rounded-2xl bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg">
<div className="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<h3 className="text-xl font-semibold leading-6 text-slate-900">Send Invitation</h3>
<p className="mt-2 text-sm text-slate-500">The user will receive an email with a link to set up their account.</p>
<div className="mt-6 space-y-4">
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
Email address
</label>
<input
type="email"
name="email"
id="email"
className="mt-2 block w-full rounded-lg border-0 py-2.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6"
placeholder="colleague@company.com"
/>
</div>
<div>
<label htmlFor="role" className="block text-sm font-medium text-gray-700">
Access level
</label>
<select
id="role"
name="role"
className="mt-2 block w-full rounded-lg border-0 py-2.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-600 sm:text-sm sm:leading-6"
defaultValue="User"
>
<option>Admin</option>
<option>Vendor</option>
<option>Client</option>
<option>User</option>
</select>
</div>
</div>
</div>
<div className="bg-slate-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
<button
type="button"
className="inline-flex w-full items-center justify-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 sm:ml-3 sm:w-auto"
onClick={onClose}
>
<Send className="h-5 w-5 mr-2" />
Send Invitation
</button>
<button
type="button"
className="mt-3 inline-flex w-full justify-center rounded-lg bg-white px-4 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
onClick={onClose}
>
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
);
}
export default function UserManagement() {
const [isModalOpen, setIsModalOpen] = useState(false);
return (
<div>
<div className="sm:flex sm:items-center">
<div className="sm:flex-auto">
<h1 className="text-3xl font-bold text-slate-800">User Management</h1>
<p className="mt-2 text-base text-slate-600">
A list of all the users in your account including their name, email and role.
</p>
</div>
<div className="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<button
type="button"
className="inline-flex items-center justify-center rounded-lg border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 sm:w-auto"
onClick={() => setIsModalOpen(true)}
>
<Plus className="h-5 w-5 mr-2" />
Invite User
</button>
</div>
</div>
<div className="mt-8 flow-root">
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 sm:rounded-2xl">
<table className="min-w-full divide-y divide-gray-300">
<thead className="bg-slate-50">
<tr>
<th scope="col" className="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Name</th>
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Email</th>
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Role</th>
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Status</th>
</tr>
</thead>
<tbody className="divide-y divide-gray-200 bg-white">
{users.map((user) => (
<tr key={user.email}>
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<div className="flex items-center">
<div className="h-11 w-11 flex-shrink-0">
<img className="h-11 w-11 rounded-full" src={user.avatar} alt="" />
</div>
<div className="ml-4">
<div className="font-medium text-gray-900">{user.name}</div>
</div>
</div>
</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{user.email}</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{user.role}</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
<span className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${
user.status === 'Active' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'
}`}>
{user.status}
</span>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
</div>
<InviteUserModal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)} />
</div>
);
}

View File

@@ -1,89 +0,0 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ["class"],
content: ["./index.html", "./src/**/*.{ts,tsx,js,jsx}"],
theme: {
extend: {
borderRadius: {
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)'
},
colors: {
background: 'hsl(var(--background))',
foreground: 'hsl(var(--foreground))',
card: {
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))'
},
popover: {
DEFAULT: 'hsl(var(--popover))',
foreground: 'hsl(var(--popover-foreground))'
},
primary: {
DEFAULT: 'hsl(var(--primary))',
foreground: 'hsl(var(--primary-foreground))'
},
secondary: {
DEFAULT: 'hsl(var(--secondary))',
foreground: 'hsl(var(--secondary-foreground))'
},
muted: {
DEFAULT: 'hsl(var(--muted))',
foreground: 'hsl(var(--muted-foreground))'
},
accent: {
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))'
},
destructive: {
DEFAULT: 'hsl(var(--destructive))',
foreground: 'hsl(var(--destructive-foreground))'
},
border: 'hsl(var(--border))',
input: 'hsl(var(--input))',
ring: 'hsl(var(--ring))',
chart: {
'1': 'hsl(var(--chart-1))',
'2': 'hsl(var(--chart-2))',
'3': 'hsl(var(--chart-3))',
'4': 'hsl(var(--chart-4))',
'5': 'hsl(var(--chart-5))'
},
sidebar: {
DEFAULT: 'hsl(var(--sidebar-background))',
foreground: 'hsl(var(--sidebar-foreground))',
primary: 'hsl(var(--sidebar-primary))',
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
accent: 'hsl(var(--sidebar-accent))',
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
border: 'hsl(var(--sidebar-border))',
ring: 'hsl(var(--sidebar-ring))'
}
},
keyframes: {
'accordion-down': {
from: {
height: '0'
},
to: {
height: 'var(--radix-accordion-content-height)'
}
},
'accordion-up': {
from: {
height: 'var(--radix-accordion-content-height)'
},
to: {
height: '0'
}
}
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out'
}
}
},
plugins: [require("tailwindcss-animate")],
}

View File

@@ -1,13 +0,0 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
})

24
makefiles/common.mk Normal file
View File

@@ -0,0 +1,24 @@
# --- Environment & Variables ---
# Flutter check
FLUTTER := $(shell which flutter)
# Firebase & GCP Configuration
GCP_DEV_PROJECT_ID := krow-workforce-dev
GCP_STAGING_PROJECT_ID := krow-workforce-staging
# Environment Detection
ENV ?= dev
# Conditional Variables by Environment
ifeq ($(ENV),staging)
GCP_PROJECT_ID := $(GCP_STAGING_PROJECT_ID)
FIREBASE_ALIAS := staging
HOSTING_TARGET := app-staging
SQL_TIER := db-n1-standard-1
else
GCP_PROJECT_ID := $(GCP_DEV_PROJECT_ID)
FIREBASE_ALIAS := dev
HOSTING_TARGET := app-dev
SQL_TIER := db-g1-small
endif

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!"

18
makefiles/launchpad.mk Normal file
View File

@@ -0,0 +1,18 @@
# --- DevOps Launchpad ---
.PHONY: launchpad-dev deploy-launchpad-hosting
launchpad-dev:
@echo "--> Starting local Launchpad server using Firebase Hosting emulator..."
@echo " - Generating secure email hashes..."
@node scripts/generate-allowed-hashes.js
@firebase serve --only hosting:launchpad --project=$(FIREBASE_ALIAS)
deploy-launchpad-hosting:
@echo "--> Deploying Internal Launchpad to Firebase Hosting..."
@echo " - Generating secure email hashes..."
@node scripts/generate-allowed-hashes.js
@echo " - Target: hosting:launchpad"
@echo " - Project: $(FIREBASE_ALIAS)"
@firebase deploy --only hosting:launchpad --project=$(FIREBASE_ALIAS)
@echo "--> ✅ Deployment to Firebase Hosting successful."

68
makefiles/mobile.mk Normal file
View File

@@ -0,0 +1,68 @@
# --- Mobile App Development ---
.PHONY: mobile-client-install mobile-client-dev mobile-client-build mobile-staff-install mobile-staff-dev mobile-staff-build
FLAVOR :=
ifeq ($(ENV),dev)
FLAVOR := dev
else ifeq ($(ENV),staging)
FLAVOR := staging
else ifeq ($(ENV),prod)
FLAVOR := production
endif
BUILD_TYPE ?= appbundle
# --- Client App ---
mobile-client-install:
@echo "--> Installing Flutter dependencies for client app..."
@cd mobile-apps/client-app && $(FLUTTER) pub get
mobile-client-dev:
@echo "--> Running client app in dev mode..."
@echo "--> If using VS code, use the debug configurations"
@cd mobile-apps/client-app && $(FLUTTER) run --flavor dev -t lib/main_dev.dart
mobile-client-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; 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 mobile-apps/client-app && \
$(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 ---
mobile-staff-install:
@echo "--> Installing Flutter dependencies for staff app..."
@cd mobile-apps/staff-app && $(FLUTTER) pub get
mobile-staff-dev:
@echo "--> Running staff app in dev mode..."
@echo "--> If using VS code, use the debug configurations"
@cd mobile-apps/staff-app && $(FLUTTER) run --flavor dev -t lib/main_dev.dart
mobile-staff-build:
@if [ "$(ENV)" != "dev" ] && [ "$(ENV)" != "staging" ] && [ "$(ENV)" != "prod" ]; then \
echo "ERROR: ENV must be one of dev, staging, or prod."; 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 mobile-apps/staff-app && \
$(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

8
makefiles/tools.mk Normal file
View File

@@ -0,0 +1,8 @@
# --- Development Tools ---
.PHONY: install-git-hooks
install-git-hooks:
@echo "--> Installing Git hooks..."
@ln -sf ../../scripts/git-hooks/pre-push .git/hooks/pre-push
@echo "✅ pre-push hook installed successfully. Direct pushes to 'main' and 'dev' are now blocked."

21
makefiles/web.mk Normal file
View File

@@ -0,0 +1,21 @@
# --- Core Web Development ---
.PHONY: install dev build deploy-app
install:
@echo "--> Installing web frontend dependencies..."
@cd frontend-web && npm install
dev:
@echo "--> Ensuring web frontend dependencies are installed..."
@cd frontend-web && npm install
@echo "--> Starting web frontend development server on http://localhost:5173 ..."
@cd frontend-web && npm run dev
build:
@echo "--> Building web frontend for production..."
@cd frontend-web && VITE_APP_ENV=$(ENV) npm run build
deploy-app: build
@echo "--> Deploying Frontend Web App to [$(ENV)] environment..."
@firebase deploy --only hosting:$(HOSTING_TARGET) --project=$(FIREBASE_ALIAS)

View File

@@ -1,132 +0,0 @@
# ===================================================================
# MEMO : Sécurisation d'un service Cloud Run avec IAP (Identity-Aware Proxy)
# ===================================================================
#
# Objectif : Ce document résume les étapes et les permissions nécessaires
# pour sécuriser un service Cloud Run avec IAP, en se basant sur
# l'expérience acquise avec le service 'internal-launchpad'.
#
# Date : 2025-11-16
# ---
# 1. PRINCIPE FONDAMENTAL ET CONTRAINTE MAJEURE
# ---
#
# L'enseignement le plus important est le suivant :
#
# > L'activation d'IAP directement sur un service Cloud Run (sans Load Balancer)
# > restreint l'accès aux utilisateurs qui font partie de la MÊME organisation
# > Google Workspace que le projet Google Cloud.
#
# Dans notre cas, le projet 'krow-workforce-dev' appartient à l'organisation
# 'krowwithus.com'. C'est pourquoi :
# - 'admin@krowwithus.com' A PU ACCÉDER au service.
# - 'boris@oloodi.com' N'A PAS PU ACCÉDER au service, même avec les bonnes permissions.
#
# Solution adoptée : Créer des comptes utilisateurs via Google Workspace ou
# Cloud Identity (qui est gratuit) dans le domaine 'krowwithus.com' pour
# tous les développeurs et administrateurs qui ont besoin d'accéder aux
# services internes.
# ---
# 2. PRÉREQUIS INDISPENSABLES
# ---
#
# Avant de commencer, les éléments suivants doivent être configurés pour le projet :
#
# a) APIs Google Cloud activées :
# - Cloud Run API (`run.googleapis.com`)
# - Identity-Aware Proxy API (`iap.googleapis.com`)
# - Cloud Build API (`cloudbuild.googleapis.com`)
# - Artifact Registry API (`artifactregistry.googleapis.com`)
#
# Commande pour les activer :
# gcloud services enable run.googleapis.com iap.googleapis.com cloudbuild.googleapis.com artifactregistry.googleapis.com --project=krow-workforce-dev
#
# b) Écran de consentement OAuth configuré :
# - IAP utilise OAuth2 pour identifier les utilisateurs. L'écran de consentement est obligatoire.
# - URL : https://console.cloud.google.com/apis/credentials/consent?project=krow-workforce-dev
# - Type d'utilisateur : "Interne" est préférable si disponible.
# - Nom de l'application : Utiliser un nom général (ex: "Krow Workforce Platform").
#
# c) Compte de service IAP existant :
# - Parfois, ce compte n'est pas créé automatiquement. Il est plus sûr de forcer sa création.
#
# Commande pour le créer :
# gcloud beta services identity create --service=iap.googleapis.com --project=krow-workforce-dev
# ---
# 3. LOGIQUE DE CONFIGURATION EN 3 ÉTAPES (AUTOMATISÉE DANS LE MAKEFILE)
# ---
#
# Le processus complet pour sécuriser un service se déroule en 3 étapes séquentielles.
#
# ÉTAPE A : DÉPLOIEMENT SÉCURISÉ DU SERVICE
# -----------------------------------------
# Le service doit être déployé en mode privé, puis IAP doit être activé dessus.
#
# 1. Déployer le service avec l'accès public désactivé :
# gcloud run deploy <SERVICE_NAME> --image <IMAGE_URI> --no-allow-unauthenticated ...
#
# 2. Activer IAP sur le service :
# gcloud beta run services update <SERVICE_NAME> --iap ...
#
#
# ÉTAPE B : AUTORISER IAP À APPELER LE SERVICE
# -------------------------------------------
# Une fois IAP activé, le proxy IAP a besoin de la permission d'invoquer (d'appeler)
# votre service Cloud Run. Cette permission est accordée au compte de service IAP.
#
# Commande :
# gcloud run services add-iam-policy-binding <SERVICE_NAME> \
# --member="serviceAccount:service-<PROJECT_NUMBER>@gcp-sa-iap.iam.gserviceaccount.com" \
# --role="roles/run.invoker"
#
#
# ÉTAPE C : AUTORISER LES UTILISATEURS À PASSER LE PROXY IAP
# -------------------------------------------------------
# C'est ici qu'on ajoute les utilisateurs finaux (qui doivent être dans l'organisation).
# Cette commande est spécifique à IAP pour Cloud Run.
#
# Commande :
# gcloud beta iap web add-iam-policy-binding \
# --resource-type=cloud-run \
# --service=<SERVICE_NAME> \
# --member="user:email@krowwithus.com" \
# --role="roles/iap.httpsResourceAccessor"
# ---
# 4. AUTOMATISATION VIA LE MAKEFILE
# ---
#
# Tout ce processus est géré par la commande `make deploy-launchpad-full`.
#
# a) `deploy-launchpad` s'occupe de l'ÉTAPE A.
#
# b) `configure-iap-launchpad` s'occupe des ÉTAPES B et C.
#
# - Il lit les utilisateurs depuis `firebase/internal-launchpad/iap-users.txt`.
# - Il exécute la commande de l'ÉTAPE B pour le compte de service IAP.
# - Il exécute la commande de l'ÉTAPE C pour chaque utilisateur du fichier.
#
# Pour adapter cela à 'admin-web', il faudra :
# 1. Créer des variables similaires à `CR_LAUNCHPAD_...` pour `admin-web`.
# 2. Créer de nouvelles cibles `deploy-admin-web-full`, `configure-iap-admin-web`, etc.,
# en copiant la logique de celles du launchpad et en adaptant les noms de service.
# ---
# 5. VÉRIFICATION ET DÉPANNAGE
# ---
#
# a) Lister les utilisateurs autorisés :
# La commande `make list-iap-users` est le meilleur moyen de vérifier qui a accès.
#
# b) Erreur "You don't have access" :
# - Cause 1 : L'utilisateur n'est pas dans la bonne organisation (le plus probable).
# - Cause 2 : L'utilisateur n'est pas dans le fichier `iap-users.txt` et `make configure-iap-launchpad` n'a pas été lancé.
# - Cause 3 : Problème de cache de navigateur. Toujours tester dans une nouvelle fenêtre de navigation privée.
# - Cause 4 : Délai de propagation des permissions IAM (attendre 2-3 minutes).
#
# c) Erreur "Forbidden" :
# - Cela signifie que l'authentification a réussi mais que la permission d'invoquer le service est manquante.
# - La cause la plus probable est que l'ÉTAPE B (donner la permission au compte de service IAP) a échoué ou a été oubliée.

0
prototypes/.keep Normal file
View File

View File

@@ -1,106 +0,0 @@
#!/usr/bin/env python3
import subprocess
import os
import re
import argparse
# --- Configuration ---
INPUT_FILE = "issues-to-create.md"
DEFAULT_PROJECT_TITLE = "Krow"
# ---
def create_issue(title, body, labels, milestone, project_title=None):
"""Creates a GitHub issue using the gh CLI."""
command = ["gh", "issue", "create"]
command.extend(["--title", title])
command.extend(["--body", body])
if project_title:
command.extend(["--project", project_title])
if milestone:
command.extend(["--milestone", milestone])
for label in labels:
command.extend(["--label", label])
print(f" -> Creating issue: \"{title}\"")
try:
result = subprocess.run(command, check=True, text=True, capture_output=True)
print(result.stdout.strip())
except subprocess.CalledProcessError as e:
print(f"❌ ERROR: Failed to create issue '{title}'.")
print(f" Stderr: {e.stderr.strip()}")
def main():
"""Main function to parse the file and create issues."""
parser = argparse.ArgumentParser(description="Bulk create GitHub issues from a markdown file.")
parser.add_argument("--project", default=DEFAULT_PROJECT_TITLE, help="GitHub Project title to add issues to.")
parser.add_argument("--no-project", action="store_true", help="Do not add issues to any project.")
args = parser.parse_args()
project_title = args.project if not args.no_project else None
print(f"🚀 Starting bulk creation of GitHub issues from '{INPUT_FILE}'...")
if project_title:
print(f" Target Project: '{project_title}'")
else:
print(" Target Project: (None)")
if subprocess.run(["which", "gh"], capture_output=True).returncode != 0:
print("❌ ERROR: GitHub CLI (gh) is not installed.")
exit(1)
if not os.path.exists(INPUT_FILE):
print(f"❌ ERROR: Input file {INPUT_FILE} not found.")
exit(1)
print("✅ Dependencies and input file found.")
print(f"2. Reading and parsing {INPUT_FILE}...")
with open(INPUT_FILE, 'r') as f:
content = f.read()
# Split the content by lines starting with '# '
issue_blocks = re.split(r'\n(?=#\s)', content)
for block in issue_blocks:
if not block.strip():
continue
lines = block.strip().split('\n')
title = lines[0].replace('# ', '').strip()
labels_line = ""
milestone_line = ""
body_start_index = 1
# Find all metadata lines (Labels, Milestone) at the beginning of the body
for i, line in enumerate(lines[1:]):
line_lower = line.strip().lower()
if line_lower.startswith('labels:'):
labels_line = line.split(':', 1)[1].strip()
elif line_lower.startswith('milestone:'):
milestone_line = line.split(':', 1)[1].strip()
elif line.strip() == "":
continue # Ignore blank lines in the metadata header
else:
# This is the first real line of the body
body_start_index = i + 1
break
body = "\n".join(lines[body_start_index:]).strip()
labels = [label.strip() for label in labels_line.split(',') if label.strip()]
milestone = milestone_line
if not title:
print("⚠️ Skipping block with no title.")
continue
create_issue(title, body, labels, milestone, project_title)
print("\n🎉 Bulk issue creation complete!")
if __name__ == "__main__":
main()

View File

@@ -1,97 +0,0 @@
#!/bin/bash
# ====================================================================================
# SCRIPT TO EXPORT GITHUB ISSUES TO A MARKDOWN FILE
# ====================================================================================
set -e # Exit script if a command fails
# --- Default Configuration ---
ISSUE_LIMIT=1000
DEFAULT_LABEL="sred-eligible"
DEFAULT_STATE="open"
# --- Parse Command Line Arguments ---
STATE=""
LABEL=""
# If no arguments are provided, run in legacy SR&ED mode
if [ $# -eq 0 ]; then
STATE=$DEFAULT_STATE
LABEL=$DEFAULT_LABEL
else
while [[ "$#" -gt 0 ]]; do
case $1 in
--state=*) STATE="${1#*=}" ;;
--state) STATE="$2"; shift ;;
--label=*) LABEL="${1#*=}" ;;
--label) LABEL="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
fi
# --- Dynamic Configuration ---
STATE_FOR_CMD=${STATE:-"open"} # Default to open if state is empty
LABEL_FOR_FILENAME=${LABEL:-"all"}
STATE_FOR_FILENAME=${STATE:-"open"}
OUTPUT_FILE="export-issues-${STATE_FOR_FILENAME}-${LABEL_FOR_FILENAME}.md"
TITLE="Export of GitHub Issues (State: ${STATE_FOR_FILENAME}, Label: ${LABEL_FOR_FILENAME})"
FETCH_MESSAGE="Fetching issues with state '${STATE_FOR_CMD}'"
if [ -n "$LABEL" ]; then
FETCH_MESSAGE="${FETCH_MESSAGE} and label '${LABEL}'"
fi
echo "🚀 Starting export of GitHub issues to '${OUTPUT_FILE}'..."
# --- Step 1: Dependency Check ---
echo "1. Checking for 'gh' CLI dependency..."
if ! command -v gh &> /dev/null; then
echo "❌ ERROR: GitHub CLI ('gh') is not installed. Please install it to continue."
exit 1
fi
echo "✅ 'gh' CLI found."
# --- Step 2: Initialize Output File ---
echo "# ${TITLE}" > "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "*Export generated on $(date)*." >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
# --- Step 3: Build 'gh' command and Fetch Issues ---
echo "2. ${FETCH_MESSAGE}..."
GH_COMMAND=("gh" "issue" "list" "--state" "${STATE_FOR_CMD}" "--limit" "$ISSUE_LIMIT" "--json" "number")
if [ -n "$LABEL" ]; then
GH_COMMAND+=("--label" "${LABEL}")
fi
issue_numbers=$("${GH_COMMAND[@]}" | jq -r '.[].number')
if [ -z "$issue_numbers" ]; then
echo "⚠️ No issues found matching the criteria."
echo "" >> "$OUTPUT_FILE"
echo "**No issues found.**" >> "$OUTPUT_FILE"
exit 0
fi
total_issues=$(echo "$issue_numbers" | wc -l | xargs)
echo "✅ Found ${total_issues} issue(s)."
# --- Step 4: Loop Through Each Issue and Format the Output ---
echo "3. Formatting details for each issue..."
current_issue=0
for number in $issue_numbers; do
current_issue=$((current_issue + 1))
echo " -> Processing issue #${number} (${current_issue}/${total_issues})"
# Use 'gh issue view' with a template to format the output for each issue
gh issue view "$number" --json number,title,body,author,createdAt,state --template \
'\n### [#{{.number}}] {{.title}} ({{.state}})\n\n{{if .body}}{{.body}}{{else}}*No description provided.*{{end}}\n\n**Meta:** {{.author.login}} | **Created:** {{timefmt "2006-01-02" .createdAt}}\n***\n' >> "$OUTPUT_FILE"
done
echo ""
echo "🎉 Export complete!"
echo "Your markdown file is ready: ${OUTPUT_FILE}"

View File

@@ -1,100 +0,0 @@
const fs = require('fs');
const path = require('path');
const projectRoot = path.resolve(__dirname, '..');
const clientFilePath = path.join(projectRoot, 'frontend-web', 'src', 'api', 'base44Client.js');
const patchedMock = `// import { createClient } from '@base44/sdk';
// --- MIGRATION MOCK ---
// This mock completely disables the Base44 SDK to allow for local development.
// It also simulates user roles for the RoleSwitcher component.
const MOCK_USER_KEY = 'krow_mock_user_role';
// Default mock user data
const DEFAULT_MOCK_USER = {
id: "mock-user-123",
email: "dev@example.com",
full_name: "Dev User",
// 'role' is the Base44 default, 'user_role' is our custom field
role: "admin",
user_role: "admin", // Default role for testing
profile_picture: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
};
// Function to get the current mock user state
const getMockUser = () => {
try {
const storedRole = localStorage.getItem(MOCK_USER_KEY);
if (storedRole) {
return { ...DEFAULT_MOCK_USER, user_role: storedRole, role: storedRole };
}
// If no role is stored, set the default and return it
localStorage.setItem(MOCK_USER_KEY, DEFAULT_MOCK_USER.user_role);
return DEFAULT_MOCK_USER;
} catch (e) {
// localStorage is not available (e.g., in SSR)
return DEFAULT_MOCK_USER;
}
};
export const base44 = {
auth: {
me: () => Promise.resolve(getMockUser()),
logout: () => {
try {
localStorage.removeItem(MOCK_USER_KEY); // Clear role on logout
// Optionally, redirect to login page or reload
window.location.reload();
} catch (e) {
// localStorage is not available
}
return Promise.resolve();
},
updateMe: (data) => {
try {
if (data.user_role) {
localStorage.setItem(MOCK_USER_KEY, data.user_role);
}
} catch (e) {
// localStorage is not available
}
// Simulate a successful update
return Promise.resolve({ ...getMockUser(), ...data });
},
},
entities: {
ActivityLog: {
filter: () => Promise.resolve([]),
},
// Add other entity mocks as needed for the RoleSwitcher to function
// For now, the RoleSwitcher only updates the user role, so other entities might not be critical.
},
integrations: {
Core: {
SendEmail: () => Promise.resolve({ status: "sent" }),
UploadFile: () => Promise.resolve({ file_url: "mock-file-url" }),
InvokeLLM: () => Promise.resolve({ result: "mock-ai-response" }),
// Add other integration mocks if the RoleSwitcher indirectly calls them
}
}
};`;
try {
const content = fs.readFileSync(clientFilePath, 'utf8');
// Check if the file is the original, unpatched version from the export
if (content.includes("createClient({")) {
fs.writeFileSync(clientFilePath, patchedMock, 'utf8');
console.log('✅ Successfully patched frontend-web/src/api/base44Client.js');
} else if (content.includes("const MOCK_USER_KEY")) {
console.log(' base44Client.js is already patched. Skipping.');
} else {
console.error('❌ Patching failed: Could not find the expected code in base44Client.js. The export format may have changed.');
process.exit(1);
}
} catch (error) {
console.error('❌ An error occurred during patching:', error);
process.exit(1);
}

View File

@@ -1,35 +0,0 @@
const fs = require('fs');
const path = require('path');
const projectRoot = path.resolve(__dirname, '..');
const dashboardFilePath = path.join(projectRoot, 'frontend-web', 'src', 'pages', 'Dashboard.jsx');
const oldString = ` <PageHeader
title="Welcome to KROW"`;
const newString = ` <PageHeader
title={
<div className="flex items-center gap-2">
<span>Welcome to KROW</span>
{import.meta.env.VITE_APP_ENV === 'staging' && <span className="bg-yellow-100 text-yellow-800 text-xs font-semibold px-2.5 py-0.5 rounded-full">Staging</span>}
{import.meta.env.VITE_APP_ENV === 'dev' && <span className="bg-slate-200 text-slate-800 text-xs font-semibold px-2.5 py-0.5 rounded-full">Dev</span>}
</div>
}`;
try {
const content = fs.readFileSync(dashboardFilePath, 'utf8');
if (content.includes(oldString)) {
const newContent = content.replace(oldString, newString);
fs.writeFileSync(dashboardFilePath, newContent, 'utf8');
console.log('✅ Successfully patched Dashboard.jsx to include environment label.');
} else if (content.includes('VITE_APP_ENV')) {
console.log(' Dashboard.jsx is already patched for environment labels. Skipping.');
} else {
console.error('❌ Patching Dashboard.jsx failed: Could not find the PageHeader title.');
process.exit(1);
}
} catch (error) {
console.error('❌ An error occurred during patching Dashboard.jsx:', error);
process.exit(1);
}

View File

@@ -1,41 +0,0 @@
const fs = require('fs');
const path = require('path');
const projectRoot = path.resolve(__dirname, '..');
const indexPath = path.join(projectRoot, 'frontend-web', 'index.html');
const oldTitle = '<title>Base44 APP</title>';
const newTitle = '<title>KROW</title>';
const oldFavicon = '<link rel="icon" type="image/svg+xml" href="https://base44.com/logo_v2.svg" />';
const newFavicon = '<link rel="icon" type="image/svg+xml" href="https://krow-workforce-dev-launchpad.web.app/favicon.svg" />';
try {
let content = fs.readFileSync(indexPath, 'utf8');
if (content.includes(oldTitle)) {
content = content.replace(oldTitle, newTitle);
console.log('✅ Successfully patched title in frontend-web/index.html.');
} else if (content.includes(newTitle)) {
console.log(' index.html title is already patched. Skipping.');
} else {
console.error('❌ Patching index.html failed: Could not find the expected title tag.');
process.exit(1);
}
if (content.includes(oldFavicon)) {
content = content.replace(oldFavicon, newFavicon);
console.log('✅ Successfully patched favicon in frontend-web/index.html.');
} else if (content.includes(newFavicon)) {
console.log(' index.html favicon is already patched. Skipping.');
} else {
console.error('❌ Patching index.html failed: Could not find the expected favicon link.');
process.exit(1);
}
fs.writeFileSync(indexPath, content, 'utf8');
} catch (error) {
console.error('❌ An error occurred during patching index.html:', error);
process.exit(1);
}

View File

@@ -1,26 +0,0 @@
const fs = require('fs');
const path = require('path');
const projectRoot = path.resolve(__dirname, '..');
const layoutFilePath = path.join(projectRoot, 'frontend-web', 'src', 'pages', 'Layout.jsx');
const oldString = ` queryKey: ['current-user-layout'],`;
const newString = ` queryKey: ['current-user'],`;
try {
const content = fs.readFileSync(layoutFilePath, 'utf8');
if (content.includes(oldString)) {
const newContent = content.replace(oldString, newString);
fs.writeFileSync(layoutFilePath, newContent, 'utf8');
console.log('✅ Successfully patched queryKey in frontend-web/src/pages/Layout.jsx');
} else if (content.includes(newString)) {
console.log(' queryKey in Layout.jsx is already patched. Skipping.');
} else {
console.error('❌ Patching failed: Could not find the expected queryKey in Layout.jsx.');
process.exit(1);
}
} catch (error) {
console.error('❌ An error occurred during patching Layout.jsx queryKey:', error);
process.exit(1);
}

View File

@@ -1,122 +0,0 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
// Replicate __dirname functionality in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const projectRoot = path.join(__dirname, '..', 'frontend-web');
// --- Patching Functions ---
function applyPatch(filePath, patchInfo) {
const fullPath = path.join(projectRoot, filePath);
if (!fs.existsSync(fullPath)) {
console.warn(`🟡 File not found, patch skipped: ${filePath}`);
return;
}
let content = fs.readFileSync(fullPath, 'utf8');
if (patchInfo.new_string && content.includes(patchInfo.new_string)) {
console.log(`✅ Patch already applied in ${filePath}.`);
return;
}
if (patchInfo.old_string && content.includes(patchInfo.old_string)) {
content = content.replace(patchInfo.old_string, patchInfo.new_string);
fs.writeFileSync(fullPath, content, 'utf8');
console.log(`🟢 Patch applied in ${filePath}.`);
} else {
console.error(`🔴 Could not apply patch in ${filePath}. String not found.`);
}
}
// --- Global Import Fix ---
function fixAllComponentImports(directory) {
const entries = fs.readdirSync(directory, { withFileTypes: true });
for (const entry of entries) {
const fullPath = path.join(directory, entry.name);
if (entry.isDirectory()) {
// Recursively search in subdirectories
fixAllComponentImports(fullPath);
} else if (entry.isFile() && (entry.name.endsWith('.jsx') || entry.name.endsWith('.js'))) {
let content = fs.readFileSync(fullPath, 'utf8');
const originalContent = content;
// Regex to find all relative imports to the components directory
// Handles: from "./components/", from "../components/", from "../../components/", etc.
const importRegex = /from\s+(['"])((\.\.\/)+|\.\/)components\//g;
content = content.replace(importRegex, 'from $1@/components/');
if (content !== originalContent) {
console.log(`✅ Fixing component imports in ${fullPath}`);
fs.writeFileSync(fullPath, content, 'utf8');
}
}
}
}
// --- Exécution ---
function main() {
console.log('--- Applying patches for local environment ---');
// The specific patches are now less critical as the global fix is more robust,
// but we can keep them for specific, non-import related changes.
const patches = [
{
file: 'src/main.jsx',
old_string: `ReactDOM.createRoot(document.getElementById('root')).render(
<App />
)`,
new_string: `import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
const queryClient = new QueryClient();
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
</React.StrictMode>,
)`
},
{
file: 'src/pages/Layout.jsx',
old_string: `const { data: user } = useQuery({
queryKey: ['current-user-layout'],
queryFn: () => base44.auth.me(),
});`,
new_string: ` // const { data: user } = useQuery({
// queryKey: ['current-user-layout'],
// queryFn: () => base44.auth.me(),
// });
// Mock user data to prevent redirection and allow local development
const user = {
full_name: "Dev User",
email: "dev@example.com",
user_role: "admin", // You can change this to 'procurement', 'operator', 'client', etc. to test different navigation menus
profile_picture: "https://i.pravatar.cc/150?u=a042581f4e29026024d",
};
`
}
];
patches.forEach(patchInfo => {
applyPatch(patchInfo.file, patchInfo);
});
console.log('--- Global component import fixes ---');
fixAllComponentImports(path.join(projectRoot, 'src'));
console.log('--- End of patching process ---');
}
main();

View File

@@ -1,72 +0,0 @@
#!/bin/bash
# ====================================================================================
# SCRIPT TO SETUP STANDARD GITHUB LABELS FROM A YAML FILE (v4 - Robust Bash Parsing)
# ====================================================================================
set -e # Exit script if a command fails
LABELS_FILE="labels.yml"
echo "🚀 Setting up GitHub labels from '${LABELS_FILE}'..."
# --- Function to create or edit a label ---
create_or_edit_label() {
NAME=$1
DESCRIPTION=$2
COLOR=$3
if [ -z "$NAME" ] || [ -z "$DESCRIPTION" ] || [ -z "$COLOR" ]; then
echo "⚠️ Skipping invalid label entry."
return
fi
# The `gh api` command will exit with a non-zero status if the label is not found (404).
# We redirect stderr to /dev/null to silence the expected "Not Found" error message.
if gh api "repos/{owner}/{repo}/labels/${NAME}" --silent 2>/dev/null; then
echo " - Editing existing label: '${NAME}'"
gh label edit "${NAME}" --description "${DESCRIPTION}" --color "${COLOR}"
else
echo " - Creating new label: '${NAME}'"
gh label create "${NAME}" --description "${DESCRIPTION}" --color "${COLOR}"
fi
}
# --- Read and Parse YAML File using a robust while loop ---
# This approach is more reliable than complex sed/awk pipelines.
name=""
description=""
color=""
while IFS= read -r line || [[ -n "$line" ]]; do
# Skip comments and empty lines
if [[ "$line" =~ ^\s*# ]] || [[ -z "$line" ]]; then
continue
fi
# Check for name
if [[ "$line" =~ -[[:space:]]+name:[[:space:]]+\"(.*)\" ]]; then
# If we find a new name, and the previous one was complete, process it.
if [ -n "$name" ] && [ -n "$description" ] && [ -n "$color" ]; then
create_or_edit_label "$name" "$description" "$color"
# Reset for the next entry
description=""
color=""
fi
name="${BASH_REMATCH[1]}"
# Check for description
elif [[ "$line" =~ [[:space:]]+description:[[:space:]]+\"(.*)\" ]]; then
description="${BASH_REMATCH[1]}"
# Check for color
elif [[ "$line" =~ [[:space:]]+color:[[:space:]]+\"(.*)\" ]]; then
color="${BASH_REMATCH[1]}"
fi
done < "$LABELS_FILE"
# Process the very last label in the file
if [ -n "$name" ] && [ -n "$description" ] && [ -n "$color" ]; then
create_or_edit_label "$name" "$description" "$color"
fi
echo ""
echo "🎉 All standard labels have been created or updated successfully."