fix(installer): guard ExistingInstall.version and surface module.yaml errors
Guard ExistingInstall.version access with .installed check in uninstall.js, ui.js, and installer.js to prevent throwing on empty/partial _bmad dirs. Surface invalid module.yaml parse errors as warnings instead of silently returning empty results.
This commit is contained in:
parent
6ab01a4c13
commit
1735c08050
|
|
@ -62,7 +62,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
const existingInstall = await installer.getStatus(projectDir);
|
||||
const version = existingInstall.version || 'unknown';
|
||||
const version = existingInstall.installed ? existingInstall.version : 'unknown';
|
||||
const modules = existingInstall.moduleIds.join(', ');
|
||||
const ides = existingInstall.ides.join(', ');
|
||||
|
||||
|
|
|
|||
|
|
@ -1360,7 +1360,7 @@ class Installer {
|
|||
removed.modules = await this.uninstallModules(projectDir);
|
||||
}
|
||||
|
||||
return { success: true, removed, version: existingInstall.version };
|
||||
return { success: true, removed, version: existingInstall.installed ? existingInstall.version : null };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -484,8 +484,9 @@ class OfficialModules {
|
|||
try {
|
||||
const yamlContent = await fs.readFile(moduleYamlPath, 'utf8');
|
||||
moduleYaml = yaml.parse(yamlContent);
|
||||
} catch {
|
||||
return emptyResult; // Invalid YAML, skip
|
||||
} catch (error) {
|
||||
await prompts.log.warn(`Invalid module.yaml for ${moduleName}: ${error.message}`);
|
||||
return emptyResult;
|
||||
}
|
||||
|
||||
if (!moduleYaml || !moduleYaml.directories) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class UI {
|
|||
const { existingInstall, bmadDir } = await this.getExistingInstallation(confirmedDirectory);
|
||||
const packageJsonPath = path.join(__dirname, '../../package.json');
|
||||
const currentVersion = require(packageJsonPath).version;
|
||||
const installedVersion = existingInstall.version || 'unknown';
|
||||
const installedVersion = existingInstall.installed ? existingInstall.version || 'unknown' : 'unknown';
|
||||
|
||||
// Build menu choices dynamically
|
||||
const choices = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue