-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_specific_errors.js
More file actions
71 lines (64 loc) · 2.11 KB
/
fix_specific_errors.js
File metadata and controls
71 lines (64 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const fs = require('fs');
const path = require('path');
const fixes = [
{
path: 'src/pages/AICoverGenerator.tsx',
edits: [
{
find: '/) : selectedCover ?',
replace: '/>) : selectedCover ?'
},
{
find: '>img',
replace: '<img'
}
]
},
{
path: 'src/pages/AdminVerificationPanel.tsx',
edits: [
{
find: "{verification.status === 'pending' && (<button",
replace: "{verification.status === 'pending' && (<>\n<button"
}
]
},
{
path: 'src/pages/Messages.tsx',
edits: [
// Already fixed manually, but good to have fallback if reverted
]
}
];
const projectRoot = path.resolve('d:/m-zik-platform-main');
fixes.forEach(fix => {
const fullPath = path.join(projectRoot, fix.path);
if (!fs.existsSync(fullPath)) {
console.log(`Skipping ${fix.path} (not found)`);
return;
}
let content = fs.readFileSync(fullPath, 'utf8');
let originalContent = content;
fix.edits.forEach(edit => {
if (content.includes(edit.find)) {
content = content.replace(edit.find, edit.replace);
console.log(`Applied fix in ${fix.path}: ${edit.find.substring(0, 20)}...`);
} else {
// Try regex for stricter matches if exact string missing (due to formatting)
// For AdminVerificationPanel, spaces might differ
if (edit.find.includes('&& (<button')) {
// Regex for `&& (<button`
// Replace with `&& (<> <button`
// But we need to make sure we don't double fix or break
const regex = /&& \(\s*<button/g;
if (regex.test(content)) {
content = content.replace(regex, '&& (<>\n<button');
console.log(`Applied regex fix in ${fix.path}`);
}
}
}
});
if (content !== originalContent) {
fs.writeFileSync(fullPath, content, 'utf8');
}
});