fix(plugins): harden registry migration guards

This commit is contained in:
Vincent Koc
2026-04-25 04:25:16 -07:00
parent f22a2f7e8b
commit ad8296e685
4 changed files with 60 additions and 19 deletions

View File

@@ -330,22 +330,23 @@ describe("bundled plugin postinstall", () => {
});
it("honors plugin registry postinstall migration disable env", async () => {
const migratePluginRegistryForInstall = vi.fn(async () => ({
status: "disabled",
migrated: false,
preflight: {
deprecationWarnings: [],
},
}));
const importModule = vi.fn(async () => {
throw new Error("dist migration module should not import when migration is disabled");
});
await expect(
runPluginRegistryPostinstallMigration({
packageRoot: "/pkg",
env: { OPENCLAW_DISABLE_PLUGIN_REGISTRY_MIGRATION: "1" },
existsSync: vi.fn(() => true),
importModule: vi.fn(async () => ({ migratePluginRegistryForInstall })),
importModule,
log: { log: vi.fn(), warn: vi.fn() },
}),
).resolves.toMatchObject({ status: "disabled" });
).resolves.toMatchObject({
status: "disabled",
migrated: false,
reason: "disabled-env",
});
expect(importModule).not.toHaveBeenCalled();
});
it("prunes stale dist files from packaged installs", async () => {