From 19c3d267fad7a29d779dda810ca5801de9e5312c Mon Sep 17 00:00:00 2001 From: ertopogo Date: Sat, 24 Jan 2026 14:23:03 +0100 Subject: corrections du backend --- backend/Dockerfile | 4 ++-- backend/package.json | 10 ++++++---- backend/scripts/patch-medusa.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 backend/scripts/patch-medusa.js (limited to 'backend') diff --git a/backend/Dockerfile b/backend/Dockerfile index 6775ba5..17fdda8 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -10,8 +10,8 @@ RUN npm install COPY . . -# Build the project (if using TypeScript) -RUN npm run build +# Build only when TypeScript sources exist +RUN if [ -d "src" ]; then npm run build; else echo "Skipping build: no src/ directory"; fi # Expose port EXPOSE 9000 diff --git a/backend/package.json b/backend/package.json index 5a4c902..caf9258 100644 --- a/backend/package.json +++ b/backend/package.json @@ -15,11 +15,12 @@ "scripts": { "clean": "cross-env ./node_modules/.bin/rimraf dist", "build": "cross-env ./node_modules/.bin/rimraf dist && tsc -p tsconfig.json", - "start": "cross-env npm run build && medusa start", - "start:custom": "cross-env npm run build && node --preserve-symlinks index.js", - "dev": "cross-env npm run build && medusa develop", + "start": "sh -c \"if [ -d src ]; then npm run build; else echo 'Skipping build: no src/ directory'; fi && medusa start\"", + "start:custom": "sh -c \"if [ -d src ]; then npm run build; else echo 'Skipping build: no src/ directory'; fi && node --preserve-symlinks index.js\"", + "dev": "sh -c \"if [ -d src ]; then npm run build; else echo 'Skipping build: no src/ directory'; fi && medusa develop\"", "seed": "medusa seed -f ./data/seed.json", - "install:cli": "npm install -g @medusajs/medusa-cli" + "install:cli": "npm install -g @medusajs/medusa-cli", + "postinstall": "node scripts/patch-medusa.js" }, "dependencies": { "@medusajs/medusa": "^1.20.0", @@ -34,6 +35,7 @@ "cors": "^2.8.5", "dotenv": "16.3.1", "express": "^4.17.1", + "medusa-fulfillment-manual": "^1.1.0", "medusa-interfaces": "^1.3.7", "medusa-payment-manual": "^1.0.24", "medusa-payment-stripe": "^6.0.7", diff --git a/backend/scripts/patch-medusa.js b/backend/scripts/patch-medusa.js new file mode 100644 index 0000000..9d95d9a --- /dev/null +++ b/backend/scripts/patch-medusa.js @@ -0,0 +1,34 @@ +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."); -- cgit v1.2.3