diff options
| author | ertopogo <erwin.t.pombett@gmail.com> | 2026-01-24 19:36:11 +0100 |
|---|---|---|
| committer | ertopogo <erwin.t.pombett@gmail.com> | 2026-01-24 19:36:11 +0100 |
| commit | b4d8c9f8204e90aaf958dde6fbfe9cf4925af559 (patch) | |
| tree | 6ae340452f4d0b93cf85e47f4f441f4f7ecaa939 /backend | |
| parent | fe49c7a16d3edb65cf4706c336bc65784bf94548 (diff) | |
ajout d'un patch pour les modules manquants
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/scripts/patch-medusa.js | 76 |
1 files changed, 60 insertions, 16 deletions
diff --git a/backend/scripts/patch-medusa.js b/backend/scripts/patch-medusa.js index f44f23c..b20a9fd 100644 --- a/backend/scripts/patch-medusa.js +++ b/backend/scripts/patch-medusa.js @@ -11,24 +11,68 @@ const targetPath = path.join( "services",
"payment-provider.js"
);
+const notificationPath = path.join(
+ __dirname,
+ "..",
+ "node_modules",
+ "@medusajs",
+ "medusa",
+ "dist",
+ "services",
+ "notification.js"
+);
-if (!fs.existsSync(targetPath)) {
- console.error("patch-medusa: cible introuvable:", targetPath);
- process.exit(1);
-}
+const targets = [
+ {
+ label: "payment-provider",
+ filePath: targetPath,
+ },
+ {
+ label: "notification",
+ filePath: notificationPath,
+ },
+];
+
+const replacements = [
+ {
+ before: "model.update({}, { is_installed: false })",
+ after:
+ "model.createQueryBuilder().update().set({ is_installed: false }).where('1=1').execute()",
+ },
+];
+
+let totalApplied = 0;
+
+for (const target of targets) {
+ if (!fs.existsSync(target.filePath)) {
+ console.error("patch-medusa: cible introuvable:", target.filePath);
+ 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()";
+ const original = fs.readFileSync(target.filePath, "utf8");
+ let patched = original;
+ let appliedCount = 0;
-if (!original.includes(before)) {
- console.error(
- "patch-medusa: motif introuvable, le patch n'a pas ete applique."
- );
- process.exit(1);
+ for (const { before, after } of replacements) {
+ if (patched.includes(before)) {
+ patched = patched.replace(before, after);
+ appliedCount += 1;
+ }
+ }
+
+ if (appliedCount === 0) {
+ console.error(
+ "patch-medusa: motif introuvable pour " + target.label + "."
+ );
+ process.exit(1);
+ }
+
+ fs.writeFileSync(target.filePath, patched, "utf8");
+ totalApplied += appliedCount;
}
-const patched = original.replace(before, after);
-fs.writeFileSync(targetPath, patched, "utf8");
-console.log("patch-medusa: update vide remplace avec succes.");
+console.log(
+ "patch-medusa: update vide remplace avec succes (count=" +
+ totalApplied +
+ ")."
+);
|
