integratedhub/fix_code.py
open-swe-dev-andrinoid[bot] cc4892d857 Apply patch [skip ci]
2026-01-20 18:45:14 +00:00

95 lines
3.5 KiB
Python

import sys
def modify_vite():
try:
with open('vite.config.ts', 'r') as f:
lines = f.readlines()
new_lines = []
public_dir_added = False
for line in lines:
new_lines.append(line)
if 'export default defineConfig({' in line and not public_dir_added:
# Check if publicDir is already there to avoid duplicates
if not any('publicDir' in l for l in lines):
new_lines.append(' publicDir: "static",\n')
public_dir_added = True
with open('vite.config.ts', 'w') as f:
f.writelines(new_lines)
print("Modified vite.config.ts")
except Exception as e:
print(f"Error modifying vite.config.ts: {e}")
def modify_messages():
try:
with open('routes/tenant/messages/index.tsx', 'r') as f:
lines = f.readlines()
# Swap lines 1 and 2 (0-indexed) -> lines 2 and 3 (1-indexed)
# Line 2 is index 1, Line 3 is index 2
if len(lines) > 2 and 'import { define }' in lines[1] and 'import { page }' in lines[2]:
lines[1], lines[2] = lines[2], lines[1]
with open('routes/tenant/messages/index.tsx', 'w') as f:
f.writelines(lines)
print("Modified routes/tenant/messages/index.tsx")
else:
print("Skipped routes/tenant/messages/index.tsx (conditions not met)")
except Exception as e:
print(f"Error modifying routes/tenant/messages/index.tsx: {e}")
def modify_settings():
try:
with open('routes/tenant/settings/index.tsx', 'r') as f:
lines = f.readlines()
# Find the lines to replace
for i, line in enumerate(lines):
if 'export default define.page(' in line:
# Check next line
if i+1 < len(lines) and 'function TenantSettingsPage' in lines[i+1]:
lines[i] = 'export default define.page(function TenantSettingsPage({\n'
lines[i+1] = ' data,\n}: {\n data: SettingsPageData;\n}) {\n'
break
with open('routes/tenant/settings/index.tsx', 'w') as f:
f.writelines(lines)
print("Modified routes/tenant/settings/index.tsx")
except Exception as e:
print(f"Error modifying routes/tenant/settings/index.tsx: {e}")
def modify_service():
try:
with open('services/messageService.ts', 'r') as f:
lines = f.readlines()
# Find lines for schema and interfaces imports
schema_idx = -1
interfaces_idx = -1
for i, line in enumerate(lines):
if 'from "../db/schema.ts"' in line:
schema_idx = i
if 'from "../db/interfaces.ts"' in line:
interfaces_idx = i
if schema_idx != -1 and interfaces_idx != -1 and schema_idx < interfaces_idx:
# Swap them
lines[schema_idx], lines[interfaces_idx] = lines[interfaces_idx], lines[schema_idx]
with open('services/messageService.ts', 'w') as f:
f.writelines(lines)
print("Modified services/messageService.ts")
else:
print("Skipped services/messageService.ts (conditions not met or already correct)")
except Exception as e:
print(f"Error modifying services/messageService.ts: {e}")
if __name__ == '__main__':
modify_vite()
modify_messages()
modify_settings()
modify_service()