node-karin 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/dir.js +1 -1
- package/lib/core/plugin.loader.js +0 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +5 -1
- package/lib/tools/init.js +8 -2
- package/package.json +1 -1
package/lib/core/dir.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
2
|
import { fileURLToPath } from 'url'
|
|
3
3
|
const filename = fileURLToPath(import.meta.url)
|
|
4
|
-
export const karinDir = path.resolve(filename, '
|
|
4
|
+
export const karinDir = path.resolve(filename, '../../../').replace(/\\/g, '/').replace(/\/$/, '')
|
package/lib/index.d.ts
CHANGED
|
@@ -16,9 +16,12 @@ import update from './utils/update.js';
|
|
|
16
16
|
import YamlEditor from './utils/YamlEditor.js';
|
|
17
17
|
import render from './renderer/app.js';
|
|
18
18
|
import { KarinMessage } from './event/message.js';
|
|
19
|
+
import Karin from './core/karin.js';
|
|
19
20
|
import level from './db/level.js';
|
|
20
21
|
import { RedisClientType } from 'redis';
|
|
21
22
|
import { kritor } from 'kritor-proto';
|
|
22
23
|
export * as types from './types/index.js';
|
|
23
24
|
declare const redis: RedisClientType;
|
|
24
25
|
export { config, config as Cfg, common, listener, logger, Plugin, PluginLoader, server, Plugin as plugin, listener as Bot, segment, handler, ffmpeg, exec, button, level, redis, update, render, kritor, YamlEditor, render as Renderer, update as Update, KarinMessage, };
|
|
26
|
+
declare const karin: Karin;
|
|
27
|
+
export default karin;
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import update from './utils/update.js';
|
|
|
19
19
|
import YamlEditor from './utils/YamlEditor.js';
|
|
20
20
|
import render from './renderer/app.js';
|
|
21
21
|
import { KarinMessage } from './event/message.js';
|
|
22
|
+
import Karin from './core/karin.js';
|
|
22
23
|
// 适配器
|
|
23
24
|
import Puppeteer from './renderer/server.js';
|
|
24
25
|
import OneBot11 from './adapter/onebot/onebot11.js';
|
|
@@ -34,7 +35,10 @@ const redis = (await new Redis().start());
|
|
|
34
35
|
PluginLoader.load();
|
|
35
36
|
listener.emit('adapter', Puppeteer);
|
|
36
37
|
listener.emit('adapter', OneBot11);
|
|
37
|
-
//
|
|
38
|
+
// 命名导出
|
|
38
39
|
export {
|
|
39
40
|
// 基本模块
|
|
40
41
|
config, config as Cfg, common, listener, logger, Plugin, PluginLoader, server, Plugin as plugin, listener as Bot, segment, handler, ffmpeg, exec, button, level, redis, update, render, kritor, YamlEditor, render as Renderer, update as Update, KarinMessage, };
|
|
42
|
+
// 默认导出
|
|
43
|
+
const karin = new Karin();
|
|
44
|
+
export default karin;
|
package/lib/tools/init.js
CHANGED
|
@@ -14,8 +14,14 @@ function mkdir (dirname) {
|
|
|
14
14
|
const delList = ['./config/defSet', './config/view']
|
|
15
15
|
for (const dir of delList) {
|
|
16
16
|
if (fs.existsSync(dir)) { fs.rmdirSync(dir, { recursive: true }) }
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
mkdir(dir)
|
|
18
|
+
const root = `${karinDir}${dir.replace('.', '')}`
|
|
19
|
+
const files = fs.readdirSync(root).filter(file => file.endsWith('.yaml'))
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const path = `${dir}/${file}`
|
|
22
|
+
const pathDef = `${root}/${file}`
|
|
23
|
+
if (!fs.existsSync(path)) { fs.copyFileSync(pathDef, path) }
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
// 判断是否为第一次使用
|
|
21
27
|
if (!fs.existsSync('./index.js') && !fs.existsSync('./plugins')) {
|