@casoon/auditmysite
Version:
Professional website analysis suite with robust accessibility testing, Core Web Vitals performance monitoring, SEO analysis, and content optimization insights. Features isolated browser contexts, retry mechanisms, and comprehensive API endpoints for profe
108 lines • 2.75 kB
JavaScript
;
/**
* 🔧 Command Registry
*
* Central registry for all CLI commands.
* Manages command registration, validation, and execution.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandRegistry = void 0;
const audit_command_1 = require("./commands/audit-command");
class CommandRegistry {
constructor() {
this.commands = new Map();
this.registerBuiltinCommands();
}
/**
* Register built-in commands
*/
registerBuiltinCommands() {
this.register(new audit_command_1.AuditCommand());
// Future commands can be registered here:
// this.register(new InitCommand());
// this.register(new ValidateCommand());
// this.register(new ConfigCommand());
}
/**
* Register a new command
*/
register(command) {
const name = command.getName();
if (this.commands.has(name)) {
throw new Error(`Command '${name}' is already registered`);
}
this.commands.set(name, command);
}
/**
* Get a command by name
*/
getCommand(name) {
return this.commands.get(name);
}
/**
* Check if command exists
*/
hasCommand(name) {
return this.commands.has(name);
}
/**
* Get all registered commands
*/
getCommands() {
return new Map(this.commands);
}
/**
* Execute a command
*/
async executeCommand(name, args) {
const command = this.getCommand(name);
if (!command) {
return {
success: false,
message: `Unknown command: ${name}`,
exitCode: 1
};
}
try {
return await command.execute(args);
}
catch (error) {
return {
success: false,
message: `Command execution failed: ${error instanceof Error ? error.message : String(error)}`,
exitCode: 1
};
}
}
/**
* Get help information for all commands
*/
getHelpText() {
const lines = [];
lines.push('Available commands:\n');
for (const [name, command] of this.commands) {
lines.push(` ${name.padEnd(20)} ${command.getDescription()}`);
}
return lines.join('\n');
}
/**
* Unregister a command
*/
unregister(name) {
return this.commands.delete(name);
}
/**
* Clear all commands
*/
clear() {
this.commands.clear();
}
/**
* Get command count
*/
size() {
return this.commands.size;
}
}
exports.CommandRegistry = CommandRegistry;
//# sourceMappingURL=command-registry.js.map