From c678764c11d0eec433b4876a3808019d6825ee2a Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Fri, 20 Mar 2026 16:03:46 +0800 Subject: [PATCH] fix(ci): repair converted deployment adapters --- .github/workflows/pages-cf.yml | 1 + .github/workflows/sync.yml | 42 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pages-cf.yml b/.github/workflows/pages-cf.yml index 167e4ab..f161020 100644 --- a/.github/workflows/pages-cf.yml +++ b/.github/workflows/pages-cf.yml @@ -60,4 +60,5 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: "4.76.0" command: pages deploy . --project-name=xget --branch=${{ github.ref_name }} diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index ed076d6..318942c 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -45,12 +45,21 @@ jobs: cp package-lock.json /tmp/pages-conversion/ 2>/dev/null || true cp LICENSE /tmp/pages-conversion/ - - name: Export handleRequest from src/index.js + - name: Rewrite Pages adapter imports for converted layout run: | cd /tmp/pages-conversion - # Add export statement before the default export at the end of the file - sed -i '/^export default {$/i\ - export { handleRequest };' src/index.js + python3 - <<'PY' + from pathlib import Path + + path = Path("functions/[[path]].js") + old = "../../../src/app/handle-request.js" + new = "../src/app/handle-request.js" + + text = path.read_text(encoding="utf-8") + if old not in text: + raise SystemExit(f"expected import path not found in {path}") + path.write_text(text.replace(old, new), encoding="utf-8") + PY - name: Update package.json for Pages run: | @@ -120,12 +129,29 @@ jobs: cp package-lock.json /tmp/functions-conversion/ 2>/dev/null || true cp LICENSE /tmp/functions-conversion/ - - name: Export handleRequest from src/index.js + - name: Rewrite Functions adapter imports for converted layout run: | cd /tmp/functions-conversion - # Add export statement before the default export at the end of the file - sed -i '/^export default {$/i\ - export { handleRequest };' src/index.js + python3 - <<'PY' + from pathlib import Path + + replacements = { + Path("api/index.js"): ( + "../../../src/app/handle-request.js", + "../src/app/handle-request.js", + ), + Path("deno.js"): ( + "../../src/app/handle-request.js", + "./src/app/handle-request.js", + ), + } + + for path, (old, new) in replacements.items(): + text = path.read_text(encoding="utf-8") + if old not in text: + raise SystemExit(f"expected import path not found in {path}") + path.write_text(text.replace(old, new), encoding="utf-8") + PY - name: Initialize functions branch run: |