Skip to content

Commit

Permalink
docs CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Jul 31, 2024
1 parent a095453 commit 61e40a9
Show file tree
Hide file tree
Showing 27 changed files with 43 additions and 13 deletions.
1 change: 1 addition & 0 deletions core/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
6 changes: 5 additions & 1 deletion core/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export type Element = {
export class Adapter<I extends object = object, M = {}> extends EventEmitter {
bots: Adapter.Bot<I>[] = [];
elements: Element[] = [];
private __IS_ZHIN_ADAPTER__ = true;
app: App | null = null;
static isAdapter(obj: any): obj is Adapter {
return typeof obj === 'object' && !!obj['__IS_ZHIN_ADAPTER__'];
}
schemas: Schema = Schema.object({
unique_id: Schema.string('请输入机器人唯一标识'),
master: Schema.string('请输入主人id'),
Expand Down Expand Up @@ -174,7 +178,7 @@ export namespace Adapter {
} catch {}
if (!result) continue;
result = result.default || result;
if (!(result instanceof Adapter)) throw new Error(`${adapterPath} is not an adapter`);
if (!Adapter.isAdapter(result)) throw new Error(`${adapterPath} is not an adapter`);
return result;
}
throw new Error(`can't find adapter ${name}`);
Expand Down
12 changes: 6 additions & 6 deletions core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class App extends EventEmitter {
plugin = this.plugins.get(plugin)!;
if (!plugin) throw new Error('none plugin:' + plugin);
}
if (!(plugin instanceof Plugin)) throw new Error(`${plugin} 不是一个有效的插件`);
if (!Plugin.isPlugin(plugin)) throw new Error(`${plugin} 不是一个有效的插件`);
if (this.config.disable_plugins.indexOf(plugin.id) >= 0) remove(this.config.disable_plugins, plugin.id);
return this;
}
Expand All @@ -169,7 +169,7 @@ export class App extends EventEmitter {
plugin = this.plugins.get(plugin)!;
if (!plugin) throw new Error('plugin:' + plugin + 'no init');
}
if (!(plugin instanceof Plugin)) throw new Error(`${plugin} 不是一个有效的插件`);
if (!Plugin.isPlugin(plugin)) throw new Error(`${plugin} 不是一个有效的插件`);
if (!this.config.disable_plugins.includes(plugin.id)) {
this.config.disable_plugins.push(plugin.id);
}
Expand Down Expand Up @@ -219,10 +219,10 @@ export class App extends EventEmitter {
mount(plugin: Plugin): this;
mount(entry: Plugin | string) {
let plugin: Plugin;
if (entry instanceof Plugin) plugin = entry;
if (Plugin.isPlugin(entry)) plugin = entry;
else {
const mod = loadModule<any>(entry);
if (mod instanceof Plugin) plugin = mod;
if (Plugin.isPlugin(mod)) plugin = mod;
else plugin = this.plugins.getWithPath(entry)!;
if (typeof mod === 'function' || typeof mod['install'] === 'function') return this.use(mod);
if (!plugin) throw new Error(`"${entry}" is not a valid plugin`);
Expand Down Expand Up @@ -266,7 +266,7 @@ export class App extends EventEmitter {
if (typeof plugin === 'string') {
plugin = this.plugins.get(plugin)!;
}
if (!(plugin instanceof Plugin)) {
if (!Plugin.isPlugin(plugin)) {
this.logger.warn(`${plugin} 不是一个有效的插件,将忽略其卸载。`);
return this;
}
Expand Down Expand Up @@ -308,7 +308,7 @@ export class App extends EventEmitter {
if (loaded) break;
try {
const adapter = loadModule<any>(loadPath);
if (!(adapter instanceof Adapter)) throw new Error(`${loadPath} is not a valid adapter`);
if (!Adapter.isAdapter(adapter)) throw new Error(`${loadPath} is not a valid adapter`);
this.adapters.set(adapter.name, adapter);
loadName = adapter.name;
adapter.mount(this);
Expand Down
5 changes: 4 additions & 1 deletion core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { Schema } from './schema';
import { Config } from './config';

export interface Plugin extends Plugin.Options {}

export class Plugin extends EventEmitter {
public id: string;
public name: string = '';
private _logger?: Logger;
disposes: Function[] = [];
priority: number;
private __IS_ZHIN_PLUGIN__ = true;
isMounted: boolean = false;
[REQUIRED_KEY]: (keyof App.Services)[] = [];
filePath: string;
Expand All @@ -29,6 +29,9 @@ export class Plugin extends EventEmitter {
get status(): Plugin.Status {
return this.isMounted && !this.app!.config.disable_plugins.includes(this.id) ? 'enabled' : 'disabled';
}
static isPlugin(obj: any): obj is Plugin {
return typeof obj === 'object' && !!obj['__IS_ZHIN_PLUGIN__'];
}
services: Map<string | symbol, any> = new Map<string | symbol, any>();
commands: Map<string, Command> = new Map<string, Command>();
middlewares: Middleware[] = [];
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"vue": "latest"
},
"dependencies": {
"@changesets/cli": "^2.27.7",
"@element-plus/icons-vue": "^2.3.1",
"element-plus": "^2.7.8",
"markdown-it": "^14.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/adapters/com-wechat/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/dingtalk/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/discord/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/email/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
4 changes: 1 addition & 3 deletions packages/adapters/icqq/.npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
//npm.pkg.github.com/:_authToken=${GITHUB_AUTH_TOKEN}
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
@icqqjs:registry=https://npm.pkg.github.com
always-auth=true
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/kritor/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/mock/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/onebot-11/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/onebot-12/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/qq/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/adapters/web-wechat/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/plugins/groupManage/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/plugins/guildManage/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/plugins/qa/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/plugins/schedule/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/services/http-server/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/services/sandbox/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/services/screenshot/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions packages/services/upyun/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
2 changes: 1 addition & 1 deletion test/.npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
@icqqjs:registry=https://npm.pkg.github.com
always-auth=true
registry = https://registry.npmmirror.com
1 change: 1 addition & 0 deletions zhin/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry = https://registry.npmmirror.com
6 changes: 5 additions & 1 deletion zhin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@
},
"peerDependencies": {
"level": "^8.0.1",
"redis": "^4.6.15"
"redis": "^4.6.15",
"mysql2": "^3.11.0"
},
"peerDependenciesMeta": {
"level": {
"optional": true
},
"redis": {
"optional": true
},
"mysql2": {
"optional": true
}
}
}

0 comments on commit 61e40a9

Please sign in to comment.