Compare commits

...

1 Commits

Author SHA1 Message Date
murat ecb9bbd3e8 fix: installer live version for external modules 2026-04-24 05:11:30 -05:00
1 changed files with 19 additions and 5 deletions

View File

@ -4,14 +4,28 @@ const fs = require('./fs-native');
const { CLIUtils } = require('./cli-utils'); 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 prompts = require('./prompts'); const prompts = require('./prompts');
/** /**
* Read a module version from the freshest local metadata available. * Read a module version from the freshest local metadata available.
* @param {string} moduleCode - Module code (e.g., 'core', 'bmm', 'cis') * @param {string} moduleCode - Module code (e.g., 'core', 'bmm', 'cis')
* @param {string|null} npmPackage - npm package name for live version lookup
* @returns {string} Version string or empty string * @returns {string} Version string or empty string
*/ */
async function getModuleVersion(moduleCode) { async function getModuleVersion(moduleCode, npmPackage = null) {
if (npmPackage) {
try {
const manifest = new Manifest();
const npmVersion = await manifest.fetchNpmVersion(npmPackage);
if (npmVersion) {
return npmVersion;
}
} catch {
// Fall back to local metadata when npm is unreachable.
}
}
const versionInfo = await resolveModuleVersion(moduleCode); const versionInfo = await resolveModuleVersion(moduleCode);
return versionInfo.version || ''; return versionInfo.version || '';
} }
@ -611,9 +625,9 @@ class UI {
const initialValues = []; const initialValues = [];
const lockedValues = ['core']; const lockedValues = ['core'];
const buildModuleEntry = async (code, name, description, isDefault) => { const buildModuleEntry = async (code, name, description, isDefault, npmPackage = null) => {
const isInstalled = installedModuleIds.has(code); const isInstalled = installedModuleIds.has(code);
const version = await getModuleVersion(code); const version = await getModuleVersion(code, npmPackage);
const label = version ? `${name} (v${version})` : name; const label = version ? `${name} (v${version})` : name;
return { return {
label, label,
@ -628,7 +642,7 @@ class UI {
for (const mod of builtInModules) { for (const mod of builtInModules) {
const code = mod.id; const code = mod.id;
builtInCodes.add(code); builtInCodes.add(code);
const entry = await buildModuleEntry(code, mod.name, mod.description, mod.defaultSelected); const entry = await buildModuleEntry(code, mod.name, mod.description, mod.defaultSelected, mod.npmPackage || null);
allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint }); allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint });
if (entry.selected) { if (entry.selected) {
initialValues.push(code); initialValues.push(code);
@ -638,7 +652,7 @@ class UI {
// Add external registry modules (skip built-in duplicates) // Add external registry modules (skip built-in duplicates)
for (const mod of registryModules) { for (const mod of registryModules) {
if (mod.builtIn || builtInCodes.has(mod.code)) continue; if (mod.builtIn || builtInCodes.has(mod.code)) continue;
const entry = await buildModuleEntry(mod.code, mod.name, mod.description, mod.defaultSelected); const entry = await buildModuleEntry(mod.code, mod.name, mod.description, mod.defaultSelected, mod.npmPackage || null);
allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint }); allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint });
if (entry.selected) { if (entry.selected) {
initialValues.push(mod.code); initialValues.push(mod.code);