Commit 3f7b2165 authored by nanahira's avatar nanahira

bump to Koishi 4.8

parent 44539c81
import { App } from 'koishi'; import { Context } from 'koishi';
import TargetPlugin from '../src'; import TargetPlugin from '../src';
import ConsolePlugin from '@koishijs/plugin-console'; import ConsolePlugin from '@koishijs/plugin-console';
import SandboxPlugin from '@koishijs/plugin-sandbox'; import SandboxPlugin from '@koishijs/plugin-sandbox';
import * as DatabasePlugin from '@koishijs/plugin-database-memory'; import DatabasePlugin from '@koishijs/plugin-database-memory';
import CachePlugin from '@koishijs/plugin-cache-lru'; // import CachePlugin from '@koishijs/plugin-cache-lru';
import ExtrasInDev from './extras'; import ExtrasInDev from './extras';
const app = new App({ const app = new Context({
port: 14514, port: 14514,
host: 'localhost', host: 'localhost',
prefix: '.', prefix: '.',
...@@ -19,7 +19,7 @@ app.plugin(ConsolePlugin, { ...@@ -19,7 +19,7 @@ app.plugin(ConsolePlugin, {
}); });
// Some services // Some services
app.plugin(CachePlugin); // app.plugin(CachePlugin);
app.plugin(DatabasePlugin); app.plugin(DatabasePlugin);
// Some extras // Some extras
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -31,18 +31,18 @@ ...@@ -31,18 +31,18 @@
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-dicex", "homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-dicex",
"dependencies": { "dependencies": {
"cosmotype-decorators": "^2.0.3", "cosmotype-decorators": "^2.0.3",
"koishi-thirdeye": "^10.3.2" "koishi-thirdeye": "^11.0.6"
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-cache-lru": "^1.0.0-rc.0", "@koishijs/plugin-console": "^4.1.1",
"@koishijs/plugin-console": "^3.3.2", "@koishijs/plugin-database-memory": "^1.4.1",
"@koishijs/plugin-database-memory": "^1.3.0", "@koishijs/plugin-dataview": "^2.0.0",
"@koishijs/plugin-dataview": "^1.2.4", "@koishijs/plugin-sandbox": "^2.0.1",
"@koishijs/plugin-sandbox": "^1.1.3",
"@types/jest": "^27.4.0", "@types/jest": "^27.4.0",
"@types/node": "^17.0.4", "@types/node": "^17.0.4",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0", "@typescript-eslint/parser": "^4.33.0",
"esbuild-loader": "^2.19.0",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1", "eslint-plugin-prettier": "^3.4.1",
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
"ws": "^8.4.0" "ws": "^8.4.0"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.7.5" "koishi": "^4.8.2"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [
......
...@@ -3,7 +3,7 @@ import { DicePluginConfig } from './config'; ...@@ -3,7 +3,7 @@ import { DicePluginConfig } from './config';
import { import {
CommandDescription, CommandDescription,
DefinePlugin, DefinePlugin,
OnApply, LifecycleEvents,
UseCommand, UseCommand,
} from 'koishi-thirdeye'; } from 'koishi-thirdeye';
import { DbModule } from './modules/db'; import { DbModule } from './modules/db';
...@@ -15,16 +15,13 @@ import { CompatModule } from './modules/compat'; ...@@ -15,16 +15,13 @@ import { CompatModule } from './modules/compat';
export * from './config'; export * from './config';
declare module 'koishi' { declare module 'koishi' {
// eslint-disable-next-line @typescript-eslint/no-namespace interface Context {
namespace Context { diceDb: DbModule;
interface Services {
diceDb: DbModule;
}
} }
} }
@DefinePlugin({ name: 'dicex', schema: DicePluginConfig }) @DefinePlugin({ name: 'dicex', schema: DicePluginConfig })
export default class DicePlugin extends BaseModule implements OnApply { export default class DicePlugin extends BaseModule implements LifecycleEvents {
@UseCommand('dice', { empty: true }) @UseCommand('dice', { empty: true })
@CommandDescription({ zh: '骰子指令', en: 'Dice command' }) @CommandDescription({ zh: '骰子指令', en: 'Dice command' })
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
......
...@@ -5,13 +5,11 @@ import { ...@@ -5,13 +5,11 @@ import {
CommandUsage, CommandUsage,
Inject, Inject,
InjectLogger, InjectLogger,
LifecycleEvents,
MixinModel, MixinModel,
OnApply,
Provide, Provide,
PutArg, PutArg,
PutChannel,
PutOption, PutOption,
PutUser,
UseCommand, UseCommand,
} from 'koishi-thirdeye'; } from 'koishi-thirdeye';
import { Channel, Database, DatabaseService, Logger, User } from 'koishi'; import { Channel, Database, DatabaseService, Logger, User } from 'koishi';
...@@ -41,7 +39,7 @@ declare module 'koishi' { ...@@ -41,7 +39,7 @@ declare module 'koishi' {
@MixinModel('user', { diceProfile: DiceProfile }) @MixinModel('user', { diceProfile: DiceProfile })
@MixinModel('channel', { diceProfile: DiceProfile }) @MixinModel('channel', { diceProfile: DiceProfile })
@DiceModule() @DiceModule()
export class DbModule extends BaseModule implements OnApply { export class DbModule extends BaseModule implements LifecycleEvents {
@Inject(true) @Inject(true)
private database: Database; private database: Database;
......
import { DicePluginConfig } from '../config'; import { DicePluginConfig } from '../config';
import { BasePlugin } from 'koishi-thirdeye'; import { StarterPlugin } from 'koishi-thirdeye';
export class BaseModule extends BasePlugin<DicePluginConfig> {} export class BaseModule extends StarterPlugin(DicePluginConfig) {}
import { App } from 'koishi'; import { Context } from 'koishi';
import TargetPlugin from '../src'; import TargetPlugin from '../src';
describe('Test of plugin.', () => { describe('Test of plugin.', () => {
let app: App; let app: Context;
beforeEach(async () => { beforeEach(async () => {
app = new App(); app = new Context();
// app.plugin(TargetPlugin); // app.plugin(TargetPlugin);
await app.start(); await app.start();
}); });
......
const path = require('path'); const path = require('path');
const packgeInfo = require('./package.json'); const packgeInfo = require('./package.json');
const { ESBuildMinifyPlugin } = require('esbuild-loader');
function externalsFromDep() { function externalsFromDep() {
return Object.fromEntries( return Object.fromEntries(
...@@ -43,4 +44,11 @@ module.exports = { ...@@ -43,4 +44,11 @@ module.exports = {
koishi: 'koishi', koishi: 'koishi',
...(packAll ? {} : externalsFromDep()), ...(packAll ? {} : externalsFromDep()),
}, },
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
keepNames: true,
}),
],
},
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment