diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 00000000..85314b12 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,30 @@ +{ + "projects": { + "default": "krow-workforce-dev", + "dev": "krow-workforce-dev", + "staging": "krow-workforce-staging" + }, + "targets": { + "krow-workforce-dev": { + "hosting": { + "launchpad": [ + "krow-workforce-dev-launchpad" + ], + "app-dev": [ + "krow-workforce-dev" + ], + "app-staging": [ + "krow-workforce-staging" + ] + } + }, + "krow-workforce-staging": { + "hosting": { + "app-staging": [ + "krow-workforce-staging" + ] + } + } + }, + "etags": {} +} \ No newline at end of file diff --git a/Makefile b/Makefile index 97783865..ca061072 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,29 @@ # It is designed to be the main entry point for developers. # Use .PHONY to declare targets that are not files, to avoid conflicts. -.PHONY: install dev build prepare-export help +.PHONY: install dev build prepare-export help deploy-launchpad deploy-app # The default command to run if no target is specified (e.g., just 'make'). .DEFAULT_GOAL := help +# --- 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 +else + GCP_PROJECT_ID := $(GCP_DEV_PROJECT_ID) + FIREBASE_ALIAS := dev + HOSTING_TARGET := app-dev +endif + # Installs all project dependencies using npm. install: @echo "--> Installing web frontend dependencies..." @@ -24,7 +42,7 @@ dev: # Builds the application for production. build: @echo "--> Building web frontend for production..." - @cd frontend-web && npm run build + @cd frontend-web && VITE_APP_ENV=$(ENV) npm run build # Integrates a new Base44 export into the current project. # It replaces the src directory and the index.html file in the frontend-web directory. @@ -45,6 +63,8 @@ integrate-export: @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 "--> Integration complete. Next step: 'make prepare-export'." # Applies all necessary patches to a fresh Base44 export to run it locally. @@ -54,6 +74,15 @@ prepare-export: @node scripts/prepare-export.js @echo "--> Preparation complete. You can now run 'make dev'." +# --- Firebase Deployment --- +deploy-launchpad: + @echo "--> Deploying Internal Launchpad to DEV project..." + @firebase deploy --only hosting:launchpad --project=dev + +deploy-app: build + @echo "--> Deploying Frontend Web App to [$(ENV)] environment..." + @firebase deploy --only hosting:$(HOSTING_TARGET) --project=$(FIREBASE_ALIAS) + # Shows this help message. help: @echo "--------------------------------------------------" @@ -64,6 +93,11 @@ help: @echo " make build - Builds the web frontend for production." @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 " --- DEPLOYMENT ---" + @echo " make deploy-launchpad - Deploys the internal launchpad (always to dev)." + @echo " make deploy-app [ENV=staging] - Builds and deploys the main web app (default: dev)." + @echo "" @echo " make help - Shows this help message." @echo "--------------------------------------------------" diff --git a/firebase.json b/firebase.json index a25a05b0..78e46ee6 100644 --- a/firebase.json +++ b/firebase.json @@ -1,58 +1,49 @@ { + "firestore": { + "rules": "firebase/firestore.rules" + }, + "storage": { + "rules": "firebase/storage.rules" + }, "hosting": [ { - "target": "dev", - "public": "frontend-web/dist", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], - "rewrites": [ - { - "source": "**", - "destination": "/index.html" - } - ] - }, - { - "target": "staging", - "public": "frontend-web/dist", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], - "rewrites": [ - { - "source": "**", - "destination": "/index.html" - } - ] - }, - { - "target": "prod", - "public": "frontend-web/dist", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], - "rewrites": [ - { - "source": "**", - "destination": "/index.html" - } - ] - }, - { - "target": "internal-launchpad", + "target": "launchpad", "public": "firebase/internal-launchpad", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ] + }, + { + "target": "app-dev", + "public": "frontend-web/dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + }, + { + "target": "app-staging", + "public": "frontend-web/dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] } ] -} +} \ No newline at end of file diff --git a/firebase/internal-launchpad/index.html b/firebase/internal-launchpad/index.html index dbb09f4e..e62c859a 100644 --- a/firebase/internal-launchpad/index.html +++ b/firebase/internal-launchpad/index.html @@ -165,7 +165,7 @@
-

Applications

+

Applications (Hosting URLs)

  • @@ -196,6 +196,29 @@
+
+

Google Cloud & Firebase Consoles

+ +

Access & Resources

diff --git a/frontend-web/index.html b/frontend-web/index.html index 8131cdb4..ce41a902 100644 --- a/frontend-web/index.html +++ b/frontend-web/index.html @@ -4,7 +4,7 @@ - Base44 APP + KROW
diff --git a/frontend-web/src/pages/Dashboard.jsx b/frontend-web/src/pages/Dashboard.jsx index 7cf606f1..7efbb4f7 100644 --- a/frontend-web/src/pages/Dashboard.jsx +++ b/frontend-web/src/pages/Dashboard.jsx @@ -88,7 +88,13 @@ export default function Dashboard() {
+ Welcome to KROW + {import.meta.env.VITE_APP_ENV === 'staging' && Staging} + {import.meta.env.VITE_APP_ENV === 'dev' && Dev} +
+ } subtitle="Your Complete Workforce Management Ecosystem" actions={ <> diff --git a/scripts/patch-dashboard-for-env-label.js b/scripts/patch-dashboard-for-env-label.js new file mode 100644 index 00000000..be3db6e6 --- /dev/null +++ b/scripts/patch-dashboard-for-env-label.js @@ -0,0 +1,35 @@ +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 = ` + Welcome to KROW + {import.meta.env.VITE_APP_ENV === 'staging' && Staging} + {import.meta.env.VITE_APP_ENV === 'dev' && Dev} +
+ }`; + +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); +}