const fs = require("fs"); const path = require("path"); const targetPath = path.join( __dirname, "..", "node_modules", "@medusajs", "medusa", "dist", "services", "payment-provider.js" ); if (!fs.existsSync(targetPath)) { console.error("patch-medusa: cible introuvable:", targetPath); process.exit(1); } const original = fs.readFileSync(targetPath, "utf8"); const before = "model.update({}, { is_installed: false })"; const after = "model.createQueryBuilder().update().set({ is_installed: false }).where('1=1').execute()"; if (!original.includes(before)) { console.error( "patch-medusa: motif introuvable, le patch n'a pas ete applique." ); process.exit(1); } const patched = original.replace(before, after); fs.writeFileSync(targetPath, patched, "utf8"); console.log("patch-medusa: update vide remplace avec succes.");