@syntropysoft/praetorian
Version:
Praetorian CLI – A universal multi-environment configuration validator for DevSecOps teams. Validate, compare, and secure YAML/ENV files with ease.
97 lines • 2.72 kB
JavaScript
;
/**
* TODO: DECLARATIVE PROGRAMMING PATTERN
*
* This file demonstrates excellent declarative programming practices:
* - Pure functions with immutable data structures (Map)
* - Functional array methods (filter, map, every)
* - Immutable data transformations
* - Object spread operator for composition
* - No imperative loops or state mutations
* - Clear data flow with Array.from()
*
* Mutation Score: 89.66% - Functional patterns make testing predictable!
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.PluginManager = void 0;
class PluginManager {
constructor(options = {}) {
this.plugins = new Map();
this.options = {
autoLoad: false, // Plugin loading is now handled by PluginLoader
...options
};
}
/**
* Register a plugin
*/
registerPlugin(plugin) {
const metadata = plugin.getMetadata();
this.plugins.set(metadata.name, plugin);
}
/**
* Get a plugin by name
*/
getPlugin(name) {
return this.plugins.get(name);
}
/**
* Get all enabled plugins
*/
getEnabledPlugins() {
return Array.from(this.plugins.values()).filter(plugin => {
const metadata = plugin.getMetadata();
return metadata.enabled !== false;
});
}
/**
* Get all plugins (enabled and disabled)
*/
getAllPlugins() {
return Array.from(this.plugins.values());
}
/**
* Enable or disable a plugin
*/
setPluginEnabled(name, enabled) {
const plugin = this.plugins.get(name);
if (plugin) {
// TODO: Implement plugin enable/disable
return true;
}
return false;
}
/**
* Get plugin metadata
*/
getPluginMetadata(name) {
const plugin = this.plugins.get(name);
return plugin ? plugin.getMetadata() : undefined;
}
/**
* List all available plugins
*/
listPlugins() {
return Array.from(this.plugins.entries()).map(([name, plugin]) => ({
name,
metadata: plugin.getMetadata()
}));
}
/**
* Get plugin health status
*/
async getHealth() {
const plugins = this.getAllPlugins();
const healthResults = await Promise.all(plugins.map(async (plugin) => ({
name: plugin.getMetadata().name,
...(await plugin.getHealth())
})));
const healthy = healthResults.every(result => result.healthy);
return {
healthy,
plugins: healthResults
};
}
}
exports.PluginManager = PluginManager;
//# sourceMappingURL=PluginManager.js.map