From 4bbbbd6de609cdcffc87c6f3ccd4c9757197ae65 Mon Sep 17 00:00:00 2001 From: seonghobae Date: Mon, 24 Aug 2026 17:03:35 +0900 Subject: [PATCH] chore: remove one-shot patch scripts left from PR #347 development add_translations.py, patch_api.py, patch_app_fetch.py, patch_app_order.py, and patch_main.py were single-use edit scripts that already applied their changes; nothing in the Makefile, CI, or runtime references them, and leaving dead top-level scripts invites someone to run them twice. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01VENX71RtEntaUq6nkAWZho --- add_translations.py | 48 --------------------------------------------- patch_api.py | 35 --------------------------------- patch_app_fetch.py | 24 ----------------------- patch_app_order.py | 36 ---------------------------------- patch_main.py | 41 -------------------------------------- 5 files changed, 184 deletions(-) delete mode 100644 add_translations.py delete mode 100644 patch_api.py delete mode 100644 patch_app_fetch.py delete mode 100644 patch_app_order.py delete mode 100644 patch_main.py diff --git a/add_translations.py b/add_translations.py deleted file mode 100644 index 8448d75ee..000000000 --- a/add_translations.py +++ /dev/null @@ -1,48 +0,0 @@ -import re - -with open("frontend/src/i18n.ts", "r") as f: - content = f.read() - -translations = { - "Admin": { - "ko": "관리자", - "zh": "管理员", - "ja": "管理者", - "vi": "Quản trị viên" - }, - "Admin settings": { - "ko": "관리자 설정", - "zh": "管理员设置", - "ja": "管理者設定", - "vi": "Cài đặt quản trị viên" - }, - "Tenant brand name": { - "ko": "테넌트 브랜드명", - "zh": "租户品牌名称", - "ja": "テナントブランド名", - "vi": "Tên thương hiệu khách thuê" - }, - "Save settings": { - "ko": "설정 저장", - "zh": "保存设置", - "ja": "設定を保存", - "vi": "Lưu cài đặt" - }, - "Settings saved!": { - "ko": "설정이 저장되었습니다!", - "zh": "设置已保存!", - "ja": "設定が保存されました!", - "vi": "Đã lưu cài đặt!" - } -} - -for eng, trans in translations.items(): - content = content.replace(f' Refresh: "새로 고침",', f' Refresh: "새로 고침",\n "{eng}": "{trans["ko"]}",') - content = content.replace(f' Refresh: "조회",', f' Refresh: "조회",\n "{eng}": "{trans["ko"]}",') - - content = content.replace(f' Refresh: "刷新",', f' Refresh: "刷新",\n "{eng}": "{trans["zh"]}",') - content = content.replace(f' Refresh: "更新",', f' Refresh: "更新",\n "{eng}": "{trans["ja"]}",') - content = content.replace(f' Refresh: "Làm mới",', f' Refresh: "Làm mới",\n "{eng}": "{trans["vi"]}",') - -with open("frontend/src/i18n.ts", "w") as f: - f.write(content) diff --git a/patch_api.py b/patch_api.py deleted file mode 100644 index 250e265e7..000000000 --- a/patch_api.py +++ /dev/null @@ -1,35 +0,0 @@ -with open("frontend/src/api.ts", "r") as f: - content = f.read() - -new_api = """ -export async function fetchTenantConfig(accessToken: string): Promise<{ brandName: string }> { - const response = await fetch(`${config.backendBaseUrl}/api/settings`, { - headers: { Authorization: `Bearer ${accessToken}` }, - }); - if (!response.ok) { - throw new Error(`Failed to fetch tenant config: ${response.status}`); - } - return response.json(); -} - -export async function updateTenantConfig(accessToken: string, brandName: string): Promise<{ brandName: string }> { - const response = await fetch(`${config.backendBaseUrl}/api/settings`, { - method: "PATCH", - headers: { - Authorization: `Bearer ${accessToken}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ brandName }), - }); - if (!response.ok) { - throw new Error(`Failed to update tenant config: ${response.status}`); - } - return response.json(); -} -""" - -if "fetchTenantConfig" not in content: - content += new_api - with open("frontend/src/api.ts", "w") as f: - f.write(content) - print("Patched api.ts") diff --git a/patch_app_fetch.py b/patch_app_fetch.py deleted file mode 100644 index 57320ef8c..000000000 --- a/patch_app_fetch.py +++ /dev/null @@ -1,24 +0,0 @@ -with open("frontend/src/App.tsx", "r") as f: - content = f.read() - -# Add imports for fetchTenantConfig -content = content.replace( - '} from "./api";', - ' fetchTenantConfig,\n} from "./api";' -) - -# Replace standard state with fetch hook inside App -old_state = ' const [brandName, setBrandName] = useState("LineageWeave");' -new_state = """ const [brandName, setBrandName] = useState("LineageWeave"); - useEffect(() => { - if (accessToken) { - fetchTenantConfig(accessToken).then((config) => { - if (config.brandName) setBrandName(config.brandName); - }).catch(console.error); - } - }, [accessToken]);""" - -content = content.replace(old_state, new_state) - -with open("frontend/src/App.tsx", "w") as f: - f.write(content) diff --git a/patch_app_order.py b/patch_app_order.py deleted file mode 100644 index 07f4ffc32..000000000 --- a/patch_app_order.py +++ /dev/null @@ -1,36 +0,0 @@ -with open("frontend/src/App.tsx", "r") as f: - content = f.read() - -# We have: -# const [brandName, setBrandName] = useState("LineageWeave"); -# useEffect(() => { ... }, [accessToken]); -# const auth = useAuth(); -# const [destination, setDestination] = useState("board"); -# ... -# const testOnlyLabPanels = import.meta.env.MODE === "test" && showLabPanels; -# const accessToken = auth.user?.access_token; - -# We need to move the useEffect down after accessToken is defined. - -import re - -# Remove the bad useEffect -bad_effect_pattern = r" useEffect\(\(\) => \{\n if \(accessToken\) \{\n fetchTenantConfig\(accessToken\).then\(\(config\) => \{\n if \(config\.brandName\) setBrandName\(config\.brandName\);\n \}\)\.catch\(console\.error\);\n \}\n \}, \[accessToken\]\);\n" -content = re.sub(bad_effect_pattern, "", content) - -# Insert it after accessToken is defined -access_token_line = ' const accessToken = auth.user?.access_token;\n' -good_effect = """ - useEffect(() => { - if (accessToken) { - fetchTenantConfig(accessToken).then((config) => { - if (config.brandName) setBrandName(config.brandName); - }).catch(console.error); - } - }, [accessToken]); -""" - -content = content.replace(access_token_line, access_token_line + good_effect) - -with open("frontend/src/App.tsx", "w") as f: - f.write(content) diff --git a/patch_main.py b/patch_main.py deleted file mode 100644 index dc990d319..000000000 --- a/patch_main.py +++ /dev/null @@ -1,41 +0,0 @@ -import re - -with open("backend/app/main.py", "r") as f: - content = f.read() - -endpoints = """ -@app.get("/api/settings", response_model=dict) -async def read_tenant_settings( - account: CurrentAccount, - conn: asyncpg.Connection = Depends(get_db), -): - row = await conn.fetchrow("SELECT brand_name FROM tenant_settings WHERE id = 1") - if not row: - return {"brandName": "LineageWeave"} - return {"brandName": row["brand_name"]} - -@app.patch("/api/settings", response_model=dict) -async def update_tenant_settings( - payload: dict, - account: CurrentAccount, - conn: asyncpg.Connection = Depends(get_db), -): - # Only admins can change settings - _require_post_admin(account) - brand_name = payload.get("brandName", "LineageWeave") - await conn.execute( - "INSERT INTO tenant_settings (id, brand_name) VALUES (1, $1) " - "ON CONFLICT (id) DO UPDATE SET brand_name = $1", - brand_name - ) - return {"brandName": brand_name} -""" - -if "@app.get(\"/api/settings\"" not in content: - # Insert before the last function or at a logical place - content = content.replace("async def healthz", endpoints + "\n\nasync def healthz") - with open("backend/app/main.py", "w") as f: - f.write(content) - print("Patched main.py") -else: - print("Endpoints already exist")