From ecb9bbd3e8e8a82f6426a5da7f6491056a4162c6 Mon Sep 17 00:00:00 2001 From: murat Date: Fri, 24 Apr 2026 05:11:30 -0500 Subject: [PATCH] fix: installer live version for external modules --- tools/installer/ui.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/installer/ui.js b/tools/installer/ui.js index 26b3619c1..266e04694 100644 --- a/tools/installer/ui.js +++ b/tools/installer/ui.js @@ -4,14 +4,28 @@ const fs = require('./fs-native'); const { CLIUtils } = require('./cli-utils'); const { ExternalModuleManager } = require('./modules/external-manager'); const { resolveModuleVersion } = require('./modules/version-resolver'); +const { Manifest } = require('./core/manifest'); const prompts = require('./prompts'); /** * Read a module version from the freshest local metadata available. * @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 */ -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); return versionInfo.version || ''; } @@ -611,9 +625,9 @@ class UI { const initialValues = []; 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 version = await getModuleVersion(code); + const version = await getModuleVersion(code, npmPackage); const label = version ? `${name} (v${version})` : name; return { label, @@ -628,7 +642,7 @@ class UI { for (const mod of builtInModules) { const code = mod.id; 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 }); if (entry.selected) { initialValues.push(code); @@ -638,7 +652,7 @@ class UI { // Add external registry modules (skip built-in duplicates) for (const mod of registryModules) { 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 }); if (entry.selected) { initialValues.push(mod.code);