( name: string, autoUpdate: boolean, )
| 2585 | * @throws If marketplace not found |
| 2586 | */ |
| 2587 | export async function setMarketplaceAutoUpdate( |
| 2588 | name: string, |
| 2589 | autoUpdate: boolean, |
| 2590 | ): Promise<void> { |
| 2591 | const config = await loadKnownMarketplacesConfig() |
| 2592 | const entry = config[name] |
| 2593 | |
| 2594 | if (!entry) { |
| 2595 | throw new Error( |
| 2596 | `Marketplace '${name}' not found. Available marketplaces: ${Object.keys(config).join(', ')}`, |
| 2597 | ) |
| 2598 | } |
| 2599 | |
| 2600 | // Seed-managed marketplaces always have autoUpdate: false (read-only, git-pull |
| 2601 | // would fail). Toggle appears to work but registerSeedMarketplaces overwrites |
| 2602 | // it on next startup. Error with guidance instead of silent revert. |
| 2603 | const seedDir = seedDirFor(entry.installLocation) |
| 2604 | if (seedDir) { |
| 2605 | throw new Error( |
| 2606 | `Marketplace '${name}' is seed-managed (${seedDir}) and ` + |
| 2607 | `auto-update is always disabled for seed content. ` + |
| 2608 | `To update: ask your admin to update the seed.`, |
| 2609 | ) |
| 2610 | } |
| 2611 | |
| 2612 | // Only update if the value is actually changing |
| 2613 | if (entry.autoUpdate === autoUpdate) { |
| 2614 | return |
| 2615 | } |
| 2616 | |
| 2617 | config[name] = { |
| 2618 | ...entry, |
| 2619 | autoUpdate, |
| 2620 | } |
| 2621 | await saveKnownMarketplacesConfig(config) |
| 2622 | |
| 2623 | // Also update intent in settings if declared there — write to the SAME |
| 2624 | // source that declared it to avoid creating duplicates at wrong scope |
| 2625 | const declaringSource = getMarketplaceDeclaringSource(name) |
| 2626 | if (declaringSource) { |
| 2627 | const declared = |
| 2628 | getSettingsForSource(declaringSource)?.extraKnownMarketplaces?.[name] |
| 2629 | if (declared) { |
| 2630 | saveMarketplaceToSettings( |
| 2631 | name, |
| 2632 | { source: declared.source, autoUpdate }, |
| 2633 | declaringSource, |
| 2634 | ) |
| 2635 | } |
| 2636 | } |
| 2637 | |
| 2638 | logForDebugging(`Set autoUpdate=${autoUpdate} for marketplace: ${name}`) |
| 2639 | } |
| 2640 | |
| 2641 | export const _test = { |
| 2642 | redactUrlCredentials, |
no test coverage detected