test: remove remaining legacy warning mock leaks
This commit is contained in:
@@ -5,8 +5,17 @@ import { log } from "../../shared/logger"
|
||||
import { LEGACY_PLUGIN_NAME, PLUGIN_NAME } from "../../shared/plugin-identity"
|
||||
import { autoMigrateLegacyPluginEntry } from "./auto-migrate-runner"
|
||||
|
||||
export function createLegacyPluginToastHook(ctx: PluginInput) {
|
||||
type LegacyPluginToastDeps = {
|
||||
checkForLegacyPluginEntry?: typeof checkForLegacyPluginEntry
|
||||
log?: typeof log
|
||||
autoMigrateLegacyPluginEntry?: typeof autoMigrateLegacyPluginEntry
|
||||
}
|
||||
|
||||
export function createLegacyPluginToastHook(ctx: PluginInput, deps: LegacyPluginToastDeps = {}) {
|
||||
let fired = false
|
||||
const checkForLegacyPluginEntryFn = deps.checkForLegacyPluginEntry ?? checkForLegacyPluginEntry
|
||||
const logFn = deps.log ?? log
|
||||
const autoMigrateLegacyPluginEntryFn = deps.autoMigrateLegacyPluginEntry ?? autoMigrateLegacyPluginEntry
|
||||
|
||||
return {
|
||||
event: async ({ event }: { event: { type: string; properties?: unknown } }) => {
|
||||
@@ -17,13 +26,13 @@ export function createLegacyPluginToastHook(ctx: PluginInput) {
|
||||
|
||||
fired = true
|
||||
|
||||
const result = checkForLegacyPluginEntry()
|
||||
const result = checkForLegacyPluginEntryFn()
|
||||
if (!result.hasLegacyEntry) return
|
||||
|
||||
const migration = autoMigrateLegacyPluginEntry()
|
||||
const migration = autoMigrateLegacyPluginEntryFn()
|
||||
|
||||
if (migration.migrated) {
|
||||
log("[legacy-plugin-toast] Auto-migrated opencode.json plugin entry", {
|
||||
logFn("[legacy-plugin-toast] Auto-migrated opencode.json plugin entry", {
|
||||
from: migration.from,
|
||||
to: migration.to,
|
||||
})
|
||||
@@ -39,7 +48,7 @@ export function createLegacyPluginToastHook(ctx: PluginInput) {
|
||||
})
|
||||
.catch(() => {})
|
||||
} else {
|
||||
log("[legacy-plugin-toast] Legacy entry detected but migration failed", {
|
||||
logFn("[legacy-plugin-toast] Legacy entry detected but migration failed", {
|
||||
legacyEntries: result.legacyEntries,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user