Skip to content

Commit 6e8b2f6

Browse files
committed
[migrate] upgrade to MobX-Lark 2.8.1, Open-Source-Bazaar/feishu-action@v3 & Vercel CLI 50.x
[migrate] upgrade to Node.js 24, Undici 8, Globals 17, ESLint 10, File-Type 22 & other latest Upstream packages/actions
1 parent 7b4e617 commit 6e8b2f6

9 files changed

Lines changed: 2682 additions & 2802 deletions

File tree

.github/workflows/deploy-production.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
packages: write
2121
contents: read
2222
steps:
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
2424

2525
- name: Inject Environment variables
2626
run: |
@@ -49,7 +49,7 @@ jobs:
4949
mv ${{ env.ARTIFACT_PATH }} ./docker-compose.yml ./start.sh ./build
5050
5151
- name: Transport Image
52-
uses: appleboy/scp-action@v0.1.7
52+
uses: appleboy/scp-action@v1
5353
with:
5454
source: ./build/*.*
5555
target: /tmp/${{ env.BOX_NAME }}

.github/workflows/init-template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
contents: write
1717
actions: write
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v6
2020

2121
- name: transform Repository variables to lower case
2222
run: |
@@ -30,6 +30,6 @@ jobs:
3030
${{ env.REPOSITORY_OWNER }} ${{ env.REPOSITORY_NAME }}
3131
git checkout -- .github/workflows/init-template.yml
3232
33-
- uses: stefanzweifel/git-auto-commit-action@v5
33+
- uses: stefanzweifel/git-auto-commit-action@v7
3434
with:
3535
commit_message: '[fix] replace Repository Name'

.github/workflows/main.yml

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,68 @@ jobs:
1313
permissions:
1414
contents: write
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
1818

19+
- uses: actions/setup-node@v6
20+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
21+
with:
22+
node-version: 24
23+
1924
- name: Deploy to Vercel
2025
id: vercel-deployment
21-
uses: amondnet/vercel-action@v25
2226
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
23-
with:
24-
vercel-token: ${{ secrets.VERCEL_TOKEN }}
25-
github-token: ${{ secrets.GITHUB_TOKEN }}
26-
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
27-
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
28-
working-directory: ./
29-
vercel-args: ${{ github.ref == 'refs/heads/main' && ' --prod' || '' }}
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
31+
npm install vercel -g
32+
33+
if [[ "$GITHUB_REF" == 'refs/heads/main' ]]; then
34+
DeployOutput=$(vercel -t "$VERCEL_TOKEN" --prod)
35+
else
36+
DeployOutput=$(vercel -t "$VERCEL_TOKEN")
37+
fi
38+
echo "$DeployOutput"
39+
40+
ParsedURL=$(echo "$DeployOutput" | grep -Eo 'https://[^[:space:]]*\.vercel\.app' | tail -n 1)
41+
42+
if [[ -z "$ParsedURL" ]]; then
43+
echo "Failed to parse Vercel URL from deploy output"
44+
exit 1
45+
fi
46+
vercel inspect "$ParsedURL" -t "$VERCEL_TOKEN" -F json > vercel-inspect.json
47+
48+
InspectURL=$(jq -r '.url // empty' vercel-inspect.json)
49+
50+
if [[ -z "$InspectURL" ]]; then
51+
echo "Failed to parse inspect url from vercel-inspect.json"
52+
exit 1
53+
fi
54+
if [[ "$InspectURL" != http* ]]; then
55+
InspectURL="https://$InspectURL"
56+
fi
57+
echo "preview-url=$InspectURL" >> "$GITHUB_OUTPUT"
3058
3159
- name: Lark notification
32-
uses: foxundermoon/feishu-action@v2
60+
uses: Open-Source-Bazaar/feishu-action@v3
3361
with:
3462
url: ${{ secrets.LARK_CHATBOT_HOOK_URL }}
35-
msg_type: post
63+
msg_type: interactive
3664
content: |
37-
post:
38-
en_us:
39-
title: "Vercel Preview Environment"
40-
content:
41-
- - tag: text
42-
text: "Git Repository: "
43-
- tag: a
44-
text: ${{ github.server_url }}/${{ github.repository }}
45-
href: ${{ github.server_url }}/${{ github.repository }}
46-
- - tag: text
47-
text: "Code Branch: "
48-
- tag: a
49-
text: ${{ github.ref }}
50-
href: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
51-
- - tag: text
52-
text: "Commit Author: "
53-
- tag: a
54-
text: ${{ github.actor }}
55-
href: ${{ github.server_url }}/${{ github.actor }}
56-
- - tag: text
57-
text: "Preview Link: "
58-
- tag: a
59-
text: ${{ steps.vercel-deployment.outputs.preview-url }}
60-
href: ${{ steps.vercel-deployment.outputs.preview-url }}
65+
schema: "2.0"
66+
config:
67+
wide_screen_mode: true
68+
header:
69+
title:
70+
tag: plain_text
71+
content: Vercel deployment
72+
template: blue
73+
body:
74+
elements:
75+
- tag: markdown
76+
content: |
77+
- **Git Repository**: [${{ github.server_url }}/${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})
78+
- **Code Branch**: [${{ github.ref }}](${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }})
79+
- **Commit Author**: [${{ github.actor }}](${{ github.server_url }}/${{ github.actor }})
80+
- **Preview Link**: [${{ steps.vercel-deployment.outputs.preview-url }}](${{ steps.vercel-deployment.outputs.preview-url }})

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
"redhat.vscode-yaml",
88
"clinyong.vscode-css-modules",
99
"akamud.vscode-caniuse",
10-
"visualstudioexptteam.intellicode-api-usage-examples",
1110
"pflannery.vscode-versionlens",
1211
"christian-kohler.npm-intellisense",
1312
"esbenp.prettier-vscode",
1413
"rangav.vscode-thunder-client",
1514
"eamodio.gitlens",
1615
"github.vscode-pull-request-github",
1716
"github.vscode-github-actions",
18-
"GitHub.copilot"
17+
"GitHub.copilot-chat"
1918
]
2019
}

package.json

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"@editorjs/code": "^2.9.4",
11-
"@editorjs/editorjs": "^2.31.0",
11+
"@editorjs/editorjs": "^2.31.5",
1212
"@editorjs/header": "^2.8.8",
1313
"@editorjs/image": "^2.10.3",
1414
"@editorjs/link": "^2.6.2",
@@ -17,79 +17,79 @@
1717
"@editorjs/quote": "^2.7.6",
1818
"@mdx-js/loader": "^3.1.1",
1919
"@mdx-js/react": "^3.1.1",
20-
"@next/mdx": "^16.1.1",
21-
"@sentry/nextjs": "^10.32.1",
22-
"copy-webpack-plugin": "^13.0.1",
23-
"core-js": "^3.47.0",
20+
"@next/mdx": "^16.2.2",
21+
"@sentry/nextjs": "^10.47.0",
22+
"copy-webpack-plugin": "^14.0.0",
23+
"core-js": "^3.49.0",
2424
"editorjs-html": "^4.0.5",
25-
"file-type": "^21.2.0",
25+
"file-type": "^22.0.0",
2626
"formidable": "^3.5.4",
2727
"idea-react": "^2.0.0-rc.13",
2828
"jsonwebtoken": "^9.0.3",
29-
"koa": "^3.1.1",
29+
"koa": "^3.2.0",
3030
"koa-jwt": "^4.0.4",
31-
"koajax": "^3.1.2",
32-
"less": "^4.5.1",
33-
"less-loader": "^12.3.0",
34-
"lodash": "^4.17.21",
35-
"marked": "^17.0.1",
31+
"koajax": "^3.3.0",
32+
"less": "^4.6.4",
33+
"less-loader": "^12.3.2",
34+
"lodash": "^4.18.1",
35+
"marked": "^17.0.6",
3636
"mime": "^4.1.0",
3737
"mobx": "^6.15.0",
3838
"mobx-github": "^0.6.2",
3939
"mobx-i18n": "^0.7.2",
40-
"mobx-lark": "^2.6.0",
40+
"mobx-lark": "^2.8.1",
4141
"mobx-react": "^9.2.1",
4242
"mobx-react-helper": "^0.5.1",
4343
"mobx-restful": "^2.1.4",
4444
"mobx-restful-table": "^2.6.3",
45-
"next": "^16.1.1",
45+
"next": "^16.2.2",
4646
"next-pwa": "~5.6.0",
4747
"next-ssr-middleware": "^1.1.0",
4848
"next-with-less": "^3.0.1",
4949
"prismjs": "^1.30.0",
50-
"react": "^19.2.3",
50+
"react": "^19.2.4",
5151
"react-bootstrap": "^2.10.10",
5252
"react-bootstrap-editor": "^2.1.1",
53-
"react-dom": "^19.2.3",
53+
"react-dom": "^19.2.4",
5454
"react-editor-js": "^2.1.0",
5555
"remark-frontmatter": "^5.0.0",
5656
"remark-gfm": "^4.0.1",
5757
"remark-mdx-frontmatter": "^5.2.0",
58-
"undici": "^7.16.0",
59-
"web-utility": "^4.6.4",
60-
"webpack": "^5.104.1",
61-
"yaml": "^2.8.2"
58+
"undici": "^8.0.2",
59+
"web-utility": "^4.6.5",
60+
"webpack": "^5.105.4",
61+
"yaml": "^2.8.3"
6262
},
6363
"devDependencies": {
64-
"@babel/plugin-proposal-decorators": "^7.28.0",
65-
"@babel/plugin-transform-typescript": "^7.28.5",
64+
"@babel/plugin-proposal-decorators": "^7.29.0",
65+
"@babel/plugin-transform-typescript": "^7.28.6",
6666
"@babel/preset-react": "^7.28.5",
67-
"@cspell/eslint-plugin": "^9.4.0",
68-
"@eslint/js": "^9.39.2",
69-
"@next/eslint-plugin-next": "^16.1.1",
67+
"@cspell/eslint-plugin": "^10.0.0",
68+
"@eslint/js": "^10.0.1",
69+
"@next/eslint-plugin-next": "^16.2.2",
7070
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
71-
"@stylistic/eslint-plugin": "^5.6.1",
71+
"@stylistic/eslint-plugin": "^5.10.0",
7272
"@types/eslint-config-prettier": "^6.11.3",
73-
"@types/formidable": "^3.4.6",
73+
"@types/formidable": "^3.5.0",
7474
"@types/jsonwebtoken": "^9.0.10",
75-
"@types/koa": "^3.0.1",
76-
"@types/lodash": "^4.17.21",
75+
"@types/koa": "^3.0.2",
76+
"@types/lodash": "^4.17.24",
7777
"@types/next-pwa": "^5.6.9",
78-
"@types/node": "^22.19.3",
79-
"@types/react": "^19.2.7",
80-
"eslint": "^9.39.2",
81-
"eslint-config-next": "^16.1.1",
78+
"@types/node": "^24.12.2",
79+
"@types/react": "^19.2.14",
80+
"eslint": "^10.2.0",
81+
"eslint-config-next": "^16.2.2",
8282
"eslint-config-prettier": "^10.1.8",
8383
"eslint-plugin-react": "^7.37.5",
8484
"eslint-plugin-simple-import-sort": "^12.1.1",
85-
"globals": "^16.5.0",
85+
"globals": "^17.4.0",
8686
"husky": "^9.1.7",
8787
"jiti": "^2.6.1",
88-
"lint-staged": "^16.2.7",
89-
"prettier": "^3.7.4",
90-
"prettier-plugin-css-order": "^2.1.2",
88+
"lint-staged": "^16.4.0",
89+
"prettier": "^3.8.1",
90+
"prettier-plugin-css-order": "^2.2.0",
9191
"typescript": "~5.9.3",
92-
"typescript-eslint": "^8.50.1"
92+
"typescript-eslint": "^8.58.0"
9393
},
9494
"resolutions": {
9595
"next": "$next"
Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,6 @@
1-
import { Context } from 'koa';
2-
import { LarkPageData, TableRecord, TableRecordData } from 'mobx-lark';
3-
import { DataObject } from 'mobx-restful';
4-
import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware';
5-
6-
import { safeAPI } from '../../../core';
7-
import { proxyLark, proxyLarkAll } from '../../core';
1+
import { withSafeKoa } from '../../../core';
2+
import { proxyLarkAll } from '../../core';
83

94
export const config = { api: { bodyParser: false } };
105

11-
const router = createKoaRouter(import.meta.url);
12-
13-
function filterData(fields: DataObject) {
14-
for (const key of Object.keys(fields))
15-
if (!/^\w+$/.test(key)) delete fields[key];
16-
}
17-
18-
router.get(
19-
'/apps/:app/tables/:table/records/:record',
20-
safeAPI,
21-
async (context: Context) => {
22-
const { status, body } =
23-
await proxyLark<TableRecordData<DataObject>>(context);
24-
25-
const { fields } = body!.data!.record;
26-
27-
filterData(fields);
28-
29-
context.status = status;
30-
context.body = body;
31-
},
32-
);
33-
34-
router.get(
35-
'/apps/:app/tables/:table/records',
36-
safeAPI,
37-
async (context: Context) => {
38-
const { status, body } =
39-
await proxyLark<LarkPageData<TableRecord<DataObject>>>(context);
40-
41-
const list = body!.data!.items || [];
42-
43-
for (const { fields } of list) filterData(fields);
44-
45-
context.status = status;
46-
context.body = body;
47-
},
48-
);
49-
50-
router.all('/(.*)', safeAPI, proxyLarkAll);
51-
52-
export default withKoaRouter(router);
6+
export default withSafeKoa(proxyLarkAll);

pages/api/Lark/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const normalizeMarkdownArray = (list: TableCellText[]) =>
1818
export const proxyLark = async <T extends LarkData>({
1919
method,
2020
url,
21-
headers: { host, authorization, ...headers },
21+
headers: { host, authorization, 'content-length': _, ...headers },
2222
request,
2323
}: Context) => {
2424
await lark.getAccessToken();
Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Context } from 'koa';
2+
import { LarkDocumentPathType } from 'mobx-lark';
23
import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware';
34

45
import { safeAPI, verifyJWT } from '../../../core';
@@ -10,13 +11,33 @@ const router = createKoaRouter(import.meta.url);
1011

1112
router.post('/:type/:id', safeAPI, verifyJWT, async (context: Context) => {
1213
const { type, id } = context.params,
13-
{ name, parentToken } = Reflect.get(context.request, 'body');
14+
{ name, parentToken, ownerType, ownerId } = Reflect.get(
15+
context.request,
16+
'body',
17+
);
1418

15-
context.body = await lark.copyFile(
16-
`${type as 'wiki'}/${id}`,
17-
name,
18-
parentToken,
19-
);
19+
const copiedFile =
20+
type === 'wiki'
21+
? await lark.copyFile(`${type as 'wiki'}/${id}`, name, parentToken)
22+
: await lark.copyFile(
23+
`${type as LarkDocumentPathType}/${id}`,
24+
name,
25+
parentToken,
26+
);
27+
28+
const newId =
29+
'token' in copiedFile ? copiedFile.token : copiedFile.node_token;
30+
31+
if (ownerType && ownerId)
32+
try {
33+
await lark.driveFileStore.transferOwner(type, newId, {
34+
member_type: ownerType,
35+
member_id: ownerId,
36+
});
37+
} catch (error) {
38+
console.error(JSON.stringify(error, null, 2));
39+
}
40+
context.body = copiedFile;
2041
});
2142

2243
export default withKoaRouter(router);

0 commit comments

Comments
 (0)