Commit fa614711 authored by nanahira's avatar nanahira

catchup

parent cb53fbf2
......@@ -23,7 +23,7 @@ upload_to_minio:
tags:
- linux
script:
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/ s3://nanahira/koishi-plugin/cache-memcached
- aws s3 --endpoint=https://minio.mycard.moe:9000 sync --delete dist/full/ s3://nanahira/koishi-plugin/cache-memcached
only:
- master
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"scripts": {
"lint": "eslint --fix .",
"build": "webpack"
"build": "webpack && env PACK_ALL=1 webpack"
},
"repository": {
"type": "git",
......@@ -31,24 +31,24 @@
"homepage": "https://github.com/koishijs/koishi-plugin-cache-memcached",
"dependencies": {
"@types/memjs": "^1.2.3",
"source-map-support": "^0.5.20"
"schemastery-gen": "^1.0.3",
"source-map-support": "^0.5.20",
"memjs": "^1.3.0",
"moment": "^2.29.1",
"encoded-buffer": "^0.2.6"
},
"peerDependencies": {
"koishi": "^4.0.0-alpha.10"
"koishi": "^4.0.0-beta-2"
},
"devDependencies": {
"@types/moment": "^2.13.0",
"@types/node": "^16.11.1",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"encoded-buffer": "^0.2.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"koishi": "^4.0.0-alpha.10",
"koishi-utils-schemagen": "^1.1.7",
"memjs": "^1.3.0",
"moment": "^2.29.1",
"koishi": "^4.0.0-beta.2",
"prettier": "^2.4.1",
"raw-loader": "^4.0.2",
"ts-loader": "^9.2.6",
......
import 'source-map-support/register';
import { DefineSchema } from 'koishi-utils-schemagen';
import { ClientOptions } from 'memjs';
import { RegisterSchema, DefineSchema } from 'schemastery-gen';
@RegisterSchema()
export class MemcachedCachePluginConfig {
@DefineSchema({ desc: 'Memcached 服务器地址', default: 'localhost:11211' })
endpoint: string;
......
import 'source-map-support/register';
import { Context } from 'koishi';
import { MemcachedCache, MemcachedCachePlugin } from './plugin';
import { MemcachedCachePluginConfigLike } from './config';
import { MemcachedCachePluginConfig } from './config';
export * from './config';
export * from './plugin';
export const name = 'memcached';
const plugin = new MemcachedCachePlugin();
export const schema = plugin.schema;
export function apply(
ctx: Context,
config: Partial<MemcachedCachePluginConfigLike>,
) {
export function apply(ctx: Context, config: MemcachedCachePluginConfig) {
ctx.plugin(plugin, config);
}
......@@ -4,13 +4,14 @@ import {
MemcachedCachePluginConfig,
MemcachedCachePluginConfigLike,
} from './config';
import { schemaFromClass, schemaTransform } from 'koishi-utils-schemagen';
import { Client } from 'memjs';
import { Moment } from 'moment';
import moment from 'moment';
import * as EncodeBuffer from 'encoded-buffer';
export class MemcachedCache extends Cache {
protected start(): void | Promise<void> {}
protected stop(): void | Promise<void> {}
private logger = new Logger('memcached');
private mem: Client;
constructor(ctx: Context, private config: MemcachedCachePluginConfig) {
......@@ -148,12 +149,10 @@ export class MemcachedCachePlugin {
private config: MemcachedCachePluginConfig;
private ctx: Context;
name = 'memcached-main';
schema: Schema<MemcachedCachePluginConfigLike> = schemaFromClass(
MemcachedCachePluginConfig,
);
apply(ctx: Context, config: MemcachedCachePluginConfigLike) {
schema = MemcachedCachePluginConfig;
apply(ctx: Context, config: MemcachedCachePluginConfig) {
this.ctx = ctx;
this.config = schemaTransform(MemcachedCachePluginConfig, config);
this.config = config;
ctx.cache = new MemcachedCache(ctx, this.config);
}
}
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 = {
entry: "./src/index.ts",
mode: "production",
target: "node",
devtool: "source-map",
entry: './src/index.ts',
mode: 'production',
target: 'node',
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
use: 'ts-loader',
exclude: /node_modules/,
},
{ test: /\.mustache$/, use: "raw-loader" },
{ test: /\.mustache$/, use: 'raw-loader' },
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
extensions: ['.tsx', '.ts', '.js'],
},
output: {
filename: "index.js",
filename: 'index.js',
library: {
type: "commonjs",
type: 'commonjs',
},
path: path.resolve(__dirname, "dist"),
path: path.resolve(__dirname, packAll ? 'dist/full' : 'dist'),
},
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