Skip to content

Commit 5c58fd8

Browse files
authored
[migrate] upgrade to Next.js 16, MobX-GitHub 0.6 & other latest Upstream packages (#10)
1 parent 0ba4561 commit 5c58fd8

File tree

11 files changed

+2135
-2138
lines changed

11 files changed

+2135
-2138
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ pnpm container
111111

112112
1. create & configure your own `CACHE_REPOSITORY` with https://github.com/idea2app/Web-file-cache
113113
2. set the `NEXT_PUBLIC_CACHE_HOST` environment variable to your CDN URL
114-
3. start your Lark-Next.js service, then copy the Crawler JWT from CLI console
115-
4. create an Automation Flow in your Lark BI Table to watch Attachment fields changing, then send an HTTP `POST` request to `https://your.next.js/api/file/crawler/task` with the Crawler JWT in the `Authorization` header
116-
5. your Lark file attachments will be cached in your CDN and loaded by your Lark-Next.js service automatically
114+
3. create an Automation Flow in your Lark BI Table to watch Attachment fields changing, then send an HTTP `POST` request to `https://api.github.com/repos/your-namespace/Web-file-cache/actions/workflows/crawler.yml/dispatches` with:
115+
1. the [GitHub PAT][35] in the `Authorization` header
116+
2. `https://your.next.js/api/Lark/file/attachment-id/file-name` as `url` body parameter
117+
4. your Lark file attachments will be cached in your CDN and loaded by your Lark-Next.js service automatically
117118

118119
[0]: https://www.larksuite.com/
119120
[1]: https://react.dev/
@@ -150,3 +151,4 @@ pnpm container
150151
[32]: https://open.larksuite.com/document/server-docs/getting-started/api-access-token/app-access-token-development-guide#1f8b587c
151152
[33]: https://github.com/idea2app/Web-file-cache?tab=readme-ov-file
152153
[34]: https://nextjs.org/docs/deployment
154+
[35]: https://github.com/settings/tokens

eslint.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export default tsEslint.config(
5252
warnOnUnsupportedTypeScriptVersion: false,
5353
},
5454
},
55-
// @ts-expect-error https://github.com/vercel/next.js/issues/81695
5655
rules: {
5756
// spellchecker
5857
'@cspell/spellchecker': [

models/Translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
22
loadLanguageMapFrom,
3-
parseCookie,
43
TranslationMap,
54
TranslationModel,
65
} from 'mobx-i18n';
76
import { DataObject } from 'mobx-restful';
87
import { NextPageContext } from 'next';
98
import { createContext } from 'react';
9+
import { parseCookie } from 'web-utility';
1010

1111
import zhCN from '../translation/zh-CN';
1212

models/configuration.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export const API_Host = isServer()
1313
: 'http://localhost:3000'
1414
: globalThis.location.origin;
1515

16-
export const CACHE_HOST = process.env.NEXT_PUBLIC_CACHE_HOST!,
17-
CrawlerEmail = `[email protected]`;
16+
export const CACHE_HOST = process.env.NEXT_PUBLIC_CACHE_HOST!;
1817

1918
export const LARK_API_HOST = `${API_Host}/api/Lark/`;
2019

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
/// <reference path="./.next/types/routes.d.ts" />
3+
import './.next/dev/types/routes.d.ts';
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

package.json

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"@editorjs/code": "^2.9.3",
11-
"@editorjs/editorjs": "^2.30.8",
11+
"@editorjs/editorjs": "^2.31.0",
1212
"@editorjs/header": "^2.8.8",
1313
"@editorjs/image": "^2.10.3",
1414
"@editorjs/link": "^2.6.2",
@@ -17,82 +17,82 @@
1717
"@editorjs/quote": "^2.7.6",
1818
"@mdx-js/loader": "^3.1.1",
1919
"@mdx-js/react": "^3.1.1",
20-
"@next/mdx": "^15.5.2",
21-
"@sentry/nextjs": "^10.9.0",
20+
"@next/mdx": "^16.0.1",
21+
"@sentry/nextjs": "^10.22.0",
2222
"copy-webpack-plugin": "^13.0.1",
23-
"core-js": "^3.45.1",
23+
"core-js": "^3.46.0",
2424
"editorjs-html": "^4.0.5",
2525
"file-type": "^21.0.0",
2626
"formidable": "^3.5.4",
2727
"idea-react": "^2.0.0-rc.13",
2828
"jsonwebtoken": "^9.0.2",
29-
"koa": "^3.0.1",
29+
"koa": "^3.1.1",
3030
"koa-jwt": "^4.0.4",
3131
"koajax": "^3.1.2",
32-
"less": "^4.4.1",
32+
"less": "^4.4.2",
3333
"less-loader": "^12.3.0",
3434
"lodash": "^4.17.21",
35-
"marked": "^16.2.1",
36-
"mime": "^4.0.7",
37-
"mobx": "^6.13.7",
38-
"mobx-github": "^0.4.0",
39-
"mobx-i18n": "^0.7.1",
40-
"mobx-lark": "^2.4.1",
41-
"mobx-react": "^9.2.0",
35+
"marked": "^16.4.1",
36+
"mime": "^4.1.0",
37+
"mobx": "^6.15.0",
38+
"mobx-github": "^0.6.2",
39+
"mobx-i18n": "^0.7.2",
40+
"mobx-lark": "^2.5.0",
41+
"mobx-react": "^9.2.1",
4242
"mobx-react-helper": "^0.5.1",
43-
"mobx-restful": "^2.1.0",
44-
"mobx-restful-table": "^2.5.3",
45-
"next": "^15.5.2",
43+
"mobx-restful": "^2.1.4",
44+
"mobx-restful-table": "^2.5.5",
45+
"next": "^16.0.1",
4646
"next-pwa": "~5.6.0",
4747
"next-ssr-middleware": "^1.0.3",
4848
"next-with-less": "^3.0.1",
4949
"prismjs": "^1.30.0",
50-
"react": "^19.1.1",
50+
"react": "^19.2.0",
5151
"react-bootstrap": "^2.10.10",
5252
"react-bootstrap-editor": "^2.1.1",
53-
"react-dom": "^19.1.1",
53+
"react-dom": "^19.2.0",
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.15.0",
59-
"web-utility": "^4.5.3",
60-
"webpack": "^5.101.3",
58+
"undici": "^7.16.0",
59+
"web-utility": "^4.6.4",
60+
"webpack": "^5.102.1",
6161
"yaml": "^2.8.1"
6262
},
6363
"devDependencies": {
6464
"@babel/plugin-proposal-decorators": "^7.28.0",
65-
"@babel/plugin-transform-typescript": "^7.28.0",
66-
"@babel/preset-react": "^7.27.1",
67-
"@cspell/eslint-plugin": "^9.2.1",
68-
"@eslint/compat": "^1.3.2",
65+
"@babel/plugin-transform-typescript": "^7.28.5",
66+
"@babel/preset-react": "^7.28.5",
67+
"@cspell/eslint-plugin": "^9.2.2",
68+
"@eslint/compat": "^1.4.1",
6969
"@eslint/eslintrc": "^3.3.1",
70-
"@eslint/js": "^9.34.0",
71-
"@next/eslint-plugin-next": "^15.5.2",
70+
"@eslint/js": "^9.39.0",
71+
"@next/eslint-plugin-next": "^16.0.1",
7272
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
73-
"@stylistic/eslint-plugin": "^5.3.1",
73+
"@stylistic/eslint-plugin": "^5.5.0",
7474
"@types/eslint-config-prettier": "^6.11.3",
75-
"@types/formidable": "^3.4.5",
75+
"@types/formidable": "^3.4.6",
7676
"@types/jsonwebtoken": "^9.0.10",
77-
"@types/koa": "^3.0.0",
78-
"@types/koa__router": "^12.0.4",
77+
"@types/koa": "^3.0.1",
78+
"@types/koa__router": "^12.0.5",
7979
"@types/lodash": "^4.17.20",
8080
"@types/next-pwa": "^5.6.9",
81-
"@types/node": "^22.18.0",
82-
"@types/react": "^19.1.12",
83-
"eslint": "^9.34.0",
84-
"eslint-config-next": "^15.5.2",
81+
"@types/node": "^22.18.13",
82+
"@types/react": "^19.2.2",
83+
"eslint": "^9.39.0",
84+
"eslint-config-next": "^16.0.1",
8585
"eslint-config-prettier": "^10.1.8",
8686
"eslint-plugin-react": "^7.37.5",
8787
"eslint-plugin-simple-import-sort": "^12.1.1",
88-
"globals": "^16.3.0",
88+
"globals": "^16.4.0",
8989
"husky": "^9.1.7",
90-
"jiti": "^2.5.1",
91-
"lint-staged": "^16.1.6",
90+
"jiti": "^2.6.1",
91+
"lint-staged": "^16.2.6",
9292
"prettier": "^3.6.2",
9393
"prettier-plugin-css-order": "^2.1.2",
94-
"typescript": "~5.9.2",
95-
"typescript-eslint": "^8.42.0"
94+
"typescript": "~5.9.3",
95+
"typescript-eslint": "^8.46.2"
9696
},
9797
"resolutions": {
9898
"next": "$next"
@@ -120,11 +120,10 @@
120120
},
121121
"scripts": {
122122
"prepare": "husky",
123-
"dev": "next dev",
124-
"build": "next build",
123+
"dev": "next dev --webpack",
124+
"build": "next build --webpack",
125125
"start": "next start",
126-
"lint": "next lint --fix && git add . && tsc --noEmit",
127-
"test": "lint-staged && npm run lint",
126+
"test": "lint-staged && tsc --noEmit",
128127
"pack-image": "docker build -t idea2app/lark-next-bootstrap-ts:latest .",
129128
"container": "docker rm -f lark-next-bootstrap-ts && docker run --name lark-next-bootstrap-ts -p 3000:3000 -d idea2app/lark-next-bootstrap-ts:latest"
130129
}

pages/api/core.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { KoaOption, withKoa } from 'next-ssr-middleware';
99
import { ProxyAgent, setGlobalDispatcher } from 'undici';
1010
import { parse } from 'yaml';
1111

12-
import { CrawlerEmail, JWT_SECRET } from '../../models/configuration';
12+
import { JWT_SECRET } from '../../models/configuration';
1313

1414
const { HTTP_PROXY } = process.env;
1515

@@ -25,9 +25,6 @@ export const parseJWT = JWT({
2525
passthrough: true,
2626
});
2727

28-
if (JWT_SECRET)
29-
console.info('🔑 [Crawler JWT]', sign({ email: CrawlerEmail }, JWT_SECRET));
30-
3128
export const safeAPI: Middleware<any, any> = async (context: Context, next) => {
3229
try {
3330
return await next();

pages/api/file/crawler/task.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const HomePage = observer(() => {
3030
</code>
3131
</p>
3232

33-
<Row className="g-4" xs={1} sm={2} md={4}>
33+
<Row className="g-4" xs={1} md={2} lg={4}>
3434
{mainNav(i18n).map(({ link, title, summary }) => (
3535
<Col key={link}>
3636
<Card
@@ -52,7 +52,7 @@ const HomePage = observer(() => {
5252

5353
<h2 className="my-4 text-center">{t('upstream_projects')}</h2>
5454

55-
<Row className="g-4" xs={1} sm={2} md={3}>
55+
<Row className="g-4" xs={1} md={2} lg={3}>
5656
{framework.map(
5757
({ title, languages, tags, summary, link, repository }) => (
5858
<Col key={title}>

0 commit comments

Comments
 (0)