Skip to content

Commit

Permalink
build: support scaffold command
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jul 11, 2022
1 parent a90afd6 commit 1bec063
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 23 deletions.
36 changes: 15 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,27 @@ Koishi 是一个相当大的仓库,包含了各种各样的插件和适配器

## 可以贡献的范围(我可以贡献__吗?)

- 为已有的库添加新的特性
### 为已有的库添加新的特性

当然可以。不过在此之前建议你发一个 feature request 或者在官方群中与作者交流意见。这是为了确保你写的东西不会让别人的机器人挂掉。

- 贡献一个新的平台/数据库实现
### 贡献一个新的适配器 / 数据库实现

非常欢迎。不过你需要知道平台和数据库实现非常底层的东西,建议你在写之前熟悉一下 Koishi 的基本架构和文档。如果有什么疑问,也可以在 issues 或者官方群中提出。
非常欢迎。不过目前 Koishi 的适配器和数据库的实现并不在官方仓库中,你或许应该去这里提交 Pull Request:

- 贡献一个新的插件
- 适配器:[satorijs/node-sdk](https://github.com/satorijs/node-sdk)
- 数据库:[shigma/minato](https://github.com/shigma/minato)

另外,适配器和数据库实现非常底层的东西,建议你在写之前熟悉一下 Koishi 的基本架构和文档。如果有什么疑问,也可以在 issues 或者官方群中提出。

### 贡献一个新的插件

Koishi 至今为止的官方插件数量已经非常非常多了,比起创建一个新的官方插件,我们更愿意见到社区插件丰富起来。
只要你为自己的插件添加上合适的前缀(如 `koishi-plugin-bar``@foo/koishi-plugin-bar`),Koishi 的插件市场便会自动收录。
对于活跃的社区贡献者,我们也会邀请其成为组织 @koishijs 的成员(现在已经有不少了)。

关于发布插件的指南,请参考[这篇文档](https://koishi.js.org/guide/plugin/publish.html)

## 如何发送 Pull Request

### 基本流程
Expand Down Expand Up @@ -74,23 +81,10 @@ Koishi 至今为止的官方插件数量已经非常非常多了,比起创建
如果你希望直接使用官方仓库调试机器人,可以尝试以下流程:

1. 运行 `yarn` 安装必要的依赖
2. 在根目录下创建一个新的 test 目录
3. 创建 `test/package.json`
```json
{
"name": "@koishijs/test",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "koishi start --watch .. -r esbuild-register -r yml-register"
},
"dependencies": {
"@koishijs/cli": "*"
}
}
```
3. 创建 `test/koishi.yml`,可以参考[官方模板仓库](https://github.com/koishijs/boilerplate)
4. 现在,运行 `yarn dev` 即可启动你的机器人
2. 运行 `yarn scaffold` 创建一个模板项目
3. 现在,运行 `yarn dev` 即可启动你的机器人

你创建的模板项目将处于 `test` 目录下,这个目录已经被记录在了 .gitignore 中,所以你大可以放心地修改其中的内容。

## 脚本说明

Expand Down
19 changes: 19 additions & 0 deletions build/template/koishi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
port: 8080
maxPort: 8099

plugins:
group:basic:
suggest: null
help: null
group:console:
console:
devMode: true
sandbox: null
insight: null
dataview: null
manager: null
status: null
logger: null
chat: null
group:adapter:
group:database:
11 changes: 11 additions & 0 deletions build/template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@koishijs/test",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "koishi start --watch .. -r esbuild-register -r yml-register"
},
"dependencies": {
"@koishijs/cli": "*"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test:html": "rimraf coverage && c8 -r html yarn test",
"test:text": "c8 -r text yarn test",
"lint": "eslint packages plugins --ext=ts --cache",
"scaffold": "yarn compile koishi && yarn create-koishi test",
"scaffold": "rm -rf test && cp -rf build/template/ test/ && yarn",
"start": "yarn compile && cross-env TS_NODE_PROJECT=../tsconfig.json yarn workspace @koishijs/test koishi start --watch .. -r ../build/register --experimental-vm-modules",
"dev": "yarn compile && yarn workspace @koishijs/test dev",
"shiki": "yarn workspace bot-shiki"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/worker/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ namespace Watcher {
debounce?: number
}

export const Config = Schema.object({
export const Config: Schema<Config> = Schema.object({
root: Schema.string().description('要监听的根目录,相对于当前工作路径。'),
debounce: Schema.natural().role('ms').default(100).description('延迟触发更新的等待时间。'),
ignored: Schema.union([
Expand Down

0 comments on commit 1bec063

Please sign in to comment.