Skip to content

Commit

Permalink
fix: dev mode load ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
BIYUEHU committed Aug 11, 2024
1 parent ae19c20 commit 57db713
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
13 changes: 9 additions & 4 deletions packages/kotori/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,26 @@ Kotori is a chatbot framework that is **cross-platform, decoupled, and modern**
#### Platform

- QQ (based on Tencent's official API)
- QQ (based on [OneBot11 Standard](https://onebot.dev/)
- QQ (based on [OneBot11 Standard](https://onebot.dev/))
- CMD command line
- Slack
- Telegram
- Email
- Discord
- Kook
- MinecraftBedrock (based on WebSocket)

#### Will support:

- Kook
- WeChat
- Discord
- Line
- What's App
- DingTalk

#### Data

- LevelDb

## 📖 Documentation

- [Kotori Docs](https://kotori.js.org/)
- [Kotori Docs](https://kotori.js.org/)
10 changes: 4 additions & 6 deletions packages/kotori/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,28 @@
#### Platform

- QQ(基于腾讯官方接口)
- QQ (基于 [OneBot11 标准](https://onebot.dev/)
- QQ基于 [OneBot11 标准](https://onebot.dev/),适用于 [NapCat](https://github.com/NapNeko/NapCatQQ)[go-cqhttp](https://github.com/Mrs4s/go-cqhttp) 等项目)
- CMD 命令行
- Slack
- Telegram
- Email
- Discord
- Kook
- MinecraftBedrock (基于 WebSocket)
- WeChat
- Discord


即将支持:

- Kook/开黑啦
- WeChat/微信
- Line
- What's App
- DingTalk

#### Data

- LevelDb

Kotori 使用极为轻量的 LevelDb 作为数据存储。

## 📖 Documentation

- [Kotori Docs](https://kotori.js.org/)
- [Kotori Docs](https://kotori.js.org/)
2 changes: 1 addition & 1 deletion packages/kotori/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kotori-bot",
"version": "1.6.2",
"version": "1.6.3",
"description": "Cross-platform chatbot framework base on Node.js and TypeScript",
"main": "lib/index.js",
"license": "GPL-3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kotori/src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (!process.env.IS_DAEMON) env.config()

export default {
mode: process.env.NODE_ENV === DEV_MODE ? DEV_MODE : BUILD_MODE,
dir: process.env.DIR,
dir: process.env.DIR ?? './',
config: process.env.CONFIG,
port: process.env.PORT ? Number(process.env.PORT) : undefined,
dbPrefix: process.env.DB_PREFIX,
Expand Down
2 changes: 1 addition & 1 deletion packages/loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kotori-bot/loader",
"version": "1.7.1",
"version": "1.7.2",
"description": "Loader For KotoriBot",
"license": "GPL-3.0",
"main": "lib/index.js",
Expand Down
10 changes: 4 additions & 6 deletions packages/loader/src/loader/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Blog: https://hotaru.icu
* @Date: 2023-06-24 15:12:55
* @LastEditors: Hotaru [email protected]
* @LastEditTime: 2024-08-09 18:33:51
* @LastEditTime: 2024-08-11 13:58:37
*/
// import '@kotori-bot/core/src/utils/internal'
import {
Expand Down Expand Up @@ -408,10 +408,8 @@ export class Loader extends Core {
throw new DevError(`illegal package.json ${pkgPath}`)
}

const main = path.resolve(
dir,
this.isDev && fs.existsSync(path.join(dir, 'src/index.ts')) ? 'src/index.ts' : pkg.main
)
const loadTs = this.isDev && fs.existsSync(path.join(dir, 'src/index.ts'))
const main = path.resolve(dir, loadTs ? 'src/index.ts' : pkg.main)
if (!fs.existsSync(main)) throw new DevError(`cannot find main file ${main}`)

const getDirFiles = (rootDir: string) => {
Expand All @@ -430,7 +428,7 @@ export class Loader extends Core {
return list
}

const files = getDirFiles(path.join(dir, this.isDev ? 'src' : path.parse(pkg.main).dir))
const files = getDirFiles(path.join(dir, loadTs ? 'src' : path.parse(pkg.main).dir))

const [pkgScope, pkgName] = pkg.name.split('/')
const pluginName = `${pkgScope.startsWith('@') && pkgScope !== '@kotori-bot' ? `${pkgScope.slice(1)}/` : ''}${(pkgName ?? pkgScope).replace(PLUGIN_PREFIX, '')}`
Expand Down

0 comments on commit 57db713

Please sign in to comment.