mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 06:30:45 +08:00
Add unified IM channel plugin
This commit is contained in:
commit
b8bd681a79
26 changed files with 7901 additions and 0 deletions
24
plugin-src/host/build.mjs
Normal file
24
plugin-src/host/build.mjs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { mkdir } from 'node:fs/promises';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { build } from 'esbuild';
|
||||
|
||||
const sourceDirectory = dirname(fileURLToPath(import.meta.url));
|
||||
const packageRoot = resolve(sourceDirectory, '../..');
|
||||
const outputPath = resolve(packageRoot, 'lib/index.js');
|
||||
|
||||
await mkdir(dirname(outputPath), { recursive: true });
|
||||
await build({
|
||||
entryPoints: [resolve(sourceDirectory, 'index.mjs')],
|
||||
bundle: true,
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
target: ['node22'],
|
||||
packages: 'external',
|
||||
outfile: outputPath,
|
||||
sourcemap: false,
|
||||
legalComments: 'none',
|
||||
});
|
||||
|
||||
console.log(`Wrote ${outputPath}`);
|
||||
22
plugin-src/host/index.mjs
Normal file
22
plugin-src/host/index.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { apply as applyFeishu } from '@xmanrui/dsh-feishu';
|
||||
import { apply as applyWeixin } from '@xmanrui/dsh-weixin';
|
||||
|
||||
export const name = 'dsh-im-host';
|
||||
export const inject = ['connection', 'credentials', 'webServer'];
|
||||
|
||||
export function createImHostPlugin(internals = {}) {
|
||||
const startFeishu = internals.applyFeishu ?? applyFeishu;
|
||||
const startWeixin = internals.applyWeixin ?? applyWeixin;
|
||||
return Object.freeze({
|
||||
name,
|
||||
inject,
|
||||
async apply(ctx, config = {}) {
|
||||
await startFeishu(ctx, config.feishu ?? {});
|
||||
await startWeixin(ctx, config.weixin ?? {});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function apply(ctx, config = {}) {
|
||||
return createImHostPlugin().apply(ctx, config);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue