Commit f516d658 authored by nanahira's avatar nanahira

bump to Koishi 4.8

parent e8671b3a
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.
...@@ -28,22 +28,22 @@ ...@@ -28,22 +28,22 @@
}, },
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-greeting", "homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-greeting",
"dependencies": { "dependencies": {
"koishi-thirdeye": "^10.3.2", "koishi-thirdeye": "^11.0.6",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"moment": "^2.29.1", "moment": "^2.29.1",
"node-schedule": "^2.1.0" "node-schedule": "^2.1.0"
}, },
"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-sandbox": "^2.0.1",
"@koishijs/plugin-sandbox": "^1.1.3",
"@types/jest": "^27.4.0", "@types/jest": "^27.4.0",
"@types/lodash": "^4.14.178", "@types/lodash": "^4.14.178",
"@types/node": "^17.0.8", "@types/node": "^17.0.8",
"@types/node-schedule": "^1.3.2", "@types/node-schedule": "^1.3.2",
"@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",
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
"ws": "^8.4.2" "ws": "^8.4.2"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.7.5" "koishi": "^4.8.2"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [
......
...@@ -178,8 +178,8 @@ export class Instance { ...@@ -178,8 +178,8 @@ export class Instance {
}) })
from: string; from: string;
getBot(list: Adapter.BotList) { getBot(list: Bot[]) {
return list.get(this.from); return list.find((bot) => bot.sid === this.from);
} }
@DefineSchema({ @DefineSchema({
...@@ -194,7 +194,7 @@ export class Instance { ...@@ -194,7 +194,7 @@ export class Instance {
}) })
rules: Rule[]; rules: Rule[];
async run(list: Adapter.BotList) { async run(list:Bot[]) {
const bot = this.getBot(list); const bot = this.getBot(list);
if (bot?.status !== 'online') { if (bot?.status !== 'online') {
logger.info(`Skipping job for ${this.from} because it's not online.`); logger.info(`Skipping job for ${this.from} because it's not online.`);
...@@ -235,7 +235,7 @@ export class GreetingPluginConfig { ...@@ -235,7 +235,7 @@ export class GreetingPluginConfig {
@DefineSchema({ description: '实例列表。', type: Instance }) @DefineSchema({ description: '实例列表。', type: Instance })
instances: Instance[]; instances: Instance[];
async runInstances(list: Adapter.BotList, instances = this.instances) { async runInstances(list:Bot[], instances = this.instances) {
const failedInstances = _.compact( const failedInstances = _.compact(
await Promise.all(instances.map((instance) => instance.run(list))), await Promise.all(instances.map((instance) => instance.run(list))),
); );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GreetingPluginConfig, Instance } from './config'; import { GreetingPluginConfig, Instance } from './config';
import { import {
DefinePlugin, DefinePlugin,
BasePlugin, StarterPlugin,
Inject, Inject,
LifecycleEvents, LifecycleEvents,
UseEvent, UseEvent,
...@@ -14,11 +14,11 @@ export * from './config'; ...@@ -14,11 +14,11 @@ export * from './config';
@DefinePlugin({ name: 'greeting', schema: GreetingPluginConfig }) @DefinePlugin({ name: 'greeting', schema: GreetingPluginConfig })
export default class GreetingPlugin export default class GreetingPlugin
extends BasePlugin<GreetingPluginConfig> extends StarterPlugin(GreetingPluginConfig)
implements LifecycleEvents implements LifecycleEvents
{ {
@Inject() @Inject()
private bots: Adapter.BotList; private bots: Bot[];
private job: Job; private job: Job;
......
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