|
| 1 | +import fs from "node:fs/promises"; |
| 2 | +import os from "node:os"; |
| 3 | +import path from "node:path"; |
| 4 | +import { pathToFileURL } from "node:url"; |
| 5 | +import { build } from "tsdown"; |
1 | 6 | import { describe, expect, it } from "vitest"; |
2 | 7 | import * as sdk from "./index.js"; |
3 | 8 |
|
| 9 | +const pluginSdkEntrypoints = [ |
| 10 | + "index", |
| 11 | + "core", |
| 12 | + "compat", |
| 13 | + "telegram", |
| 14 | + "discord", |
| 15 | + "slack", |
| 16 | + "signal", |
| 17 | + "imessage", |
| 18 | + "whatsapp", |
| 19 | + "line", |
| 20 | + "msteams", |
| 21 | + "acpx", |
| 22 | + "bluebubbles", |
| 23 | + "copilot-proxy", |
| 24 | + "device-pair", |
| 25 | + "diagnostics-otel", |
| 26 | + "diffs", |
| 27 | + "feishu", |
| 28 | + "google-gemini-cli-auth", |
| 29 | + "googlechat", |
| 30 | + "irc", |
| 31 | + "llm-task", |
| 32 | + "lobster", |
| 33 | + "matrix", |
| 34 | + "mattermost", |
| 35 | + "memory-core", |
| 36 | + "memory-lancedb", |
| 37 | + "minimax-portal-auth", |
| 38 | + "nextcloud-talk", |
| 39 | + "nostr", |
| 40 | + "open-prose", |
| 41 | + "phone-control", |
| 42 | + "qwen-portal-auth", |
| 43 | + "synology-chat", |
| 44 | + "talk-voice", |
| 45 | + "test-utils", |
| 46 | + "thread-ownership", |
| 47 | + "tlon", |
| 48 | + "twitch", |
| 49 | + "voice-call", |
| 50 | + "zalo", |
| 51 | + "zalouser", |
| 52 | + "account-id", |
| 53 | + "keyed-async-queue", |
| 54 | +] as const; |
| 55 | + |
4 | 56 | describe("plugin-sdk exports", () => { |
5 | 57 | it("does not expose runtime modules", () => { |
6 | 58 | const forbidden = [ |
@@ -104,4 +156,31 @@ describe("plugin-sdk exports", () => { |
104 | 156 | expect(sdk).toHaveProperty(key); |
105 | 157 | } |
106 | 158 | }); |
| 159 | + |
| 160 | + it("emits importable bundled subpath entries", { timeout: 240_000 }, async () => { |
| 161 | + const outDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-plugin-sdk-build-")); |
| 162 | + |
| 163 | + try { |
| 164 | + await build({ |
| 165 | + clean: true, |
| 166 | + config: false, |
| 167 | + dts: false, |
| 168 | + entry: Object.fromEntries( |
| 169 | + pluginSdkEntrypoints.map((entry) => [entry, `src/plugin-sdk/${entry}.ts`]), |
| 170 | + ), |
| 171 | + env: { NODE_ENV: "production" }, |
| 172 | + fixedExtension: false, |
| 173 | + logLevel: "error", |
| 174 | + outDir, |
| 175 | + platform: "node", |
| 176 | + }); |
| 177 | + |
| 178 | + for (const entry of pluginSdkEntrypoints) { |
| 179 | + const module = await import(pathToFileURL(path.join(outDir, `${entry}.js`)).href); |
| 180 | + expect(module).toBeTypeOf("object"); |
| 181 | + } |
| 182 | + } finally { |
| 183 | + await fs.rm(outDir, { recursive: true, force: true }); |
| 184 | + } |
| 185 | + }); |
107 | 186 | }); |
0 commit comments