|
| 1 | +import fs from "node:fs"; |
| 2 | +import path from "node:path"; |
1 | 3 | import { describe, expect, it } from "vitest"; |
2 | 4 | import { |
3 | 5 | getOfficialExternalPluginCatalogEntry, |
@@ -46,4 +48,41 @@ describe("official external plugin catalog", () => {
|
46 | 48 | expect(ids.has("matrix")).toBe(false); |
47 | 49 | expect(ids.has("mattermost")).toBe(false); |
48 | 50 | }); |
| 51 | + |
| 52 | +it("keeps local package install metadata aligned with external catalog specs", () => { |
| 53 | +const mismatches: string[] = []; |
| 54 | + |
| 55 | +for (const entry of listOfficialExternalPluginCatalogEntries()) { |
| 56 | +const pluginId = resolveOfficialExternalPluginId(entry); |
| 57 | +const catalogInstall = resolveOfficialExternalPluginInstall(entry); |
| 58 | +if (!pluginId || !catalogInstall) { |
| 59 | +continue; |
| 60 | +} |
| 61 | +const packagePath = path.join("extensions", pluginId, "package.json"); |
| 62 | +if (!fs.existsSync(packagePath)) { |
| 63 | +continue; |
| 64 | +} |
| 65 | +const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8")) as { |
| 66 | +openclaw?: { |
| 67 | +install?: { |
| 68 | +clawhubSpec?: string; |
| 69 | +npmSpec?: string; |
| 70 | +}; |
| 71 | +}; |
| 72 | +}; |
| 73 | +const packageInstall = packageJson.openclaw?.install ?? {}; |
| 74 | +if (packageInstall.npmSpec && packageInstall.npmSpec !== catalogInstall.npmSpec) { |
| 75 | +mismatches.push( |
| 76 | +`${pluginId} npmSpec catalog=${catalogInstall.npmSpec ?? "<none>"} package=${packageInstall.npmSpec}`, |
| 77 | +); |
| 78 | +} |
| 79 | +if (packageInstall.clawhubSpec && packageInstall.clawhubSpec !== catalogInstall.clawhubSpec) { |
| 80 | +mismatches.push( |
| 81 | +`${pluginId} clawhubSpec catalog=${catalogInstall.clawhubSpec ?? "<none>"} package=${packageInstall.clawhubSpec}`, |
| 82 | +); |
| 83 | +} |
| 84 | +} |
| 85 | + |
| 86 | +expect(mismatches).toEqual([]); |
| 87 | +}); |
49 | 88 | }); |