Internalize all IM channel implementations

This commit is contained in:
xmanrui 2026-08-15 15:40:53 +08:00
parent 8996476693
commit bd469f58f8
95 changed files with 25012 additions and 100 deletions

View file

@ -9,14 +9,24 @@ const required = [
'cordis.patch.yml',
'README.md',
'THIRD_PARTY_NOTICES.md',
'plugin-src/client/channels/dingtalk/index.js',
'plugin-src/host/channels/feishu/index.mjs',
'plugin-src/host/channels/weixin/index.mjs',
'plugin-src/host/channels/dingtalk/index.mjs',
'src/channels/feishu/feishu-runtime.mjs',
'src/channels/weixin/weixin-runtime.mjs',
'src/channels/dingtalk/dingtalk-runtime.mjs',
];
await Promise.all(required.map((path) => access(resolve(root, path))));
const [client, host, patch, manifestText, executable] = await Promise.all([
const [client, host, patch, manifestText, lockText, hostSource, clientSource, executable] = await Promise.all([
readFile(resolve(root, 'lib/client.js'), 'utf8'),
readFile(resolve(root, 'lib/index.js'), 'utf8'),
readFile(resolve(root, 'cordis.patch.yml'), 'utf8'),
readFile(resolve(root, 'package.json'), 'utf8'),
readFile(resolve(root, 'package-lock.json'), 'utf8'),
readFile(resolve(root, 'plugin-src/host/index.mjs'), 'utf8'),
readFile(resolve(root, 'plugin-src/client/index.js'), 'utf8'),
stat(resolve(root, 'bin/dsh-im.mjs')),
]);
const manifest = JSON.parse(manifestText);
@ -37,19 +47,35 @@ if (!client.includes('container-type: inline-size')
|| !client.includes('@container (max-width: 680px)')) {
throw new Error('client bundle does not contain the narrow-panel DingTalk QR layout');
}
if (!host.includes('@xmanrui/dsh-feishu')
|| !host.includes('@xmanrui/dsh-weixin')
|| !host.includes('@xmanrui/dsh-dingtalk')) {
throw new Error('host bundle does not compose all three channel providers');
for (const marker of ['/feishu', '/weixin', '/dingtalk']) {
if (!host.includes(marker)) {
throw new Error(`host bundle does not contain the internal ${marker} RPC provider`);
}
}
if (/@xmanrui\/dsh-(?:feishu|weixin|dingtalk)/.test(host)) {
throw new Error('host bundle still imports an external channel plugin');
}
if (/@xmanrui\/dsh-(?:feishu|weixin|dingtalk)/.test(
manifestText + lockText + hostSource + clientSource,
)) {
throw new Error('source or package metadata still depends on an external channel plugin');
}
if (!patch.includes("name: '@xmanrui/dsh-im'") || /dsh-(?:feishu|weixin|dingtalk)/.test(patch)) {
throw new Error('bundle patch must activate only dsh-im');
}
for (const name of ['@xmanrui/dsh-feishu', '@xmanrui/dsh-weixin', '@xmanrui/dsh-dingtalk']) {
const spec = manifest.dependencies?.[name];
if (typeof spec !== 'string'
|| !/^https:\/\/github\.com\/[^/]+\/[^/]+\/archive\/[0-9a-f]{40}\.tar\.gz$/.test(spec)) {
throw new Error(`${name} must use a pinned public HTTPS archive`);
if (manifest.dependencies?.[name]) {
throw new Error(`${name} must not remain an external dependency`);
}
}
const directDependencies = {
'@larksuiteoapi/node-sdk': '1.73.0',
'dingtalk-stream': '2.1.4',
qrcode: '1.5.4',
};
for (const [name, version] of Object.entries(directDependencies)) {
if (manifest.dependencies?.[name] !== version) {
throw new Error(`${name} must be a pinned direct dependency at ${version}`);
}
}
if ((executable.mode & 0o111) === 0) throw new Error('dsh-im CLI is not executable');