@kotori-bot/loader 1.4.0 → 1.4.2
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/README.md +27 -27
- package/lib/consts.js +1 -1
- package/lib/loader.d.ts +1 -1
- package/lib/loader.js +1 -3
- package/lib/log.js +7 -7
- package/lib/service/database.d.ts +3 -4
- package/lib/service/database.js +0 -41
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# @kotori-bot/core
|
|
2
|
-
|
|
3
|
-
```typescript
|
|
4
|
-
interface Context {
|
|
5
|
-
readonly baseDir: Runner['baseDir'];
|
|
6
|
-
readonly options: Runner['options'];
|
|
7
|
-
readonly [Symbols.modules]: Runner[typeof Symbols.modules];
|
|
8
|
-
loadAll(): void;
|
|
9
|
-
watcher(): void;
|
|
10
|
-
logger: Logger;
|
|
11
|
-
/* Service */
|
|
12
|
-
server: Server;
|
|
13
|
-
db: Database;
|
|
14
|
-
file: File;
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
- Loader
|
|
19
|
-
- Runner
|
|
20
|
-
- Server
|
|
21
|
-
- Database
|
|
22
|
-
- File
|
|
23
|
-
- log
|
|
24
|
-
|
|
25
|
-
## Reference
|
|
26
|
-
|
|
27
|
-
- [Kotori Docs](https://kotori.js.org/)
|
|
1
|
+
# @kotori-bot/core
|
|
2
|
+
|
|
3
|
+
```typescript
|
|
4
|
+
interface Context {
|
|
5
|
+
readonly baseDir: Runner['baseDir'];
|
|
6
|
+
readonly options: Runner['options'];
|
|
7
|
+
readonly [Symbols.modules]: Runner[typeof Symbols.modules];
|
|
8
|
+
loadAll(): void;
|
|
9
|
+
watcher(): void;
|
|
10
|
+
logger: Logger;
|
|
11
|
+
/* Service */
|
|
12
|
+
server: Server;
|
|
13
|
+
db: Database;
|
|
14
|
+
file: File;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Loader
|
|
19
|
+
- Runner
|
|
20
|
+
- Server
|
|
21
|
+
- Database
|
|
22
|
+
- File
|
|
23
|
+
- log
|
|
24
|
+
|
|
25
|
+
## Reference
|
|
26
|
+
|
|
27
|
+
- [Kotori Docs](https://kotori.js.org/)
|
package/lib/consts.js
CHANGED
|
@@ -7,5 +7,5 @@ exports.DEV_CODE_DIRS = './src/';
|
|
|
7
7
|
exports.DEV_IMPORT = `${exports.DEV_CODE_DIRS}index.ts`;
|
|
8
8
|
exports.BUILD_CONFIG_NAME = 'kotori.yml';
|
|
9
9
|
exports.DEV_CONFIG_NAME = 'kotori.dev.yml';
|
|
10
|
-
exports.SUPPORTS_VERSION = /(1\.1\.0)|(1\.2\.0)/;
|
|
10
|
+
exports.SUPPORTS_VERSION = /(1\.1\.0)|(1\.2\.0)|(1\.3\.(.*?))/;
|
|
11
11
|
exports.SUPPORTS_HALF_VERSION = /(x\.x\.(.*?))/;
|
package/lib/loader.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Container, Symbols } from '@kotori-bot/core';
|
|
|
2
2
|
import Logger from '@kotori-bot/logger';
|
|
3
3
|
import Runner from './runner';
|
|
4
4
|
import Server from './service/server';
|
|
5
|
-
import Database from './service/database';
|
|
5
|
+
import type Database from './service/database';
|
|
6
6
|
import File from './service/file';
|
|
7
7
|
declare module '@kotori-bot/core' {
|
|
8
8
|
interface Context {
|
package/lib/loader.js
CHANGED
|
@@ -32,7 +32,7 @@ exports.Loader = void 0;
|
|
|
32
32
|
* @Blog: https://hotaru.icu
|
|
33
33
|
* @Date: 2023-06-24 15:12:55
|
|
34
34
|
* @LastEditors: Hotaru biyuehuya@gmail.com
|
|
35
|
-
* @LastEditTime: 2024-02-
|
|
35
|
+
* @LastEditTime: 2024-02-24 19:11:35
|
|
36
36
|
*/
|
|
37
37
|
const core_1 = require("@kotori-bot/core");
|
|
38
38
|
const path_1 = __importDefault(require("path"));
|
|
@@ -42,7 +42,6 @@ const runner_1 = __importStar(require("./runner"));
|
|
|
42
42
|
const log_1 = __importDefault(require("./log"));
|
|
43
43
|
const consts_1 = require("./consts");
|
|
44
44
|
const server_1 = __importDefault(require("./service/server"));
|
|
45
|
-
const database_1 = __importDefault(require("./service/database"));
|
|
46
45
|
const file_1 = __importDefault(require("./service/file"));
|
|
47
46
|
function getRunnerConfig(file, dir) {
|
|
48
47
|
const handle = (root) => {
|
|
@@ -215,7 +214,6 @@ class Loader extends core_1.Container {
|
|
|
215
214
|
}
|
|
216
215
|
setPreService() {
|
|
217
216
|
this.ctx.service('server', new server_1.default(this.ctx.extends(), { port: this.ctx.config.global.port }));
|
|
218
|
-
this.ctx.service('db', new database_1.default(this.ctx.extends()));
|
|
219
217
|
this.ctx.service('file', new file_1.default(this.ctx.extends()));
|
|
220
218
|
}
|
|
221
219
|
loadAllModules() {
|
package/lib/log.js
CHANGED
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadInfo = void 0;
|
|
4
4
|
function loadInfo(info, ctx) {
|
|
5
5
|
process.stdout.write('Kotori Bot is loading...');
|
|
6
|
-
process.stdout.write(`
|
|
7
|
-
██╗ ██╗ ██████╗ ████████╗ ██████╗ ██████╗ ██╗
|
|
8
|
-
██║ ██╔╝██╔═══██╗╚══██╔══╝██╔═══██╗██╔══██╗██║
|
|
9
|
-
█████╔╝ ██║ ██║ ██║ ██║ ██║██████╔╝██║
|
|
10
|
-
██╔═██╗ ██║ ██║ ██║ ██║ ██║██╔══██╗██║
|
|
11
|
-
██║ ██╗╚██████╔╝ ██║ ╚██████╔╝██║ ██║██║
|
|
12
|
-
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝
|
|
6
|
+
process.stdout.write(`
|
|
7
|
+
██╗ ██╗ ██████╗ ████████╗ ██████╗ ██████╗ ██╗
|
|
8
|
+
██║ ██╔╝██╔═══██╗╚══██╔══╝██╔═══██╗██╔══██╗██║
|
|
9
|
+
█████╔╝ ██║ ██║ ██║ ██║ ██║██████╔╝██║
|
|
10
|
+
██╔═██╗ ██║ ██║ ██║ ██║ ██║██╔══██╗██║
|
|
11
|
+
██║ ██╗╚██████╔╝ ██║ ╚██████╔╝██║ ██║██║
|
|
12
|
+
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝
|
|
13
13
|
`);
|
|
14
14
|
ctx.logger.info('loader base dir:', ctx.baseDir.root);
|
|
15
15
|
ctx.logger.info(`Kotori Bot Version: ${info.version} License: ${info.license}`);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import knex from 'knex';
|
|
3
|
-
export
|
|
1
|
+
import { Service } from '@kotori-bot/core';
|
|
2
|
+
import type knex from 'knex';
|
|
3
|
+
export interface Database extends Service {
|
|
4
4
|
internal: ReturnType<typeof knex>;
|
|
5
5
|
select: ReturnType<typeof knex>['select'];
|
|
6
6
|
delete: ReturnType<typeof knex>['delete'];
|
|
7
7
|
update: ReturnType<typeof knex>['update'];
|
|
8
8
|
insert: ReturnType<typeof knex>['insert'];
|
|
9
9
|
schema: ReturnType<typeof knex>['schema'];
|
|
10
|
-
constructor(ctx: Context);
|
|
11
10
|
}
|
|
12
11
|
export default Database;
|
package/lib/service/database.js
CHANGED
|
@@ -1,43 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Database = void 0;
|
|
7
|
-
const core_1 = require("@kotori-bot/core");
|
|
8
|
-
const knex_1 = __importDefault(require("knex"));
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
class Database extends core_1.Service {
|
|
11
|
-
internal;
|
|
12
|
-
select;
|
|
13
|
-
delete;
|
|
14
|
-
update;
|
|
15
|
-
insert;
|
|
16
|
-
schema;
|
|
17
|
-
constructor(ctx) {
|
|
18
|
-
super(ctx, {}, 'database');
|
|
19
|
-
this.internal = (0, knex_1.default)({
|
|
20
|
-
client: 'sqlite',
|
|
21
|
-
connection: {
|
|
22
|
-
filename: (0, path_1.resolve)(this.ctx.baseDir.root, 'kotori.db')
|
|
23
|
-
},
|
|
24
|
-
useNullAsDefault: true
|
|
25
|
-
} /* {
|
|
26
|
-
client: 'mysql',
|
|
27
|
-
connection: {
|
|
28
|
-
host: '127.0.0.1',
|
|
29
|
-
port: 3306,
|
|
30
|
-
user: 'kotori',
|
|
31
|
-
password: 'kotori',
|
|
32
|
-
database: 'kotori'
|
|
33
|
-
}
|
|
34
|
-
} */);
|
|
35
|
-
this.select = this.internal.select.bind(this.internal);
|
|
36
|
-
this.delete = this.internal.delete.bind(this.internal);
|
|
37
|
-
this.update = this.internal.update.bind(this.internal);
|
|
38
|
-
this.insert = this.internal.insert.bind(this.internal);
|
|
39
|
-
this.schema = this.internal.schema;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.Database = Database;
|
|
43
|
-
exports.default = Database;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kotori-bot/loader",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Loader For KotoriBot",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -26,9 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"express": "^4.18.2",
|
|
28
28
|
"knex": "^3.1.0",
|
|
29
|
-
"
|
|
30
|
-
"@kotori-bot/logger": "^1.
|
|
31
|
-
"@kotori-bot/core": "^1.3.0"
|
|
29
|
+
"@kotori-bot/core": "^1.3.0",
|
|
30
|
+
"@kotori-bot/logger": "^1.2.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@types/body-parser": "^1.19.5",
|