Files
Krow-workspace/scripts/patch-dashboard-for-env-label.js
bwnyasse 9bdb250714 feat: add firebase configuration and deployment scripts
This commit introduces Firebase configuration files (.firebaserc,
firebase.json) and updates the Makefile to include deployment
commands for different environments (dev, staging).

The .firebaserc file defines Firebase projects for development and
staging, along with hosting targets.

The firebase.json file configures hosting settings, including
rewrites and ignores. It defines hosting targets for the main app
in dev and staging, and a separate target for an internal launchpad.

The Makefile is updated to include:
- GCP project IDs for dev and staging.
- Environment detection (ENV variable).
- Conditional variables based on the environment (GCP_PROJECT_ID,
 FIREBASE_ALIAS, HOSTING_TARGET).
- Deployment commands for the launchpad and the main app.
- The build command now passes the environment variable to the
 frontend build process.

The internal launchpad is added to firebase/internal-launchpad/index.html
to provide quick access to application URLs and Firebase/GCP
consoles for different environments.

A patch script is added to inject the environment label into the
Dashboard page.

The index.html title is changed to KROW.

These changes enable streamlined deployment and environment
management for the KROW application.
2025-11-14 08:53:00 -05:00

36 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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' && <Badge className="bg-yellow-100 text-yellow-800">Staging</Badge>}
{import.meta.env.VITE_APP_ENV === 'dev' && <Badge className="bg-slate-100 text-slate-800">Dev</Badge>}
</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);
}