@o3r/schematics
Version:
Schematics module of the Otter framework
42 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.displayModuleListRule = displayModuleListRule;
const node_os_1 = require("node:os");
const index_1 = require("../utility/index");
const modules_constants_1 = require("./modules.constants");
const modules_helpers_1 = require("./modules.helpers");
/**
* Display the list of available Otter modules
* @param options Options of the Display Module list
*/
function displayModuleListRule(options) {
const scopeWhitelist = options?.scopeWhitelist || modules_constants_1.OTTER_MODULE_SUPPORTED_SCOPES;
const keyword = options?.keyword || modules_constants_1.OTTER_MODULE_KEYWORD;
return async (tree, context) => {
const tagMap = { [modules_constants_1.OTTER_KEYWORD_CMS]: 'CMS enabler' };
const workspaceConfig = (0, index_1.getWorkspaceConfig)(tree);
try {
const modules = await (0, modules_helpers_1.getAvailableModulesWithLatestPackage)(keyword, {
scopeWhitelist,
onlyNotInstalled: !!options?.onlyNotInstalledModules,
logger: context.logger,
workspaceConfig
});
const message = modules
.filter((mod) => !options?.onlyCmsModules || mod.keywords?.includes(modules_constants_1.OTTER_KEYWORD_CMS))
.map((mod) => (0, modules_helpers_1.formatModuleDescription)(mod, (0, index_1.getPackageManagerExecutor)(workspaceConfig, options?.packageName), tagMap))
.filter((msg) => !!msg)
.join(node_os_1.EOL + node_os_1.EOL);
if (message) {
context.logger.info('The following modules are now available for your application, add them according to your needs:');
context.logger.info(node_os_1.EOL + message);
}
}
catch (e) {
context.logger.debug('Error during the module discovery', e);
context.logger.error('List of Otter modules unavailable');
}
return () => tree;
};
}
//# sourceMappingURL=modules.display.rule.js.map