Commit f223b288 authored by nanahira's avatar nanahira

catchup

parent a5592430
...@@ -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/srvpro-roomlist - aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/full/ s3://nanahira/koishi-plugin/srvpro-roomlist
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",
...@@ -28,25 +28,24 @@ ...@@ -28,25 +28,24 @@
}, },
"homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-srvpro-roomlist", "homepage": "https://code.mycard.moe/3rdeye/koishi-plugin-srvpro-roomlist",
"dependencies": { "dependencies": {
"source-map-support": "^0.5.20" "schemastery-gen": "^1.0.3",
"source-map-support": "^0.5.20",
"lodash": "^4.17.21",
"class-transformer": "^0.4.0"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.0.0-alpha.9" "koishi": "^4.0.0-beta.2"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.14.175", "@types/lodash": "^4.14.175",
"@types/node": "^16.11.1", "@types/node": "^16.11.1",
"@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",
"class-transformer": "^0.4.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",
"koishi": "^4.0.0-alpha.9", "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, SchemaConf } from 'koishi-utils-schemagen';
import { Context } from 'koishi'; import { Context } from 'koishi';
import { SRVProRoomInfo } from './def'; import { SRVProRoomInfo } from './def';
import { plainToClass } from 'class-transformer'; import { plainToClass } from 'class-transformer';
import { RegisterSchema, DefineSchema } from 'schemastery-gen';
export interface ServerLike { export interface ServerLike {
name: string; name: string;
...@@ -15,7 +15,7 @@ export interface ServerLike { ...@@ -15,7 +15,7 @@ export interface ServerLike {
displayPlayerIp?: boolean; displayPlayerIp?: boolean;
} }
@SchemaConf({ desc: 'SRVPro 服务器' }) @RegisterSchema({ desc: 'SRVPro 服务器' })
export class Server implements ServerLike { export class Server implements ServerLike {
@DefineSchema({ desc: '服务器名称', required: true }) @DefineSchema({ desc: '服务器名称', required: true })
name: string; name: string;
...@@ -69,7 +69,7 @@ export interface MyPluginConfigLike { ...@@ -69,7 +69,7 @@ export interface MyPluginConfigLike {
servers: ServerLike[]; servers: ServerLike[];
} }
@SchemaConf({ required: true }) @RegisterSchema({ required: true })
export class MyPluginConfig implements MyPluginConfigLike { export class MyPluginConfig implements MyPluginConfigLike {
@DefineSchema({ desc: '服务器列表命令名', default: 'serverlist' }) @DefineSchema({ desc: '服务器列表命令名', default: 'serverlist' })
listCommandName: string; listCommandName: string;
......
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 { MyPluginConfig, MyPluginConfigLike } from './config'; import { MyPluginConfig } from './config';
export { MyPluginConfig } from './config'; export { MyPluginConfig } from './config';
export const name = 'srvpro-roomlist'; export const name = 'srvpro-roomlist';
const plugin = new MyPlugin(); const plugin = new MyPlugin();
export const schema = plugin.schema; export const schema = plugin.schema;
export function apply(ctx: Context, config: MyPluginConfigLike) { export function apply(ctx: Context, config: MyPluginConfig) {
ctx.plugin(plugin, config); ctx.plugin(plugin, config);
} }
import 'source-map-support/register'; import 'source-map-support/register';
import { Context, Schema } from 'koishi'; import { Context } from 'koishi';
import { MyPluginConfig, MyPluginConfigLike } from './config'; import { MyPluginConfig } from './config';
import { schemaFromClass, schemaTransform } from 'koishi-utils-schemagen';
export class MyPlugin { export class MyPlugin {
private config: MyPluginConfig; private config: MyPluginConfig;
private ctx: Context; private ctx: Context;
name = 'srvpro-roomlist-main'; name = 'srvpro-roomlist-main';
schema: Schema<MyPluginConfigLike> = schemaFromClass(MyPluginConfig); schema = MyPluginConfig;
apply(ctx: Context, config: MyPluginConfigLike) { apply(ctx: Context, config: MyPluginConfig) {
this.ctx = ctx; this.ctx = ctx;
this.config = schemaTransform(MyPluginConfig, config); this.config = config;
ctx ctx
.command(`${this.config.listCommandName}`, '获取服务器列表') .command(`${this.config.listCommandName}`, '获取服务器列表')
.action( .action(
......
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