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 newsletter.js has moved
Yudhi Armyndharisb5f6a2954a77
diff --git a/scripts/patch-baileys-newsletter-create.js b/scripts/patch-baileys-newsletter-create.jsindex dc08583d5..1f8eb5bdd 100644--- a/scripts/patch-baileys-newsletter-create.js+++ b/scripts/patch-baileys-newsletter-create.js@@ -81,7 +81,7 @@ const PARSE_REPLACE = ` // ${MARKER} — its input is { name, description } afunction applyNewsletterCreatePatch(baileysDir = DEFAULT_BAILEYS) {const file = path.join(baileysDir, NEWSLETTER_PATH);if (!fs.existsSync(file)) {- return { skipped: true, reason: `${NEWSLETTER_PATH} not found — nothing to patch` };+ throw new Error(`@whiskeysockets/baileys ${NEWSLETTER_PATH} not found at ${file}`);}const source = fs.readFileSync(file, 'utf8');if (source.includes(MARKER)) {@@ -118,8 +118,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 newsletter.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 newsletter.js already fails the image build, where the apply function refuses it.*/function isApplied(baileysDir = DEFAULT_BAILEYS) {try {diff --git a/scripts/patch-baileys-newsletter-create.spec.js b/scripts/patch-baileys-newsletter-create.spec.jsindex 549da722a..c579c9c34 100644--- a/scripts/patch-baileys-newsletter-create.spec.js+++ b/scripts/patch-baileys-newsletter-create.spec.js@@ -116,11 +116,9 @@ test('refuses an unknown shape rather than shipping unpatched', () => {fs.rmSync(dir, { recursive: true, force: true });});-test('skips a tree with no baileys rather than failing the install', () => {+test('refuses a tree with no newsletter.js rather than shipping unpatched', () => {const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'baileys-newsletter-'));- const result = applyNewsletterCreatePatch(dir);- assert.equal(result.skipped, true);- assert.match(result.reason, /not found/);+ assert.throws(() => applyNewsletterCreatePatch(dir), /not found/);fs.rmSync(dir, { recursive: true, force: true });});