const fs = require('fs'); const req = (label) => `label={${label} *}`; function processFile(file) { let content = fs.readFileSync(file, 'utf8'); // Find all components with isRequired // We need to match: label="Something" ... isRequired // First, find all lines with label="..." // If a block has isRequired, replace the label and remove isRequired. const tags = ['TextInput', 'Selector', 'NumberInput', 'TimeInput']; // A simple regex to find JSX tags and their props const regex = /<(TextInput|Selector|NumberInput|TimeInput)([^>]+)isRequired([^>]*)>/g; content = content.replace(regex, (match, tag, before, after) => { // extract label const labelMatch = before.match(/label="([^"]+)"/); if (!labelMatch) { // maybe label is after isRequired const labelMatchAfter = after.match(/label="([^"]+)"/); if (!labelMatchAfter) return match; // fallback const newLabel = req(labelMatchAfter[1]); return `<${tag}${before}${after.replace(labelMatchAfter[0], newLabel)}>`; } const newLabel = req(labelMatch[1]); return `<${tag}${before.replace(labelMatch[0], newLabel)}${after}>`; }); fs.writeFileSync(file, content); } processFile('src/features/nearle-admin/pages/OnboardTenantPage.tsx'); processFile('src/features/nearle-admin/pages/OnboardBranchPage.tsx'); console.log("Done");