39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
import os, re
|
|
|
|
def read(path):
|
|
with open(path, 'r') as f: return f.read()
|
|
|
|
def write(path, content):
|
|
with open(path, 'w') as f: f.write(content)
|
|
print(f" ✓ {path}")
|
|
|
|
# Fix 1: revalidatePath cast to any (Next.js 16 types it as possibly undefined)
|
|
# Fix 2: logger.info`...`) → logger.info(`...`)
|
|
files = [
|
|
'src/collections/Pages/hooks/revalidatePage.ts',
|
|
'src/collections/Posts/hooks/revalidatePost.ts',
|
|
'src/Footer/hooks/revalidateFooter.ts',
|
|
'src/Header/hooks/revalidateHeader.ts',
|
|
'src/hooks/revalidateRedirects.ts',
|
|
'src/globals/PopupAnnouncement/hooks/revalidatePopup.ts',
|
|
]
|
|
|
|
for path in files:
|
|
if not os.path.exists(path): continue
|
|
content = read(path)
|
|
|
|
# Fix revalidatePath(x, 'page') → (revalidatePath as any)(x, 'page')
|
|
new = re.sub(r'\brevalidatePath\(', '(revalidatePath as any)(', content)
|
|
|
|
# Fix broken logger.info`...`) → logger.info(`...`)
|
|
# Pattern: .info`some text ${var}`) → .info(`some text ${var}`)
|
|
new = re.sub(r'\.info`([^`]*)`\)', r'.info(`\1`)', new)
|
|
|
|
if new != content:
|
|
write(path, new)
|
|
else:
|
|
print(f" - no changes: {path}")
|
|
|
|
print("\nDone. Run: npx tsc --noEmit")
|