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); }