Commit 7dbe2c2f authored by nanahira's avatar nanahira

bump to Koishi 4.8

parent 6873666c
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 diff is collapsed.
...@@ -32,20 +32,20 @@ ...@@ -32,20 +32,20 @@
}, },
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-typeorm", "homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-typeorm",
"dependencies": { "dependencies": {
"koishi-thirdeye": "^10.3.2", "koishi-thirdeye": "^11.0.6",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"pg": "^8.7.3", "pg": "^8.7.3",
"typeorm": "0.2.45" "typeorm": "0.2.45"
}, },
"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/node": "^17.0.16", "@types/node": "^17.0.16",
"@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",
...@@ -78,6 +78,6 @@ ...@@ -78,6 +78,6 @@
"testEnvironment": "node" "testEnvironment": "node"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.7.5" "koishi": "^4.8.2"
} }
} }
...@@ -2,15 +2,13 @@ ...@@ -2,15 +2,13 @@
import { import {
TypeORMEntity, TypeORMEntity,
TypeORMPluginConfig, TypeORMPluginConfig,
TypeORMPluginConfigLike,
} from './config'; } from './config';
import { import {
DefinePlugin, DefinePlugin,
BasePlugin, StarterPlugin,
Caller, Caller,
Provide, Provide,
LifecycleEvents, LifecycleEvents,
StarterPlugin,
PluginSchema, PluginSchema,
} from 'koishi-thirdeye'; } from 'koishi-thirdeye';
import { Connection, ConnectionOptions } from 'typeorm'; import { Connection, ConnectionOptions } from 'typeorm';
...@@ -24,11 +22,8 @@ interface ConnectionEntry { ...@@ -24,11 +22,8 @@ interface ConnectionEntry {
} }
declare module 'koishi' { declare module 'koishi' {
// eslint-disable-next-line @typescript-eslint/no-namespace interface Context {
namespace Context { typeorm: TypeORMPlugin;
interface Services {
typeorm: TypeORMPlugin;
}
} }
} }
...@@ -36,7 +31,7 @@ declare module 'koishi' { ...@@ -36,7 +31,7 @@ declare module 'koishi' {
@Provide('typeorm', { immediate: true }) @Provide('typeorm', { immediate: true })
@DefinePlugin() @DefinePlugin()
export default class TypeORMPlugin export default class TypeORMPlugin
extends BasePlugin<TypeORMPluginConfig, ConnectionOptions> extends StarterPlugin(TypeORMPluginConfig)
implements LifecycleEvents implements LifecycleEvents
{ {
private registryMap = new Map<string, ConnectionEntry>(); private registryMap = new Map<string, ConnectionEntry>();
......
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();
}); });
......
import { App } from 'koishi'; import { Context } from 'koishi';
import TypeORMPlugin from '../src'; import TypeORMPlugin from '../src';
import { import {
Column, Column,
...@@ -42,10 +42,10 @@ class Magic { ...@@ -42,10 +42,10 @@ class Magic {
} }
describe('Koishi typeorm', () => { describe('Koishi typeorm', () => {
let app: App; let app: Context;
beforeEach(async () => { beforeEach(async () => {
app = new App(); app = new Context();
await app.start(); await app.start();
app.plugin(TypeORMPlugin, { app.plugin(TypeORMPlugin, {
type: 'postgres', type: 'postgres',
......
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