import fs from 'fs'; const path = new URL('../src/modules/workflow/legacyRoutes.ts', import.meta.url); let s = fs.readFileSync(path, 'utf8'); s = s.replace(/from '\.\.\//g, "from '../../"); s = s.replace( "import { authMiddleware, AuthRequest } from '../../middleware/auth';", "import { authMiddleware, type AuthRequest } from '../../middleware/auth';" ); s = s.replace(/import \{[\s\S]*?\} from '\.\.\/services\/pickingService';\r?\n/, ''); s = s.replace(/import \{ isPickingBarcodeEnabled \} from '\.\.\/services\/pickingBarcodeService';\r?\n/, ''); const pickStart = s.indexOf("router.post('/picking/create'"); const pickEnd = s.indexOf("router.post('/purchase/submit-audit'"); if (pickStart >= 0 && pickEnd > pickStart) { s = s.slice(0, pickStart) + s.slice(pickEnd); } s = s.replace('const router = Router();', 'export function mountWorkflowLegacyRoutes(router: Router): void {'); s = s.replace('export default router;', '}'); fs.writeFileSync(path, s); console.log('patched legacyRoutes.ts', s.length);