Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(baileys): fail the image build when chats.js has moved
Yudhi Armyndharisb6d4db0bc044
diff --git a/scripts/patch-baileys-appstate.js b/scripts/patch-baileys-appstate.jsindex 88d0ebab2..1a1a84ce8 100644--- a/scripts/patch-baileys-appstate.js+++ b/scripts/patch-baileys-appstate.js@@ -53,7 +53,7 @@ const LOOP_REPLACE = ` const decoded = await extractSyncdPatches(function applyAppStatePatch(baileysDir = DEFAULT_BAILEYS) {const file = path.join(baileysDir, CHATS_PATH);if (!fs.existsSync(file)) {- return { skipped: true, reason: `${CHATS_PATH} not found — nothing to patch` };+ throw new Error(`@whiskeysockets/baileys ${CHATS_PATH} not found at ${file}`);}const source = fs.readFileSync(file, 'utf8');if (source.includes(PATCHED_MARKER)) {@@ -89,8 +89,8 @@ if (require.main === module) run();/*** The stand-down branch above as a predicate, for the startup guard (engine-patch-status.ts).- * Unreadable reads as applied: a tree we cannot inspect is not evidence of a broken one, and the- * apply function treats a missing chats.js as nothing to patch rather than a fault.+ * Unreadable reads as applied: a tree we cannot inspect is not evidence of a broken one, and a+ * missing chats.js already fails the image build, where the apply function refuses it.*/function isApplied(baileysDir = DEFAULT_BAILEYS) {try {diff --git a/scripts/patch-baileys-appstate.spec.js b/scripts/patch-baileys-appstate.spec.jsindex e7e067ea2..9cd1e2a53 100644--- a/scripts/patch-baileys-appstate.spec.js+++ b/scripts/patch-baileys-appstate.spec.js@@ -68,9 +68,9 @@ test('refuses when the decode site appears more than once', () => {assert.throws(() => applyAppStatePatch(dir), /found 2/);});-test('skips a tree that has no chats.js rather than throwing', () => {+test('refuses a tree that has no chats.js rather than skipping it', () => {+ // A moved or renamed chats.js is an upstream layout change: skipping it let the fatal image-build+ // run pass and ship the unbounded loop. postinstall's --best-effort run still only warns.const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'baileys-absent-'));- const result = applyAppStatePatch(dir);- assert.equal(result.skipped, true);- assert.match(result.reason, /not found/);+ assert.throws(() => applyAppStatePatch(dir), /not found/);});