From dcb6f69f2151f7579ae8b5b0d99bcb81de232b2f Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Thu, 2 Dec 2021 14:03:06 +0800 Subject: [PATCH] :bug: fix build and ci bug --- .github/workflows/release-plugin-docs.yml | 14 ++++- .github/workflows/release.yml | 19 ++++++- .github/workflows/website-deploy.yml | 24 +++++++- package.json | 2 + website/docs/guide/mirai-guide.md | 18 +++--- website/docusaurus.config.js | 11 +++- yarn.lock | 67 +++++++++++++++++++++-- 7 files changed, 134 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release-plugin-docs.yml b/.github/workflows/release-plugin-docs.yml index 518804b2..a575c7e2 100644 --- a/.github/workflows/release-plugin-docs.yml +++ b/.github/workflows/release-plugin-docs.yml @@ -14,7 +14,17 @@ jobs: - name: Setup Node uses: actions/setup-node@v1 with: - node-version: '16' + node-version: "16" + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache Packages + uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - name: Set up Python uses: actions/setup-python@v2 @@ -27,7 +37,7 @@ jobs: - name: Build Docs run: | yarn install - yarn build:plugin --out-dir ./packages/nonebot-plugin-docs/nonebot_plugin_docs/dist + yarn build:plugin --out-dir ../packages/nonebot-plugin-docs/nonebot_plugin_docs/dist - name: Publish Package run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3fd39030..c8f20111 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,21 @@ jobs: path: ~/.cache/pypoetry/virtualenvs key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: "16" + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - name: Cache Packages + uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + - name: Set up dependencies run: | poetry install -E all @@ -36,7 +51,9 @@ jobs: run: cp -r ./build/markdown/* ./website/docs/api/ - name: Archive Files - run: yarn archive $(poetry version -s) + run: | + yarn install + yarn archive $(poetry version -s) - name: Push Tag and Release to PyPI run: | diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml index f77013bf..2d3a6d34 100644 --- a/.github/workflows/website-deploy.yml +++ b/.github/workflows/website-deploy.yml @@ -17,6 +17,24 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + architecture: "x64" + + - uses: Gr1N/setup-poetry@v4 + + - uses: actions/cache@v1 + with: + path: ~/.cache/pypoetry/virtualenvs + key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: "16" + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -26,11 +44,13 @@ jobs: with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + run: cp -r ./build/markdown/* ./website/docs/api/ - name: Install and build run: | + poetry install -E all + poetry run sphinx-build -M markdown ./docs_build ./build + cp -r ./build/markdown/* ./website/docs/api/ yarn install yarn build diff --git a/package.json b/package.json index c6635c8b..fe45c517 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,11 @@ "build": "yarn workspace nonebot build", "build:plugin": "cross-env BASE_URL='/docs/' yarn workspace nonebot build", "start": "yarn workspace nonebot start", + "clear": "yarn workspace nonebot clear", "prettier": "prettier --config ./.prettierrc --write \"./website/**/*.md\"" }, "devDependencies": { + "cross-env": "^7.0.3", "prettier": "^2.5.0" }, "dependencies": { diff --git a/website/docs/guide/mirai-guide.md b/website/docs/guide/mirai-guide.md index 60b72a35..b4e050f7 100644 --- a/website/docs/guide/mirai-guide.md +++ b/website/docs/guide/mirai-guide.md @@ -1,6 +1,6 @@ # Mirai-API-HTTP 协议使用指南 -::: warning +:::warning Mirai-API-HTTP 的适配现在仍然处于早期阶段, 可能没有进行过充分的测试 @@ -8,7 +8,7 @@ Mirai-API-HTTP 的适配现在仍然处于早期阶段, 可能没有进行过充 ::: -::: tip +:::tip 为了你的使用之旅更加顺畅, 我们建议您在配置之前具有以下的前置知识 @@ -18,7 +18,7 @@ Mirai-API-HTTP 的适配现在仍然处于早期阶段, 可能没有进行过充 ::: -::: danger +:::danger Mirai-API-HTTP 的适配器以 [AGPLv3 许可](https://opensource.org/licenses/AGPL-3.0) 单独开源 @@ -59,7 +59,7 @@ pip install nonebot-adapter-mirai - 在 Mirai Console Loader 目录下执行该指令 - - ```shell + ```bash ./mcl --update-package net.mamoe:mirai-api-http --channel stable --type plugin ``` @@ -67,7 +67,7 @@ pip install nonebot-adapter-mirai 4. 修改配置文件 - ::: tip + :::tip 在此之前, 你可能需要了解我们为 MAH 设计的两种通信方式 @@ -97,7 +97,7 @@ pip install nonebot-adapter-mirai - `nonebot.drivers.fastapi`: 同时支持正向和反向 - `nonebot.drivers.aiohttp`: 仅支持正向 - ::: warning + :::warning 在默认情况下, NoneBot 和 MAH 会同时监听 8080 端口, 这会导致端口冲突的错误 请确保二者配置不在同一端口下 @@ -149,7 +149,7 @@ pip install nonebot-adapter-mirai - ```yaml # 省略了部分无需修改的部分 - host: '0.0.0.0' # 监听地址 + host: "0.0.0.0" # 监听地址 port: 8080 # 监听端口 authKey: 1234567890 # 访问密钥, 最少八位 @@ -157,7 +157,7 @@ pip install nonebot-adapter-mirai report: enable: true # 必须为true groupMessage: - report: true # 群消息上报 + report: true # 群消息上报 friendMessage: report: true # 好友消息上报 tempMessage: @@ -165,7 +165,7 @@ pip install nonebot-adapter-mirai eventMessage: report: true # 事件上报 destinations: - - 'http://127.0.0.1:2333/mirai/http' #上报地址, 请按照实际情况修改 + - "http://127.0.0.1:2333/mirai/http" #上报地址, 请按照实际情况修改 # 上报时的额外Header extraHeaders: {} ``` diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 7204b31f..c71bc13e 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -9,12 +9,19 @@ const config = { title: "NoneBot", tagline: "跨平台 Python 异步机器人框架", url: "https://v2.nonebot.dev", - baseUrl: "/", + baseUrl: process.env.BASE_URL || "/", onBrokenLinks: "throw", onBrokenMarkdownLinks: "warn", favicon: "icons/favicon.ico", organizationName: "nonebot", // Usually your GitHub org/user name. projectName: "nonebot2", // Usually your repo name. + i18n: { + defaultLocale: "zh-Hans", + locales: ["zh-Hans"], + localeConfigs: { + "zh-Hans": { label: "简体中文" }, + }, + }, presets: [ [ @@ -33,7 +40,7 @@ const config = { ], themeConfig: - /** @type {import('docusaurus-theme-nonepress/types').ThemeConfig} */ + /** @type {import('docusaurus-preset-nonepress').ThemeConfig} */ ({ colorMode: { defaultMode: "light", diff --git a/yarn.lock b/yarn.lock index 1809a587..67088a3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2857,7 +2857,14 @@ cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: path-type "^4.0.0" yaml "^1.10.0" -cross-spawn@^7.0.3: +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.npm.taobao.org/cross-env/download/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha1-hlJkspZ33AFbqEGJGJZd0jL8VM8= + dependencies: + cross-spawn "^7.0.1" + +cross-spawn@^7.0.1, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.nlark.com/cross-spawn/download/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha1-9zqFudXUHQRVUcF34ogtSshXKKY= @@ -3230,7 +3237,7 @@ dns-txt@^2.0.2: dependencies: buffer-indexof "^1.0.0" -docusaurus-preset-nonepress@0.0.0-108, docusaurus-preset-nonepress@canary: +docusaurus-preset-nonepress@0.0.0-108: version "0.0.0-108" resolved "https://registry.npmmirror.com/docusaurus-preset-nonepress/download/docusaurus-preset-nonepress-0.0.0-108.tgz#37a4068c71fe335d2486d9effcadcb18503b50cb" integrity sha512-GuH22RrrI5FWiUPIKEWWisWJ/laymWMY+aFbfXY5fNLzarLFkAmshUpGHuuAMAnL/U1W812RYyJNoNHnUA/XgQ== @@ -3240,6 +3247,16 @@ docusaurus-preset-nonepress@0.0.0-108, docusaurus-preset-nonepress@canary: "@docusaurus/plugin-content-pages" "2.0.0-beta.9" docusaurus-theme-nonepress "0.0.0-108" +docusaurus-preset-nonepress@canary: + version "0.0.0-109" + resolved "https://registry.npmmirror.com/docusaurus-preset-nonepress/download/docusaurus-preset-nonepress-0.0.0-109.tgz#bb3d373beb908ae981a1e0f41e3d2d3619672c0c" + integrity sha512-bZRyInMVPdJ9jn/lo/24yT67WwuO0yPVOItRe3f7w2ziDUMIQ1/UM2RAc8My+RyRbByyFu6kWc9SBIeJlmupVQ== + dependencies: + "@docusaurus/core" "2.0.0-beta.9" + "@docusaurus/plugin-content-docs" "2.0.0-beta.9" + "@docusaurus/plugin-content-pages" "2.0.0-beta.9" + docusaurus-theme-nonepress "0.0.0-109" + docusaurus-theme-nonepress@0.0.0-108: version "0.0.0-108" resolved "https://registry.npmmirror.com/docusaurus-theme-nonepress/download/docusaurus-theme-nonepress-0.0.0-108.tgz#d1e381a446d1179841ae4fe5f51cd6314df9b0a1" @@ -3280,6 +3297,46 @@ docusaurus-theme-nonepress@0.0.0-108: react-router-dom "^5.2.0" tailwindcss ">=3.0.0 || >=3.0.0-alpha.1" +docusaurus-theme-nonepress@0.0.0-109: + version "0.0.0-109" + resolved "https://registry.npmmirror.com/docusaurus-theme-nonepress/download/docusaurus-theme-nonepress-0.0.0-109.tgz#955b8ca07b9c4d971ec9eb7d86d98f5b5640c4a2" + integrity sha512-qkck6fAYQPmajFeaWKzh61wIrOuxVVJDH+NhqyWHuSkbCqBxHo5qjHV3LZyZh+480PtAmHornkXVDluSJSRM7w== + dependencies: + "@docsearch/react" "^3.0.0-alpha.39" + "@docusaurus/core" "2.0.0-beta.9" + "@docusaurus/plugin-content-docs" "2.0.0-beta.9" + "@docusaurus/plugin-content-pages" "2.0.0-beta.9" + "@docusaurus/theme-common" "2.0.0-beta.9" + "@docusaurus/utils" "2.0.0-beta.9" + "@docusaurus/utils-common" "2.0.0-beta.9" + "@docusaurus/utils-validation" "2.0.0-beta.9" + "@fortawesome/fontawesome-svg-core" "^1.2.36" + "@fortawesome/free-brands-svg-icons" "^5.15.4" + "@fortawesome/free-regular-svg-icons" "^5.15.4" + "@fortawesome/free-solid-svg-icons" "^5.15.4" + "@fortawesome/react-fontawesome" "^0.1.16" + "@mdx-js/mdx" "^1.6.21" + "@mdx-js/react" "^1.6.21" + "@seznam/compose-react-refs" "^1.0.6" + "@tailwindcss/typography" "^0.5.0-alpha.3" + algoliasearch "^4.11.0" + algoliasearch-helper "^3.5.5" + autoprefixer "^10.3.1" + chalk "^4.1.2" + clsx "^1.1.1" + copy-text-to-clipboard "^3.0.1" + eta "^1.12.3" + globby "^11.0.2" + lodash "^4.17.20" + parse-numeric-range "^1.2.0" + postcss "^8.3.7" + postcss-import "^14.0.2" + prism-react-renderer "^1.2.1" + prismjs "^1.23.0" + react-cool-onclickoutside "^1.6.2" + react-router-dom "^5.2.0" + tailwindcss ">=3.0.0 || >=3.0.0-alpha.1" + dom-converter@^0.2.0: version "0.2.0" resolved "https://registry.npm.taobao.org/dom-converter/download/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768" @@ -3392,9 +3449,9 @@ ee-first@1.1.1: integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= electron-to-chromium@^1.3.896: - version "1.4.7" - resolved "https://registry.npmmirror.com/electron-to-chromium/download/electron-to-chromium-1.4.7.tgz#58e0b4ec9096ee1422e4d9e83ceeb05b0cf076eb" - integrity sha512-UPy2MsQw1OdcbxR7fvwWZH/rXcv+V26+uvQVHx0fGa1kqRfydtfOw+NMGAvZJ63hyaH4aEBxbhSEtqbpliSNWA== + version "1.4.8" + resolved "https://registry.npmmirror.com/electron-to-chromium/download/electron-to-chromium-1.4.8.tgz#e1b7752ac1a75e39b5dd90cc7e29ea08b351c484" + integrity sha512-Cu5+dbg55+1E3ohlsa8HT0s4b8D0gBewXEGG8s5wBl8ynWv60VuvYW25GpsOeTVXpulhyU/U8JYZH+yxASSJBQ== emoji-regex@^8.0.0: version "8.0.0"