Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 重构并适配新版本 #35

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/build-check.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: PR

# 监听 PR 相关事件
on:
pull_request:
# 监听 PR 被打开、重新打开和推送事件
types: [opened, reopened, synchronize]

# 赋予 release-please-action 权限
permissions:
contents: write
pull-requests: write
jobs:
# 设置 release-please 任务
release-please:
# 设置任务运行环境为 ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
# 设置 Node.js 环境
- name: 设置 Node.js 环境
uses: actions/setup-node@v4
with:
# 设置 Node.js 版本
node-version: 20
# 设置 npm 源
registry-url: "https://registry.npmjs.org"
# 安装依赖 不安装对等依赖
- name: 安装依赖
run: npm install --config.auto-install-peers=false --ignore-scripts --omit=peer
# 构建输出
- name: 构建输出
id: build
run: npm run build > build.log 2>&1
continue-on-error: true # 捕获失败并允许后续步骤运行
# 获取当前 PR 编号并设置环境变量
- name: 获取 PR 编号
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
# 自动修改 package.json 的版本号、删除开发、对等依赖
- name: 修订版本号
run: npm run pr all
if: success()
# 发布到 npm
- name: 发布到 npm
run: npm run pub-beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: success()
# 在 PR 上发布构建完成或失败信息
- name: 发布评论
run: |
if [ "${{ steps.build.outcome }}" = "failure" ]; then
# 捕获构建失败日志
ERROR_MESSAGE=$(cat build.log || echo "未找到详细的构建日志。")
# 发布构建失败评论
gh pr comment ${{ env.PR_NUMBER }} --body $'❌ 构建失败!以下是错误日志:\n\n<details>\n<summary>展开查看错误日志</summary>\n\n```\n'"${ERROR_MESSAGE}"$'\n```\n\n</details>'
else
# 构建成功评论
INSTALL_COMMAND="pnpm install ${{ env.PKG_NAME }}@${{ env.PKG_VERSION }} -w"
gh pr comment ${{ env.PR_NUMBER }} --body $'🎉 构建完成!您可以通过以下命令安装此版本:\n\n```\n'"${INSTALL_COMMAND}"$'\n```'
fi
env:
GITHUB_TOKEN: ${{ secrets.RELEASE }}
46 changes: 0 additions & 46 deletions .github/workflows/release-please.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release and Publish
on:
push:
# 监听 main 分支的 push 事件
branches:
- main
# 赋予 release-please-action 权限
permissions:
contents: write
pull-requests: write
jobs:
# 设置 release-please 任务
release-please:
# 设置任务运行环境为 ubuntu-latest
runs-on: ubuntu-latest
steps:
# 使用 release-please-action 动作来自动创建发布 PR
- uses: googleapis/release-please-action@v4
id: release
with:
# 设置发布类型为 node
release-type: node
# 检出代码
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
# 设置 Node.js 环境
- uses: actions/setup-node@v4
with:
# 设置 Node.js 版本
node-version: 20
# 设置 npm 源
registry-url: "https://registry.npmjs.org"
# 安装依赖 不安装对等依赖
- run: npm install --config.auto-install-peers=false --ignore-scripts --omit=peer
env:
NODE_AUTH_TOKEN: ${{ secrets.RELEASE }}
if: ${{ steps.release.outputs.release_created }}
# 构建输出
- run: npm run build
if: ${{ steps.release.outputs.release_created }}
# 删除开发依赖、对等依赖
- run: npm run pr clean
if: ${{ steps.release.outputs.release_created }}
# 发布到 npm
- run: npm run pub
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ lerna-debug.log*

# 编辑器配置
.idea/
.vscode/

# 临时文件
/logs/
/temp/
/lib/

# 配置
/plugins/
/data/
/config/config
/resources
/lib

# 依赖
node_modules/
config/config/pm2.yaml
index.js
pnpm-workspace.yaml
@karinjs/
1.js
src/test.ts
src/apps/
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"christian-kohler.path-intellisense",
"formulahendry.code-runner",
"MS-CEINTL.vscode-language-pack-zh-hans",
"steoates.autoimport",
"Meezilla.json",
"yzhang.markdown-all-in-one",
"ChakrounAnas.turbo-console-log",
"Gruntfuggly.todo-tree"
]
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.formatOnPaste": true,
"editor.formatOnSaveMode": "file",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"files.autoSave": "onFocusChange",
// 单引号
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
// 去掉分号
"javascript.format.semicolons": "remove",
"typescript.format.semicolons": "remove",
// 函数括号前面加空格
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
// 构造函数后面加空格
"typescript.format.insertSpaceAfterConstructor": true,
"javascript.format.insertSpaceAfterConstructor": true,
}
3 changes: 3 additions & 0 deletions config/comment/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"screenshotUrl": "网页截图测试地址"
}
69 changes: 0 additions & 69 deletions config/config.yaml

This file was deleted.

53 changes: 53 additions & 0 deletions config/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 全局默认配置 以下所有配置均可在账号配置中单独配置
default:
# 机器人ID
appId: string
# 机器人密钥
secret: string
# 正式环境api
prodApi: https://api.sgroup.qq.com
# 沙盒api
sandboxApi: https://sandbox.api.sgroup.qq.com
# 调用凭证的Api
tokenApi: https://bots.qq.com/app/getAppAccessToken
# 是否开启沙盒环境
sandbox: false
# 开启QQ场景能力
qqEnable: true
# 开启频道场景能力
guildEnable: true
# 频道场景模式 0-公域 1-私域
guildMode: 0
# 文本中的url转二维码白名单 配置后将不转换这些url为二维码
exclude: []
# 接受到消息后对文本进行表达式处理
regex: [
{
# 表达式
reg: "^#",
# 替换为
rep: "",
},
]
# markdown配置
markdown:
# 发送模式 0-关闭MD 1-原生MD 3-旧图文模板MD 4-纯文模板MD 5-自定义处理
mode: 0
# 模板ID
id: ""
kv:
- text_start
- img_dec
- img_url
- text_end

# 事件接收配置
event:
# 接收方式 0-关闭 1-webhook 2-http 3-ws
type: 0
# ws服务器地址
wsUrl: ws://example.com/webhook
# ws服务器token
wsToken: your_token
# http鉴权token
httpToken: your_token
4 changes: 4 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import neostandard from 'neostandard'

const ignores = ['node_modules', 'temp', 'lib', 'logs', 'data']
export default neostandard({ ignores, ts: true, })
Loading
Loading