fix(installer): preserve source-backed modules and configs
This commit is contained in:
parent
3cf5f0b31c
commit
c11efd46d4
|
|
@ -7,6 +7,7 @@ const { CLIUtils } = require('./cli-utils');
|
||||||
const { ExternalModuleManager } = require('./modules/external-manager');
|
const { ExternalModuleManager } = require('./modules/external-manager');
|
||||||
const { resolveModuleVersion } = require('./modules/version-resolver');
|
const { resolveModuleVersion } = require('./modules/version-resolver');
|
||||||
const { Manifest } = require('./core/manifest');
|
const { Manifest } = require('./core/manifest');
|
||||||
|
const { resolveInstalledModuleYaml } = require('./project-root');
|
||||||
const {
|
const {
|
||||||
parseChannelOptions,
|
parseChannelOptions,
|
||||||
buildPlan,
|
buildPlan,
|
||||||
|
|
@ -111,41 +112,20 @@ async function getModuleVersion(moduleCode, { repoUrl = null, registryDefault =
|
||||||
*/
|
*/
|
||||||
class UI {
|
class UI {
|
||||||
async _findUnavailableInstalledModules(installedModuleIds = new Set(), bmadDir) {
|
async _findUnavailableInstalledModules(installedModuleIds = new Set(), bmadDir) {
|
||||||
const { OfficialModules } = require('./modules/official-modules');
|
const unavailable = [];
|
||||||
const availableModulesData = await new OfficialModules().listAvailable();
|
|
||||||
const availableModules = [...availableModulesData.modules];
|
|
||||||
|
|
||||||
const externalManager = new ExternalModuleManager();
|
|
||||||
const externalModules = await externalManager.listAvailable();
|
|
||||||
for (const externalModule of externalModules) {
|
|
||||||
if (installedModuleIds.has(externalModule.code) && !availableModules.some((m) => m.id === externalModule.code)) {
|
|
||||||
availableModules.push({
|
|
||||||
id: externalModule.code,
|
|
||||||
name: externalModule.name,
|
|
||||||
isExternal: true,
|
|
||||||
fromExternal: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { CustomModuleManager } = require('./modules/custom-module-manager');
|
|
||||||
const customMgr = new CustomModuleManager();
|
|
||||||
for (const moduleId of installedModuleIds) {
|
for (const moduleId of installedModuleIds) {
|
||||||
if (!availableModules.some((m) => m.id === moduleId)) {
|
if (moduleId === 'core' || moduleId === 'bmm') continue;
|
||||||
const customSource = await customMgr.findModuleSourceByCode(moduleId, { bmadDir });
|
const moduleYamlPath = await resolveInstalledModuleYaml(moduleId);
|
||||||
if (customSource) {
|
if (moduleYamlPath) continue;
|
||||||
availableModules.push({
|
|
||||||
id: moduleId,
|
|
||||||
name: moduleId,
|
|
||||||
isExternal: true,
|
|
||||||
fromCustom: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const availableModuleIds = new Set(availableModules.map((m) => m.id));
|
const { CustomModuleManager } = require('./modules/custom-module-manager');
|
||||||
return [...installedModuleIds].filter((id) => !availableModuleIds.has(id));
|
const customMgr = new CustomModuleManager();
|
||||||
|
const localSource = await customMgr.findModuleSourceByCode(moduleId, { bmadDir });
|
||||||
|
if (localSource) continue;
|
||||||
|
|
||||||
|
unavailable.push(moduleId);
|
||||||
|
}
|
||||||
|
return unavailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -339,6 +319,14 @@ class UI {
|
||||||
...options,
|
...options,
|
||||||
channelOptions,
|
channelOptions,
|
||||||
});
|
});
|
||||||
|
if (preservedModules.length > 0) {
|
||||||
|
const preservedConfigLoader = new (require('./modules/official-modules').OfficialModules)({ channelOptions });
|
||||||
|
await preservedConfigLoader.loadExistingConfig(confirmedDirectory);
|
||||||
|
for (const moduleName of preservedModules) {
|
||||||
|
if (moduleConfigs[moduleName] || !preservedConfigLoader.existingConfig?.[moduleName]) continue;
|
||||||
|
moduleConfigs[moduleName] = { ...preservedConfigLoader.existingConfig[moduleName] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Warn about --pin/--next flags that refer to modules the user didn't
|
// Warn about --pin/--next flags that refer to modules the user didn't
|
||||||
// select, or that target bundled modules (core/bmm) where channel
|
// select, or that target bundled modules (core/bmm) where channel
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue