Commit f4e09007 by Ryo Committed by GitHub

chore: upgrade lint toolchain (#6901)

* fix: build docs

* fix: deps
parent dffae73d
...@@ -109,6 +109,9 @@ jobs: ...@@ -109,6 +109,9 @@ jobs:
username: ${{ secrets.FASTGPT_ALI_IMAGE_USER }} username: ${{ secrets.FASTGPT_ALI_IMAGE_USER }}
password: ${{ secrets.FASTGPT_ALI_IMAGE_PSW }} password: ${{ secrets.FASTGPT_ALI_IMAGE_PSW }}
- name: Prepare Docker workspace catalog
run: cp pnpm-workspace.yaml document/pnpm-workspace.yaml
- name: Build and push Docker images (CN) - name: Build and push Docker images (CN)
if: matrix.domain_config.suffix == 'cn' if: matrix.domain_config.suffix == 'cn'
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
......
...@@ -28,6 +28,9 @@ jobs: ...@@ -28,6 +28,9 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Prepare Docker workspace catalog
run: cp pnpm-workspace.yaml document/pnpm-workspace.yaml
- name: Build Docker image (no push) - name: Build Docker image (no push)
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
......
content/**/*.en.mdx
{
"plugins": ["mdx"],
"rules": {
"preset-zh-technical-writing": true
}
}
...@@ -70,7 +70,8 @@ FILE_TOKEN_KEY= ...@@ -70,7 +70,8 @@ FILE_TOKEN_KEY=
## 代码优化 ## 代码优化
1. 重新调整代码结构,升级 nextjs 最新版,切换至 turbopack 构建,提高构建速度;升级容器默认 node 至 24。 1. 重新调整代码结构,升级 Next.js 最新版,切换至 Turbopack 构建,提高构建速度;升级容器默认 Node.js 至 24。
2. 优化 Agent tool 声明和运行,统一所有 tool 的声明和运行方式。 2. 优化 Agent tool 声明和运行,统一所有 tool 的声明和运行方式。
3. 文件上传内容从 system prompt 中放到 user message 中,提高 cache 命中率。 3. 文件上传内容从 system prompt 中放到 user message 中,提高 cache 命中率。
4. 服务端 env 加载全部使用`@t3-oss/env-core`,增加更多类型检查。其余服务,也采用集中导出 env 的方式进行环境变量使用。 4. 服务端 env 加载全部使用 `@t3-oss/env-core`,增加更多类型检查。其余服务,也采用集中导出 env 的方式进行环境变量使用。
5. 升级了项目工程化工具链版本,包括 ESLint、Prettier、textlint 和 lint-staged 工具。
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
"dev": "next dev --turbo", "dev": "next dev --turbo",
"start": "next start", "start": "next start",
"postinstall": "fumadocs-mdx", "postinstall": "fumadocs-mdx",
"format-doc": "pnpx zhlint --dir ./ *.mdx --fix", "format-doc": "pnpm exec textlint --fix \"content/**/*.mdx\" && pnpm exec prettier --config ../.prettierrc.js --write \"**/*.mdx\" && pnpm exec textlint \"content/**/*.mdx\"",
"lint-doc:text": "pnpm exec textlint \"content/**/*.mdx\"",
"initDocTime": "node ./script/initDocTime.js", "initDocTime": "node ./script/initDocTime.js",
"initDocToc": "node ./script/generateToc.js", "initDocToc": "node ./script/generateToc.js",
"checkDocRefs": "node ./script/checkDocRefs.js", "checkDocRefs": "node ./script/checkDocRefs.js",
...@@ -47,8 +48,10 @@ ...@@ -47,8 +48,10 @@
"@types/react-dom": "^19.1.6", "@types/react-dom": "^19.1.6",
"postcss": "^8.5.10", "postcss": "^8.5.10",
"tailwindcss": "^4.1.11", "tailwindcss": "^4.1.11",
"textlint": "catalog:lint",
"textlint-plugin-mdx": "catalog:lint",
"textlint-rule-preset-zh-technical-writing": "catalog:lint",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"zhlint": "^0.8.2",
"zod": "^4.0.5" "zod": "^4.0.5"
} }
} }
...@@ -3,6 +3,30 @@ import path from 'node:path'; ...@@ -3,6 +3,30 @@ import path from 'node:path';
const quoteFiles = (files) => const quoteFiles = (files) =>
files.map((file) => JSON.stringify(path.relative(process.cwd(), file))).join(' '); files.map((file) => JSON.stringify(path.relative(process.cwd(), file))).join(' ');
const toAbsolutePath = (file) => (path.isAbsolute(file) ? file : path.resolve(process.cwd(), file));
const quoteDocumentFiles = (files) =>
files
.map((file) =>
JSON.stringify(path.relative(path.join(process.cwd(), 'document'), toAbsolutePath(file)))
)
.join(' ');
const quoteDocumentArtifactPaths = () =>
[
'document/data/doc-last-modified.json',
'document/content/toc.mdx',
'document/content/toc.en.mdx'
]
.map((file) => JSON.stringify(file))
.join(' ');
const withoutTranslatedDocumentFiles = (files) =>
files.filter((file) => {
const documentPath = path.relative(path.join(process.cwd(), 'document'), toAbsolutePath(file));
return !/\.[a-z]{2}\.mdx$/.test(documentPath);
});
const withoutIgnoredPaths = (files) => const withoutIgnoredPaths = (files) =>
files.filter((file) => { files.filter((file) => {
const relativePath = path.relative(process.cwd(), file); const relativePath = path.relative(process.cwd(), file);
...@@ -17,17 +41,29 @@ const withoutIgnoredPaths = (files) => ...@@ -17,17 +41,29 @@ const withoutIgnoredPaths = (files) =>
}); });
export default { export default {
'./document/**/**/*.mdx': (files) => './document/**/**/*.mdx': (files) => {
files.length === 0 if (files.length === 0) return [];
? []
: [ const filenames = quoteDocumentFiles(files);
'pnpm -C ./document run format-doc', const textlintFiles = withoutTranslatedDocumentFiles(files);
const textlintFilenames = quoteDocumentFiles(textlintFiles);
return [
...(textlintFiles.length > 0
? [`pnpm -C ./document exec textlint --fix ${textlintFilenames}`]
: []),
`pnpm -C ./document exec prettier --config ../.prettierrc.js --write ${filenames}`,
...(textlintFiles.length > 0
? [`pnpm -C ./document exec textlint ${textlintFilenames}`]
: []),
'pnpm -C ./document run initDocTime', 'pnpm -C ./document run initDocTime',
'pnpm -C ./document run initDocToc', 'pnpm -C ./document run initDocToc',
'pnpm -C ./document run checkDocRefs', 'pnpm -C ./document run checkDocRefs',
'pnpm -C ./document run removeInvalidImg', 'pnpm -C ./document run removeInvalidImg',
'git add .' `git add -- ${quoteDocumentArtifactPaths()}`,
], 'git add -u -- document/public/imgs'
];
},
'**/*.{ts,tsx}': (files) => { '**/*.{ts,tsx}': (files) => {
const lintFiles = withoutIgnoredPaths(files); const lintFiles = withoutIgnoredPaths(files);
if (lintFiles.length === 0) return []; if (lintFiles.length === 0) return [];
......
...@@ -28,18 +28,18 @@ ...@@ -28,18 +28,18 @@
"devDependencies": { "devDependencies": {
"@chakra-ui/cli": "^2.4.1", "@chakra-ui/cli": "^2.4.1",
"@vitest/coverage-v8": "catalog:", "@vitest/coverage-v8": "catalog:",
"eslint": "catalog:eslint", "eslint": "catalog:lint",
"eslint-config-next": "catalog:eslint", "eslint-config-next": "catalog:lint",
"husky": "^8.0.3", "husky": "^8.0.3",
"i18next": "catalog:", "i18next": "catalog:",
"js-yaml": "catalog:", "js-yaml": "catalog:",
"lint-staged": "catalog:", "lint-staged": "catalog:lint",
"mongodb-memory-server": "catalog:", "mongodb-memory-server": "catalog:",
"next-i18next": "catalog:", "next-i18next": "catalog:",
"prettier": "catalog:", "prettier": "catalog:lint",
"react-i18next": "catalog:", "react-i18next": "catalog:",
"turbo": "2.9.9", "turbo": "2.9.9",
"typescript-eslint": "catalog:eslint", "typescript-eslint": "catalog:lint",
"typescript": "catalog:", "typescript": "catalog:",
"vitest": "catalog:" "vitest": "catalog:"
}, },
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -50,7 +50,6 @@ catalog: ...@@ -50,7 +50,6 @@ catalog:
js-yaml: ^4.1.1 js-yaml: ^4.1.1
jsonwebtoken: ^9.0.3 jsonwebtoken: ^9.0.3
json5: ^2.2.3 json5: ^2.2.3
lint-staged: ^16.4.0
lodash: 4.17.23 lodash: 4.17.23
mime: ^4.1.0 mime: ^4.1.0
mime-types: 3.0.2 mime-types: 3.0.2
...@@ -60,7 +59,6 @@ catalog: ...@@ -60,7 +59,6 @@ catalog:
nanoid: ^5.1.3 nanoid: ^5.1.3
next: 16.2.4 next: 16.2.4
next-i18next: 15.4.2 next-i18next: 15.4.2
prettier: 3.8.3
proxy-addr: 2.0.7 proxy-addr: 2.0.7
proxy-agent: ^6 proxy-agent: ^6
react: ^18 react: ^18
...@@ -78,9 +76,14 @@ catalog: ...@@ -78,9 +76,14 @@ catalog:
zod: ^4 zod: ^4
catalogs: catalogs:
eslint: lint:
eslint: ^9 eslint: ^9
eslint-config-next: 16.2.4 eslint-config-next: 16.2.4
lint-staged: ^16.4.0
prettier: 3.8.3
textlint: 12.6.1
textlint-plugin-mdx: ^1.1.0
textlint-rule-preset-zh-technical-writing: ^0.0.3
typescript-eslint: ^8 typescript-eslint: ^8
onlyBuiltDependencies: onlyBuiltDependencies:
......
Subproject commit 958c6c7b27f6e3b8d04213b60e41d7ac75a605c7 Subproject commit 26ee89803dc551ad77bd34ac8fdfd6103c1b626c
...@@ -113,11 +113,11 @@ ...@@ -113,11 +113,11 @@
"@types/react": "catalog:", "@types/react": "catalog:",
"@types/react-dom": "catalog:", "@types/react-dom": "catalog:",
"@types/react-syntax-highlighter": "^15.5.6", "@types/react-syntax-highlighter": "^15.5.6",
"eslint": "catalog:eslint", "eslint": "catalog:lint",
"eslint-config-next": "catalog:eslint", "eslint-config-next": "catalog:lint",
"tailwindcss": "^3", "tailwindcss": "^3",
"tsx": "catalog:", "tsx": "catalog:",
"typescript-eslint": "catalog:eslint", "typescript-eslint": "catalog:lint",
"typescript": "catalog:", "typescript": "catalog:",
"vitest": "catalog:" "vitest": "catalog:"
} }
......
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
"@types/node": "catalog:", "@types/node": "catalog:",
"@types/react": "catalog:", "@types/react": "catalog:",
"@types/react-dom": "catalog:", "@types/react-dom": "catalog:",
"eslint": "catalog:eslint", "eslint": "catalog:lint",
"eslint-config-next": "catalog:eslint", "eslint-config-next": "catalog:lint",
"postcss": "^8", "postcss": "^8",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",
"typescript": "catalog:" "typescript": "catalog:"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment