fix(ci): repair converted deployment adapters
This commit is contained in:
1 parent
24cb47488b
commit
c678764c11
2 files changed
+35
-8
No files matched your search
@@ -60,4 +60,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
wranglerVersion: "4.76.0"
|
||||||
command: pages deploy . --project-name=xget --branch=${{ github.ref_name }}
|
command: pages deploy . --project-name=xget --branch=${{ github.ref_name }}
|
||||||
@@ -45,12 +45,21 @@ jobs:
|
|||||||
cp package-lock.json /tmp/pages-conversion/ 2>/dev/null || true
|
cp package-lock.json /tmp/pages-conversion/ 2>/dev/null || true
|
||||||
cp LICENSE /tmp/pages-conversion/
|
cp LICENSE /tmp/pages-conversion/
|
||||||
|
|
||||||
- name: Export handleRequest from src/index.js
|
- name: Rewrite Pages adapter imports for converted layout
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/pages-conversion
|
cd /tmp/pages-conversion
|
||||||
# Add export statement before the default export at the end of the file
|
python3 - <<'PY'
|
||||||
sed -i '/^export default {$/i\
|
from pathlib import Path
|
||||||
export { handleRequest };' src/index.js
|
|
||||||
|
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
|
- name: Update package.json for Pages
|
||||||
run: |
|
run: |
|
||||||
@@ -120,12 +129,29 @@ jobs:
|
|||||||
cp package-lock.json /tmp/functions-conversion/ 2>/dev/null || true
|
cp package-lock.json /tmp/functions-conversion/ 2>/dev/null || true
|
||||||
cp LICENSE /tmp/functions-conversion/
|
cp LICENSE /tmp/functions-conversion/
|
||||||
|
|
||||||
- name: Export handleRequest from src/index.js
|
- name: Rewrite Functions adapter imports for converted layout
|
||||||
run: |
|
run: |
|
||||||
cd /tmp/functions-conversion
|
cd /tmp/functions-conversion
|
||||||
# Add export statement before the default export at the end of the file
|
python3 - <<'PY'
|
||||||
sed -i '/^export default {$/i\
|
from pathlib import Path
|
||||||
export { handleRequest };' src/index.js
|
|
||||||
|
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
|
- name: Initialize functions branch
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in new issue
Block a user