fix: remove prebuild script and patch_appwrite.js as we use monkey patching instead

This commit is contained in:
Carlos (Almeira) 2026-07-09 23:30:00 -05:00
parent ade675e0d8
commit b9f74a8c87
2 changed files with 1 additions and 45 deletions

View File

@ -7,8 +7,7 @@
"build": "next build",
"start": "next start",
"lint": "eslint",
"check-config": "node --env-file=.env.local check_config.js",
"prebuild": "node patch_appwrite.js"
"check-config": "node --env-file=.env.local check_config.js"
},
"dependencies": {
"@livekit/components-react": "^2.9.21",

View File

@ -1,43 +0,0 @@
const fs = require('fs');
const path = require('path');
const filesToPatch = [
'node_modules/node-appwrite/dist/client.mjs',
'node_modules/node-appwrite/dist/client.js',
'node_modules/appwrite/dist/cjs/sdk.js',
'node_modules/appwrite/dist/esm/sdk.js'
];
filesToPatch.forEach(file => {
const filePath = path.join(__dirname, file);
if (fs.existsSync(filePath)) {
let content = fs.readFileSync(filePath, 'utf8');
// We want to replace the console.warn that outputs the warning.
// The exact code in client is: warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));
const target = "warnings.split(';').forEach((warning) => console.warn('Warning: ' + warning));";
const replacement = "warnings.split(';').forEach((warning) => { if (!warning.includes('built for Appwrite')) console.warn('Warning: ' + warning); });";
// Also try the compiled JS versions which might have different formatting
const target2 = 'warnings.split(";").forEach((warning) => console.warn("Warning: " + warning));';
const replacement2 = 'warnings.split(";").forEach((warning) => { if (!warning.includes("built for Appwrite")) console.warn("Warning: " + warning); });';
if (content.includes(target)) {
content = content.replace(target, replacement);
fs.writeFileSync(filePath, content, 'utf8');
console.log(`Patched ${file}`);
} else if (content.includes(target2)) {
content = content.replace(target2, replacement2);
fs.writeFileSync(filePath, content, 'utf8');
console.log(`Patched ${file}`);
} else {
// For minified files or different formats, use regex
const regex = /warnings\.split\(['"]\;['"]\)\.forEach\(\([^)]*\)\s*=>\s*console\.warn\(['"]Warning:\s*['"]\s*\+\s*warning\)\)/g;
const match = content.match(regex);
if (match) {
content = content.replace(regex, "warnings.split(';').forEach((warning) => { if (!warning.includes('built for Appwrite')) console.warn('Warning: ' + warning); })");
fs.writeFileSync(filePath, content, 'utf8');
console.log(`Patched ${file} via regex`);
}
}
}
});