feat(plugins): move install records to managed ledger

This commit is contained in:
Vincent Koc
2026-04-25 11:36:42 -07:00
parent e473577eaa
commit 888448facc
31 changed files with 721 additions and 74 deletions

View File

@@ -42,6 +42,13 @@ import {
resolveGlobalInstallSpec,
} from "../../infra/update-global.js";
import { runGatewayUpdate, type UpdateRunResult } from "../../infra/update-runner.js";
import {
loadPluginInstallRecords,
PLUGIN_INSTALLS_CONFIG_PATH,
withoutPluginInstallRecords,
writePersistedPluginInstallLedger,
withPluginInstallRecords,
} from "../../plugins/install-ledger-store.js";
import { syncPluginsForUpdateChannel, updateNpmInstalledPlugins } from "../../plugins/update.js";
import { runCommandWithTimeout } from "../../process/exec.js";
import { defaultRuntime } from "../../runtime.js";
@@ -577,8 +584,11 @@ async function updatePluginsAfterCoreUpdate(params: {
defaultRuntime.log(theme.heading("Updating plugins..."));
}
const syncResult = await syncPluginsForUpdateChannel({
const pluginInstallRecords = await loadPluginInstallRecords({
config: params.configSnapshot.sourceConfig,
});
const syncResult = await syncPluginsForUpdateChannel({
config: withPluginInstallRecords(params.configSnapshot.sourceConfig, pluginInstallRecords),
channel: params.channel,
workspaceDir: params.root,
externalizedBundledPluginBridges: await listPersistedBundledPluginLocationBridges({
@@ -620,12 +630,15 @@ async function updatePluginsAfterCoreUpdate(params: {
pluginConfig = npmResult.config;
if (syncResult.changed || npmResult.changed) {
await writePersistedPluginInstallLedger(pluginConfig.plugins?.installs ?? {});
const nextConfig = withoutPluginInstallRecords(pluginConfig);
await replaceConfigFile({
nextConfig: pluginConfig,
nextConfig,
baseHash: params.configSnapshot.hash,
writeOptions: { unsetPaths: [Array.from(PLUGIN_INSTALLS_CONFIG_PATH)] },
});
await refreshPluginRegistryAfterConfigMutation({
config: pluginConfig,
config: nextConfig,
reason: "source-changed",
workspaceDir: params.root,
logger: pluginLogger,