Commit 774aef24 authored by nanahira's avatar nanahira

catchup

parent 589953bb
......@@ -16,17 +16,6 @@ build:
paths:
- dist/
upload_to_minio:
stage: deploy
dependencies:
- build
tags:
- linux
script:
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/ s3://nanahira/koishi-plugin/ygocard
only:
- master
deploy_npm:
stage: deploy
dependencies:
......
This diff is collapsed.
import { DefineSchema, UseSchema } from 'koishi-utils-schemagen';
import { DefineSchema, RegisterSchema } from 'schemastery-gen';
import { Schema } from 'koishi';
import { YGOProCardLike } from './YGOProCard';
import _ from 'lodash';
import { renderTemplate } from './utility';
@RegisterSchema()
export class YGOCardConfig {
@DefineSchema({ type: 'string', desc: '命令名', default: 'card' })
commandName: string;
......@@ -19,7 +20,9 @@ export class YGOCardConfig {
@DefineSchema({ type: 'number', default: 100, desc: '查询最多显示的数量' })
matchCount: number;
@UseSchema(Schema.select(['cn', 'en'], '显示语言').default('cn'))
@DefineSchema({
schema: Schema.select(['cn', 'en'], '显示语言').default('cn'),
})
lang: 'cn' | 'en';
@DefineSchema({ type: 'boolean', desc: '是否展示卡图', default: true })
......
import 'source-map-support/register';
import { Context } from 'koishi';
import { Config, MyPlugin } from './plugin';
export { Config } from './plugin';
import { MyPlugin } from './plugin';
import { YGOCardConfig } from './config';
export * from './plugin';
export * from './config';
export const name = 'ygocard';
const plugin = new MyPlugin();
export const schema = plugin.schema;
export function apply(ctx: Context, config: Config) {
export function apply(ctx: Context, config: YGOCardConfig) {
ctx.plugin(plugin, config);
}
import 'source-map-support/register';
import { Context, Schema } from 'koishi';
import { Context } from 'koishi';
import { YGOCardConfig } from './config';
import { schemaFromClass, schemaTransform } from 'koishi-utils-schemagen';
import sqlite, { Database } from 'better-sqlite3';
import { promises as fs } from 'fs';
import _ from 'lodash';
......@@ -16,7 +15,7 @@ export class MyPlugin {
private ctx: Context;
private dbs: Database[] = [];
name = 'ygocard-main';
schema: Schema<Config> = schemaFromClass(YGOCardConfig);
schema = YGOCardConfig;
private queryInDB(value: string, db: Database) {
const possibleValueNumber = parseInt(value) || 0;
const statement = db.prepare<[number, string, string]>(
......@@ -55,9 +54,9 @@ export class MyPlugin {
}),
);
}
async apply(ctx: Context, config: Config) {
async apply(ctx: Context, config: YGOCardConfig) {
this.ctx = ctx;
this.config = schemaTransform(YGOCardConfig, config);
this.config = config;
await this.loadDBs();
ctx.on('connect', () => this.loadDBs());
ctx.on('disconnect', () => {
......
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 = {
entry: './src/index.ts',
......@@ -23,10 +37,10 @@ module.exports = {
library: {
type: 'commonjs',
},
path: path.resolve(__dirname, 'dist'),
path: path.resolve(__dirname, packAll ? 'dist/full' : 'dist'),
},
externals: {
koishi: 'koishi',
'better-sqlite3': 'better-sqlite3',
...(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