fix: repair bundled channel secret sidecars

This commit is contained in:
Peter Steinberger
2026-04-08 04:56:58 +01:00
parent 5982f2e5e4
commit d03fa0899f
34 changed files with 67 additions and 30 deletions

View File

@@ -1,4 +1,5 @@
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
listBundledPluginBuildEntries,
@@ -49,15 +50,40 @@ describe("bundled plugin build entries", () => {
expect(artifacts).toContain("dist/extensions/matrix/plugin-entry.handlers.runtime.js");
});
it("keeps the Telegram setup entry on packed top-level sidecars", () => {
const setupEntry = fs.readFileSync("extensions/telegram/setup-entry.ts", "utf8");
it("keeps bundled channel secret contracts on packed top-level sidecars", () => {
const artifacts = listBundledPluginPackArtifacts();
const sourceEntries = ["index.ts", "channel-entry.ts", "setup-entry.ts"];
const offenders: string[] = [];
const secretBackedPluginIds = new Set<string>();
expect(setupEntry).toContain('specifier: "./setup-plugin-api.js"');
expect(setupEntry).toContain('specifier: "./secret-contract-api.js"');
expect(setupEntry).not.toContain("./src/channel.setup.js");
expect(setupEntry).not.toContain("./src/secret-contract.js");
expect(artifacts).toContain("dist/extensions/telegram/setup-plugin-api.js");
expect(artifacts).toContain("dist/extensions/telegram/secret-contract-api.js");
for (const dirent of fs.readdirSync("extensions", { withFileTypes: true })) {
if (!dirent.isDirectory()) {
continue;
}
for (const sourceEntry of sourceEntries) {
const entryPath = path.join("extensions", dirent.name, sourceEntry);
if (!fs.existsSync(entryPath)) {
continue;
}
const entry = fs.readFileSync(entryPath, "utf8");
if (!entry.includes('exportName: "channelSecrets"')) {
continue;
}
secretBackedPluginIds.add(dirent.name);
if (entry.includes("./src/secret-contract.js")) {
offenders.push(entryPath);
}
expect(entry).toContain('specifier: "./secret-contract-api.js"');
}
}
expect(offenders).toEqual([]);
for (const pluginId of [...secretBackedPluginIds].toSorted()) {
const secretApiPath = path.join("extensions", pluginId, "secret-contract-api.ts");
expect(fs.readFileSync(secretApiPath, "utf8")).toContain("channelSecrets");
expect(artifacts).toContain(`dist/extensions/${pluginId}/secret-contract-api.js`);
}
});
});