Commit 598c77b6 authored by nanahira's avatar nanahira

catchup

parent 0e2feb3e
...@@ -23,7 +23,7 @@ upload_to_minio: ...@@ -23,7 +23,7 @@ upload_to_minio:
tags: tags:
- linux - linux
script: script:
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/ s3://nanahira/koishi-plugin/thesaurus - aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/full/ s3://nanahira/koishi-plugin/thesaurus
only: only:
- master - master
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"lint": "eslint --fix .", "lint": "eslint --fix .",
"build": "webpack" "build": "webpack && env PACK_ALL=1 webpack"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
...@@ -25,10 +25,12 @@ ...@@ -25,10 +25,12 @@
}, },
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-thesaurus", "homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-thesaurus",
"dependencies": { "dependencies": {
"source-map-support": "^0.5.20" "schemastery-gen": "^1.0.3",
"source-map-support": "^0.5.20",
"lodash": "^4.17.21"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.0.0-alpha.12" "koishi": "^4.0.0-beta.2"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.14.175", "@types/lodash": "^4.14.175",
...@@ -38,11 +40,8 @@ ...@@ -38,11 +40,8 @@
"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",
"koishi": "^4.0.0-beta.0", "koishi": "^4.0.0-beta.2",
"koishi-utils-schemagen": "^1.1.7",
"lodash": "^4.17.21",
"prettier": "^2.4.1", "prettier": "^2.4.1",
"proxy-agent": "^5.0.0",
"raw-loader": "^4.0.2", "raw-loader": "^4.0.2",
"ts-loader": "^9.2.6", "ts-loader": "^9.2.6",
"typescript": "^4.4.4", "typescript": "^4.4.4",
......
import 'source-map-support/register'; import 'source-map-support/register';
import { DefineSchema } from 'koishi-utils-schemagen'; import { DefineSchema, RegisterSchema } from 'schemastery-gen';
@RegisterSchema()
export class MyPluginConfig { export class MyPluginConfig {
@DefineSchema({ @DefineSchema({
desc: '词库本地路径或 URL。', desc: '词库本地路径或 URL。',
......
import 'source-map-support/register'; import 'source-map-support/register';
import { Context } from 'koishi'; import { Context } from 'koishi';
import { MyPlugin } from './plugin'; import { MyPlugin } from './plugin';
import { MyPluginConfigLike } from './config'; import { MyPluginConfig } from './config';
export { MyPluginConfig } from './config'; export { MyPluginConfig } from './config';
export { ChatSession } from './plugin'; export { ChatSession } from './plugin';
...@@ -14,6 +14,6 @@ declare module 'koishi' { ...@@ -14,6 +14,6 @@ declare module 'koishi' {
export const name = 'thesaurus'; export const name = 'thesaurus';
const plugin = new MyPlugin(); const plugin = new MyPlugin();
export const schema = plugin.schema; export const schema = plugin.schema;
export function apply(ctx: Context, config: Partial<MyPluginConfigLike>) { export function apply(ctx: Context, config: MyPluginConfig) {
ctx.plugin(plugin, config); ctx.plugin(plugin, config);
} }
...@@ -143,10 +143,10 @@ export class MyPlugin { ...@@ -143,10 +143,10 @@ export class MyPlugin {
return name; return name;
} }
name = 'thesaurus-main'; name = 'thesaurus-main';
schema: Schema<MyPluginConfigLike> = schemaFromClass(MyPluginConfig); schema = MyPluginConfig;
async apply(ctx: Context, config: MyPluginConfigLike) { async apply(ctx: Context, config: MyPluginConfig) {
this.ctx = ctx; this.ctx = ctx;
this.config = schemaTransform(MyPluginConfig, config); this.config = config;
ctx.on('service/database', () => { ctx.on('service/database', () => {
if (this.config.useDatabase) this.useDatabase = !!ctx.database; if (this.config.useDatabase) this.useDatabase = !!ctx.database;
}); });
......
const path = require("path"); const path = require('path');
const packgeInfo = require('./package.json');
function externalsFromDep() {
return Object.fromEntries(
[
...Object.keys(packgeInfo.dependencies || {}),
...Object.keys(packgeInfo.peerDependencies || {}),
]
.filter((dep) => dep !== 'source-map-support')
.map((dep) => [dep, dep]),
);
}
const packAll = !!process.env.PACK_ALL;
module.exports = { module.exports = {
entry: "./src/index.ts", entry: './src/index.ts',
mode: "production", mode: 'production',
target: "node", target: 'node',
devtool: "source-map", devtool: 'source-map',
module: { module: {
rules: [ rules: [
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: "ts-loader", use: 'ts-loader',
exclude: /node_modules/, exclude: /node_modules/,
}, },
{ test: /\.mustache$/, use: "raw-loader" }, { test: /\.mustache$/, use: 'raw-loader' },
], ],
}, },
resolve: { resolve: {
extensions: [".tsx", ".ts", ".js"], extensions: ['.tsx', '.ts', '.js'],
}, },
output: { output: {
filename: "index.js", filename: 'index.js',
library: { library: {
type: "commonjs", type: 'commonjs',
}, },
path: path.resolve(__dirname, "dist"), path: path.resolve(__dirname, packAll ? 'dist/full' : 'dist'),
}, },
externals: { externals: {
'koishi': 'koishi', koishi: 'koishi',
} ...(packAll ? {} : externalsFromDep()),
},
}; };
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