feat: tea automation prereq prompts (#1649)
* feat: tea automation prereq prompts * fix: addressed PR comments * docs: added docs on how to set the post install output in the module * addressed PR request from Brian
This commit is contained in:
parent
e66bbd02f2
commit
3103c3d4ce
|
|
@ -550,6 +550,8 @@ class ConfigCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.displayModulePostConfigNotes(moduleName, moduleConfig);
|
||||||
|
|
||||||
return newKeys.length > 0 || newStaticKeys.length > 0; // Return true if we had any new fields (interactive or static)
|
return newKeys.length > 0 || newStaticKeys.length > 0; // Return true if we had any new fields (interactive or static)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -923,6 +925,8 @@ class ConfigCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.displayModulePostConfigNotes(moduleName, moduleConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1195,6 +1199,59 @@ class ConfigCollector {
|
||||||
return question;
|
return question;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display post-configuration notes for a module
|
||||||
|
* Shows prerequisite guidance based on collected config values
|
||||||
|
* Reads notes from the module's `post-install-notes` section in module.yaml
|
||||||
|
* Supports two formats:
|
||||||
|
* - Simple string: always displayed
|
||||||
|
* - Object keyed by config field name, with value-specific messages
|
||||||
|
* @param {string} moduleName - Module name
|
||||||
|
* @param {Object} moduleConfig - Parsed module.yaml content
|
||||||
|
*/
|
||||||
|
async displayModulePostConfigNotes(moduleName, moduleConfig) {
|
||||||
|
if (this._silentConfig) return;
|
||||||
|
if (!moduleConfig || !moduleConfig['post-install-notes']) return;
|
||||||
|
|
||||||
|
const notes = moduleConfig['post-install-notes'];
|
||||||
|
const color = await prompts.getColor();
|
||||||
|
|
||||||
|
// Format 1: Simple string - always display
|
||||||
|
if (typeof notes === 'string') {
|
||||||
|
await prompts.log.message('');
|
||||||
|
for (const line of notes.trim().split('\n')) {
|
||||||
|
await prompts.log.message(color.dim(line));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format 2: Conditional on config values
|
||||||
|
if (typeof notes === 'object') {
|
||||||
|
const config = this.collectedConfig[moduleName];
|
||||||
|
if (!config) return;
|
||||||
|
|
||||||
|
let hasOutput = false;
|
||||||
|
for (const [configKey, valueMessages] of Object.entries(notes)) {
|
||||||
|
const selectedValue = config[configKey];
|
||||||
|
if (!selectedValue || !valueMessages[selectedValue]) continue;
|
||||||
|
|
||||||
|
if (hasOutput) await prompts.log.message('');
|
||||||
|
hasOutput = true;
|
||||||
|
|
||||||
|
const message = valueMessages[selectedValue];
|
||||||
|
await prompts.log.message('');
|
||||||
|
for (const line of message.trim().split('\n')) {
|
||||||
|
const trimmedLine = line.trim();
|
||||||
|
if (trimmedLine.endsWith(':') && !trimmedLine.startsWith(' ')) {
|
||||||
|
await prompts.log.info(color.bold(trimmedLine));
|
||||||
|
} else {
|
||||||
|
await prompts.log.message(color.dim(' ' + trimmedLine));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deep merge two objects
|
* Deep merge two objects
|
||||||
* @param {Object} target - Target object
|
* @param {Object} target - Target object
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue